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 printf("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 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 printf("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 <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 printf("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 printf("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 printf("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 printf("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 printf("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 printf("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 printf("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 printf("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 printf("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 printf("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 printf("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 printf("Please stop all ports first\n");
1815 if (!strcmp(res->name, "rxq")) {
1816 if (!res->value && !nb_txq) {
1817 printf("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 printf("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 printf("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 printf("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) {
1909 printf("max-pkt-len can not be less than %d\n",
1913 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1916 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1918 printf("rte_eth_dev_info_get() failed for port %u\n",
1923 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1925 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1926 if (update_jumbo_frame_offload(pid) != 0)
1927 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1929 printf("Unknown parameter\n");
1936 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1939 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1942 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1943 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1945 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1946 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1948 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1949 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1951 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1952 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1955 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1956 .f = cmd_config_max_pkt_len_parsed,
1958 .help_str = "port config all max-pkt-len <value>",
1960 (void *)&cmd_config_max_pkt_len_port,
1961 (void *)&cmd_config_max_pkt_len_keyword,
1962 (void *)&cmd_config_max_pkt_len_all,
1963 (void *)&cmd_config_max_pkt_len_name,
1964 (void *)&cmd_config_max_pkt_len_value,
1969 /* *** config max LRO aggregated packet size *** */
1970 struct cmd_config_max_lro_pkt_size_result {
1971 cmdline_fixed_string_t port;
1972 cmdline_fixed_string_t keyword;
1973 cmdline_fixed_string_t all;
1974 cmdline_fixed_string_t name;
1979 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1980 __rte_unused struct cmdline *cl,
1981 __rte_unused void *data)
1983 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1986 if (!all_ports_stopped()) {
1987 printf("Please stop all ports first\n");
1991 RTE_ETH_FOREACH_DEV(pid) {
1992 struct rte_port *port = &ports[pid];
1994 if (!strcmp(res->name, "max-lro-pkt-size")) {
1996 port->dev_conf.rxmode.max_lro_pkt_size)
1999 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2001 printf("Unknown parameter\n");
2008 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2011 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2012 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2014 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2015 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2017 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2018 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2020 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2021 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2022 name, "max-lro-pkt-size");
2023 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2024 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2027 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2028 .f = cmd_config_max_lro_pkt_size_parsed,
2030 .help_str = "port config all max-lro-pkt-size <value>",
2032 (void *)&cmd_config_max_lro_pkt_size_port,
2033 (void *)&cmd_config_max_lro_pkt_size_keyword,
2034 (void *)&cmd_config_max_lro_pkt_size_all,
2035 (void *)&cmd_config_max_lro_pkt_size_name,
2036 (void *)&cmd_config_max_lro_pkt_size_value,
2041 /* *** configure port MTU *** */
2042 struct cmd_config_mtu_result {
2043 cmdline_fixed_string_t port;
2044 cmdline_fixed_string_t keyword;
2045 cmdline_fixed_string_t mtu;
2051 cmd_config_mtu_parsed(void *parsed_result,
2052 __rte_unused struct cmdline *cl,
2053 __rte_unused void *data)
2055 struct cmd_config_mtu_result *res = parsed_result;
2057 if (res->value < RTE_ETHER_MIN_LEN) {
2058 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2061 port_mtu_set(res->port_id, res->value);
2064 cmdline_parse_token_string_t cmd_config_mtu_port =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2067 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2068 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2070 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2071 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2073 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2074 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2076 cmdline_parse_token_num_t cmd_config_mtu_value =
2077 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2080 cmdline_parse_inst_t cmd_config_mtu = {
2081 .f = cmd_config_mtu_parsed,
2083 .help_str = "port config mtu <port_id> <value>",
2085 (void *)&cmd_config_mtu_port,
2086 (void *)&cmd_config_mtu_keyword,
2087 (void *)&cmd_config_mtu_mtu,
2088 (void *)&cmd_config_mtu_port_id,
2089 (void *)&cmd_config_mtu_value,
2094 /* *** configure rx mode *** */
2095 struct cmd_config_rx_mode_flag {
2096 cmdline_fixed_string_t port;
2097 cmdline_fixed_string_t keyword;
2098 cmdline_fixed_string_t all;
2099 cmdline_fixed_string_t name;
2100 cmdline_fixed_string_t value;
2104 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2105 __rte_unused struct cmdline *cl,
2106 __rte_unused void *data)
2108 struct cmd_config_rx_mode_flag *res = parsed_result;
2110 if (!all_ports_stopped()) {
2111 printf("Please stop all ports first\n");
2115 if (!strcmp(res->name, "drop-en")) {
2116 if (!strcmp(res->value, "on"))
2118 else if (!strcmp(res->value, "off"))
2121 printf("Unknown parameter\n");
2125 printf("Unknown parameter\n");
2131 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2134 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2135 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2139 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2141 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2142 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2144 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2145 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2148 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2149 .f = cmd_config_rx_mode_flag_parsed,
2151 .help_str = "port config all drop-en on|off",
2153 (void *)&cmd_config_rx_mode_flag_port,
2154 (void *)&cmd_config_rx_mode_flag_keyword,
2155 (void *)&cmd_config_rx_mode_flag_all,
2156 (void *)&cmd_config_rx_mode_flag_name,
2157 (void *)&cmd_config_rx_mode_flag_value,
2162 /* *** configure rss *** */
2163 struct cmd_config_rss {
2164 cmdline_fixed_string_t port;
2165 cmdline_fixed_string_t keyword;
2166 cmdline_fixed_string_t all;
2167 cmdline_fixed_string_t name;
2168 cmdline_fixed_string_t value;
2172 cmd_config_rss_parsed(void *parsed_result,
2173 __rte_unused struct cmdline *cl,
2174 __rte_unused void *data)
2176 struct cmd_config_rss *res = parsed_result;
2177 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2178 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2179 int use_default = 0;
2180 int all_updated = 1;
2185 if (!strcmp(res->value, "all"))
2186 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2187 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2188 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2189 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2191 else if (!strcmp(res->value, "eth"))
2192 rss_conf.rss_hf = ETH_RSS_ETH;
2193 else if (!strcmp(res->value, "vlan"))
2194 rss_conf.rss_hf = ETH_RSS_VLAN;
2195 else if (!strcmp(res->value, "ip"))
2196 rss_conf.rss_hf = ETH_RSS_IP;
2197 else if (!strcmp(res->value, "udp"))
2198 rss_conf.rss_hf = ETH_RSS_UDP;
2199 else if (!strcmp(res->value, "tcp"))
2200 rss_conf.rss_hf = ETH_RSS_TCP;
2201 else if (!strcmp(res->value, "sctp"))
2202 rss_conf.rss_hf = ETH_RSS_SCTP;
2203 else if (!strcmp(res->value, "ether"))
2204 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2205 else if (!strcmp(res->value, "port"))
2206 rss_conf.rss_hf = ETH_RSS_PORT;
2207 else if (!strcmp(res->value, "vxlan"))
2208 rss_conf.rss_hf = ETH_RSS_VXLAN;
2209 else if (!strcmp(res->value, "geneve"))
2210 rss_conf.rss_hf = ETH_RSS_GENEVE;
2211 else if (!strcmp(res->value, "nvgre"))
2212 rss_conf.rss_hf = ETH_RSS_NVGRE;
2213 else if (!strcmp(res->value, "l3-pre32"))
2214 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2215 else if (!strcmp(res->value, "l3-pre40"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2217 else if (!strcmp(res->value, "l3-pre48"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2219 else if (!strcmp(res->value, "l3-pre56"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2221 else if (!strcmp(res->value, "l3-pre64"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2223 else if (!strcmp(res->value, "l3-pre96"))
2224 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2225 else if (!strcmp(res->value, "l3-src-only"))
2226 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2227 else if (!strcmp(res->value, "l3-dst-only"))
2228 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2229 else if (!strcmp(res->value, "l4-src-only"))
2230 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2231 else if (!strcmp(res->value, "l4-dst-only"))
2232 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2233 else if (!strcmp(res->value, "l2-src-only"))
2234 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2235 else if (!strcmp(res->value, "l2-dst-only"))
2236 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2237 else if (!strcmp(res->value, "l2tpv3"))
2238 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2239 else if (!strcmp(res->value, "esp"))
2240 rss_conf.rss_hf = ETH_RSS_ESP;
2241 else if (!strcmp(res->value, "ah"))
2242 rss_conf.rss_hf = ETH_RSS_AH;
2243 else if (!strcmp(res->value, "pfcp"))
2244 rss_conf.rss_hf = ETH_RSS_PFCP;
2245 else if (!strcmp(res->value, "pppoe"))
2246 rss_conf.rss_hf = ETH_RSS_PPPOE;
2247 else if (!strcmp(res->value, "gtpu"))
2248 rss_conf.rss_hf = ETH_RSS_GTPU;
2249 else if (!strcmp(res->value, "ecpri"))
2250 rss_conf.rss_hf = ETH_RSS_ECPRI;
2251 else if (!strcmp(res->value, "mpls"))
2252 rss_conf.rss_hf = ETH_RSS_MPLS;
2253 else if (!strcmp(res->value, "none"))
2254 rss_conf.rss_hf = 0;
2255 else if (!strcmp(res->value, "level-default")) {
2256 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2257 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2258 } else if (!strcmp(res->value, "level-outer")) {
2259 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2260 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2261 } else if (!strcmp(res->value, "level-inner")) {
2262 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2263 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2264 } else if (!strcmp(res->value, "default"))
2266 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2267 atoi(res->value) < 64)
2268 rss_conf.rss_hf = 1ULL << atoi(res->value);
2270 printf("Unknown parameter\n");
2273 rss_conf.rss_key = NULL;
2274 /* Update global configuration for RSS types. */
2275 RTE_ETH_FOREACH_DEV(i) {
2276 struct rte_eth_rss_conf local_rss_conf;
2278 ret = eth_dev_info_get_print_err(i, &dev_info);
2283 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2285 local_rss_conf = rss_conf;
2286 local_rss_conf.rss_hf = rss_conf.rss_hf &
2287 dev_info.flow_type_rss_offloads;
2288 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2289 printf("Port %u modified RSS hash function based on hardware support,"
2290 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2291 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2293 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2296 printf("Configuration of RSS hash at ethernet port %d "
2297 "failed with error (%d): %s.\n",
2298 i, -diag, strerror(-diag));
2301 if (all_updated && !use_default) {
2302 rss_hf = rss_conf.rss_hf;
2303 printf("rss_hf %#"PRIx64"\n", rss_hf);
2307 cmdline_parse_token_string_t cmd_config_rss_port =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2309 cmdline_parse_token_string_t cmd_config_rss_keyword =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2311 cmdline_parse_token_string_t cmd_config_rss_all =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2313 cmdline_parse_token_string_t cmd_config_rss_name =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2315 cmdline_parse_token_string_t cmd_config_rss_value =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2318 cmdline_parse_inst_t cmd_config_rss = {
2319 .f = cmd_config_rss_parsed,
2321 .help_str = "port config all rss "
2322 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2323 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2324 "level-outer|level-inner|<flowtype_id>",
2326 (void *)&cmd_config_rss_port,
2327 (void *)&cmd_config_rss_keyword,
2328 (void *)&cmd_config_rss_all,
2329 (void *)&cmd_config_rss_name,
2330 (void *)&cmd_config_rss_value,
2335 /* *** configure rss hash key *** */
2336 struct cmd_config_rss_hash_key {
2337 cmdline_fixed_string_t port;
2338 cmdline_fixed_string_t config;
2340 cmdline_fixed_string_t rss_hash_key;
2341 cmdline_fixed_string_t rss_type;
2342 cmdline_fixed_string_t key;
2346 hexa_digit_to_value(char hexa_digit)
2348 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2349 return (uint8_t) (hexa_digit - '0');
2350 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2351 return (uint8_t) ((hexa_digit - 'a') + 10);
2352 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2353 return (uint8_t) ((hexa_digit - 'A') + 10);
2354 /* Invalid hexa digit */
2359 parse_and_check_key_hexa_digit(char *key, int idx)
2363 hexa_v = hexa_digit_to_value(key[idx]);
2365 printf("invalid key: character %c at position %d is not a "
2366 "valid hexa digit\n", key[idx], idx);
2371 cmd_config_rss_hash_key_parsed(void *parsed_result,
2372 __rte_unused struct cmdline *cl,
2373 __rte_unused void *data)
2375 struct cmd_config_rss_hash_key *res = parsed_result;
2376 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2380 struct rte_eth_dev_info dev_info;
2381 uint8_t hash_key_size;
2385 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2389 if (dev_info.hash_key_size > 0 &&
2390 dev_info.hash_key_size <= sizeof(hash_key))
2391 hash_key_size = dev_info.hash_key_size;
2393 printf("dev_info did not provide a valid hash key size\n");
2396 /* Check the length of the RSS hash key */
2397 key_len = strlen(res->key);
2398 if (key_len != (hash_key_size * 2)) {
2399 printf("key length: %d invalid - key must be a string of %d"
2400 " hexa-decimal numbers\n",
2401 (int) key_len, hash_key_size * 2);
2404 /* Translate RSS hash key into binary representation */
2405 for (i = 0; i < hash_key_size; i++) {
2406 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2409 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2412 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2414 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2418 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2420 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2421 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2423 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2424 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2426 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2427 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2428 rss_hash_key, "rss-hash-key");
2429 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2430 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2431 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2432 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2433 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2434 "ipv6-tcp-ex#ipv6-udp-ex#"
2435 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2436 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2437 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2438 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2439 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2441 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2442 .f = cmd_config_rss_hash_key_parsed,
2444 .help_str = "port config <port_id> rss-hash-key "
2445 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2446 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2447 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2448 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2449 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2450 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2451 "<string of hex digits (variable length, NIC dependent)>",
2453 (void *)&cmd_config_rss_hash_key_port,
2454 (void *)&cmd_config_rss_hash_key_config,
2455 (void *)&cmd_config_rss_hash_key_port_id,
2456 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2457 (void *)&cmd_config_rss_hash_key_rss_type,
2458 (void *)&cmd_config_rss_hash_key_value,
2463 /* *** cleanup txq mbufs *** */
2464 struct cmd_cleanup_txq_mbufs_result {
2465 cmdline_fixed_string_t port;
2466 cmdline_fixed_string_t keyword;
2467 cmdline_fixed_string_t name;
2474 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2475 __rte_unused struct cmdline *cl,
2476 __rte_unused void *data)
2478 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2479 uint16_t port_id = res->port_id;
2480 uint16_t queue_id = res->queue_id;
2481 uint32_t free_cnt = res->free_cnt;
2482 struct rte_eth_txq_info qinfo;
2485 if (test_done == 0) {
2486 printf("Please stop forwarding first\n");
2490 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2491 printf("Failed to get port %u Tx queue %u info\n",
2496 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2497 printf("Tx queue %u not started\n", queue_id);
2501 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2503 printf("Failed to cleanup mbuf for port %u Tx queue %u "
2504 "error desc: %s(%d)\n",
2505 port_id, queue_id, strerror(-ret), ret);
2509 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2510 port_id, queue_id, ret);
2513 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2514 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2516 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2517 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2519 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2520 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2522 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2523 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2525 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2526 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2528 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2529 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2532 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2533 .f = cmd_cleanup_txq_mbufs_parsed,
2535 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2537 (void *)&cmd_cleanup_txq_mbufs_port,
2538 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2539 (void *)&cmd_cleanup_txq_mbufs_port_id,
2540 (void *)&cmd_cleanup_txq_mbufs_txq,
2541 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2542 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2547 /* *** configure port rxq/txq ring size *** */
2548 struct cmd_config_rxtx_ring_size {
2549 cmdline_fixed_string_t port;
2550 cmdline_fixed_string_t config;
2552 cmdline_fixed_string_t rxtxq;
2554 cmdline_fixed_string_t rsize;
2559 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2560 __rte_unused struct cmdline *cl,
2561 __rte_unused void *data)
2563 struct cmd_config_rxtx_ring_size *res = parsed_result;
2564 struct rte_port *port;
2567 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2570 if (res->portid == (portid_t)RTE_PORT_ALL) {
2571 printf("Invalid port id\n");
2575 port = &ports[res->portid];
2577 if (!strcmp(res->rxtxq, "rxq"))
2579 else if (!strcmp(res->rxtxq, "txq"))
2582 printf("Unknown parameter\n");
2586 if (isrx && rx_queue_id_is_invalid(res->qid))
2588 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2591 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2592 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2598 port->nb_rx_desc[res->qid] = res->size;
2600 port->nb_tx_desc[res->qid] = res->size;
2602 cmd_reconfig_device_queue(res->portid, 0, 1);
2605 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2606 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2608 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2609 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2611 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2612 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2613 portid, RTE_UINT16);
2614 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2615 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2617 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2618 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2620 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2621 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2622 rsize, "ring_size");
2623 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2624 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2627 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2628 .f = cmd_config_rxtx_ring_size_parsed,
2630 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2632 (void *)&cmd_config_rxtx_ring_size_port,
2633 (void *)&cmd_config_rxtx_ring_size_config,
2634 (void *)&cmd_config_rxtx_ring_size_portid,
2635 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2636 (void *)&cmd_config_rxtx_ring_size_qid,
2637 (void *)&cmd_config_rxtx_ring_size_rsize,
2638 (void *)&cmd_config_rxtx_ring_size_size,
2643 /* *** configure port rxq/txq start/stop *** */
2644 struct cmd_config_rxtx_queue {
2645 cmdline_fixed_string_t port;
2647 cmdline_fixed_string_t rxtxq;
2649 cmdline_fixed_string_t opname;
2653 cmd_config_rxtx_queue_parsed(void *parsed_result,
2654 __rte_unused struct cmdline *cl,
2655 __rte_unused void *data)
2657 struct cmd_config_rxtx_queue *res = parsed_result;
2662 if (test_done == 0) {
2663 printf("Please stop forwarding first\n");
2667 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2670 if (port_is_started(res->portid) != 1) {
2671 printf("Please start port %u first\n", res->portid);
2675 if (!strcmp(res->rxtxq, "rxq"))
2677 else if (!strcmp(res->rxtxq, "txq"))
2680 printf("Unknown parameter\n");
2684 if (isrx && rx_queue_id_is_invalid(res->qid))
2686 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2689 if (!strcmp(res->opname, "start"))
2691 else if (!strcmp(res->opname, "stop"))
2694 printf("Unknown parameter\n");
2698 if (isstart && isrx)
2699 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2700 else if (!isstart && isrx)
2701 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2702 else if (isstart && !isrx)
2703 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2705 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2707 if (ret == -ENOTSUP)
2708 printf("Function not supported in PMD driver\n");
2711 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2712 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2713 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2714 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2715 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2716 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2717 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2718 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2719 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2720 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2723 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2724 .f = cmd_config_rxtx_queue_parsed,
2726 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2728 (void *)&cmd_config_rxtx_queue_port,
2729 (void *)&cmd_config_rxtx_queue_portid,
2730 (void *)&cmd_config_rxtx_queue_rxtxq,
2731 (void *)&cmd_config_rxtx_queue_qid,
2732 (void *)&cmd_config_rxtx_queue_opname,
2737 /* *** configure port rxq/txq deferred start on/off *** */
2738 struct cmd_config_deferred_start_rxtx_queue {
2739 cmdline_fixed_string_t port;
2741 cmdline_fixed_string_t rxtxq;
2743 cmdline_fixed_string_t opname;
2744 cmdline_fixed_string_t state;
2748 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2749 __rte_unused struct cmdline *cl,
2750 __rte_unused void *data)
2752 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2753 struct rte_port *port;
2756 uint8_t needreconfig = 0;
2758 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2761 if (port_is_started(res->port_id) != 0) {
2762 printf("Please stop port %u first\n", res->port_id);
2766 port = &ports[res->port_id];
2768 isrx = !strcmp(res->rxtxq, "rxq");
2770 if (isrx && rx_queue_id_is_invalid(res->qid))
2772 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2775 ison = !strcmp(res->state, "on");
2777 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2778 port->rx_conf[res->qid].rx_deferred_start = ison;
2780 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2781 port->tx_conf[res->qid].tx_deferred_start = ison;
2786 cmd_reconfig_device_queue(res->port_id, 0, 1);
2789 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2790 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2792 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2793 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2794 port_id, RTE_UINT16);
2795 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2796 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2798 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2799 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2801 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2802 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2803 opname, "deferred_start");
2804 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2805 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2808 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2809 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2811 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2813 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2814 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2815 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2816 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2817 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2818 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2823 /* *** configure port rxq/txq setup *** */
2824 struct cmd_setup_rxtx_queue {
2825 cmdline_fixed_string_t port;
2827 cmdline_fixed_string_t rxtxq;
2829 cmdline_fixed_string_t setup;
2832 /* Common CLI fields for queue setup */
2833 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2834 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2835 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2836 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2837 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2838 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2839 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2840 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2841 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2842 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2845 cmd_setup_rxtx_queue_parsed(
2846 void *parsed_result,
2847 __rte_unused struct cmdline *cl,
2848 __rte_unused void *data)
2850 struct cmd_setup_rxtx_queue *res = parsed_result;
2851 struct rte_port *port;
2852 struct rte_mempool *mp;
2853 unsigned int socket_id;
2857 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2860 if (res->portid == (portid_t)RTE_PORT_ALL) {
2861 printf("Invalid port id\n");
2865 if (!strcmp(res->rxtxq, "rxq"))
2867 else if (!strcmp(res->rxtxq, "txq"))
2870 printf("Unknown parameter\n");
2874 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2875 printf("Invalid rx queue\n");
2877 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2878 printf("Invalid tx queue\n");
2882 port = &ports[res->portid];
2884 socket_id = rxring_numa[res->portid];
2885 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2886 socket_id = port->socket_id;
2888 mp = mbuf_pool_find(socket_id, 0);
2890 printf("Failed to setup RX queue: "
2891 "No mempool allocation"
2892 " on the socket %d\n",
2893 rxring_numa[res->portid]);
2896 ret = rx_queue_setup(res->portid,
2898 port->nb_rx_desc[res->qid],
2900 &port->rx_conf[res->qid],
2903 printf("Failed to setup RX queue\n");
2905 socket_id = txring_numa[res->portid];
2906 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2907 socket_id = port->socket_id;
2909 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2910 printf("Failed to setup TX queue: not enough descriptors\n");
2913 ret = rte_eth_tx_queue_setup(res->portid,
2915 port->nb_tx_desc[res->qid],
2917 &port->tx_conf[res->qid]);
2919 printf("Failed to setup TX queue\n");
2923 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2924 .f = cmd_setup_rxtx_queue_parsed,
2926 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2928 (void *)&cmd_setup_rxtx_queue_port,
2929 (void *)&cmd_setup_rxtx_queue_portid,
2930 (void *)&cmd_setup_rxtx_queue_rxtxq,
2931 (void *)&cmd_setup_rxtx_queue_qid,
2932 (void *)&cmd_setup_rxtx_queue_setup,
2938 /* *** Configure RSS RETA *** */
2939 struct cmd_config_rss_reta {
2940 cmdline_fixed_string_t port;
2941 cmdline_fixed_string_t keyword;
2943 cmdline_fixed_string_t name;
2944 cmdline_fixed_string_t list_name;
2945 cmdline_fixed_string_t list_of_items;
2949 parse_reta_config(const char *str,
2950 struct rte_eth_rss_reta_entry64 *reta_conf,
2951 uint16_t nb_entries)
2955 uint16_t hash_index, idx, shift;
2958 const char *p, *p0 = str;
2965 unsigned long int_fld[_NUM_FLD];
2966 char *str_fld[_NUM_FLD];
2968 while ((p = strchr(p0,'(')) != NULL) {
2970 if((p0 = strchr(p,')')) == NULL)
2974 if(size >= sizeof(s))
2977 snprintf(s, sizeof(s), "%.*s", size, p);
2978 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2980 for (i = 0; i < _NUM_FLD; i++) {
2982 int_fld[i] = strtoul(str_fld[i], &end, 0);
2983 if (errno != 0 || end == str_fld[i] ||
2988 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2989 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2991 if (hash_index >= nb_entries) {
2992 printf("Invalid RETA hash index=%d\n", hash_index);
2996 idx = hash_index / RTE_RETA_GROUP_SIZE;
2997 shift = hash_index % RTE_RETA_GROUP_SIZE;
2998 reta_conf[idx].mask |= (1ULL << shift);
2999 reta_conf[idx].reta[shift] = nb_queue;
3006 cmd_set_rss_reta_parsed(void *parsed_result,
3007 __rte_unused struct cmdline *cl,
3008 __rte_unused void *data)
3011 struct rte_eth_dev_info dev_info;
3012 struct rte_eth_rss_reta_entry64 reta_conf[8];
3013 struct cmd_config_rss_reta *res = parsed_result;
3015 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3019 if (dev_info.reta_size == 0) {
3020 printf("Redirection table size is 0 which is "
3021 "invalid for RSS\n");
3024 printf("The reta size of port %d is %u\n",
3025 res->port_id, dev_info.reta_size);
3026 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3027 printf("Currently do not support more than %u entries of "
3028 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3032 memset(reta_conf, 0, sizeof(reta_conf));
3033 if (!strcmp(res->list_name, "reta")) {
3034 if (parse_reta_config(res->list_of_items, reta_conf,
3035 dev_info.reta_size)) {
3036 printf("Invalid RSS Redirection Table "
3037 "config entered\n");
3040 ret = rte_eth_dev_rss_reta_update(res->port_id,
3041 reta_conf, dev_info.reta_size);
3043 printf("Bad redirection table parameter, "
3044 "return code = %d \n", ret);
3048 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3049 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3050 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3051 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3052 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3053 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3054 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3056 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3058 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3061 cmdline_parse_inst_t cmd_config_rss_reta = {
3062 .f = cmd_set_rss_reta_parsed,
3064 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3066 (void *)&cmd_config_rss_reta_port,
3067 (void *)&cmd_config_rss_reta_keyword,
3068 (void *)&cmd_config_rss_reta_port_id,
3069 (void *)&cmd_config_rss_reta_name,
3070 (void *)&cmd_config_rss_reta_list_name,
3071 (void *)&cmd_config_rss_reta_list_of_items,
3076 /* *** SHOW PORT RETA INFO *** */
3077 struct cmd_showport_reta {
3078 cmdline_fixed_string_t show;
3079 cmdline_fixed_string_t port;
3081 cmdline_fixed_string_t rss;
3082 cmdline_fixed_string_t reta;
3084 cmdline_fixed_string_t list_of_items;
3088 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3089 uint16_t nb_entries,
3093 const char *p, *p0 = str;
3098 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3099 RTE_RETA_GROUP_SIZE;
3102 p = strchr(p0, '(');
3106 p0 = strchr(p, ')');
3110 if (size >= sizeof(s)) {
3111 printf("The string size exceeds the internal buffer size\n");
3114 snprintf(s, sizeof(s), "%.*s", size, p);
3115 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3116 if (ret <= 0 || ret != num) {
3117 printf("The bits of masks do not match the number of "
3118 "reta entries: %u\n", num);
3121 for (i = 0; i < ret; i++)
3122 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3128 cmd_showport_reta_parsed(void *parsed_result,
3129 __rte_unused struct cmdline *cl,
3130 __rte_unused void *data)
3132 struct cmd_showport_reta *res = parsed_result;
3133 struct rte_eth_rss_reta_entry64 reta_conf[8];
3134 struct rte_eth_dev_info dev_info;
3135 uint16_t max_reta_size;
3138 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3142 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3143 if (res->size == 0 || res->size > max_reta_size) {
3144 printf("Invalid redirection table size: %u (1-%u)\n",
3145 res->size, max_reta_size);
3149 memset(reta_conf, 0, sizeof(reta_conf));
3150 if (showport_parse_reta_config(reta_conf, res->size,
3151 res->list_of_items) < 0) {
3152 printf("Invalid string: %s for reta masks\n",
3153 res->list_of_items);
3156 port_rss_reta_info(res->port_id, reta_conf, res->size);
3159 cmdline_parse_token_string_t cmd_showport_reta_show =
3160 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3161 cmdline_parse_token_string_t cmd_showport_reta_port =
3162 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3163 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3164 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3165 cmdline_parse_token_string_t cmd_showport_reta_rss =
3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3167 cmdline_parse_token_string_t cmd_showport_reta_reta =
3168 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3169 cmdline_parse_token_num_t cmd_showport_reta_size =
3170 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3171 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3173 list_of_items, NULL);
3175 cmdline_parse_inst_t cmd_showport_reta = {
3176 .f = cmd_showport_reta_parsed,
3178 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3180 (void *)&cmd_showport_reta_show,
3181 (void *)&cmd_showport_reta_port,
3182 (void *)&cmd_showport_reta_port_id,
3183 (void *)&cmd_showport_reta_rss,
3184 (void *)&cmd_showport_reta_reta,
3185 (void *)&cmd_showport_reta_size,
3186 (void *)&cmd_showport_reta_list_of_items,
3191 /* *** Show RSS hash configuration *** */
3192 struct cmd_showport_rss_hash {
3193 cmdline_fixed_string_t show;
3194 cmdline_fixed_string_t port;
3196 cmdline_fixed_string_t rss_hash;
3197 cmdline_fixed_string_t rss_type;
3198 cmdline_fixed_string_t key; /* optional argument */
3201 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3202 __rte_unused struct cmdline *cl,
3205 struct cmd_showport_rss_hash *res = parsed_result;
3207 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3210 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3211 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3212 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3213 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3214 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3215 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3217 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3218 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3220 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3221 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3223 cmdline_parse_inst_t cmd_showport_rss_hash = {
3224 .f = cmd_showport_rss_hash_parsed,
3226 .help_str = "show port <port_id> rss-hash",
3228 (void *)&cmd_showport_rss_hash_show,
3229 (void *)&cmd_showport_rss_hash_port,
3230 (void *)&cmd_showport_rss_hash_port_id,
3231 (void *)&cmd_showport_rss_hash_rss_hash,
3236 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3237 .f = cmd_showport_rss_hash_parsed,
3239 .help_str = "show port <port_id> rss-hash key",
3241 (void *)&cmd_showport_rss_hash_show,
3242 (void *)&cmd_showport_rss_hash_port,
3243 (void *)&cmd_showport_rss_hash_port_id,
3244 (void *)&cmd_showport_rss_hash_rss_hash,
3245 (void *)&cmd_showport_rss_hash_rss_key,
3250 /* *** Configure DCB *** */
3251 struct cmd_config_dcb {
3252 cmdline_fixed_string_t port;
3253 cmdline_fixed_string_t config;
3255 cmdline_fixed_string_t dcb;
3256 cmdline_fixed_string_t vt;
3257 cmdline_fixed_string_t vt_en;
3259 cmdline_fixed_string_t pfc;
3260 cmdline_fixed_string_t pfc_en;
3264 cmd_config_dcb_parsed(void *parsed_result,
3265 __rte_unused struct cmdline *cl,
3266 __rte_unused void *data)
3268 struct cmd_config_dcb *res = parsed_result;
3269 struct rte_eth_dcb_info dcb_info;
3270 portid_t port_id = res->port_id;
3271 struct rte_port *port;
3275 port = &ports[port_id];
3276 /** Check if the port is not started **/
3277 if (port->port_status != RTE_PORT_STOPPED) {
3278 printf("Please stop port %d first\n", port_id);
3282 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3283 printf("The invalid number of traffic class,"
3284 " only 4 or 8 allowed.\n");
3288 if (nb_fwd_lcores < res->num_tcs) {
3289 printf("nb_cores shouldn't be less than number of TCs.\n");
3293 /* Check whether the port supports the report of DCB info. */
3294 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3295 if (ret == -ENOTSUP) {
3296 printf("rte_eth_dev_get_dcb_info not supported.\n");
3300 if (!strncmp(res->pfc_en, "on", 2))
3305 /* DCB in VT mode */
3306 if (!strncmp(res->vt_en, "on", 2))
3307 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3308 (enum rte_eth_nb_tcs)res->num_tcs,
3311 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3312 (enum rte_eth_nb_tcs)res->num_tcs,
3315 printf("Cannot initialize network ports.\n");
3321 cmd_reconfig_device_queue(port_id, 1, 1);
3324 cmdline_parse_token_string_t cmd_config_dcb_port =
3325 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3326 cmdline_parse_token_string_t cmd_config_dcb_config =
3327 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3328 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3329 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3330 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3331 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3332 cmdline_parse_token_string_t cmd_config_dcb_vt =
3333 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3334 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3336 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3337 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3338 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3339 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3340 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3341 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3343 cmdline_parse_inst_t cmd_config_dcb = {
3344 .f = cmd_config_dcb_parsed,
3346 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3348 (void *)&cmd_config_dcb_port,
3349 (void *)&cmd_config_dcb_config,
3350 (void *)&cmd_config_dcb_port_id,
3351 (void *)&cmd_config_dcb_dcb,
3352 (void *)&cmd_config_dcb_vt,
3353 (void *)&cmd_config_dcb_vt_en,
3354 (void *)&cmd_config_dcb_num_tcs,
3355 (void *)&cmd_config_dcb_pfc,
3356 (void *)&cmd_config_dcb_pfc_en,
3361 /* *** configure number of packets per burst *** */
3362 struct cmd_config_burst {
3363 cmdline_fixed_string_t port;
3364 cmdline_fixed_string_t keyword;
3365 cmdline_fixed_string_t all;
3366 cmdline_fixed_string_t name;
3371 cmd_config_burst_parsed(void *parsed_result,
3372 __rte_unused struct cmdline *cl,
3373 __rte_unused void *data)
3375 struct cmd_config_burst *res = parsed_result;
3376 struct rte_eth_dev_info dev_info;
3377 uint16_t rec_nb_pkts;
3380 if (!all_ports_stopped()) {
3381 printf("Please stop all ports first\n");
3385 if (!strcmp(res->name, "burst")) {
3386 if (res->value == 0) {
3387 /* If user gives a value of zero, query the PMD for
3388 * its recommended Rx burst size. Testpmd uses a single
3389 * size for all ports, so assume all ports are the same
3390 * NIC model and use the values from Port 0.
3392 ret = eth_dev_info_get_print_err(0, &dev_info);
3396 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3398 if (rec_nb_pkts == 0) {
3399 printf("PMD does not recommend a burst size.\n"
3400 "User provided value must be between"
3401 " 1 and %d\n", MAX_PKT_BURST);
3403 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3404 printf("PMD recommended burst size of %d"
3405 " exceeds maximum value of %d\n",
3406 rec_nb_pkts, MAX_PKT_BURST);
3409 printf("Using PMD-provided burst value of %d\n",
3411 nb_pkt_per_burst = rec_nb_pkts;
3412 } else if (res->value > MAX_PKT_BURST) {
3413 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3416 nb_pkt_per_burst = res->value;
3418 printf("Unknown parameter\n");
3424 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3427 cmdline_parse_token_string_t cmd_config_burst_port =
3428 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3429 cmdline_parse_token_string_t cmd_config_burst_keyword =
3430 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3431 cmdline_parse_token_string_t cmd_config_burst_all =
3432 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3433 cmdline_parse_token_string_t cmd_config_burst_name =
3434 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3435 cmdline_parse_token_num_t cmd_config_burst_value =
3436 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3438 cmdline_parse_inst_t cmd_config_burst = {
3439 .f = cmd_config_burst_parsed,
3441 .help_str = "port config all burst <value>",
3443 (void *)&cmd_config_burst_port,
3444 (void *)&cmd_config_burst_keyword,
3445 (void *)&cmd_config_burst_all,
3446 (void *)&cmd_config_burst_name,
3447 (void *)&cmd_config_burst_value,
3452 /* *** configure rx/tx queues *** */
3453 struct cmd_config_thresh {
3454 cmdline_fixed_string_t port;
3455 cmdline_fixed_string_t keyword;
3456 cmdline_fixed_string_t all;
3457 cmdline_fixed_string_t name;
3462 cmd_config_thresh_parsed(void *parsed_result,
3463 __rte_unused struct cmdline *cl,
3464 __rte_unused void *data)
3466 struct cmd_config_thresh *res = parsed_result;
3468 if (!all_ports_stopped()) {
3469 printf("Please stop all ports first\n");
3473 if (!strcmp(res->name, "txpt"))
3474 tx_pthresh = res->value;
3475 else if(!strcmp(res->name, "txht"))
3476 tx_hthresh = res->value;
3477 else if(!strcmp(res->name, "txwt"))
3478 tx_wthresh = res->value;
3479 else if(!strcmp(res->name, "rxpt"))
3480 rx_pthresh = res->value;
3481 else if(!strcmp(res->name, "rxht"))
3482 rx_hthresh = res->value;
3483 else if(!strcmp(res->name, "rxwt"))
3484 rx_wthresh = res->value;
3486 printf("Unknown parameter\n");
3492 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3495 cmdline_parse_token_string_t cmd_config_thresh_port =
3496 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3497 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3498 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3499 cmdline_parse_token_string_t cmd_config_thresh_all =
3500 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3501 cmdline_parse_token_string_t cmd_config_thresh_name =
3502 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3503 "txpt#txht#txwt#rxpt#rxht#rxwt");
3504 cmdline_parse_token_num_t cmd_config_thresh_value =
3505 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3507 cmdline_parse_inst_t cmd_config_thresh = {
3508 .f = cmd_config_thresh_parsed,
3510 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3512 (void *)&cmd_config_thresh_port,
3513 (void *)&cmd_config_thresh_keyword,
3514 (void *)&cmd_config_thresh_all,
3515 (void *)&cmd_config_thresh_name,
3516 (void *)&cmd_config_thresh_value,
3521 /* *** configure free/rs threshold *** */
3522 struct cmd_config_threshold {
3523 cmdline_fixed_string_t port;
3524 cmdline_fixed_string_t keyword;
3525 cmdline_fixed_string_t all;
3526 cmdline_fixed_string_t name;
3531 cmd_config_threshold_parsed(void *parsed_result,
3532 __rte_unused struct cmdline *cl,
3533 __rte_unused void *data)
3535 struct cmd_config_threshold *res = parsed_result;
3537 if (!all_ports_stopped()) {
3538 printf("Please stop all ports first\n");
3542 if (!strcmp(res->name, "txfreet"))
3543 tx_free_thresh = res->value;
3544 else if (!strcmp(res->name, "txrst"))
3545 tx_rs_thresh = res->value;
3546 else if (!strcmp(res->name, "rxfreet"))
3547 rx_free_thresh = res->value;
3549 printf("Unknown parameter\n");
3555 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3558 cmdline_parse_token_string_t cmd_config_threshold_port =
3559 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3560 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3561 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3563 cmdline_parse_token_string_t cmd_config_threshold_all =
3564 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3565 cmdline_parse_token_string_t cmd_config_threshold_name =
3566 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3567 "txfreet#txrst#rxfreet");
3568 cmdline_parse_token_num_t cmd_config_threshold_value =
3569 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3571 cmdline_parse_inst_t cmd_config_threshold = {
3572 .f = cmd_config_threshold_parsed,
3574 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3576 (void *)&cmd_config_threshold_port,
3577 (void *)&cmd_config_threshold_keyword,
3578 (void *)&cmd_config_threshold_all,
3579 (void *)&cmd_config_threshold_name,
3580 (void *)&cmd_config_threshold_value,
3586 struct cmd_stop_result {
3587 cmdline_fixed_string_t stop;
3590 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3591 __rte_unused struct cmdline *cl,
3592 __rte_unused void *data)
3594 stop_packet_forwarding();
3597 cmdline_parse_token_string_t cmd_stop_stop =
3598 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3600 cmdline_parse_inst_t cmd_stop = {
3601 .f = cmd_stop_parsed,
3603 .help_str = "stop: Stop packet forwarding",
3605 (void *)&cmd_stop_stop,
3610 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3613 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3614 unsigned int *parsed_items, int check_unique_values)
3616 unsigned int nb_item;
3624 * First parse all items in the list and store their value.
3629 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3631 if ((c >= '0') && (c <= '9')) {
3632 value = (unsigned int) (value * 10 + (c - '0'));
3637 printf("character %c is not a decimal digit\n", c);
3641 printf("No valid value before comma\n");
3644 if (nb_item < max_items) {
3645 parsed_items[nb_item] = value;
3651 if (nb_item >= max_items) {
3652 printf("Number of %s = %u > %u (maximum items)\n",
3653 item_name, nb_item + 1, max_items);
3656 parsed_items[nb_item++] = value;
3657 if (! check_unique_values)
3661 * Then, check that all values in the list are differents.
3662 * No optimization here...
3664 for (i = 0; i < nb_item; i++) {
3665 for (j = i + 1; j < nb_item; j++) {
3666 if (parsed_items[j] == parsed_items[i]) {
3667 printf("duplicated %s %u at index %u and %u\n",
3668 item_name, parsed_items[i], i, j);
3676 struct cmd_set_list_result {
3677 cmdline_fixed_string_t cmd_keyword;
3678 cmdline_fixed_string_t list_name;
3679 cmdline_fixed_string_t list_of_items;
3682 static void cmd_set_list_parsed(void *parsed_result,
3683 __rte_unused struct cmdline *cl,
3684 __rte_unused void *data)
3686 struct cmd_set_list_result *res;
3688 unsigned int lcorelist[RTE_MAX_LCORE];
3689 unsigned int portlist[RTE_MAX_ETHPORTS];
3691 unsigned int nb_item;
3693 if (test_done == 0) {
3694 printf("Please stop forwarding first\n");
3698 res = parsed_result;
3699 if (!strcmp(res->list_name, "corelist")) {
3700 nb_item = parse_item_list(res->list_of_items, "core",
3702 parsed_items.lcorelist, 1);
3704 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3709 if (!strcmp(res->list_name, "portlist")) {
3710 nb_item = parse_item_list(res->list_of_items, "port",
3712 parsed_items.portlist, 1);
3714 set_fwd_ports_list(parsed_items.portlist, nb_item);
3720 cmdline_parse_token_string_t cmd_set_list_keyword =
3721 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3723 cmdline_parse_token_string_t cmd_set_list_name =
3724 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3725 "corelist#portlist");
3726 cmdline_parse_token_string_t cmd_set_list_of_items =
3727 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3730 cmdline_parse_inst_t cmd_set_fwd_list = {
3731 .f = cmd_set_list_parsed,
3733 .help_str = "set corelist|portlist <list0[,list1]*>",
3735 (void *)&cmd_set_list_keyword,
3736 (void *)&cmd_set_list_name,
3737 (void *)&cmd_set_list_of_items,
3742 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3744 struct cmd_setmask_result {
3745 cmdline_fixed_string_t set;
3746 cmdline_fixed_string_t mask;
3750 static void cmd_set_mask_parsed(void *parsed_result,
3751 __rte_unused struct cmdline *cl,
3752 __rte_unused void *data)
3754 struct cmd_setmask_result *res = parsed_result;
3756 if (test_done == 0) {
3757 printf("Please stop forwarding first\n");
3760 if (!strcmp(res->mask, "coremask")) {
3761 set_fwd_lcores_mask(res->hexavalue);
3763 } else if (!strcmp(res->mask, "portmask")) {
3764 set_fwd_ports_mask(res->hexavalue);
3769 cmdline_parse_token_string_t cmd_setmask_set =
3770 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3771 cmdline_parse_token_string_t cmd_setmask_mask =
3772 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3773 "coremask#portmask");
3774 cmdline_parse_token_num_t cmd_setmask_value =
3775 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3777 cmdline_parse_inst_t cmd_set_fwd_mask = {
3778 .f = cmd_set_mask_parsed,
3780 .help_str = "set coremask|portmask <hexadecimal value>",
3782 (void *)&cmd_setmask_set,
3783 (void *)&cmd_setmask_mask,
3784 (void *)&cmd_setmask_value,
3790 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3792 struct cmd_set_result {
3793 cmdline_fixed_string_t set;
3794 cmdline_fixed_string_t what;
3798 static void cmd_set_parsed(void *parsed_result,
3799 __rte_unused struct cmdline *cl,
3800 __rte_unused void *data)
3802 struct cmd_set_result *res = parsed_result;
3803 if (!strcmp(res->what, "nbport")) {
3804 set_fwd_ports_number(res->value);
3806 } else if (!strcmp(res->what, "nbcore")) {
3807 set_fwd_lcores_number(res->value);
3809 } else if (!strcmp(res->what, "burst"))
3810 set_nb_pkt_per_burst(res->value);
3811 else if (!strcmp(res->what, "verbose"))
3812 set_verbose_level(res->value);
3815 cmdline_parse_token_string_t cmd_set_set =
3816 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3817 cmdline_parse_token_string_t cmd_set_what =
3818 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3819 "nbport#nbcore#burst#verbose");
3820 cmdline_parse_token_num_t cmd_set_value =
3821 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3823 cmdline_parse_inst_t cmd_set_numbers = {
3824 .f = cmd_set_parsed,
3826 .help_str = "set nbport|nbcore|burst|verbose <value>",
3828 (void *)&cmd_set_set,
3829 (void *)&cmd_set_what,
3830 (void *)&cmd_set_value,
3835 /* *** SET LOG LEVEL CONFIGURATION *** */
3837 struct cmd_set_log_result {
3838 cmdline_fixed_string_t set;
3839 cmdline_fixed_string_t log;
3840 cmdline_fixed_string_t type;
3845 cmd_set_log_parsed(void *parsed_result,
3846 __rte_unused struct cmdline *cl,
3847 __rte_unused void *data)
3849 struct cmd_set_log_result *res;
3852 res = parsed_result;
3853 if (!strcmp(res->type, "global"))
3854 rte_log_set_global_level(res->level);
3856 ret = rte_log_set_level_regexp(res->type, res->level);
3858 printf("Unable to set log level\n");
3862 cmdline_parse_token_string_t cmd_set_log_set =
3863 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3864 cmdline_parse_token_string_t cmd_set_log_log =
3865 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3866 cmdline_parse_token_string_t cmd_set_log_type =
3867 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3868 cmdline_parse_token_num_t cmd_set_log_level =
3869 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3871 cmdline_parse_inst_t cmd_set_log = {
3872 .f = cmd_set_log_parsed,
3874 .help_str = "set log global|<type> <level>",
3876 (void *)&cmd_set_log_set,
3877 (void *)&cmd_set_log_log,
3878 (void *)&cmd_set_log_type,
3879 (void *)&cmd_set_log_level,
3884 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3886 struct cmd_set_rxoffs_result {
3887 cmdline_fixed_string_t cmd_keyword;
3888 cmdline_fixed_string_t rxoffs;
3889 cmdline_fixed_string_t seg_offsets;
3893 cmd_set_rxoffs_parsed(void *parsed_result,
3894 __rte_unused struct cmdline *cl,
3895 __rte_unused void *data)
3897 struct cmd_set_rxoffs_result *res;
3898 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3899 unsigned int nb_segs;
3901 res = parsed_result;
3902 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3903 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3905 set_rx_pkt_offsets(seg_offsets, nb_segs);
3906 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3909 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3910 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3911 cmd_keyword, "set");
3912 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3913 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3915 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3916 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3919 cmdline_parse_inst_t cmd_set_rxoffs = {
3920 .f = cmd_set_rxoffs_parsed,
3922 .help_str = "set rxoffs <len0[,len1]*>",
3924 (void *)&cmd_set_rxoffs_keyword,
3925 (void *)&cmd_set_rxoffs_name,
3926 (void *)&cmd_set_rxoffs_offsets,
3931 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3933 struct cmd_set_rxpkts_result {
3934 cmdline_fixed_string_t cmd_keyword;
3935 cmdline_fixed_string_t rxpkts;
3936 cmdline_fixed_string_t seg_lengths;
3940 cmd_set_rxpkts_parsed(void *parsed_result,
3941 __rte_unused struct cmdline *cl,
3942 __rte_unused void *data)
3944 struct cmd_set_rxpkts_result *res;
3945 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3946 unsigned int nb_segs;
3948 res = parsed_result;
3949 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3950 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3952 set_rx_pkt_segments(seg_lengths, nb_segs);
3953 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3956 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3957 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3958 cmd_keyword, "set");
3959 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3960 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3962 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3963 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3966 cmdline_parse_inst_t cmd_set_rxpkts = {
3967 .f = cmd_set_rxpkts_parsed,
3969 .help_str = "set rxpkts <len0[,len1]*>",
3971 (void *)&cmd_set_rxpkts_keyword,
3972 (void *)&cmd_set_rxpkts_name,
3973 (void *)&cmd_set_rxpkts_lengths,
3978 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3980 struct cmd_set_txpkts_result {
3981 cmdline_fixed_string_t cmd_keyword;
3982 cmdline_fixed_string_t txpkts;
3983 cmdline_fixed_string_t seg_lengths;
3987 cmd_set_txpkts_parsed(void *parsed_result,
3988 __rte_unused struct cmdline *cl,
3989 __rte_unused void *data)
3991 struct cmd_set_txpkts_result *res;
3992 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3993 unsigned int nb_segs;
3995 res = parsed_result;
3996 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3997 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3999 set_tx_pkt_segments(seg_lengths, nb_segs);
4002 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4003 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4004 cmd_keyword, "set");
4005 cmdline_parse_token_string_t cmd_set_txpkts_name =
4006 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4008 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4009 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4012 cmdline_parse_inst_t cmd_set_txpkts = {
4013 .f = cmd_set_txpkts_parsed,
4015 .help_str = "set txpkts <len0[,len1]*>",
4017 (void *)&cmd_set_txpkts_keyword,
4018 (void *)&cmd_set_txpkts_name,
4019 (void *)&cmd_set_txpkts_lengths,
4024 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4026 struct cmd_set_txsplit_result {
4027 cmdline_fixed_string_t cmd_keyword;
4028 cmdline_fixed_string_t txsplit;
4029 cmdline_fixed_string_t mode;
4033 cmd_set_txsplit_parsed(void *parsed_result,
4034 __rte_unused struct cmdline *cl,
4035 __rte_unused void *data)
4037 struct cmd_set_txsplit_result *res;
4039 res = parsed_result;
4040 set_tx_pkt_split(res->mode);
4043 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4044 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4045 cmd_keyword, "set");
4046 cmdline_parse_token_string_t cmd_set_txsplit_name =
4047 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4048 txsplit, "txsplit");
4049 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4050 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4053 cmdline_parse_inst_t cmd_set_txsplit = {
4054 .f = cmd_set_txsplit_parsed,
4056 .help_str = "set txsplit on|off|rand",
4058 (void *)&cmd_set_txsplit_keyword,
4059 (void *)&cmd_set_txsplit_name,
4060 (void *)&cmd_set_txsplit_mode,
4065 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4067 struct cmd_set_txtimes_result {
4068 cmdline_fixed_string_t cmd_keyword;
4069 cmdline_fixed_string_t txtimes;
4070 cmdline_fixed_string_t tx_times;
4074 cmd_set_txtimes_parsed(void *parsed_result,
4075 __rte_unused struct cmdline *cl,
4076 __rte_unused void *data)
4078 struct cmd_set_txtimes_result *res;
4079 unsigned int tx_times[2] = {0, 0};
4080 unsigned int n_times;
4082 res = parsed_result;
4083 n_times = parse_item_list(res->tx_times, "tx times",
4086 set_tx_pkt_times(tx_times);
4089 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4090 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4091 cmd_keyword, "set");
4092 cmdline_parse_token_string_t cmd_set_txtimes_name =
4093 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4094 txtimes, "txtimes");
4095 cmdline_parse_token_string_t cmd_set_txtimes_value =
4096 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4099 cmdline_parse_inst_t cmd_set_txtimes = {
4100 .f = cmd_set_txtimes_parsed,
4102 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4104 (void *)&cmd_set_txtimes_keyword,
4105 (void *)&cmd_set_txtimes_name,
4106 (void *)&cmd_set_txtimes_value,
4111 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4112 struct cmd_rx_vlan_filter_all_result {
4113 cmdline_fixed_string_t rx_vlan;
4114 cmdline_fixed_string_t what;
4115 cmdline_fixed_string_t all;
4120 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4121 __rte_unused struct cmdline *cl,
4122 __rte_unused void *data)
4124 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4126 if (!strcmp(res->what, "add"))
4127 rx_vlan_all_filter_set(res->port_id, 1);
4129 rx_vlan_all_filter_set(res->port_id, 0);
4132 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4133 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4134 rx_vlan, "rx_vlan");
4135 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4136 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4138 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4139 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4141 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4142 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4143 port_id, RTE_UINT16);
4145 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4146 .f = cmd_rx_vlan_filter_all_parsed,
4148 .help_str = "rx_vlan add|rm all <port_id>: "
4149 "Add/Remove all identifiers to/from the set of VLAN "
4150 "identifiers filtered by a port",
4152 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4153 (void *)&cmd_rx_vlan_filter_all_what,
4154 (void *)&cmd_rx_vlan_filter_all_all,
4155 (void *)&cmd_rx_vlan_filter_all_portid,
4160 /* *** VLAN OFFLOAD SET ON A PORT *** */
4161 struct cmd_vlan_offload_result {
4162 cmdline_fixed_string_t vlan;
4163 cmdline_fixed_string_t set;
4164 cmdline_fixed_string_t vlan_type;
4165 cmdline_fixed_string_t what;
4166 cmdline_fixed_string_t on;
4167 cmdline_fixed_string_t port_id;
4171 cmd_vlan_offload_parsed(void *parsed_result,
4172 __rte_unused struct cmdline *cl,
4173 __rte_unused void *data)
4176 struct cmd_vlan_offload_result *res = parsed_result;
4179 portid_t port_id = 0;
4183 len = strnlen(str, STR_TOKEN_SIZE);
4185 /* Get port_id first */
4193 tmp = strtoul(str, NULL, 0);
4194 /* If port_id greater that what portid_t can represent, return */
4195 if(tmp >= RTE_MAX_ETHPORTS)
4197 port_id = (portid_t)tmp;
4199 if (!strcmp(res->on, "on"))
4204 if (!strcmp(res->what, "strip"))
4205 rx_vlan_strip_set(port_id, on);
4206 else if(!strcmp(res->what, "stripq")){
4207 uint16_t queue_id = 0;
4209 /* No queue_id, return */
4211 printf("must specify (port,queue_id)\n");
4214 tmp = strtoul(str + i + 1, NULL, 0);
4215 /* If queue_id greater that what 16-bits can represent, return */
4219 queue_id = (uint16_t)tmp;
4220 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4222 else if (!strcmp(res->what, "filter"))
4223 rx_vlan_filter_set(port_id, on);
4224 else if (!strcmp(res->what, "qinq_strip"))
4225 rx_vlan_qinq_strip_set(port_id, on);
4227 vlan_extend_set(port_id, on);
4232 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4233 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4235 cmdline_parse_token_string_t cmd_vlan_offload_set =
4236 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4238 cmdline_parse_token_string_t cmd_vlan_offload_what =
4239 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4240 what, "strip#filter#qinq_strip#extend#stripq");
4241 cmdline_parse_token_string_t cmd_vlan_offload_on =
4242 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4244 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4245 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4248 cmdline_parse_inst_t cmd_vlan_offload = {
4249 .f = cmd_vlan_offload_parsed,
4251 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4252 "<port_id[,queue_id]>: "
4253 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4255 (void *)&cmd_vlan_offload_vlan,
4256 (void *)&cmd_vlan_offload_set,
4257 (void *)&cmd_vlan_offload_what,
4258 (void *)&cmd_vlan_offload_on,
4259 (void *)&cmd_vlan_offload_portid,
4264 /* *** VLAN TPID SET ON A PORT *** */
4265 struct cmd_vlan_tpid_result {
4266 cmdline_fixed_string_t vlan;
4267 cmdline_fixed_string_t set;
4268 cmdline_fixed_string_t vlan_type;
4269 cmdline_fixed_string_t what;
4275 cmd_vlan_tpid_parsed(void *parsed_result,
4276 __rte_unused struct cmdline *cl,
4277 __rte_unused void *data)
4279 struct cmd_vlan_tpid_result *res = parsed_result;
4280 enum rte_vlan_type vlan_type;
4282 if (!strcmp(res->vlan_type, "inner"))
4283 vlan_type = ETH_VLAN_TYPE_INNER;
4284 else if (!strcmp(res->vlan_type, "outer"))
4285 vlan_type = ETH_VLAN_TYPE_OUTER;
4287 printf("Unknown vlan type\n");
4290 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4293 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4294 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4296 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4297 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4299 cmdline_parse_token_string_t cmd_vlan_type =
4300 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4301 vlan_type, "inner#outer");
4302 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4303 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4305 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4306 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4308 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4309 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4310 port_id, RTE_UINT16);
4312 cmdline_parse_inst_t cmd_vlan_tpid = {
4313 .f = cmd_vlan_tpid_parsed,
4315 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4316 "Set the VLAN Ether type",
4318 (void *)&cmd_vlan_tpid_vlan,
4319 (void *)&cmd_vlan_tpid_set,
4320 (void *)&cmd_vlan_type,
4321 (void *)&cmd_vlan_tpid_what,
4322 (void *)&cmd_vlan_tpid_tpid,
4323 (void *)&cmd_vlan_tpid_portid,
4328 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4329 struct cmd_rx_vlan_filter_result {
4330 cmdline_fixed_string_t rx_vlan;
4331 cmdline_fixed_string_t what;
4337 cmd_rx_vlan_filter_parsed(void *parsed_result,
4338 __rte_unused struct cmdline *cl,
4339 __rte_unused void *data)
4341 struct cmd_rx_vlan_filter_result *res = parsed_result;
4343 if (!strcmp(res->what, "add"))
4344 rx_vft_set(res->port_id, res->vlan_id, 1);
4346 rx_vft_set(res->port_id, res->vlan_id, 0);
4349 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4350 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4351 rx_vlan, "rx_vlan");
4352 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4353 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4355 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4356 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4357 vlan_id, RTE_UINT16);
4358 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4359 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4360 port_id, RTE_UINT16);
4362 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4363 .f = cmd_rx_vlan_filter_parsed,
4365 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4366 "Add/Remove a VLAN identifier to/from the set of VLAN "
4367 "identifiers filtered by a port",
4369 (void *)&cmd_rx_vlan_filter_rx_vlan,
4370 (void *)&cmd_rx_vlan_filter_what,
4371 (void *)&cmd_rx_vlan_filter_vlanid,
4372 (void *)&cmd_rx_vlan_filter_portid,
4377 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4378 struct cmd_tx_vlan_set_result {
4379 cmdline_fixed_string_t tx_vlan;
4380 cmdline_fixed_string_t set;
4386 cmd_tx_vlan_set_parsed(void *parsed_result,
4387 __rte_unused struct cmdline *cl,
4388 __rte_unused void *data)
4390 struct cmd_tx_vlan_set_result *res = parsed_result;
4392 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4395 if (!port_is_stopped(res->port_id)) {
4396 printf("Please stop port %d first\n", res->port_id);
4400 tx_vlan_set(res->port_id, res->vlan_id);
4402 cmd_reconfig_device_queue(res->port_id, 1, 1);
4405 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4406 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4407 tx_vlan, "tx_vlan");
4408 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4409 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4411 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4412 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4413 port_id, RTE_UINT16);
4414 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4415 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4416 vlan_id, RTE_UINT16);
4418 cmdline_parse_inst_t cmd_tx_vlan_set = {
4419 .f = cmd_tx_vlan_set_parsed,
4421 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4422 "Enable hardware insertion of a single VLAN header "
4423 "with a given TAG Identifier in packets sent on a port",
4425 (void *)&cmd_tx_vlan_set_tx_vlan,
4426 (void *)&cmd_tx_vlan_set_set,
4427 (void *)&cmd_tx_vlan_set_portid,
4428 (void *)&cmd_tx_vlan_set_vlanid,
4433 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4434 struct cmd_tx_vlan_set_qinq_result {
4435 cmdline_fixed_string_t tx_vlan;
4436 cmdline_fixed_string_t set;
4439 uint16_t vlan_id_outer;
4443 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4444 __rte_unused struct cmdline *cl,
4445 __rte_unused void *data)
4447 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4449 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4452 if (!port_is_stopped(res->port_id)) {
4453 printf("Please stop port %d first\n", res->port_id);
4457 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4459 cmd_reconfig_device_queue(res->port_id, 1, 1);
4462 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4463 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4464 tx_vlan, "tx_vlan");
4465 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4466 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4468 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4469 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4470 port_id, RTE_UINT16);
4471 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4472 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4473 vlan_id, RTE_UINT16);
4474 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4475 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4476 vlan_id_outer, RTE_UINT16);
4478 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4479 .f = cmd_tx_vlan_set_qinq_parsed,
4481 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4482 "Enable hardware insertion of double VLAN header "
4483 "with given TAG Identifiers in packets sent on a port",
4485 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4486 (void *)&cmd_tx_vlan_set_qinq_set,
4487 (void *)&cmd_tx_vlan_set_qinq_portid,
4488 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4489 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4494 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4495 struct cmd_tx_vlan_set_pvid_result {
4496 cmdline_fixed_string_t tx_vlan;
4497 cmdline_fixed_string_t set;
4498 cmdline_fixed_string_t pvid;
4501 cmdline_fixed_string_t mode;
4505 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4506 __rte_unused struct cmdline *cl,
4507 __rte_unused void *data)
4509 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4511 if (strcmp(res->mode, "on") == 0)
4512 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4514 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4517 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4518 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4519 tx_vlan, "tx_vlan");
4520 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4521 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4523 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4524 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4526 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4527 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4528 port_id, RTE_UINT16);
4529 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4530 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4531 vlan_id, RTE_UINT16);
4532 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4533 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4536 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4537 .f = cmd_tx_vlan_set_pvid_parsed,
4539 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4541 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4542 (void *)&cmd_tx_vlan_set_pvid_set,
4543 (void *)&cmd_tx_vlan_set_pvid_pvid,
4544 (void *)&cmd_tx_vlan_set_pvid_port_id,
4545 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4546 (void *)&cmd_tx_vlan_set_pvid_mode,
4551 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4552 struct cmd_tx_vlan_reset_result {
4553 cmdline_fixed_string_t tx_vlan;
4554 cmdline_fixed_string_t reset;
4559 cmd_tx_vlan_reset_parsed(void *parsed_result,
4560 __rte_unused struct cmdline *cl,
4561 __rte_unused void *data)
4563 struct cmd_tx_vlan_reset_result *res = parsed_result;
4565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4568 if (!port_is_stopped(res->port_id)) {
4569 printf("Please stop port %d first\n", res->port_id);
4573 tx_vlan_reset(res->port_id);
4575 cmd_reconfig_device_queue(res->port_id, 1, 1);
4578 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4579 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4580 tx_vlan, "tx_vlan");
4581 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4582 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4584 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4585 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4586 port_id, RTE_UINT16);
4588 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4589 .f = cmd_tx_vlan_reset_parsed,
4591 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4592 "VLAN header in packets sent on a port",
4594 (void *)&cmd_tx_vlan_reset_tx_vlan,
4595 (void *)&cmd_tx_vlan_reset_reset,
4596 (void *)&cmd_tx_vlan_reset_portid,
4602 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4603 struct cmd_csum_result {
4604 cmdline_fixed_string_t csum;
4605 cmdline_fixed_string_t mode;
4606 cmdline_fixed_string_t proto;
4607 cmdline_fixed_string_t hwsw;
4612 csum_show(int port_id)
4614 struct rte_eth_dev_info dev_info;
4615 uint64_t tx_offloads;
4618 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4619 printf("Parse tunnel is %s\n",
4620 (ports[port_id].parse_tunnel) ? "on" : "off");
4621 printf("IP checksum offload is %s\n",
4622 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4623 printf("UDP checksum offload is %s\n",
4624 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4625 printf("TCP checksum offload is %s\n",
4626 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4627 printf("SCTP checksum offload is %s\n",
4628 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4629 printf("Outer-Ip checksum offload is %s\n",
4630 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4631 printf("Outer-Udp checksum offload is %s\n",
4632 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4634 /* display warnings if configuration is not supported by the NIC */
4635 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4639 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4640 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4641 printf("Warning: hardware IP checksum enabled but not "
4642 "supported by port %d\n", port_id);
4644 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4645 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4646 printf("Warning: hardware UDP checksum enabled but not "
4647 "supported by port %d\n", port_id);
4649 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4650 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4651 printf("Warning: hardware TCP checksum enabled but not "
4652 "supported by port %d\n", port_id);
4654 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4655 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4656 printf("Warning: hardware SCTP checksum enabled but not "
4657 "supported by port %d\n", port_id);
4659 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4660 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4661 printf("Warning: hardware outer IP checksum enabled but not "
4662 "supported by port %d\n", port_id);
4664 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4665 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4667 printf("Warning: hardware outer UDP checksum enabled but not "
4668 "supported by port %d\n", port_id);
4673 cmd_config_queue_tx_offloads(struct rte_port *port)
4677 /* Apply queue tx offloads configuration */
4678 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4679 port->tx_conf[k].offloads =
4680 port->dev_conf.txmode.offloads;
4684 cmd_csum_parsed(void *parsed_result,
4685 __rte_unused struct cmdline *cl,
4686 __rte_unused void *data)
4688 struct cmd_csum_result *res = parsed_result;
4690 uint64_t csum_offloads = 0;
4691 struct rte_eth_dev_info dev_info;
4694 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4695 printf("invalid port %d\n", res->port_id);
4698 if (!port_is_stopped(res->port_id)) {
4699 printf("Please stop port %d first\n", res->port_id);
4703 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4707 if (!strcmp(res->mode, "set")) {
4709 if (!strcmp(res->hwsw, "hw"))
4712 if (!strcmp(res->proto, "ip")) {
4713 if (hw == 0 || (dev_info.tx_offload_capa &
4714 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4715 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4717 printf("IP checksum offload is not supported "
4718 "by port %u\n", res->port_id);
4720 } else if (!strcmp(res->proto, "udp")) {
4721 if (hw == 0 || (dev_info.tx_offload_capa &
4722 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4723 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4725 printf("UDP checksum offload is not supported "
4726 "by port %u\n", res->port_id);
4728 } else if (!strcmp(res->proto, "tcp")) {
4729 if (hw == 0 || (dev_info.tx_offload_capa &
4730 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4731 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4733 printf("TCP checksum offload is not supported "
4734 "by port %u\n", res->port_id);
4736 } else if (!strcmp(res->proto, "sctp")) {
4737 if (hw == 0 || (dev_info.tx_offload_capa &
4738 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4739 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4741 printf("SCTP checksum offload is not supported "
4742 "by port %u\n", res->port_id);
4744 } else if (!strcmp(res->proto, "outer-ip")) {
4745 if (hw == 0 || (dev_info.tx_offload_capa &
4746 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4748 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4750 printf("Outer IP checksum offload is not "
4751 "supported by port %u\n", res->port_id);
4753 } else if (!strcmp(res->proto, "outer-udp")) {
4754 if (hw == 0 || (dev_info.tx_offload_capa &
4755 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4757 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4759 printf("Outer UDP checksum offload is not "
4760 "supported by port %u\n", res->port_id);
4765 ports[res->port_id].dev_conf.txmode.offloads |=
4768 ports[res->port_id].dev_conf.txmode.offloads &=
4771 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4773 csum_show(res->port_id);
4775 cmd_reconfig_device_queue(res->port_id, 1, 1);
4778 cmdline_parse_token_string_t cmd_csum_csum =
4779 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4781 cmdline_parse_token_string_t cmd_csum_mode =
4782 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4784 cmdline_parse_token_string_t cmd_csum_proto =
4785 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4786 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4787 cmdline_parse_token_string_t cmd_csum_hwsw =
4788 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4790 cmdline_parse_token_num_t cmd_csum_portid =
4791 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4792 port_id, RTE_UINT16);
4794 cmdline_parse_inst_t cmd_csum_set = {
4795 .f = cmd_csum_parsed,
4797 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4798 "Enable/Disable hardware calculation of L3/L4 checksum when "
4799 "using csum forward engine",
4801 (void *)&cmd_csum_csum,
4802 (void *)&cmd_csum_mode,
4803 (void *)&cmd_csum_proto,
4804 (void *)&cmd_csum_hwsw,
4805 (void *)&cmd_csum_portid,
4810 cmdline_parse_token_string_t cmd_csum_mode_show =
4811 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4814 cmdline_parse_inst_t cmd_csum_show = {
4815 .f = cmd_csum_parsed,
4817 .help_str = "csum show <port_id>: Show checksum offload configuration",
4819 (void *)&cmd_csum_csum,
4820 (void *)&cmd_csum_mode_show,
4821 (void *)&cmd_csum_portid,
4826 /* Enable/disable tunnel parsing */
4827 struct cmd_csum_tunnel_result {
4828 cmdline_fixed_string_t csum;
4829 cmdline_fixed_string_t parse;
4830 cmdline_fixed_string_t onoff;
4835 cmd_csum_tunnel_parsed(void *parsed_result,
4836 __rte_unused struct cmdline *cl,
4837 __rte_unused void *data)
4839 struct cmd_csum_tunnel_result *res = parsed_result;
4841 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4844 if (!strcmp(res->onoff, "on"))
4845 ports[res->port_id].parse_tunnel = 1;
4847 ports[res->port_id].parse_tunnel = 0;
4849 csum_show(res->port_id);
4852 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4853 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4855 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4856 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4857 parse, "parse-tunnel");
4858 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4859 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4861 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4862 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4863 port_id, RTE_UINT16);
4865 cmdline_parse_inst_t cmd_csum_tunnel = {
4866 .f = cmd_csum_tunnel_parsed,
4868 .help_str = "csum parse-tunnel on|off <port_id>: "
4869 "Enable/Disable parsing of tunnels for csum engine",
4871 (void *)&cmd_csum_tunnel_csum,
4872 (void *)&cmd_csum_tunnel_parse,
4873 (void *)&cmd_csum_tunnel_onoff,
4874 (void *)&cmd_csum_tunnel_portid,
4879 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4880 struct cmd_tso_set_result {
4881 cmdline_fixed_string_t tso;
4882 cmdline_fixed_string_t mode;
4888 cmd_tso_set_parsed(void *parsed_result,
4889 __rte_unused struct cmdline *cl,
4890 __rte_unused void *data)
4892 struct cmd_tso_set_result *res = parsed_result;
4893 struct rte_eth_dev_info dev_info;
4896 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4898 if (!port_is_stopped(res->port_id)) {
4899 printf("Please stop port %d first\n", res->port_id);
4903 if (!strcmp(res->mode, "set"))
4904 ports[res->port_id].tso_segsz = res->tso_segsz;
4906 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4910 if ((ports[res->port_id].tso_segsz != 0) &&
4911 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4912 printf("Error: TSO is not supported by port %d\n",
4917 if (ports[res->port_id].tso_segsz == 0) {
4918 ports[res->port_id].dev_conf.txmode.offloads &=
4919 ~DEV_TX_OFFLOAD_TCP_TSO;
4920 printf("TSO for non-tunneled packets is disabled\n");
4922 ports[res->port_id].dev_conf.txmode.offloads |=
4923 DEV_TX_OFFLOAD_TCP_TSO;
4924 printf("TSO segment size for non-tunneled packets is %d\n",
4925 ports[res->port_id].tso_segsz);
4927 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4929 /* display warnings if configuration is not supported by the NIC */
4930 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4934 if ((ports[res->port_id].tso_segsz != 0) &&
4935 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4936 printf("Warning: TSO enabled but not "
4937 "supported by port %d\n", res->port_id);
4940 cmd_reconfig_device_queue(res->port_id, 1, 1);
4943 cmdline_parse_token_string_t cmd_tso_set_tso =
4944 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4946 cmdline_parse_token_string_t cmd_tso_set_mode =
4947 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4949 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4950 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4951 tso_segsz, RTE_UINT16);
4952 cmdline_parse_token_num_t cmd_tso_set_portid =
4953 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4954 port_id, RTE_UINT16);
4956 cmdline_parse_inst_t cmd_tso_set = {
4957 .f = cmd_tso_set_parsed,
4959 .help_str = "tso set <tso_segsz> <port_id>: "
4960 "Set TSO segment size of non-tunneled packets for csum engine "
4963 (void *)&cmd_tso_set_tso,
4964 (void *)&cmd_tso_set_mode,
4965 (void *)&cmd_tso_set_tso_segsz,
4966 (void *)&cmd_tso_set_portid,
4971 cmdline_parse_token_string_t cmd_tso_show_mode =
4972 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4976 cmdline_parse_inst_t cmd_tso_show = {
4977 .f = cmd_tso_set_parsed,
4979 .help_str = "tso show <port_id>: "
4980 "Show TSO segment size of non-tunneled packets for csum engine",
4982 (void *)&cmd_tso_set_tso,
4983 (void *)&cmd_tso_show_mode,
4984 (void *)&cmd_tso_set_portid,
4989 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4990 struct cmd_tunnel_tso_set_result {
4991 cmdline_fixed_string_t tso;
4992 cmdline_fixed_string_t mode;
4997 static struct rte_eth_dev_info
4998 check_tunnel_tso_nic_support(portid_t port_id)
5000 struct rte_eth_dev_info dev_info;
5002 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5005 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5006 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5007 "not enabled for port %d\n", port_id);
5008 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5009 printf("Warning: GRE TUNNEL TSO not supported therefore "
5010 "not enabled for port %d\n", port_id);
5011 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5012 printf("Warning: IPIP TUNNEL TSO not supported therefore "
5013 "not enabled for port %d\n", port_id);
5014 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5015 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5016 "not enabled for port %d\n", port_id);
5017 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5018 printf("Warning: IP TUNNEL TSO not supported therefore "
5019 "not enabled for port %d\n", port_id);
5020 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5021 printf("Warning: UDP TUNNEL TSO not supported therefore "
5022 "not enabled for port %d\n", port_id);
5027 cmd_tunnel_tso_set_parsed(void *parsed_result,
5028 __rte_unused struct cmdline *cl,
5029 __rte_unused void *data)
5031 struct cmd_tunnel_tso_set_result *res = parsed_result;
5032 struct rte_eth_dev_info dev_info;
5034 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5036 if (!port_is_stopped(res->port_id)) {
5037 printf("Please stop port %d first\n", res->port_id);
5041 if (!strcmp(res->mode, "set"))
5042 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5044 dev_info = check_tunnel_tso_nic_support(res->port_id);
5045 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5046 ports[res->port_id].dev_conf.txmode.offloads &=
5047 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5048 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5049 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5050 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5051 DEV_TX_OFFLOAD_IP_TNL_TSO |
5052 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5053 printf("TSO for tunneled packets is disabled\n");
5055 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5056 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5057 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5058 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5059 DEV_TX_OFFLOAD_IP_TNL_TSO |
5060 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5062 ports[res->port_id].dev_conf.txmode.offloads |=
5063 (tso_offloads & dev_info.tx_offload_capa);
5064 printf("TSO segment size for tunneled packets is %d\n",
5065 ports[res->port_id].tunnel_tso_segsz);
5067 /* Below conditions are needed to make it work:
5068 * (1) tunnel TSO is supported by the NIC;
5069 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5071 * (3) for tunneled pkts with outer L3 of IPv4,
5072 * "csum set outer-ip" must be set to hw, because after tso,
5073 * total_len of outer IP header is changed, and the checksum
5074 * of outer IP header calculated by sw should be wrong; that
5075 * is not necessary for IPv6 tunneled pkts because there's no
5076 * checksum in IP header anymore.
5079 if (!ports[res->port_id].parse_tunnel)
5080 printf("Warning: csum parse_tunnel must be set "
5081 "so that tunneled packets are recognized\n");
5082 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5083 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5084 printf("Warning: csum set outer-ip must be set to hw "
5085 "if outer L3 is IPv4; not necessary for IPv6\n");
5088 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5089 cmd_reconfig_device_queue(res->port_id, 1, 1);
5092 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5093 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5095 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5096 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5098 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5099 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5100 tso_segsz, RTE_UINT16);
5101 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5102 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5103 port_id, RTE_UINT16);
5105 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5106 .f = cmd_tunnel_tso_set_parsed,
5108 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5109 "Set TSO segment size of tunneled packets for csum engine "
5112 (void *)&cmd_tunnel_tso_set_tso,
5113 (void *)&cmd_tunnel_tso_set_mode,
5114 (void *)&cmd_tunnel_tso_set_tso_segsz,
5115 (void *)&cmd_tunnel_tso_set_portid,
5120 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5121 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5125 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5126 .f = cmd_tunnel_tso_set_parsed,
5128 .help_str = "tunnel_tso show <port_id> "
5129 "Show TSO segment size of tunneled packets for csum engine",
5131 (void *)&cmd_tunnel_tso_set_tso,
5132 (void *)&cmd_tunnel_tso_show_mode,
5133 (void *)&cmd_tunnel_tso_set_portid,
5138 /* *** SET GRO FOR A PORT *** */
5139 struct cmd_gro_enable_result {
5140 cmdline_fixed_string_t cmd_set;
5141 cmdline_fixed_string_t cmd_port;
5142 cmdline_fixed_string_t cmd_keyword;
5143 cmdline_fixed_string_t cmd_onoff;
5148 cmd_gro_enable_parsed(void *parsed_result,
5149 __rte_unused struct cmdline *cl,
5150 __rte_unused void *data)
5152 struct cmd_gro_enable_result *res;
5154 res = parsed_result;
5155 if (!strcmp(res->cmd_keyword, "gro"))
5156 setup_gro(res->cmd_onoff, res->cmd_pid);
5159 cmdline_parse_token_string_t cmd_gro_enable_set =
5160 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5162 cmdline_parse_token_string_t cmd_gro_enable_port =
5163 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5164 cmd_keyword, "port");
5165 cmdline_parse_token_num_t cmd_gro_enable_pid =
5166 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5167 cmd_pid, RTE_UINT16);
5168 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5169 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5170 cmd_keyword, "gro");
5171 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5172 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5173 cmd_onoff, "on#off");
5175 cmdline_parse_inst_t cmd_gro_enable = {
5176 .f = cmd_gro_enable_parsed,
5178 .help_str = "set port <port_id> gro on|off",
5180 (void *)&cmd_gro_enable_set,
5181 (void *)&cmd_gro_enable_port,
5182 (void *)&cmd_gro_enable_pid,
5183 (void *)&cmd_gro_enable_keyword,
5184 (void *)&cmd_gro_enable_onoff,
5189 /* *** DISPLAY GRO CONFIGURATION *** */
5190 struct cmd_gro_show_result {
5191 cmdline_fixed_string_t cmd_show;
5192 cmdline_fixed_string_t cmd_port;
5193 cmdline_fixed_string_t cmd_keyword;
5198 cmd_gro_show_parsed(void *parsed_result,
5199 __rte_unused struct cmdline *cl,
5200 __rte_unused void *data)
5202 struct cmd_gro_show_result *res;
5204 res = parsed_result;
5205 if (!strcmp(res->cmd_keyword, "gro"))
5206 show_gro(res->cmd_pid);
5209 cmdline_parse_token_string_t cmd_gro_show_show =
5210 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5212 cmdline_parse_token_string_t cmd_gro_show_port =
5213 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5215 cmdline_parse_token_num_t cmd_gro_show_pid =
5216 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5217 cmd_pid, RTE_UINT16);
5218 cmdline_parse_token_string_t cmd_gro_show_keyword =
5219 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5220 cmd_keyword, "gro");
5222 cmdline_parse_inst_t cmd_gro_show = {
5223 .f = cmd_gro_show_parsed,
5225 .help_str = "show port <port_id> gro",
5227 (void *)&cmd_gro_show_show,
5228 (void *)&cmd_gro_show_port,
5229 (void *)&cmd_gro_show_pid,
5230 (void *)&cmd_gro_show_keyword,
5235 /* *** SET FLUSH CYCLES FOR GRO *** */
5236 struct cmd_gro_flush_result {
5237 cmdline_fixed_string_t cmd_set;
5238 cmdline_fixed_string_t cmd_keyword;
5239 cmdline_fixed_string_t cmd_flush;
5244 cmd_gro_flush_parsed(void *parsed_result,
5245 __rte_unused struct cmdline *cl,
5246 __rte_unused void *data)
5248 struct cmd_gro_flush_result *res;
5250 res = parsed_result;
5251 if ((!strcmp(res->cmd_keyword, "gro")) &&
5252 (!strcmp(res->cmd_flush, "flush")))
5253 setup_gro_flush_cycles(res->cmd_cycles);
5256 cmdline_parse_token_string_t cmd_gro_flush_set =
5257 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5259 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5260 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5261 cmd_keyword, "gro");
5262 cmdline_parse_token_string_t cmd_gro_flush_flush =
5263 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5264 cmd_flush, "flush");
5265 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5266 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5267 cmd_cycles, RTE_UINT8);
5269 cmdline_parse_inst_t cmd_gro_flush = {
5270 .f = cmd_gro_flush_parsed,
5272 .help_str = "set gro flush <cycles>",
5274 (void *)&cmd_gro_flush_set,
5275 (void *)&cmd_gro_flush_keyword,
5276 (void *)&cmd_gro_flush_flush,
5277 (void *)&cmd_gro_flush_cycles,
5282 /* *** ENABLE/DISABLE GSO *** */
5283 struct cmd_gso_enable_result {
5284 cmdline_fixed_string_t cmd_set;
5285 cmdline_fixed_string_t cmd_port;
5286 cmdline_fixed_string_t cmd_keyword;
5287 cmdline_fixed_string_t cmd_mode;
5292 cmd_gso_enable_parsed(void *parsed_result,
5293 __rte_unused struct cmdline *cl,
5294 __rte_unused void *data)
5296 struct cmd_gso_enable_result *res;
5298 res = parsed_result;
5299 if (!strcmp(res->cmd_keyword, "gso"))
5300 setup_gso(res->cmd_mode, res->cmd_pid);
5303 cmdline_parse_token_string_t cmd_gso_enable_set =
5304 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5306 cmdline_parse_token_string_t cmd_gso_enable_port =
5307 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5309 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5310 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5311 cmd_keyword, "gso");
5312 cmdline_parse_token_string_t cmd_gso_enable_mode =
5313 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5314 cmd_mode, "on#off");
5315 cmdline_parse_token_num_t cmd_gso_enable_pid =
5316 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5317 cmd_pid, RTE_UINT16);
5319 cmdline_parse_inst_t cmd_gso_enable = {
5320 .f = cmd_gso_enable_parsed,
5322 .help_str = "set port <port_id> gso on|off",
5324 (void *)&cmd_gso_enable_set,
5325 (void *)&cmd_gso_enable_port,
5326 (void *)&cmd_gso_enable_pid,
5327 (void *)&cmd_gso_enable_keyword,
5328 (void *)&cmd_gso_enable_mode,
5333 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5334 struct cmd_gso_size_result {
5335 cmdline_fixed_string_t cmd_set;
5336 cmdline_fixed_string_t cmd_keyword;
5337 cmdline_fixed_string_t cmd_segsz;
5342 cmd_gso_size_parsed(void *parsed_result,
5343 __rte_unused struct cmdline *cl,
5344 __rte_unused void *data)
5346 struct cmd_gso_size_result *res = parsed_result;
5348 if (test_done == 0) {
5349 printf("Before setting GSO segsz, please first"
5350 " stop forwarding\n");
5354 if (!strcmp(res->cmd_keyword, "gso") &&
5355 !strcmp(res->cmd_segsz, "segsz")) {
5356 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5357 printf("gso_size should be larger than %zu."
5358 " Please input a legal value\n",
5359 RTE_GSO_SEG_SIZE_MIN);
5361 gso_max_segment_size = res->cmd_size;
5365 cmdline_parse_token_string_t cmd_gso_size_set =
5366 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5368 cmdline_parse_token_string_t cmd_gso_size_keyword =
5369 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5370 cmd_keyword, "gso");
5371 cmdline_parse_token_string_t cmd_gso_size_segsz =
5372 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5373 cmd_segsz, "segsz");
5374 cmdline_parse_token_num_t cmd_gso_size_size =
5375 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5376 cmd_size, RTE_UINT16);
5378 cmdline_parse_inst_t cmd_gso_size = {
5379 .f = cmd_gso_size_parsed,
5381 .help_str = "set gso segsz <length>",
5383 (void *)&cmd_gso_size_set,
5384 (void *)&cmd_gso_size_keyword,
5385 (void *)&cmd_gso_size_segsz,
5386 (void *)&cmd_gso_size_size,
5391 /* *** SHOW GSO CONFIGURATION *** */
5392 struct cmd_gso_show_result {
5393 cmdline_fixed_string_t cmd_show;
5394 cmdline_fixed_string_t cmd_port;
5395 cmdline_fixed_string_t cmd_keyword;
5400 cmd_gso_show_parsed(void *parsed_result,
5401 __rte_unused struct cmdline *cl,
5402 __rte_unused void *data)
5404 struct cmd_gso_show_result *res = parsed_result;
5406 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5407 printf("invalid port id %u\n", res->cmd_pid);
5410 if (!strcmp(res->cmd_keyword, "gso")) {
5411 if (gso_ports[res->cmd_pid].enable) {
5412 printf("Max GSO'd packet size: %uB\n"
5413 "Supported GSO types: TCP/IPv4, "
5414 "UDP/IPv4, VxLAN with inner "
5415 "TCP/IPv4 packet, GRE with inner "
5416 "TCP/IPv4 packet\n",
5417 gso_max_segment_size);
5419 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5423 cmdline_parse_token_string_t cmd_gso_show_show =
5424 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5426 cmdline_parse_token_string_t cmd_gso_show_port =
5427 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5429 cmdline_parse_token_string_t cmd_gso_show_keyword =
5430 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5431 cmd_keyword, "gso");
5432 cmdline_parse_token_num_t cmd_gso_show_pid =
5433 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5434 cmd_pid, RTE_UINT16);
5436 cmdline_parse_inst_t cmd_gso_show = {
5437 .f = cmd_gso_show_parsed,
5439 .help_str = "show port <port_id> gso",
5441 (void *)&cmd_gso_show_show,
5442 (void *)&cmd_gso_show_port,
5443 (void *)&cmd_gso_show_pid,
5444 (void *)&cmd_gso_show_keyword,
5449 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5450 struct cmd_set_flush_rx {
5451 cmdline_fixed_string_t set;
5452 cmdline_fixed_string_t flush_rx;
5453 cmdline_fixed_string_t mode;
5457 cmd_set_flush_rx_parsed(void *parsed_result,
5458 __rte_unused struct cmdline *cl,
5459 __rte_unused void *data)
5461 struct cmd_set_flush_rx *res = parsed_result;
5462 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5465 cmdline_parse_token_string_t cmd_setflushrx_set =
5466 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5468 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5469 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5470 flush_rx, "flush_rx");
5471 cmdline_parse_token_string_t cmd_setflushrx_mode =
5472 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5476 cmdline_parse_inst_t cmd_set_flush_rx = {
5477 .f = cmd_set_flush_rx_parsed,
5478 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5481 (void *)&cmd_setflushrx_set,
5482 (void *)&cmd_setflushrx_flush_rx,
5483 (void *)&cmd_setflushrx_mode,
5488 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5489 struct cmd_set_link_check {
5490 cmdline_fixed_string_t set;
5491 cmdline_fixed_string_t link_check;
5492 cmdline_fixed_string_t mode;
5496 cmd_set_link_check_parsed(void *parsed_result,
5497 __rte_unused struct cmdline *cl,
5498 __rte_unused void *data)
5500 struct cmd_set_link_check *res = parsed_result;
5501 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5504 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5505 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5507 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5508 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5509 link_check, "link_check");
5510 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5511 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5515 cmdline_parse_inst_t cmd_set_link_check = {
5516 .f = cmd_set_link_check_parsed,
5517 .help_str = "set link_check on|off: Enable/Disable link status check "
5518 "when starting/stopping a port",
5521 (void *)&cmd_setlinkcheck_set,
5522 (void *)&cmd_setlinkcheck_link_check,
5523 (void *)&cmd_setlinkcheck_mode,
5528 /* *** SET NIC BYPASS MODE *** */
5529 struct cmd_set_bypass_mode_result {
5530 cmdline_fixed_string_t set;
5531 cmdline_fixed_string_t bypass;
5532 cmdline_fixed_string_t mode;
5533 cmdline_fixed_string_t value;
5538 cmd_set_bypass_mode_parsed(void *parsed_result,
5539 __rte_unused struct cmdline *cl,
5540 __rte_unused void *data)
5542 struct cmd_set_bypass_mode_result *res = parsed_result;
5543 portid_t port_id = res->port_id;
5544 int32_t rc = -EINVAL;
5546 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5547 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5549 if (!strcmp(res->value, "bypass"))
5550 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5551 else if (!strcmp(res->value, "isolate"))
5552 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5554 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5556 /* Set the bypass mode for the relevant port. */
5557 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5560 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5563 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5564 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5566 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5567 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5569 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5570 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5572 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5573 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5574 value, "normal#bypass#isolate");
5575 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5576 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5577 port_id, RTE_UINT16);
5579 cmdline_parse_inst_t cmd_set_bypass_mode = {
5580 .f = cmd_set_bypass_mode_parsed,
5581 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5582 "Set the NIC bypass mode for port_id",
5585 (void *)&cmd_setbypass_mode_set,
5586 (void *)&cmd_setbypass_mode_bypass,
5587 (void *)&cmd_setbypass_mode_mode,
5588 (void *)&cmd_setbypass_mode_value,
5589 (void *)&cmd_setbypass_mode_port,
5594 /* *** SET NIC BYPASS EVENT *** */
5595 struct cmd_set_bypass_event_result {
5596 cmdline_fixed_string_t set;
5597 cmdline_fixed_string_t bypass;
5598 cmdline_fixed_string_t event;
5599 cmdline_fixed_string_t event_value;
5600 cmdline_fixed_string_t mode;
5601 cmdline_fixed_string_t mode_value;
5606 cmd_set_bypass_event_parsed(void *parsed_result,
5607 __rte_unused struct cmdline *cl,
5608 __rte_unused void *data)
5610 int32_t rc = -EINVAL;
5611 struct cmd_set_bypass_event_result *res = parsed_result;
5612 portid_t port_id = res->port_id;
5614 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5615 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5616 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5618 if (!strcmp(res->event_value, "timeout"))
5619 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5620 else if (!strcmp(res->event_value, "os_on"))
5621 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5622 else if (!strcmp(res->event_value, "os_off"))
5623 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5624 else if (!strcmp(res->event_value, "power_on"))
5625 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5626 else if (!strcmp(res->event_value, "power_off"))
5627 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5629 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5631 if (!strcmp(res->mode_value, "bypass"))
5632 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5633 else if (!strcmp(res->mode_value, "isolate"))
5634 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5636 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5638 /* Set the watchdog timeout. */
5639 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5642 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5643 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5647 printf("Failed to set timeout value %u "
5648 "for port %d, errto code: %d.\n",
5649 bypass_timeout, port_id, rc);
5653 /* Set the bypass event to transition to bypass mode. */
5654 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5659 printf("\t Failed to set bypass event for port = %d.\n",
5663 cmdline_parse_token_string_t cmd_setbypass_event_set =
5664 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5666 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5667 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5669 cmdline_parse_token_string_t cmd_setbypass_event_event =
5670 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5672 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5673 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5674 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5675 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5676 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5678 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5679 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5680 mode_value, "normal#bypass#isolate");
5681 cmdline_parse_token_num_t cmd_setbypass_event_port =
5682 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5683 port_id, RTE_UINT16);
5685 cmdline_parse_inst_t cmd_set_bypass_event = {
5686 .f = cmd_set_bypass_event_parsed,
5687 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5688 "power_off mode normal|bypass|isolate <port_id>: "
5689 "Set the NIC bypass event mode for port_id",
5692 (void *)&cmd_setbypass_event_set,
5693 (void *)&cmd_setbypass_event_bypass,
5694 (void *)&cmd_setbypass_event_event,
5695 (void *)&cmd_setbypass_event_event_value,
5696 (void *)&cmd_setbypass_event_mode,
5697 (void *)&cmd_setbypass_event_mode_value,
5698 (void *)&cmd_setbypass_event_port,
5704 /* *** SET NIC BYPASS TIMEOUT *** */
5705 struct cmd_set_bypass_timeout_result {
5706 cmdline_fixed_string_t set;
5707 cmdline_fixed_string_t bypass;
5708 cmdline_fixed_string_t timeout;
5709 cmdline_fixed_string_t value;
5713 cmd_set_bypass_timeout_parsed(void *parsed_result,
5714 __rte_unused struct cmdline *cl,
5715 __rte_unused void *data)
5717 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5719 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5720 if (!strcmp(res->value, "1.5"))
5721 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5722 else if (!strcmp(res->value, "2"))
5723 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5724 else if (!strcmp(res->value, "3"))
5725 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5726 else if (!strcmp(res->value, "4"))
5727 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5728 else if (!strcmp(res->value, "8"))
5729 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5730 else if (!strcmp(res->value, "16"))
5731 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5732 else if (!strcmp(res->value, "32"))
5733 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5735 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5739 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5740 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5742 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5743 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5745 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5746 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5747 timeout, "timeout");
5748 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5749 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5750 value, "0#1.5#2#3#4#8#16#32");
5752 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5753 .f = cmd_set_bypass_timeout_parsed,
5754 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5755 "Set the NIC bypass watchdog timeout in seconds",
5758 (void *)&cmd_setbypass_timeout_set,
5759 (void *)&cmd_setbypass_timeout_bypass,
5760 (void *)&cmd_setbypass_timeout_timeout,
5761 (void *)&cmd_setbypass_timeout_value,
5766 /* *** SHOW NIC BYPASS MODE *** */
5767 struct cmd_show_bypass_config_result {
5768 cmdline_fixed_string_t show;
5769 cmdline_fixed_string_t bypass;
5770 cmdline_fixed_string_t config;
5775 cmd_show_bypass_config_parsed(void *parsed_result,
5776 __rte_unused struct cmdline *cl,
5777 __rte_unused void *data)
5779 struct cmd_show_bypass_config_result *res = parsed_result;
5780 portid_t port_id = res->port_id;
5782 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5783 uint32_t event_mode;
5784 uint32_t bypass_mode;
5785 uint32_t timeout = bypass_timeout;
5788 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5789 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5790 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5791 {"UNKNOWN", "normal", "bypass", "isolate"};
5792 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5800 /* Display the bypass mode.*/
5801 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5802 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5806 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5807 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5809 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5812 /* Display the bypass timeout.*/
5813 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5814 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5816 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5818 /* Display the bypass events and associated modes. */
5819 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5821 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5822 printf("\tFailed to get bypass mode for event = %s\n",
5825 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5826 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5828 printf("\tbypass event: %-16s = %s\n", events[i],
5834 printf("\tFailed to get bypass configuration for port = %d\n",
5838 cmdline_parse_token_string_t cmd_showbypass_config_show =
5839 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5841 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5842 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5844 cmdline_parse_token_string_t cmd_showbypass_config_config =
5845 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5847 cmdline_parse_token_num_t cmd_showbypass_config_port =
5848 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5849 port_id, RTE_UINT16);
5851 cmdline_parse_inst_t cmd_show_bypass_config = {
5852 .f = cmd_show_bypass_config_parsed,
5853 .help_str = "show bypass config <port_id>: "
5854 "Show the NIC bypass config for port_id",
5857 (void *)&cmd_showbypass_config_show,
5858 (void *)&cmd_showbypass_config_bypass,
5859 (void *)&cmd_showbypass_config_config,
5860 (void *)&cmd_showbypass_config_port,
5866 /* *** SET BONDING MODE *** */
5867 struct cmd_set_bonding_mode_result {
5868 cmdline_fixed_string_t set;
5869 cmdline_fixed_string_t bonding;
5870 cmdline_fixed_string_t mode;
5875 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5876 __rte_unused struct cmdline *cl,
5877 __rte_unused void *data)
5879 struct cmd_set_bonding_mode_result *res = parsed_result;
5880 portid_t port_id = res->port_id;
5882 /* Set the bonding mode for the relevant port. */
5883 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5884 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5887 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5888 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5890 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5891 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5892 bonding, "bonding");
5893 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5894 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5896 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5897 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5899 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5900 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5901 port_id, RTE_UINT16);
5903 cmdline_parse_inst_t cmd_set_bonding_mode = {
5904 .f = cmd_set_bonding_mode_parsed,
5905 .help_str = "set bonding mode <mode_value> <port_id>: "
5906 "Set the bonding mode for port_id",
5909 (void *) &cmd_setbonding_mode_set,
5910 (void *) &cmd_setbonding_mode_bonding,
5911 (void *) &cmd_setbonding_mode_mode,
5912 (void *) &cmd_setbonding_mode_value,
5913 (void *) &cmd_setbonding_mode_port,
5918 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5919 struct cmd_set_bonding_lacp_dedicated_queues_result {
5920 cmdline_fixed_string_t set;
5921 cmdline_fixed_string_t bonding;
5922 cmdline_fixed_string_t lacp;
5923 cmdline_fixed_string_t dedicated_queues;
5925 cmdline_fixed_string_t mode;
5928 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5929 __rte_unused struct cmdline *cl,
5930 __rte_unused void *data)
5932 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5933 portid_t port_id = res->port_id;
5934 struct rte_port *port;
5936 port = &ports[port_id];
5938 /** Check if the port is not started **/
5939 if (port->port_status != RTE_PORT_STOPPED) {
5940 printf("Please stop port %d first\n", port_id);
5944 if (!strcmp(res->mode, "enable")) {
5945 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5946 printf("Dedicate queues for LACP control packets"
5949 printf("Enabling dedicate queues for LACP control "
5950 "packets on port %d failed\n", port_id);
5951 } else if (!strcmp(res->mode, "disable")) {
5952 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5953 printf("Dedicated queues for LACP control packets "
5956 printf("Disabling dedicated queues for LACP control "
5957 "traffic on port %d failed\n", port_id);
5961 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5962 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5964 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5965 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5966 bonding, "bonding");
5967 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5968 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5970 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5971 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5972 dedicated_queues, "dedicated_queues");
5973 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5974 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5975 port_id, RTE_UINT16);
5976 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5977 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5978 mode, "enable#disable");
5980 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5981 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5982 .help_str = "set bonding lacp dedicated_queues <port_id> "
5984 "Enable/disable dedicated queues for LACP control traffic for port_id",
5987 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5988 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5989 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5990 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5991 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5992 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5997 /* *** SET BALANCE XMIT POLICY *** */
5998 struct cmd_set_bonding_balance_xmit_policy_result {
5999 cmdline_fixed_string_t set;
6000 cmdline_fixed_string_t bonding;
6001 cmdline_fixed_string_t balance_xmit_policy;
6003 cmdline_fixed_string_t policy;
6006 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6007 __rte_unused struct cmdline *cl,
6008 __rte_unused void *data)
6010 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6011 portid_t port_id = res->port_id;
6014 if (!strcmp(res->policy, "l2")) {
6015 policy = BALANCE_XMIT_POLICY_LAYER2;
6016 } else if (!strcmp(res->policy, "l23")) {
6017 policy = BALANCE_XMIT_POLICY_LAYER23;
6018 } else if (!strcmp(res->policy, "l34")) {
6019 policy = BALANCE_XMIT_POLICY_LAYER34;
6021 printf("\t Invalid xmit policy selection");
6025 /* Set the bonding mode for the relevant port. */
6026 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6027 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6032 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6033 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6035 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6036 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6037 bonding, "bonding");
6038 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6039 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6040 balance_xmit_policy, "balance_xmit_policy");
6041 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6042 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6043 port_id, RTE_UINT16);
6044 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6045 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6046 policy, "l2#l23#l34");
6048 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6049 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6050 .help_str = "set bonding balance_xmit_policy <port_id> "
6052 "Set the bonding balance_xmit_policy for port_id",
6055 (void *)&cmd_setbonding_balance_xmit_policy_set,
6056 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6057 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6058 (void *)&cmd_setbonding_balance_xmit_policy_port,
6059 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6064 /* *** SHOW NIC BONDING CONFIGURATION *** */
6065 struct cmd_show_bonding_config_result {
6066 cmdline_fixed_string_t show;
6067 cmdline_fixed_string_t bonding;
6068 cmdline_fixed_string_t config;
6072 static void cmd_show_bonding_config_parsed(void *parsed_result,
6073 __rte_unused struct cmdline *cl,
6074 __rte_unused void *data)
6076 struct cmd_show_bonding_config_result *res = parsed_result;
6077 int bonding_mode, agg_mode;
6078 portid_t slaves[RTE_MAX_ETHPORTS];
6079 int num_slaves, num_active_slaves;
6082 portid_t port_id = res->port_id;
6084 /* Display the bonding mode.*/
6085 bonding_mode = rte_eth_bond_mode_get(port_id);
6086 if (bonding_mode < 0) {
6087 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6090 printf("\tBonding mode: %d\n", bonding_mode);
6092 if (bonding_mode == BONDING_MODE_BALANCE) {
6093 int balance_xmit_policy;
6095 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6096 if (balance_xmit_policy < 0) {
6097 printf("\tFailed to get balance xmit policy for port = %d\n",
6101 printf("\tBalance Xmit Policy: ");
6103 switch (balance_xmit_policy) {
6104 case BALANCE_XMIT_POLICY_LAYER2:
6105 printf("BALANCE_XMIT_POLICY_LAYER2");
6107 case BALANCE_XMIT_POLICY_LAYER23:
6108 printf("BALANCE_XMIT_POLICY_LAYER23");
6110 case BALANCE_XMIT_POLICY_LAYER34:
6111 printf("BALANCE_XMIT_POLICY_LAYER34");
6118 if (bonding_mode == BONDING_MODE_8023AD) {
6119 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6120 printf("\tIEEE802.3AD Aggregator Mode: ");
6123 printf("bandwidth");
6135 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6137 if (num_slaves < 0) {
6138 printf("\tFailed to get slave list for port = %d\n", port_id);
6141 if (num_slaves > 0) {
6142 printf("\tSlaves (%d): [", num_slaves);
6143 for (i = 0; i < num_slaves - 1; i++)
6144 printf("%d ", slaves[i]);
6146 printf("%d]\n", slaves[num_slaves - 1]);
6148 printf("\tSlaves: []\n");
6152 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6155 if (num_active_slaves < 0) {
6156 printf("\tFailed to get active slave list for port = %d\n", port_id);
6159 if (num_active_slaves > 0) {
6160 printf("\tActive Slaves (%d): [", num_active_slaves);
6161 for (i = 0; i < num_active_slaves - 1; i++)
6162 printf("%d ", slaves[i]);
6164 printf("%d]\n", slaves[num_active_slaves - 1]);
6167 printf("\tActive Slaves: []\n");
6171 primary_id = rte_eth_bond_primary_get(port_id);
6172 if (primary_id < 0) {
6173 printf("\tFailed to get primary slave for port = %d\n", port_id);
6176 printf("\tPrimary: [%d]\n", primary_id);
6180 cmdline_parse_token_string_t cmd_showbonding_config_show =
6181 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6183 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6184 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6185 bonding, "bonding");
6186 cmdline_parse_token_string_t cmd_showbonding_config_config =
6187 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6189 cmdline_parse_token_num_t cmd_showbonding_config_port =
6190 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6191 port_id, RTE_UINT16);
6193 cmdline_parse_inst_t cmd_show_bonding_config = {
6194 .f = cmd_show_bonding_config_parsed,
6195 .help_str = "show bonding config <port_id>: "
6196 "Show the bonding config for port_id",
6199 (void *)&cmd_showbonding_config_show,
6200 (void *)&cmd_showbonding_config_bonding,
6201 (void *)&cmd_showbonding_config_config,
6202 (void *)&cmd_showbonding_config_port,
6207 /* *** SET BONDING PRIMARY *** */
6208 struct cmd_set_bonding_primary_result {
6209 cmdline_fixed_string_t set;
6210 cmdline_fixed_string_t bonding;
6211 cmdline_fixed_string_t primary;
6216 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6217 __rte_unused struct cmdline *cl,
6218 __rte_unused void *data)
6220 struct cmd_set_bonding_primary_result *res = parsed_result;
6221 portid_t master_port_id = res->port_id;
6222 portid_t slave_port_id = res->slave_id;
6224 /* Set the primary slave for a bonded device. */
6225 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6226 printf("\t Failed to set primary slave for port = %d.\n",
6233 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6234 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6236 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6237 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6238 bonding, "bonding");
6239 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6240 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6241 primary, "primary");
6242 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6243 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6244 slave_id, RTE_UINT16);
6245 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6246 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6247 port_id, RTE_UINT16);
6249 cmdline_parse_inst_t cmd_set_bonding_primary = {
6250 .f = cmd_set_bonding_primary_parsed,
6251 .help_str = "set bonding primary <slave_id> <port_id>: "
6252 "Set the primary slave for port_id",
6255 (void *)&cmd_setbonding_primary_set,
6256 (void *)&cmd_setbonding_primary_bonding,
6257 (void *)&cmd_setbonding_primary_primary,
6258 (void *)&cmd_setbonding_primary_slave,
6259 (void *)&cmd_setbonding_primary_port,
6264 /* *** ADD SLAVE *** */
6265 struct cmd_add_bonding_slave_result {
6266 cmdline_fixed_string_t add;
6267 cmdline_fixed_string_t bonding;
6268 cmdline_fixed_string_t slave;
6273 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6274 __rte_unused struct cmdline *cl,
6275 __rte_unused void *data)
6277 struct cmd_add_bonding_slave_result *res = parsed_result;
6278 portid_t master_port_id = res->port_id;
6279 portid_t slave_port_id = res->slave_id;
6281 /* add the slave for a bonded device. */
6282 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6283 printf("\t Failed to add slave %d to master port = %d.\n",
6284 slave_port_id, master_port_id);
6288 set_port_slave_flag(slave_port_id);
6291 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6292 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6294 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6295 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6296 bonding, "bonding");
6297 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6298 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6300 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6301 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6302 slave_id, RTE_UINT16);
6303 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6304 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6305 port_id, RTE_UINT16);
6307 cmdline_parse_inst_t cmd_add_bonding_slave = {
6308 .f = cmd_add_bonding_slave_parsed,
6309 .help_str = "add bonding slave <slave_id> <port_id>: "
6310 "Add a slave device to a bonded device",
6313 (void *)&cmd_addbonding_slave_add,
6314 (void *)&cmd_addbonding_slave_bonding,
6315 (void *)&cmd_addbonding_slave_slave,
6316 (void *)&cmd_addbonding_slave_slaveid,
6317 (void *)&cmd_addbonding_slave_port,
6322 /* *** REMOVE SLAVE *** */
6323 struct cmd_remove_bonding_slave_result {
6324 cmdline_fixed_string_t remove;
6325 cmdline_fixed_string_t bonding;
6326 cmdline_fixed_string_t slave;
6331 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6332 __rte_unused struct cmdline *cl,
6333 __rte_unused void *data)
6335 struct cmd_remove_bonding_slave_result *res = parsed_result;
6336 portid_t master_port_id = res->port_id;
6337 portid_t slave_port_id = res->slave_id;
6339 /* remove the slave from a bonded device. */
6340 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6341 printf("\t Failed to remove slave %d from master port = %d.\n",
6342 slave_port_id, master_port_id);
6346 clear_port_slave_flag(slave_port_id);
6349 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6350 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6352 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6353 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6354 bonding, "bonding");
6355 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6356 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6358 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6359 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6360 slave_id, RTE_UINT16);
6361 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6362 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6363 port_id, RTE_UINT16);
6365 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6366 .f = cmd_remove_bonding_slave_parsed,
6367 .help_str = "remove bonding slave <slave_id> <port_id>: "
6368 "Remove a slave device from a bonded device",
6371 (void *)&cmd_removebonding_slave_remove,
6372 (void *)&cmd_removebonding_slave_bonding,
6373 (void *)&cmd_removebonding_slave_slave,
6374 (void *)&cmd_removebonding_slave_slaveid,
6375 (void *)&cmd_removebonding_slave_port,
6380 /* *** CREATE BONDED DEVICE *** */
6381 struct cmd_create_bonded_device_result {
6382 cmdline_fixed_string_t create;
6383 cmdline_fixed_string_t bonded;
6384 cmdline_fixed_string_t device;
6389 static int bond_dev_num = 0;
6391 static void cmd_create_bonded_device_parsed(void *parsed_result,
6392 __rte_unused struct cmdline *cl,
6393 __rte_unused void *data)
6395 struct cmd_create_bonded_device_result *res = parsed_result;
6396 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6400 if (test_done == 0) {
6401 printf("Please stop forwarding first\n");
6405 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6408 /* Create a new bonded device. */
6409 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6411 printf("\t Failed to create bonded device.\n");
6414 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6417 /* Update number of ports */
6418 nb_ports = rte_eth_dev_count_avail();
6419 reconfig(port_id, res->socket);
6420 ret = rte_eth_promiscuous_enable(port_id);
6422 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6423 port_id, rte_strerror(-ret));
6425 ports[port_id].need_setup = 0;
6426 ports[port_id].port_status = RTE_PORT_STOPPED;
6431 cmdline_parse_token_string_t cmd_createbonded_device_create =
6432 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6434 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6435 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6437 cmdline_parse_token_string_t cmd_createbonded_device_device =
6438 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6440 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6441 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6443 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6444 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6447 cmdline_parse_inst_t cmd_create_bonded_device = {
6448 .f = cmd_create_bonded_device_parsed,
6449 .help_str = "create bonded device <mode> <socket>: "
6450 "Create a new bonded device with specific bonding mode and socket",
6453 (void *)&cmd_createbonded_device_create,
6454 (void *)&cmd_createbonded_device_bonded,
6455 (void *)&cmd_createbonded_device_device,
6456 (void *)&cmd_createbonded_device_mode,
6457 (void *)&cmd_createbonded_device_socket,
6462 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6463 struct cmd_set_bond_mac_addr_result {
6464 cmdline_fixed_string_t set;
6465 cmdline_fixed_string_t bonding;
6466 cmdline_fixed_string_t mac_addr;
6468 struct rte_ether_addr address;
6471 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6472 __rte_unused struct cmdline *cl,
6473 __rte_unused void *data)
6475 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6478 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6481 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6483 /* check the return value and print it if is < 0 */
6485 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6488 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6490 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6491 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6493 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6494 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6496 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6497 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6498 port_num, RTE_UINT16);
6499 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6500 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6502 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6503 .f = cmd_set_bond_mac_addr_parsed,
6505 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6507 (void *)&cmd_set_bond_mac_addr_set,
6508 (void *)&cmd_set_bond_mac_addr_bonding,
6509 (void *)&cmd_set_bond_mac_addr_mac,
6510 (void *)&cmd_set_bond_mac_addr_portnum,
6511 (void *)&cmd_set_bond_mac_addr_addr,
6517 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6518 struct cmd_set_bond_mon_period_result {
6519 cmdline_fixed_string_t set;
6520 cmdline_fixed_string_t bonding;
6521 cmdline_fixed_string_t mon_period;
6526 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6527 __rte_unused struct cmdline *cl,
6528 __rte_unused void *data)
6530 struct cmd_set_bond_mon_period_result *res = parsed_result;
6533 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6535 /* check the return value and print it if is < 0 */
6537 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6540 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6541 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6543 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6544 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6545 bonding, "bonding");
6546 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6547 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6548 mon_period, "mon_period");
6549 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6550 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6551 port_num, RTE_UINT16);
6552 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6553 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6554 period_ms, RTE_UINT32);
6556 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6557 .f = cmd_set_bond_mon_period_parsed,
6559 .help_str = "set bonding mon_period <port_id> <period_ms>",
6561 (void *)&cmd_set_bond_mon_period_set,
6562 (void *)&cmd_set_bond_mon_period_bonding,
6563 (void *)&cmd_set_bond_mon_period_mon_period,
6564 (void *)&cmd_set_bond_mon_period_portnum,
6565 (void *)&cmd_set_bond_mon_period_period_ms,
6572 struct cmd_set_bonding_agg_mode_policy_result {
6573 cmdline_fixed_string_t set;
6574 cmdline_fixed_string_t bonding;
6575 cmdline_fixed_string_t agg_mode;
6577 cmdline_fixed_string_t policy;
6582 cmd_set_bonding_agg_mode(void *parsed_result,
6583 __rte_unused struct cmdline *cl,
6584 __rte_unused void *data)
6586 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6587 uint8_t policy = AGG_BANDWIDTH;
6589 if (!strcmp(res->policy, "bandwidth"))
6590 policy = AGG_BANDWIDTH;
6591 else if (!strcmp(res->policy, "stable"))
6592 policy = AGG_STABLE;
6593 else if (!strcmp(res->policy, "count"))
6596 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6600 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6601 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6603 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6604 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6605 bonding, "bonding");
6607 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6608 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6609 agg_mode, "agg_mode");
6611 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6612 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6613 port_num, RTE_UINT16);
6615 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6616 TOKEN_STRING_INITIALIZER(
6617 struct cmd_set_bonding_balance_xmit_policy_result,
6618 policy, "stable#bandwidth#count");
6620 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6621 .f = cmd_set_bonding_agg_mode,
6623 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6625 (void *)&cmd_set_bonding_agg_mode_set,
6626 (void *)&cmd_set_bonding_agg_mode_bonding,
6627 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6628 (void *)&cmd_set_bonding_agg_mode_portnum,
6629 (void *)&cmd_set_bonding_agg_mode_policy_string,
6635 #endif /* RTE_NET_BOND */
6637 /* *** SET FORWARDING MODE *** */
6638 struct cmd_set_fwd_mode_result {
6639 cmdline_fixed_string_t set;
6640 cmdline_fixed_string_t fwd;
6641 cmdline_fixed_string_t mode;
6644 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6645 __rte_unused struct cmdline *cl,
6646 __rte_unused void *data)
6648 struct cmd_set_fwd_mode_result *res = parsed_result;
6651 set_pkt_forwarding_mode(res->mode);
6654 cmdline_parse_token_string_t cmd_setfwd_set =
6655 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6656 cmdline_parse_token_string_t cmd_setfwd_fwd =
6657 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6658 cmdline_parse_token_string_t cmd_setfwd_mode =
6659 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6660 "" /* defined at init */);
6662 cmdline_parse_inst_t cmd_set_fwd_mode = {
6663 .f = cmd_set_fwd_mode_parsed,
6665 .help_str = NULL, /* defined at init */
6667 (void *)&cmd_setfwd_set,
6668 (void *)&cmd_setfwd_fwd,
6669 (void *)&cmd_setfwd_mode,
6674 static void cmd_set_fwd_mode_init(void)
6677 static char token[128];
6678 static char help[256];
6679 cmdline_parse_token_string_t *token_struct;
6681 modes = list_pkt_forwarding_modes();
6682 snprintf(help, sizeof(help), "set fwd %s: "
6683 "Set packet forwarding mode", modes);
6684 cmd_set_fwd_mode.help_str = help;
6686 /* string token separator is # */
6687 for (c = token; *modes != '\0'; modes++)
6692 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6693 token_struct->string_data.str = token;
6696 /* *** SET RETRY FORWARDING MODE *** */
6697 struct cmd_set_fwd_retry_mode_result {
6698 cmdline_fixed_string_t set;
6699 cmdline_fixed_string_t fwd;
6700 cmdline_fixed_string_t mode;
6701 cmdline_fixed_string_t retry;
6704 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6705 __rte_unused struct cmdline *cl,
6706 __rte_unused void *data)
6708 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6711 set_pkt_forwarding_mode(res->mode);
6714 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6715 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6717 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6718 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6720 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6721 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6723 "" /* defined at init */);
6724 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6725 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6728 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6729 .f = cmd_set_fwd_retry_mode_parsed,
6731 .help_str = NULL, /* defined at init */
6733 (void *)&cmd_setfwd_retry_set,
6734 (void *)&cmd_setfwd_retry_fwd,
6735 (void *)&cmd_setfwd_retry_mode,
6736 (void *)&cmd_setfwd_retry_retry,
6741 static void cmd_set_fwd_retry_mode_init(void)
6744 static char token[128];
6745 static char help[256];
6746 cmdline_parse_token_string_t *token_struct;
6748 modes = list_pkt_forwarding_retry_modes();
6749 snprintf(help, sizeof(help), "set fwd %s retry: "
6750 "Set packet forwarding mode with retry", modes);
6751 cmd_set_fwd_retry_mode.help_str = help;
6753 /* string token separator is # */
6754 for (c = token; *modes != '\0'; modes++)
6759 token_struct = (cmdline_parse_token_string_t *)
6760 cmd_set_fwd_retry_mode.tokens[2];
6761 token_struct->string_data.str = token;
6764 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6765 struct cmd_set_burst_tx_retry_result {
6766 cmdline_fixed_string_t set;
6767 cmdline_fixed_string_t burst;
6768 cmdline_fixed_string_t tx;
6769 cmdline_fixed_string_t delay;
6771 cmdline_fixed_string_t retry;
6775 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6776 __rte_unused struct cmdline *cl,
6777 __rte_unused void *data)
6779 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6781 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6782 && !strcmp(res->tx, "tx")) {
6783 if (!strcmp(res->delay, "delay"))
6784 burst_tx_delay_time = res->time;
6785 if (!strcmp(res->retry, "retry"))
6786 burst_tx_retry_num = res->retry_num;
6791 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6792 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6793 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6794 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6796 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6797 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6798 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6799 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6800 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6801 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6803 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6804 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6805 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6806 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6809 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6810 .f = cmd_set_burst_tx_retry_parsed,
6811 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6813 (void *)&cmd_set_burst_tx_retry_set,
6814 (void *)&cmd_set_burst_tx_retry_burst,
6815 (void *)&cmd_set_burst_tx_retry_tx,
6816 (void *)&cmd_set_burst_tx_retry_delay,
6817 (void *)&cmd_set_burst_tx_retry_time,
6818 (void *)&cmd_set_burst_tx_retry_retry,
6819 (void *)&cmd_set_burst_tx_retry_retry_num,
6824 /* *** SET PROMISC MODE *** */
6825 struct cmd_set_promisc_mode_result {
6826 cmdline_fixed_string_t set;
6827 cmdline_fixed_string_t promisc;
6828 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6829 uint16_t port_num; /* valid if "allports" argument == 0 */
6830 cmdline_fixed_string_t mode;
6833 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6834 __rte_unused struct cmdline *cl,
6837 struct cmd_set_promisc_mode_result *res = parsed_result;
6841 if (!strcmp(res->mode, "on"))
6848 RTE_ETH_FOREACH_DEV(i)
6849 eth_set_promisc_mode(i, enable);
6851 eth_set_promisc_mode(res->port_num, enable);
6855 cmdline_parse_token_string_t cmd_setpromisc_set =
6856 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6857 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6858 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6860 cmdline_parse_token_string_t cmd_setpromisc_portall =
6861 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6863 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6864 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6866 cmdline_parse_token_string_t cmd_setpromisc_mode =
6867 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6870 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6871 .f = cmd_set_promisc_mode_parsed,
6873 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6875 (void *)&cmd_setpromisc_set,
6876 (void *)&cmd_setpromisc_promisc,
6877 (void *)&cmd_setpromisc_portall,
6878 (void *)&cmd_setpromisc_mode,
6883 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6884 .f = cmd_set_promisc_mode_parsed,
6886 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6888 (void *)&cmd_setpromisc_set,
6889 (void *)&cmd_setpromisc_promisc,
6890 (void *)&cmd_setpromisc_portnum,
6891 (void *)&cmd_setpromisc_mode,
6896 /* *** SET ALLMULTI MODE *** */
6897 struct cmd_set_allmulti_mode_result {
6898 cmdline_fixed_string_t set;
6899 cmdline_fixed_string_t allmulti;
6900 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6901 uint16_t port_num; /* valid if "allports" argument == 0 */
6902 cmdline_fixed_string_t mode;
6905 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6906 __rte_unused struct cmdline *cl,
6909 struct cmd_set_allmulti_mode_result *res = parsed_result;
6913 if (!strcmp(res->mode, "on"))
6920 RTE_ETH_FOREACH_DEV(i) {
6921 eth_set_allmulticast_mode(i, enable);
6925 eth_set_allmulticast_mode(res->port_num, enable);
6929 cmdline_parse_token_string_t cmd_setallmulti_set =
6930 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6931 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6932 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6934 cmdline_parse_token_string_t cmd_setallmulti_portall =
6935 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6937 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6938 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6940 cmdline_parse_token_string_t cmd_setallmulti_mode =
6941 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6944 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6945 .f = cmd_set_allmulti_mode_parsed,
6947 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6949 (void *)&cmd_setallmulti_set,
6950 (void *)&cmd_setallmulti_allmulti,
6951 (void *)&cmd_setallmulti_portall,
6952 (void *)&cmd_setallmulti_mode,
6957 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6958 .f = cmd_set_allmulti_mode_parsed,
6960 .help_str = "set allmulti <port_id> on|off: "
6961 "Set allmulti mode on port_id",
6963 (void *)&cmd_setallmulti_set,
6964 (void *)&cmd_setallmulti_allmulti,
6965 (void *)&cmd_setallmulti_portnum,
6966 (void *)&cmd_setallmulti_mode,
6971 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6972 struct cmd_link_flow_ctrl_show {
6973 cmdline_fixed_string_t show;
6974 cmdline_fixed_string_t port;
6976 cmdline_fixed_string_t flow_ctrl;
6979 cmdline_parse_token_string_t cmd_lfc_show_show =
6980 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6982 cmdline_parse_token_string_t cmd_lfc_show_port =
6983 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6985 cmdline_parse_token_num_t cmd_lfc_show_portid =
6986 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6987 port_id, RTE_UINT16);
6988 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6989 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6990 flow_ctrl, "flow_ctrl");
6993 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6994 __rte_unused struct cmdline *cl,
6995 __rte_unused void *data)
6997 struct cmd_link_flow_ctrl_show *res = parsed_result;
6998 static const char *info_border = "*********************";
6999 struct rte_eth_fc_conf fc_conf;
7000 bool rx_fc_en = false;
7001 bool tx_fc_en = false;
7004 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7006 printf("Failed to get current flow ctrl information: err = %d\n",
7011 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7013 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7016 printf("\n%s Flow control infos for port %-2d %s\n",
7017 info_border, res->port_id, info_border);
7018 printf("FC mode:\n");
7019 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7020 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7021 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7022 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7023 printf("High waterline: 0x%x\n", fc_conf.high_water);
7024 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7025 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7026 printf("Forward MAC control frames: %s\n",
7027 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7028 printf("\n%s************** End ***********%s\n",
7029 info_border, info_border);
7032 cmdline_parse_inst_t cmd_link_flow_control_show = {
7033 .f = cmd_link_flow_ctrl_show_parsed,
7035 .help_str = "show port <port_id> flow_ctrl",
7037 (void *)&cmd_lfc_show_show,
7038 (void *)&cmd_lfc_show_port,
7039 (void *)&cmd_lfc_show_portid,
7040 (void *)&cmd_lfc_show_flow_ctrl,
7045 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7046 struct cmd_link_flow_ctrl_set_result {
7047 cmdline_fixed_string_t set;
7048 cmdline_fixed_string_t flow_ctrl;
7049 cmdline_fixed_string_t rx;
7050 cmdline_fixed_string_t rx_lfc_mode;
7051 cmdline_fixed_string_t tx;
7052 cmdline_fixed_string_t tx_lfc_mode;
7053 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7054 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7055 cmdline_fixed_string_t autoneg_str;
7056 cmdline_fixed_string_t autoneg;
7057 cmdline_fixed_string_t hw_str;
7058 uint32_t high_water;
7059 cmdline_fixed_string_t lw_str;
7061 cmdline_fixed_string_t pt_str;
7062 uint16_t pause_time;
7063 cmdline_fixed_string_t xon_str;
7068 cmdline_parse_token_string_t cmd_lfc_set_set =
7069 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7071 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7072 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7073 flow_ctrl, "flow_ctrl");
7074 cmdline_parse_token_string_t cmd_lfc_set_rx =
7075 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7077 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7078 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7079 rx_lfc_mode, "on#off");
7080 cmdline_parse_token_string_t cmd_lfc_set_tx =
7081 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7083 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7084 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7085 tx_lfc_mode, "on#off");
7086 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7087 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7088 hw_str, "high_water");
7089 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7090 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7091 high_water, RTE_UINT32);
7092 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7093 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7094 lw_str, "low_water");
7095 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7096 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7097 low_water, RTE_UINT32);
7098 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7099 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7100 pt_str, "pause_time");
7101 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7102 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7103 pause_time, RTE_UINT16);
7104 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7105 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7106 xon_str, "send_xon");
7107 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7108 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7109 send_xon, RTE_UINT16);
7110 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7111 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7112 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7113 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7114 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7115 mac_ctrl_frame_fwd_mode, "on#off");
7116 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7117 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7118 autoneg_str, "autoneg");
7119 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7120 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7122 cmdline_parse_token_num_t cmd_lfc_set_portid =
7123 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7124 port_id, RTE_UINT16);
7126 /* forward declaration */
7128 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7131 cmdline_parse_inst_t cmd_link_flow_control_set = {
7132 .f = cmd_link_flow_ctrl_set_parsed,
7134 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7135 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7136 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7138 (void *)&cmd_lfc_set_set,
7139 (void *)&cmd_lfc_set_flow_ctrl,
7140 (void *)&cmd_lfc_set_rx,
7141 (void *)&cmd_lfc_set_rx_mode,
7142 (void *)&cmd_lfc_set_tx,
7143 (void *)&cmd_lfc_set_tx_mode,
7144 (void *)&cmd_lfc_set_high_water,
7145 (void *)&cmd_lfc_set_low_water,
7146 (void *)&cmd_lfc_set_pause_time,
7147 (void *)&cmd_lfc_set_send_xon,
7148 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7149 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7150 (void *)&cmd_lfc_set_autoneg_str,
7151 (void *)&cmd_lfc_set_autoneg,
7152 (void *)&cmd_lfc_set_portid,
7157 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7158 .f = cmd_link_flow_ctrl_set_parsed,
7159 .data = (void *)&cmd_link_flow_control_set_rx,
7160 .help_str = "set flow_ctrl rx on|off <port_id>: "
7161 "Change rx flow control parameter",
7163 (void *)&cmd_lfc_set_set,
7164 (void *)&cmd_lfc_set_flow_ctrl,
7165 (void *)&cmd_lfc_set_rx,
7166 (void *)&cmd_lfc_set_rx_mode,
7167 (void *)&cmd_lfc_set_portid,
7172 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7173 .f = cmd_link_flow_ctrl_set_parsed,
7174 .data = (void *)&cmd_link_flow_control_set_tx,
7175 .help_str = "set flow_ctrl tx on|off <port_id>: "
7176 "Change tx flow control parameter",
7178 (void *)&cmd_lfc_set_set,
7179 (void *)&cmd_lfc_set_flow_ctrl,
7180 (void *)&cmd_lfc_set_tx,
7181 (void *)&cmd_lfc_set_tx_mode,
7182 (void *)&cmd_lfc_set_portid,
7187 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7188 .f = cmd_link_flow_ctrl_set_parsed,
7189 .data = (void *)&cmd_link_flow_control_set_hw,
7190 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7191 "Change high water flow control parameter",
7193 (void *)&cmd_lfc_set_set,
7194 (void *)&cmd_lfc_set_flow_ctrl,
7195 (void *)&cmd_lfc_set_high_water_str,
7196 (void *)&cmd_lfc_set_high_water,
7197 (void *)&cmd_lfc_set_portid,
7202 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7203 .f = cmd_link_flow_ctrl_set_parsed,
7204 .data = (void *)&cmd_link_flow_control_set_lw,
7205 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7206 "Change low water flow control parameter",
7208 (void *)&cmd_lfc_set_set,
7209 (void *)&cmd_lfc_set_flow_ctrl,
7210 (void *)&cmd_lfc_set_low_water_str,
7211 (void *)&cmd_lfc_set_low_water,
7212 (void *)&cmd_lfc_set_portid,
7217 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7218 .f = cmd_link_flow_ctrl_set_parsed,
7219 .data = (void *)&cmd_link_flow_control_set_pt,
7220 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7221 "Change pause time flow control parameter",
7223 (void *)&cmd_lfc_set_set,
7224 (void *)&cmd_lfc_set_flow_ctrl,
7225 (void *)&cmd_lfc_set_pause_time_str,
7226 (void *)&cmd_lfc_set_pause_time,
7227 (void *)&cmd_lfc_set_portid,
7232 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7233 .f = cmd_link_flow_ctrl_set_parsed,
7234 .data = (void *)&cmd_link_flow_control_set_xon,
7235 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7236 "Change send_xon flow control parameter",
7238 (void *)&cmd_lfc_set_set,
7239 (void *)&cmd_lfc_set_flow_ctrl,
7240 (void *)&cmd_lfc_set_send_xon_str,
7241 (void *)&cmd_lfc_set_send_xon,
7242 (void *)&cmd_lfc_set_portid,
7247 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7248 .f = cmd_link_flow_ctrl_set_parsed,
7249 .data = (void *)&cmd_link_flow_control_set_macfwd,
7250 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7251 "Change mac ctrl fwd flow control parameter",
7253 (void *)&cmd_lfc_set_set,
7254 (void *)&cmd_lfc_set_flow_ctrl,
7255 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7256 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7257 (void *)&cmd_lfc_set_portid,
7262 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7263 .f = cmd_link_flow_ctrl_set_parsed,
7264 .data = (void *)&cmd_link_flow_control_set_autoneg,
7265 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7266 "Change autoneg flow control parameter",
7268 (void *)&cmd_lfc_set_set,
7269 (void *)&cmd_lfc_set_flow_ctrl,
7270 (void *)&cmd_lfc_set_autoneg_str,
7271 (void *)&cmd_lfc_set_autoneg,
7272 (void *)&cmd_lfc_set_portid,
7278 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7279 __rte_unused struct cmdline *cl,
7282 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7283 cmdline_parse_inst_t *cmd = data;
7284 struct rte_eth_fc_conf fc_conf;
7290 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7291 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7292 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7293 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7295 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7296 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7299 /* Partial command line, retrieve current configuration */
7301 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7303 printf("cannot get current flow ctrl parameters, return"
7304 "code = %d\n", ret);
7308 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7309 (fc_conf.mode == RTE_FC_FULL))
7311 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7312 (fc_conf.mode == RTE_FC_FULL))
7316 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7317 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7319 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7320 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7322 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7324 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7325 fc_conf.high_water = res->high_water;
7327 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7328 fc_conf.low_water = res->low_water;
7330 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7331 fc_conf.pause_time = res->pause_time;
7333 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7334 fc_conf.send_xon = res->send_xon;
7336 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7337 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7338 fc_conf.mac_ctrl_frame_fwd = 1;
7340 fc_conf.mac_ctrl_frame_fwd = 0;
7343 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7344 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7346 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7348 printf("bad flow contrl parameter, return code = %d \n", ret);
7351 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7352 struct cmd_priority_flow_ctrl_set_result {
7353 cmdline_fixed_string_t set;
7354 cmdline_fixed_string_t pfc_ctrl;
7355 cmdline_fixed_string_t rx;
7356 cmdline_fixed_string_t rx_pfc_mode;
7357 cmdline_fixed_string_t tx;
7358 cmdline_fixed_string_t tx_pfc_mode;
7359 uint32_t high_water;
7361 uint16_t pause_time;
7367 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7368 __rte_unused struct cmdline *cl,
7369 __rte_unused void *data)
7371 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7372 struct rte_eth_pfc_conf pfc_conf;
7373 int rx_fc_enable, tx_fc_enable;
7377 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7378 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7379 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7380 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7382 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7383 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7386 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7387 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7388 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7389 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7390 pfc_conf.fc.high_water = res->high_water;
7391 pfc_conf.fc.low_water = res->low_water;
7392 pfc_conf.fc.pause_time = res->pause_time;
7393 pfc_conf.priority = res->priority;
7395 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7397 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7400 cmdline_parse_token_string_t cmd_pfc_set_set =
7401 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7403 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7404 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7405 pfc_ctrl, "pfc_ctrl");
7406 cmdline_parse_token_string_t cmd_pfc_set_rx =
7407 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7409 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7410 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7411 rx_pfc_mode, "on#off");
7412 cmdline_parse_token_string_t cmd_pfc_set_tx =
7413 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7415 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7416 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7417 tx_pfc_mode, "on#off");
7418 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7419 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7420 high_water, RTE_UINT32);
7421 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7422 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7423 low_water, RTE_UINT32);
7424 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7425 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7426 pause_time, RTE_UINT16);
7427 cmdline_parse_token_num_t cmd_pfc_set_priority =
7428 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7429 priority, RTE_UINT8);
7430 cmdline_parse_token_num_t cmd_pfc_set_portid =
7431 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7432 port_id, RTE_UINT16);
7434 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7435 .f = cmd_priority_flow_ctrl_set_parsed,
7437 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7438 "<pause_time> <priority> <port_id>: "
7439 "Configure the Ethernet priority flow control",
7441 (void *)&cmd_pfc_set_set,
7442 (void *)&cmd_pfc_set_flow_ctrl,
7443 (void *)&cmd_pfc_set_rx,
7444 (void *)&cmd_pfc_set_rx_mode,
7445 (void *)&cmd_pfc_set_tx,
7446 (void *)&cmd_pfc_set_tx_mode,
7447 (void *)&cmd_pfc_set_high_water,
7448 (void *)&cmd_pfc_set_low_water,
7449 (void *)&cmd_pfc_set_pause_time,
7450 (void *)&cmd_pfc_set_priority,
7451 (void *)&cmd_pfc_set_portid,
7456 /* *** RESET CONFIGURATION *** */
7457 struct cmd_reset_result {
7458 cmdline_fixed_string_t reset;
7459 cmdline_fixed_string_t def;
7462 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7464 __rte_unused void *data)
7466 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7467 set_def_fwd_config();
7470 cmdline_parse_token_string_t cmd_reset_set =
7471 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7472 cmdline_parse_token_string_t cmd_reset_def =
7473 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7476 cmdline_parse_inst_t cmd_reset = {
7477 .f = cmd_reset_parsed,
7479 .help_str = "set default: Reset default forwarding configuration",
7481 (void *)&cmd_reset_set,
7482 (void *)&cmd_reset_def,
7487 /* *** START FORWARDING *** */
7488 struct cmd_start_result {
7489 cmdline_fixed_string_t start;
7492 cmdline_parse_token_string_t cmd_start_start =
7493 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7495 static void cmd_start_parsed(__rte_unused void *parsed_result,
7496 __rte_unused struct cmdline *cl,
7497 __rte_unused void *data)
7499 start_packet_forwarding(0);
7502 cmdline_parse_inst_t cmd_start = {
7503 .f = cmd_start_parsed,
7505 .help_str = "start: Start packet forwarding",
7507 (void *)&cmd_start_start,
7512 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7513 struct cmd_start_tx_first_result {
7514 cmdline_fixed_string_t start;
7515 cmdline_fixed_string_t tx_first;
7519 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7520 __rte_unused struct cmdline *cl,
7521 __rte_unused void *data)
7523 start_packet_forwarding(1);
7526 cmdline_parse_token_string_t cmd_start_tx_first_start =
7527 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7529 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7530 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7531 tx_first, "tx_first");
7533 cmdline_parse_inst_t cmd_start_tx_first = {
7534 .f = cmd_start_tx_first_parsed,
7536 .help_str = "start tx_first: Start packet forwarding, "
7537 "after sending 1 burst of packets",
7539 (void *)&cmd_start_tx_first_start,
7540 (void *)&cmd_start_tx_first_tx_first,
7545 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7546 struct cmd_start_tx_first_n_result {
7547 cmdline_fixed_string_t start;
7548 cmdline_fixed_string_t tx_first;
7553 cmd_start_tx_first_n_parsed(void *parsed_result,
7554 __rte_unused struct cmdline *cl,
7555 __rte_unused void *data)
7557 struct cmd_start_tx_first_n_result *res = parsed_result;
7559 start_packet_forwarding(res->tx_num);
7562 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7563 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7565 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7566 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7567 tx_first, "tx_first");
7568 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7569 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7570 tx_num, RTE_UINT32);
7572 cmdline_parse_inst_t cmd_start_tx_first_n = {
7573 .f = cmd_start_tx_first_n_parsed,
7575 .help_str = "start tx_first <num>: "
7576 "packet forwarding, after sending <num> bursts of packets",
7578 (void *)&cmd_start_tx_first_n_start,
7579 (void *)&cmd_start_tx_first_n_tx_first,
7580 (void *)&cmd_start_tx_first_n_tx_num,
7585 /* *** SET LINK UP *** */
7586 struct cmd_set_link_up_result {
7587 cmdline_fixed_string_t set;
7588 cmdline_fixed_string_t link_up;
7589 cmdline_fixed_string_t port;
7593 cmdline_parse_token_string_t cmd_set_link_up_set =
7594 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7595 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7596 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7598 cmdline_parse_token_string_t cmd_set_link_up_port =
7599 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7600 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7601 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7604 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7605 __rte_unused struct cmdline *cl,
7606 __rte_unused void *data)
7608 struct cmd_set_link_up_result *res = parsed_result;
7609 dev_set_link_up(res->port_id);
7612 cmdline_parse_inst_t cmd_set_link_up = {
7613 .f = cmd_set_link_up_parsed,
7615 .help_str = "set link-up port <port id>",
7617 (void *)&cmd_set_link_up_set,
7618 (void *)&cmd_set_link_up_link_up,
7619 (void *)&cmd_set_link_up_port,
7620 (void *)&cmd_set_link_up_port_id,
7625 /* *** SET LINK DOWN *** */
7626 struct cmd_set_link_down_result {
7627 cmdline_fixed_string_t set;
7628 cmdline_fixed_string_t link_down;
7629 cmdline_fixed_string_t port;
7633 cmdline_parse_token_string_t cmd_set_link_down_set =
7634 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7635 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7636 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7638 cmdline_parse_token_string_t cmd_set_link_down_port =
7639 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7640 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7641 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7644 static void cmd_set_link_down_parsed(
7645 __rte_unused void *parsed_result,
7646 __rte_unused struct cmdline *cl,
7647 __rte_unused void *data)
7649 struct cmd_set_link_down_result *res = parsed_result;
7650 dev_set_link_down(res->port_id);
7653 cmdline_parse_inst_t cmd_set_link_down = {
7654 .f = cmd_set_link_down_parsed,
7656 .help_str = "set link-down port <port id>",
7658 (void *)&cmd_set_link_down_set,
7659 (void *)&cmd_set_link_down_link_down,
7660 (void *)&cmd_set_link_down_port,
7661 (void *)&cmd_set_link_down_port_id,
7666 /* *** SHOW CFG *** */
7667 struct cmd_showcfg_result {
7668 cmdline_fixed_string_t show;
7669 cmdline_fixed_string_t cfg;
7670 cmdline_fixed_string_t what;
7673 static void cmd_showcfg_parsed(void *parsed_result,
7674 __rte_unused struct cmdline *cl,
7675 __rte_unused void *data)
7677 struct cmd_showcfg_result *res = parsed_result;
7678 if (!strcmp(res->what, "rxtx"))
7679 rxtx_config_display();
7680 else if (!strcmp(res->what, "cores"))
7681 fwd_lcores_config_display();
7682 else if (!strcmp(res->what, "fwd"))
7683 pkt_fwd_config_display(&cur_fwd_config);
7684 else if (!strcmp(res->what, "rxoffs"))
7685 show_rx_pkt_offsets();
7686 else if (!strcmp(res->what, "rxpkts"))
7687 show_rx_pkt_segments();
7688 else if (!strcmp(res->what, "txpkts"))
7689 show_tx_pkt_segments();
7690 else if (!strcmp(res->what, "txtimes"))
7691 show_tx_pkt_times();
7694 cmdline_parse_token_string_t cmd_showcfg_show =
7695 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7696 cmdline_parse_token_string_t cmd_showcfg_port =
7697 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7698 cmdline_parse_token_string_t cmd_showcfg_what =
7699 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7700 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7702 cmdline_parse_inst_t cmd_showcfg = {
7703 .f = cmd_showcfg_parsed,
7705 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7707 (void *)&cmd_showcfg_show,
7708 (void *)&cmd_showcfg_port,
7709 (void *)&cmd_showcfg_what,
7714 /* *** SHOW ALL PORT INFO *** */
7715 struct cmd_showportall_result {
7716 cmdline_fixed_string_t show;
7717 cmdline_fixed_string_t port;
7718 cmdline_fixed_string_t what;
7719 cmdline_fixed_string_t all;
7722 static void cmd_showportall_parsed(void *parsed_result,
7723 __rte_unused struct cmdline *cl,
7724 __rte_unused void *data)
7728 struct cmd_showportall_result *res = parsed_result;
7729 if (!strcmp(res->show, "clear")) {
7730 if (!strcmp(res->what, "stats"))
7731 RTE_ETH_FOREACH_DEV(i)
7733 else if (!strcmp(res->what, "xstats"))
7734 RTE_ETH_FOREACH_DEV(i)
7735 nic_xstats_clear(i);
7736 } else if (!strcmp(res->what, "info"))
7737 RTE_ETH_FOREACH_DEV(i)
7738 port_infos_display(i);
7739 else if (!strcmp(res->what, "summary")) {
7740 port_summary_header_display();
7741 RTE_ETH_FOREACH_DEV(i)
7742 port_summary_display(i);
7744 else if (!strcmp(res->what, "stats"))
7745 RTE_ETH_FOREACH_DEV(i)
7746 nic_stats_display(i);
7747 else if (!strcmp(res->what, "xstats"))
7748 RTE_ETH_FOREACH_DEV(i)
7749 nic_xstats_display(i);
7750 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7751 else if (!strcmp(res->what, "fdir"))
7752 RTE_ETH_FOREACH_DEV(i)
7755 else if (!strcmp(res->what, "dcb_tc"))
7756 RTE_ETH_FOREACH_DEV(i)
7757 port_dcb_info_display(i);
7760 cmdline_parse_token_string_t cmd_showportall_show =
7761 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7763 cmdline_parse_token_string_t cmd_showportall_port =
7764 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7765 cmdline_parse_token_string_t cmd_showportall_what =
7766 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7767 "info#summary#stats#xstats#fdir#dcb_tc");
7768 cmdline_parse_token_string_t cmd_showportall_all =
7769 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7770 cmdline_parse_inst_t cmd_showportall = {
7771 .f = cmd_showportall_parsed,
7773 .help_str = "show|clear port "
7774 "info|summary|stats|xstats|fdir|dcb_tc all",
7776 (void *)&cmd_showportall_show,
7777 (void *)&cmd_showportall_port,
7778 (void *)&cmd_showportall_what,
7779 (void *)&cmd_showportall_all,
7784 /* *** SHOW PORT INFO *** */
7785 struct cmd_showport_result {
7786 cmdline_fixed_string_t show;
7787 cmdline_fixed_string_t port;
7788 cmdline_fixed_string_t what;
7792 static void cmd_showport_parsed(void *parsed_result,
7793 __rte_unused struct cmdline *cl,
7794 __rte_unused void *data)
7796 struct cmd_showport_result *res = parsed_result;
7797 if (!strcmp(res->show, "clear")) {
7798 if (!strcmp(res->what, "stats"))
7799 nic_stats_clear(res->portnum);
7800 else if (!strcmp(res->what, "xstats"))
7801 nic_xstats_clear(res->portnum);
7802 } else if (!strcmp(res->what, "info"))
7803 port_infos_display(res->portnum);
7804 else if (!strcmp(res->what, "summary")) {
7805 port_summary_header_display();
7806 port_summary_display(res->portnum);
7808 else if (!strcmp(res->what, "stats"))
7809 nic_stats_display(res->portnum);
7810 else if (!strcmp(res->what, "xstats"))
7811 nic_xstats_display(res->portnum);
7812 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7813 else if (!strcmp(res->what, "fdir"))
7814 fdir_get_infos(res->portnum);
7816 else if (!strcmp(res->what, "dcb_tc"))
7817 port_dcb_info_display(res->portnum);
7820 cmdline_parse_token_string_t cmd_showport_show =
7821 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7823 cmdline_parse_token_string_t cmd_showport_port =
7824 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7825 cmdline_parse_token_string_t cmd_showport_what =
7826 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7827 "info#summary#stats#xstats#fdir#dcb_tc");
7828 cmdline_parse_token_num_t cmd_showport_portnum =
7829 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7831 cmdline_parse_inst_t cmd_showport = {
7832 .f = cmd_showport_parsed,
7834 .help_str = "show|clear port "
7835 "info|summary|stats|xstats|fdir|dcb_tc "
7838 (void *)&cmd_showport_show,
7839 (void *)&cmd_showport_port,
7840 (void *)&cmd_showport_what,
7841 (void *)&cmd_showport_portnum,
7846 /* *** SHOW DEVICE INFO *** */
7847 struct cmd_showdevice_result {
7848 cmdline_fixed_string_t show;
7849 cmdline_fixed_string_t device;
7850 cmdline_fixed_string_t what;
7851 cmdline_fixed_string_t identifier;
7854 static void cmd_showdevice_parsed(void *parsed_result,
7855 __rte_unused struct cmdline *cl,
7856 __rte_unused void *data)
7858 struct cmd_showdevice_result *res = parsed_result;
7859 if (!strcmp(res->what, "info")) {
7860 if (!strcmp(res->identifier, "all"))
7861 device_infos_display(NULL);
7863 device_infos_display(res->identifier);
7867 cmdline_parse_token_string_t cmd_showdevice_show =
7868 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7870 cmdline_parse_token_string_t cmd_showdevice_device =
7871 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7872 cmdline_parse_token_string_t cmd_showdevice_what =
7873 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7875 cmdline_parse_token_string_t cmd_showdevice_identifier =
7876 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7879 cmdline_parse_inst_t cmd_showdevice = {
7880 .f = cmd_showdevice_parsed,
7882 .help_str = "show device info <identifier>|all",
7884 (void *)&cmd_showdevice_show,
7885 (void *)&cmd_showdevice_device,
7886 (void *)&cmd_showdevice_what,
7887 (void *)&cmd_showdevice_identifier,
7892 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7893 struct cmd_showeeprom_result {
7894 cmdline_fixed_string_t show;
7895 cmdline_fixed_string_t port;
7897 cmdline_fixed_string_t type;
7900 static void cmd_showeeprom_parsed(void *parsed_result,
7901 __rte_unused struct cmdline *cl,
7902 __rte_unused void *data)
7904 struct cmd_showeeprom_result *res = parsed_result;
7906 if (!strcmp(res->type, "eeprom"))
7907 port_eeprom_display(res->portnum);
7908 else if (!strcmp(res->type, "module_eeprom"))
7909 port_module_eeprom_display(res->portnum);
7911 printf("Unknown argument\n");
7914 cmdline_parse_token_string_t cmd_showeeprom_show =
7915 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7916 cmdline_parse_token_string_t cmd_showeeprom_port =
7917 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7918 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7919 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7921 cmdline_parse_token_string_t cmd_showeeprom_type =
7922 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7924 cmdline_parse_inst_t cmd_showeeprom = {
7925 .f = cmd_showeeprom_parsed,
7927 .help_str = "show port <port_id> module_eeprom|eeprom",
7929 (void *)&cmd_showeeprom_show,
7930 (void *)&cmd_showeeprom_port,
7931 (void *)&cmd_showeeprom_portnum,
7932 (void *)&cmd_showeeprom_type,
7937 /* *** SHOW QUEUE INFO *** */
7938 struct cmd_showqueue_result {
7939 cmdline_fixed_string_t show;
7940 cmdline_fixed_string_t type;
7941 cmdline_fixed_string_t what;
7947 cmd_showqueue_parsed(void *parsed_result,
7948 __rte_unused struct cmdline *cl,
7949 __rte_unused void *data)
7951 struct cmd_showqueue_result *res = parsed_result;
7953 if (!strcmp(res->type, "rxq"))
7954 rx_queue_infos_display(res->portnum, res->queuenum);
7955 else if (!strcmp(res->type, "txq"))
7956 tx_queue_infos_display(res->portnum, res->queuenum);
7959 cmdline_parse_token_string_t cmd_showqueue_show =
7960 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7961 cmdline_parse_token_string_t cmd_showqueue_type =
7962 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7963 cmdline_parse_token_string_t cmd_showqueue_what =
7964 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7965 cmdline_parse_token_num_t cmd_showqueue_portnum =
7966 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7968 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7969 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7972 cmdline_parse_inst_t cmd_showqueue = {
7973 .f = cmd_showqueue_parsed,
7975 .help_str = "show rxq|txq info <port_id> <queue_id>",
7977 (void *)&cmd_showqueue_show,
7978 (void *)&cmd_showqueue_type,
7979 (void *)&cmd_showqueue_what,
7980 (void *)&cmd_showqueue_portnum,
7981 (void *)&cmd_showqueue_queuenum,
7986 /* show/clear fwd engine statistics */
7988 cmdline_fixed_string_t action;
7989 cmdline_fixed_string_t fwd;
7990 cmdline_fixed_string_t stats;
7991 cmdline_fixed_string_t all;
7994 cmdline_parse_token_string_t cmd_fwd_action =
7995 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7996 cmdline_parse_token_string_t cmd_fwd_fwd =
7997 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7998 cmdline_parse_token_string_t cmd_fwd_stats =
7999 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8000 cmdline_parse_token_string_t cmd_fwd_all =
8001 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8004 cmd_showfwdall_parsed(void *parsed_result,
8005 __rte_unused struct cmdline *cl,
8006 __rte_unused void *data)
8008 struct fwd_result *res = parsed_result;
8010 if (!strcmp(res->action, "show"))
8011 fwd_stats_display();
8016 static cmdline_parse_inst_t cmd_showfwdall = {
8017 .f = cmd_showfwdall_parsed,
8019 .help_str = "show|clear fwd stats all",
8021 (void *)&cmd_fwd_action,
8022 (void *)&cmd_fwd_fwd,
8023 (void *)&cmd_fwd_stats,
8024 (void *)&cmd_fwd_all,
8029 /* *** READ PORT REGISTER *** */
8030 struct cmd_read_reg_result {
8031 cmdline_fixed_string_t read;
8032 cmdline_fixed_string_t reg;
8038 cmd_read_reg_parsed(void *parsed_result,
8039 __rte_unused struct cmdline *cl,
8040 __rte_unused void *data)
8042 struct cmd_read_reg_result *res = parsed_result;
8043 port_reg_display(res->port_id, res->reg_off);
8046 cmdline_parse_token_string_t cmd_read_reg_read =
8047 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8048 cmdline_parse_token_string_t cmd_read_reg_reg =
8049 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8050 cmdline_parse_token_num_t cmd_read_reg_port_id =
8051 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8052 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8053 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8055 cmdline_parse_inst_t cmd_read_reg = {
8056 .f = cmd_read_reg_parsed,
8058 .help_str = "read reg <port_id> <reg_off>",
8060 (void *)&cmd_read_reg_read,
8061 (void *)&cmd_read_reg_reg,
8062 (void *)&cmd_read_reg_port_id,
8063 (void *)&cmd_read_reg_reg_off,
8068 /* *** READ PORT REGISTER BIT FIELD *** */
8069 struct cmd_read_reg_bit_field_result {
8070 cmdline_fixed_string_t read;
8071 cmdline_fixed_string_t regfield;
8079 cmd_read_reg_bit_field_parsed(void *parsed_result,
8080 __rte_unused struct cmdline *cl,
8081 __rte_unused void *data)
8083 struct cmd_read_reg_bit_field_result *res = parsed_result;
8084 port_reg_bit_field_display(res->port_id, res->reg_off,
8085 res->bit1_pos, res->bit2_pos);
8088 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8089 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8091 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8092 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8093 regfield, "regfield");
8094 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8095 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8097 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8098 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8100 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8101 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8103 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8104 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8107 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8108 .f = cmd_read_reg_bit_field_parsed,
8110 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8111 "Read register bit field between bit_x and bit_y included",
8113 (void *)&cmd_read_reg_bit_field_read,
8114 (void *)&cmd_read_reg_bit_field_regfield,
8115 (void *)&cmd_read_reg_bit_field_port_id,
8116 (void *)&cmd_read_reg_bit_field_reg_off,
8117 (void *)&cmd_read_reg_bit_field_bit1_pos,
8118 (void *)&cmd_read_reg_bit_field_bit2_pos,
8123 /* *** READ PORT REGISTER BIT *** */
8124 struct cmd_read_reg_bit_result {
8125 cmdline_fixed_string_t read;
8126 cmdline_fixed_string_t regbit;
8133 cmd_read_reg_bit_parsed(void *parsed_result,
8134 __rte_unused struct cmdline *cl,
8135 __rte_unused void *data)
8137 struct cmd_read_reg_bit_result *res = parsed_result;
8138 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8141 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8142 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8143 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8144 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8146 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8147 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8149 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8150 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8152 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8153 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8156 cmdline_parse_inst_t cmd_read_reg_bit = {
8157 .f = cmd_read_reg_bit_parsed,
8159 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8161 (void *)&cmd_read_reg_bit_read,
8162 (void *)&cmd_read_reg_bit_regbit,
8163 (void *)&cmd_read_reg_bit_port_id,
8164 (void *)&cmd_read_reg_bit_reg_off,
8165 (void *)&cmd_read_reg_bit_bit_pos,
8170 /* *** WRITE PORT REGISTER *** */
8171 struct cmd_write_reg_result {
8172 cmdline_fixed_string_t write;
8173 cmdline_fixed_string_t reg;
8180 cmd_write_reg_parsed(void *parsed_result,
8181 __rte_unused struct cmdline *cl,
8182 __rte_unused void *data)
8184 struct cmd_write_reg_result *res = parsed_result;
8185 port_reg_set(res->port_id, res->reg_off, res->value);
8188 cmdline_parse_token_string_t cmd_write_reg_write =
8189 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8190 cmdline_parse_token_string_t cmd_write_reg_reg =
8191 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8192 cmdline_parse_token_num_t cmd_write_reg_port_id =
8193 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8194 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8195 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8196 cmdline_parse_token_num_t cmd_write_reg_value =
8197 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8199 cmdline_parse_inst_t cmd_write_reg = {
8200 .f = cmd_write_reg_parsed,
8202 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8204 (void *)&cmd_write_reg_write,
8205 (void *)&cmd_write_reg_reg,
8206 (void *)&cmd_write_reg_port_id,
8207 (void *)&cmd_write_reg_reg_off,
8208 (void *)&cmd_write_reg_value,
8213 /* *** WRITE PORT REGISTER BIT FIELD *** */
8214 struct cmd_write_reg_bit_field_result {
8215 cmdline_fixed_string_t write;
8216 cmdline_fixed_string_t regfield;
8225 cmd_write_reg_bit_field_parsed(void *parsed_result,
8226 __rte_unused struct cmdline *cl,
8227 __rte_unused void *data)
8229 struct cmd_write_reg_bit_field_result *res = parsed_result;
8230 port_reg_bit_field_set(res->port_id, res->reg_off,
8231 res->bit1_pos, res->bit2_pos, res->value);
8234 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8235 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8237 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8238 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8239 regfield, "regfield");
8240 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8241 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8243 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8244 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8246 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8247 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8249 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8250 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8252 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8253 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8256 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8257 .f = cmd_write_reg_bit_field_parsed,
8259 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8261 "Set register bit field between bit_x and bit_y included",
8263 (void *)&cmd_write_reg_bit_field_write,
8264 (void *)&cmd_write_reg_bit_field_regfield,
8265 (void *)&cmd_write_reg_bit_field_port_id,
8266 (void *)&cmd_write_reg_bit_field_reg_off,
8267 (void *)&cmd_write_reg_bit_field_bit1_pos,
8268 (void *)&cmd_write_reg_bit_field_bit2_pos,
8269 (void *)&cmd_write_reg_bit_field_value,
8274 /* *** WRITE PORT REGISTER BIT *** */
8275 struct cmd_write_reg_bit_result {
8276 cmdline_fixed_string_t write;
8277 cmdline_fixed_string_t regbit;
8285 cmd_write_reg_bit_parsed(void *parsed_result,
8286 __rte_unused struct cmdline *cl,
8287 __rte_unused void *data)
8289 struct cmd_write_reg_bit_result *res = parsed_result;
8290 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8293 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8294 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8296 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8297 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8299 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8300 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8302 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8303 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8305 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8306 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8308 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8309 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8312 cmdline_parse_inst_t cmd_write_reg_bit = {
8313 .f = cmd_write_reg_bit_parsed,
8315 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8318 (void *)&cmd_write_reg_bit_write,
8319 (void *)&cmd_write_reg_bit_regbit,
8320 (void *)&cmd_write_reg_bit_port_id,
8321 (void *)&cmd_write_reg_bit_reg_off,
8322 (void *)&cmd_write_reg_bit_bit_pos,
8323 (void *)&cmd_write_reg_bit_value,
8328 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8329 struct cmd_read_rxd_txd_result {
8330 cmdline_fixed_string_t read;
8331 cmdline_fixed_string_t rxd_txd;
8338 cmd_read_rxd_txd_parsed(void *parsed_result,
8339 __rte_unused struct cmdline *cl,
8340 __rte_unused void *data)
8342 struct cmd_read_rxd_txd_result *res = parsed_result;
8344 if (!strcmp(res->rxd_txd, "rxd"))
8345 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8346 else if (!strcmp(res->rxd_txd, "txd"))
8347 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8350 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8351 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8352 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8353 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8355 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8356 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8358 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8359 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8361 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8362 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8365 cmdline_parse_inst_t cmd_read_rxd_txd = {
8366 .f = cmd_read_rxd_txd_parsed,
8368 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8370 (void *)&cmd_read_rxd_txd_read,
8371 (void *)&cmd_read_rxd_txd_rxd_txd,
8372 (void *)&cmd_read_rxd_txd_port_id,
8373 (void *)&cmd_read_rxd_txd_queue_id,
8374 (void *)&cmd_read_rxd_txd_desc_id,
8380 struct cmd_quit_result {
8381 cmdline_fixed_string_t quit;
8384 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8386 __rte_unused void *data)
8391 cmdline_parse_token_string_t cmd_quit_quit =
8392 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8394 cmdline_parse_inst_t cmd_quit = {
8395 .f = cmd_quit_parsed,
8397 .help_str = "quit: Exit application",
8399 (void *)&cmd_quit_quit,
8404 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8405 struct cmd_mac_addr_result {
8406 cmdline_fixed_string_t mac_addr_cmd;
8407 cmdline_fixed_string_t what;
8409 struct rte_ether_addr address;
8412 static void cmd_mac_addr_parsed(void *parsed_result,
8413 __rte_unused struct cmdline *cl,
8414 __rte_unused void *data)
8416 struct cmd_mac_addr_result *res = parsed_result;
8419 if (strcmp(res->what, "add") == 0)
8420 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8421 else if (strcmp(res->what, "set") == 0)
8422 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8425 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8427 /* check the return value and print it if is < 0 */
8429 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8433 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8434 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8436 cmdline_parse_token_string_t cmd_mac_addr_what =
8437 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8439 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8440 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8442 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8443 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8445 cmdline_parse_inst_t cmd_mac_addr = {
8446 .f = cmd_mac_addr_parsed,
8448 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8449 "Add/Remove/Set MAC address on port_id",
8451 (void *)&cmd_mac_addr_cmd,
8452 (void *)&cmd_mac_addr_what,
8453 (void *)&cmd_mac_addr_portnum,
8454 (void *)&cmd_mac_addr_addr,
8459 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8460 struct cmd_eth_peer_result {
8461 cmdline_fixed_string_t set;
8462 cmdline_fixed_string_t eth_peer;
8464 cmdline_fixed_string_t peer_addr;
8467 static void cmd_set_eth_peer_parsed(void *parsed_result,
8468 __rte_unused struct cmdline *cl,
8469 __rte_unused void *data)
8471 struct cmd_eth_peer_result *res = parsed_result;
8473 if (test_done == 0) {
8474 printf("Please stop forwarding first\n");
8477 if (!strcmp(res->eth_peer, "eth-peer")) {
8478 set_fwd_eth_peer(res->port_id, res->peer_addr);
8482 cmdline_parse_token_string_t cmd_eth_peer_set =
8483 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8484 cmdline_parse_token_string_t cmd_eth_peer =
8485 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8486 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8487 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8489 cmdline_parse_token_string_t cmd_eth_peer_addr =
8490 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8492 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8493 .f = cmd_set_eth_peer_parsed,
8495 .help_str = "set eth-peer <port_id> <peer_mac>",
8497 (void *)&cmd_eth_peer_set,
8498 (void *)&cmd_eth_peer,
8499 (void *)&cmd_eth_peer_port_id,
8500 (void *)&cmd_eth_peer_addr,
8505 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8506 struct cmd_set_qmap_result {
8507 cmdline_fixed_string_t set;
8508 cmdline_fixed_string_t qmap;
8509 cmdline_fixed_string_t what;
8516 cmd_set_qmap_parsed(void *parsed_result,
8517 __rte_unused struct cmdline *cl,
8518 __rte_unused void *data)
8520 struct cmd_set_qmap_result *res = parsed_result;
8521 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8523 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8526 cmdline_parse_token_string_t cmd_setqmap_set =
8527 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8529 cmdline_parse_token_string_t cmd_setqmap_qmap =
8530 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8532 cmdline_parse_token_string_t cmd_setqmap_what =
8533 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8535 cmdline_parse_token_num_t cmd_setqmap_portid =
8536 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8537 port_id, RTE_UINT16);
8538 cmdline_parse_token_num_t cmd_setqmap_queueid =
8539 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8540 queue_id, RTE_UINT16);
8541 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8542 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8543 map_value, RTE_UINT8);
8545 cmdline_parse_inst_t cmd_set_qmap = {
8546 .f = cmd_set_qmap_parsed,
8548 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8549 "Set statistics mapping value on tx|rx queue_id of port_id",
8551 (void *)&cmd_setqmap_set,
8552 (void *)&cmd_setqmap_qmap,
8553 (void *)&cmd_setqmap_what,
8554 (void *)&cmd_setqmap_portid,
8555 (void *)&cmd_setqmap_queueid,
8556 (void *)&cmd_setqmap_mapvalue,
8561 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8562 struct cmd_set_xstats_hide_zero_result {
8563 cmdline_fixed_string_t keyword;
8564 cmdline_fixed_string_t name;
8565 cmdline_fixed_string_t on_off;
8569 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8570 __rte_unused struct cmdline *cl,
8571 __rte_unused void *data)
8573 struct cmd_set_xstats_hide_zero_result *res;
8574 uint16_t on_off = 0;
8576 res = parsed_result;
8577 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8578 set_xstats_hide_zero(on_off);
8581 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8582 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8584 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8585 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8586 name, "xstats-hide-zero");
8587 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8588 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8591 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8592 .f = cmd_set_xstats_hide_zero_parsed,
8594 .help_str = "set xstats-hide-zero on|off",
8596 (void *)&cmd_set_xstats_hide_zero_keyword,
8597 (void *)&cmd_set_xstats_hide_zero_name,
8598 (void *)&cmd_set_xstats_hide_zero_on_off,
8603 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8604 struct cmd_set_record_core_cycles_result {
8605 cmdline_fixed_string_t keyword;
8606 cmdline_fixed_string_t name;
8607 cmdline_fixed_string_t on_off;
8611 cmd_set_record_core_cycles_parsed(void *parsed_result,
8612 __rte_unused struct cmdline *cl,
8613 __rte_unused void *data)
8615 struct cmd_set_record_core_cycles_result *res;
8616 uint16_t on_off = 0;
8618 res = parsed_result;
8619 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8620 set_record_core_cycles(on_off);
8623 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8624 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8626 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8627 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8628 name, "record-core-cycles");
8629 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8630 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8633 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8634 .f = cmd_set_record_core_cycles_parsed,
8636 .help_str = "set record-core-cycles on|off",
8638 (void *)&cmd_set_record_core_cycles_keyword,
8639 (void *)&cmd_set_record_core_cycles_name,
8640 (void *)&cmd_set_record_core_cycles_on_off,
8645 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8646 struct cmd_set_record_burst_stats_result {
8647 cmdline_fixed_string_t keyword;
8648 cmdline_fixed_string_t name;
8649 cmdline_fixed_string_t on_off;
8653 cmd_set_record_burst_stats_parsed(void *parsed_result,
8654 __rte_unused struct cmdline *cl,
8655 __rte_unused void *data)
8657 struct cmd_set_record_burst_stats_result *res;
8658 uint16_t on_off = 0;
8660 res = parsed_result;
8661 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8662 set_record_burst_stats(on_off);
8665 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8666 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8668 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8669 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8670 name, "record-burst-stats");
8671 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8672 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8675 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8676 .f = cmd_set_record_burst_stats_parsed,
8678 .help_str = "set record-burst-stats on|off",
8680 (void *)&cmd_set_record_burst_stats_keyword,
8681 (void *)&cmd_set_record_burst_stats_name,
8682 (void *)&cmd_set_record_burst_stats_on_off,
8687 /* *** CONFIGURE UNICAST HASH TABLE *** */
8688 struct cmd_set_uc_hash_table {
8689 cmdline_fixed_string_t set;
8690 cmdline_fixed_string_t port;
8692 cmdline_fixed_string_t what;
8693 struct rte_ether_addr address;
8694 cmdline_fixed_string_t mode;
8698 cmd_set_uc_hash_parsed(void *parsed_result,
8699 __rte_unused struct cmdline *cl,
8700 __rte_unused void *data)
8703 struct cmd_set_uc_hash_table *res = parsed_result;
8705 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8707 if (strcmp(res->what, "uta") == 0)
8708 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8709 &res->address,(uint8_t)is_on);
8711 printf("bad unicast hash table parameter, return code = %d \n", ret);
8715 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8716 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8718 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8719 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8721 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8722 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8723 port_id, RTE_UINT16);
8724 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8725 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8727 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8728 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8730 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8731 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8734 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8735 .f = cmd_set_uc_hash_parsed,
8737 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8739 (void *)&cmd_set_uc_hash_set,
8740 (void *)&cmd_set_uc_hash_port,
8741 (void *)&cmd_set_uc_hash_portid,
8742 (void *)&cmd_set_uc_hash_what,
8743 (void *)&cmd_set_uc_hash_mac,
8744 (void *)&cmd_set_uc_hash_mode,
8749 struct cmd_set_uc_all_hash_table {
8750 cmdline_fixed_string_t set;
8751 cmdline_fixed_string_t port;
8753 cmdline_fixed_string_t what;
8754 cmdline_fixed_string_t value;
8755 cmdline_fixed_string_t mode;
8759 cmd_set_uc_all_hash_parsed(void *parsed_result,
8760 __rte_unused struct cmdline *cl,
8761 __rte_unused void *data)
8764 struct cmd_set_uc_all_hash_table *res = parsed_result;
8766 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8768 if ((strcmp(res->what, "uta") == 0) &&
8769 (strcmp(res->value, "all") == 0))
8770 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8772 printf("bad unicast hash table parameter,"
8773 "return code = %d \n", ret);
8776 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8777 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8779 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8780 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8782 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8783 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8784 port_id, RTE_UINT16);
8785 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8786 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8788 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8789 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8791 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8792 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8795 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8796 .f = cmd_set_uc_all_hash_parsed,
8798 .help_str = "set port <port_id> uta all on|off",
8800 (void *)&cmd_set_uc_all_hash_set,
8801 (void *)&cmd_set_uc_all_hash_port,
8802 (void *)&cmd_set_uc_all_hash_portid,
8803 (void *)&cmd_set_uc_all_hash_what,
8804 (void *)&cmd_set_uc_all_hash_value,
8805 (void *)&cmd_set_uc_all_hash_mode,
8810 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8811 struct cmd_set_vf_traffic {
8812 cmdline_fixed_string_t set;
8813 cmdline_fixed_string_t port;
8815 cmdline_fixed_string_t vf;
8817 cmdline_fixed_string_t what;
8818 cmdline_fixed_string_t mode;
8822 cmd_set_vf_traffic_parsed(void *parsed_result,
8823 __rte_unused struct cmdline *cl,
8824 __rte_unused void *data)
8826 struct cmd_set_vf_traffic *res = parsed_result;
8827 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8828 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8830 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8833 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8834 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8836 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8837 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8839 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8840 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8841 port_id, RTE_UINT16);
8842 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8843 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8845 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8846 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8848 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8849 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8851 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8852 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8855 cmdline_parse_inst_t cmd_set_vf_traffic = {
8856 .f = cmd_set_vf_traffic_parsed,
8858 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8860 (void *)&cmd_setvf_traffic_set,
8861 (void *)&cmd_setvf_traffic_port,
8862 (void *)&cmd_setvf_traffic_portid,
8863 (void *)&cmd_setvf_traffic_vf,
8864 (void *)&cmd_setvf_traffic_vfid,
8865 (void *)&cmd_setvf_traffic_what,
8866 (void *)&cmd_setvf_traffic_mode,
8871 /* *** CONFIGURE VF RECEIVE MODE *** */
8872 struct cmd_set_vf_rxmode {
8873 cmdline_fixed_string_t set;
8874 cmdline_fixed_string_t port;
8876 cmdline_fixed_string_t vf;
8878 cmdline_fixed_string_t what;
8879 cmdline_fixed_string_t mode;
8880 cmdline_fixed_string_t on;
8884 cmd_set_vf_rxmode_parsed(void *parsed_result,
8885 __rte_unused struct cmdline *cl,
8886 __rte_unused void *data)
8889 uint16_t vf_rxmode = 0;
8890 struct cmd_set_vf_rxmode *res = parsed_result;
8892 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8893 if (!strcmp(res->what,"rxmode")) {
8894 if (!strcmp(res->mode, "AUPE"))
8895 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8896 else if (!strcmp(res->mode, "ROPE"))
8897 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8898 else if (!strcmp(res->mode, "BAM"))
8899 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8900 else if (!strncmp(res->mode, "MPE",3))
8901 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8904 RTE_SET_USED(is_on);
8906 #ifdef RTE_NET_IXGBE
8907 if (ret == -ENOTSUP)
8908 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8909 vf_rxmode, (uint8_t)is_on);
8912 if (ret == -ENOTSUP)
8913 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8914 vf_rxmode, (uint8_t)is_on);
8917 printf("bad VF receive mode parameter, return code = %d \n",
8921 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8922 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8924 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8925 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8927 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8928 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8929 port_id, RTE_UINT16);
8930 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8931 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8933 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8934 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8936 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8937 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8939 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8940 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8941 mode, "AUPE#ROPE#BAM#MPE");
8942 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8943 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8946 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8947 .f = cmd_set_vf_rxmode_parsed,
8949 .help_str = "set port <port_id> vf <vf_id> rxmode "
8950 "AUPE|ROPE|BAM|MPE on|off",
8952 (void *)&cmd_set_vf_rxmode_set,
8953 (void *)&cmd_set_vf_rxmode_port,
8954 (void *)&cmd_set_vf_rxmode_portid,
8955 (void *)&cmd_set_vf_rxmode_vf,
8956 (void *)&cmd_set_vf_rxmode_vfid,
8957 (void *)&cmd_set_vf_rxmode_what,
8958 (void *)&cmd_set_vf_rxmode_mode,
8959 (void *)&cmd_set_vf_rxmode_on,
8964 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8965 struct cmd_vf_mac_addr_result {
8966 cmdline_fixed_string_t mac_addr_cmd;
8967 cmdline_fixed_string_t what;
8968 cmdline_fixed_string_t port;
8970 cmdline_fixed_string_t vf;
8972 struct rte_ether_addr address;
8975 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8976 __rte_unused struct cmdline *cl,
8977 __rte_unused void *data)
8979 struct cmd_vf_mac_addr_result *res = parsed_result;
8982 if (strcmp(res->what, "add") != 0)
8986 if (ret == -ENOTSUP)
8987 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8991 if (ret == -ENOTSUP)
8992 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8997 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9001 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9002 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9003 mac_addr_cmd,"mac_addr");
9004 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9005 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9007 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9008 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9010 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9011 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9012 port_num, RTE_UINT16);
9013 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9014 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9016 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9017 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9019 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9020 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9023 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9024 .f = cmd_vf_mac_addr_parsed,
9026 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9027 "Add MAC address filtering for a VF on port_id",
9029 (void *)&cmd_vf_mac_addr_cmd,
9030 (void *)&cmd_vf_mac_addr_what,
9031 (void *)&cmd_vf_mac_addr_port,
9032 (void *)&cmd_vf_mac_addr_portnum,
9033 (void *)&cmd_vf_mac_addr_vf,
9034 (void *)&cmd_vf_mac_addr_vfnum,
9035 (void *)&cmd_vf_mac_addr_addr,
9040 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9041 struct cmd_vf_rx_vlan_filter {
9042 cmdline_fixed_string_t rx_vlan;
9043 cmdline_fixed_string_t what;
9045 cmdline_fixed_string_t port;
9047 cmdline_fixed_string_t vf;
9052 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9053 __rte_unused struct cmdline *cl,
9054 __rte_unused void *data)
9056 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9059 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9061 #ifdef RTE_NET_IXGBE
9062 if (ret == -ENOTSUP)
9063 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9064 res->vlan_id, res->vf_mask, is_add);
9067 if (ret == -ENOTSUP)
9068 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9069 res->vlan_id, res->vf_mask, is_add);
9072 if (ret == -ENOTSUP)
9073 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9074 res->vlan_id, res->vf_mask, is_add);
9081 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9082 res->vlan_id, res->vf_mask);
9085 printf("invalid port_id %d\n", res->port_id);
9088 printf("function not implemented or supported\n");
9091 printf("programming error: (%s)\n", strerror(-ret));
9095 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9096 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9097 rx_vlan, "rx_vlan");
9098 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9099 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9101 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9102 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9103 vlan_id, RTE_UINT16);
9104 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9105 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9107 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9108 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9109 port_id, RTE_UINT16);
9110 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9111 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9113 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9114 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9115 vf_mask, RTE_UINT64);
9117 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9118 .f = cmd_vf_rx_vlan_filter_parsed,
9120 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9121 "(vf_mask = hexadecimal VF mask)",
9123 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9124 (void *)&cmd_vf_rx_vlan_filter_what,
9125 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9126 (void *)&cmd_vf_rx_vlan_filter_port,
9127 (void *)&cmd_vf_rx_vlan_filter_portid,
9128 (void *)&cmd_vf_rx_vlan_filter_vf,
9129 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9134 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9135 struct cmd_queue_rate_limit_result {
9136 cmdline_fixed_string_t set;
9137 cmdline_fixed_string_t port;
9139 cmdline_fixed_string_t queue;
9141 cmdline_fixed_string_t rate;
9145 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9146 __rte_unused struct cmdline *cl,
9147 __rte_unused void *data)
9149 struct cmd_queue_rate_limit_result *res = parsed_result;
9152 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9153 && (strcmp(res->queue, "queue") == 0)
9154 && (strcmp(res->rate, "rate") == 0))
9155 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9158 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9162 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9163 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9165 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9166 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9168 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9169 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9170 port_num, RTE_UINT16);
9171 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9172 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9174 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9175 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9176 queue_num, RTE_UINT8);
9177 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9178 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9180 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9181 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9182 rate_num, RTE_UINT16);
9184 cmdline_parse_inst_t cmd_queue_rate_limit = {
9185 .f = cmd_queue_rate_limit_parsed,
9187 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9188 "Set rate limit for a queue on port_id",
9190 (void *)&cmd_queue_rate_limit_set,
9191 (void *)&cmd_queue_rate_limit_port,
9192 (void *)&cmd_queue_rate_limit_portnum,
9193 (void *)&cmd_queue_rate_limit_queue,
9194 (void *)&cmd_queue_rate_limit_queuenum,
9195 (void *)&cmd_queue_rate_limit_rate,
9196 (void *)&cmd_queue_rate_limit_ratenum,
9201 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9202 struct cmd_vf_rate_limit_result {
9203 cmdline_fixed_string_t set;
9204 cmdline_fixed_string_t port;
9206 cmdline_fixed_string_t vf;
9208 cmdline_fixed_string_t rate;
9210 cmdline_fixed_string_t q_msk;
9214 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9215 __rte_unused struct cmdline *cl,
9216 __rte_unused void *data)
9218 struct cmd_vf_rate_limit_result *res = parsed_result;
9221 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9222 && (strcmp(res->vf, "vf") == 0)
9223 && (strcmp(res->rate, "rate") == 0)
9224 && (strcmp(res->q_msk, "queue_mask") == 0))
9225 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9226 res->rate_num, res->q_msk_val);
9228 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9232 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9233 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9235 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9236 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9238 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9239 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9240 port_num, RTE_UINT16);
9241 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9242 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9244 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9245 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9247 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9248 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9250 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9251 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9252 rate_num, RTE_UINT16);
9253 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9254 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9255 q_msk, "queue_mask");
9256 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9257 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9258 q_msk_val, RTE_UINT64);
9260 cmdline_parse_inst_t cmd_vf_rate_limit = {
9261 .f = cmd_vf_rate_limit_parsed,
9263 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9264 "queue_mask <queue_mask_value>: "
9265 "Set rate limit for queues of VF on port_id",
9267 (void *)&cmd_vf_rate_limit_set,
9268 (void *)&cmd_vf_rate_limit_port,
9269 (void *)&cmd_vf_rate_limit_portnum,
9270 (void *)&cmd_vf_rate_limit_vf,
9271 (void *)&cmd_vf_rate_limit_vfnum,
9272 (void *)&cmd_vf_rate_limit_rate,
9273 (void *)&cmd_vf_rate_limit_ratenum,
9274 (void *)&cmd_vf_rate_limit_q_msk,
9275 (void *)&cmd_vf_rate_limit_q_msk_val,
9280 /* *** CONFIGURE TUNNEL UDP PORT *** */
9281 struct cmd_tunnel_udp_config {
9282 cmdline_fixed_string_t rx_vxlan_port;
9283 cmdline_fixed_string_t what;
9289 cmd_tunnel_udp_config_parsed(void *parsed_result,
9290 __rte_unused struct cmdline *cl,
9291 __rte_unused void *data)
9293 struct cmd_tunnel_udp_config *res = parsed_result;
9294 struct rte_eth_udp_tunnel tunnel_udp;
9297 tunnel_udp.udp_port = res->udp_port;
9298 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9300 if (!strcmp(res->what, "add"))
9301 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9304 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9308 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9311 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9312 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9313 rx_vxlan_port, "rx_vxlan_port");
9314 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9315 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9317 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9318 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9319 udp_port, RTE_UINT16);
9320 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9321 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9322 port_id, RTE_UINT16);
9324 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9325 .f = cmd_tunnel_udp_config_parsed,
9327 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9328 "Add/Remove a tunneling UDP port filter",
9330 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9331 (void *)&cmd_tunnel_udp_config_what,
9332 (void *)&cmd_tunnel_udp_config_udp_port,
9333 (void *)&cmd_tunnel_udp_config_port_id,
9338 struct cmd_config_tunnel_udp_port {
9339 cmdline_fixed_string_t port;
9340 cmdline_fixed_string_t config;
9342 cmdline_fixed_string_t udp_tunnel_port;
9343 cmdline_fixed_string_t action;
9344 cmdline_fixed_string_t tunnel_type;
9349 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9350 __rte_unused struct cmdline *cl,
9351 __rte_unused void *data)
9353 struct cmd_config_tunnel_udp_port *res = parsed_result;
9354 struct rte_eth_udp_tunnel tunnel_udp;
9357 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9360 tunnel_udp.udp_port = res->udp_port;
9362 if (!strcmp(res->tunnel_type, "vxlan")) {
9363 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9364 } else if (!strcmp(res->tunnel_type, "geneve")) {
9365 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9366 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9367 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9368 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9369 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9371 printf("Invalid tunnel type\n");
9375 if (!strcmp(res->action, "add"))
9376 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9379 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9383 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9386 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9387 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9389 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9390 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9392 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9393 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9395 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9396 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9399 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9400 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9402 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9403 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9404 "vxlan#geneve#vxlan-gpe#ecpri");
9405 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9406 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9409 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9410 .f = cmd_cfg_tunnel_udp_port_parsed,
9412 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9413 "geneve|vxlan-gpe|ecpri <udp_port>",
9415 (void *)&cmd_config_tunnel_udp_port_port,
9416 (void *)&cmd_config_tunnel_udp_port_config,
9417 (void *)&cmd_config_tunnel_udp_port_port_id,
9418 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9419 (void *)&cmd_config_tunnel_udp_port_action,
9420 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9421 (void *)&cmd_config_tunnel_udp_port_value,
9426 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9427 struct cmd_set_mirror_mask_result {
9428 cmdline_fixed_string_t set;
9429 cmdline_fixed_string_t port;
9431 cmdline_fixed_string_t mirror;
9433 cmdline_fixed_string_t what;
9434 cmdline_fixed_string_t value;
9435 cmdline_fixed_string_t dstpool;
9437 cmdline_fixed_string_t on;
9440 cmdline_parse_token_string_t cmd_mirror_mask_set =
9441 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9443 cmdline_parse_token_string_t cmd_mirror_mask_port =
9444 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9446 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9447 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9448 port_id, RTE_UINT16);
9449 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9450 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9451 mirror, "mirror-rule");
9452 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9453 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9454 rule_id, RTE_UINT8);
9455 cmdline_parse_token_string_t cmd_mirror_mask_what =
9456 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9457 what, "pool-mirror-up#pool-mirror-down"
9459 cmdline_parse_token_string_t cmd_mirror_mask_value =
9460 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9462 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9463 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9464 dstpool, "dst-pool");
9465 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9466 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9467 dstpool_id, RTE_UINT8);
9468 cmdline_parse_token_string_t cmd_mirror_mask_on =
9469 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9473 cmd_set_mirror_mask_parsed(void *parsed_result,
9474 __rte_unused struct cmdline *cl,
9475 __rte_unused void *data)
9478 struct cmd_set_mirror_mask_result *res = parsed_result;
9479 struct rte_eth_mirror_conf mr_conf;
9481 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9483 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9485 mr_conf.dst_pool = res->dstpool_id;
9487 if (!strcmp(res->what, "pool-mirror-up")) {
9488 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9489 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9490 } else if (!strcmp(res->what, "pool-mirror-down")) {
9491 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9492 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9493 } else if (!strcmp(res->what, "vlan-mirror")) {
9494 mr_conf.rule_type = ETH_MIRROR_VLAN;
9495 nb_item = parse_item_list(res->value, "vlan",
9496 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9500 for (i = 0; i < nb_item; i++) {
9501 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9502 printf("Invalid vlan_id: must be < 4096\n");
9506 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9507 mr_conf.vlan.vlan_mask |= 1ULL << i;
9511 if (!strcmp(res->on, "on"))
9512 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9515 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9518 printf("mirror rule add error: (%s)\n", strerror(-ret));
9521 cmdline_parse_inst_t cmd_set_mirror_mask = {
9522 .f = cmd_set_mirror_mask_parsed,
9524 .help_str = "set port <port_id> mirror-rule <rule_id> "
9525 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9526 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9528 (void *)&cmd_mirror_mask_set,
9529 (void *)&cmd_mirror_mask_port,
9530 (void *)&cmd_mirror_mask_portid,
9531 (void *)&cmd_mirror_mask_mirror,
9532 (void *)&cmd_mirror_mask_ruleid,
9533 (void *)&cmd_mirror_mask_what,
9534 (void *)&cmd_mirror_mask_value,
9535 (void *)&cmd_mirror_mask_dstpool,
9536 (void *)&cmd_mirror_mask_poolid,
9537 (void *)&cmd_mirror_mask_on,
9542 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9543 struct cmd_set_mirror_link_result {
9544 cmdline_fixed_string_t set;
9545 cmdline_fixed_string_t port;
9547 cmdline_fixed_string_t mirror;
9549 cmdline_fixed_string_t what;
9550 cmdline_fixed_string_t dstpool;
9552 cmdline_fixed_string_t on;
9555 cmdline_parse_token_string_t cmd_mirror_link_set =
9556 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9558 cmdline_parse_token_string_t cmd_mirror_link_port =
9559 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9561 cmdline_parse_token_num_t cmd_mirror_link_portid =
9562 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9563 port_id, RTE_UINT16);
9564 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9565 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9566 mirror, "mirror-rule");
9567 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9568 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9569 rule_id, RTE_UINT8);
9570 cmdline_parse_token_string_t cmd_mirror_link_what =
9571 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9572 what, "uplink-mirror#downlink-mirror");
9573 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9574 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9575 dstpool, "dst-pool");
9576 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9577 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9578 dstpool_id, RTE_UINT8);
9579 cmdline_parse_token_string_t cmd_mirror_link_on =
9580 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9584 cmd_set_mirror_link_parsed(void *parsed_result,
9585 __rte_unused struct cmdline *cl,
9586 __rte_unused void *data)
9589 struct cmd_set_mirror_link_result *res = parsed_result;
9590 struct rte_eth_mirror_conf mr_conf;
9592 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9593 if (!strcmp(res->what, "uplink-mirror"))
9594 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9596 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9598 mr_conf.dst_pool = res->dstpool_id;
9600 if (!strcmp(res->on, "on"))
9601 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9604 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9607 /* check the return value and print it if is < 0 */
9609 printf("mirror rule add error: (%s)\n", strerror(-ret));
9613 cmdline_parse_inst_t cmd_set_mirror_link = {
9614 .f = cmd_set_mirror_link_parsed,
9616 .help_str = "set port <port_id> mirror-rule <rule_id> "
9617 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9619 (void *)&cmd_mirror_link_set,
9620 (void *)&cmd_mirror_link_port,
9621 (void *)&cmd_mirror_link_portid,
9622 (void *)&cmd_mirror_link_mirror,
9623 (void *)&cmd_mirror_link_ruleid,
9624 (void *)&cmd_mirror_link_what,
9625 (void *)&cmd_mirror_link_dstpool,
9626 (void *)&cmd_mirror_link_poolid,
9627 (void *)&cmd_mirror_link_on,
9632 /* *** RESET VM MIRROR RULE *** */
9633 struct cmd_rm_mirror_rule_result {
9634 cmdline_fixed_string_t reset;
9635 cmdline_fixed_string_t port;
9637 cmdline_fixed_string_t mirror;
9641 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9642 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9644 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9645 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9647 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9648 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9649 port_id, RTE_UINT16);
9650 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9651 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9652 mirror, "mirror-rule");
9653 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9654 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9655 rule_id, RTE_UINT8);
9658 cmd_reset_mirror_rule_parsed(void *parsed_result,
9659 __rte_unused struct cmdline *cl,
9660 __rte_unused void *data)
9663 struct cmd_set_mirror_link_result *res = parsed_result;
9665 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9667 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9670 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9671 .f = cmd_reset_mirror_rule_parsed,
9673 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9675 (void *)&cmd_rm_mirror_rule_reset,
9676 (void *)&cmd_rm_mirror_rule_port,
9677 (void *)&cmd_rm_mirror_rule_portid,
9678 (void *)&cmd_rm_mirror_rule_mirror,
9679 (void *)&cmd_rm_mirror_rule_ruleid,
9684 /* ******************************************************************************** */
9686 struct cmd_dump_result {
9687 cmdline_fixed_string_t dump;
9691 dump_struct_sizes(void)
9693 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9694 DUMP_SIZE(struct rte_mbuf);
9695 DUMP_SIZE(struct rte_mempool);
9696 DUMP_SIZE(struct rte_ring);
9701 /* Dump the socket memory statistics on console */
9703 dump_socket_mem(FILE *f)
9705 struct rte_malloc_socket_stats socket_stats;
9710 unsigned int n_alloc = 0;
9711 unsigned int n_free = 0;
9712 static size_t last_allocs;
9713 static size_t last_total;
9716 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9717 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9718 !socket_stats.heap_totalsz_bytes)
9720 total += socket_stats.heap_totalsz_bytes;
9721 alloc += socket_stats.heap_allocsz_bytes;
9722 free += socket_stats.heap_freesz_bytes;
9723 n_alloc += socket_stats.alloc_count;
9724 n_free += socket_stats.free_count;
9726 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9728 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9729 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9730 (double)socket_stats.heap_allocsz_bytes * 100 /
9731 (double)socket_stats.heap_totalsz_bytes,
9732 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9733 socket_stats.alloc_count,
9734 socket_stats.free_count);
9737 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9738 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9739 total ? ((double)alloc * 100 / (double)total) : 0,
9740 (double)free / (1024 * 1024),
9743 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9744 ((double)total - (double)last_total) / (1024 * 1024),
9745 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9746 last_allocs = alloc;
9750 static void cmd_dump_parsed(void *parsed_result,
9751 __rte_unused struct cmdline *cl,
9752 __rte_unused void *data)
9754 struct cmd_dump_result *res = parsed_result;
9756 if (!strcmp(res->dump, "dump_physmem"))
9757 rte_dump_physmem_layout(stdout);
9758 else if (!strcmp(res->dump, "dump_socket_mem"))
9759 dump_socket_mem(stdout);
9760 else if (!strcmp(res->dump, "dump_memzone"))
9761 rte_memzone_dump(stdout);
9762 else if (!strcmp(res->dump, "dump_struct_sizes"))
9763 dump_struct_sizes();
9764 else if (!strcmp(res->dump, "dump_ring"))
9765 rte_ring_list_dump(stdout);
9766 else if (!strcmp(res->dump, "dump_mempool"))
9767 rte_mempool_list_dump(stdout);
9768 else if (!strcmp(res->dump, "dump_devargs"))
9769 rte_devargs_dump(stdout);
9770 else if (!strcmp(res->dump, "dump_log_types"))
9771 rte_log_dump(stdout);
9774 cmdline_parse_token_string_t cmd_dump_dump =
9775 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9779 "dump_struct_sizes#"
9785 cmdline_parse_inst_t cmd_dump = {
9786 .f = cmd_dump_parsed, /* function to call */
9787 .data = NULL, /* 2nd arg of func */
9788 .help_str = "Dump status",
9789 .tokens = { /* token list, NULL terminated */
9790 (void *)&cmd_dump_dump,
9795 /* ******************************************************************************** */
9797 struct cmd_dump_one_result {
9798 cmdline_fixed_string_t dump;
9799 cmdline_fixed_string_t name;
9802 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9803 __rte_unused void *data)
9805 struct cmd_dump_one_result *res = parsed_result;
9807 if (!strcmp(res->dump, "dump_ring")) {
9809 r = rte_ring_lookup(res->name);
9811 cmdline_printf(cl, "Cannot find ring\n");
9814 rte_ring_dump(stdout, r);
9815 } else if (!strcmp(res->dump, "dump_mempool")) {
9816 struct rte_mempool *mp;
9817 mp = rte_mempool_lookup(res->name);
9819 cmdline_printf(cl, "Cannot find mempool\n");
9822 rte_mempool_dump(stdout, mp);
9826 cmdline_parse_token_string_t cmd_dump_one_dump =
9827 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9828 "dump_ring#dump_mempool");
9830 cmdline_parse_token_string_t cmd_dump_one_name =
9831 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9833 cmdline_parse_inst_t cmd_dump_one = {
9834 .f = cmd_dump_one_parsed, /* function to call */
9835 .data = NULL, /* 2nd arg of func */
9836 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9837 .tokens = { /* token list, NULL terminated */
9838 (void *)&cmd_dump_one_dump,
9839 (void *)&cmd_dump_one_name,
9844 /* *** queue region set *** */
9845 struct cmd_queue_region_result {
9846 cmdline_fixed_string_t set;
9847 cmdline_fixed_string_t port;
9849 cmdline_fixed_string_t cmd;
9850 cmdline_fixed_string_t region;
9852 cmdline_fixed_string_t queue_start_index;
9854 cmdline_fixed_string_t queue_num;
9855 uint8_t queue_num_value;
9859 cmd_queue_region_parsed(void *parsed_result,
9860 __rte_unused struct cmdline *cl,
9861 __rte_unused void *data)
9863 struct cmd_queue_region_result *res = parsed_result;
9866 struct rte_pmd_i40e_queue_region_conf region_conf;
9867 enum rte_pmd_i40e_queue_region_op op_type;
9870 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9874 memset(®ion_conf, 0, sizeof(region_conf));
9875 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9876 region_conf.region_id = res->region_id;
9877 region_conf.queue_num = res->queue_num_value;
9878 region_conf.queue_start_index = res->queue_id;
9880 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9881 op_type, ®ion_conf);
9888 printf("function not implemented or supported\n");
9891 printf("queue region config error: (%s)\n", strerror(-ret));
9895 cmdline_parse_token_string_t cmd_queue_region_set =
9896 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9898 cmdline_parse_token_string_t cmd_queue_region_port =
9899 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9900 cmdline_parse_token_num_t cmd_queue_region_port_id =
9901 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9902 port_id, RTE_UINT16);
9903 cmdline_parse_token_string_t cmd_queue_region_cmd =
9904 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9905 cmd, "queue-region");
9906 cmdline_parse_token_string_t cmd_queue_region_id =
9907 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9908 region, "region_id");
9909 cmdline_parse_token_num_t cmd_queue_region_index =
9910 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9911 region_id, RTE_UINT8);
9912 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9913 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9914 queue_start_index, "queue_start_index");
9915 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9916 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9917 queue_id, RTE_UINT8);
9918 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9919 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9920 queue_num, "queue_num");
9921 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9922 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9923 queue_num_value, RTE_UINT8);
9925 cmdline_parse_inst_t cmd_queue_region = {
9926 .f = cmd_queue_region_parsed,
9928 .help_str = "set port <port_id> queue-region region_id <value> "
9929 "queue_start_index <value> queue_num <value>: Set a queue region",
9931 (void *)&cmd_queue_region_set,
9932 (void *)&cmd_queue_region_port,
9933 (void *)&cmd_queue_region_port_id,
9934 (void *)&cmd_queue_region_cmd,
9935 (void *)&cmd_queue_region_id,
9936 (void *)&cmd_queue_region_index,
9937 (void *)&cmd_queue_region_queue_start_index,
9938 (void *)&cmd_queue_region_queue_id,
9939 (void *)&cmd_queue_region_queue_num,
9940 (void *)&cmd_queue_region_queue_num_value,
9945 /* *** queue region and flowtype set *** */
9946 struct cmd_region_flowtype_result {
9947 cmdline_fixed_string_t set;
9948 cmdline_fixed_string_t port;
9950 cmdline_fixed_string_t cmd;
9951 cmdline_fixed_string_t region;
9953 cmdline_fixed_string_t flowtype;
9954 uint8_t flowtype_id;
9958 cmd_region_flowtype_parsed(void *parsed_result,
9959 __rte_unused struct cmdline *cl,
9960 __rte_unused void *data)
9962 struct cmd_region_flowtype_result *res = parsed_result;
9965 struct rte_pmd_i40e_queue_region_conf region_conf;
9966 enum rte_pmd_i40e_queue_region_op op_type;
9969 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9973 memset(®ion_conf, 0, sizeof(region_conf));
9975 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9976 region_conf.region_id = res->region_id;
9977 region_conf.hw_flowtype = res->flowtype_id;
9979 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9980 op_type, ®ion_conf);
9987 printf("function not implemented or supported\n");
9990 printf("region flowtype config error: (%s)\n", strerror(-ret));
9994 cmdline_parse_token_string_t cmd_region_flowtype_set =
9995 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9997 cmdline_parse_token_string_t cmd_region_flowtype_port =
9998 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10000 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10001 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10002 port_id, RTE_UINT16);
10003 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10004 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10005 cmd, "queue-region");
10006 cmdline_parse_token_string_t cmd_region_flowtype_index =
10007 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10008 region, "region_id");
10009 cmdline_parse_token_num_t cmd_region_flowtype_id =
10010 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10011 region_id, RTE_UINT8);
10012 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10013 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10014 flowtype, "flowtype");
10015 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10016 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10017 flowtype_id, RTE_UINT8);
10018 cmdline_parse_inst_t cmd_region_flowtype = {
10019 .f = cmd_region_flowtype_parsed,
10021 .help_str = "set port <port_id> queue-region region_id <value> "
10022 "flowtype <value>: Set a flowtype region index",
10024 (void *)&cmd_region_flowtype_set,
10025 (void *)&cmd_region_flowtype_port,
10026 (void *)&cmd_region_flowtype_port_index,
10027 (void *)&cmd_region_flowtype_cmd,
10028 (void *)&cmd_region_flowtype_index,
10029 (void *)&cmd_region_flowtype_id,
10030 (void *)&cmd_region_flowtype_flow_index,
10031 (void *)&cmd_region_flowtype_flow_id,
10036 /* *** User Priority (UP) to queue region (region_id) set *** */
10037 struct cmd_user_priority_region_result {
10038 cmdline_fixed_string_t set;
10039 cmdline_fixed_string_t port;
10041 cmdline_fixed_string_t cmd;
10042 cmdline_fixed_string_t user_priority;
10043 uint8_t user_priority_id;
10044 cmdline_fixed_string_t region;
10049 cmd_user_priority_region_parsed(void *parsed_result,
10050 __rte_unused struct cmdline *cl,
10051 __rte_unused void *data)
10053 struct cmd_user_priority_region_result *res = parsed_result;
10054 int ret = -ENOTSUP;
10055 #ifdef RTE_NET_I40E
10056 struct rte_pmd_i40e_queue_region_conf region_conf;
10057 enum rte_pmd_i40e_queue_region_op op_type;
10060 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10063 #ifdef RTE_NET_I40E
10064 memset(®ion_conf, 0, sizeof(region_conf));
10065 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10066 region_conf.user_priority = res->user_priority_id;
10067 region_conf.region_id = res->region_id;
10069 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10070 op_type, ®ion_conf);
10077 printf("function not implemented or supported\n");
10080 printf("user_priority region config error: (%s)\n",
10085 cmdline_parse_token_string_t cmd_user_priority_region_set =
10086 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10088 cmdline_parse_token_string_t cmd_user_priority_region_port =
10089 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10091 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10092 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10093 port_id, RTE_UINT16);
10094 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10095 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10096 cmd, "queue-region");
10097 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10098 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10099 user_priority, "UP");
10100 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10101 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10102 user_priority_id, RTE_UINT8);
10103 cmdline_parse_token_string_t cmd_user_priority_region_region =
10104 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10105 region, "region_id");
10106 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10107 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10108 region_id, RTE_UINT8);
10110 cmdline_parse_inst_t cmd_user_priority_region = {
10111 .f = cmd_user_priority_region_parsed,
10113 .help_str = "set port <port_id> queue-region UP <value> "
10114 "region_id <value>: Set the mapping of User Priority (UP) "
10115 "to queue region (region_id) ",
10117 (void *)&cmd_user_priority_region_set,
10118 (void *)&cmd_user_priority_region_port,
10119 (void *)&cmd_user_priority_region_port_index,
10120 (void *)&cmd_user_priority_region_cmd,
10121 (void *)&cmd_user_priority_region_UP,
10122 (void *)&cmd_user_priority_region_UP_id,
10123 (void *)&cmd_user_priority_region_region,
10124 (void *)&cmd_user_priority_region_region_id,
10129 /* *** flush all queue region related configuration *** */
10130 struct cmd_flush_queue_region_result {
10131 cmdline_fixed_string_t set;
10132 cmdline_fixed_string_t port;
10134 cmdline_fixed_string_t cmd;
10135 cmdline_fixed_string_t flush;
10136 cmdline_fixed_string_t what;
10140 cmd_flush_queue_region_parsed(void *parsed_result,
10141 __rte_unused struct cmdline *cl,
10142 __rte_unused void *data)
10144 struct cmd_flush_queue_region_result *res = parsed_result;
10145 int ret = -ENOTSUP;
10146 #ifdef RTE_NET_I40E
10147 struct rte_pmd_i40e_queue_region_conf region_conf;
10148 enum rte_pmd_i40e_queue_region_op op_type;
10151 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10154 #ifdef RTE_NET_I40E
10155 memset(®ion_conf, 0, sizeof(region_conf));
10157 if (strcmp(res->what, "on") == 0)
10158 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10160 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10162 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10163 op_type, ®ion_conf);
10170 printf("function not implemented or supported\n");
10173 printf("queue region config flush error: (%s)\n",
10178 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10179 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10181 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10182 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10184 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10185 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10186 port_id, RTE_UINT16);
10187 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10188 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10189 cmd, "queue-region");
10190 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10191 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10193 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10194 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10197 cmdline_parse_inst_t cmd_flush_queue_region = {
10198 .f = cmd_flush_queue_region_parsed,
10200 .help_str = "set port <port_id> queue-region flush on|off"
10201 ": flush all queue region related configuration",
10203 (void *)&cmd_flush_queue_region_set,
10204 (void *)&cmd_flush_queue_region_port,
10205 (void *)&cmd_flush_queue_region_port_index,
10206 (void *)&cmd_flush_queue_region_cmd,
10207 (void *)&cmd_flush_queue_region_flush,
10208 (void *)&cmd_flush_queue_region_what,
10213 /* *** get all queue region related configuration info *** */
10214 struct cmd_show_queue_region_info {
10215 cmdline_fixed_string_t show;
10216 cmdline_fixed_string_t port;
10218 cmdline_fixed_string_t cmd;
10222 cmd_show_queue_region_info_parsed(void *parsed_result,
10223 __rte_unused struct cmdline *cl,
10224 __rte_unused void *data)
10226 struct cmd_show_queue_region_info *res = parsed_result;
10227 int ret = -ENOTSUP;
10228 #ifdef RTE_NET_I40E
10229 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10230 enum rte_pmd_i40e_queue_region_op op_type;
10233 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10236 #ifdef RTE_NET_I40E
10237 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10239 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10241 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10242 op_type, &rte_pmd_regions);
10244 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10251 printf("function not implemented or supported\n");
10254 printf("queue region config info show error: (%s)\n",
10259 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10260 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10262 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10263 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10265 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10266 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10267 port_id, RTE_UINT16);
10268 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10269 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10270 cmd, "queue-region");
10272 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10273 .f = cmd_show_queue_region_info_parsed,
10275 .help_str = "show port <port_id> queue-region"
10276 ": show all queue region related configuration info",
10278 (void *)&cmd_show_queue_region_info_get,
10279 (void *)&cmd_show_queue_region_info_port,
10280 (void *)&cmd_show_queue_region_info_port_index,
10281 (void *)&cmd_show_queue_region_info_cmd,
10286 /* *** Filters Control *** */
10288 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10290 if ((ip_addr).family == AF_INET) \
10291 (ip) = (ip_addr).addr.ipv4.s_addr; \
10293 printf("invalid parameter.\n"); \
10298 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10300 if ((ip_addr).family == AF_INET6) \
10301 rte_memcpy(&(ip), \
10302 &((ip_addr).addr.ipv6), \
10303 sizeof(struct in6_addr)); \
10305 printf("invalid parameter.\n"); \
10310 #ifdef RTE_NET_I40E
10313 str2flowtype(char *string)
10316 static const struct {
10319 } flowtype_str[] = {
10320 {"raw", RTE_ETH_FLOW_RAW},
10321 {"ipv4", RTE_ETH_FLOW_IPV4},
10322 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10323 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10324 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10325 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10326 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10327 {"ipv6", RTE_ETH_FLOW_IPV6},
10328 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10329 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10330 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10331 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10332 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10333 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10336 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10337 if (!strcmp(flowtype_str[i].str, string))
10338 return flowtype_str[i].type;
10341 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10342 return (uint16_t)atoi(string);
10344 return RTE_ETH_FLOW_UNKNOWN;
10347 /* *** deal with flow director filter *** */
10348 struct cmd_flow_director_result {
10349 cmdline_fixed_string_t flow_director_filter;
10351 cmdline_fixed_string_t mode;
10352 cmdline_fixed_string_t mode_value;
10353 cmdline_fixed_string_t ops;
10354 cmdline_fixed_string_t flow;
10355 cmdline_fixed_string_t flow_type;
10356 cmdline_fixed_string_t drop;
10357 cmdline_fixed_string_t queue;
10359 cmdline_fixed_string_t fd_id;
10360 uint32_t fd_id_value;
10361 cmdline_fixed_string_t packet;
10366 cmd_flow_director_filter_parsed(void *parsed_result,
10367 __rte_unused struct cmdline *cl,
10368 __rte_unused void *data)
10370 struct cmd_flow_director_result *res = parsed_result;
10372 struct rte_pmd_i40e_flow_type_mapping
10373 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10374 struct rte_pmd_i40e_pkt_template_conf conf;
10375 uint16_t flow_type = str2flowtype(res->flow_type);
10376 uint16_t i, port = res->port_id;
10379 memset(&conf, 0, sizeof(conf));
10381 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10382 printf("Invalid flow type specified.\n");
10385 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10389 if (mapping[flow_type].pctype == 0ULL) {
10390 printf("Invalid flow type specified.\n");
10393 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10394 if (mapping[flow_type].pctype & (1ULL << i)) {
10395 conf.input.pctype = i;
10400 conf.input.packet = open_file(res->filepath,
10401 &conf.input.length);
10402 if (!conf.input.packet)
10404 if (!strcmp(res->drop, "drop"))
10405 conf.action.behavior =
10406 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10408 conf.action.behavior =
10409 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10410 conf.action.report_status =
10411 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10412 conf.action.rx_queue = res->queue_id;
10413 conf.soft_id = res->fd_id_value;
10414 add = strcmp(res->ops, "del") ? 1 : 0;
10415 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10419 printf("flow director config error: (%s)\n",
10421 close_file(conf.input.packet);
10424 cmdline_parse_token_string_t cmd_flow_director_filter =
10425 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10426 flow_director_filter, "flow_director_filter");
10427 cmdline_parse_token_num_t cmd_flow_director_port_id =
10428 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10429 port_id, RTE_UINT16);
10430 cmdline_parse_token_string_t cmd_flow_director_ops =
10431 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10432 ops, "add#del#update");
10433 cmdline_parse_token_string_t cmd_flow_director_flow =
10434 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10436 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10437 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10439 cmdline_parse_token_string_t cmd_flow_director_drop =
10440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10442 cmdline_parse_token_string_t cmd_flow_director_queue =
10443 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10445 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10446 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10447 queue_id, RTE_UINT16);
10448 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10449 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10451 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10452 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10453 fd_id_value, RTE_UINT32);
10455 cmdline_parse_token_string_t cmd_flow_director_mode =
10456 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10458 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10459 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10460 mode_value, "raw");
10461 cmdline_parse_token_string_t cmd_flow_director_packet =
10462 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10464 cmdline_parse_token_string_t cmd_flow_director_filepath =
10465 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10468 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10469 .f = cmd_flow_director_filter_parsed,
10471 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10472 "director entry on NIC",
10474 (void *)&cmd_flow_director_filter,
10475 (void *)&cmd_flow_director_port_id,
10476 (void *)&cmd_flow_director_mode,
10477 (void *)&cmd_flow_director_mode_raw,
10478 (void *)&cmd_flow_director_ops,
10479 (void *)&cmd_flow_director_flow,
10480 (void *)&cmd_flow_director_flow_type,
10481 (void *)&cmd_flow_director_drop,
10482 (void *)&cmd_flow_director_queue,
10483 (void *)&cmd_flow_director_queue_id,
10484 (void *)&cmd_flow_director_fd_id,
10485 (void *)&cmd_flow_director_fd_id_value,
10486 (void *)&cmd_flow_director_packet,
10487 (void *)&cmd_flow_director_filepath,
10492 #endif /* RTE_NET_I40E */
10494 /* *** deal with flow director mask *** */
10495 struct cmd_flow_director_mask_result {
10496 cmdline_fixed_string_t flow_director_mask;
10498 cmdline_fixed_string_t mode;
10499 cmdline_fixed_string_t mode_value;
10500 cmdline_fixed_string_t vlan;
10501 uint16_t vlan_mask;
10502 cmdline_fixed_string_t src_mask;
10503 cmdline_ipaddr_t ipv4_src;
10504 cmdline_ipaddr_t ipv6_src;
10506 cmdline_fixed_string_t dst_mask;
10507 cmdline_ipaddr_t ipv4_dst;
10508 cmdline_ipaddr_t ipv6_dst;
10510 cmdline_fixed_string_t mac;
10511 uint8_t mac_addr_byte_mask;
10512 cmdline_fixed_string_t tunnel_id;
10513 uint32_t tunnel_id_mask;
10514 cmdline_fixed_string_t tunnel_type;
10515 uint8_t tunnel_type_mask;
10519 cmd_flow_director_mask_parsed(void *parsed_result,
10520 __rte_unused struct cmdline *cl,
10521 __rte_unused void *data)
10523 struct cmd_flow_director_mask_result *res = parsed_result;
10524 struct rte_eth_fdir_masks *mask;
10525 struct rte_port *port;
10527 port = &ports[res->port_id];
10528 /** Check if the port is not started **/
10529 if (port->port_status != RTE_PORT_STOPPED) {
10530 printf("Please stop port %d first\n", res->port_id);
10534 mask = &port->dev_conf.fdir_conf.mask;
10536 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10537 if (strcmp(res->mode_value, "MAC-VLAN")) {
10538 printf("Please set mode to MAC-VLAN.\n");
10542 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10543 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10544 if (strcmp(res->mode_value, "Tunnel")) {
10545 printf("Please set mode to Tunnel.\n");
10549 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10550 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10551 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10552 mask->tunnel_type_mask = res->tunnel_type_mask;
10554 if (strcmp(res->mode_value, "IP")) {
10555 printf("Please set mode to IP.\n");
10559 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10560 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10561 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10562 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10563 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10564 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10565 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10568 cmd_reconfig_device_queue(res->port_id, 1, 1);
10571 cmdline_parse_token_string_t cmd_flow_director_mask =
10572 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10573 flow_director_mask, "flow_director_mask");
10574 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10575 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10576 port_id, RTE_UINT16);
10577 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10578 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10580 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10581 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10582 vlan_mask, RTE_UINT16);
10583 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10585 src_mask, "src_mask");
10586 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10587 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10589 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10590 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10592 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10593 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10594 port_src, RTE_UINT16);
10595 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10597 dst_mask, "dst_mask");
10598 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10599 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10601 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10602 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10604 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10605 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10606 port_dst, RTE_UINT16);
10608 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10609 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10611 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10612 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10614 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10615 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10616 mode_value, "MAC-VLAN");
10617 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10618 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10619 mode_value, "Tunnel");
10620 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10621 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10623 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10624 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10625 mac_addr_byte_mask, RTE_UINT8);
10626 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10627 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10628 tunnel_type, "tunnel-type");
10629 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10630 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10631 tunnel_type_mask, RTE_UINT8);
10632 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10633 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10634 tunnel_id, "tunnel-id");
10635 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10636 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10637 tunnel_id_mask, RTE_UINT32);
10639 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10640 .f = cmd_flow_director_mask_parsed,
10642 .help_str = "flow_director_mask ... : "
10643 "Set IP mode flow director's mask on NIC",
10645 (void *)&cmd_flow_director_mask,
10646 (void *)&cmd_flow_director_mask_port_id,
10647 (void *)&cmd_flow_director_mask_mode,
10648 (void *)&cmd_flow_director_mask_mode_ip,
10649 (void *)&cmd_flow_director_mask_vlan,
10650 (void *)&cmd_flow_director_mask_vlan_value,
10651 (void *)&cmd_flow_director_mask_src,
10652 (void *)&cmd_flow_director_mask_ipv4_src,
10653 (void *)&cmd_flow_director_mask_ipv6_src,
10654 (void *)&cmd_flow_director_mask_port_src,
10655 (void *)&cmd_flow_director_mask_dst,
10656 (void *)&cmd_flow_director_mask_ipv4_dst,
10657 (void *)&cmd_flow_director_mask_ipv6_dst,
10658 (void *)&cmd_flow_director_mask_port_dst,
10663 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10664 .f = cmd_flow_director_mask_parsed,
10666 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10667 "flow director's mask on NIC",
10669 (void *)&cmd_flow_director_mask,
10670 (void *)&cmd_flow_director_mask_port_id,
10671 (void *)&cmd_flow_director_mask_mode,
10672 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10673 (void *)&cmd_flow_director_mask_vlan,
10674 (void *)&cmd_flow_director_mask_vlan_value,
10679 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10680 .f = cmd_flow_director_mask_parsed,
10682 .help_str = "flow_director_mask ... : Set tunnel mode "
10683 "flow director's mask on NIC",
10685 (void *)&cmd_flow_director_mask,
10686 (void *)&cmd_flow_director_mask_port_id,
10687 (void *)&cmd_flow_director_mask_mode,
10688 (void *)&cmd_flow_director_mask_mode_tunnel,
10689 (void *)&cmd_flow_director_mask_vlan,
10690 (void *)&cmd_flow_director_mask_vlan_value,
10691 (void *)&cmd_flow_director_mask_mac,
10692 (void *)&cmd_flow_director_mask_mac_value,
10693 (void *)&cmd_flow_director_mask_tunnel_type,
10694 (void *)&cmd_flow_director_mask_tunnel_type_value,
10695 (void *)&cmd_flow_director_mask_tunnel_id,
10696 (void *)&cmd_flow_director_mask_tunnel_id_value,
10701 /* *** deal with flow director flexible payload configuration *** */
10702 struct cmd_flow_director_flexpayload_result {
10703 cmdline_fixed_string_t flow_director_flexpayload;
10705 cmdline_fixed_string_t payload_layer;
10706 cmdline_fixed_string_t payload_cfg;
10710 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10713 const char *p, *p0 = q_arg;
10715 unsigned long int_fld;
10716 char *str_fld[max_num];
10721 p = strchr(p0, '(');
10725 p0 = strchr(p, ')');
10730 if (size >= sizeof(s))
10733 snprintf(s, sizeof(s), "%.*s", size, p);
10734 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10735 if (ret < 0 || ret > max_num)
10737 for (i = 0; i < ret; i++) {
10739 int_fld = strtoul(str_fld[i], &end, 0);
10740 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10742 offsets[i] = (uint16_t)int_fld;
10748 cmd_flow_director_flxpld_parsed(void *parsed_result,
10749 __rte_unused struct cmdline *cl,
10750 __rte_unused void *data)
10752 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10753 struct rte_eth_flex_payload_cfg flex_cfg;
10754 struct rte_port *port;
10757 port = &ports[res->port_id];
10758 /** Check if the port is not started **/
10759 if (port->port_status != RTE_PORT_STOPPED) {
10760 printf("Please stop port %d first\n", res->port_id);
10764 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10766 if (!strcmp(res->payload_layer, "raw"))
10767 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10768 else if (!strcmp(res->payload_layer, "l2"))
10769 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10770 else if (!strcmp(res->payload_layer, "l3"))
10771 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10772 else if (!strcmp(res->payload_layer, "l4"))
10773 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10775 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10776 RTE_ETH_FDIR_MAX_FLEXLEN);
10778 printf("error: Cannot parse flex payload input.\n");
10782 fdir_set_flex_payload(res->port_id, &flex_cfg);
10783 cmd_reconfig_device_queue(res->port_id, 1, 1);
10786 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10787 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10788 flow_director_flexpayload,
10789 "flow_director_flex_payload");
10790 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10791 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10792 port_id, RTE_UINT16);
10793 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10794 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10795 payload_layer, "raw#l2#l3#l4");
10796 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10797 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10798 payload_cfg, NULL);
10800 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10801 .f = cmd_flow_director_flxpld_parsed,
10803 .help_str = "flow_director_flexpayload ... : "
10804 "Set flow director's flex payload on NIC",
10806 (void *)&cmd_flow_director_flexpayload,
10807 (void *)&cmd_flow_director_flexpayload_port_id,
10808 (void *)&cmd_flow_director_flexpayload_payload_layer,
10809 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10814 /* Generic flow interface command. */
10815 extern cmdline_parse_inst_t cmd_flow;
10817 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10818 struct cmd_mcast_addr_result {
10819 cmdline_fixed_string_t mcast_addr_cmd;
10820 cmdline_fixed_string_t what;
10822 struct rte_ether_addr mc_addr;
10825 static void cmd_mcast_addr_parsed(void *parsed_result,
10826 __rte_unused struct cmdline *cl,
10827 __rte_unused void *data)
10829 struct cmd_mcast_addr_result *res = parsed_result;
10831 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10832 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10833 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10834 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10835 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10838 if (strcmp(res->what, "add") == 0)
10839 mcast_addr_add(res->port_num, &res->mc_addr);
10841 mcast_addr_remove(res->port_num, &res->mc_addr);
10844 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10845 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10846 mcast_addr_cmd, "mcast_addr");
10847 cmdline_parse_token_string_t cmd_mcast_addr_what =
10848 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10850 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10851 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10853 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10854 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10856 cmdline_parse_inst_t cmd_mcast_addr = {
10857 .f = cmd_mcast_addr_parsed,
10859 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10860 "Add/Remove multicast MAC address on port_id",
10862 (void *)&cmd_mcast_addr_cmd,
10863 (void *)&cmd_mcast_addr_what,
10864 (void *)&cmd_mcast_addr_portnum,
10865 (void *)&cmd_mcast_addr_addr,
10870 /* vf vlan anti spoof configuration */
10872 /* Common result structure for vf vlan anti spoof */
10873 struct cmd_vf_vlan_anti_spoof_result {
10874 cmdline_fixed_string_t set;
10875 cmdline_fixed_string_t vf;
10876 cmdline_fixed_string_t vlan;
10877 cmdline_fixed_string_t antispoof;
10880 cmdline_fixed_string_t on_off;
10883 /* Common CLI fields for vf vlan anti spoof enable disable */
10884 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10885 TOKEN_STRING_INITIALIZER
10886 (struct cmd_vf_vlan_anti_spoof_result,
10888 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10889 TOKEN_STRING_INITIALIZER
10890 (struct cmd_vf_vlan_anti_spoof_result,
10892 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10893 TOKEN_STRING_INITIALIZER
10894 (struct cmd_vf_vlan_anti_spoof_result,
10896 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10897 TOKEN_STRING_INITIALIZER
10898 (struct cmd_vf_vlan_anti_spoof_result,
10899 antispoof, "antispoof");
10900 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10901 TOKEN_NUM_INITIALIZER
10902 (struct cmd_vf_vlan_anti_spoof_result,
10903 port_id, RTE_UINT16);
10904 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10905 TOKEN_NUM_INITIALIZER
10906 (struct cmd_vf_vlan_anti_spoof_result,
10907 vf_id, RTE_UINT32);
10908 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10909 TOKEN_STRING_INITIALIZER
10910 (struct cmd_vf_vlan_anti_spoof_result,
10914 cmd_set_vf_vlan_anti_spoof_parsed(
10915 void *parsed_result,
10916 __rte_unused struct cmdline *cl,
10917 __rte_unused void *data)
10919 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10920 int ret = -ENOTSUP;
10922 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10924 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10927 #ifdef RTE_NET_IXGBE
10928 if (ret == -ENOTSUP)
10929 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10930 res->vf_id, is_on);
10932 #ifdef RTE_NET_I40E
10933 if (ret == -ENOTSUP)
10934 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10935 res->vf_id, is_on);
10937 #ifdef RTE_NET_BNXT
10938 if (ret == -ENOTSUP)
10939 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10940 res->vf_id, is_on);
10947 printf("invalid vf_id %d\n", res->vf_id);
10950 printf("invalid port_id %d\n", res->port_id);
10953 printf("function not implemented\n");
10956 printf("programming error: (%s)\n", strerror(-ret));
10960 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10961 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10963 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10965 (void *)&cmd_vf_vlan_anti_spoof_set,
10966 (void *)&cmd_vf_vlan_anti_spoof_vf,
10967 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10968 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10969 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10970 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10971 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10976 /* vf mac anti spoof configuration */
10978 /* Common result structure for vf mac anti spoof */
10979 struct cmd_vf_mac_anti_spoof_result {
10980 cmdline_fixed_string_t set;
10981 cmdline_fixed_string_t vf;
10982 cmdline_fixed_string_t mac;
10983 cmdline_fixed_string_t antispoof;
10986 cmdline_fixed_string_t on_off;
10989 /* Common CLI fields for vf mac anti spoof enable disable */
10990 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10991 TOKEN_STRING_INITIALIZER
10992 (struct cmd_vf_mac_anti_spoof_result,
10994 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10995 TOKEN_STRING_INITIALIZER
10996 (struct cmd_vf_mac_anti_spoof_result,
10998 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10999 TOKEN_STRING_INITIALIZER
11000 (struct cmd_vf_mac_anti_spoof_result,
11002 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11003 TOKEN_STRING_INITIALIZER
11004 (struct cmd_vf_mac_anti_spoof_result,
11005 antispoof, "antispoof");
11006 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11007 TOKEN_NUM_INITIALIZER
11008 (struct cmd_vf_mac_anti_spoof_result,
11009 port_id, RTE_UINT16);
11010 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11011 TOKEN_NUM_INITIALIZER
11012 (struct cmd_vf_mac_anti_spoof_result,
11013 vf_id, RTE_UINT32);
11014 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11015 TOKEN_STRING_INITIALIZER
11016 (struct cmd_vf_mac_anti_spoof_result,
11020 cmd_set_vf_mac_anti_spoof_parsed(
11021 void *parsed_result,
11022 __rte_unused struct cmdline *cl,
11023 __rte_unused void *data)
11025 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11026 int ret = -ENOTSUP;
11028 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11030 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11033 #ifdef RTE_NET_IXGBE
11034 if (ret == -ENOTSUP)
11035 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11036 res->vf_id, is_on);
11038 #ifdef RTE_NET_I40E
11039 if (ret == -ENOTSUP)
11040 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11041 res->vf_id, is_on);
11043 #ifdef RTE_NET_BNXT
11044 if (ret == -ENOTSUP)
11045 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11046 res->vf_id, is_on);
11053 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11056 printf("invalid port_id %d\n", res->port_id);
11059 printf("function not implemented\n");
11062 printf("programming error: (%s)\n", strerror(-ret));
11066 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11067 .f = cmd_set_vf_mac_anti_spoof_parsed,
11069 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11071 (void *)&cmd_vf_mac_anti_spoof_set,
11072 (void *)&cmd_vf_mac_anti_spoof_vf,
11073 (void *)&cmd_vf_mac_anti_spoof_mac,
11074 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11075 (void *)&cmd_vf_mac_anti_spoof_port_id,
11076 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11077 (void *)&cmd_vf_mac_anti_spoof_on_off,
11082 /* vf vlan strip queue configuration */
11084 /* Common result structure for vf mac anti spoof */
11085 struct cmd_vf_vlan_stripq_result {
11086 cmdline_fixed_string_t set;
11087 cmdline_fixed_string_t vf;
11088 cmdline_fixed_string_t vlan;
11089 cmdline_fixed_string_t stripq;
11092 cmdline_fixed_string_t on_off;
11095 /* Common CLI fields for vf vlan strip enable disable */
11096 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11097 TOKEN_STRING_INITIALIZER
11098 (struct cmd_vf_vlan_stripq_result,
11100 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11101 TOKEN_STRING_INITIALIZER
11102 (struct cmd_vf_vlan_stripq_result,
11104 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11105 TOKEN_STRING_INITIALIZER
11106 (struct cmd_vf_vlan_stripq_result,
11108 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11109 TOKEN_STRING_INITIALIZER
11110 (struct cmd_vf_vlan_stripq_result,
11112 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11113 TOKEN_NUM_INITIALIZER
11114 (struct cmd_vf_vlan_stripq_result,
11115 port_id, RTE_UINT16);
11116 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11117 TOKEN_NUM_INITIALIZER
11118 (struct cmd_vf_vlan_stripq_result,
11119 vf_id, RTE_UINT16);
11120 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11121 TOKEN_STRING_INITIALIZER
11122 (struct cmd_vf_vlan_stripq_result,
11126 cmd_set_vf_vlan_stripq_parsed(
11127 void *parsed_result,
11128 __rte_unused struct cmdline *cl,
11129 __rte_unused void *data)
11131 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11132 int ret = -ENOTSUP;
11134 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11136 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11139 #ifdef RTE_NET_IXGBE
11140 if (ret == -ENOTSUP)
11141 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11142 res->vf_id, is_on);
11144 #ifdef RTE_NET_I40E
11145 if (ret == -ENOTSUP)
11146 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11147 res->vf_id, is_on);
11149 #ifdef RTE_NET_BNXT
11150 if (ret == -ENOTSUP)
11151 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11152 res->vf_id, is_on);
11159 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11162 printf("invalid port_id %d\n", res->port_id);
11165 printf("function not implemented\n");
11168 printf("programming error: (%s)\n", strerror(-ret));
11172 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11173 .f = cmd_set_vf_vlan_stripq_parsed,
11175 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11177 (void *)&cmd_vf_vlan_stripq_set,
11178 (void *)&cmd_vf_vlan_stripq_vf,
11179 (void *)&cmd_vf_vlan_stripq_vlan,
11180 (void *)&cmd_vf_vlan_stripq_stripq,
11181 (void *)&cmd_vf_vlan_stripq_port_id,
11182 (void *)&cmd_vf_vlan_stripq_vf_id,
11183 (void *)&cmd_vf_vlan_stripq_on_off,
11188 /* vf vlan insert configuration */
11190 /* Common result structure for vf vlan insert */
11191 struct cmd_vf_vlan_insert_result {
11192 cmdline_fixed_string_t set;
11193 cmdline_fixed_string_t vf;
11194 cmdline_fixed_string_t vlan;
11195 cmdline_fixed_string_t insert;
11201 /* Common CLI fields for vf vlan insert enable disable */
11202 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11203 TOKEN_STRING_INITIALIZER
11204 (struct cmd_vf_vlan_insert_result,
11206 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11207 TOKEN_STRING_INITIALIZER
11208 (struct cmd_vf_vlan_insert_result,
11210 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11211 TOKEN_STRING_INITIALIZER
11212 (struct cmd_vf_vlan_insert_result,
11214 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11215 TOKEN_STRING_INITIALIZER
11216 (struct cmd_vf_vlan_insert_result,
11218 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11219 TOKEN_NUM_INITIALIZER
11220 (struct cmd_vf_vlan_insert_result,
11221 port_id, RTE_UINT16);
11222 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11223 TOKEN_NUM_INITIALIZER
11224 (struct cmd_vf_vlan_insert_result,
11225 vf_id, RTE_UINT16);
11226 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11227 TOKEN_NUM_INITIALIZER
11228 (struct cmd_vf_vlan_insert_result,
11229 vlan_id, RTE_UINT16);
11232 cmd_set_vf_vlan_insert_parsed(
11233 void *parsed_result,
11234 __rte_unused struct cmdline *cl,
11235 __rte_unused void *data)
11237 struct cmd_vf_vlan_insert_result *res = parsed_result;
11238 int ret = -ENOTSUP;
11240 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11243 #ifdef RTE_NET_IXGBE
11244 if (ret == -ENOTSUP)
11245 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11248 #ifdef RTE_NET_I40E
11249 if (ret == -ENOTSUP)
11250 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11253 #ifdef RTE_NET_BNXT
11254 if (ret == -ENOTSUP)
11255 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11263 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11266 printf("invalid port_id %d\n", res->port_id);
11269 printf("function not implemented\n");
11272 printf("programming error: (%s)\n", strerror(-ret));
11276 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11277 .f = cmd_set_vf_vlan_insert_parsed,
11279 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11281 (void *)&cmd_vf_vlan_insert_set,
11282 (void *)&cmd_vf_vlan_insert_vf,
11283 (void *)&cmd_vf_vlan_insert_vlan,
11284 (void *)&cmd_vf_vlan_insert_insert,
11285 (void *)&cmd_vf_vlan_insert_port_id,
11286 (void *)&cmd_vf_vlan_insert_vf_id,
11287 (void *)&cmd_vf_vlan_insert_vlan_id,
11292 /* tx loopback configuration */
11294 /* Common result structure for tx loopback */
11295 struct cmd_tx_loopback_result {
11296 cmdline_fixed_string_t set;
11297 cmdline_fixed_string_t tx;
11298 cmdline_fixed_string_t loopback;
11300 cmdline_fixed_string_t on_off;
11303 /* Common CLI fields for tx loopback enable disable */
11304 cmdline_parse_token_string_t cmd_tx_loopback_set =
11305 TOKEN_STRING_INITIALIZER
11306 (struct cmd_tx_loopback_result,
11308 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11309 TOKEN_STRING_INITIALIZER
11310 (struct cmd_tx_loopback_result,
11312 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11313 TOKEN_STRING_INITIALIZER
11314 (struct cmd_tx_loopback_result,
11315 loopback, "loopback");
11316 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11317 TOKEN_NUM_INITIALIZER
11318 (struct cmd_tx_loopback_result,
11319 port_id, RTE_UINT16);
11320 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11321 TOKEN_STRING_INITIALIZER
11322 (struct cmd_tx_loopback_result,
11326 cmd_set_tx_loopback_parsed(
11327 void *parsed_result,
11328 __rte_unused struct cmdline *cl,
11329 __rte_unused void *data)
11331 struct cmd_tx_loopback_result *res = parsed_result;
11332 int ret = -ENOTSUP;
11334 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11336 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11339 #ifdef RTE_NET_IXGBE
11340 if (ret == -ENOTSUP)
11341 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11343 #ifdef RTE_NET_I40E
11344 if (ret == -ENOTSUP)
11345 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11347 #ifdef RTE_NET_BNXT
11348 if (ret == -ENOTSUP)
11349 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11351 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11352 if (ret == -ENOTSUP)
11353 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11360 printf("invalid is_on %d\n", is_on);
11363 printf("invalid port_id %d\n", res->port_id);
11366 printf("function not implemented\n");
11369 printf("programming error: (%s)\n", strerror(-ret));
11373 cmdline_parse_inst_t cmd_set_tx_loopback = {
11374 .f = cmd_set_tx_loopback_parsed,
11376 .help_str = "set tx loopback <port_id> on|off",
11378 (void *)&cmd_tx_loopback_set,
11379 (void *)&cmd_tx_loopback_tx,
11380 (void *)&cmd_tx_loopback_loopback,
11381 (void *)&cmd_tx_loopback_port_id,
11382 (void *)&cmd_tx_loopback_on_off,
11387 /* all queues drop enable configuration */
11389 /* Common result structure for all queues drop enable */
11390 struct cmd_all_queues_drop_en_result {
11391 cmdline_fixed_string_t set;
11392 cmdline_fixed_string_t all;
11393 cmdline_fixed_string_t queues;
11394 cmdline_fixed_string_t drop;
11396 cmdline_fixed_string_t on_off;
11399 /* Common CLI fields for tx loopback enable disable */
11400 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11401 TOKEN_STRING_INITIALIZER
11402 (struct cmd_all_queues_drop_en_result,
11404 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11405 TOKEN_STRING_INITIALIZER
11406 (struct cmd_all_queues_drop_en_result,
11408 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11409 TOKEN_STRING_INITIALIZER
11410 (struct cmd_all_queues_drop_en_result,
11412 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11413 TOKEN_STRING_INITIALIZER
11414 (struct cmd_all_queues_drop_en_result,
11416 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11417 TOKEN_NUM_INITIALIZER
11418 (struct cmd_all_queues_drop_en_result,
11419 port_id, RTE_UINT16);
11420 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11421 TOKEN_STRING_INITIALIZER
11422 (struct cmd_all_queues_drop_en_result,
11426 cmd_set_all_queues_drop_en_parsed(
11427 void *parsed_result,
11428 __rte_unused struct cmdline *cl,
11429 __rte_unused void *data)
11431 struct cmd_all_queues_drop_en_result *res = parsed_result;
11432 int ret = -ENOTSUP;
11433 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11435 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11438 #ifdef RTE_NET_IXGBE
11439 if (ret == -ENOTSUP)
11440 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11442 #ifdef RTE_NET_BNXT
11443 if (ret == -ENOTSUP)
11444 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11450 printf("invalid is_on %d\n", is_on);
11453 printf("invalid port_id %d\n", res->port_id);
11456 printf("function not implemented\n");
11459 printf("programming error: (%s)\n", strerror(-ret));
11463 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11464 .f = cmd_set_all_queues_drop_en_parsed,
11466 .help_str = "set all queues drop <port_id> on|off",
11468 (void *)&cmd_all_queues_drop_en_set,
11469 (void *)&cmd_all_queues_drop_en_all,
11470 (void *)&cmd_all_queues_drop_en_queues,
11471 (void *)&cmd_all_queues_drop_en_drop,
11472 (void *)&cmd_all_queues_drop_en_port_id,
11473 (void *)&cmd_all_queues_drop_en_on_off,
11478 /* vf split drop enable configuration */
11480 /* Common result structure for vf split drop enable */
11481 struct cmd_vf_split_drop_en_result {
11482 cmdline_fixed_string_t set;
11483 cmdline_fixed_string_t vf;
11484 cmdline_fixed_string_t split;
11485 cmdline_fixed_string_t drop;
11488 cmdline_fixed_string_t on_off;
11491 /* Common CLI fields for vf split drop enable disable */
11492 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11493 TOKEN_STRING_INITIALIZER
11494 (struct cmd_vf_split_drop_en_result,
11496 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11497 TOKEN_STRING_INITIALIZER
11498 (struct cmd_vf_split_drop_en_result,
11500 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11501 TOKEN_STRING_INITIALIZER
11502 (struct cmd_vf_split_drop_en_result,
11504 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11505 TOKEN_STRING_INITIALIZER
11506 (struct cmd_vf_split_drop_en_result,
11508 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11509 TOKEN_NUM_INITIALIZER
11510 (struct cmd_vf_split_drop_en_result,
11511 port_id, RTE_UINT16);
11512 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11513 TOKEN_NUM_INITIALIZER
11514 (struct cmd_vf_split_drop_en_result,
11515 vf_id, RTE_UINT16);
11516 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11517 TOKEN_STRING_INITIALIZER
11518 (struct cmd_vf_split_drop_en_result,
11522 cmd_set_vf_split_drop_en_parsed(
11523 void *parsed_result,
11524 __rte_unused struct cmdline *cl,
11525 __rte_unused void *data)
11527 struct cmd_vf_split_drop_en_result *res = parsed_result;
11528 int ret = -ENOTSUP;
11529 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11531 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11534 #ifdef RTE_NET_IXGBE
11535 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11542 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11545 printf("invalid port_id %d\n", res->port_id);
11548 printf("not supported on port %d\n", res->port_id);
11551 printf("programming error: (%s)\n", strerror(-ret));
11555 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11556 .f = cmd_set_vf_split_drop_en_parsed,
11558 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11560 (void *)&cmd_vf_split_drop_en_set,
11561 (void *)&cmd_vf_split_drop_en_vf,
11562 (void *)&cmd_vf_split_drop_en_split,
11563 (void *)&cmd_vf_split_drop_en_drop,
11564 (void *)&cmd_vf_split_drop_en_port_id,
11565 (void *)&cmd_vf_split_drop_en_vf_id,
11566 (void *)&cmd_vf_split_drop_en_on_off,
11571 /* vf mac address configuration */
11573 /* Common result structure for vf mac address */
11574 struct cmd_set_vf_mac_addr_result {
11575 cmdline_fixed_string_t set;
11576 cmdline_fixed_string_t vf;
11577 cmdline_fixed_string_t mac;
11578 cmdline_fixed_string_t addr;
11581 struct rte_ether_addr mac_addr;
11585 /* Common CLI fields for vf split drop enable disable */
11586 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11587 TOKEN_STRING_INITIALIZER
11588 (struct cmd_set_vf_mac_addr_result,
11590 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11591 TOKEN_STRING_INITIALIZER
11592 (struct cmd_set_vf_mac_addr_result,
11594 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11595 TOKEN_STRING_INITIALIZER
11596 (struct cmd_set_vf_mac_addr_result,
11598 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11599 TOKEN_STRING_INITIALIZER
11600 (struct cmd_set_vf_mac_addr_result,
11602 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11603 TOKEN_NUM_INITIALIZER
11604 (struct cmd_set_vf_mac_addr_result,
11605 port_id, RTE_UINT16);
11606 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11607 TOKEN_NUM_INITIALIZER
11608 (struct cmd_set_vf_mac_addr_result,
11609 vf_id, RTE_UINT16);
11610 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11611 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11615 cmd_set_vf_mac_addr_parsed(
11616 void *parsed_result,
11617 __rte_unused struct cmdline *cl,
11618 __rte_unused void *data)
11620 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11621 int ret = -ENOTSUP;
11623 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11626 #ifdef RTE_NET_IXGBE
11627 if (ret == -ENOTSUP)
11628 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11631 #ifdef RTE_NET_I40E
11632 if (ret == -ENOTSUP)
11633 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11636 #ifdef RTE_NET_BNXT
11637 if (ret == -ENOTSUP)
11638 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11646 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11649 printf("invalid port_id %d\n", res->port_id);
11652 printf("function not implemented\n");
11655 printf("programming error: (%s)\n", strerror(-ret));
11659 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11660 .f = cmd_set_vf_mac_addr_parsed,
11662 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11664 (void *)&cmd_set_vf_mac_addr_set,
11665 (void *)&cmd_set_vf_mac_addr_vf,
11666 (void *)&cmd_set_vf_mac_addr_mac,
11667 (void *)&cmd_set_vf_mac_addr_addr,
11668 (void *)&cmd_set_vf_mac_addr_port_id,
11669 (void *)&cmd_set_vf_mac_addr_vf_id,
11670 (void *)&cmd_set_vf_mac_addr_mac_addr,
11675 /* MACsec configuration */
11677 /* Common result structure for MACsec offload enable */
11678 struct cmd_macsec_offload_on_result {
11679 cmdline_fixed_string_t set;
11680 cmdline_fixed_string_t macsec;
11681 cmdline_fixed_string_t offload;
11683 cmdline_fixed_string_t on;
11684 cmdline_fixed_string_t encrypt;
11685 cmdline_fixed_string_t en_on_off;
11686 cmdline_fixed_string_t replay_protect;
11687 cmdline_fixed_string_t rp_on_off;
11690 /* Common CLI fields for MACsec offload disable */
11691 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11692 TOKEN_STRING_INITIALIZER
11693 (struct cmd_macsec_offload_on_result,
11695 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11696 TOKEN_STRING_INITIALIZER
11697 (struct cmd_macsec_offload_on_result,
11699 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11700 TOKEN_STRING_INITIALIZER
11701 (struct cmd_macsec_offload_on_result,
11702 offload, "offload");
11703 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11704 TOKEN_NUM_INITIALIZER
11705 (struct cmd_macsec_offload_on_result,
11706 port_id, RTE_UINT16);
11707 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11708 TOKEN_STRING_INITIALIZER
11709 (struct cmd_macsec_offload_on_result,
11711 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11712 TOKEN_STRING_INITIALIZER
11713 (struct cmd_macsec_offload_on_result,
11714 encrypt, "encrypt");
11715 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11716 TOKEN_STRING_INITIALIZER
11717 (struct cmd_macsec_offload_on_result,
11718 en_on_off, "on#off");
11719 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11720 TOKEN_STRING_INITIALIZER
11721 (struct cmd_macsec_offload_on_result,
11722 replay_protect, "replay-protect");
11723 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11724 TOKEN_STRING_INITIALIZER
11725 (struct cmd_macsec_offload_on_result,
11726 rp_on_off, "on#off");
11729 cmd_set_macsec_offload_on_parsed(
11730 void *parsed_result,
11731 __rte_unused struct cmdline *cl,
11732 __rte_unused void *data)
11734 struct cmd_macsec_offload_on_result *res = parsed_result;
11735 int ret = -ENOTSUP;
11736 portid_t port_id = res->port_id;
11737 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11738 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11739 struct rte_eth_dev_info dev_info;
11741 if (port_id_is_invalid(port_id, ENABLED_WARN))
11743 if (!port_is_stopped(port_id)) {
11744 printf("Please stop port %d first\n", port_id);
11748 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11752 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11753 #ifdef RTE_NET_IXGBE
11754 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11762 ports[port_id].dev_conf.txmode.offloads |=
11763 DEV_TX_OFFLOAD_MACSEC_INSERT;
11764 cmd_reconfig_device_queue(port_id, 1, 1);
11767 printf("invalid port_id %d\n", port_id);
11770 printf("not supported on port %d\n", port_id);
11773 printf("programming error: (%s)\n", strerror(-ret));
11777 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11778 .f = cmd_set_macsec_offload_on_parsed,
11780 .help_str = "set macsec offload <port_id> on "
11781 "encrypt on|off replay-protect on|off",
11783 (void *)&cmd_macsec_offload_on_set,
11784 (void *)&cmd_macsec_offload_on_macsec,
11785 (void *)&cmd_macsec_offload_on_offload,
11786 (void *)&cmd_macsec_offload_on_port_id,
11787 (void *)&cmd_macsec_offload_on_on,
11788 (void *)&cmd_macsec_offload_on_encrypt,
11789 (void *)&cmd_macsec_offload_on_en_on_off,
11790 (void *)&cmd_macsec_offload_on_replay_protect,
11791 (void *)&cmd_macsec_offload_on_rp_on_off,
11796 /* Common result structure for MACsec offload disable */
11797 struct cmd_macsec_offload_off_result {
11798 cmdline_fixed_string_t set;
11799 cmdline_fixed_string_t macsec;
11800 cmdline_fixed_string_t offload;
11802 cmdline_fixed_string_t off;
11805 /* Common CLI fields for MACsec offload disable */
11806 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11807 TOKEN_STRING_INITIALIZER
11808 (struct cmd_macsec_offload_off_result,
11810 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11811 TOKEN_STRING_INITIALIZER
11812 (struct cmd_macsec_offload_off_result,
11814 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11815 TOKEN_STRING_INITIALIZER
11816 (struct cmd_macsec_offload_off_result,
11817 offload, "offload");
11818 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11819 TOKEN_NUM_INITIALIZER
11820 (struct cmd_macsec_offload_off_result,
11821 port_id, RTE_UINT16);
11822 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11823 TOKEN_STRING_INITIALIZER
11824 (struct cmd_macsec_offload_off_result,
11828 cmd_set_macsec_offload_off_parsed(
11829 void *parsed_result,
11830 __rte_unused struct cmdline *cl,
11831 __rte_unused void *data)
11833 struct cmd_macsec_offload_off_result *res = parsed_result;
11834 int ret = -ENOTSUP;
11835 struct rte_eth_dev_info dev_info;
11836 portid_t port_id = res->port_id;
11838 if (port_id_is_invalid(port_id, ENABLED_WARN))
11840 if (!port_is_stopped(port_id)) {
11841 printf("Please stop port %d first\n", port_id);
11845 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11849 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11850 #ifdef RTE_NET_IXGBE
11851 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11856 ports[port_id].dev_conf.txmode.offloads &=
11857 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11858 cmd_reconfig_device_queue(port_id, 1, 1);
11861 printf("invalid port_id %d\n", port_id);
11864 printf("not supported on port %d\n", port_id);
11867 printf("programming error: (%s)\n", strerror(-ret));
11871 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11872 .f = cmd_set_macsec_offload_off_parsed,
11874 .help_str = "set macsec offload <port_id> off",
11876 (void *)&cmd_macsec_offload_off_set,
11877 (void *)&cmd_macsec_offload_off_macsec,
11878 (void *)&cmd_macsec_offload_off_offload,
11879 (void *)&cmd_macsec_offload_off_port_id,
11880 (void *)&cmd_macsec_offload_off_off,
11885 /* Common result structure for MACsec secure connection configure */
11886 struct cmd_macsec_sc_result {
11887 cmdline_fixed_string_t set;
11888 cmdline_fixed_string_t macsec;
11889 cmdline_fixed_string_t sc;
11890 cmdline_fixed_string_t tx_rx;
11892 struct rte_ether_addr mac;
11896 /* Common CLI fields for MACsec secure connection configure */
11897 cmdline_parse_token_string_t cmd_macsec_sc_set =
11898 TOKEN_STRING_INITIALIZER
11899 (struct cmd_macsec_sc_result,
11901 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11902 TOKEN_STRING_INITIALIZER
11903 (struct cmd_macsec_sc_result,
11905 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11906 TOKEN_STRING_INITIALIZER
11907 (struct cmd_macsec_sc_result,
11909 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11910 TOKEN_STRING_INITIALIZER
11911 (struct cmd_macsec_sc_result,
11913 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11914 TOKEN_NUM_INITIALIZER
11915 (struct cmd_macsec_sc_result,
11916 port_id, RTE_UINT16);
11917 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11918 TOKEN_ETHERADDR_INITIALIZER
11919 (struct cmd_macsec_sc_result,
11921 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11922 TOKEN_NUM_INITIALIZER
11923 (struct cmd_macsec_sc_result,
11927 cmd_set_macsec_sc_parsed(
11928 void *parsed_result,
11929 __rte_unused struct cmdline *cl,
11930 __rte_unused void *data)
11932 struct cmd_macsec_sc_result *res = parsed_result;
11933 int ret = -ENOTSUP;
11934 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11936 #ifdef RTE_NET_IXGBE
11938 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11939 res->mac.addr_bytes) :
11940 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11941 res->mac.addr_bytes, res->pi);
11943 RTE_SET_USED(is_tx);
11949 printf("invalid port_id %d\n", res->port_id);
11952 printf("not supported on port %d\n", res->port_id);
11955 printf("programming error: (%s)\n", strerror(-ret));
11959 cmdline_parse_inst_t cmd_set_macsec_sc = {
11960 .f = cmd_set_macsec_sc_parsed,
11962 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11964 (void *)&cmd_macsec_sc_set,
11965 (void *)&cmd_macsec_sc_macsec,
11966 (void *)&cmd_macsec_sc_sc,
11967 (void *)&cmd_macsec_sc_tx_rx,
11968 (void *)&cmd_macsec_sc_port_id,
11969 (void *)&cmd_macsec_sc_mac,
11970 (void *)&cmd_macsec_sc_pi,
11975 /* Common result structure for MACsec secure connection configure */
11976 struct cmd_macsec_sa_result {
11977 cmdline_fixed_string_t set;
11978 cmdline_fixed_string_t macsec;
11979 cmdline_fixed_string_t sa;
11980 cmdline_fixed_string_t tx_rx;
11985 cmdline_fixed_string_t key;
11988 /* Common CLI fields for MACsec secure connection configure */
11989 cmdline_parse_token_string_t cmd_macsec_sa_set =
11990 TOKEN_STRING_INITIALIZER
11991 (struct cmd_macsec_sa_result,
11993 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11994 TOKEN_STRING_INITIALIZER
11995 (struct cmd_macsec_sa_result,
11997 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11998 TOKEN_STRING_INITIALIZER
11999 (struct cmd_macsec_sa_result,
12001 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12002 TOKEN_STRING_INITIALIZER
12003 (struct cmd_macsec_sa_result,
12005 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12006 TOKEN_NUM_INITIALIZER
12007 (struct cmd_macsec_sa_result,
12008 port_id, RTE_UINT16);
12009 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12010 TOKEN_NUM_INITIALIZER
12011 (struct cmd_macsec_sa_result,
12013 cmdline_parse_token_num_t cmd_macsec_sa_an =
12014 TOKEN_NUM_INITIALIZER
12015 (struct cmd_macsec_sa_result,
12017 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12018 TOKEN_NUM_INITIALIZER
12019 (struct cmd_macsec_sa_result,
12021 cmdline_parse_token_string_t cmd_macsec_sa_key =
12022 TOKEN_STRING_INITIALIZER
12023 (struct cmd_macsec_sa_result,
12027 cmd_set_macsec_sa_parsed(
12028 void *parsed_result,
12029 __rte_unused struct cmdline *cl,
12030 __rte_unused void *data)
12032 struct cmd_macsec_sa_result *res = parsed_result;
12033 int ret = -ENOTSUP;
12034 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12035 uint8_t key[16] = { 0 };
12041 key_len = strlen(res->key) / 2;
12045 for (i = 0; i < key_len; i++) {
12046 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12049 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12052 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12055 #ifdef RTE_NET_IXGBE
12057 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12058 res->idx, res->an, res->pn, key) :
12059 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12060 res->idx, res->an, res->pn, key);
12062 RTE_SET_USED(is_tx);
12069 printf("invalid idx %d or an %d\n", res->idx, res->an);
12072 printf("invalid port_id %d\n", res->port_id);
12075 printf("not supported on port %d\n", res->port_id);
12078 printf("programming error: (%s)\n", strerror(-ret));
12082 cmdline_parse_inst_t cmd_set_macsec_sa = {
12083 .f = cmd_set_macsec_sa_parsed,
12085 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12087 (void *)&cmd_macsec_sa_set,
12088 (void *)&cmd_macsec_sa_macsec,
12089 (void *)&cmd_macsec_sa_sa,
12090 (void *)&cmd_macsec_sa_tx_rx,
12091 (void *)&cmd_macsec_sa_port_id,
12092 (void *)&cmd_macsec_sa_idx,
12093 (void *)&cmd_macsec_sa_an,
12094 (void *)&cmd_macsec_sa_pn,
12095 (void *)&cmd_macsec_sa_key,
12100 /* VF unicast promiscuous mode configuration */
12102 /* Common result structure for VF unicast promiscuous mode */
12103 struct cmd_vf_promisc_result {
12104 cmdline_fixed_string_t set;
12105 cmdline_fixed_string_t vf;
12106 cmdline_fixed_string_t promisc;
12109 cmdline_fixed_string_t on_off;
12112 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12113 cmdline_parse_token_string_t cmd_vf_promisc_set =
12114 TOKEN_STRING_INITIALIZER
12115 (struct cmd_vf_promisc_result,
12117 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12118 TOKEN_STRING_INITIALIZER
12119 (struct cmd_vf_promisc_result,
12121 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12122 TOKEN_STRING_INITIALIZER
12123 (struct cmd_vf_promisc_result,
12124 promisc, "promisc");
12125 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12126 TOKEN_NUM_INITIALIZER
12127 (struct cmd_vf_promisc_result,
12128 port_id, RTE_UINT16);
12129 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12130 TOKEN_NUM_INITIALIZER
12131 (struct cmd_vf_promisc_result,
12132 vf_id, RTE_UINT32);
12133 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12134 TOKEN_STRING_INITIALIZER
12135 (struct cmd_vf_promisc_result,
12139 cmd_set_vf_promisc_parsed(
12140 void *parsed_result,
12141 __rte_unused struct cmdline *cl,
12142 __rte_unused void *data)
12144 struct cmd_vf_promisc_result *res = parsed_result;
12145 int ret = -ENOTSUP;
12147 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12149 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12152 #ifdef RTE_NET_I40E
12153 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12154 res->vf_id, is_on);
12161 printf("invalid vf_id %d\n", res->vf_id);
12164 printf("invalid port_id %d\n", res->port_id);
12167 printf("function not implemented\n");
12170 printf("programming error: (%s)\n", strerror(-ret));
12174 cmdline_parse_inst_t cmd_set_vf_promisc = {
12175 .f = cmd_set_vf_promisc_parsed,
12177 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12178 "Set unicast promiscuous mode for a VF from the PF",
12180 (void *)&cmd_vf_promisc_set,
12181 (void *)&cmd_vf_promisc_vf,
12182 (void *)&cmd_vf_promisc_promisc,
12183 (void *)&cmd_vf_promisc_port_id,
12184 (void *)&cmd_vf_promisc_vf_id,
12185 (void *)&cmd_vf_promisc_on_off,
12190 /* VF multicast promiscuous mode configuration */
12192 /* Common result structure for VF multicast promiscuous mode */
12193 struct cmd_vf_allmulti_result {
12194 cmdline_fixed_string_t set;
12195 cmdline_fixed_string_t vf;
12196 cmdline_fixed_string_t allmulti;
12199 cmdline_fixed_string_t on_off;
12202 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12203 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12204 TOKEN_STRING_INITIALIZER
12205 (struct cmd_vf_allmulti_result,
12207 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12208 TOKEN_STRING_INITIALIZER
12209 (struct cmd_vf_allmulti_result,
12211 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12212 TOKEN_STRING_INITIALIZER
12213 (struct cmd_vf_allmulti_result,
12214 allmulti, "allmulti");
12215 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12216 TOKEN_NUM_INITIALIZER
12217 (struct cmd_vf_allmulti_result,
12218 port_id, RTE_UINT16);
12219 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12220 TOKEN_NUM_INITIALIZER
12221 (struct cmd_vf_allmulti_result,
12222 vf_id, RTE_UINT32);
12223 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12224 TOKEN_STRING_INITIALIZER
12225 (struct cmd_vf_allmulti_result,
12229 cmd_set_vf_allmulti_parsed(
12230 void *parsed_result,
12231 __rte_unused struct cmdline *cl,
12232 __rte_unused void *data)
12234 struct cmd_vf_allmulti_result *res = parsed_result;
12235 int ret = -ENOTSUP;
12237 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12239 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12242 #ifdef RTE_NET_I40E
12243 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12244 res->vf_id, is_on);
12251 printf("invalid vf_id %d\n", res->vf_id);
12254 printf("invalid port_id %d\n", res->port_id);
12257 printf("function not implemented\n");
12260 printf("programming error: (%s)\n", strerror(-ret));
12264 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12265 .f = cmd_set_vf_allmulti_parsed,
12267 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12268 "Set multicast promiscuous mode for a VF from the PF",
12270 (void *)&cmd_vf_allmulti_set,
12271 (void *)&cmd_vf_allmulti_vf,
12272 (void *)&cmd_vf_allmulti_allmulti,
12273 (void *)&cmd_vf_allmulti_port_id,
12274 (void *)&cmd_vf_allmulti_vf_id,
12275 (void *)&cmd_vf_allmulti_on_off,
12280 /* vf broadcast mode configuration */
12282 /* Common result structure for vf broadcast */
12283 struct cmd_set_vf_broadcast_result {
12284 cmdline_fixed_string_t set;
12285 cmdline_fixed_string_t vf;
12286 cmdline_fixed_string_t broadcast;
12289 cmdline_fixed_string_t on_off;
12292 /* Common CLI fields for vf broadcast enable disable */
12293 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12294 TOKEN_STRING_INITIALIZER
12295 (struct cmd_set_vf_broadcast_result,
12297 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12298 TOKEN_STRING_INITIALIZER
12299 (struct cmd_set_vf_broadcast_result,
12301 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12302 TOKEN_STRING_INITIALIZER
12303 (struct cmd_set_vf_broadcast_result,
12304 broadcast, "broadcast");
12305 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12306 TOKEN_NUM_INITIALIZER
12307 (struct cmd_set_vf_broadcast_result,
12308 port_id, RTE_UINT16);
12309 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12310 TOKEN_NUM_INITIALIZER
12311 (struct cmd_set_vf_broadcast_result,
12312 vf_id, RTE_UINT16);
12313 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12314 TOKEN_STRING_INITIALIZER
12315 (struct cmd_set_vf_broadcast_result,
12319 cmd_set_vf_broadcast_parsed(
12320 void *parsed_result,
12321 __rte_unused struct cmdline *cl,
12322 __rte_unused void *data)
12324 struct cmd_set_vf_broadcast_result *res = parsed_result;
12325 int ret = -ENOTSUP;
12327 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12329 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12332 #ifdef RTE_NET_I40E
12333 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12334 res->vf_id, is_on);
12341 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12344 printf("invalid port_id %d\n", res->port_id);
12347 printf("function not implemented\n");
12350 printf("programming error: (%s)\n", strerror(-ret));
12354 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12355 .f = cmd_set_vf_broadcast_parsed,
12357 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12359 (void *)&cmd_set_vf_broadcast_set,
12360 (void *)&cmd_set_vf_broadcast_vf,
12361 (void *)&cmd_set_vf_broadcast_broadcast,
12362 (void *)&cmd_set_vf_broadcast_port_id,
12363 (void *)&cmd_set_vf_broadcast_vf_id,
12364 (void *)&cmd_set_vf_broadcast_on_off,
12369 /* vf vlan tag configuration */
12371 /* Common result structure for vf vlan tag */
12372 struct cmd_set_vf_vlan_tag_result {
12373 cmdline_fixed_string_t set;
12374 cmdline_fixed_string_t vf;
12375 cmdline_fixed_string_t vlan;
12376 cmdline_fixed_string_t tag;
12379 cmdline_fixed_string_t on_off;
12382 /* Common CLI fields for vf vlan tag enable disable */
12383 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12384 TOKEN_STRING_INITIALIZER
12385 (struct cmd_set_vf_vlan_tag_result,
12387 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12388 TOKEN_STRING_INITIALIZER
12389 (struct cmd_set_vf_vlan_tag_result,
12391 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12392 TOKEN_STRING_INITIALIZER
12393 (struct cmd_set_vf_vlan_tag_result,
12395 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12396 TOKEN_STRING_INITIALIZER
12397 (struct cmd_set_vf_vlan_tag_result,
12399 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12400 TOKEN_NUM_INITIALIZER
12401 (struct cmd_set_vf_vlan_tag_result,
12402 port_id, RTE_UINT16);
12403 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12404 TOKEN_NUM_INITIALIZER
12405 (struct cmd_set_vf_vlan_tag_result,
12406 vf_id, RTE_UINT16);
12407 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12408 TOKEN_STRING_INITIALIZER
12409 (struct cmd_set_vf_vlan_tag_result,
12413 cmd_set_vf_vlan_tag_parsed(
12414 void *parsed_result,
12415 __rte_unused struct cmdline *cl,
12416 __rte_unused void *data)
12418 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12419 int ret = -ENOTSUP;
12421 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12423 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12426 #ifdef RTE_NET_I40E
12427 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12428 res->vf_id, is_on);
12435 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12438 printf("invalid port_id %d\n", res->port_id);
12441 printf("function not implemented\n");
12444 printf("programming error: (%s)\n", strerror(-ret));
12448 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12449 .f = cmd_set_vf_vlan_tag_parsed,
12451 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12453 (void *)&cmd_set_vf_vlan_tag_set,
12454 (void *)&cmd_set_vf_vlan_tag_vf,
12455 (void *)&cmd_set_vf_vlan_tag_vlan,
12456 (void *)&cmd_set_vf_vlan_tag_tag,
12457 (void *)&cmd_set_vf_vlan_tag_port_id,
12458 (void *)&cmd_set_vf_vlan_tag_vf_id,
12459 (void *)&cmd_set_vf_vlan_tag_on_off,
12464 /* Common definition of VF and TC TX bandwidth configuration */
12465 struct cmd_vf_tc_bw_result {
12466 cmdline_fixed_string_t set;
12467 cmdline_fixed_string_t vf;
12468 cmdline_fixed_string_t tc;
12469 cmdline_fixed_string_t tx;
12470 cmdline_fixed_string_t min_bw;
12471 cmdline_fixed_string_t max_bw;
12472 cmdline_fixed_string_t strict_link_prio;
12477 cmdline_fixed_string_t bw_list;
12481 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12482 TOKEN_STRING_INITIALIZER
12483 (struct cmd_vf_tc_bw_result,
12485 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12486 TOKEN_STRING_INITIALIZER
12487 (struct cmd_vf_tc_bw_result,
12489 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12490 TOKEN_STRING_INITIALIZER
12491 (struct cmd_vf_tc_bw_result,
12493 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12494 TOKEN_STRING_INITIALIZER
12495 (struct cmd_vf_tc_bw_result,
12497 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12498 TOKEN_STRING_INITIALIZER
12499 (struct cmd_vf_tc_bw_result,
12500 strict_link_prio, "strict-link-priority");
12501 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12502 TOKEN_STRING_INITIALIZER
12503 (struct cmd_vf_tc_bw_result,
12504 min_bw, "min-bandwidth");
12505 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12506 TOKEN_STRING_INITIALIZER
12507 (struct cmd_vf_tc_bw_result,
12508 max_bw, "max-bandwidth");
12509 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12510 TOKEN_NUM_INITIALIZER
12511 (struct cmd_vf_tc_bw_result,
12512 port_id, RTE_UINT16);
12513 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12514 TOKEN_NUM_INITIALIZER
12515 (struct cmd_vf_tc_bw_result,
12516 vf_id, RTE_UINT16);
12517 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12518 TOKEN_NUM_INITIALIZER
12519 (struct cmd_vf_tc_bw_result,
12521 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12522 TOKEN_NUM_INITIALIZER
12523 (struct cmd_vf_tc_bw_result,
12525 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12526 TOKEN_STRING_INITIALIZER
12527 (struct cmd_vf_tc_bw_result,
12529 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12530 TOKEN_NUM_INITIALIZER
12531 (struct cmd_vf_tc_bw_result,
12532 tc_map, RTE_UINT8);
12534 /* VF max bandwidth setting */
12536 cmd_vf_max_bw_parsed(
12537 void *parsed_result,
12538 __rte_unused struct cmdline *cl,
12539 __rte_unused void *data)
12541 struct cmd_vf_tc_bw_result *res = parsed_result;
12542 int ret = -ENOTSUP;
12544 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12547 #ifdef RTE_NET_I40E
12548 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12549 res->vf_id, res->bw);
12556 printf("invalid vf_id %d or bandwidth %d\n",
12557 res->vf_id, res->bw);
12560 printf("invalid port_id %d\n", res->port_id);
12563 printf("function not implemented\n");
12566 printf("programming error: (%s)\n", strerror(-ret));
12570 cmdline_parse_inst_t cmd_vf_max_bw = {
12571 .f = cmd_vf_max_bw_parsed,
12573 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12575 (void *)&cmd_vf_tc_bw_set,
12576 (void *)&cmd_vf_tc_bw_vf,
12577 (void *)&cmd_vf_tc_bw_tx,
12578 (void *)&cmd_vf_tc_bw_max_bw,
12579 (void *)&cmd_vf_tc_bw_port_id,
12580 (void *)&cmd_vf_tc_bw_vf_id,
12581 (void *)&cmd_vf_tc_bw_bw,
12587 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12592 const char *p, *p0 = str;
12599 p = strchr(p0, '(');
12601 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12605 p0 = strchr(p, ')');
12607 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12611 if (size >= sizeof(s)) {
12612 printf("The string size exceeds the internal buffer size\n");
12615 snprintf(s, sizeof(s), "%.*s", size, p);
12616 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12618 printf("Failed to get the bandwidth list. ");
12622 for (i = 0; i < ret; i++)
12623 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12628 /* TC min bandwidth setting */
12630 cmd_vf_tc_min_bw_parsed(
12631 void *parsed_result,
12632 __rte_unused struct cmdline *cl,
12633 __rte_unused void *data)
12635 struct cmd_vf_tc_bw_result *res = parsed_result;
12638 int ret = -ENOTSUP;
12640 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12643 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12647 #ifdef RTE_NET_I40E
12648 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12656 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12659 printf("invalid port_id %d\n", res->port_id);
12662 printf("function not implemented\n");
12665 printf("programming error: (%s)\n", strerror(-ret));
12669 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12670 .f = cmd_vf_tc_min_bw_parsed,
12672 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12673 " <bw1, bw2, ...>",
12675 (void *)&cmd_vf_tc_bw_set,
12676 (void *)&cmd_vf_tc_bw_vf,
12677 (void *)&cmd_vf_tc_bw_tc,
12678 (void *)&cmd_vf_tc_bw_tx,
12679 (void *)&cmd_vf_tc_bw_min_bw,
12680 (void *)&cmd_vf_tc_bw_port_id,
12681 (void *)&cmd_vf_tc_bw_vf_id,
12682 (void *)&cmd_vf_tc_bw_bw_list,
12688 cmd_tc_min_bw_parsed(
12689 void *parsed_result,
12690 __rte_unused struct cmdline *cl,
12691 __rte_unused void *data)
12693 struct cmd_vf_tc_bw_result *res = parsed_result;
12694 struct rte_port *port;
12697 int ret = -ENOTSUP;
12699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12702 port = &ports[res->port_id];
12703 /** Check if the port is not started **/
12704 if (port->port_status != RTE_PORT_STOPPED) {
12705 printf("Please stop port %d first\n", res->port_id);
12709 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12713 #ifdef RTE_NET_IXGBE
12714 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12721 printf("invalid bandwidth\n");
12724 printf("invalid port_id %d\n", res->port_id);
12727 printf("function not implemented\n");
12730 printf("programming error: (%s)\n", strerror(-ret));
12734 cmdline_parse_inst_t cmd_tc_min_bw = {
12735 .f = cmd_tc_min_bw_parsed,
12737 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12739 (void *)&cmd_vf_tc_bw_set,
12740 (void *)&cmd_vf_tc_bw_tc,
12741 (void *)&cmd_vf_tc_bw_tx,
12742 (void *)&cmd_vf_tc_bw_min_bw,
12743 (void *)&cmd_vf_tc_bw_port_id,
12744 (void *)&cmd_vf_tc_bw_bw_list,
12749 /* TC max bandwidth setting */
12751 cmd_vf_tc_max_bw_parsed(
12752 void *parsed_result,
12753 __rte_unused struct cmdline *cl,
12754 __rte_unused void *data)
12756 struct cmd_vf_tc_bw_result *res = parsed_result;
12757 int ret = -ENOTSUP;
12759 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12762 #ifdef RTE_NET_I40E
12763 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12764 res->tc_no, res->bw);
12771 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12772 res->vf_id, res->tc_no, res->bw);
12775 printf("invalid port_id %d\n", res->port_id);
12778 printf("function not implemented\n");
12781 printf("programming error: (%s)\n", strerror(-ret));
12785 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12786 .f = cmd_vf_tc_max_bw_parsed,
12788 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12791 (void *)&cmd_vf_tc_bw_set,
12792 (void *)&cmd_vf_tc_bw_vf,
12793 (void *)&cmd_vf_tc_bw_tc,
12794 (void *)&cmd_vf_tc_bw_tx,
12795 (void *)&cmd_vf_tc_bw_max_bw,
12796 (void *)&cmd_vf_tc_bw_port_id,
12797 (void *)&cmd_vf_tc_bw_vf_id,
12798 (void *)&cmd_vf_tc_bw_tc_no,
12799 (void *)&cmd_vf_tc_bw_bw,
12804 /** Set VXLAN encapsulation details */
12805 struct cmd_set_vxlan_result {
12806 cmdline_fixed_string_t set;
12807 cmdline_fixed_string_t vxlan;
12808 cmdline_fixed_string_t pos_token;
12809 cmdline_fixed_string_t ip_version;
12810 uint32_t vlan_present:1;
12814 cmdline_ipaddr_t ip_src;
12815 cmdline_ipaddr_t ip_dst;
12819 struct rte_ether_addr eth_src;
12820 struct rte_ether_addr eth_dst;
12823 cmdline_parse_token_string_t cmd_set_vxlan_set =
12824 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12825 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12826 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12827 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12828 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12830 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12831 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12832 "vxlan-with-vlan");
12833 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12834 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12836 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12837 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12839 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12840 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12842 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12843 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12844 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12845 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12847 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12848 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12849 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12850 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12852 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12853 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12854 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12855 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12857 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12858 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12859 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12860 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12862 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12863 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12864 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12865 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12867 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12868 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12869 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12870 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12872 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12873 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12874 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12875 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12877 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12878 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12879 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12880 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12882 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12883 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12884 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12885 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12887 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12888 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12890 static void cmd_set_vxlan_parsed(void *parsed_result,
12891 __rte_unused struct cmdline *cl,
12892 __rte_unused void *data)
12894 struct cmd_set_vxlan_result *res = parsed_result;
12899 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12902 vxlan_encap_conf.select_tos_ttl = 0;
12903 if (strcmp(res->vxlan, "vxlan") == 0)
12904 vxlan_encap_conf.select_vlan = 0;
12905 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12906 vxlan_encap_conf.select_vlan = 1;
12907 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12908 vxlan_encap_conf.select_vlan = 0;
12909 vxlan_encap_conf.select_tos_ttl = 1;
12911 if (strcmp(res->ip_version, "ipv4") == 0)
12912 vxlan_encap_conf.select_ipv4 = 1;
12913 else if (strcmp(res->ip_version, "ipv6") == 0)
12914 vxlan_encap_conf.select_ipv4 = 0;
12917 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12918 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12919 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12920 vxlan_encap_conf.ip_tos = res->tos;
12921 vxlan_encap_conf.ip_ttl = res->ttl;
12922 if (vxlan_encap_conf.select_ipv4) {
12923 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12924 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12926 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12927 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12929 if (vxlan_encap_conf.select_vlan)
12930 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12931 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12932 RTE_ETHER_ADDR_LEN);
12933 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12934 RTE_ETHER_ADDR_LEN);
12937 cmdline_parse_inst_t cmd_set_vxlan = {
12938 .f = cmd_set_vxlan_parsed,
12940 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12941 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12942 " eth-src <eth-src> eth-dst <eth-dst>",
12944 (void *)&cmd_set_vxlan_set,
12945 (void *)&cmd_set_vxlan_vxlan,
12946 (void *)&cmd_set_vxlan_ip_version,
12947 (void *)&cmd_set_vxlan_ip_version_value,
12948 (void *)&cmd_set_vxlan_vni,
12949 (void *)&cmd_set_vxlan_vni_value,
12950 (void *)&cmd_set_vxlan_udp_src,
12951 (void *)&cmd_set_vxlan_udp_src_value,
12952 (void *)&cmd_set_vxlan_udp_dst,
12953 (void *)&cmd_set_vxlan_udp_dst_value,
12954 (void *)&cmd_set_vxlan_ip_src,
12955 (void *)&cmd_set_vxlan_ip_src_value,
12956 (void *)&cmd_set_vxlan_ip_dst,
12957 (void *)&cmd_set_vxlan_ip_dst_value,
12958 (void *)&cmd_set_vxlan_eth_src,
12959 (void *)&cmd_set_vxlan_eth_src_value,
12960 (void *)&cmd_set_vxlan_eth_dst,
12961 (void *)&cmd_set_vxlan_eth_dst_value,
12966 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12967 .f = cmd_set_vxlan_parsed,
12969 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12970 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12971 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12972 " eth-dst <eth-dst>",
12974 (void *)&cmd_set_vxlan_set,
12975 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12976 (void *)&cmd_set_vxlan_ip_version,
12977 (void *)&cmd_set_vxlan_ip_version_value,
12978 (void *)&cmd_set_vxlan_vni,
12979 (void *)&cmd_set_vxlan_vni_value,
12980 (void *)&cmd_set_vxlan_udp_src,
12981 (void *)&cmd_set_vxlan_udp_src_value,
12982 (void *)&cmd_set_vxlan_udp_dst,
12983 (void *)&cmd_set_vxlan_udp_dst_value,
12984 (void *)&cmd_set_vxlan_ip_tos,
12985 (void *)&cmd_set_vxlan_ip_tos_value,
12986 (void *)&cmd_set_vxlan_ip_ttl,
12987 (void *)&cmd_set_vxlan_ip_ttl_value,
12988 (void *)&cmd_set_vxlan_ip_src,
12989 (void *)&cmd_set_vxlan_ip_src_value,
12990 (void *)&cmd_set_vxlan_ip_dst,
12991 (void *)&cmd_set_vxlan_ip_dst_value,
12992 (void *)&cmd_set_vxlan_eth_src,
12993 (void *)&cmd_set_vxlan_eth_src_value,
12994 (void *)&cmd_set_vxlan_eth_dst,
12995 (void *)&cmd_set_vxlan_eth_dst_value,
13000 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13001 .f = cmd_set_vxlan_parsed,
13003 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13004 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13005 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13008 (void *)&cmd_set_vxlan_set,
13009 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13010 (void *)&cmd_set_vxlan_ip_version,
13011 (void *)&cmd_set_vxlan_ip_version_value,
13012 (void *)&cmd_set_vxlan_vni,
13013 (void *)&cmd_set_vxlan_vni_value,
13014 (void *)&cmd_set_vxlan_udp_src,
13015 (void *)&cmd_set_vxlan_udp_src_value,
13016 (void *)&cmd_set_vxlan_udp_dst,
13017 (void *)&cmd_set_vxlan_udp_dst_value,
13018 (void *)&cmd_set_vxlan_ip_src,
13019 (void *)&cmd_set_vxlan_ip_src_value,
13020 (void *)&cmd_set_vxlan_ip_dst,
13021 (void *)&cmd_set_vxlan_ip_dst_value,
13022 (void *)&cmd_set_vxlan_vlan,
13023 (void *)&cmd_set_vxlan_vlan_value,
13024 (void *)&cmd_set_vxlan_eth_src,
13025 (void *)&cmd_set_vxlan_eth_src_value,
13026 (void *)&cmd_set_vxlan_eth_dst,
13027 (void *)&cmd_set_vxlan_eth_dst_value,
13032 /** Set NVGRE encapsulation details */
13033 struct cmd_set_nvgre_result {
13034 cmdline_fixed_string_t set;
13035 cmdline_fixed_string_t nvgre;
13036 cmdline_fixed_string_t pos_token;
13037 cmdline_fixed_string_t ip_version;
13039 cmdline_ipaddr_t ip_src;
13040 cmdline_ipaddr_t ip_dst;
13042 struct rte_ether_addr eth_src;
13043 struct rte_ether_addr eth_dst;
13046 cmdline_parse_token_string_t cmd_set_nvgre_set =
13047 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13048 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13049 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13050 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13051 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13052 "nvgre-with-vlan");
13053 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13054 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13056 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13057 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13059 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13060 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13062 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13063 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13064 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13065 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13067 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13068 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13069 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13070 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13072 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13073 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13074 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13075 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13077 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13078 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13079 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13080 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13082 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13083 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13084 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13085 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13087 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13088 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13090 static void cmd_set_nvgre_parsed(void *parsed_result,
13091 __rte_unused struct cmdline *cl,
13092 __rte_unused void *data)
13094 struct cmd_set_nvgre_result *res = parsed_result;
13096 uint32_t nvgre_tni;
13099 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13102 if (strcmp(res->nvgre, "nvgre") == 0)
13103 nvgre_encap_conf.select_vlan = 0;
13104 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13105 nvgre_encap_conf.select_vlan = 1;
13106 if (strcmp(res->ip_version, "ipv4") == 0)
13107 nvgre_encap_conf.select_ipv4 = 1;
13108 else if (strcmp(res->ip_version, "ipv6") == 0)
13109 nvgre_encap_conf.select_ipv4 = 0;
13112 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13113 if (nvgre_encap_conf.select_ipv4) {
13114 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13115 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13117 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13118 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13120 if (nvgre_encap_conf.select_vlan)
13121 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13122 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13123 RTE_ETHER_ADDR_LEN);
13124 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13125 RTE_ETHER_ADDR_LEN);
13128 cmdline_parse_inst_t cmd_set_nvgre = {
13129 .f = cmd_set_nvgre_parsed,
13131 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13132 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13133 " eth-dst <eth-dst>",
13135 (void *)&cmd_set_nvgre_set,
13136 (void *)&cmd_set_nvgre_nvgre,
13137 (void *)&cmd_set_nvgre_ip_version,
13138 (void *)&cmd_set_nvgre_ip_version_value,
13139 (void *)&cmd_set_nvgre_tni,
13140 (void *)&cmd_set_nvgre_tni_value,
13141 (void *)&cmd_set_nvgre_ip_src,
13142 (void *)&cmd_set_nvgre_ip_src_value,
13143 (void *)&cmd_set_nvgre_ip_dst,
13144 (void *)&cmd_set_nvgre_ip_dst_value,
13145 (void *)&cmd_set_nvgre_eth_src,
13146 (void *)&cmd_set_nvgre_eth_src_value,
13147 (void *)&cmd_set_nvgre_eth_dst,
13148 (void *)&cmd_set_nvgre_eth_dst_value,
13153 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13154 .f = cmd_set_nvgre_parsed,
13156 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13157 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13158 " eth-src <eth-src> eth-dst <eth-dst>",
13160 (void *)&cmd_set_nvgre_set,
13161 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13162 (void *)&cmd_set_nvgre_ip_version,
13163 (void *)&cmd_set_nvgre_ip_version_value,
13164 (void *)&cmd_set_nvgre_tni,
13165 (void *)&cmd_set_nvgre_tni_value,
13166 (void *)&cmd_set_nvgre_ip_src,
13167 (void *)&cmd_set_nvgre_ip_src_value,
13168 (void *)&cmd_set_nvgre_ip_dst,
13169 (void *)&cmd_set_nvgre_ip_dst_value,
13170 (void *)&cmd_set_nvgre_vlan,
13171 (void *)&cmd_set_nvgre_vlan_value,
13172 (void *)&cmd_set_nvgre_eth_src,
13173 (void *)&cmd_set_nvgre_eth_src_value,
13174 (void *)&cmd_set_nvgre_eth_dst,
13175 (void *)&cmd_set_nvgre_eth_dst_value,
13180 /** Set L2 encapsulation details */
13181 struct cmd_set_l2_encap_result {
13182 cmdline_fixed_string_t set;
13183 cmdline_fixed_string_t l2_encap;
13184 cmdline_fixed_string_t pos_token;
13185 cmdline_fixed_string_t ip_version;
13186 uint32_t vlan_present:1;
13188 struct rte_ether_addr eth_src;
13189 struct rte_ether_addr eth_dst;
13192 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13193 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13194 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13195 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13196 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13197 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13198 "l2_encap-with-vlan");
13199 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13200 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13202 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13203 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13205 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13206 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13208 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13209 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13210 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13211 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13213 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13214 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13215 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13216 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13218 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13219 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13221 static void cmd_set_l2_encap_parsed(void *parsed_result,
13222 __rte_unused struct cmdline *cl,
13223 __rte_unused void *data)
13225 struct cmd_set_l2_encap_result *res = parsed_result;
13227 if (strcmp(res->l2_encap, "l2_encap") == 0)
13228 l2_encap_conf.select_vlan = 0;
13229 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13230 l2_encap_conf.select_vlan = 1;
13231 if (strcmp(res->ip_version, "ipv4") == 0)
13232 l2_encap_conf.select_ipv4 = 1;
13233 else if (strcmp(res->ip_version, "ipv6") == 0)
13234 l2_encap_conf.select_ipv4 = 0;
13237 if (l2_encap_conf.select_vlan)
13238 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13239 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13240 RTE_ETHER_ADDR_LEN);
13241 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13242 RTE_ETHER_ADDR_LEN);
13245 cmdline_parse_inst_t cmd_set_l2_encap = {
13246 .f = cmd_set_l2_encap_parsed,
13248 .help_str = "set l2_encap ip-version ipv4|ipv6"
13249 " eth-src <eth-src> eth-dst <eth-dst>",
13251 (void *)&cmd_set_l2_encap_set,
13252 (void *)&cmd_set_l2_encap_l2_encap,
13253 (void *)&cmd_set_l2_encap_ip_version,
13254 (void *)&cmd_set_l2_encap_ip_version_value,
13255 (void *)&cmd_set_l2_encap_eth_src,
13256 (void *)&cmd_set_l2_encap_eth_src_value,
13257 (void *)&cmd_set_l2_encap_eth_dst,
13258 (void *)&cmd_set_l2_encap_eth_dst_value,
13263 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13264 .f = cmd_set_l2_encap_parsed,
13266 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13267 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13269 (void *)&cmd_set_l2_encap_set,
13270 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13271 (void *)&cmd_set_l2_encap_ip_version,
13272 (void *)&cmd_set_l2_encap_ip_version_value,
13273 (void *)&cmd_set_l2_encap_vlan,
13274 (void *)&cmd_set_l2_encap_vlan_value,
13275 (void *)&cmd_set_l2_encap_eth_src,
13276 (void *)&cmd_set_l2_encap_eth_src_value,
13277 (void *)&cmd_set_l2_encap_eth_dst,
13278 (void *)&cmd_set_l2_encap_eth_dst_value,
13283 /** Set L2 decapsulation details */
13284 struct cmd_set_l2_decap_result {
13285 cmdline_fixed_string_t set;
13286 cmdline_fixed_string_t l2_decap;
13287 cmdline_fixed_string_t pos_token;
13288 uint32_t vlan_present:1;
13291 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13292 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13293 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13294 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13296 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13297 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13298 "l2_decap-with-vlan");
13300 static void cmd_set_l2_decap_parsed(void *parsed_result,
13301 __rte_unused struct cmdline *cl,
13302 __rte_unused void *data)
13304 struct cmd_set_l2_decap_result *res = parsed_result;
13306 if (strcmp(res->l2_decap, "l2_decap") == 0)
13307 l2_decap_conf.select_vlan = 0;
13308 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13309 l2_decap_conf.select_vlan = 1;
13312 cmdline_parse_inst_t cmd_set_l2_decap = {
13313 .f = cmd_set_l2_decap_parsed,
13315 .help_str = "set l2_decap",
13317 (void *)&cmd_set_l2_decap_set,
13318 (void *)&cmd_set_l2_decap_l2_decap,
13323 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13324 .f = cmd_set_l2_decap_parsed,
13326 .help_str = "set l2_decap-with-vlan",
13328 (void *)&cmd_set_l2_decap_set,
13329 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13334 /** Set MPLSoGRE encapsulation details */
13335 struct cmd_set_mplsogre_encap_result {
13336 cmdline_fixed_string_t set;
13337 cmdline_fixed_string_t mplsogre;
13338 cmdline_fixed_string_t pos_token;
13339 cmdline_fixed_string_t ip_version;
13340 uint32_t vlan_present:1;
13342 cmdline_ipaddr_t ip_src;
13343 cmdline_ipaddr_t ip_dst;
13345 struct rte_ether_addr eth_src;
13346 struct rte_ether_addr eth_dst;
13349 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13350 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13352 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13353 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13355 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13356 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13357 mplsogre, "mplsogre_encap-with-vlan");
13358 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13359 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13360 pos_token, "ip-version");
13361 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13362 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13363 ip_version, "ipv4#ipv6");
13364 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13365 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13366 pos_token, "label");
13367 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13368 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13370 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13371 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13372 pos_token, "ip-src");
13373 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13374 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13375 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13376 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13377 pos_token, "ip-dst");
13378 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13379 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13380 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13381 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13382 pos_token, "vlan-tci");
13383 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13384 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13386 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13387 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13388 pos_token, "eth-src");
13389 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13390 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13392 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13393 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13394 pos_token, "eth-dst");
13395 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13396 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13399 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13400 __rte_unused struct cmdline *cl,
13401 __rte_unused void *data)
13403 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13405 uint32_t mplsogre_label;
13408 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13411 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13412 mplsogre_encap_conf.select_vlan = 0;
13413 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13414 mplsogre_encap_conf.select_vlan = 1;
13415 if (strcmp(res->ip_version, "ipv4") == 0)
13416 mplsogre_encap_conf.select_ipv4 = 1;
13417 else if (strcmp(res->ip_version, "ipv6") == 0)
13418 mplsogre_encap_conf.select_ipv4 = 0;
13421 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13422 if (mplsogre_encap_conf.select_ipv4) {
13423 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13424 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13426 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13427 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13429 if (mplsogre_encap_conf.select_vlan)
13430 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13431 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13432 RTE_ETHER_ADDR_LEN);
13433 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13434 RTE_ETHER_ADDR_LEN);
13437 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13438 .f = cmd_set_mplsogre_encap_parsed,
13440 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13441 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13442 " eth-dst <eth-dst>",
13444 (void *)&cmd_set_mplsogre_encap_set,
13445 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13446 (void *)&cmd_set_mplsogre_encap_ip_version,
13447 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13448 (void *)&cmd_set_mplsogre_encap_label,
13449 (void *)&cmd_set_mplsogre_encap_label_value,
13450 (void *)&cmd_set_mplsogre_encap_ip_src,
13451 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13452 (void *)&cmd_set_mplsogre_encap_ip_dst,
13453 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13454 (void *)&cmd_set_mplsogre_encap_eth_src,
13455 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13456 (void *)&cmd_set_mplsogre_encap_eth_dst,
13457 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13462 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13463 .f = cmd_set_mplsogre_encap_parsed,
13465 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13466 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13467 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13469 (void *)&cmd_set_mplsogre_encap_set,
13470 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13471 (void *)&cmd_set_mplsogre_encap_ip_version,
13472 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13473 (void *)&cmd_set_mplsogre_encap_label,
13474 (void *)&cmd_set_mplsogre_encap_label_value,
13475 (void *)&cmd_set_mplsogre_encap_ip_src,
13476 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13477 (void *)&cmd_set_mplsogre_encap_ip_dst,
13478 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13479 (void *)&cmd_set_mplsogre_encap_vlan,
13480 (void *)&cmd_set_mplsogre_encap_vlan_value,
13481 (void *)&cmd_set_mplsogre_encap_eth_src,
13482 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13483 (void *)&cmd_set_mplsogre_encap_eth_dst,
13484 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13489 /** Set MPLSoGRE decapsulation details */
13490 struct cmd_set_mplsogre_decap_result {
13491 cmdline_fixed_string_t set;
13492 cmdline_fixed_string_t mplsogre;
13493 cmdline_fixed_string_t pos_token;
13494 cmdline_fixed_string_t ip_version;
13495 uint32_t vlan_present:1;
13498 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13499 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13501 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13502 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13504 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13505 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13506 mplsogre, "mplsogre_decap-with-vlan");
13507 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13508 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13509 pos_token, "ip-version");
13510 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13511 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13512 ip_version, "ipv4#ipv6");
13514 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13515 __rte_unused struct cmdline *cl,
13516 __rte_unused void *data)
13518 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13520 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13521 mplsogre_decap_conf.select_vlan = 0;
13522 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13523 mplsogre_decap_conf.select_vlan = 1;
13524 if (strcmp(res->ip_version, "ipv4") == 0)
13525 mplsogre_decap_conf.select_ipv4 = 1;
13526 else if (strcmp(res->ip_version, "ipv6") == 0)
13527 mplsogre_decap_conf.select_ipv4 = 0;
13530 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13531 .f = cmd_set_mplsogre_decap_parsed,
13533 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13535 (void *)&cmd_set_mplsogre_decap_set,
13536 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13537 (void *)&cmd_set_mplsogre_decap_ip_version,
13538 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13543 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13544 .f = cmd_set_mplsogre_decap_parsed,
13546 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13548 (void *)&cmd_set_mplsogre_decap_set,
13549 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13550 (void *)&cmd_set_mplsogre_decap_ip_version,
13551 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13556 /** Set MPLSoUDP encapsulation details */
13557 struct cmd_set_mplsoudp_encap_result {
13558 cmdline_fixed_string_t set;
13559 cmdline_fixed_string_t mplsoudp;
13560 cmdline_fixed_string_t pos_token;
13561 cmdline_fixed_string_t ip_version;
13562 uint32_t vlan_present:1;
13566 cmdline_ipaddr_t ip_src;
13567 cmdline_ipaddr_t ip_dst;
13569 struct rte_ether_addr eth_src;
13570 struct rte_ether_addr eth_dst;
13573 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13574 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13576 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13577 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13579 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13580 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13581 mplsoudp, "mplsoudp_encap-with-vlan");
13582 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13583 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13584 pos_token, "ip-version");
13585 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13586 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13587 ip_version, "ipv4#ipv6");
13588 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13589 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13590 pos_token, "label");
13591 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13592 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13594 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13595 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13596 pos_token, "udp-src");
13597 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13598 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13600 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13601 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13602 pos_token, "udp-dst");
13603 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13604 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13606 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13607 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13608 pos_token, "ip-src");
13609 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13610 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13611 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13612 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13613 pos_token, "ip-dst");
13614 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13615 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13616 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13617 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13618 pos_token, "vlan-tci");
13619 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13620 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13622 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13623 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13624 pos_token, "eth-src");
13625 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13626 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13628 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13629 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13630 pos_token, "eth-dst");
13631 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13632 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13635 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13636 __rte_unused struct cmdline *cl,
13637 __rte_unused void *data)
13639 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13641 uint32_t mplsoudp_label;
13644 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13647 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13648 mplsoudp_encap_conf.select_vlan = 0;
13649 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13650 mplsoudp_encap_conf.select_vlan = 1;
13651 if (strcmp(res->ip_version, "ipv4") == 0)
13652 mplsoudp_encap_conf.select_ipv4 = 1;
13653 else if (strcmp(res->ip_version, "ipv6") == 0)
13654 mplsoudp_encap_conf.select_ipv4 = 0;
13657 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13658 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13659 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13660 if (mplsoudp_encap_conf.select_ipv4) {
13661 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13662 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13664 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13665 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13667 if (mplsoudp_encap_conf.select_vlan)
13668 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13669 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13670 RTE_ETHER_ADDR_LEN);
13671 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13672 RTE_ETHER_ADDR_LEN);
13675 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13676 .f = cmd_set_mplsoudp_encap_parsed,
13678 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13679 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13680 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13682 (void *)&cmd_set_mplsoudp_encap_set,
13683 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13684 (void *)&cmd_set_mplsoudp_encap_ip_version,
13685 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13686 (void *)&cmd_set_mplsoudp_encap_label,
13687 (void *)&cmd_set_mplsoudp_encap_label_value,
13688 (void *)&cmd_set_mplsoudp_encap_udp_src,
13689 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13690 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13691 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13692 (void *)&cmd_set_mplsoudp_encap_ip_src,
13693 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13694 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13695 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13696 (void *)&cmd_set_mplsoudp_encap_eth_src,
13697 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13698 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13699 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13704 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13705 .f = cmd_set_mplsoudp_encap_parsed,
13707 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13708 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13709 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13710 " eth-src <eth-src> eth-dst <eth-dst>",
13712 (void *)&cmd_set_mplsoudp_encap_set,
13713 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13714 (void *)&cmd_set_mplsoudp_encap_ip_version,
13715 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13716 (void *)&cmd_set_mplsoudp_encap_label,
13717 (void *)&cmd_set_mplsoudp_encap_label_value,
13718 (void *)&cmd_set_mplsoudp_encap_udp_src,
13719 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13720 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13721 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13722 (void *)&cmd_set_mplsoudp_encap_ip_src,
13723 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13724 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13725 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13726 (void *)&cmd_set_mplsoudp_encap_vlan,
13727 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13728 (void *)&cmd_set_mplsoudp_encap_eth_src,
13729 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13730 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13731 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13736 /** Set MPLSoUDP decapsulation details */
13737 struct cmd_set_mplsoudp_decap_result {
13738 cmdline_fixed_string_t set;
13739 cmdline_fixed_string_t mplsoudp;
13740 cmdline_fixed_string_t pos_token;
13741 cmdline_fixed_string_t ip_version;
13742 uint32_t vlan_present:1;
13745 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13746 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13748 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13749 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13751 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13752 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13753 mplsoudp, "mplsoudp_decap-with-vlan");
13754 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13755 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13756 pos_token, "ip-version");
13757 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13758 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13759 ip_version, "ipv4#ipv6");
13761 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13762 __rte_unused struct cmdline *cl,
13763 __rte_unused void *data)
13765 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13767 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13768 mplsoudp_decap_conf.select_vlan = 0;
13769 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13770 mplsoudp_decap_conf.select_vlan = 1;
13771 if (strcmp(res->ip_version, "ipv4") == 0)
13772 mplsoudp_decap_conf.select_ipv4 = 1;
13773 else if (strcmp(res->ip_version, "ipv6") == 0)
13774 mplsoudp_decap_conf.select_ipv4 = 0;
13777 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13778 .f = cmd_set_mplsoudp_decap_parsed,
13780 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13782 (void *)&cmd_set_mplsoudp_decap_set,
13783 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13784 (void *)&cmd_set_mplsoudp_decap_ip_version,
13785 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13790 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13791 .f = cmd_set_mplsoudp_decap_parsed,
13793 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13795 (void *)&cmd_set_mplsoudp_decap_set,
13796 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13797 (void *)&cmd_set_mplsoudp_decap_ip_version,
13798 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13803 /** Set connection tracking object common details */
13804 struct cmd_set_conntrack_common_result {
13805 cmdline_fixed_string_t set;
13806 cmdline_fixed_string_t conntrack;
13807 cmdline_fixed_string_t common;
13808 cmdline_fixed_string_t peer;
13809 cmdline_fixed_string_t is_orig;
13810 cmdline_fixed_string_t enable;
13811 cmdline_fixed_string_t live;
13812 cmdline_fixed_string_t sack;
13813 cmdline_fixed_string_t cack;
13814 cmdline_fixed_string_t last_dir;
13815 cmdline_fixed_string_t liberal;
13816 cmdline_fixed_string_t state;
13817 cmdline_fixed_string_t max_ack_win;
13818 cmdline_fixed_string_t retrans;
13819 cmdline_fixed_string_t last_win;
13820 cmdline_fixed_string_t last_seq;
13821 cmdline_fixed_string_t last_ack;
13822 cmdline_fixed_string_t last_end;
13823 cmdline_fixed_string_t last_index;
13826 uint16_t peer_port;
13827 uint32_t is_original;
13842 cmdline_parse_token_string_t cmd_set_conntrack_set =
13843 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13845 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13846 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13847 conntrack, "conntrack");
13848 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13849 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13851 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13852 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13854 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13855 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13856 peer_port, RTE_UINT16);
13857 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13858 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13859 is_orig, "is_orig");
13860 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13861 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13862 is_original, RTE_UINT32);
13863 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13864 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13866 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13867 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13869 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13870 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13872 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13873 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13874 is_live, RTE_UINT32);
13875 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13876 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13878 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13879 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13880 s_ack, RTE_UINT32);
13881 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13882 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13884 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13885 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13886 c_ack, RTE_UINT32);
13887 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13888 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13889 last_dir, "last_dir");
13890 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13891 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13893 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13894 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13895 liberal, "liberal");
13896 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13897 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13899 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13900 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13902 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13903 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13905 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13906 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13907 max_ack_win, "max_ack_win");
13908 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13909 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13910 factor, RTE_UINT8);
13911 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13912 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13914 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13915 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13916 re_num, RTE_UINT8);
13917 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13918 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13919 last_win, "last_win");
13920 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13921 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13923 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13924 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13925 last_seq, "last_seq");
13926 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13927 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13929 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13930 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13931 last_ack, "last_ack");
13932 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13933 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13935 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13936 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13937 last_end, "last_end");
13938 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13939 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13941 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13942 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13943 last_index, "last_index");
13944 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13945 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13948 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13949 __rte_unused struct cmdline *cl,
13950 __rte_unused void *data)
13952 struct cmd_set_conntrack_common_result *res = parsed_result;
13954 /* No need to swap to big endian. */
13955 conntrack_context.peer_port = res->peer_port;
13956 conntrack_context.is_original_dir = res->is_original;
13957 conntrack_context.enable = res->en;
13958 conntrack_context.live_connection = res->is_live;
13959 conntrack_context.selective_ack = res->s_ack;
13960 conntrack_context.challenge_ack_passed = res->c_ack;
13961 conntrack_context.last_direction = res->ld;
13962 conntrack_context.liberal_mode = res->lb;
13963 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13964 conntrack_context.max_ack_window = res->factor;
13965 conntrack_context.retransmission_limit = res->re_num;
13966 conntrack_context.last_window = res->lw;
13967 conntrack_context.last_index =
13968 (enum rte_flow_conntrack_tcp_last_index)res->li;
13969 conntrack_context.last_seq = res->ls;
13970 conntrack_context.last_ack = res->la;
13971 conntrack_context.last_end = res->le;
13974 cmdline_parse_inst_t cmd_set_conntrack_common = {
13975 .f = cmd_set_conntrack_common_parsed,
13977 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13978 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13979 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13980 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13981 " last_index <flag>",
13983 (void *)&cmd_set_conntrack_set,
13984 (void *)&cmd_set_conntrack_conntrack,
13985 (void *)&cmd_set_conntrack_common_com,
13986 (void *)&cmd_set_conntrack_common_peer,
13987 (void *)&cmd_set_conntrack_common_peer_value,
13988 (void *)&cmd_set_conntrack_common_is_orig,
13989 (void *)&cmd_set_conntrack_common_is_orig_value,
13990 (void *)&cmd_set_conntrack_common_enable,
13991 (void *)&cmd_set_conntrack_common_enable_value,
13992 (void *)&cmd_set_conntrack_common_live,
13993 (void *)&cmd_set_conntrack_common_live_value,
13994 (void *)&cmd_set_conntrack_common_sack,
13995 (void *)&cmd_set_conntrack_common_sack_value,
13996 (void *)&cmd_set_conntrack_common_cack,
13997 (void *)&cmd_set_conntrack_common_cack_value,
13998 (void *)&cmd_set_conntrack_common_last_dir,
13999 (void *)&cmd_set_conntrack_common_last_dir_value,
14000 (void *)&cmd_set_conntrack_common_liberal,
14001 (void *)&cmd_set_conntrack_common_liberal_value,
14002 (void *)&cmd_set_conntrack_common_state,
14003 (void *)&cmd_set_conntrack_common_state_value,
14004 (void *)&cmd_set_conntrack_common_max_ackwin,
14005 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14006 (void *)&cmd_set_conntrack_common_retrans,
14007 (void *)&cmd_set_conntrack_common_retrans_value,
14008 (void *)&cmd_set_conntrack_common_last_win,
14009 (void *)&cmd_set_conntrack_common_last_win_value,
14010 (void *)&cmd_set_conntrack_common_last_seq,
14011 (void *)&cmd_set_conntrack_common_last_seq_value,
14012 (void *)&cmd_set_conntrack_common_last_ack,
14013 (void *)&cmd_set_conntrack_common_last_ack_value,
14014 (void *)&cmd_set_conntrack_common_last_end,
14015 (void *)&cmd_set_conntrack_common_last_end_value,
14016 (void *)&cmd_set_conntrack_common_last_index,
14017 (void *)&cmd_set_conntrack_common_last_index_value,
14022 /** Set connection tracking object both directions' details */
14023 struct cmd_set_conntrack_dir_result {
14024 cmdline_fixed_string_t set;
14025 cmdline_fixed_string_t conntrack;
14026 cmdline_fixed_string_t dir;
14027 cmdline_fixed_string_t scale;
14028 cmdline_fixed_string_t fin;
14029 cmdline_fixed_string_t ack_seen;
14030 cmdline_fixed_string_t unack;
14031 cmdline_fixed_string_t sent_end;
14032 cmdline_fixed_string_t reply_end;
14033 cmdline_fixed_string_t max_win;
14034 cmdline_fixed_string_t max_ack;
14045 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14046 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14048 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14049 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14050 conntrack, "conntrack");
14051 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14052 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14054 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14055 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14057 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14058 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14059 factor, RTE_UINT32);
14060 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14061 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14063 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14064 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14066 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14067 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14068 ack_seen, "acked");
14069 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14070 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14072 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14073 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14074 unack, "unack_data");
14075 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14076 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14078 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14079 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14080 sent_end, "sent_end");
14081 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14082 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14084 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14085 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14086 reply_end, "reply_end");
14087 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14088 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14090 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14091 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14092 max_win, "max_win");
14093 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14094 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14096 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14097 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14098 max_ack, "max_ack");
14099 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14100 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14103 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14104 __rte_unused struct cmdline *cl,
14105 __rte_unused void *data)
14107 struct cmd_set_conntrack_dir_result *res = parsed_result;
14108 struct rte_flow_tcp_dir_param *dir = NULL;
14110 if (strcmp(res->dir, "orig") == 0)
14111 dir = &conntrack_context.original_dir;
14112 else if (strcmp(res->dir, "rply") == 0)
14113 dir = &conntrack_context.reply_dir;
14116 dir->scale = res->factor;
14117 dir->close_initiated = res->f;
14118 dir->last_ack_seen = res->as;
14119 dir->data_unacked = res->un;
14120 dir->sent_end = res->se;
14121 dir->reply_end = res->re;
14122 dir->max_ack = res->ma;
14123 dir->max_win = res->mw;
14126 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14127 .f = cmd_set_conntrack_dir_parsed,
14129 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14130 " acked <seen> unack_data <unack> sent_end <sent>"
14131 " reply_end <reply> max_win <win> max_ack <ack>",
14133 (void *)&cmd_set_conntrack_set,
14134 (void *)&cmd_set_conntrack_conntrack,
14135 (void *)&cmd_set_conntrack_dir_dir,
14136 (void *)&cmd_set_conntrack_dir_scale,
14137 (void *)&cmd_set_conntrack_dir_scale_value,
14138 (void *)&cmd_set_conntrack_dir_fin,
14139 (void *)&cmd_set_conntrack_dir_fin_value,
14140 (void *)&cmd_set_conntrack_dir_ack,
14141 (void *)&cmd_set_conntrack_dir_ack_value,
14142 (void *)&cmd_set_conntrack_dir_unack_data,
14143 (void *)&cmd_set_conntrack_dir_unack_data_value,
14144 (void *)&cmd_set_conntrack_dir_sent_end,
14145 (void *)&cmd_set_conntrack_dir_sent_end_value,
14146 (void *)&cmd_set_conntrack_dir_reply_end,
14147 (void *)&cmd_set_conntrack_dir_reply_end_value,
14148 (void *)&cmd_set_conntrack_dir_max_win,
14149 (void *)&cmd_set_conntrack_dir_max_win_value,
14150 (void *)&cmd_set_conntrack_dir_max_ack,
14151 (void *)&cmd_set_conntrack_dir_max_ack_value,
14156 /* Strict link priority scheduling mode setting */
14158 cmd_strict_link_prio_parsed(
14159 void *parsed_result,
14160 __rte_unused struct cmdline *cl,
14161 __rte_unused void *data)
14163 struct cmd_vf_tc_bw_result *res = parsed_result;
14164 int ret = -ENOTSUP;
14166 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14169 #ifdef RTE_NET_I40E
14170 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14177 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14180 printf("invalid port_id %d\n", res->port_id);
14183 printf("function not implemented\n");
14186 printf("programming error: (%s)\n", strerror(-ret));
14190 cmdline_parse_inst_t cmd_strict_link_prio = {
14191 .f = cmd_strict_link_prio_parsed,
14193 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14195 (void *)&cmd_vf_tc_bw_set,
14196 (void *)&cmd_vf_tc_bw_tx,
14197 (void *)&cmd_vf_tc_bw_strict_link_prio,
14198 (void *)&cmd_vf_tc_bw_port_id,
14199 (void *)&cmd_vf_tc_bw_tc_map,
14204 /* Load dynamic device personalization*/
14205 struct cmd_ddp_add_result {
14206 cmdline_fixed_string_t ddp;
14207 cmdline_fixed_string_t add;
14212 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14213 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14214 cmdline_parse_token_string_t cmd_ddp_add_add =
14215 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14216 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14217 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14219 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14220 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14223 cmd_ddp_add_parsed(
14224 void *parsed_result,
14225 __rte_unused struct cmdline *cl,
14226 __rte_unused void *data)
14228 struct cmd_ddp_add_result *res = parsed_result;
14234 int ret = -ENOTSUP;
14236 if (!all_ports_stopped()) {
14237 printf("Please stop all ports first\n");
14241 filepath = strdup(res->filepath);
14242 if (filepath == NULL) {
14243 printf("Failed to allocate memory\n");
14246 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14248 buff = open_file(file_fld[0], &size);
14250 free((void *)filepath);
14254 #ifdef RTE_NET_I40E
14255 if (ret == -ENOTSUP)
14256 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14258 RTE_PMD_I40E_PKG_OP_WR_ADD);
14261 if (ret == -EEXIST)
14262 printf("Profile has already existed.\n");
14264 printf("Failed to load profile.\n");
14265 else if (file_num == 2)
14266 save_file(file_fld[1], buff, size);
14269 free((void *)filepath);
14272 cmdline_parse_inst_t cmd_ddp_add = {
14273 .f = cmd_ddp_add_parsed,
14275 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14277 (void *)&cmd_ddp_add_ddp,
14278 (void *)&cmd_ddp_add_add,
14279 (void *)&cmd_ddp_add_port_id,
14280 (void *)&cmd_ddp_add_filepath,
14285 /* Delete dynamic device personalization*/
14286 struct cmd_ddp_del_result {
14287 cmdline_fixed_string_t ddp;
14288 cmdline_fixed_string_t del;
14293 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14294 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14295 cmdline_parse_token_string_t cmd_ddp_del_del =
14296 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14297 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14298 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14299 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14300 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14303 cmd_ddp_del_parsed(
14304 void *parsed_result,
14305 __rte_unused struct cmdline *cl,
14306 __rte_unused void *data)
14308 struct cmd_ddp_del_result *res = parsed_result;
14311 int ret = -ENOTSUP;
14313 if (!all_ports_stopped()) {
14314 printf("Please stop all ports first\n");
14318 buff = open_file(res->filepath, &size);
14322 #ifdef RTE_NET_I40E
14323 if (ret == -ENOTSUP)
14324 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14326 RTE_PMD_I40E_PKG_OP_WR_DEL);
14329 if (ret == -EACCES)
14330 printf("Profile does not exist.\n");
14332 printf("Failed to delete profile.\n");
14337 cmdline_parse_inst_t cmd_ddp_del = {
14338 .f = cmd_ddp_del_parsed,
14340 .help_str = "ddp del <port_id> <backup_profile_path>",
14342 (void *)&cmd_ddp_del_ddp,
14343 (void *)&cmd_ddp_del_del,
14344 (void *)&cmd_ddp_del_port_id,
14345 (void *)&cmd_ddp_del_filepath,
14350 /* Get dynamic device personalization profile info */
14351 struct cmd_ddp_info_result {
14352 cmdline_fixed_string_t ddp;
14353 cmdline_fixed_string_t get;
14354 cmdline_fixed_string_t info;
14358 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14359 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14360 cmdline_parse_token_string_t cmd_ddp_info_get =
14361 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14362 cmdline_parse_token_string_t cmd_ddp_info_info =
14363 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14364 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14365 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14368 cmd_ddp_info_parsed(
14369 void *parsed_result,
14370 __rte_unused struct cmdline *cl,
14371 __rte_unused void *data)
14373 struct cmd_ddp_info_result *res = parsed_result;
14376 int ret = -ENOTSUP;
14377 #ifdef RTE_NET_I40E
14380 uint32_t buff_size = 0;
14381 struct rte_pmd_i40e_profile_info info;
14382 uint32_t dev_num = 0;
14383 struct rte_pmd_i40e_ddp_device_id *devs;
14384 uint32_t proto_num = 0;
14385 struct rte_pmd_i40e_proto_info *proto = NULL;
14386 uint32_t pctype_num = 0;
14387 struct rte_pmd_i40e_ptype_info *pctype;
14388 uint32_t ptype_num = 0;
14389 struct rte_pmd_i40e_ptype_info *ptype;
14394 pkg = open_file(res->filepath, &pkg_size);
14398 #ifdef RTE_NET_I40E
14399 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14400 (uint8_t *)&info, sizeof(info),
14401 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14403 printf("Global Track id: 0x%x\n", info.track_id);
14404 printf("Global Version: %d.%d.%d.%d\n",
14405 info.version.major,
14406 info.version.minor,
14407 info.version.update,
14408 info.version.draft);
14409 printf("Global Package name: %s\n\n", info.name);
14412 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14413 (uint8_t *)&info, sizeof(info),
14414 RTE_PMD_I40E_PKG_INFO_HEADER);
14416 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14417 printf("i40e Profile Version: %d.%d.%d.%d\n",
14418 info.version.major,
14419 info.version.minor,
14420 info.version.update,
14421 info.version.draft);
14422 printf("i40e Profile name: %s\n\n", info.name);
14425 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14426 (uint8_t *)&buff_size, sizeof(buff_size),
14427 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14428 if (!ret && buff_size) {
14429 buff = (uint8_t *)malloc(buff_size);
14431 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14433 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14435 printf("Package Notes:\n%s\n\n", buff);
14440 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14441 (uint8_t *)&dev_num, sizeof(dev_num),
14442 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14443 if (!ret && dev_num) {
14444 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14445 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14447 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14448 (uint8_t *)devs, buff_size,
14449 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14451 printf("List of supported devices:\n");
14452 for (i = 0; i < dev_num; i++) {
14453 printf(" %04X:%04X %04X:%04X\n",
14454 devs[i].vendor_dev_id >> 16,
14455 devs[i].vendor_dev_id & 0xFFFF,
14456 devs[i].sub_vendor_dev_id >> 16,
14457 devs[i].sub_vendor_dev_id & 0xFFFF);
14465 /* get information about protocols and packet types */
14466 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14467 (uint8_t *)&proto_num, sizeof(proto_num),
14468 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14469 if (ret || !proto_num)
14470 goto no_print_return;
14472 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14473 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14475 goto no_print_return;
14477 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14479 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14481 printf("List of used protocols:\n");
14482 for (i = 0; i < proto_num; i++)
14483 printf(" %2u: %s\n", proto[i].proto_id,
14487 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14488 (uint8_t *)&pctype_num, sizeof(pctype_num),
14489 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14490 if (ret || !pctype_num)
14491 goto no_print_pctypes;
14493 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14494 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14496 goto no_print_pctypes;
14498 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14500 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14503 goto no_print_pctypes;
14506 printf("List of defined packet classification types:\n");
14507 for (i = 0; i < pctype_num; i++) {
14508 printf(" %2u:", pctype[i].ptype_id);
14509 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14510 proto_id = pctype[i].protocols[j];
14511 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14512 for (n = 0; n < proto_num; n++) {
14513 if (proto[n].proto_id == proto_id) {
14514 printf(" %s", proto[n].name);
14527 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14529 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14530 if (ret || !ptype_num)
14531 goto no_print_return;
14533 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14534 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14536 goto no_print_return;
14538 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14540 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14543 goto no_print_return;
14545 printf("List of defined packet types:\n");
14546 for (i = 0; i < ptype_num; i++) {
14547 printf(" %2u:", ptype[i].ptype_id);
14548 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14549 proto_id = ptype[i].protocols[j];
14550 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14551 for (n = 0; n < proto_num; n++) {
14552 if (proto[n].proto_id == proto_id) {
14553 printf(" %s", proto[n].name);
14569 if (ret == -ENOTSUP)
14570 printf("Function not supported in PMD driver\n");
14574 cmdline_parse_inst_t cmd_ddp_get_info = {
14575 .f = cmd_ddp_info_parsed,
14577 .help_str = "ddp get info <profile_path>",
14579 (void *)&cmd_ddp_info_ddp,
14580 (void *)&cmd_ddp_info_get,
14581 (void *)&cmd_ddp_info_info,
14582 (void *)&cmd_ddp_info_filepath,
14587 /* Get dynamic device personalization profile info list*/
14588 #define PROFILE_INFO_SIZE 48
14589 #define MAX_PROFILE_NUM 16
14591 struct cmd_ddp_get_list_result {
14592 cmdline_fixed_string_t ddp;
14593 cmdline_fixed_string_t get;
14594 cmdline_fixed_string_t list;
14598 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14599 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14600 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14601 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14602 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14603 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14604 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14605 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14609 cmd_ddp_get_list_parsed(
14610 __rte_unused void *parsed_result,
14611 __rte_unused struct cmdline *cl,
14612 __rte_unused void *data)
14614 #ifdef RTE_NET_I40E
14615 struct cmd_ddp_get_list_result *res = parsed_result;
14616 struct rte_pmd_i40e_profile_list *p_list;
14617 struct rte_pmd_i40e_profile_info *p_info;
14622 int ret = -ENOTSUP;
14624 #ifdef RTE_NET_I40E
14625 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14626 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14628 printf("%s: Failed to malloc buffer\n", __func__);
14632 if (ret == -ENOTSUP)
14633 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14634 (uint8_t *)p_list, size);
14637 p_num = p_list->p_count;
14638 printf("Profile number is: %d\n\n", p_num);
14640 for (i = 0; i < p_num; i++) {
14641 p_info = &p_list->p_info[i];
14642 printf("Profile %d:\n", i);
14643 printf("Track id: 0x%x\n", p_info->track_id);
14644 printf("Version: %d.%d.%d.%d\n",
14645 p_info->version.major,
14646 p_info->version.minor,
14647 p_info->version.update,
14648 p_info->version.draft);
14649 printf("Profile name: %s\n\n", p_info->name);
14657 printf("Failed to get ddp list\n");
14660 cmdline_parse_inst_t cmd_ddp_get_list = {
14661 .f = cmd_ddp_get_list_parsed,
14663 .help_str = "ddp get list <port_id>",
14665 (void *)&cmd_ddp_get_list_ddp,
14666 (void *)&cmd_ddp_get_list_get,
14667 (void *)&cmd_ddp_get_list_list,
14668 (void *)&cmd_ddp_get_list_port_id,
14673 /* Configure input set */
14674 struct cmd_cfg_input_set_result {
14675 cmdline_fixed_string_t port;
14676 cmdline_fixed_string_t cfg;
14678 cmdline_fixed_string_t pctype;
14680 cmdline_fixed_string_t inset_type;
14681 cmdline_fixed_string_t opt;
14682 cmdline_fixed_string_t field;
14687 cmd_cfg_input_set_parsed(
14688 __rte_unused void *parsed_result,
14689 __rte_unused struct cmdline *cl,
14690 __rte_unused void *data)
14692 #ifdef RTE_NET_I40E
14693 struct cmd_cfg_input_set_result *res = parsed_result;
14694 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14695 struct rte_pmd_i40e_inset inset;
14697 int ret = -ENOTSUP;
14699 if (!all_ports_stopped()) {
14700 printf("Please stop all ports first\n");
14704 #ifdef RTE_NET_I40E
14705 if (!strcmp(res->inset_type, "hash_inset"))
14706 inset_type = INSET_HASH;
14707 else if (!strcmp(res->inset_type, "fdir_inset"))
14708 inset_type = INSET_FDIR;
14709 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14710 inset_type = INSET_FDIR_FLX;
14711 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14712 &inset, inset_type);
14714 printf("Failed to get input set.\n");
14718 if (!strcmp(res->opt, "get")) {
14719 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14722 printf("Field index %d is enabled.\n", res->field_idx);
14724 printf("Field index %d is disabled.\n", res->field_idx);
14726 } else if (!strcmp(res->opt, "set"))
14727 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14729 else if (!strcmp(res->opt, "clear"))
14730 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14733 printf("Failed to configure input set field.\n");
14737 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14738 &inset, inset_type);
14740 printf("Failed to set input set.\n");
14745 if (ret == -ENOTSUP)
14746 printf("Function not supported\n");
14749 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14750 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14752 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14753 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14755 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14756 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14757 port_id, RTE_UINT16);
14758 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14759 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14761 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14762 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14763 pctype_id, RTE_UINT8);
14764 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14765 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14767 "hash_inset#fdir_inset#fdir_flx_inset");
14768 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14769 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14770 opt, "get#set#clear");
14771 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14772 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14774 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14775 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14776 field_idx, RTE_UINT8);
14778 cmdline_parse_inst_t cmd_cfg_input_set = {
14779 .f = cmd_cfg_input_set_parsed,
14781 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14782 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14784 (void *)&cmd_cfg_input_set_port,
14785 (void *)&cmd_cfg_input_set_cfg,
14786 (void *)&cmd_cfg_input_set_port_id,
14787 (void *)&cmd_cfg_input_set_pctype,
14788 (void *)&cmd_cfg_input_set_pctype_id,
14789 (void *)&cmd_cfg_input_set_inset_type,
14790 (void *)&cmd_cfg_input_set_opt,
14791 (void *)&cmd_cfg_input_set_field,
14792 (void *)&cmd_cfg_input_set_field_idx,
14797 /* Clear input set */
14798 struct cmd_clear_input_set_result {
14799 cmdline_fixed_string_t port;
14800 cmdline_fixed_string_t cfg;
14802 cmdline_fixed_string_t pctype;
14804 cmdline_fixed_string_t inset_type;
14805 cmdline_fixed_string_t clear;
14806 cmdline_fixed_string_t all;
14810 cmd_clear_input_set_parsed(
14811 __rte_unused void *parsed_result,
14812 __rte_unused struct cmdline *cl,
14813 __rte_unused void *data)
14815 #ifdef RTE_NET_I40E
14816 struct cmd_clear_input_set_result *res = parsed_result;
14817 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14818 struct rte_pmd_i40e_inset inset;
14820 int ret = -ENOTSUP;
14822 if (!all_ports_stopped()) {
14823 printf("Please stop all ports first\n");
14827 #ifdef RTE_NET_I40E
14828 if (!strcmp(res->inset_type, "hash_inset"))
14829 inset_type = INSET_HASH;
14830 else if (!strcmp(res->inset_type, "fdir_inset"))
14831 inset_type = INSET_FDIR;
14832 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14833 inset_type = INSET_FDIR_FLX;
14835 memset(&inset, 0, sizeof(inset));
14837 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14838 &inset, inset_type);
14840 printf("Failed to clear input set.\n");
14846 if (ret == -ENOTSUP)
14847 printf("Function not supported\n");
14850 cmdline_parse_token_string_t cmd_clear_input_set_port =
14851 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14853 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14854 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14856 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14857 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14858 port_id, RTE_UINT16);
14859 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14860 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14862 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14863 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14864 pctype_id, RTE_UINT8);
14865 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14866 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14868 "hash_inset#fdir_inset#fdir_flx_inset");
14869 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14870 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14872 cmdline_parse_token_string_t cmd_clear_input_set_all =
14873 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14876 cmdline_parse_inst_t cmd_clear_input_set = {
14877 .f = cmd_clear_input_set_parsed,
14879 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14880 "fdir_inset|fdir_flx_inset clear all",
14882 (void *)&cmd_clear_input_set_port,
14883 (void *)&cmd_clear_input_set_cfg,
14884 (void *)&cmd_clear_input_set_port_id,
14885 (void *)&cmd_clear_input_set_pctype,
14886 (void *)&cmd_clear_input_set_pctype_id,
14887 (void *)&cmd_clear_input_set_inset_type,
14888 (void *)&cmd_clear_input_set_clear,
14889 (void *)&cmd_clear_input_set_all,
14894 /* show vf stats */
14896 /* Common result structure for show vf stats */
14897 struct cmd_show_vf_stats_result {
14898 cmdline_fixed_string_t show;
14899 cmdline_fixed_string_t vf;
14900 cmdline_fixed_string_t stats;
14905 /* Common CLI fields show vf stats*/
14906 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14907 TOKEN_STRING_INITIALIZER
14908 (struct cmd_show_vf_stats_result,
14910 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14911 TOKEN_STRING_INITIALIZER
14912 (struct cmd_show_vf_stats_result,
14914 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14915 TOKEN_STRING_INITIALIZER
14916 (struct cmd_show_vf_stats_result,
14918 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14919 TOKEN_NUM_INITIALIZER
14920 (struct cmd_show_vf_stats_result,
14921 port_id, RTE_UINT16);
14922 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14923 TOKEN_NUM_INITIALIZER
14924 (struct cmd_show_vf_stats_result,
14925 vf_id, RTE_UINT16);
14928 cmd_show_vf_stats_parsed(
14929 void *parsed_result,
14930 __rte_unused struct cmdline *cl,
14931 __rte_unused void *data)
14933 struct cmd_show_vf_stats_result *res = parsed_result;
14934 struct rte_eth_stats stats;
14935 int ret = -ENOTSUP;
14936 static const char *nic_stats_border = "########################";
14938 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14941 memset(&stats, 0, sizeof(stats));
14943 #ifdef RTE_NET_I40E
14944 if (ret == -ENOTSUP)
14945 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14949 #ifdef RTE_NET_BNXT
14950 if (ret == -ENOTSUP)
14951 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14960 printf("invalid vf_id %d\n", res->vf_id);
14963 printf("invalid port_id %d\n", res->port_id);
14966 printf("function not implemented\n");
14969 printf("programming error: (%s)\n", strerror(-ret));
14972 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14973 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14975 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14977 stats.ipackets, stats.imissed, stats.ibytes);
14978 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14979 printf(" RX-nombuf: %-10"PRIu64"\n",
14981 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14983 stats.opackets, stats.oerrors, stats.obytes);
14985 printf(" %s############################%s\n",
14986 nic_stats_border, nic_stats_border);
14989 cmdline_parse_inst_t cmd_show_vf_stats = {
14990 .f = cmd_show_vf_stats_parsed,
14992 .help_str = "show vf stats <port_id> <vf_id>",
14994 (void *)&cmd_show_vf_stats_show,
14995 (void *)&cmd_show_vf_stats_vf,
14996 (void *)&cmd_show_vf_stats_stats,
14997 (void *)&cmd_show_vf_stats_port_id,
14998 (void *)&cmd_show_vf_stats_vf_id,
15003 /* clear vf stats */
15005 /* Common result structure for clear vf stats */
15006 struct cmd_clear_vf_stats_result {
15007 cmdline_fixed_string_t clear;
15008 cmdline_fixed_string_t vf;
15009 cmdline_fixed_string_t stats;
15014 /* Common CLI fields clear vf stats*/
15015 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15016 TOKEN_STRING_INITIALIZER
15017 (struct cmd_clear_vf_stats_result,
15019 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15020 TOKEN_STRING_INITIALIZER
15021 (struct cmd_clear_vf_stats_result,
15023 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15024 TOKEN_STRING_INITIALIZER
15025 (struct cmd_clear_vf_stats_result,
15027 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15028 TOKEN_NUM_INITIALIZER
15029 (struct cmd_clear_vf_stats_result,
15030 port_id, RTE_UINT16);
15031 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15032 TOKEN_NUM_INITIALIZER
15033 (struct cmd_clear_vf_stats_result,
15034 vf_id, RTE_UINT16);
15037 cmd_clear_vf_stats_parsed(
15038 void *parsed_result,
15039 __rte_unused struct cmdline *cl,
15040 __rte_unused void *data)
15042 struct cmd_clear_vf_stats_result *res = parsed_result;
15043 int ret = -ENOTSUP;
15045 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15048 #ifdef RTE_NET_I40E
15049 if (ret == -ENOTSUP)
15050 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15053 #ifdef RTE_NET_BNXT
15054 if (ret == -ENOTSUP)
15055 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15063 printf("invalid vf_id %d\n", res->vf_id);
15066 printf("invalid port_id %d\n", res->port_id);
15069 printf("function not implemented\n");
15072 printf("programming error: (%s)\n", strerror(-ret));
15076 cmdline_parse_inst_t cmd_clear_vf_stats = {
15077 .f = cmd_clear_vf_stats_parsed,
15079 .help_str = "clear vf stats <port_id> <vf_id>",
15081 (void *)&cmd_clear_vf_stats_clear,
15082 (void *)&cmd_clear_vf_stats_vf,
15083 (void *)&cmd_clear_vf_stats_stats,
15084 (void *)&cmd_clear_vf_stats_port_id,
15085 (void *)&cmd_clear_vf_stats_vf_id,
15090 /* port config pctype mapping reset */
15092 /* Common result structure for port config pctype mapping reset */
15093 struct cmd_pctype_mapping_reset_result {
15094 cmdline_fixed_string_t port;
15095 cmdline_fixed_string_t config;
15097 cmdline_fixed_string_t pctype;
15098 cmdline_fixed_string_t mapping;
15099 cmdline_fixed_string_t reset;
15102 /* Common CLI fields for port config pctype mapping reset*/
15103 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15104 TOKEN_STRING_INITIALIZER
15105 (struct cmd_pctype_mapping_reset_result,
15107 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15108 TOKEN_STRING_INITIALIZER
15109 (struct cmd_pctype_mapping_reset_result,
15111 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15112 TOKEN_NUM_INITIALIZER
15113 (struct cmd_pctype_mapping_reset_result,
15114 port_id, RTE_UINT16);
15115 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15116 TOKEN_STRING_INITIALIZER
15117 (struct cmd_pctype_mapping_reset_result,
15119 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15120 TOKEN_STRING_INITIALIZER
15121 (struct cmd_pctype_mapping_reset_result,
15122 mapping, "mapping");
15123 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15124 TOKEN_STRING_INITIALIZER
15125 (struct cmd_pctype_mapping_reset_result,
15129 cmd_pctype_mapping_reset_parsed(
15130 void *parsed_result,
15131 __rte_unused struct cmdline *cl,
15132 __rte_unused void *data)
15134 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15135 int ret = -ENOTSUP;
15137 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15140 #ifdef RTE_NET_I40E
15141 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15148 printf("invalid port_id %d\n", res->port_id);
15151 printf("function not implemented\n");
15154 printf("programming error: (%s)\n", strerror(-ret));
15158 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15159 .f = cmd_pctype_mapping_reset_parsed,
15161 .help_str = "port config <port_id> pctype mapping reset",
15163 (void *)&cmd_pctype_mapping_reset_port,
15164 (void *)&cmd_pctype_mapping_reset_config,
15165 (void *)&cmd_pctype_mapping_reset_port_id,
15166 (void *)&cmd_pctype_mapping_reset_pctype,
15167 (void *)&cmd_pctype_mapping_reset_mapping,
15168 (void *)&cmd_pctype_mapping_reset_reset,
15173 /* show port pctype mapping */
15175 /* Common result structure for show port pctype mapping */
15176 struct cmd_pctype_mapping_get_result {
15177 cmdline_fixed_string_t show;
15178 cmdline_fixed_string_t port;
15180 cmdline_fixed_string_t pctype;
15181 cmdline_fixed_string_t mapping;
15184 /* Common CLI fields for pctype mapping get */
15185 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15186 TOKEN_STRING_INITIALIZER
15187 (struct cmd_pctype_mapping_get_result,
15189 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15190 TOKEN_STRING_INITIALIZER
15191 (struct cmd_pctype_mapping_get_result,
15193 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15194 TOKEN_NUM_INITIALIZER
15195 (struct cmd_pctype_mapping_get_result,
15196 port_id, RTE_UINT16);
15197 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15198 TOKEN_STRING_INITIALIZER
15199 (struct cmd_pctype_mapping_get_result,
15201 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15202 TOKEN_STRING_INITIALIZER
15203 (struct cmd_pctype_mapping_get_result,
15204 mapping, "mapping");
15207 cmd_pctype_mapping_get_parsed(
15208 void *parsed_result,
15209 __rte_unused struct cmdline *cl,
15210 __rte_unused void *data)
15212 struct cmd_pctype_mapping_get_result *res = parsed_result;
15213 int ret = -ENOTSUP;
15214 #ifdef RTE_NET_I40E
15215 struct rte_pmd_i40e_flow_type_mapping
15216 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15217 int i, j, first_pctype;
15220 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15223 #ifdef RTE_NET_I40E
15224 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15231 printf("invalid port_id %d\n", res->port_id);
15234 printf("function not implemented\n");
15237 printf("programming error: (%s)\n", strerror(-ret));
15241 #ifdef RTE_NET_I40E
15242 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15243 if (mapping[i].pctype != 0ULL) {
15246 printf("pctype: ");
15247 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15248 if (mapping[i].pctype & (1ULL << j)) {
15249 printf(first_pctype ?
15250 "%02d" : ",%02d", j);
15254 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15260 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15261 .f = cmd_pctype_mapping_get_parsed,
15263 .help_str = "show port <port_id> pctype mapping",
15265 (void *)&cmd_pctype_mapping_get_show,
15266 (void *)&cmd_pctype_mapping_get_port,
15267 (void *)&cmd_pctype_mapping_get_port_id,
15268 (void *)&cmd_pctype_mapping_get_pctype,
15269 (void *)&cmd_pctype_mapping_get_mapping,
15274 /* port config pctype mapping update */
15276 /* Common result structure for port config pctype mapping update */
15277 struct cmd_pctype_mapping_update_result {
15278 cmdline_fixed_string_t port;
15279 cmdline_fixed_string_t config;
15281 cmdline_fixed_string_t pctype;
15282 cmdline_fixed_string_t mapping;
15283 cmdline_fixed_string_t update;
15284 cmdline_fixed_string_t pctype_list;
15285 uint16_t flow_type;
15288 /* Common CLI fields for pctype mapping update*/
15289 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15290 TOKEN_STRING_INITIALIZER
15291 (struct cmd_pctype_mapping_update_result,
15293 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15294 TOKEN_STRING_INITIALIZER
15295 (struct cmd_pctype_mapping_update_result,
15297 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15298 TOKEN_NUM_INITIALIZER
15299 (struct cmd_pctype_mapping_update_result,
15300 port_id, RTE_UINT16);
15301 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15302 TOKEN_STRING_INITIALIZER
15303 (struct cmd_pctype_mapping_update_result,
15305 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15306 TOKEN_STRING_INITIALIZER
15307 (struct cmd_pctype_mapping_update_result,
15308 mapping, "mapping");
15309 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15310 TOKEN_STRING_INITIALIZER
15311 (struct cmd_pctype_mapping_update_result,
15313 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15314 TOKEN_STRING_INITIALIZER
15315 (struct cmd_pctype_mapping_update_result,
15316 pctype_list, NULL);
15317 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15318 TOKEN_NUM_INITIALIZER
15319 (struct cmd_pctype_mapping_update_result,
15320 flow_type, RTE_UINT16);
15323 cmd_pctype_mapping_update_parsed(
15324 void *parsed_result,
15325 __rte_unused struct cmdline *cl,
15326 __rte_unused void *data)
15328 struct cmd_pctype_mapping_update_result *res = parsed_result;
15329 int ret = -ENOTSUP;
15330 #ifdef RTE_NET_I40E
15331 struct rte_pmd_i40e_flow_type_mapping mapping;
15333 unsigned int nb_item;
15334 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15337 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15340 #ifdef RTE_NET_I40E
15341 nb_item = parse_item_list(res->pctype_list, "pctypes",
15342 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15343 mapping.flow_type = res->flow_type;
15344 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15345 mapping.pctype |= (1ULL << pctype_list[i]);
15346 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15356 printf("invalid pctype or flow type\n");
15359 printf("invalid port_id %d\n", res->port_id);
15362 printf("function not implemented\n");
15365 printf("programming error: (%s)\n", strerror(-ret));
15369 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15370 .f = cmd_pctype_mapping_update_parsed,
15372 .help_str = "port config <port_id> pctype mapping update"
15373 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15375 (void *)&cmd_pctype_mapping_update_port,
15376 (void *)&cmd_pctype_mapping_update_config,
15377 (void *)&cmd_pctype_mapping_update_port_id,
15378 (void *)&cmd_pctype_mapping_update_pctype,
15379 (void *)&cmd_pctype_mapping_update_mapping,
15380 (void *)&cmd_pctype_mapping_update_update,
15381 (void *)&cmd_pctype_mapping_update_pc_type,
15382 (void *)&cmd_pctype_mapping_update_flow_type,
15387 /* ptype mapping get */
15389 /* Common result structure for ptype mapping get */
15390 struct cmd_ptype_mapping_get_result {
15391 cmdline_fixed_string_t ptype;
15392 cmdline_fixed_string_t mapping;
15393 cmdline_fixed_string_t get;
15395 uint8_t valid_only;
15398 /* Common CLI fields for ptype mapping get */
15399 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15400 TOKEN_STRING_INITIALIZER
15401 (struct cmd_ptype_mapping_get_result,
15403 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15404 TOKEN_STRING_INITIALIZER
15405 (struct cmd_ptype_mapping_get_result,
15406 mapping, "mapping");
15407 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15408 TOKEN_STRING_INITIALIZER
15409 (struct cmd_ptype_mapping_get_result,
15411 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15412 TOKEN_NUM_INITIALIZER
15413 (struct cmd_ptype_mapping_get_result,
15414 port_id, RTE_UINT16);
15415 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15416 TOKEN_NUM_INITIALIZER
15417 (struct cmd_ptype_mapping_get_result,
15418 valid_only, RTE_UINT8);
15421 cmd_ptype_mapping_get_parsed(
15422 void *parsed_result,
15423 __rte_unused struct cmdline *cl,
15424 __rte_unused void *data)
15426 struct cmd_ptype_mapping_get_result *res = parsed_result;
15427 int ret = -ENOTSUP;
15428 #ifdef RTE_NET_I40E
15429 int max_ptype_num = 256;
15430 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15435 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15438 #ifdef RTE_NET_I40E
15439 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15450 printf("invalid port_id %d\n", res->port_id);
15453 printf("function not implemented\n");
15456 printf("programming error: (%s)\n", strerror(-ret));
15459 #ifdef RTE_NET_I40E
15461 for (i = 0; i < count; i++)
15462 printf("%3d\t0x%08x\n",
15463 mapping[i].hw_ptype, mapping[i].sw_ptype);
15468 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15469 .f = cmd_ptype_mapping_get_parsed,
15471 .help_str = "ptype mapping get <port_id> <valid_only>",
15473 (void *)&cmd_ptype_mapping_get_ptype,
15474 (void *)&cmd_ptype_mapping_get_mapping,
15475 (void *)&cmd_ptype_mapping_get_get,
15476 (void *)&cmd_ptype_mapping_get_port_id,
15477 (void *)&cmd_ptype_mapping_get_valid_only,
15482 /* ptype mapping replace */
15484 /* Common result structure for ptype mapping replace */
15485 struct cmd_ptype_mapping_replace_result {
15486 cmdline_fixed_string_t ptype;
15487 cmdline_fixed_string_t mapping;
15488 cmdline_fixed_string_t replace;
15495 /* Common CLI fields for ptype mapping replace */
15496 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15497 TOKEN_STRING_INITIALIZER
15498 (struct cmd_ptype_mapping_replace_result,
15500 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15501 TOKEN_STRING_INITIALIZER
15502 (struct cmd_ptype_mapping_replace_result,
15503 mapping, "mapping");
15504 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15505 TOKEN_STRING_INITIALIZER
15506 (struct cmd_ptype_mapping_replace_result,
15507 replace, "replace");
15508 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15509 TOKEN_NUM_INITIALIZER
15510 (struct cmd_ptype_mapping_replace_result,
15511 port_id, RTE_UINT16);
15512 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15513 TOKEN_NUM_INITIALIZER
15514 (struct cmd_ptype_mapping_replace_result,
15515 target, RTE_UINT32);
15516 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15517 TOKEN_NUM_INITIALIZER
15518 (struct cmd_ptype_mapping_replace_result,
15520 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15521 TOKEN_NUM_INITIALIZER
15522 (struct cmd_ptype_mapping_replace_result,
15523 pkt_type, RTE_UINT32);
15526 cmd_ptype_mapping_replace_parsed(
15527 void *parsed_result,
15528 __rte_unused struct cmdline *cl,
15529 __rte_unused void *data)
15531 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15532 int ret = -ENOTSUP;
15534 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15537 #ifdef RTE_NET_I40E
15538 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15548 printf("invalid ptype 0x%8x or 0x%8x\n",
15549 res->target, res->pkt_type);
15552 printf("invalid port_id %d\n", res->port_id);
15555 printf("function not implemented\n");
15558 printf("programming error: (%s)\n", strerror(-ret));
15562 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15563 .f = cmd_ptype_mapping_replace_parsed,
15566 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15568 (void *)&cmd_ptype_mapping_replace_ptype,
15569 (void *)&cmd_ptype_mapping_replace_mapping,
15570 (void *)&cmd_ptype_mapping_replace_replace,
15571 (void *)&cmd_ptype_mapping_replace_port_id,
15572 (void *)&cmd_ptype_mapping_replace_target,
15573 (void *)&cmd_ptype_mapping_replace_mask,
15574 (void *)&cmd_ptype_mapping_replace_pkt_type,
15579 /* ptype mapping reset */
15581 /* Common result structure for ptype mapping reset */
15582 struct cmd_ptype_mapping_reset_result {
15583 cmdline_fixed_string_t ptype;
15584 cmdline_fixed_string_t mapping;
15585 cmdline_fixed_string_t reset;
15589 /* Common CLI fields for ptype mapping reset*/
15590 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15591 TOKEN_STRING_INITIALIZER
15592 (struct cmd_ptype_mapping_reset_result,
15594 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15595 TOKEN_STRING_INITIALIZER
15596 (struct cmd_ptype_mapping_reset_result,
15597 mapping, "mapping");
15598 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15599 TOKEN_STRING_INITIALIZER
15600 (struct cmd_ptype_mapping_reset_result,
15602 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15603 TOKEN_NUM_INITIALIZER
15604 (struct cmd_ptype_mapping_reset_result,
15605 port_id, RTE_UINT16);
15608 cmd_ptype_mapping_reset_parsed(
15609 void *parsed_result,
15610 __rte_unused struct cmdline *cl,
15611 __rte_unused void *data)
15613 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15614 int ret = -ENOTSUP;
15616 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15619 #ifdef RTE_NET_I40E
15620 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15627 printf("invalid port_id %d\n", res->port_id);
15630 printf("function not implemented\n");
15633 printf("programming error: (%s)\n", strerror(-ret));
15637 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15638 .f = cmd_ptype_mapping_reset_parsed,
15640 .help_str = "ptype mapping reset <port_id>",
15642 (void *)&cmd_ptype_mapping_reset_ptype,
15643 (void *)&cmd_ptype_mapping_reset_mapping,
15644 (void *)&cmd_ptype_mapping_reset_reset,
15645 (void *)&cmd_ptype_mapping_reset_port_id,
15650 /* ptype mapping update */
15652 /* Common result structure for ptype mapping update */
15653 struct cmd_ptype_mapping_update_result {
15654 cmdline_fixed_string_t ptype;
15655 cmdline_fixed_string_t mapping;
15656 cmdline_fixed_string_t reset;
15662 /* Common CLI fields for ptype mapping update*/
15663 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15664 TOKEN_STRING_INITIALIZER
15665 (struct cmd_ptype_mapping_update_result,
15667 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15668 TOKEN_STRING_INITIALIZER
15669 (struct cmd_ptype_mapping_update_result,
15670 mapping, "mapping");
15671 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15672 TOKEN_STRING_INITIALIZER
15673 (struct cmd_ptype_mapping_update_result,
15675 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15676 TOKEN_NUM_INITIALIZER
15677 (struct cmd_ptype_mapping_update_result,
15678 port_id, RTE_UINT16);
15679 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15680 TOKEN_NUM_INITIALIZER
15681 (struct cmd_ptype_mapping_update_result,
15682 hw_ptype, RTE_UINT8);
15683 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15684 TOKEN_NUM_INITIALIZER
15685 (struct cmd_ptype_mapping_update_result,
15686 sw_ptype, RTE_UINT32);
15689 cmd_ptype_mapping_update_parsed(
15690 void *parsed_result,
15691 __rte_unused struct cmdline *cl,
15692 __rte_unused void *data)
15694 struct cmd_ptype_mapping_update_result *res = parsed_result;
15695 int ret = -ENOTSUP;
15696 #ifdef RTE_NET_I40E
15697 struct rte_pmd_i40e_ptype_mapping mapping;
15699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15702 #ifdef RTE_NET_I40E
15703 mapping.hw_ptype = res->hw_ptype;
15704 mapping.sw_ptype = res->sw_ptype;
15705 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15715 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15718 printf("invalid port_id %d\n", res->port_id);
15721 printf("function not implemented\n");
15724 printf("programming error: (%s)\n", strerror(-ret));
15728 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15729 .f = cmd_ptype_mapping_update_parsed,
15731 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15733 (void *)&cmd_ptype_mapping_update_ptype,
15734 (void *)&cmd_ptype_mapping_update_mapping,
15735 (void *)&cmd_ptype_mapping_update_update,
15736 (void *)&cmd_ptype_mapping_update_port_id,
15737 (void *)&cmd_ptype_mapping_update_hw_ptype,
15738 (void *)&cmd_ptype_mapping_update_sw_ptype,
15743 /* Common result structure for file commands */
15744 struct cmd_cmdfile_result {
15745 cmdline_fixed_string_t load;
15746 cmdline_fixed_string_t filename;
15749 /* Common CLI fields for file commands */
15750 cmdline_parse_token_string_t cmd_load_cmdfile =
15751 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15752 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15753 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15756 cmd_load_from_file_parsed(
15757 void *parsed_result,
15758 __rte_unused struct cmdline *cl,
15759 __rte_unused void *data)
15761 struct cmd_cmdfile_result *res = parsed_result;
15763 cmdline_read_from_file(res->filename);
15766 cmdline_parse_inst_t cmd_load_from_file = {
15767 .f = cmd_load_from_file_parsed,
15769 .help_str = "load <filename>",
15771 (void *)&cmd_load_cmdfile,
15772 (void *)&cmd_load_cmdfile_filename,
15777 /* Get Rx offloads capabilities */
15778 struct cmd_rx_offload_get_capa_result {
15779 cmdline_fixed_string_t show;
15780 cmdline_fixed_string_t port;
15782 cmdline_fixed_string_t rx_offload;
15783 cmdline_fixed_string_t capabilities;
15786 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15787 TOKEN_STRING_INITIALIZER
15788 (struct cmd_rx_offload_get_capa_result,
15790 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15791 TOKEN_STRING_INITIALIZER
15792 (struct cmd_rx_offload_get_capa_result,
15794 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15795 TOKEN_NUM_INITIALIZER
15796 (struct cmd_rx_offload_get_capa_result,
15797 port_id, RTE_UINT16);
15798 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15799 TOKEN_STRING_INITIALIZER
15800 (struct cmd_rx_offload_get_capa_result,
15801 rx_offload, "rx_offload");
15802 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15803 TOKEN_STRING_INITIALIZER
15804 (struct cmd_rx_offload_get_capa_result,
15805 capabilities, "capabilities");
15808 print_rx_offloads(uint64_t offloads)
15810 uint64_t single_offload;
15818 begin = __builtin_ctzll(offloads);
15819 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15821 single_offload = 1ULL << begin;
15822 for (bit = begin; bit < end; bit++) {
15823 if (offloads & single_offload)
15825 rte_eth_dev_rx_offload_name(single_offload));
15826 single_offload <<= 1;
15831 cmd_rx_offload_get_capa_parsed(
15832 void *parsed_result,
15833 __rte_unused struct cmdline *cl,
15834 __rte_unused void *data)
15836 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15837 struct rte_eth_dev_info dev_info;
15838 portid_t port_id = res->port_id;
15839 uint64_t queue_offloads;
15840 uint64_t port_offloads;
15843 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15847 queue_offloads = dev_info.rx_queue_offload_capa;
15848 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15850 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15851 printf(" Per Queue :");
15852 print_rx_offloads(queue_offloads);
15855 printf(" Per Port :");
15856 print_rx_offloads(port_offloads);
15860 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15861 .f = cmd_rx_offload_get_capa_parsed,
15863 .help_str = "show port <port_id> rx_offload capabilities",
15865 (void *)&cmd_rx_offload_get_capa_show,
15866 (void *)&cmd_rx_offload_get_capa_port,
15867 (void *)&cmd_rx_offload_get_capa_port_id,
15868 (void *)&cmd_rx_offload_get_capa_rx_offload,
15869 (void *)&cmd_rx_offload_get_capa_capabilities,
15874 /* Get Rx offloads configuration */
15875 struct cmd_rx_offload_get_configuration_result {
15876 cmdline_fixed_string_t show;
15877 cmdline_fixed_string_t port;
15879 cmdline_fixed_string_t rx_offload;
15880 cmdline_fixed_string_t configuration;
15883 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15884 TOKEN_STRING_INITIALIZER
15885 (struct cmd_rx_offload_get_configuration_result,
15887 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15888 TOKEN_STRING_INITIALIZER
15889 (struct cmd_rx_offload_get_configuration_result,
15891 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15892 TOKEN_NUM_INITIALIZER
15893 (struct cmd_rx_offload_get_configuration_result,
15894 port_id, RTE_UINT16);
15895 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15896 TOKEN_STRING_INITIALIZER
15897 (struct cmd_rx_offload_get_configuration_result,
15898 rx_offload, "rx_offload");
15899 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15900 TOKEN_STRING_INITIALIZER
15901 (struct cmd_rx_offload_get_configuration_result,
15902 configuration, "configuration");
15905 cmd_rx_offload_get_configuration_parsed(
15906 void *parsed_result,
15907 __rte_unused struct cmdline *cl,
15908 __rte_unused void *data)
15910 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15911 struct rte_eth_dev_info dev_info;
15912 portid_t port_id = res->port_id;
15913 struct rte_port *port = &ports[port_id];
15914 uint64_t port_offloads;
15915 uint64_t queue_offloads;
15916 uint16_t nb_rx_queues;
15920 printf("Rx Offloading Configuration of port %d :\n", port_id);
15922 port_offloads = port->dev_conf.rxmode.offloads;
15924 print_rx_offloads(port_offloads);
15927 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15931 nb_rx_queues = dev_info.nb_rx_queues;
15932 for (q = 0; q < nb_rx_queues; q++) {
15933 queue_offloads = port->rx_conf[q].offloads;
15934 printf(" Queue[%2d] :", q);
15935 print_rx_offloads(queue_offloads);
15941 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15942 .f = cmd_rx_offload_get_configuration_parsed,
15944 .help_str = "show port <port_id> rx_offload configuration",
15946 (void *)&cmd_rx_offload_get_configuration_show,
15947 (void *)&cmd_rx_offload_get_configuration_port,
15948 (void *)&cmd_rx_offload_get_configuration_port_id,
15949 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15950 (void *)&cmd_rx_offload_get_configuration_configuration,
15955 /* Enable/Disable a per port offloading */
15956 struct cmd_config_per_port_rx_offload_result {
15957 cmdline_fixed_string_t port;
15958 cmdline_fixed_string_t config;
15960 cmdline_fixed_string_t rx_offload;
15961 cmdline_fixed_string_t offload;
15962 cmdline_fixed_string_t on_off;
15965 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15966 TOKEN_STRING_INITIALIZER
15967 (struct cmd_config_per_port_rx_offload_result,
15969 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15970 TOKEN_STRING_INITIALIZER
15971 (struct cmd_config_per_port_rx_offload_result,
15973 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15974 TOKEN_NUM_INITIALIZER
15975 (struct cmd_config_per_port_rx_offload_result,
15976 port_id, RTE_UINT16);
15977 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15978 TOKEN_STRING_INITIALIZER
15979 (struct cmd_config_per_port_rx_offload_result,
15980 rx_offload, "rx_offload");
15981 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15982 TOKEN_STRING_INITIALIZER
15983 (struct cmd_config_per_port_rx_offload_result,
15984 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15985 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15986 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15987 "scatter#buffer_split#timestamp#security#"
15988 "keep_crc#rss_hash");
15989 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15990 TOKEN_STRING_INITIALIZER
15991 (struct cmd_config_per_port_rx_offload_result,
15995 search_rx_offload(const char *name)
15997 uint64_t single_offload;
15998 const char *single_name;
16002 single_offload = 1;
16003 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16004 single_name = rte_eth_dev_rx_offload_name(single_offload);
16005 if (!strcasecmp(single_name, name)) {
16009 single_offload <<= 1;
16013 return single_offload;
16019 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16020 __rte_unused struct cmdline *cl,
16021 __rte_unused void *data)
16023 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16024 portid_t port_id = res->port_id;
16025 struct rte_eth_dev_info dev_info;
16026 struct rte_port *port = &ports[port_id];
16027 uint64_t single_offload;
16028 uint16_t nb_rx_queues;
16032 if (port->port_status != RTE_PORT_STOPPED) {
16033 printf("Error: Can't config offload when Port %d "
16034 "is not stopped\n", port_id);
16038 single_offload = search_rx_offload(res->offload);
16039 if (single_offload == 0) {
16040 printf("Unknown offload name: %s\n", res->offload);
16044 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16048 nb_rx_queues = dev_info.nb_rx_queues;
16049 if (!strcmp(res->on_off, "on")) {
16050 port->dev_conf.rxmode.offloads |= single_offload;
16051 for (q = 0; q < nb_rx_queues; q++)
16052 port->rx_conf[q].offloads |= single_offload;
16054 port->dev_conf.rxmode.offloads &= ~single_offload;
16055 for (q = 0; q < nb_rx_queues; q++)
16056 port->rx_conf[q].offloads &= ~single_offload;
16059 cmd_reconfig_device_queue(port_id, 1, 1);
16062 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16063 .f = cmd_config_per_port_rx_offload_parsed,
16065 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16066 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16067 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16068 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16069 "keep_crc|rss_hash on|off",
16071 (void *)&cmd_config_per_port_rx_offload_result_port,
16072 (void *)&cmd_config_per_port_rx_offload_result_config,
16073 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16074 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16075 (void *)&cmd_config_per_port_rx_offload_result_offload,
16076 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16081 /* Enable/Disable a per queue offloading */
16082 struct cmd_config_per_queue_rx_offload_result {
16083 cmdline_fixed_string_t port;
16085 cmdline_fixed_string_t rxq;
16087 cmdline_fixed_string_t rx_offload;
16088 cmdline_fixed_string_t offload;
16089 cmdline_fixed_string_t on_off;
16092 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16093 TOKEN_STRING_INITIALIZER
16094 (struct cmd_config_per_queue_rx_offload_result,
16096 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16097 TOKEN_NUM_INITIALIZER
16098 (struct cmd_config_per_queue_rx_offload_result,
16099 port_id, RTE_UINT16);
16100 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16101 TOKEN_STRING_INITIALIZER
16102 (struct cmd_config_per_queue_rx_offload_result,
16104 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16105 TOKEN_NUM_INITIALIZER
16106 (struct cmd_config_per_queue_rx_offload_result,
16107 queue_id, RTE_UINT16);
16108 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16109 TOKEN_STRING_INITIALIZER
16110 (struct cmd_config_per_queue_rx_offload_result,
16111 rx_offload, "rx_offload");
16112 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16113 TOKEN_STRING_INITIALIZER
16114 (struct cmd_config_per_queue_rx_offload_result,
16115 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16116 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16117 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16118 "scatter#buffer_split#timestamp#security#keep_crc");
16119 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16120 TOKEN_STRING_INITIALIZER
16121 (struct cmd_config_per_queue_rx_offload_result,
16125 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16126 __rte_unused struct cmdline *cl,
16127 __rte_unused void *data)
16129 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16130 struct rte_eth_dev_info dev_info;
16131 portid_t port_id = res->port_id;
16132 uint16_t queue_id = res->queue_id;
16133 struct rte_port *port = &ports[port_id];
16134 uint64_t single_offload;
16137 if (port->port_status != RTE_PORT_STOPPED) {
16138 printf("Error: Can't config offload when Port %d "
16139 "is not stopped\n", port_id);
16143 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16147 if (queue_id >= dev_info.nb_rx_queues) {
16148 printf("Error: input queue_id should be 0 ... "
16149 "%d\n", dev_info.nb_rx_queues - 1);
16153 single_offload = search_rx_offload(res->offload);
16154 if (single_offload == 0) {
16155 printf("Unknown offload name: %s\n", res->offload);
16159 if (!strcmp(res->on_off, "on"))
16160 port->rx_conf[queue_id].offloads |= single_offload;
16162 port->rx_conf[queue_id].offloads &= ~single_offload;
16164 cmd_reconfig_device_queue(port_id, 1, 1);
16167 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16168 .f = cmd_config_per_queue_rx_offload_parsed,
16170 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16171 "vlan_strip|ipv4_cksum|"
16172 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16173 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16174 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16177 (void *)&cmd_config_per_queue_rx_offload_result_port,
16178 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16179 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16180 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16181 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16182 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16183 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16188 /* Get Tx offloads capabilities */
16189 struct cmd_tx_offload_get_capa_result {
16190 cmdline_fixed_string_t show;
16191 cmdline_fixed_string_t port;
16193 cmdline_fixed_string_t tx_offload;
16194 cmdline_fixed_string_t capabilities;
16197 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16198 TOKEN_STRING_INITIALIZER
16199 (struct cmd_tx_offload_get_capa_result,
16201 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16202 TOKEN_STRING_INITIALIZER
16203 (struct cmd_tx_offload_get_capa_result,
16205 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16206 TOKEN_NUM_INITIALIZER
16207 (struct cmd_tx_offload_get_capa_result,
16208 port_id, RTE_UINT16);
16209 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16210 TOKEN_STRING_INITIALIZER
16211 (struct cmd_tx_offload_get_capa_result,
16212 tx_offload, "tx_offload");
16213 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16214 TOKEN_STRING_INITIALIZER
16215 (struct cmd_tx_offload_get_capa_result,
16216 capabilities, "capabilities");
16219 print_tx_offloads(uint64_t offloads)
16221 uint64_t single_offload;
16229 begin = __builtin_ctzll(offloads);
16230 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16232 single_offload = 1ULL << begin;
16233 for (bit = begin; bit < end; bit++) {
16234 if (offloads & single_offload)
16236 rte_eth_dev_tx_offload_name(single_offload));
16237 single_offload <<= 1;
16242 cmd_tx_offload_get_capa_parsed(
16243 void *parsed_result,
16244 __rte_unused struct cmdline *cl,
16245 __rte_unused void *data)
16247 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16248 struct rte_eth_dev_info dev_info;
16249 portid_t port_id = res->port_id;
16250 uint64_t queue_offloads;
16251 uint64_t port_offloads;
16254 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16258 queue_offloads = dev_info.tx_queue_offload_capa;
16259 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16261 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16262 printf(" Per Queue :");
16263 print_tx_offloads(queue_offloads);
16266 printf(" Per Port :");
16267 print_tx_offloads(port_offloads);
16271 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16272 .f = cmd_tx_offload_get_capa_parsed,
16274 .help_str = "show port <port_id> tx_offload capabilities",
16276 (void *)&cmd_tx_offload_get_capa_show,
16277 (void *)&cmd_tx_offload_get_capa_port,
16278 (void *)&cmd_tx_offload_get_capa_port_id,
16279 (void *)&cmd_tx_offload_get_capa_tx_offload,
16280 (void *)&cmd_tx_offload_get_capa_capabilities,
16285 /* Get Tx offloads configuration */
16286 struct cmd_tx_offload_get_configuration_result {
16287 cmdline_fixed_string_t show;
16288 cmdline_fixed_string_t port;
16290 cmdline_fixed_string_t tx_offload;
16291 cmdline_fixed_string_t configuration;
16294 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16295 TOKEN_STRING_INITIALIZER
16296 (struct cmd_tx_offload_get_configuration_result,
16298 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16299 TOKEN_STRING_INITIALIZER
16300 (struct cmd_tx_offload_get_configuration_result,
16302 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16303 TOKEN_NUM_INITIALIZER
16304 (struct cmd_tx_offload_get_configuration_result,
16305 port_id, RTE_UINT16);
16306 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16307 TOKEN_STRING_INITIALIZER
16308 (struct cmd_tx_offload_get_configuration_result,
16309 tx_offload, "tx_offload");
16310 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16311 TOKEN_STRING_INITIALIZER
16312 (struct cmd_tx_offload_get_configuration_result,
16313 configuration, "configuration");
16316 cmd_tx_offload_get_configuration_parsed(
16317 void *parsed_result,
16318 __rte_unused struct cmdline *cl,
16319 __rte_unused void *data)
16321 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16322 struct rte_eth_dev_info dev_info;
16323 portid_t port_id = res->port_id;
16324 struct rte_port *port = &ports[port_id];
16325 uint64_t port_offloads;
16326 uint64_t queue_offloads;
16327 uint16_t nb_tx_queues;
16331 printf("Tx Offloading Configuration of port %d :\n", port_id);
16333 port_offloads = port->dev_conf.txmode.offloads;
16335 print_tx_offloads(port_offloads);
16338 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16342 nb_tx_queues = dev_info.nb_tx_queues;
16343 for (q = 0; q < nb_tx_queues; q++) {
16344 queue_offloads = port->tx_conf[q].offloads;
16345 printf(" Queue[%2d] :", q);
16346 print_tx_offloads(queue_offloads);
16352 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16353 .f = cmd_tx_offload_get_configuration_parsed,
16355 .help_str = "show port <port_id> tx_offload configuration",
16357 (void *)&cmd_tx_offload_get_configuration_show,
16358 (void *)&cmd_tx_offload_get_configuration_port,
16359 (void *)&cmd_tx_offload_get_configuration_port_id,
16360 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16361 (void *)&cmd_tx_offload_get_configuration_configuration,
16366 /* Enable/Disable a per port offloading */
16367 struct cmd_config_per_port_tx_offload_result {
16368 cmdline_fixed_string_t port;
16369 cmdline_fixed_string_t config;
16371 cmdline_fixed_string_t tx_offload;
16372 cmdline_fixed_string_t offload;
16373 cmdline_fixed_string_t on_off;
16376 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16377 TOKEN_STRING_INITIALIZER
16378 (struct cmd_config_per_port_tx_offload_result,
16380 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16381 TOKEN_STRING_INITIALIZER
16382 (struct cmd_config_per_port_tx_offload_result,
16384 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16385 TOKEN_NUM_INITIALIZER
16386 (struct cmd_config_per_port_tx_offload_result,
16387 port_id, RTE_UINT16);
16388 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16389 TOKEN_STRING_INITIALIZER
16390 (struct cmd_config_per_port_tx_offload_result,
16391 tx_offload, "tx_offload");
16392 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16393 TOKEN_STRING_INITIALIZER
16394 (struct cmd_config_per_port_tx_offload_result,
16395 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16396 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16397 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16398 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16399 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16400 "send_on_timestamp");
16401 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16402 TOKEN_STRING_INITIALIZER
16403 (struct cmd_config_per_port_tx_offload_result,
16407 search_tx_offload(const char *name)
16409 uint64_t single_offload;
16410 const char *single_name;
16414 single_offload = 1;
16415 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16416 single_name = rte_eth_dev_tx_offload_name(single_offload);
16417 if (single_name == NULL)
16419 if (!strcasecmp(single_name, name)) {
16422 } else if (!strcasecmp(single_name, "UNKNOWN"))
16424 single_offload <<= 1;
16428 return single_offload;
16434 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16435 __rte_unused struct cmdline *cl,
16436 __rte_unused void *data)
16438 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16439 portid_t port_id = res->port_id;
16440 struct rte_eth_dev_info dev_info;
16441 struct rte_port *port = &ports[port_id];
16442 uint64_t single_offload;
16443 uint16_t nb_tx_queues;
16447 if (port->port_status != RTE_PORT_STOPPED) {
16448 printf("Error: Can't config offload when Port %d "
16449 "is not stopped\n", port_id);
16453 single_offload = search_tx_offload(res->offload);
16454 if (single_offload == 0) {
16455 printf("Unknown offload name: %s\n", res->offload);
16459 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16463 nb_tx_queues = dev_info.nb_tx_queues;
16464 if (!strcmp(res->on_off, "on")) {
16465 port->dev_conf.txmode.offloads |= single_offload;
16466 for (q = 0; q < nb_tx_queues; q++)
16467 port->tx_conf[q].offloads |= single_offload;
16469 port->dev_conf.txmode.offloads &= ~single_offload;
16470 for (q = 0; q < nb_tx_queues; q++)
16471 port->tx_conf[q].offloads &= ~single_offload;
16474 cmd_reconfig_device_queue(port_id, 1, 1);
16477 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16478 .f = cmd_config_per_port_tx_offload_parsed,
16480 .help_str = "port config <port_id> tx_offload "
16481 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16482 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16483 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16484 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16485 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16486 "send_on_timestamp on|off",
16488 (void *)&cmd_config_per_port_tx_offload_result_port,
16489 (void *)&cmd_config_per_port_tx_offload_result_config,
16490 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16491 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16492 (void *)&cmd_config_per_port_tx_offload_result_offload,
16493 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16498 /* Enable/Disable a per queue offloading */
16499 struct cmd_config_per_queue_tx_offload_result {
16500 cmdline_fixed_string_t port;
16502 cmdline_fixed_string_t txq;
16504 cmdline_fixed_string_t tx_offload;
16505 cmdline_fixed_string_t offload;
16506 cmdline_fixed_string_t on_off;
16509 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16510 TOKEN_STRING_INITIALIZER
16511 (struct cmd_config_per_queue_tx_offload_result,
16513 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16514 TOKEN_NUM_INITIALIZER
16515 (struct cmd_config_per_queue_tx_offload_result,
16516 port_id, RTE_UINT16);
16517 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16518 TOKEN_STRING_INITIALIZER
16519 (struct cmd_config_per_queue_tx_offload_result,
16521 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16522 TOKEN_NUM_INITIALIZER
16523 (struct cmd_config_per_queue_tx_offload_result,
16524 queue_id, RTE_UINT16);
16525 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16526 TOKEN_STRING_INITIALIZER
16527 (struct cmd_config_per_queue_tx_offload_result,
16528 tx_offload, "tx_offload");
16529 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16530 TOKEN_STRING_INITIALIZER
16531 (struct cmd_config_per_queue_tx_offload_result,
16532 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16533 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16534 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16535 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16536 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16537 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16538 TOKEN_STRING_INITIALIZER
16539 (struct cmd_config_per_queue_tx_offload_result,
16543 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16544 __rte_unused struct cmdline *cl,
16545 __rte_unused void *data)
16547 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16548 struct rte_eth_dev_info dev_info;
16549 portid_t port_id = res->port_id;
16550 uint16_t queue_id = res->queue_id;
16551 struct rte_port *port = &ports[port_id];
16552 uint64_t single_offload;
16555 if (port->port_status != RTE_PORT_STOPPED) {
16556 printf("Error: Can't config offload when Port %d "
16557 "is not stopped\n", port_id);
16561 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16565 if (queue_id >= dev_info.nb_tx_queues) {
16566 printf("Error: input queue_id should be 0 ... "
16567 "%d\n", dev_info.nb_tx_queues - 1);
16571 single_offload = search_tx_offload(res->offload);
16572 if (single_offload == 0) {
16573 printf("Unknown offload name: %s\n", res->offload);
16577 if (!strcmp(res->on_off, "on"))
16578 port->tx_conf[queue_id].offloads |= single_offload;
16580 port->tx_conf[queue_id].offloads &= ~single_offload;
16582 cmd_reconfig_device_queue(port_id, 1, 1);
16585 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16586 .f = cmd_config_per_queue_tx_offload_parsed,
16588 .help_str = "port <port_id> txq <queue_id> tx_offload "
16589 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16590 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16591 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16592 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16593 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16596 (void *)&cmd_config_per_queue_tx_offload_result_port,
16597 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16598 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16599 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16600 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16601 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16602 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16607 /* *** configure tx_metadata for specific port *** */
16608 struct cmd_config_tx_metadata_specific_result {
16609 cmdline_fixed_string_t port;
16610 cmdline_fixed_string_t keyword;
16612 cmdline_fixed_string_t item;
16617 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16618 __rte_unused struct cmdline *cl,
16619 __rte_unused void *data)
16621 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16623 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16625 ports[res->port_id].tx_metadata = res->value;
16626 /* Add/remove callback to insert valid metadata in every Tx packet. */
16627 if (ports[res->port_id].tx_metadata)
16628 add_tx_md_callback(res->port_id);
16630 remove_tx_md_callback(res->port_id);
16631 rte_flow_dynf_metadata_register();
16634 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16635 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16637 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16638 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16639 keyword, "config");
16640 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16641 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16642 port_id, RTE_UINT16);
16643 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16644 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16645 item, "tx_metadata");
16646 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16647 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16648 value, RTE_UINT32);
16650 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16651 .f = cmd_config_tx_metadata_specific_parsed,
16653 .help_str = "port config <port_id> tx_metadata <value>",
16655 (void *)&cmd_config_tx_metadata_specific_port,
16656 (void *)&cmd_config_tx_metadata_specific_keyword,
16657 (void *)&cmd_config_tx_metadata_specific_id,
16658 (void *)&cmd_config_tx_metadata_specific_item,
16659 (void *)&cmd_config_tx_metadata_specific_value,
16664 /* *** set dynf *** */
16665 struct cmd_config_tx_dynf_specific_result {
16666 cmdline_fixed_string_t port;
16667 cmdline_fixed_string_t keyword;
16669 cmdline_fixed_string_t item;
16670 cmdline_fixed_string_t name;
16671 cmdline_fixed_string_t value;
16675 cmd_config_dynf_specific_parsed(void *parsed_result,
16676 __rte_unused struct cmdline *cl,
16677 __rte_unused void *data)
16679 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16680 struct rte_mbuf_dynflag desc_flag;
16682 uint64_t old_port_flags;
16684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16686 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16688 if (strlcpy(desc_flag.name, res->name,
16689 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16690 printf("Flag name too long\n");
16693 desc_flag.flags = 0;
16694 flag = rte_mbuf_dynflag_register(&desc_flag);
16696 printf("Can't register flag\n");
16699 strcpy(dynf_names[flag], desc_flag.name);
16701 old_port_flags = ports[res->port_id].mbuf_dynf;
16702 if (!strcmp(res->value, "set")) {
16703 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16704 if (old_port_flags == 0)
16705 add_tx_dynf_callback(res->port_id);
16707 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16708 if (ports[res->port_id].mbuf_dynf == 0)
16709 remove_tx_dynf_callback(res->port_id);
16713 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16714 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16716 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16717 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16718 keyword, "config");
16719 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16720 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16721 port_id, RTE_UINT16);
16722 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16723 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16725 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16726 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16728 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16729 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16730 value, "set#clear");
16732 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16733 .f = cmd_config_dynf_specific_parsed,
16735 .help_str = "port config <port id> dynf <name> set|clear",
16737 (void *)&cmd_config_tx_dynf_specific_port,
16738 (void *)&cmd_config_tx_dynf_specific_keyword,
16739 (void *)&cmd_config_tx_dynf_specific_port_id,
16740 (void *)&cmd_config_tx_dynf_specific_item,
16741 (void *)&cmd_config_tx_dynf_specific_name,
16742 (void *)&cmd_config_tx_dynf_specific_value,
16747 /* *** display tx_metadata per port configuration *** */
16748 struct cmd_show_tx_metadata_result {
16749 cmdline_fixed_string_t cmd_show;
16750 cmdline_fixed_string_t cmd_port;
16751 cmdline_fixed_string_t cmd_keyword;
16756 cmd_show_tx_metadata_parsed(void *parsed_result,
16757 __rte_unused struct cmdline *cl,
16758 __rte_unused void *data)
16760 struct cmd_show_tx_metadata_result *res = parsed_result;
16762 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16763 printf("invalid port id %u\n", res->cmd_pid);
16766 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16767 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16768 ports[res->cmd_pid].tx_metadata);
16772 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16773 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16775 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16776 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16778 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16779 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16780 cmd_pid, RTE_UINT16);
16781 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16782 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16783 cmd_keyword, "tx_metadata");
16785 cmdline_parse_inst_t cmd_show_tx_metadata = {
16786 .f = cmd_show_tx_metadata_parsed,
16788 .help_str = "show port <port_id> tx_metadata",
16790 (void *)&cmd_show_tx_metadata_show,
16791 (void *)&cmd_show_tx_metadata_port,
16792 (void *)&cmd_show_tx_metadata_pid,
16793 (void *)&cmd_show_tx_metadata_keyword,
16798 /* *** show fec capability per port configuration *** */
16799 struct cmd_show_fec_capability_result {
16800 cmdline_fixed_string_t cmd_show;
16801 cmdline_fixed_string_t cmd_port;
16802 cmdline_fixed_string_t cmd_fec;
16803 cmdline_fixed_string_t cmd_keyword;
16808 cmd_show_fec_capability_parsed(void *parsed_result,
16809 __rte_unused struct cmdline *cl,
16810 __rte_unused void *data)
16812 struct cmd_show_fec_capability_result *res = parsed_result;
16813 struct rte_eth_fec_capa *speed_fec_capa;
16817 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16818 printf("Invalid port id %u\n", res->cmd_pid);
16822 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16823 if (ret == -ENOTSUP) {
16824 printf("Function not implemented\n");
16826 } else if (ret < 0) {
16827 printf("Get FEC capability failed: %d\n", ret);
16831 num = (unsigned int)ret;
16832 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16833 if (speed_fec_capa == NULL) {
16834 printf("Failed to alloc FEC capability buffer\n");
16838 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16840 printf("Error getting FEC capability: %d\n", ret);
16844 show_fec_capability(num, speed_fec_capa);
16846 free(speed_fec_capa);
16849 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16850 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16852 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16853 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16855 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16856 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16857 cmd_pid, RTE_UINT16);
16858 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16859 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16861 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16862 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16863 cmd_keyword, "capabilities");
16865 cmdline_parse_inst_t cmd_show_capability = {
16866 .f = cmd_show_fec_capability_parsed,
16868 .help_str = "show port <port_id> fec capabilities",
16870 (void *)&cmd_show_fec_capability_show,
16871 (void *)&cmd_show_fec_capability_port,
16872 (void *)&cmd_show_fec_capability_pid,
16873 (void *)&cmd_show_fec_capability_fec,
16874 (void *)&cmd_show_fec_capability_keyword,
16879 /* *** show fec mode per port configuration *** */
16880 struct cmd_show_fec_metadata_result {
16881 cmdline_fixed_string_t cmd_show;
16882 cmdline_fixed_string_t cmd_port;
16883 cmdline_fixed_string_t cmd_keyword;
16888 cmd_show_fec_mode_parsed(void *parsed_result,
16889 __rte_unused struct cmdline *cl,
16890 __rte_unused void *data)
16892 #define FEC_NAME_SIZE 16
16893 struct cmd_show_fec_metadata_result *res = parsed_result;
16895 char buf[FEC_NAME_SIZE];
16898 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16899 printf("Invalid port id %u\n", res->cmd_pid);
16902 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16903 if (ret == -ENOTSUP) {
16904 printf("Function not implemented\n");
16906 } else if (ret < 0) {
16907 printf("Get FEC mode failed\n");
16912 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16913 strlcpy(buf, "off", sizeof(buf));
16915 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16916 strlcpy(buf, "auto", sizeof(buf));
16918 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16919 strlcpy(buf, "baser", sizeof(buf));
16921 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16922 strlcpy(buf, "rs", sizeof(buf));
16928 printf("%s\n", buf);
16931 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16932 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16934 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16935 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16937 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16938 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16939 cmd_pid, RTE_UINT16);
16940 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16941 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16942 cmd_keyword, "fec_mode");
16944 cmdline_parse_inst_t cmd_show_fec_mode = {
16945 .f = cmd_show_fec_mode_parsed,
16947 .help_str = "show port <port_id> fec_mode",
16949 (void *)&cmd_show_fec_mode_show,
16950 (void *)&cmd_show_fec_mode_port,
16951 (void *)&cmd_show_fec_mode_pid,
16952 (void *)&cmd_show_fec_mode_keyword,
16957 /* *** set fec mode per port configuration *** */
16958 struct cmd_set_port_fec_mode {
16959 cmdline_fixed_string_t set;
16960 cmdline_fixed_string_t port;
16962 cmdline_fixed_string_t fec_mode;
16963 cmdline_fixed_string_t fec_value;
16966 /* Common CLI fields for set fec mode */
16967 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16968 TOKEN_STRING_INITIALIZER
16969 (struct cmd_set_port_fec_mode,
16971 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16972 TOKEN_STRING_INITIALIZER
16973 (struct cmd_set_port_fec_mode,
16975 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16976 TOKEN_NUM_INITIALIZER
16977 (struct cmd_set_port_fec_mode,
16978 port_id, RTE_UINT16);
16979 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16980 TOKEN_STRING_INITIALIZER
16981 (struct cmd_set_port_fec_mode,
16982 fec_mode, "fec_mode");
16983 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16984 TOKEN_STRING_INITIALIZER
16985 (struct cmd_set_port_fec_mode,
16989 cmd_set_port_fec_mode_parsed(
16990 void *parsed_result,
16991 __rte_unused struct cmdline *cl,
16992 __rte_unused void *data)
16994 struct cmd_set_port_fec_mode *res = parsed_result;
16995 uint16_t port_id = res->port_id;
16999 ret = parse_fec_mode(res->fec_value, &fec_capa);
17001 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
17006 ret = rte_eth_fec_set(port_id, fec_capa);
17007 if (ret == -ENOTSUP) {
17008 printf("Function not implemented\n");
17010 } else if (ret < 0) {
17011 printf("Set FEC mode failed\n");
17016 cmdline_parse_inst_t cmd_set_fec_mode = {
17017 .f = cmd_set_port_fec_mode_parsed,
17019 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17021 (void *)&cmd_set_port_fec_mode_set,
17022 (void *)&cmd_set_port_fec_mode_port,
17023 (void *)&cmd_set_port_fec_mode_port_id,
17024 (void *)&cmd_set_port_fec_mode_str,
17025 (void *)&cmd_set_port_fec_mode_value,
17030 /* show port supported ptypes */
17032 /* Common result structure for show port ptypes */
17033 struct cmd_show_port_supported_ptypes_result {
17034 cmdline_fixed_string_t show;
17035 cmdline_fixed_string_t port;
17037 cmdline_fixed_string_t ptypes;
17040 /* Common CLI fields for show port ptypes */
17041 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17042 TOKEN_STRING_INITIALIZER
17043 (struct cmd_show_port_supported_ptypes_result,
17045 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17046 TOKEN_STRING_INITIALIZER
17047 (struct cmd_show_port_supported_ptypes_result,
17049 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17050 TOKEN_NUM_INITIALIZER
17051 (struct cmd_show_port_supported_ptypes_result,
17052 port_id, RTE_UINT16);
17053 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17054 TOKEN_STRING_INITIALIZER
17055 (struct cmd_show_port_supported_ptypes_result,
17059 cmd_show_port_supported_ptypes_parsed(
17060 void *parsed_result,
17061 __rte_unused struct cmdline *cl,
17062 __rte_unused void *data)
17064 #define RSVD_PTYPE_MASK 0xf0000000
17065 #define MAX_PTYPES_PER_LAYER 16
17066 #define LTYPE_NAMESIZE 32
17067 #define PTYPE_NAMESIZE 256
17068 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17069 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17070 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17071 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17072 uint16_t port_id = res->port_id;
17075 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17079 while (ptype_mask != RSVD_PTYPE_MASK) {
17081 switch (ptype_mask) {
17082 case RTE_PTYPE_L2_MASK:
17083 strlcpy(ltype, "L2", sizeof(ltype));
17085 case RTE_PTYPE_L3_MASK:
17086 strlcpy(ltype, "L3", sizeof(ltype));
17088 case RTE_PTYPE_L4_MASK:
17089 strlcpy(ltype, "L4", sizeof(ltype));
17091 case RTE_PTYPE_TUNNEL_MASK:
17092 strlcpy(ltype, "Tunnel", sizeof(ltype));
17094 case RTE_PTYPE_INNER_L2_MASK:
17095 strlcpy(ltype, "Inner L2", sizeof(ltype));
17097 case RTE_PTYPE_INNER_L3_MASK:
17098 strlcpy(ltype, "Inner L3", sizeof(ltype));
17100 case RTE_PTYPE_INNER_L4_MASK:
17101 strlcpy(ltype, "Inner L4", sizeof(ltype));
17107 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17108 ptype_mask, ptypes,
17109 MAX_PTYPES_PER_LAYER);
17112 printf("Supported %s ptypes:\n", ltype);
17114 printf("%s ptypes unsupported\n", ltype);
17116 for (i = 0; i < ret; ++i) {
17117 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17118 printf("%s\n", buf);
17125 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17126 .f = cmd_show_port_supported_ptypes_parsed,
17128 .help_str = "show port <port_id> ptypes",
17130 (void *)&cmd_show_port_supported_ptypes_show,
17131 (void *)&cmd_show_port_supported_ptypes_port,
17132 (void *)&cmd_show_port_supported_ptypes_port_id,
17133 (void *)&cmd_show_port_supported_ptypes_ptypes,
17138 /* *** display rx/tx descriptor status *** */
17139 struct cmd_show_rx_tx_desc_status_result {
17140 cmdline_fixed_string_t cmd_show;
17141 cmdline_fixed_string_t cmd_port;
17142 cmdline_fixed_string_t cmd_keyword;
17143 cmdline_fixed_string_t cmd_desc;
17144 cmdline_fixed_string_t cmd_status;
17151 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17152 __rte_unused struct cmdline *cl,
17153 __rte_unused void *data)
17155 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17158 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17159 printf("invalid port id %u\n", res->cmd_pid);
17163 if (!strcmp(res->cmd_keyword, "rxq")) {
17164 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17167 printf("Invalid input: queue id = %d, desc id = %d\n",
17168 res->cmd_qid, res->cmd_did);
17171 if (rc == RTE_ETH_RX_DESC_AVAIL)
17172 printf("Desc status = AVAILABLE\n");
17173 else if (rc == RTE_ETH_RX_DESC_DONE)
17174 printf("Desc status = DONE\n");
17176 printf("Desc status = UNAVAILABLE\n");
17177 } else if (!strcmp(res->cmd_keyword, "txq")) {
17178 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17181 printf("Invalid input: queue id = %d, desc id = %d\n",
17182 res->cmd_qid, res->cmd_did);
17185 if (rc == RTE_ETH_TX_DESC_FULL)
17186 printf("Desc status = FULL\n");
17187 else if (rc == RTE_ETH_TX_DESC_DONE)
17188 printf("Desc status = DONE\n");
17190 printf("Desc status = UNAVAILABLE\n");
17194 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17195 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17197 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17198 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17200 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17201 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17202 cmd_pid, RTE_UINT16);
17203 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17204 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17205 cmd_keyword, "rxq#txq");
17206 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17207 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17208 cmd_qid, RTE_UINT16);
17209 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17210 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17212 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17213 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17214 cmd_did, RTE_UINT16);
17215 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17216 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17217 cmd_status, "status");
17218 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17219 .f = cmd_show_rx_tx_desc_status_parsed,
17221 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17224 (void *)&cmd_show_rx_tx_desc_status_show,
17225 (void *)&cmd_show_rx_tx_desc_status_port,
17226 (void *)&cmd_show_rx_tx_desc_status_pid,
17227 (void *)&cmd_show_rx_tx_desc_status_keyword,
17228 (void *)&cmd_show_rx_tx_desc_status_qid,
17229 (void *)&cmd_show_rx_tx_desc_status_desc,
17230 (void *)&cmd_show_rx_tx_desc_status_did,
17231 (void *)&cmd_show_rx_tx_desc_status_status,
17236 /* *** display rx queue desc used count *** */
17237 struct cmd_show_rx_queue_desc_used_count_result {
17238 cmdline_fixed_string_t cmd_show;
17239 cmdline_fixed_string_t cmd_port;
17240 cmdline_fixed_string_t cmd_rxq;
17241 cmdline_fixed_string_t cmd_desc;
17242 cmdline_fixed_string_t cmd_used;
17243 cmdline_fixed_string_t cmd_count;
17249 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17250 __rte_unused struct cmdline *cl,
17251 __rte_unused void *data)
17253 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17256 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17257 printf("invalid port id %u\n", res->cmd_pid);
17261 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17263 printf("Invalid queueid = %d\n", res->cmd_qid);
17266 printf("Used desc count = %d\n", rc);
17269 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17270 TOKEN_STRING_INITIALIZER
17271 (struct cmd_show_rx_queue_desc_used_count_result,
17273 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17274 TOKEN_STRING_INITIALIZER
17275 (struct cmd_show_rx_queue_desc_used_count_result,
17277 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17278 TOKEN_NUM_INITIALIZER
17279 (struct cmd_show_rx_queue_desc_used_count_result,
17280 cmd_pid, RTE_UINT16);
17281 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17282 TOKEN_STRING_INITIALIZER
17283 (struct cmd_show_rx_queue_desc_used_count_result,
17285 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17286 TOKEN_NUM_INITIALIZER
17287 (struct cmd_show_rx_queue_desc_used_count_result,
17288 cmd_qid, RTE_UINT16);
17289 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17290 TOKEN_STRING_INITIALIZER
17291 (struct cmd_show_rx_queue_desc_used_count_result,
17292 cmd_count, "desc");
17293 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17294 TOKEN_STRING_INITIALIZER
17295 (struct cmd_show_rx_queue_desc_used_count_result,
17296 cmd_count, "used");
17297 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17298 TOKEN_STRING_INITIALIZER
17299 (struct cmd_show_rx_queue_desc_used_count_result,
17300 cmd_count, "count");
17301 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17302 .f = cmd_show_rx_queue_desc_used_count_parsed,
17304 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17306 (void *)&cmd_show_rx_queue_desc_used_count_show,
17307 (void *)&cmd_show_rx_queue_desc_used_count_port,
17308 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17309 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17310 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17311 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17312 (void *)&cmd_show_rx_queue_desc_used_count_used,
17313 (void *)&cmd_show_rx_queue_desc_used_count_count,
17318 /* Common result structure for set port ptypes */
17319 struct cmd_set_port_ptypes_result {
17320 cmdline_fixed_string_t set;
17321 cmdline_fixed_string_t port;
17323 cmdline_fixed_string_t ptype_mask;
17327 /* Common CLI fields for set port ptypes */
17328 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17329 TOKEN_STRING_INITIALIZER
17330 (struct cmd_set_port_ptypes_result,
17332 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17333 TOKEN_STRING_INITIALIZER
17334 (struct cmd_set_port_ptypes_result,
17336 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17337 TOKEN_NUM_INITIALIZER
17338 (struct cmd_set_port_ptypes_result,
17339 port_id, RTE_UINT16);
17340 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17341 TOKEN_STRING_INITIALIZER
17342 (struct cmd_set_port_ptypes_result,
17343 ptype_mask, "ptype_mask");
17344 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17345 TOKEN_NUM_INITIALIZER
17346 (struct cmd_set_port_ptypes_result,
17350 cmd_set_port_ptypes_parsed(
17351 void *parsed_result,
17352 __rte_unused struct cmdline *cl,
17353 __rte_unused void *data)
17355 struct cmd_set_port_ptypes_result *res = parsed_result;
17356 #define PTYPE_NAMESIZE 256
17357 char ptype_name[PTYPE_NAMESIZE];
17358 uint16_t port_id = res->port_id;
17359 uint32_t ptype_mask = res->mask;
17362 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17365 printf("Port %d doesn't support any ptypes.\n", port_id);
17369 uint32_t ptypes[ret];
17371 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17373 printf("Unable to set requested ptypes for Port %d\n", port_id);
17377 printf("Successfully set following ptypes for Port %d\n", port_id);
17378 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17379 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17380 printf("%s\n", ptype_name);
17383 clear_ptypes = false;
17386 cmdline_parse_inst_t cmd_set_port_ptypes = {
17387 .f = cmd_set_port_ptypes_parsed,
17389 .help_str = "set port <port_id> ptype_mask <mask>",
17391 (void *)&cmd_set_port_ptypes_set,
17392 (void *)&cmd_set_port_ptypes_port,
17393 (void *)&cmd_set_port_ptypes_port_id,
17394 (void *)&cmd_set_port_ptypes_mask_str,
17395 (void *)&cmd_set_port_ptypes_mask_u32,
17400 /* *** display mac addresses added to a port *** */
17401 struct cmd_showport_macs_result {
17402 cmdline_fixed_string_t cmd_show;
17403 cmdline_fixed_string_t cmd_port;
17404 cmdline_fixed_string_t cmd_keyword;
17409 cmd_showport_macs_parsed(void *parsed_result,
17410 __rte_unused struct cmdline *cl,
17411 __rte_unused void *data)
17413 struct cmd_showport_macs_result *res = parsed_result;
17415 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17418 if (!strcmp(res->cmd_keyword, "macs"))
17419 show_macs(res->cmd_pid);
17420 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17421 show_mcast_macs(res->cmd_pid);
17424 cmdline_parse_token_string_t cmd_showport_macs_show =
17425 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17427 cmdline_parse_token_string_t cmd_showport_macs_port =
17428 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17430 cmdline_parse_token_num_t cmd_showport_macs_pid =
17431 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17432 cmd_pid, RTE_UINT16);
17433 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17434 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17435 cmd_keyword, "macs#mcast_macs");
17437 cmdline_parse_inst_t cmd_showport_macs = {
17438 .f = cmd_showport_macs_parsed,
17440 .help_str = "show port <port_id> macs|mcast_macs",
17442 (void *)&cmd_showport_macs_show,
17443 (void *)&cmd_showport_macs_port,
17444 (void *)&cmd_showport_macs_pid,
17445 (void *)&cmd_showport_macs_keyword,
17450 /* ******************************************************************************** */
17452 /* list of instructions */
17453 cmdline_parse_ctx_t main_ctx[] = {
17454 (cmdline_parse_inst_t *)&cmd_help_brief,
17455 (cmdline_parse_inst_t *)&cmd_help_long,
17456 (cmdline_parse_inst_t *)&cmd_quit,
17457 (cmdline_parse_inst_t *)&cmd_load_from_file,
17458 (cmdline_parse_inst_t *)&cmd_showport,
17459 (cmdline_parse_inst_t *)&cmd_showqueue,
17460 (cmdline_parse_inst_t *)&cmd_showeeprom,
17461 (cmdline_parse_inst_t *)&cmd_showportall,
17462 (cmdline_parse_inst_t *)&cmd_showdevice,
17463 (cmdline_parse_inst_t *)&cmd_showcfg,
17464 (cmdline_parse_inst_t *)&cmd_showfwdall,
17465 (cmdline_parse_inst_t *)&cmd_start,
17466 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17467 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17468 (cmdline_parse_inst_t *)&cmd_set_link_up,
17469 (cmdline_parse_inst_t *)&cmd_set_link_down,
17470 (cmdline_parse_inst_t *)&cmd_reset,
17471 (cmdline_parse_inst_t *)&cmd_set_numbers,
17472 (cmdline_parse_inst_t *)&cmd_set_log,
17473 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17474 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17475 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17476 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17477 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17478 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17479 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17480 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17481 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17482 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17483 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17484 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17485 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17486 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17487 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17488 (cmdline_parse_inst_t *)&cmd_set_link_check,
17489 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17490 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17491 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17492 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17493 #ifdef RTE_NET_BOND
17494 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17495 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17496 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17497 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17498 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17499 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17500 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17501 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17502 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17503 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17504 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17506 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17507 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17508 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17509 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17510 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17511 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17512 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17513 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17514 (cmdline_parse_inst_t *)&cmd_csum_set,
17515 (cmdline_parse_inst_t *)&cmd_csum_show,
17516 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17517 (cmdline_parse_inst_t *)&cmd_tso_set,
17518 (cmdline_parse_inst_t *)&cmd_tso_show,
17519 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17520 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17521 (cmdline_parse_inst_t *)&cmd_gro_enable,
17522 (cmdline_parse_inst_t *)&cmd_gro_flush,
17523 (cmdline_parse_inst_t *)&cmd_gro_show,
17524 (cmdline_parse_inst_t *)&cmd_gso_enable,
17525 (cmdline_parse_inst_t *)&cmd_gso_size,
17526 (cmdline_parse_inst_t *)&cmd_gso_show,
17527 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17528 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17529 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17530 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17531 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17532 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17533 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17534 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17535 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17536 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17537 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17538 (cmdline_parse_inst_t *)&cmd_config_dcb,
17539 (cmdline_parse_inst_t *)&cmd_read_reg,
17540 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17541 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17542 (cmdline_parse_inst_t *)&cmd_write_reg,
17543 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17544 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17545 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17546 (cmdline_parse_inst_t *)&cmd_stop,
17547 (cmdline_parse_inst_t *)&cmd_mac_addr,
17548 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17549 (cmdline_parse_inst_t *)&cmd_set_qmap,
17550 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17551 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17552 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17553 (cmdline_parse_inst_t *)&cmd_operate_port,
17554 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17555 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17556 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17557 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17558 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17559 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17560 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17561 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17562 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17563 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17564 (cmdline_parse_inst_t *)&cmd_config_mtu,
17565 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17566 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17567 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17568 (cmdline_parse_inst_t *)&cmd_config_rss,
17569 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17570 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17571 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17572 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17573 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17574 (cmdline_parse_inst_t *)&cmd_showport_reta,
17575 (cmdline_parse_inst_t *)&cmd_showport_macs,
17576 (cmdline_parse_inst_t *)&cmd_config_burst,
17577 (cmdline_parse_inst_t *)&cmd_config_thresh,
17578 (cmdline_parse_inst_t *)&cmd_config_threshold,
17579 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17580 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17581 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17582 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17583 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17584 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17585 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17586 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17587 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17588 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17589 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17590 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17591 (cmdline_parse_inst_t *)&cmd_dump,
17592 (cmdline_parse_inst_t *)&cmd_dump_one,
17593 #ifdef RTE_NET_I40E
17594 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17596 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17597 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17598 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17599 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17600 (cmdline_parse_inst_t *)&cmd_flow,
17601 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17602 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17603 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17604 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17605 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17606 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17607 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17608 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17609 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17610 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17611 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17612 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17613 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17614 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17615 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17616 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17617 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17618 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17619 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17620 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17621 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17622 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17623 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17624 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17625 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17626 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17627 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17628 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17629 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17630 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17631 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17632 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17633 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17634 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17635 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17636 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17637 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17638 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17639 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17640 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17641 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17642 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17643 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17644 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17645 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17646 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17647 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17648 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17649 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17650 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17651 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17652 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17653 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17654 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17655 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17656 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17657 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17658 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17659 (cmdline_parse_inst_t *)&cmd_ddp_add,
17660 (cmdline_parse_inst_t *)&cmd_ddp_del,
17661 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17662 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17663 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17664 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17665 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17666 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17667 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17668 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17669 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17670 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17671 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17672 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17674 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17675 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17676 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17677 (cmdline_parse_inst_t *)&cmd_queue_region,
17678 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17679 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17680 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17681 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17682 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17683 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17684 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17685 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17686 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17687 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17688 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17689 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17690 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17691 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17692 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17693 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17694 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17695 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17696 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17697 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17698 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17699 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17700 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17701 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17702 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17703 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17704 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17705 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17706 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17707 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17708 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17709 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17710 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17711 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17712 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17713 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17715 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17716 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17718 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17719 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17720 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17721 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17722 (cmdline_parse_inst_t *)&cmd_set_raw,
17723 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17724 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17725 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17726 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17727 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17728 (cmdline_parse_inst_t *)&cmd_show_capability,
17732 /* read cmdline commands from file */
17734 cmdline_read_from_file(const char *filename)
17736 struct cmdline *cl;
17738 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17740 printf("Failed to create file based cmdline context: %s\n",
17745 cmdline_interact(cl);
17750 printf("Read CLI commands from %s\n", filename);
17753 /* prompt function, called from main on MAIN lcore */
17758 /* initialize non-constant commands */
17759 cmd_set_fwd_mode_init();
17760 cmd_set_fwd_retry_mode_init();
17762 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17763 if (testpmd_cl == NULL)
17766 ret = atexit(prompt_exit);
17768 printf("Cannot set exit function for cmdline\n");
17770 cmdline_interact(testpmd_cl);
17772 cmdline_stdin_exit(testpmd_cl);
17778 if (testpmd_cl != NULL) {
17779 cmdline_quit(testpmd_cl);
17780 cmdline_stdin_exit(testpmd_cl);
17785 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17787 if (id == (portid_t)RTE_PORT_ALL) {
17790 RTE_ETH_FOREACH_DEV(pid) {
17791 /* check if need_reconfig has been set to 1 */
17792 if (ports[pid].need_reconfig == 0)
17793 ports[pid].need_reconfig = dev;
17794 /* check if need_reconfig_queues has been set to 1 */
17795 if (ports[pid].need_reconfig_queues == 0)
17796 ports[pid].need_reconfig_queues = queue;
17798 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17799 /* check if need_reconfig has been set to 1 */
17800 if (ports[id].need_reconfig == 0)
17801 ports[id].need_reconfig = dev;
17802 /* check if need_reconfig_queues has been set to 1 */
17803 if (ports[id].need_reconfig_queues == 0)
17804 ports[id].need_reconfig_queues = queue;