1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
13 #include <sys/queue.h>
15 #include <rte_common.h>
16 #include <rte_byteorder.h>
18 #include <rte_debug.h>
19 #include <rte_cycles.h>
20 #include <rte_memory.h>
21 #include <rte_memzone.h>
22 #include <rte_malloc.h>
23 #include <rte_launch.h>
25 #include <rte_per_lcore.h>
26 #include <rte_lcore.h>
27 #include <rte_atomic.h>
28 #include <rte_branch_prediction.h>
30 #include <rte_mempool.h>
31 #include <rte_interrupts.h>
33 #include <rte_ether.h>
34 #include <rte_ethdev.h>
35 #include <rte_string_fns.h>
36 #include <rte_devargs.h>
39 #include <rte_mbuf_dyn.h>
41 #include <cmdline_rdline.h>
42 #include <cmdline_parse.h>
43 #include <cmdline_parse_num.h>
44 #include <cmdline_parse_string.h>
45 #include <cmdline_parse_ipaddr.h>
46 #include <cmdline_parse_etheraddr.h>
47 #include <cmdline_socket.h>
50 #include <rte_eth_bond.h>
51 #include <rte_eth_bond_8023ad.h>
53 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
54 #include <rte_pmd_dpaa.h>
57 #include <rte_pmd_ixgbe.h>
60 #include <rte_pmd_i40e.h>
63 #include <rte_pmd_bnxt.h>
66 #include "cmdline_mtr.h"
67 #include "cmdline_tm.h"
70 static struct cmdline *testpmd_cl;
72 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
74 /* *** Help command with introduction. *** */
75 struct cmd_help_brief_result {
76 cmdline_fixed_string_t help;
79 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
81 __rte_unused void *data)
86 "Help is available for the following sections:\n\n"
87 " help control : Start and stop forwarding.\n"
88 " help display : Displaying port, stats and config "
90 " help config : Configuration information.\n"
91 " help ports : Configuring ports.\n"
92 " help registers : Reading and setting port registers.\n"
93 " help filters : Filters configuration help.\n"
94 " help traffic_management : Traffic Management commands.\n"
95 " help devices : Device related cmds.\n"
96 " help all : All of the above sections.\n\n"
101 cmdline_parse_token_string_t cmd_help_brief_help =
102 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
104 cmdline_parse_inst_t cmd_help_brief = {
105 .f = cmd_help_brief_parsed,
107 .help_str = "help: Show help",
109 (void *)&cmd_help_brief_help,
114 /* *** Help command with help sections. *** */
115 struct cmd_help_long_result {
116 cmdline_fixed_string_t help;
117 cmdline_fixed_string_t section;
120 static void cmd_help_long_parsed(void *parsed_result,
122 __rte_unused void *data)
125 struct cmd_help_long_result *res = parsed_result;
127 if (!strcmp(res->section, "all"))
130 if (show_all || !strcmp(res->section, "control")) {
135 "Control forwarding:\n"
136 "-------------------\n\n"
139 " Start packet forwarding with current configuration.\n\n"
142 " Start packet forwarding with current config"
143 " after sending one burst of packets.\n\n"
146 " Stop packet forwarding, and display accumulated"
150 " Quit to prompt.\n\n"
154 if (show_all || !strcmp(res->section, "display")) {
162 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
163 " Display information for port_id, or all.\n\n"
165 "show port port_id (module_eeprom|eeprom)\n"
166 " Display the module EEPROM or EEPROM information for port_id.\n\n"
168 "show port X rss reta (size) (mask0,mask1,...)\n"
169 " Display the rss redirection table entry indicated"
170 " by masks on port X. size is used to indicate the"
171 " hardware supported reta size\n\n"
173 "show port (port_id) rss-hash [key]\n"
174 " Display the RSS hash functions and RSS hash key of port\n\n"
176 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
177 " Clear information for port_id, or all.\n\n"
179 "show (rxq|txq) info (port_id) (queue_id)\n"
180 " Display information for configured RX/TX queue.\n\n"
182 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
183 " Display the given configuration.\n\n"
185 "read rxd (port_id) (queue_id) (rxd_id)\n"
186 " Display an RX descriptor of a port RX queue.\n\n"
188 "read txd (port_id) (queue_id) (txd_id)\n"
189 " Display a TX descriptor of a port TX queue.\n\n"
191 "ddp get list (port_id)\n"
192 " Get ddp profile info list\n\n"
194 "ddp get info (profile_path)\n"
195 " Get ddp profile information.\n\n"
197 "show vf stats (port_id) (vf_id)\n"
198 " Display a VF's statistics.\n\n"
200 "clear vf stats (port_id) (vf_id)\n"
201 " Reset a VF's statistics.\n\n"
203 "show port (port_id) pctype mapping\n"
204 " Get flow ptype to pctype mapping on a port\n\n"
206 "show port meter stats (port_id) (meter_id) (clear)\n"
207 " Get meter stats on a port\n\n"
209 "show fwd stats all\n"
210 " Display statistics for all fwd engines.\n\n"
212 "clear fwd stats all\n"
213 " Clear statistics for all fwd engines.\n\n"
215 "show port (port_id) rx_offload capabilities\n"
216 " List all per queue and per port Rx offloading"
217 " capabilities of a port\n\n"
219 "show port (port_id) rx_offload configuration\n"
220 " List port level and all queue level"
221 " Rx offloading configuration\n\n"
223 "show port (port_id) tx_offload capabilities\n"
224 " List all per queue and per port"
225 " Tx offloading capabilities of a port\n\n"
227 "show port (port_id) tx_offload configuration\n"
228 " List port level and all queue level"
229 " Tx offloading configuration\n\n"
231 "show port (port_id) tx_metadata\n"
232 " Show Tx metadata value set"
233 " for a specific port\n\n"
235 "show port (port_id) ptypes\n"
236 " Show port supported ptypes"
237 " for a specific port\n\n"
239 "show device info (<identifier>|all)"
240 " Show general information about devices probed.\n\n"
242 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
243 " Show status of rx|tx descriptor.\n\n"
245 "show port (port_id) rxq (queue_id) desc used count\n"
246 " Show current number of filled receive"
247 " packet descriptors.\n\n"
249 "show port (port_id) macs|mcast_macs"
250 " Display list of mac addresses added to port.\n\n"
252 "show port (port_id) fec capabilities"
253 " Show fec capabilities of a port.\n\n"
255 "show port (port_id) fec_mode"
256 " Show fec mode of a port.\n\n"
258 "show port (port_id) flow_ctrl"
259 " Show flow control info of a port.\n\n"
263 if (show_all || !strcmp(res->section, "config")) {
269 "Configuration changes only become active when"
270 " forwarding is started/restarted.\n\n"
273 " Reset forwarding to the default configuration.\n\n"
275 "set verbose (level)\n"
276 " Set the debug verbosity level X.\n\n"
278 "set log global|(type) (level)\n"
279 " Set the log level.\n\n"
282 " Set number of ports.\n\n"
285 " Set number of cores.\n\n"
287 "set coremask (mask)\n"
288 " Set the forwarding cores hexadecimal mask.\n\n"
290 "set portmask (mask)\n"
291 " Set the forwarding ports hexadecimal mask.\n\n"
294 " Set number of packets per burst.\n\n"
296 "set burst tx delay (microseconds) retry (num)\n"
297 " Set the transmit delay time and number of retries,"
298 " effective when retry is enabled.\n\n"
300 "set rxoffs (x[,y]*)\n"
301 " Set the offset of each packet segment on"
302 " receiving if split feature is engaged."
303 " Affects only the queues configured with split"
306 "set rxpkts (x[,y]*)\n"
307 " Set the length of each segment to scatter"
308 " packets on receiving if split feature is engaged."
309 " Affects only the queues configured with split"
312 "set txpkts (x[,y]*)\n"
313 " Set the length of each segment of TXONLY"
314 " and optionally CSUM packets.\n\n"
316 "set txsplit (off|on|rand)\n"
317 " Set the split policy for the TX packets."
318 " Right now only applicable for CSUM and TXONLY"
321 "set txtimes (x, y)\n"
322 " Set the scheduling on timestamps"
323 " timings for the TXONLY mode\n\n"
325 "set corelist (x[,y]*)\n"
326 " Set the list of forwarding cores.\n\n"
328 "set portlist (x[,y]*)\n"
329 " Set the list of forwarding ports.\n\n"
331 "set port setup on (iterator|event)\n"
332 " Select how attached port is retrieved for setup.\n\n"
334 "set tx loopback (port_id) (on|off)\n"
335 " Enable or disable tx loopback.\n\n"
337 "set all queues drop (port_id) (on|off)\n"
338 " Set drop enable bit for all queues.\n\n"
340 "set vf split drop (port_id) (vf_id) (on|off)\n"
341 " Set split drop enable bit for a VF from the PF.\n\n"
343 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
344 " Set MAC antispoof for a VF from the PF.\n\n"
346 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
347 " Enable MACsec offload.\n\n"
349 "set macsec offload (port_id) off\n"
350 " Disable MACsec offload.\n\n"
352 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
353 " Configure MACsec secure connection (SC).\n\n"
355 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
356 " Configure MACsec secure association (SA).\n\n"
358 "set vf broadcast (port_id) (vf_id) (on|off)\n"
359 " Set VF broadcast for a VF from the PF.\n\n"
361 "vlan set stripq (on|off) (port_id,queue_id)\n"
362 " Set the VLAN strip for a queue on a port.\n\n"
364 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
365 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
367 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
368 " Set VLAN insert for a VF from the PF.\n\n"
370 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
371 " Set VLAN antispoof for a VF from the PF.\n\n"
373 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
374 " Set VLAN tag for a VF from the PF.\n\n"
376 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
377 " Set a VF's max bandwidth(Mbps).\n\n"
379 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
380 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
382 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
383 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
385 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
386 " Set some TCs' strict link priority mode on a physical port.\n\n"
388 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
389 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
391 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
392 " Set the VLAN strip or filter or qinq strip or extend\n\n"
394 "vlan set (inner|outer) tpid (value) (port_id)\n"
395 " Set the VLAN TPID for Packet Filtering on"
398 "rx_vlan add (vlan_id|all) (port_id)\n"
399 " Add a vlan_id, or all identifiers, to the set"
400 " of VLAN identifiers filtered by port_id.\n\n"
402 "rx_vlan rm (vlan_id|all) (port_id)\n"
403 " Remove a vlan_id, or all identifiers, from the set"
404 " of VLAN identifiers filtered by port_id.\n\n"
406 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
407 " Add a vlan_id, to the set of VLAN identifiers"
408 "filtered for VF(s) from port_id.\n\n"
410 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
411 " Remove a vlan_id, to the set of VLAN identifiers"
412 "filtered for VF(s) from port_id.\n\n"
414 "rx_vxlan_port add (udp_port) (port_id)\n"
415 " Add an UDP port for VXLAN packet filter on a port\n\n"
417 "rx_vxlan_port rm (udp_port) (port_id)\n"
418 " Remove an UDP port for VXLAN packet filter on a port\n\n"
420 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
421 " Set hardware insertion of VLAN IDs (single or double VLAN "
422 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
424 "tx_vlan set pvid port_id vlan_id (on|off)\n"
425 " Set port based TX VLAN insertion.\n\n"
427 "tx_vlan reset (port_id)\n"
428 " Disable hardware insertion of a VLAN header in"
429 " packets sent on a port.\n\n"
431 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
432 " Select hardware or software calculation of the"
433 " checksum when transmitting a packet using the"
434 " csum forward engine.\n"
435 " ip|udp|tcp|sctp always concern the inner layer.\n"
436 " outer-ip concerns the outer IP layer in"
437 " outer-udp concerns the outer UDP layer in"
438 " case the packet is recognized as a tunnel packet by"
439 " the forward engine (vxlan, gre and ipip are supported)\n"
440 " Please check the NIC datasheet for HW limits.\n\n"
442 "csum parse-tunnel (on|off) (tx_port_id)\n"
443 " If disabled, treat tunnel packets as non-tunneled"
444 " packets (treat inner headers as payload). The port\n"
445 " argument is the port used for TX in csum forward"
448 "csum show (port_id)\n"
449 " Display tx checksum offload configuration\n\n"
451 "tso set (segsize) (portid)\n"
452 " Enable TCP Segmentation Offload in csum forward"
454 " Please check the NIC datasheet for HW limits.\n\n"
457 " Display the status of TCP Segmentation Offload.\n\n"
459 "set port (port_id) gro on|off\n"
460 " Enable or disable Generic Receive Offload in"
461 " csum forwarding engine.\n\n"
463 "show port (port_id) gro\n"
464 " Display GRO configuration.\n\n"
466 "set gro flush (cycles)\n"
467 " Set the cycle to flush GROed packets from"
468 " reassembly tables.\n\n"
470 "set port (port_id) gso (on|off)"
471 " Enable or disable Generic Segmentation Offload in"
472 " csum forwarding engine.\n\n"
474 "set gso segsz (length)\n"
475 " Set max packet length for output GSO segments,"
476 " including packet header and payload.\n\n"
478 "show port (port_id) gso\n"
479 " Show GSO configuration.\n\n"
482 " Set packet forwarding mode.\n\n"
484 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 " Add a MAC address on port_id.\n\n"
487 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 " Remove a MAC address from port_id.\n\n"
490 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
491 " Set the default MAC address for port_id.\n\n"
493 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
494 " Add a MAC address for a VF on the port.\n\n"
496 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
497 " Set the MAC address for a VF from the PF.\n\n"
499 "set eth-peer (port_id) (peer_addr)\n"
500 " set the peer address for certain port.\n\n"
502 "set port (port_id) uta (mac_address|all) (on|off)\n"
503 " Add/Remove a or all unicast hash filter(s)"
506 "set promisc (port_id|all) (on|off)\n"
507 " Set the promiscuous mode on port_id, or all.\n\n"
509 "set allmulti (port_id|all) (on|off)\n"
510 " Set the allmulti mode on port_id, or all.\n\n"
512 "set vf promisc (port_id) (vf_id) (on|off)\n"
513 " Set unicast promiscuous mode for a VF from the PF.\n\n"
515 "set vf allmulti (port_id) (vf_id) (on|off)\n"
516 " Set multicast promiscuous mode for a VF from the PF.\n\n"
518 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
519 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
520 " (on|off) autoneg (on|off) (port_id)\n"
521 "set flow_ctrl rx (on|off) (portid)\n"
522 "set flow_ctrl tx (on|off) (portid)\n"
523 "set flow_ctrl high_water (high_water) (portid)\n"
524 "set flow_ctrl low_water (low_water) (portid)\n"
525 "set flow_ctrl pause_time (pause_time) (portid)\n"
526 "set flow_ctrl send_xon (send_xon) (portid)\n"
527 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
528 "set flow_ctrl autoneg (on|off) (port_id)\n"
529 " Set the link flow control parameter on a port.\n\n"
531 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
532 " (low_water) (pause_time) (priority) (port_id)\n"
533 " Set the priority flow control parameter on a"
536 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
537 " Set statistics mapping (qmapping 0..15) for RX/TX"
539 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
540 " on port 0 to mapping 5.\n\n"
542 "set xstats-hide-zero on|off\n"
543 " Set the option to hide the zero values"
544 " for xstats display.\n"
546 "set record-core-cycles on|off\n"
547 " Set the option to enable measurement of CPU cycles.\n"
549 "set record-burst-stats on|off\n"
550 " Set the option to enable display of RX and TX bursts.\n"
552 "set port (port_id) vf (vf_id) rx|tx on|off\n"
553 " Enable/Disable a VF receive/tranmit from a port\n\n"
555 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
557 " AUPE:accepts untagged VLAN;"
558 "ROPE:accept unicast hash\n\n"
559 " BAM:accepts broadcast packets;"
560 "MPE:accepts all multicast packets\n\n"
561 " Enable/Disable a VF receive mode of a port\n\n"
563 "set port (port_id) queue (queue_id) rate (rate_num)\n"
564 " Set rate limit for a queue of a port\n\n"
566 "set port (port_id) vf (vf_id) rate (rate_num) "
567 "queue_mask (queue_mask_value)\n"
568 " Set rate limit for queues in VF of a port\n\n"
570 "set port (port_id) mirror-rule (rule_id)"
571 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
572 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
573 " Set pool or vlan type mirror rule on a port.\n"
574 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
575 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
578 "set port (port_id) mirror-rule (rule_id)"
579 " (uplink-mirror|downlink-mirror) dst-pool"
580 " (pool_id) (on|off)\n"
581 " Set uplink or downlink type mirror rule on a port.\n"
582 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
583 " 0 on' enable mirror income traffic to pool 0.\n\n"
585 "reset port (port_id) mirror-rule (rule_id)\n"
586 " Reset a mirror rule.\n\n"
588 "set flush_rx (on|off)\n"
589 " Flush (default) or don't flush RX streams before"
590 " forwarding. Mainly used with PCAP drivers.\n\n"
592 "set bypass mode (normal|bypass|isolate) (port_id)\n"
593 " Set the bypass mode for the lowest port on bypass enabled"
596 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
597 "mode (normal|bypass|isolate) (port_id)\n"
598 " Set the event required to initiate specified bypass mode for"
599 " the lowest port on a bypass enabled NIC where:\n"
600 " timeout = enable bypass after watchdog timeout.\n"
601 " os_on = enable bypass when OS/board is powered on.\n"
602 " os_off = enable bypass when OS/board is powered off.\n"
603 " power_on = enable bypass when power supply is turned on.\n"
604 " power_off = enable bypass when power supply is turned off."
607 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
608 " Set the bypass watchdog timeout to 'n' seconds"
609 " where 0 = instant.\n\n"
611 "show bypass config (port_id)\n"
612 " Show the bypass configuration for a bypass enabled NIC"
613 " using the lowest port on the NIC.\n\n"
616 "create bonded device (mode) (socket)\n"
617 " Create a new bonded device with specific bonding mode and socket.\n\n"
619 "add bonding slave (slave_id) (port_id)\n"
620 " Add a slave device to a bonded device.\n\n"
622 "remove bonding slave (slave_id) (port_id)\n"
623 " Remove a slave device from a bonded device.\n\n"
625 "set bonding mode (value) (port_id)\n"
626 " Set the bonding mode on a bonded device.\n\n"
628 "set bonding primary (slave_id) (port_id)\n"
629 " Set the primary slave for a bonded device.\n\n"
631 "show bonding config (port_id)\n"
632 " Show the bonding config for port_id.\n\n"
634 "set bonding mac_addr (port_id) (address)\n"
635 " Set the MAC address of a bonded device.\n\n"
637 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
638 " Set Aggregation mode for IEEE802.3AD (mode 4)"
640 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
641 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
643 "set bonding mon_period (port_id) (value)\n"
644 " Set the bonding link status monitoring polling period in ms.\n\n"
646 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
647 " Enable/disable dedicated queues for LACP control traffic.\n\n"
650 "set link-up port (port_id)\n"
651 " Set link up for a port.\n\n"
653 "set link-down port (port_id)\n"
654 " Set link down for a port.\n\n"
656 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
657 " Load a profile package on a port\n\n"
659 "ddp del (port_id) (backup_profile_path)\n"
660 " Delete a profile package from a port\n\n"
662 "ptype mapping get (port_id) (valid_only)\n"
663 " Get ptype mapping on a port\n\n"
665 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
666 " Replace target with the pkt_type in ptype mapping\n\n"
668 "ptype mapping reset (port_id)\n"
669 " Reset ptype mapping on a port\n\n"
671 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
672 " Update a ptype mapping item on a port\n\n"
674 "set port (port_id) ptype_mask (ptype_mask)\n"
675 " set packet types classification for a specific port\n\n"
677 "set port (port_id) queue-region region_id (value) "
678 "queue_start_index (value) queue_num (value)\n"
679 " Set a queue region on a port\n\n"
681 "set port (port_id) queue-region region_id (value) "
683 " Set a flowtype region index on a port\n\n"
685 "set port (port_id) queue-region UP (value) region_id (value)\n"
686 " Set the mapping of User Priority to "
687 "queue region on a port\n\n"
689 "set port (port_id) queue-region flush (on|off)\n"
690 " flush all queue region related configuration\n\n"
692 "show port meter cap (port_id)\n"
693 " Show port meter capability information\n\n"
695 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
696 " meter profile add - srtcm rfc 2697\n\n"
698 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
699 " meter profile add - trtcm rfc 2698\n\n"
701 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
702 " meter profile add - trtcm rfc 4115\n\n"
704 "del port meter profile (port_id) (profile_id)\n"
705 " meter profile delete\n\n"
707 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
708 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
709 "(dscp_tbl_entry63)]\n"
712 "enable port meter (port_id) (mtr_id)\n"
715 "disable port meter (port_id) (mtr_id)\n"
718 "del port meter (port_id) (mtr_id)\n"
721 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
722 "y_actions (actions) r_actions (actions)\n"
723 " meter policy add\n\n"
725 "del port meter policy (port_id) (policy_id)\n"
726 " meter policy delete\n\n"
728 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
729 " meter update meter profile\n\n"
731 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
732 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
733 " update meter dscp table entries\n\n"
735 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
736 "(action0) [(action1) (action2)]\n"
737 " meter update policer action\n\n"
739 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
740 " meter update stats\n\n"
742 "show port (port_id) queue-region\n"
743 " show all queue region related configuration info\n\n"
745 "set port (port_id) fec_mode auto|off|rs|baser\n"
746 " set fec mode for a specific port\n\n"
748 , list_pkt_forwarding_modes()
752 if (show_all || !strcmp(res->section, "ports")) {
758 "----------------\n\n"
760 "port start (port_id|all)\n"
761 " Start all ports or port_id.\n\n"
763 "port stop (port_id|all)\n"
764 " Stop all ports or port_id.\n\n"
766 "port close (port_id|all)\n"
767 " Close all ports or port_id.\n\n"
769 "port reset (port_id|all)\n"
770 " Reset all ports or port_id.\n\n"
772 "port attach (ident)\n"
773 " Attach physical or virtual dev by pci address or virtual device name\n\n"
775 "port detach (port_id)\n"
776 " Detach physical or virtual dev by port_id\n\n"
778 "port config (port_id|all)"
779 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
780 " duplex (half|full|auto)\n"
781 " Set speed and duplex for all ports or port_id\n\n"
783 "port config (port_id|all) loopback (mode)\n"
784 " Set loopback mode for all ports or port_id\n\n"
786 "port config all (rxq|txq|rxd|txd) (value)\n"
787 " Set number for rxq/txq/rxd/txd.\n\n"
789 "port config all max-pkt-len (value)\n"
790 " Set the max packet length.\n\n"
792 "port config all max-lro-pkt-size (value)\n"
793 " Set the max LRO aggregated packet size.\n\n"
795 "port config all drop-en (on|off)\n"
796 " Enable or disable packet drop on all RX queues of all ports when no "
797 "receive buffers available.\n\n"
799 "port config all rss (all|default|ip|tcp|udp|sctp|"
800 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
801 "level-outer|level-inner|<flowtype_id>)\n"
802 " Set the RSS mode.\n\n"
804 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
805 " Set the RSS redirection table.\n\n"
807 "port config (port_id) dcb vt (on|off) (traffic_class)"
809 " Set the DCB mode.\n\n"
811 "port config all burst (value)\n"
812 " Set the number of packets per burst.\n\n"
814 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
816 " Set the ring prefetch/host/writeback threshold"
817 " for tx/rx queue.\n\n"
819 "port config all (txfreet|txrst|rxfreet) (value)\n"
820 " Set free threshold for rx/tx, or set"
821 " tx rs bit threshold.\n\n"
822 "port config mtu X value\n"
823 " Set the MTU of port X to a given value\n\n"
825 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
826 " Set a rx/tx queue's ring size configuration, the new"
827 " value will take effect after command that (re-)start the port"
828 " or command that setup the specific queue\n\n"
830 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
831 " Start/stop a rx/tx queue of port X. Only take effect"
832 " when port X is started\n\n"
834 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
835 " Switch on/off a deferred start of port X rx/tx queue. Only"
836 " take effect when port X is stopped.\n\n"
838 "port (port_id) (rxq|txq) (queue_id) setup\n"
839 " Setup a rx/tx queue of port X.\n\n"
841 "port config (port_id) pctype mapping reset\n"
842 " Reset flow type to pctype mapping on a port\n\n"
844 "port config (port_id) pctype mapping update"
845 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 " Update a flow type to pctype mapping item on a port\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset get|set|clear field\n"
851 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
853 "port config (port_id) pctype (pctype_id) hash_inset|"
854 "fdir_inset|fdir_flx_inset clear all"
855 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
857 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
858 " Add/remove UDP tunnel port for tunneling offload\n\n"
860 "port config <port_id> rx_offload vlan_strip|"
861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 "outer_ipv4_cksum|macsec_strip|header_split|"
863 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
864 "buffer_split|timestamp|security|keep_crc on|off\n"
865 " Enable or disable a per port Rx offloading"
866 " on all Rx queues of a port\n\n"
868 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 "outer_ipv4_cksum|macsec_strip|header_split|"
871 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
872 "buffer_split|timestamp|security|keep_crc on|off\n"
873 " Enable or disable a per queue Rx offloading"
874 " only on a specific Rx queue\n\n"
876 "port config (port_id) tx_offload vlan_insert|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
880 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
882 " Enable or disable a per port Tx offloading"
883 " on all Tx queues of a port\n\n"
885 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
891 " Enable or disable a per queue Tx offloading"
892 " only on a specific Tx queue\n\n"
894 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 " Load an eBPF program as a callback"
896 " for particular RX/TX queue\n\n"
898 "bpf-unload rx|tx (port) (queue)\n"
899 " Unload previously loaded eBPF program"
900 " for particular RX/TX queue\n\n"
902 "port config (port_id) tx_metadata (value)\n"
903 " Set Tx metadata value per port. Testpmd will add this value"
904 " to any Tx packet sent from this port\n\n"
906 "port config (port_id) dynf (name) set|clear\n"
907 " Register a dynf and Set/clear this flag on Tx. "
908 "Testpmd will set this value to any Tx packet "
909 "sent from this port\n\n"
911 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
912 " Cleanup txq mbufs for a specific Tx queue\n\n"
916 if (show_all || !strcmp(res->section, "registers")) {
924 "read reg (port_id) (address)\n"
925 " Display value of a port register.\n\n"
927 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
928 " Display a port register bit field.\n\n"
930 "read regbit (port_id) (address) (bit_x)\n"
931 " Display a single port register bit.\n\n"
933 "write reg (port_id) (address) (value)\n"
934 " Set value of a port register.\n\n"
936 "write regfield (port_id) (address) (bit_x) (bit_y)"
938 " Set bit field of a port register.\n\n"
940 "write regbit (port_id) (address) (bit_x) (value)\n"
941 " Set single bit value of a port register.\n\n"
944 if (show_all || !strcmp(res->section, "filters")) {
953 "flow_director_filter (port_id) mode raw (add|del|update)"
954 " flow (flow_id) (drop|fwd) queue (queue_id)"
955 " fd_id (fd_id_value) packet (packet file name)\n"
956 " Add/Del a raw type flow director filter.\n\n"
959 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
960 " src_mask (ipv4_src) (ipv6_src) (src_port)"
961 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
962 " Set flow director IP mask.\n\n"
964 "flow_director_mask (port_id) mode MAC-VLAN"
965 " vlan (vlan_value)\n"
966 " Set flow director MAC-VLAN mask.\n\n"
968 "flow_director_mask (port_id) mode Tunnel"
969 " vlan (vlan_value) mac (mac_value)"
970 " tunnel-type (tunnel_type_value)"
971 " tunnel-id (tunnel_id_value)\n"
972 " Set flow director Tunnel mask.\n\n"
974 "flow_director_flex_payload (port_id)"
975 " (raw|l2|l3|l4) (config)\n"
976 " Configure flex payload selection.\n\n"
978 "flow validate {port_id}"
979 " [group {group_id}] [priority {level}]"
980 " [ingress] [egress]"
981 " pattern {item} [/ {item} [...]] / end"
982 " actions {action} [/ {action} [...]] / end\n"
983 " Check whether a flow rule can be created.\n\n"
985 "flow create {port_id}"
986 " [group {group_id}] [priority {level}]"
987 " [ingress] [egress]"
988 " pattern {item} [/ {item} [...]] / end"
989 " actions {action} [/ {action} [...]] / end\n"
990 " Create a flow rule.\n\n"
992 "flow destroy {port_id} rule {rule_id} [...]\n"
993 " Destroy specific flow rules.\n\n"
995 "flow flush {port_id}\n"
996 " Destroy all flow rules.\n\n"
998 "flow query {port_id} {rule_id} {action}\n"
999 " Query an existing flow rule.\n\n"
1001 "flow list {port_id} [group {group_id}] [...]\n"
1002 " List existing flow rules sorted by priority,"
1003 " filtered by group identifiers.\n\n"
1005 "flow isolate {port_id} {boolean}\n"
1006 " Restrict ingress traffic to the defined"
1009 "flow aged {port_id} [destroy]\n"
1010 " List and destroy aged flows"
1013 "flow indirect_action {port_id} create"
1014 " [action_id {indirect_action_id}]"
1015 " [ingress] [egress]"
1016 " action {action} / end\n"
1017 " Create indirect action.\n\n"
1019 "flow indirect_action {port_id} update"
1020 " {indirect_action_id} action {action} / end\n"
1021 " Update indirect action.\n\n"
1023 "flow indirect_action {port_id} destroy"
1024 " action_id {indirect_action_id} [...]\n"
1025 " Destroy specific indirect actions.\n\n"
1027 "flow indirect_action {port_id} query"
1028 " {indirect_action_id}\n"
1029 " Query an existing indirect action.\n\n"
1031 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1032 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1033 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1034 " Configure the VXLAN encapsulation for flows.\n\n"
1036 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1037 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1038 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1039 " eth-dst (eth-dst)\n"
1040 " Configure the VXLAN encapsulation for flows.\n\n"
1042 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1043 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1044 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1045 " eth-dst (eth-dst)\n"
1046 " Configure the VXLAN encapsulation for flows.\n\n"
1048 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1049 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1051 " Configure the NVGRE encapsulation for flows.\n\n"
1053 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1054 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1055 " eth-src (eth-src) eth-dst (eth-dst)\n"
1056 " Configure the NVGRE encapsulation for flows.\n\n"
1058 "set raw_encap {flow items}\n"
1059 " Configure the encapsulation with raw data.\n\n"
1061 "set raw_decap {flow items}\n"
1062 " Configure the decapsulation with raw data.\n\n"
1067 if (show_all || !strcmp(res->section, "traffic_management")) {
1071 "Traffic Management:\n"
1073 "show port tm cap (port_id)\n"
1074 " Display the port TM capability.\n\n"
1076 "show port tm level cap (port_id) (level_id)\n"
1077 " Display the port TM hierarchical level capability.\n\n"
1079 "show port tm node cap (port_id) (node_id)\n"
1080 " Display the port TM node capability.\n\n"
1082 "show port tm node type (port_id) (node_id)\n"
1083 " Display the port TM node type.\n\n"
1085 "show port tm node stats (port_id) (node_id) (clear)\n"
1086 " Display the port TM node stats.\n\n"
1088 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1089 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1090 " (packet_length_adjust) (packet_mode)\n"
1091 " Add port tm node private shaper profile.\n\n"
1093 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1094 " Delete port tm node private shaper profile.\n\n"
1096 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1097 " (shaper_profile_id)\n"
1098 " Add/update port tm node shared shaper.\n\n"
1100 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1101 " Delete port tm node shared shaper.\n\n"
1103 "set port tm node shaper profile (port_id) (node_id)"
1104 " (shaper_profile_id)\n"
1105 " Set port tm node shaper profile.\n\n"
1107 "add port tm node wred profile (port_id) (wred_profile_id)"
1108 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1109 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1110 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1111 " Add port tm node wred profile.\n\n"
1113 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1114 " Delete port tm node wred profile.\n\n"
1116 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1117 " (priority) (weight) (level_id) (shaper_profile_id)"
1118 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1119 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1120 " Add port tm nonleaf node.\n\n"
1122 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1123 " (priority) (weight) (level_id) (shaper_profile_id)"
1124 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1125 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1126 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1128 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1129 " (priority) (weight) (level_id) (shaper_profile_id)"
1130 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1131 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1132 " Add port tm leaf node.\n\n"
1134 "del port tm node (port_id) (node_id)\n"
1135 " Delete port tm node.\n\n"
1137 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1138 " (priority) (weight)\n"
1139 " Set port tm node parent.\n\n"
1141 "suspend port tm node (port_id) (node_id)"
1142 " Suspend tm node.\n\n"
1144 "resume port tm node (port_id) (node_id)"
1145 " Resume tm node.\n\n"
1147 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1148 " Commit tm hierarchy.\n\n"
1150 "set port tm mark ip_ecn (port) (green) (yellow)"
1152 " Enables/Disables the traffic management marking"
1153 " for IP ECN (Explicit Congestion Notification)"
1154 " packets on a given port\n\n"
1156 "set port tm mark ip_dscp (port) (green) (yellow)"
1158 " Enables/Disables the traffic management marking"
1159 " on the port for IP dscp packets\n\n"
1161 "set port tm mark vlan_dei (port) (green) (yellow)"
1163 " Enables/Disables the traffic management marking"
1164 " on the port for VLAN packets with DEI enabled\n\n"
1168 if (show_all || !strcmp(res->section, "devices")) {
1172 "Device Operations:\n"
1174 "device detach (identifier)\n"
1175 " Detach device by identifier.\n\n"
1181 cmdline_parse_token_string_t cmd_help_long_help =
1182 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1184 cmdline_parse_token_string_t cmd_help_long_section =
1185 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1186 "all#control#display#config#"
1187 "ports#registers#filters#traffic_management#devices");
1189 cmdline_parse_inst_t cmd_help_long = {
1190 .f = cmd_help_long_parsed,
1192 .help_str = "help all|control|display|config|ports|register|"
1193 "filters|traffic_management|devices: "
1196 (void *)&cmd_help_long_help,
1197 (void *)&cmd_help_long_section,
1203 /* *** start/stop/close all ports *** */
1204 struct cmd_operate_port_result {
1205 cmdline_fixed_string_t keyword;
1206 cmdline_fixed_string_t name;
1207 cmdline_fixed_string_t value;
1210 static void cmd_operate_port_parsed(void *parsed_result,
1211 __rte_unused struct cmdline *cl,
1212 __rte_unused void *data)
1214 struct cmd_operate_port_result *res = parsed_result;
1216 if (!strcmp(res->name, "start"))
1217 start_port(RTE_PORT_ALL);
1218 else if (!strcmp(res->name, "stop"))
1219 stop_port(RTE_PORT_ALL);
1220 else if (!strcmp(res->name, "close"))
1221 close_port(RTE_PORT_ALL);
1222 else if (!strcmp(res->name, "reset"))
1223 reset_port(RTE_PORT_ALL);
1225 fprintf(stderr, "Unknown parameter\n");
1228 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1229 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1231 cmdline_parse_token_string_t cmd_operate_port_all_port =
1232 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1233 "start#stop#close#reset");
1234 cmdline_parse_token_string_t cmd_operate_port_all_all =
1235 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1237 cmdline_parse_inst_t cmd_operate_port = {
1238 .f = cmd_operate_port_parsed,
1240 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1242 (void *)&cmd_operate_port_all_cmd,
1243 (void *)&cmd_operate_port_all_port,
1244 (void *)&cmd_operate_port_all_all,
1249 /* *** start/stop/close specific port *** */
1250 struct cmd_operate_specific_port_result {
1251 cmdline_fixed_string_t keyword;
1252 cmdline_fixed_string_t name;
1256 static void cmd_operate_specific_port_parsed(void *parsed_result,
1257 __rte_unused struct cmdline *cl,
1258 __rte_unused void *data)
1260 struct cmd_operate_specific_port_result *res = parsed_result;
1262 if (!strcmp(res->name, "start"))
1263 start_port(res->value);
1264 else if (!strcmp(res->name, "stop"))
1265 stop_port(res->value);
1266 else if (!strcmp(res->name, "close"))
1267 close_port(res->value);
1268 else if (!strcmp(res->name, "reset"))
1269 reset_port(res->value);
1271 fprintf(stderr, "Unknown parameter\n");
1274 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1275 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1277 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1278 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1279 name, "start#stop#close#reset");
1280 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1281 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1284 cmdline_parse_inst_t cmd_operate_specific_port = {
1285 .f = cmd_operate_specific_port_parsed,
1287 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1289 (void *)&cmd_operate_specific_port_cmd,
1290 (void *)&cmd_operate_specific_port_port,
1291 (void *)&cmd_operate_specific_port_id,
1296 /* *** enable port setup (after attach) via iterator or event *** */
1297 struct cmd_set_port_setup_on_result {
1298 cmdline_fixed_string_t set;
1299 cmdline_fixed_string_t port;
1300 cmdline_fixed_string_t setup;
1301 cmdline_fixed_string_t on;
1302 cmdline_fixed_string_t mode;
1305 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1306 __rte_unused struct cmdline *cl,
1307 __rte_unused void *data)
1309 struct cmd_set_port_setup_on_result *res = parsed_result;
1311 if (strcmp(res->mode, "event") == 0)
1312 setup_on_probe_event = true;
1313 else if (strcmp(res->mode, "iterator") == 0)
1314 setup_on_probe_event = false;
1316 fprintf(stderr, "Unknown mode\n");
1319 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1320 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1322 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1323 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1325 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1326 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1328 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1329 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1331 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1332 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1333 mode, "iterator#event");
1335 cmdline_parse_inst_t cmd_set_port_setup_on = {
1336 .f = cmd_set_port_setup_on_parsed,
1338 .help_str = "set port setup on iterator|event",
1340 (void *)&cmd_set_port_setup_on_set,
1341 (void *)&cmd_set_port_setup_on_port,
1342 (void *)&cmd_set_port_setup_on_setup,
1343 (void *)&cmd_set_port_setup_on_on,
1344 (void *)&cmd_set_port_setup_on_mode,
1349 /* *** attach a specified port *** */
1350 struct cmd_operate_attach_port_result {
1351 cmdline_fixed_string_t port;
1352 cmdline_fixed_string_t keyword;
1353 cmdline_multi_string_t identifier;
1356 static void cmd_operate_attach_port_parsed(void *parsed_result,
1357 __rte_unused struct cmdline *cl,
1358 __rte_unused void *data)
1360 struct cmd_operate_attach_port_result *res = parsed_result;
1362 if (!strcmp(res->keyword, "attach"))
1363 attach_port(res->identifier);
1365 fprintf(stderr, "Unknown parameter\n");
1368 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1369 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1371 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1372 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1374 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1375 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1376 identifier, TOKEN_STRING_MULTI);
1378 cmdline_parse_inst_t cmd_operate_attach_port = {
1379 .f = cmd_operate_attach_port_parsed,
1381 .help_str = "port attach <identifier>: "
1382 "(identifier: pci address or virtual dev name)",
1384 (void *)&cmd_operate_attach_port_port,
1385 (void *)&cmd_operate_attach_port_keyword,
1386 (void *)&cmd_operate_attach_port_identifier,
1391 /* *** detach a specified port *** */
1392 struct cmd_operate_detach_port_result {
1393 cmdline_fixed_string_t port;
1394 cmdline_fixed_string_t keyword;
1398 static void cmd_operate_detach_port_parsed(void *parsed_result,
1399 __rte_unused struct cmdline *cl,
1400 __rte_unused void *data)
1402 struct cmd_operate_detach_port_result *res = parsed_result;
1404 if (!strcmp(res->keyword, "detach")) {
1405 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1406 detach_port_device(res->port_id);
1408 fprintf(stderr, "Unknown parameter\n");
1412 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1413 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1415 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1416 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1418 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1419 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1420 port_id, RTE_UINT16);
1422 cmdline_parse_inst_t cmd_operate_detach_port = {
1423 .f = cmd_operate_detach_port_parsed,
1425 .help_str = "port detach <port_id>",
1427 (void *)&cmd_operate_detach_port_port,
1428 (void *)&cmd_operate_detach_port_keyword,
1429 (void *)&cmd_operate_detach_port_port_id,
1434 /* *** detach device by identifier *** */
1435 struct cmd_operate_detach_device_result {
1436 cmdline_fixed_string_t device;
1437 cmdline_fixed_string_t keyword;
1438 cmdline_fixed_string_t identifier;
1441 static void cmd_operate_detach_device_parsed(void *parsed_result,
1442 __rte_unused struct cmdline *cl,
1443 __rte_unused void *data)
1445 struct cmd_operate_detach_device_result *res = parsed_result;
1447 if (!strcmp(res->keyword, "detach"))
1448 detach_devargs(res->identifier);
1450 fprintf(stderr, "Unknown parameter\n");
1453 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1454 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1456 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1457 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1459 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1460 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1463 cmdline_parse_inst_t cmd_operate_detach_device = {
1464 .f = cmd_operate_detach_device_parsed,
1466 .help_str = "device detach <identifier>:"
1467 "(identifier: pci address or virtual dev name)",
1469 (void *)&cmd_operate_detach_device_device,
1470 (void *)&cmd_operate_detach_device_keyword,
1471 (void *)&cmd_operate_detach_device_identifier,
1475 /* *** configure speed for all ports *** */
1476 struct cmd_config_speed_all {
1477 cmdline_fixed_string_t port;
1478 cmdline_fixed_string_t keyword;
1479 cmdline_fixed_string_t all;
1480 cmdline_fixed_string_t item1;
1481 cmdline_fixed_string_t item2;
1482 cmdline_fixed_string_t value1;
1483 cmdline_fixed_string_t value2;
1487 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1492 if (!strcmp(duplexstr, "half")) {
1493 duplex = ETH_LINK_HALF_DUPLEX;
1494 } else if (!strcmp(duplexstr, "full")) {
1495 duplex = ETH_LINK_FULL_DUPLEX;
1496 } else if (!strcmp(duplexstr, "auto")) {
1497 duplex = ETH_LINK_FULL_DUPLEX;
1499 fprintf(stderr, "Unknown duplex parameter\n");
1503 if (!strcmp(speedstr, "10")) {
1504 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1505 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1506 } else if (!strcmp(speedstr, "100")) {
1507 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1508 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1510 if (duplex != ETH_LINK_FULL_DUPLEX) {
1511 fprintf(stderr, "Invalid speed/duplex parameters\n");
1514 if (!strcmp(speedstr, "1000")) {
1515 *speed = ETH_LINK_SPEED_1G;
1516 } else if (!strcmp(speedstr, "10000")) {
1517 *speed = ETH_LINK_SPEED_10G;
1518 } else if (!strcmp(speedstr, "25000")) {
1519 *speed = ETH_LINK_SPEED_25G;
1520 } else if (!strcmp(speedstr, "40000")) {
1521 *speed = ETH_LINK_SPEED_40G;
1522 } else if (!strcmp(speedstr, "50000")) {
1523 *speed = ETH_LINK_SPEED_50G;
1524 } else if (!strcmp(speedstr, "100000")) {
1525 *speed = ETH_LINK_SPEED_100G;
1526 } else if (!strcmp(speedstr, "200000")) {
1527 *speed = ETH_LINK_SPEED_200G;
1528 } else if (!strcmp(speedstr, "auto")) {
1529 *speed = ETH_LINK_SPEED_AUTONEG;
1531 fprintf(stderr, "Unknown speed parameter\n");
1536 if (*speed != ETH_LINK_SPEED_AUTONEG)
1537 *speed |= ETH_LINK_SPEED_FIXED;
1543 cmd_config_speed_all_parsed(void *parsed_result,
1544 __rte_unused struct cmdline *cl,
1545 __rte_unused void *data)
1547 struct cmd_config_speed_all *res = parsed_result;
1548 uint32_t link_speed;
1551 if (!all_ports_stopped()) {
1552 fprintf(stderr, "Please stop all ports first\n");
1556 if (parse_and_check_speed_duplex(res->value1, res->value2,
1560 RTE_ETH_FOREACH_DEV(pid) {
1561 ports[pid].dev_conf.link_speeds = link_speed;
1564 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1567 cmdline_parse_token_string_t cmd_config_speed_all_port =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1569 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1572 cmdline_parse_token_string_t cmd_config_speed_all_all =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1574 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1575 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1576 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1577 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1578 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1579 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1581 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1582 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1585 cmdline_parse_inst_t cmd_config_speed_all = {
1586 .f = cmd_config_speed_all_parsed,
1588 .help_str = "port config all speed "
1589 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1592 (void *)&cmd_config_speed_all_port,
1593 (void *)&cmd_config_speed_all_keyword,
1594 (void *)&cmd_config_speed_all_all,
1595 (void *)&cmd_config_speed_all_item1,
1596 (void *)&cmd_config_speed_all_value1,
1597 (void *)&cmd_config_speed_all_item2,
1598 (void *)&cmd_config_speed_all_value2,
1603 /* *** configure speed for specific port *** */
1604 struct cmd_config_speed_specific {
1605 cmdline_fixed_string_t port;
1606 cmdline_fixed_string_t keyword;
1608 cmdline_fixed_string_t item1;
1609 cmdline_fixed_string_t item2;
1610 cmdline_fixed_string_t value1;
1611 cmdline_fixed_string_t value2;
1615 cmd_config_speed_specific_parsed(void *parsed_result,
1616 __rte_unused struct cmdline *cl,
1617 __rte_unused void *data)
1619 struct cmd_config_speed_specific *res = parsed_result;
1620 uint32_t link_speed;
1622 if (port_id_is_invalid(res->id, ENABLED_WARN))
1625 if (!port_is_stopped(res->id)) {
1626 fprintf(stderr, "Please stop port %d first\n", res->id);
1630 if (parse_and_check_speed_duplex(res->value1, res->value2,
1634 ports[res->id].dev_conf.link_speeds = link_speed;
1636 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1640 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1641 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1643 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1646 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1647 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1648 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1651 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1653 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1654 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1657 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1661 cmdline_parse_inst_t cmd_config_speed_specific = {
1662 .f = cmd_config_speed_specific_parsed,
1664 .help_str = "port config <port_id> speed "
1665 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1668 (void *)&cmd_config_speed_specific_port,
1669 (void *)&cmd_config_speed_specific_keyword,
1670 (void *)&cmd_config_speed_specific_id,
1671 (void *)&cmd_config_speed_specific_item1,
1672 (void *)&cmd_config_speed_specific_value1,
1673 (void *)&cmd_config_speed_specific_item2,
1674 (void *)&cmd_config_speed_specific_value2,
1679 /* *** configure loopback for all ports *** */
1680 struct cmd_config_loopback_all {
1681 cmdline_fixed_string_t port;
1682 cmdline_fixed_string_t keyword;
1683 cmdline_fixed_string_t all;
1684 cmdline_fixed_string_t item;
1689 cmd_config_loopback_all_parsed(void *parsed_result,
1690 __rte_unused struct cmdline *cl,
1691 __rte_unused void *data)
1693 struct cmd_config_loopback_all *res = parsed_result;
1696 if (!all_ports_stopped()) {
1697 fprintf(stderr, "Please stop all ports first\n");
1701 RTE_ETH_FOREACH_DEV(pid) {
1702 ports[pid].dev_conf.lpbk_mode = res->mode;
1705 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1708 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1709 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1710 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1711 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1713 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1715 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1718 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1719 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1721 cmdline_parse_inst_t cmd_config_loopback_all = {
1722 .f = cmd_config_loopback_all_parsed,
1724 .help_str = "port config all loopback <mode>",
1726 (void *)&cmd_config_loopback_all_port,
1727 (void *)&cmd_config_loopback_all_keyword,
1728 (void *)&cmd_config_loopback_all_all,
1729 (void *)&cmd_config_loopback_all_item,
1730 (void *)&cmd_config_loopback_all_mode,
1735 /* *** configure loopback for specific port *** */
1736 struct cmd_config_loopback_specific {
1737 cmdline_fixed_string_t port;
1738 cmdline_fixed_string_t keyword;
1740 cmdline_fixed_string_t item;
1745 cmd_config_loopback_specific_parsed(void *parsed_result,
1746 __rte_unused struct cmdline *cl,
1747 __rte_unused void *data)
1749 struct cmd_config_loopback_specific *res = parsed_result;
1751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1754 if (!port_is_stopped(res->port_id)) {
1755 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1759 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1761 cmd_reconfig_device_queue(res->port_id, 1, 1);
1765 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1768 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1771 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1772 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1774 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1775 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1777 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1778 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1781 cmdline_parse_inst_t cmd_config_loopback_specific = {
1782 .f = cmd_config_loopback_specific_parsed,
1784 .help_str = "port config <port_id> loopback <mode>",
1786 (void *)&cmd_config_loopback_specific_port,
1787 (void *)&cmd_config_loopback_specific_keyword,
1788 (void *)&cmd_config_loopback_specific_id,
1789 (void *)&cmd_config_loopback_specific_item,
1790 (void *)&cmd_config_loopback_specific_mode,
1795 /* *** configure txq/rxq, txd/rxd *** */
1796 struct cmd_config_rx_tx {
1797 cmdline_fixed_string_t port;
1798 cmdline_fixed_string_t keyword;
1799 cmdline_fixed_string_t all;
1800 cmdline_fixed_string_t name;
1805 cmd_config_rx_tx_parsed(void *parsed_result,
1806 __rte_unused struct cmdline *cl,
1807 __rte_unused void *data)
1809 struct cmd_config_rx_tx *res = parsed_result;
1811 if (!all_ports_stopped()) {
1812 fprintf(stderr, "Please stop all ports first\n");
1815 if (!strcmp(res->name, "rxq")) {
1816 if (!res->value && !nb_txq) {
1817 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1820 if (check_nb_rxq(res->value) != 0)
1822 nb_rxq = res->value;
1824 else if (!strcmp(res->name, "txq")) {
1825 if (!res->value && !nb_rxq) {
1826 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1829 if (check_nb_txq(res->value) != 0)
1831 nb_txq = res->value;
1833 else if (!strcmp(res->name, "rxd")) {
1834 if (check_nb_rxd(res->value) != 0)
1836 nb_rxd = res->value;
1837 } else if (!strcmp(res->name, "txd")) {
1838 if (check_nb_txd(res->value) != 0)
1841 nb_txd = res->value;
1843 fprintf(stderr, "Unknown parameter\n");
1851 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1854 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1856 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1858 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1859 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1860 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1863 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1864 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1866 cmdline_parse_inst_t cmd_config_rx_tx = {
1867 .f = cmd_config_rx_tx_parsed,
1869 .help_str = "port config all rxq|txq|rxd|txd <value>",
1871 (void *)&cmd_config_rx_tx_port,
1872 (void *)&cmd_config_rx_tx_keyword,
1873 (void *)&cmd_config_rx_tx_all,
1874 (void *)&cmd_config_rx_tx_name,
1875 (void *)&cmd_config_rx_tx_value,
1880 /* *** config max packet length *** */
1881 struct cmd_config_max_pkt_len_result {
1882 cmdline_fixed_string_t port;
1883 cmdline_fixed_string_t keyword;
1884 cmdline_fixed_string_t all;
1885 cmdline_fixed_string_t name;
1890 cmd_config_max_pkt_len_parsed(void *parsed_result,
1891 __rte_unused struct cmdline *cl,
1892 __rte_unused void *data)
1894 struct cmd_config_max_pkt_len_result *res = parsed_result;
1895 uint32_t max_rx_pkt_len_backup = 0;
1899 if (!all_ports_stopped()) {
1900 fprintf(stderr, "Please stop all ports first\n");
1904 RTE_ETH_FOREACH_DEV(pid) {
1905 struct rte_port *port = &ports[pid];
1907 if (!strcmp(res->name, "max-pkt-len")) {
1908 if (res->value < RTE_ETHER_MIN_LEN) {
1910 "max-pkt-len can not be less than %d\n",
1914 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1917 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1920 "rte_eth_dev_info_get() failed for port %u\n",
1925 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1927 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1928 if (update_jumbo_frame_offload(pid) != 0)
1929 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1931 fprintf(stderr, "Unknown parameter\n");
1938 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1941 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1944 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1947 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1948 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1950 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1953 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1954 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1957 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1958 .f = cmd_config_max_pkt_len_parsed,
1960 .help_str = "port config all max-pkt-len <value>",
1962 (void *)&cmd_config_max_pkt_len_port,
1963 (void *)&cmd_config_max_pkt_len_keyword,
1964 (void *)&cmd_config_max_pkt_len_all,
1965 (void *)&cmd_config_max_pkt_len_name,
1966 (void *)&cmd_config_max_pkt_len_value,
1971 /* *** config max LRO aggregated packet size *** */
1972 struct cmd_config_max_lro_pkt_size_result {
1973 cmdline_fixed_string_t port;
1974 cmdline_fixed_string_t keyword;
1975 cmdline_fixed_string_t all;
1976 cmdline_fixed_string_t name;
1981 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1982 __rte_unused struct cmdline *cl,
1983 __rte_unused void *data)
1985 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1988 if (!all_ports_stopped()) {
1989 fprintf(stderr, "Please stop all ports first\n");
1993 RTE_ETH_FOREACH_DEV(pid) {
1994 struct rte_port *port = &ports[pid];
1996 if (!strcmp(res->name, "max-lro-pkt-size")) {
1998 port->dev_conf.rxmode.max_lro_pkt_size)
2001 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2003 fprintf(stderr, "Unknown parameter\n");
2010 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2013 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2016 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2019 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2022 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2024 name, "max-lro-pkt-size");
2025 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2026 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2029 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2030 .f = cmd_config_max_lro_pkt_size_parsed,
2032 .help_str = "port config all max-lro-pkt-size <value>",
2034 (void *)&cmd_config_max_lro_pkt_size_port,
2035 (void *)&cmd_config_max_lro_pkt_size_keyword,
2036 (void *)&cmd_config_max_lro_pkt_size_all,
2037 (void *)&cmd_config_max_lro_pkt_size_name,
2038 (void *)&cmd_config_max_lro_pkt_size_value,
2043 /* *** configure port MTU *** */
2044 struct cmd_config_mtu_result {
2045 cmdline_fixed_string_t port;
2046 cmdline_fixed_string_t keyword;
2047 cmdline_fixed_string_t mtu;
2053 cmd_config_mtu_parsed(void *parsed_result,
2054 __rte_unused struct cmdline *cl,
2055 __rte_unused void *data)
2057 struct cmd_config_mtu_result *res = parsed_result;
2059 if (res->value < RTE_ETHER_MIN_LEN) {
2060 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2063 port_mtu_set(res->port_id, res->value);
2066 cmdline_parse_token_string_t cmd_config_mtu_port =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2069 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2072 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2073 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2075 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2076 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2078 cmdline_parse_token_num_t cmd_config_mtu_value =
2079 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2082 cmdline_parse_inst_t cmd_config_mtu = {
2083 .f = cmd_config_mtu_parsed,
2085 .help_str = "port config mtu <port_id> <value>",
2087 (void *)&cmd_config_mtu_port,
2088 (void *)&cmd_config_mtu_keyword,
2089 (void *)&cmd_config_mtu_mtu,
2090 (void *)&cmd_config_mtu_port_id,
2091 (void *)&cmd_config_mtu_value,
2096 /* *** configure rx mode *** */
2097 struct cmd_config_rx_mode_flag {
2098 cmdline_fixed_string_t port;
2099 cmdline_fixed_string_t keyword;
2100 cmdline_fixed_string_t all;
2101 cmdline_fixed_string_t name;
2102 cmdline_fixed_string_t value;
2106 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2107 __rte_unused struct cmdline *cl,
2108 __rte_unused void *data)
2110 struct cmd_config_rx_mode_flag *res = parsed_result;
2112 if (!all_ports_stopped()) {
2113 fprintf(stderr, "Please stop all ports first\n");
2117 if (!strcmp(res->name, "drop-en")) {
2118 if (!strcmp(res->value, "on"))
2120 else if (!strcmp(res->value, "off"))
2123 fprintf(stderr, "Unknown parameter\n");
2127 fprintf(stderr, "Unknown parameter\n");
2133 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2138 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2139 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2141 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2142 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2143 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2144 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2146 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2147 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2150 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2151 .f = cmd_config_rx_mode_flag_parsed,
2153 .help_str = "port config all drop-en on|off",
2155 (void *)&cmd_config_rx_mode_flag_port,
2156 (void *)&cmd_config_rx_mode_flag_keyword,
2157 (void *)&cmd_config_rx_mode_flag_all,
2158 (void *)&cmd_config_rx_mode_flag_name,
2159 (void *)&cmd_config_rx_mode_flag_value,
2164 /* *** configure rss *** */
2165 struct cmd_config_rss {
2166 cmdline_fixed_string_t port;
2167 cmdline_fixed_string_t keyword;
2168 cmdline_fixed_string_t all;
2169 cmdline_fixed_string_t name;
2170 cmdline_fixed_string_t value;
2174 cmd_config_rss_parsed(void *parsed_result,
2175 __rte_unused struct cmdline *cl,
2176 __rte_unused void *data)
2178 struct cmd_config_rss *res = parsed_result;
2179 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2180 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2181 int use_default = 0;
2182 int all_updated = 1;
2187 if (!strcmp(res->value, "all"))
2188 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2189 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2190 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2191 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2193 else if (!strcmp(res->value, "eth"))
2194 rss_conf.rss_hf = ETH_RSS_ETH;
2195 else if (!strcmp(res->value, "vlan"))
2196 rss_conf.rss_hf = ETH_RSS_VLAN;
2197 else if (!strcmp(res->value, "ip"))
2198 rss_conf.rss_hf = ETH_RSS_IP;
2199 else if (!strcmp(res->value, "udp"))
2200 rss_conf.rss_hf = ETH_RSS_UDP;
2201 else if (!strcmp(res->value, "tcp"))
2202 rss_conf.rss_hf = ETH_RSS_TCP;
2203 else if (!strcmp(res->value, "sctp"))
2204 rss_conf.rss_hf = ETH_RSS_SCTP;
2205 else if (!strcmp(res->value, "ether"))
2206 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2207 else if (!strcmp(res->value, "port"))
2208 rss_conf.rss_hf = ETH_RSS_PORT;
2209 else if (!strcmp(res->value, "vxlan"))
2210 rss_conf.rss_hf = ETH_RSS_VXLAN;
2211 else if (!strcmp(res->value, "geneve"))
2212 rss_conf.rss_hf = ETH_RSS_GENEVE;
2213 else if (!strcmp(res->value, "nvgre"))
2214 rss_conf.rss_hf = ETH_RSS_NVGRE;
2215 else if (!strcmp(res->value, "l3-pre32"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2217 else if (!strcmp(res->value, "l3-pre40"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2219 else if (!strcmp(res->value, "l3-pre48"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2221 else if (!strcmp(res->value, "l3-pre56"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2223 else if (!strcmp(res->value, "l3-pre64"))
2224 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2225 else if (!strcmp(res->value, "l3-pre96"))
2226 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2227 else if (!strcmp(res->value, "l3-src-only"))
2228 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2229 else if (!strcmp(res->value, "l3-dst-only"))
2230 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2231 else if (!strcmp(res->value, "l4-src-only"))
2232 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2233 else if (!strcmp(res->value, "l4-dst-only"))
2234 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2235 else if (!strcmp(res->value, "l2-src-only"))
2236 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2237 else if (!strcmp(res->value, "l2-dst-only"))
2238 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2239 else if (!strcmp(res->value, "l2tpv3"))
2240 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2241 else if (!strcmp(res->value, "esp"))
2242 rss_conf.rss_hf = ETH_RSS_ESP;
2243 else if (!strcmp(res->value, "ah"))
2244 rss_conf.rss_hf = ETH_RSS_AH;
2245 else if (!strcmp(res->value, "pfcp"))
2246 rss_conf.rss_hf = ETH_RSS_PFCP;
2247 else if (!strcmp(res->value, "pppoe"))
2248 rss_conf.rss_hf = ETH_RSS_PPPOE;
2249 else if (!strcmp(res->value, "gtpu"))
2250 rss_conf.rss_hf = ETH_RSS_GTPU;
2251 else if (!strcmp(res->value, "ecpri"))
2252 rss_conf.rss_hf = ETH_RSS_ECPRI;
2253 else if (!strcmp(res->value, "mpls"))
2254 rss_conf.rss_hf = ETH_RSS_MPLS;
2255 else if (!strcmp(res->value, "none"))
2256 rss_conf.rss_hf = 0;
2257 else if (!strcmp(res->value, "level-default")) {
2258 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2259 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2260 } else if (!strcmp(res->value, "level-outer")) {
2261 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2262 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2263 } else if (!strcmp(res->value, "level-inner")) {
2264 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2265 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2266 } else if (!strcmp(res->value, "default"))
2268 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2269 atoi(res->value) < 64)
2270 rss_conf.rss_hf = 1ULL << atoi(res->value);
2272 fprintf(stderr, "Unknown parameter\n");
2275 rss_conf.rss_key = NULL;
2276 /* Update global configuration for RSS types. */
2277 RTE_ETH_FOREACH_DEV(i) {
2278 struct rte_eth_rss_conf local_rss_conf;
2280 ret = eth_dev_info_get_print_err(i, &dev_info);
2285 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2287 local_rss_conf = rss_conf;
2288 local_rss_conf.rss_hf = rss_conf.rss_hf &
2289 dev_info.flow_type_rss_offloads;
2290 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2291 printf("Port %u modified RSS hash function based on hardware support,"
2292 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2293 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2295 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2299 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2300 i, -diag, strerror(-diag));
2303 if (all_updated && !use_default) {
2304 rss_hf = rss_conf.rss_hf;
2305 printf("rss_hf %#"PRIx64"\n", rss_hf);
2309 cmdline_parse_token_string_t cmd_config_rss_port =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2311 cmdline_parse_token_string_t cmd_config_rss_keyword =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2313 cmdline_parse_token_string_t cmd_config_rss_all =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2315 cmdline_parse_token_string_t cmd_config_rss_name =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2317 cmdline_parse_token_string_t cmd_config_rss_value =
2318 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2320 cmdline_parse_inst_t cmd_config_rss = {
2321 .f = cmd_config_rss_parsed,
2323 .help_str = "port config all rss "
2324 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2325 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2326 "level-outer|level-inner|<flowtype_id>",
2328 (void *)&cmd_config_rss_port,
2329 (void *)&cmd_config_rss_keyword,
2330 (void *)&cmd_config_rss_all,
2331 (void *)&cmd_config_rss_name,
2332 (void *)&cmd_config_rss_value,
2337 /* *** configure rss hash key *** */
2338 struct cmd_config_rss_hash_key {
2339 cmdline_fixed_string_t port;
2340 cmdline_fixed_string_t config;
2342 cmdline_fixed_string_t rss_hash_key;
2343 cmdline_fixed_string_t rss_type;
2344 cmdline_fixed_string_t key;
2348 hexa_digit_to_value(char hexa_digit)
2350 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2351 return (uint8_t) (hexa_digit - '0');
2352 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2353 return (uint8_t) ((hexa_digit - 'a') + 10);
2354 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2355 return (uint8_t) ((hexa_digit - 'A') + 10);
2356 /* Invalid hexa digit */
2361 parse_and_check_key_hexa_digit(char *key, int idx)
2365 hexa_v = hexa_digit_to_value(key[idx]);
2368 "invalid key: character %c at position %d is not a valid hexa digit\n",
2374 cmd_config_rss_hash_key_parsed(void *parsed_result,
2375 __rte_unused struct cmdline *cl,
2376 __rte_unused void *data)
2378 struct cmd_config_rss_hash_key *res = parsed_result;
2379 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2383 struct rte_eth_dev_info dev_info;
2384 uint8_t hash_key_size;
2388 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2392 if (dev_info.hash_key_size > 0 &&
2393 dev_info.hash_key_size <= sizeof(hash_key))
2394 hash_key_size = dev_info.hash_key_size;
2397 "dev_info did not provide a valid hash key size\n");
2400 /* Check the length of the RSS hash key */
2401 key_len = strlen(res->key);
2402 if (key_len != (hash_key_size * 2)) {
2404 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2405 (int)key_len, hash_key_size * 2);
2408 /* Translate RSS hash key into binary representation */
2409 for (i = 0; i < hash_key_size; i++) {
2410 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2413 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2416 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2418 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2422 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2423 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2425 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2427 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2428 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2430 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2431 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2432 rss_hash_key, "rss-hash-key");
2433 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2434 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2435 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2436 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2437 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2438 "ipv6-tcp-ex#ipv6-udp-ex#"
2439 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2440 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2441 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2442 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2443 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2445 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2446 .f = cmd_config_rss_hash_key_parsed,
2448 .help_str = "port config <port_id> rss-hash-key "
2449 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2450 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2451 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2452 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2453 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2454 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2455 "<string of hex digits (variable length, NIC dependent)>",
2457 (void *)&cmd_config_rss_hash_key_port,
2458 (void *)&cmd_config_rss_hash_key_config,
2459 (void *)&cmd_config_rss_hash_key_port_id,
2460 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2461 (void *)&cmd_config_rss_hash_key_rss_type,
2462 (void *)&cmd_config_rss_hash_key_value,
2467 /* *** cleanup txq mbufs *** */
2468 struct cmd_cleanup_txq_mbufs_result {
2469 cmdline_fixed_string_t port;
2470 cmdline_fixed_string_t keyword;
2471 cmdline_fixed_string_t name;
2478 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2479 __rte_unused struct cmdline *cl,
2480 __rte_unused void *data)
2482 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2483 uint16_t port_id = res->port_id;
2484 uint16_t queue_id = res->queue_id;
2485 uint32_t free_cnt = res->free_cnt;
2486 struct rte_eth_txq_info qinfo;
2489 if (test_done == 0) {
2490 fprintf(stderr, "Please stop forwarding first\n");
2494 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2495 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2500 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2501 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2505 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2508 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2509 port_id, queue_id, strerror(-ret), ret);
2513 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2514 port_id, queue_id, ret);
2517 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2518 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2520 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2521 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2523 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2524 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2526 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2527 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2529 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2530 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2532 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2533 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2536 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2537 .f = cmd_cleanup_txq_mbufs_parsed,
2539 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2541 (void *)&cmd_cleanup_txq_mbufs_port,
2542 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2543 (void *)&cmd_cleanup_txq_mbufs_port_id,
2544 (void *)&cmd_cleanup_txq_mbufs_txq,
2545 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2546 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2551 /* *** configure port rxq/txq ring size *** */
2552 struct cmd_config_rxtx_ring_size {
2553 cmdline_fixed_string_t port;
2554 cmdline_fixed_string_t config;
2556 cmdline_fixed_string_t rxtxq;
2558 cmdline_fixed_string_t rsize;
2563 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2564 __rte_unused struct cmdline *cl,
2565 __rte_unused void *data)
2567 struct cmd_config_rxtx_ring_size *res = parsed_result;
2568 struct rte_port *port;
2571 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2574 if (res->portid == (portid_t)RTE_PORT_ALL) {
2575 fprintf(stderr, "Invalid port id\n");
2579 port = &ports[res->portid];
2581 if (!strcmp(res->rxtxq, "rxq"))
2583 else if (!strcmp(res->rxtxq, "txq"))
2586 fprintf(stderr, "Unknown parameter\n");
2590 if (isrx && rx_queue_id_is_invalid(res->qid))
2592 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2595 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2597 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2603 port->nb_rx_desc[res->qid] = res->size;
2605 port->nb_tx_desc[res->qid] = res->size;
2607 cmd_reconfig_device_queue(res->portid, 0, 1);
2610 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2611 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2613 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2614 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2616 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2617 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2618 portid, RTE_UINT16);
2619 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2622 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2623 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2625 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2626 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2627 rsize, "ring_size");
2628 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2629 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2632 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2633 .f = cmd_config_rxtx_ring_size_parsed,
2635 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2637 (void *)&cmd_config_rxtx_ring_size_port,
2638 (void *)&cmd_config_rxtx_ring_size_config,
2639 (void *)&cmd_config_rxtx_ring_size_portid,
2640 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2641 (void *)&cmd_config_rxtx_ring_size_qid,
2642 (void *)&cmd_config_rxtx_ring_size_rsize,
2643 (void *)&cmd_config_rxtx_ring_size_size,
2648 /* *** configure port rxq/txq start/stop *** */
2649 struct cmd_config_rxtx_queue {
2650 cmdline_fixed_string_t port;
2652 cmdline_fixed_string_t rxtxq;
2654 cmdline_fixed_string_t opname;
2658 cmd_config_rxtx_queue_parsed(void *parsed_result,
2659 __rte_unused struct cmdline *cl,
2660 __rte_unused void *data)
2662 struct cmd_config_rxtx_queue *res = parsed_result;
2667 if (test_done == 0) {
2668 fprintf(stderr, "Please stop forwarding first\n");
2672 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2675 if (port_is_started(res->portid) != 1) {
2676 fprintf(stderr, "Please start port %u first\n", res->portid);
2680 if (!strcmp(res->rxtxq, "rxq"))
2682 else if (!strcmp(res->rxtxq, "txq"))
2685 fprintf(stderr, "Unknown parameter\n");
2689 if (isrx && rx_queue_id_is_invalid(res->qid))
2691 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2694 if (!strcmp(res->opname, "start"))
2696 else if (!strcmp(res->opname, "stop"))
2699 fprintf(stderr, "Unknown parameter\n");
2703 if (isstart && isrx)
2704 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2705 else if (!isstart && isrx)
2706 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2707 else if (isstart && !isrx)
2708 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2710 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2712 if (ret == -ENOTSUP)
2713 fprintf(stderr, "Function not supported in PMD driver\n");
2716 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2717 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2718 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2719 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2720 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2721 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2722 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2723 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2724 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2725 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2728 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2729 .f = cmd_config_rxtx_queue_parsed,
2731 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2733 (void *)&cmd_config_rxtx_queue_port,
2734 (void *)&cmd_config_rxtx_queue_portid,
2735 (void *)&cmd_config_rxtx_queue_rxtxq,
2736 (void *)&cmd_config_rxtx_queue_qid,
2737 (void *)&cmd_config_rxtx_queue_opname,
2742 /* *** configure port rxq/txq deferred start on/off *** */
2743 struct cmd_config_deferred_start_rxtx_queue {
2744 cmdline_fixed_string_t port;
2746 cmdline_fixed_string_t rxtxq;
2748 cmdline_fixed_string_t opname;
2749 cmdline_fixed_string_t state;
2753 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2754 __rte_unused struct cmdline *cl,
2755 __rte_unused void *data)
2757 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2758 struct rte_port *port;
2761 uint8_t needreconfig = 0;
2763 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2766 if (port_is_started(res->port_id) != 0) {
2767 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2771 port = &ports[res->port_id];
2773 isrx = !strcmp(res->rxtxq, "rxq");
2775 if (isrx && rx_queue_id_is_invalid(res->qid))
2777 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2780 ison = !strcmp(res->state, "on");
2782 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2783 port->rx_conf[res->qid].rx_deferred_start = ison;
2785 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2786 port->tx_conf[res->qid].tx_deferred_start = ison;
2791 cmd_reconfig_device_queue(res->port_id, 0, 1);
2794 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2795 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2797 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2798 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2799 port_id, RTE_UINT16);
2800 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2801 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2803 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2804 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2806 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2807 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2808 opname, "deferred_start");
2809 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2810 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2813 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2814 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2816 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2818 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2819 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2820 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2821 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2822 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2823 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2828 /* *** configure port rxq/txq setup *** */
2829 struct cmd_setup_rxtx_queue {
2830 cmdline_fixed_string_t port;
2832 cmdline_fixed_string_t rxtxq;
2834 cmdline_fixed_string_t setup;
2837 /* Common CLI fields for queue setup */
2838 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2839 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2840 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2841 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2842 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2843 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2844 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2845 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2846 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2847 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2850 cmd_setup_rxtx_queue_parsed(
2851 void *parsed_result,
2852 __rte_unused struct cmdline *cl,
2853 __rte_unused void *data)
2855 struct cmd_setup_rxtx_queue *res = parsed_result;
2856 struct rte_port *port;
2857 struct rte_mempool *mp;
2858 unsigned int socket_id;
2862 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2865 if (res->portid == (portid_t)RTE_PORT_ALL) {
2866 fprintf(stderr, "Invalid port id\n");
2870 if (!strcmp(res->rxtxq, "rxq"))
2872 else if (!strcmp(res->rxtxq, "txq"))
2875 fprintf(stderr, "Unknown parameter\n");
2879 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2880 fprintf(stderr, "Invalid rx queue\n");
2882 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2883 fprintf(stderr, "Invalid tx queue\n");
2887 port = &ports[res->portid];
2889 socket_id = rxring_numa[res->portid];
2890 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2891 socket_id = port->socket_id;
2893 mp = mbuf_pool_find(socket_id, 0);
2896 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2897 rxring_numa[res->portid]);
2900 ret = rx_queue_setup(res->portid,
2902 port->nb_rx_desc[res->qid],
2904 &port->rx_conf[res->qid],
2907 fprintf(stderr, "Failed to setup RX queue\n");
2909 socket_id = txring_numa[res->portid];
2910 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2911 socket_id = port->socket_id;
2913 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2915 "Failed to setup TX queue: not enough descriptors\n");
2918 ret = rte_eth_tx_queue_setup(res->portid,
2920 port->nb_tx_desc[res->qid],
2922 &port->tx_conf[res->qid]);
2924 fprintf(stderr, "Failed to setup TX queue\n");
2928 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2929 .f = cmd_setup_rxtx_queue_parsed,
2931 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2933 (void *)&cmd_setup_rxtx_queue_port,
2934 (void *)&cmd_setup_rxtx_queue_portid,
2935 (void *)&cmd_setup_rxtx_queue_rxtxq,
2936 (void *)&cmd_setup_rxtx_queue_qid,
2937 (void *)&cmd_setup_rxtx_queue_setup,
2943 /* *** Configure RSS RETA *** */
2944 struct cmd_config_rss_reta {
2945 cmdline_fixed_string_t port;
2946 cmdline_fixed_string_t keyword;
2948 cmdline_fixed_string_t name;
2949 cmdline_fixed_string_t list_name;
2950 cmdline_fixed_string_t list_of_items;
2954 parse_reta_config(const char *str,
2955 struct rte_eth_rss_reta_entry64 *reta_conf,
2956 uint16_t nb_entries)
2960 uint16_t hash_index, idx, shift;
2963 const char *p, *p0 = str;
2970 unsigned long int_fld[_NUM_FLD];
2971 char *str_fld[_NUM_FLD];
2973 while ((p = strchr(p0,'(')) != NULL) {
2975 if((p0 = strchr(p,')')) == NULL)
2979 if(size >= sizeof(s))
2982 snprintf(s, sizeof(s), "%.*s", size, p);
2983 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2985 for (i = 0; i < _NUM_FLD; i++) {
2987 int_fld[i] = strtoul(str_fld[i], &end, 0);
2988 if (errno != 0 || end == str_fld[i] ||
2993 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2994 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2996 if (hash_index >= nb_entries) {
2997 fprintf(stderr, "Invalid RETA hash index=%d\n",
3002 idx = hash_index / RTE_RETA_GROUP_SIZE;
3003 shift = hash_index % RTE_RETA_GROUP_SIZE;
3004 reta_conf[idx].mask |= (1ULL << shift);
3005 reta_conf[idx].reta[shift] = nb_queue;
3012 cmd_set_rss_reta_parsed(void *parsed_result,
3013 __rte_unused struct cmdline *cl,
3014 __rte_unused void *data)
3017 struct rte_eth_dev_info dev_info;
3018 struct rte_eth_rss_reta_entry64 reta_conf[8];
3019 struct cmd_config_rss_reta *res = parsed_result;
3021 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3025 if (dev_info.reta_size == 0) {
3027 "Redirection table size is 0 which is invalid for RSS\n");
3030 printf("The reta size of port %d is %u\n",
3031 res->port_id, dev_info.reta_size);
3032 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3034 "Currently do not support more than %u entries of redirection table\n",
3035 ETH_RSS_RETA_SIZE_512);
3039 memset(reta_conf, 0, sizeof(reta_conf));
3040 if (!strcmp(res->list_name, "reta")) {
3041 if (parse_reta_config(res->list_of_items, reta_conf,
3042 dev_info.reta_size)) {
3044 "Invalid RSS Redirection Table config entered\n");
3047 ret = rte_eth_dev_rss_reta_update(res->port_id,
3048 reta_conf, dev_info.reta_size);
3051 "Bad redirection table parameter, return code = %d\n",
3056 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3058 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3060 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3061 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3062 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3064 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3066 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3067 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3069 cmdline_parse_inst_t cmd_config_rss_reta = {
3070 .f = cmd_set_rss_reta_parsed,
3072 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3074 (void *)&cmd_config_rss_reta_port,
3075 (void *)&cmd_config_rss_reta_keyword,
3076 (void *)&cmd_config_rss_reta_port_id,
3077 (void *)&cmd_config_rss_reta_name,
3078 (void *)&cmd_config_rss_reta_list_name,
3079 (void *)&cmd_config_rss_reta_list_of_items,
3084 /* *** SHOW PORT RETA INFO *** */
3085 struct cmd_showport_reta {
3086 cmdline_fixed_string_t show;
3087 cmdline_fixed_string_t port;
3089 cmdline_fixed_string_t rss;
3090 cmdline_fixed_string_t reta;
3092 cmdline_fixed_string_t list_of_items;
3096 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3097 uint16_t nb_entries,
3101 const char *p, *p0 = str;
3106 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3107 RTE_RETA_GROUP_SIZE;
3110 p = strchr(p0, '(');
3114 p0 = strchr(p, ')');
3118 if (size >= sizeof(s)) {
3120 "The string size exceeds the internal buffer size\n");
3123 snprintf(s, sizeof(s), "%.*s", size, p);
3124 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3125 if (ret <= 0 || ret != num) {
3127 "The bits of masks do not match the number of reta entries: %u\n",
3131 for (i = 0; i < ret; i++)
3132 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3138 cmd_showport_reta_parsed(void *parsed_result,
3139 __rte_unused struct cmdline *cl,
3140 __rte_unused void *data)
3142 struct cmd_showport_reta *res = parsed_result;
3143 struct rte_eth_rss_reta_entry64 reta_conf[8];
3144 struct rte_eth_dev_info dev_info;
3145 uint16_t max_reta_size;
3148 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3152 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3153 if (res->size == 0 || res->size > max_reta_size) {
3154 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3155 res->size, max_reta_size);
3159 memset(reta_conf, 0, sizeof(reta_conf));
3160 if (showport_parse_reta_config(reta_conf, res->size,
3161 res->list_of_items) < 0) {
3162 fprintf(stderr, "Invalid string: %s for reta masks\n",
3163 res->list_of_items);
3166 port_rss_reta_info(res->port_id, reta_conf, res->size);
3169 cmdline_parse_token_string_t cmd_showport_reta_show =
3170 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3171 cmdline_parse_token_string_t cmd_showport_reta_port =
3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3173 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3174 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3175 cmdline_parse_token_string_t cmd_showport_reta_rss =
3176 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3177 cmdline_parse_token_string_t cmd_showport_reta_reta =
3178 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3179 cmdline_parse_token_num_t cmd_showport_reta_size =
3180 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3181 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3182 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3183 list_of_items, NULL);
3185 cmdline_parse_inst_t cmd_showport_reta = {
3186 .f = cmd_showport_reta_parsed,
3188 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3190 (void *)&cmd_showport_reta_show,
3191 (void *)&cmd_showport_reta_port,
3192 (void *)&cmd_showport_reta_port_id,
3193 (void *)&cmd_showport_reta_rss,
3194 (void *)&cmd_showport_reta_reta,
3195 (void *)&cmd_showport_reta_size,
3196 (void *)&cmd_showport_reta_list_of_items,
3201 /* *** Show RSS hash configuration *** */
3202 struct cmd_showport_rss_hash {
3203 cmdline_fixed_string_t show;
3204 cmdline_fixed_string_t port;
3206 cmdline_fixed_string_t rss_hash;
3207 cmdline_fixed_string_t rss_type;
3208 cmdline_fixed_string_t key; /* optional argument */
3211 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3212 __rte_unused struct cmdline *cl,
3215 struct cmd_showport_rss_hash *res = parsed_result;
3217 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3220 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3221 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3222 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3223 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3224 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3225 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3227 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3228 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3230 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3231 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3233 cmdline_parse_inst_t cmd_showport_rss_hash = {
3234 .f = cmd_showport_rss_hash_parsed,
3236 .help_str = "show port <port_id> rss-hash",
3238 (void *)&cmd_showport_rss_hash_show,
3239 (void *)&cmd_showport_rss_hash_port,
3240 (void *)&cmd_showport_rss_hash_port_id,
3241 (void *)&cmd_showport_rss_hash_rss_hash,
3246 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3247 .f = cmd_showport_rss_hash_parsed,
3249 .help_str = "show port <port_id> rss-hash key",
3251 (void *)&cmd_showport_rss_hash_show,
3252 (void *)&cmd_showport_rss_hash_port,
3253 (void *)&cmd_showport_rss_hash_port_id,
3254 (void *)&cmd_showport_rss_hash_rss_hash,
3255 (void *)&cmd_showport_rss_hash_rss_key,
3260 /* *** Configure DCB *** */
3261 struct cmd_config_dcb {
3262 cmdline_fixed_string_t port;
3263 cmdline_fixed_string_t config;
3265 cmdline_fixed_string_t dcb;
3266 cmdline_fixed_string_t vt;
3267 cmdline_fixed_string_t vt_en;
3269 cmdline_fixed_string_t pfc;
3270 cmdline_fixed_string_t pfc_en;
3274 cmd_config_dcb_parsed(void *parsed_result,
3275 __rte_unused struct cmdline *cl,
3276 __rte_unused void *data)
3278 struct cmd_config_dcb *res = parsed_result;
3279 struct rte_eth_dcb_info dcb_info;
3280 portid_t port_id = res->port_id;
3281 struct rte_port *port;
3285 port = &ports[port_id];
3286 /** Check if the port is not started **/
3287 if (port->port_status != RTE_PORT_STOPPED) {
3288 fprintf(stderr, "Please stop port %d first\n", port_id);
3292 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3294 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3298 if (nb_fwd_lcores < res->num_tcs) {
3300 "nb_cores shouldn't be less than number of TCs.\n");
3304 /* Check whether the port supports the report of DCB info. */
3305 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3306 if (ret == -ENOTSUP) {
3307 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3311 if (!strncmp(res->pfc_en, "on", 2))
3316 /* DCB in VT mode */
3317 if (!strncmp(res->vt_en, "on", 2))
3318 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3319 (enum rte_eth_nb_tcs)res->num_tcs,
3322 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3323 (enum rte_eth_nb_tcs)res->num_tcs,
3326 fprintf(stderr, "Cannot initialize network ports.\n");
3332 cmd_reconfig_device_queue(port_id, 1, 1);
3335 cmdline_parse_token_string_t cmd_config_dcb_port =
3336 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3337 cmdline_parse_token_string_t cmd_config_dcb_config =
3338 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3339 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3340 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3341 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3342 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3343 cmdline_parse_token_string_t cmd_config_dcb_vt =
3344 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3345 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3346 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3347 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3348 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3349 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3350 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3351 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3352 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3354 cmdline_parse_inst_t cmd_config_dcb = {
3355 .f = cmd_config_dcb_parsed,
3357 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3359 (void *)&cmd_config_dcb_port,
3360 (void *)&cmd_config_dcb_config,
3361 (void *)&cmd_config_dcb_port_id,
3362 (void *)&cmd_config_dcb_dcb,
3363 (void *)&cmd_config_dcb_vt,
3364 (void *)&cmd_config_dcb_vt_en,
3365 (void *)&cmd_config_dcb_num_tcs,
3366 (void *)&cmd_config_dcb_pfc,
3367 (void *)&cmd_config_dcb_pfc_en,
3372 /* *** configure number of packets per burst *** */
3373 struct cmd_config_burst {
3374 cmdline_fixed_string_t port;
3375 cmdline_fixed_string_t keyword;
3376 cmdline_fixed_string_t all;
3377 cmdline_fixed_string_t name;
3382 cmd_config_burst_parsed(void *parsed_result,
3383 __rte_unused struct cmdline *cl,
3384 __rte_unused void *data)
3386 struct cmd_config_burst *res = parsed_result;
3387 struct rte_eth_dev_info dev_info;
3388 uint16_t rec_nb_pkts;
3391 if (!all_ports_stopped()) {
3392 fprintf(stderr, "Please stop all ports first\n");
3396 if (!strcmp(res->name, "burst")) {
3397 if (res->value == 0) {
3398 /* If user gives a value of zero, query the PMD for
3399 * its recommended Rx burst size. Testpmd uses a single
3400 * size for all ports, so assume all ports are the same
3401 * NIC model and use the values from Port 0.
3403 ret = eth_dev_info_get_print_err(0, &dev_info);
3407 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3409 if (rec_nb_pkts == 0) {
3410 printf("PMD does not recommend a burst size.\n"
3411 "User provided value must be between"
3412 " 1 and %d\n", MAX_PKT_BURST);
3414 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3415 printf("PMD recommended burst size of %d"
3416 " exceeds maximum value of %d\n",
3417 rec_nb_pkts, MAX_PKT_BURST);
3420 printf("Using PMD-provided burst value of %d\n",
3422 nb_pkt_per_burst = rec_nb_pkts;
3423 } else if (res->value > MAX_PKT_BURST) {
3424 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3428 nb_pkt_per_burst = res->value;
3430 fprintf(stderr, "Unknown parameter\n");
3436 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3439 cmdline_parse_token_string_t cmd_config_burst_port =
3440 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3441 cmdline_parse_token_string_t cmd_config_burst_keyword =
3442 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3443 cmdline_parse_token_string_t cmd_config_burst_all =
3444 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3445 cmdline_parse_token_string_t cmd_config_burst_name =
3446 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3447 cmdline_parse_token_num_t cmd_config_burst_value =
3448 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3450 cmdline_parse_inst_t cmd_config_burst = {
3451 .f = cmd_config_burst_parsed,
3453 .help_str = "port config all burst <value>",
3455 (void *)&cmd_config_burst_port,
3456 (void *)&cmd_config_burst_keyword,
3457 (void *)&cmd_config_burst_all,
3458 (void *)&cmd_config_burst_name,
3459 (void *)&cmd_config_burst_value,
3464 /* *** configure rx/tx queues *** */
3465 struct cmd_config_thresh {
3466 cmdline_fixed_string_t port;
3467 cmdline_fixed_string_t keyword;
3468 cmdline_fixed_string_t all;
3469 cmdline_fixed_string_t name;
3474 cmd_config_thresh_parsed(void *parsed_result,
3475 __rte_unused struct cmdline *cl,
3476 __rte_unused void *data)
3478 struct cmd_config_thresh *res = parsed_result;
3480 if (!all_ports_stopped()) {
3481 fprintf(stderr, "Please stop all ports first\n");
3485 if (!strcmp(res->name, "txpt"))
3486 tx_pthresh = res->value;
3487 else if(!strcmp(res->name, "txht"))
3488 tx_hthresh = res->value;
3489 else if(!strcmp(res->name, "txwt"))
3490 tx_wthresh = res->value;
3491 else if(!strcmp(res->name, "rxpt"))
3492 rx_pthresh = res->value;
3493 else if(!strcmp(res->name, "rxht"))
3494 rx_hthresh = res->value;
3495 else if(!strcmp(res->name, "rxwt"))
3496 rx_wthresh = res->value;
3498 fprintf(stderr, "Unknown parameter\n");
3504 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3507 cmdline_parse_token_string_t cmd_config_thresh_port =
3508 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3509 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3510 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3511 cmdline_parse_token_string_t cmd_config_thresh_all =
3512 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3513 cmdline_parse_token_string_t cmd_config_thresh_name =
3514 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3515 "txpt#txht#txwt#rxpt#rxht#rxwt");
3516 cmdline_parse_token_num_t cmd_config_thresh_value =
3517 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3519 cmdline_parse_inst_t cmd_config_thresh = {
3520 .f = cmd_config_thresh_parsed,
3522 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3524 (void *)&cmd_config_thresh_port,
3525 (void *)&cmd_config_thresh_keyword,
3526 (void *)&cmd_config_thresh_all,
3527 (void *)&cmd_config_thresh_name,
3528 (void *)&cmd_config_thresh_value,
3533 /* *** configure free/rs threshold *** */
3534 struct cmd_config_threshold {
3535 cmdline_fixed_string_t port;
3536 cmdline_fixed_string_t keyword;
3537 cmdline_fixed_string_t all;
3538 cmdline_fixed_string_t name;
3543 cmd_config_threshold_parsed(void *parsed_result,
3544 __rte_unused struct cmdline *cl,
3545 __rte_unused void *data)
3547 struct cmd_config_threshold *res = parsed_result;
3549 if (!all_ports_stopped()) {
3550 fprintf(stderr, "Please stop all ports first\n");
3554 if (!strcmp(res->name, "txfreet"))
3555 tx_free_thresh = res->value;
3556 else if (!strcmp(res->name, "txrst"))
3557 tx_rs_thresh = res->value;
3558 else if (!strcmp(res->name, "rxfreet"))
3559 rx_free_thresh = res->value;
3561 fprintf(stderr, "Unknown parameter\n");
3567 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3570 cmdline_parse_token_string_t cmd_config_threshold_port =
3571 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3572 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3573 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3575 cmdline_parse_token_string_t cmd_config_threshold_all =
3576 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3577 cmdline_parse_token_string_t cmd_config_threshold_name =
3578 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3579 "txfreet#txrst#rxfreet");
3580 cmdline_parse_token_num_t cmd_config_threshold_value =
3581 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3583 cmdline_parse_inst_t cmd_config_threshold = {
3584 .f = cmd_config_threshold_parsed,
3586 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3588 (void *)&cmd_config_threshold_port,
3589 (void *)&cmd_config_threshold_keyword,
3590 (void *)&cmd_config_threshold_all,
3591 (void *)&cmd_config_threshold_name,
3592 (void *)&cmd_config_threshold_value,
3598 struct cmd_stop_result {
3599 cmdline_fixed_string_t stop;
3602 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3603 __rte_unused struct cmdline *cl,
3604 __rte_unused void *data)
3606 stop_packet_forwarding();
3609 cmdline_parse_token_string_t cmd_stop_stop =
3610 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3612 cmdline_parse_inst_t cmd_stop = {
3613 .f = cmd_stop_parsed,
3615 .help_str = "stop: Stop packet forwarding",
3617 (void *)&cmd_stop_stop,
3622 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3625 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3626 unsigned int *parsed_items, int check_unique_values)
3628 unsigned int nb_item;
3636 * First parse all items in the list and store their value.
3641 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3643 if ((c >= '0') && (c <= '9')) {
3644 value = (unsigned int) (value * 10 + (c - '0'));
3649 fprintf(stderr, "character %c is not a decimal digit\n", c);
3653 fprintf(stderr, "No valid value before comma\n");
3656 if (nb_item < max_items) {
3657 parsed_items[nb_item] = value;
3663 if (nb_item >= max_items) {
3664 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3665 item_name, nb_item + 1, max_items);
3668 parsed_items[nb_item++] = value;
3669 if (! check_unique_values)
3673 * Then, check that all values in the list are differents.
3674 * No optimization here...
3676 for (i = 0; i < nb_item; i++) {
3677 for (j = i + 1; j < nb_item; j++) {
3678 if (parsed_items[j] == parsed_items[i]) {
3680 "duplicated %s %u at index %u and %u\n",
3681 item_name, parsed_items[i], i, j);
3689 struct cmd_set_list_result {
3690 cmdline_fixed_string_t cmd_keyword;
3691 cmdline_fixed_string_t list_name;
3692 cmdline_fixed_string_t list_of_items;
3695 static void cmd_set_list_parsed(void *parsed_result,
3696 __rte_unused struct cmdline *cl,
3697 __rte_unused void *data)
3699 struct cmd_set_list_result *res;
3701 unsigned int lcorelist[RTE_MAX_LCORE];
3702 unsigned int portlist[RTE_MAX_ETHPORTS];
3704 unsigned int nb_item;
3706 if (test_done == 0) {
3707 fprintf(stderr, "Please stop forwarding first\n");
3711 res = parsed_result;
3712 if (!strcmp(res->list_name, "corelist")) {
3713 nb_item = parse_item_list(res->list_of_items, "core",
3715 parsed_items.lcorelist, 1);
3717 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3722 if (!strcmp(res->list_name, "portlist")) {
3723 nb_item = parse_item_list(res->list_of_items, "port",
3725 parsed_items.portlist, 1);
3727 set_fwd_ports_list(parsed_items.portlist, nb_item);
3733 cmdline_parse_token_string_t cmd_set_list_keyword =
3734 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3736 cmdline_parse_token_string_t cmd_set_list_name =
3737 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3738 "corelist#portlist");
3739 cmdline_parse_token_string_t cmd_set_list_of_items =
3740 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3743 cmdline_parse_inst_t cmd_set_fwd_list = {
3744 .f = cmd_set_list_parsed,
3746 .help_str = "set corelist|portlist <list0[,list1]*>",
3748 (void *)&cmd_set_list_keyword,
3749 (void *)&cmd_set_list_name,
3750 (void *)&cmd_set_list_of_items,
3755 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3757 struct cmd_setmask_result {
3758 cmdline_fixed_string_t set;
3759 cmdline_fixed_string_t mask;
3763 static void cmd_set_mask_parsed(void *parsed_result,
3764 __rte_unused struct cmdline *cl,
3765 __rte_unused void *data)
3767 struct cmd_setmask_result *res = parsed_result;
3769 if (test_done == 0) {
3770 fprintf(stderr, "Please stop forwarding first\n");
3773 if (!strcmp(res->mask, "coremask")) {
3774 set_fwd_lcores_mask(res->hexavalue);
3776 } else if (!strcmp(res->mask, "portmask")) {
3777 set_fwd_ports_mask(res->hexavalue);
3782 cmdline_parse_token_string_t cmd_setmask_set =
3783 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3784 cmdline_parse_token_string_t cmd_setmask_mask =
3785 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3786 "coremask#portmask");
3787 cmdline_parse_token_num_t cmd_setmask_value =
3788 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3790 cmdline_parse_inst_t cmd_set_fwd_mask = {
3791 .f = cmd_set_mask_parsed,
3793 .help_str = "set coremask|portmask <hexadecimal value>",
3795 (void *)&cmd_setmask_set,
3796 (void *)&cmd_setmask_mask,
3797 (void *)&cmd_setmask_value,
3803 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3805 struct cmd_set_result {
3806 cmdline_fixed_string_t set;
3807 cmdline_fixed_string_t what;
3811 static void cmd_set_parsed(void *parsed_result,
3812 __rte_unused struct cmdline *cl,
3813 __rte_unused void *data)
3815 struct cmd_set_result *res = parsed_result;
3816 if (!strcmp(res->what, "nbport")) {
3817 set_fwd_ports_number(res->value);
3819 } else if (!strcmp(res->what, "nbcore")) {
3820 set_fwd_lcores_number(res->value);
3822 } else if (!strcmp(res->what, "burst"))
3823 set_nb_pkt_per_burst(res->value);
3824 else if (!strcmp(res->what, "verbose"))
3825 set_verbose_level(res->value);
3828 cmdline_parse_token_string_t cmd_set_set =
3829 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3830 cmdline_parse_token_string_t cmd_set_what =
3831 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3832 "nbport#nbcore#burst#verbose");
3833 cmdline_parse_token_num_t cmd_set_value =
3834 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3836 cmdline_parse_inst_t cmd_set_numbers = {
3837 .f = cmd_set_parsed,
3839 .help_str = "set nbport|nbcore|burst|verbose <value>",
3841 (void *)&cmd_set_set,
3842 (void *)&cmd_set_what,
3843 (void *)&cmd_set_value,
3848 /* *** SET LOG LEVEL CONFIGURATION *** */
3850 struct cmd_set_log_result {
3851 cmdline_fixed_string_t set;
3852 cmdline_fixed_string_t log;
3853 cmdline_fixed_string_t type;
3858 cmd_set_log_parsed(void *parsed_result,
3859 __rte_unused struct cmdline *cl,
3860 __rte_unused void *data)
3862 struct cmd_set_log_result *res;
3865 res = parsed_result;
3866 if (!strcmp(res->type, "global"))
3867 rte_log_set_global_level(res->level);
3869 ret = rte_log_set_level_regexp(res->type, res->level);
3871 fprintf(stderr, "Unable to set log level\n");
3875 cmdline_parse_token_string_t cmd_set_log_set =
3876 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3877 cmdline_parse_token_string_t cmd_set_log_log =
3878 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3879 cmdline_parse_token_string_t cmd_set_log_type =
3880 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3881 cmdline_parse_token_num_t cmd_set_log_level =
3882 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3884 cmdline_parse_inst_t cmd_set_log = {
3885 .f = cmd_set_log_parsed,
3887 .help_str = "set log global|<type> <level>",
3889 (void *)&cmd_set_log_set,
3890 (void *)&cmd_set_log_log,
3891 (void *)&cmd_set_log_type,
3892 (void *)&cmd_set_log_level,
3897 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3899 struct cmd_set_rxoffs_result {
3900 cmdline_fixed_string_t cmd_keyword;
3901 cmdline_fixed_string_t rxoffs;
3902 cmdline_fixed_string_t seg_offsets;
3906 cmd_set_rxoffs_parsed(void *parsed_result,
3907 __rte_unused struct cmdline *cl,
3908 __rte_unused void *data)
3910 struct cmd_set_rxoffs_result *res;
3911 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3912 unsigned int nb_segs;
3914 res = parsed_result;
3915 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3916 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3918 set_rx_pkt_offsets(seg_offsets, nb_segs);
3919 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3922 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3923 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3924 cmd_keyword, "set");
3925 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3926 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3928 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3929 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3932 cmdline_parse_inst_t cmd_set_rxoffs = {
3933 .f = cmd_set_rxoffs_parsed,
3935 .help_str = "set rxoffs <len0[,len1]*>",
3937 (void *)&cmd_set_rxoffs_keyword,
3938 (void *)&cmd_set_rxoffs_name,
3939 (void *)&cmd_set_rxoffs_offsets,
3944 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3946 struct cmd_set_rxpkts_result {
3947 cmdline_fixed_string_t cmd_keyword;
3948 cmdline_fixed_string_t rxpkts;
3949 cmdline_fixed_string_t seg_lengths;
3953 cmd_set_rxpkts_parsed(void *parsed_result,
3954 __rte_unused struct cmdline *cl,
3955 __rte_unused void *data)
3957 struct cmd_set_rxpkts_result *res;
3958 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3959 unsigned int nb_segs;
3961 res = parsed_result;
3962 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3963 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3965 set_rx_pkt_segments(seg_lengths, nb_segs);
3966 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3969 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3970 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3971 cmd_keyword, "set");
3972 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3973 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3975 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3976 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3979 cmdline_parse_inst_t cmd_set_rxpkts = {
3980 .f = cmd_set_rxpkts_parsed,
3982 .help_str = "set rxpkts <len0[,len1]*>",
3984 (void *)&cmd_set_rxpkts_keyword,
3985 (void *)&cmd_set_rxpkts_name,
3986 (void *)&cmd_set_rxpkts_lengths,
3991 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3993 struct cmd_set_txpkts_result {
3994 cmdline_fixed_string_t cmd_keyword;
3995 cmdline_fixed_string_t txpkts;
3996 cmdline_fixed_string_t seg_lengths;
4000 cmd_set_txpkts_parsed(void *parsed_result,
4001 __rte_unused struct cmdline *cl,
4002 __rte_unused void *data)
4004 struct cmd_set_txpkts_result *res;
4005 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4006 unsigned int nb_segs;
4008 res = parsed_result;
4009 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4010 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4012 set_tx_pkt_segments(seg_lengths, nb_segs);
4015 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4016 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4017 cmd_keyword, "set");
4018 cmdline_parse_token_string_t cmd_set_txpkts_name =
4019 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4021 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4025 cmdline_parse_inst_t cmd_set_txpkts = {
4026 .f = cmd_set_txpkts_parsed,
4028 .help_str = "set txpkts <len0[,len1]*>",
4030 (void *)&cmd_set_txpkts_keyword,
4031 (void *)&cmd_set_txpkts_name,
4032 (void *)&cmd_set_txpkts_lengths,
4037 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4039 struct cmd_set_txsplit_result {
4040 cmdline_fixed_string_t cmd_keyword;
4041 cmdline_fixed_string_t txsplit;
4042 cmdline_fixed_string_t mode;
4046 cmd_set_txsplit_parsed(void *parsed_result,
4047 __rte_unused struct cmdline *cl,
4048 __rte_unused void *data)
4050 struct cmd_set_txsplit_result *res;
4052 res = parsed_result;
4053 set_tx_pkt_split(res->mode);
4056 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4057 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4058 cmd_keyword, "set");
4059 cmdline_parse_token_string_t cmd_set_txsplit_name =
4060 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4061 txsplit, "txsplit");
4062 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4063 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4066 cmdline_parse_inst_t cmd_set_txsplit = {
4067 .f = cmd_set_txsplit_parsed,
4069 .help_str = "set txsplit on|off|rand",
4071 (void *)&cmd_set_txsplit_keyword,
4072 (void *)&cmd_set_txsplit_name,
4073 (void *)&cmd_set_txsplit_mode,
4078 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4080 struct cmd_set_txtimes_result {
4081 cmdline_fixed_string_t cmd_keyword;
4082 cmdline_fixed_string_t txtimes;
4083 cmdline_fixed_string_t tx_times;
4087 cmd_set_txtimes_parsed(void *parsed_result,
4088 __rte_unused struct cmdline *cl,
4089 __rte_unused void *data)
4091 struct cmd_set_txtimes_result *res;
4092 unsigned int tx_times[2] = {0, 0};
4093 unsigned int n_times;
4095 res = parsed_result;
4096 n_times = parse_item_list(res->tx_times, "tx times",
4099 set_tx_pkt_times(tx_times);
4102 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4103 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4104 cmd_keyword, "set");
4105 cmdline_parse_token_string_t cmd_set_txtimes_name =
4106 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4107 txtimes, "txtimes");
4108 cmdline_parse_token_string_t cmd_set_txtimes_value =
4109 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4112 cmdline_parse_inst_t cmd_set_txtimes = {
4113 .f = cmd_set_txtimes_parsed,
4115 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4117 (void *)&cmd_set_txtimes_keyword,
4118 (void *)&cmd_set_txtimes_name,
4119 (void *)&cmd_set_txtimes_value,
4124 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4125 struct cmd_rx_vlan_filter_all_result {
4126 cmdline_fixed_string_t rx_vlan;
4127 cmdline_fixed_string_t what;
4128 cmdline_fixed_string_t all;
4133 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4134 __rte_unused struct cmdline *cl,
4135 __rte_unused void *data)
4137 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4139 if (!strcmp(res->what, "add"))
4140 rx_vlan_all_filter_set(res->port_id, 1);
4142 rx_vlan_all_filter_set(res->port_id, 0);
4145 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4146 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4147 rx_vlan, "rx_vlan");
4148 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4149 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4151 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4152 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4154 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4155 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4156 port_id, RTE_UINT16);
4158 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4159 .f = cmd_rx_vlan_filter_all_parsed,
4161 .help_str = "rx_vlan add|rm all <port_id>: "
4162 "Add/Remove all identifiers to/from the set of VLAN "
4163 "identifiers filtered by a port",
4165 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4166 (void *)&cmd_rx_vlan_filter_all_what,
4167 (void *)&cmd_rx_vlan_filter_all_all,
4168 (void *)&cmd_rx_vlan_filter_all_portid,
4173 /* *** VLAN OFFLOAD SET ON A PORT *** */
4174 struct cmd_vlan_offload_result {
4175 cmdline_fixed_string_t vlan;
4176 cmdline_fixed_string_t set;
4177 cmdline_fixed_string_t vlan_type;
4178 cmdline_fixed_string_t what;
4179 cmdline_fixed_string_t on;
4180 cmdline_fixed_string_t port_id;
4184 cmd_vlan_offload_parsed(void *parsed_result,
4185 __rte_unused struct cmdline *cl,
4186 __rte_unused void *data)
4189 struct cmd_vlan_offload_result *res = parsed_result;
4192 portid_t port_id = 0;
4196 len = strnlen(str, STR_TOKEN_SIZE);
4198 /* Get port_id first */
4206 tmp = strtoul(str, NULL, 0);
4207 /* If port_id greater that what portid_t can represent, return */
4208 if(tmp >= RTE_MAX_ETHPORTS)
4210 port_id = (portid_t)tmp;
4212 if (!strcmp(res->on, "on"))
4217 if (!strcmp(res->what, "strip"))
4218 rx_vlan_strip_set(port_id, on);
4219 else if(!strcmp(res->what, "stripq")){
4220 uint16_t queue_id = 0;
4222 /* No queue_id, return */
4224 fprintf(stderr, "must specify (port,queue_id)\n");
4227 tmp = strtoul(str + i + 1, NULL, 0);
4228 /* If queue_id greater that what 16-bits can represent, return */
4232 queue_id = (uint16_t)tmp;
4233 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4235 else if (!strcmp(res->what, "filter"))
4236 rx_vlan_filter_set(port_id, on);
4237 else if (!strcmp(res->what, "qinq_strip"))
4238 rx_vlan_qinq_strip_set(port_id, on);
4240 vlan_extend_set(port_id, on);
4245 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4246 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4248 cmdline_parse_token_string_t cmd_vlan_offload_set =
4249 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4251 cmdline_parse_token_string_t cmd_vlan_offload_what =
4252 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4253 what, "strip#filter#qinq_strip#extend#stripq");
4254 cmdline_parse_token_string_t cmd_vlan_offload_on =
4255 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4257 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4258 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4261 cmdline_parse_inst_t cmd_vlan_offload = {
4262 .f = cmd_vlan_offload_parsed,
4264 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4265 "<port_id[,queue_id]>: "
4266 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4268 (void *)&cmd_vlan_offload_vlan,
4269 (void *)&cmd_vlan_offload_set,
4270 (void *)&cmd_vlan_offload_what,
4271 (void *)&cmd_vlan_offload_on,
4272 (void *)&cmd_vlan_offload_portid,
4277 /* *** VLAN TPID SET ON A PORT *** */
4278 struct cmd_vlan_tpid_result {
4279 cmdline_fixed_string_t vlan;
4280 cmdline_fixed_string_t set;
4281 cmdline_fixed_string_t vlan_type;
4282 cmdline_fixed_string_t what;
4288 cmd_vlan_tpid_parsed(void *parsed_result,
4289 __rte_unused struct cmdline *cl,
4290 __rte_unused void *data)
4292 struct cmd_vlan_tpid_result *res = parsed_result;
4293 enum rte_vlan_type vlan_type;
4295 if (!strcmp(res->vlan_type, "inner"))
4296 vlan_type = ETH_VLAN_TYPE_INNER;
4297 else if (!strcmp(res->vlan_type, "outer"))
4298 vlan_type = ETH_VLAN_TYPE_OUTER;
4300 fprintf(stderr, "Unknown vlan type\n");
4303 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4306 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4307 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4309 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4310 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4312 cmdline_parse_token_string_t cmd_vlan_type =
4313 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4314 vlan_type, "inner#outer");
4315 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4316 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4318 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4319 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4321 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4322 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4323 port_id, RTE_UINT16);
4325 cmdline_parse_inst_t cmd_vlan_tpid = {
4326 .f = cmd_vlan_tpid_parsed,
4328 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4329 "Set the VLAN Ether type",
4331 (void *)&cmd_vlan_tpid_vlan,
4332 (void *)&cmd_vlan_tpid_set,
4333 (void *)&cmd_vlan_type,
4334 (void *)&cmd_vlan_tpid_what,
4335 (void *)&cmd_vlan_tpid_tpid,
4336 (void *)&cmd_vlan_tpid_portid,
4341 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4342 struct cmd_rx_vlan_filter_result {
4343 cmdline_fixed_string_t rx_vlan;
4344 cmdline_fixed_string_t what;
4350 cmd_rx_vlan_filter_parsed(void *parsed_result,
4351 __rte_unused struct cmdline *cl,
4352 __rte_unused void *data)
4354 struct cmd_rx_vlan_filter_result *res = parsed_result;
4356 if (!strcmp(res->what, "add"))
4357 rx_vft_set(res->port_id, res->vlan_id, 1);
4359 rx_vft_set(res->port_id, res->vlan_id, 0);
4362 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4363 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4364 rx_vlan, "rx_vlan");
4365 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4366 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4368 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4369 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4370 vlan_id, RTE_UINT16);
4371 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4372 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4373 port_id, RTE_UINT16);
4375 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4376 .f = cmd_rx_vlan_filter_parsed,
4378 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4379 "Add/Remove a VLAN identifier to/from the set of VLAN "
4380 "identifiers filtered by a port",
4382 (void *)&cmd_rx_vlan_filter_rx_vlan,
4383 (void *)&cmd_rx_vlan_filter_what,
4384 (void *)&cmd_rx_vlan_filter_vlanid,
4385 (void *)&cmd_rx_vlan_filter_portid,
4390 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4391 struct cmd_tx_vlan_set_result {
4392 cmdline_fixed_string_t tx_vlan;
4393 cmdline_fixed_string_t set;
4399 cmd_tx_vlan_set_parsed(void *parsed_result,
4400 __rte_unused struct cmdline *cl,
4401 __rte_unused void *data)
4403 struct cmd_tx_vlan_set_result *res = parsed_result;
4405 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4408 if (!port_is_stopped(res->port_id)) {
4409 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4413 tx_vlan_set(res->port_id, res->vlan_id);
4415 cmd_reconfig_device_queue(res->port_id, 1, 1);
4418 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4419 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4420 tx_vlan, "tx_vlan");
4421 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4422 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4424 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4425 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4426 port_id, RTE_UINT16);
4427 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4428 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4429 vlan_id, RTE_UINT16);
4431 cmdline_parse_inst_t cmd_tx_vlan_set = {
4432 .f = cmd_tx_vlan_set_parsed,
4434 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4435 "Enable hardware insertion of a single VLAN header "
4436 "with a given TAG Identifier in packets sent on a port",
4438 (void *)&cmd_tx_vlan_set_tx_vlan,
4439 (void *)&cmd_tx_vlan_set_set,
4440 (void *)&cmd_tx_vlan_set_portid,
4441 (void *)&cmd_tx_vlan_set_vlanid,
4446 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4447 struct cmd_tx_vlan_set_qinq_result {
4448 cmdline_fixed_string_t tx_vlan;
4449 cmdline_fixed_string_t set;
4452 uint16_t vlan_id_outer;
4456 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4457 __rte_unused struct cmdline *cl,
4458 __rte_unused void *data)
4460 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4462 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4465 if (!port_is_stopped(res->port_id)) {
4466 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4470 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4472 cmd_reconfig_device_queue(res->port_id, 1, 1);
4475 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4476 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4477 tx_vlan, "tx_vlan");
4478 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4479 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4481 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4482 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4483 port_id, RTE_UINT16);
4484 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4485 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4486 vlan_id, RTE_UINT16);
4487 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4488 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4489 vlan_id_outer, RTE_UINT16);
4491 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4492 .f = cmd_tx_vlan_set_qinq_parsed,
4494 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4495 "Enable hardware insertion of double VLAN header "
4496 "with given TAG Identifiers in packets sent on a port",
4498 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4499 (void *)&cmd_tx_vlan_set_qinq_set,
4500 (void *)&cmd_tx_vlan_set_qinq_portid,
4501 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4502 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4507 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4508 struct cmd_tx_vlan_set_pvid_result {
4509 cmdline_fixed_string_t tx_vlan;
4510 cmdline_fixed_string_t set;
4511 cmdline_fixed_string_t pvid;
4514 cmdline_fixed_string_t mode;
4518 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4519 __rte_unused struct cmdline *cl,
4520 __rte_unused void *data)
4522 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4524 if (strcmp(res->mode, "on") == 0)
4525 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4527 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4530 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4531 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4532 tx_vlan, "tx_vlan");
4533 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4534 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4536 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4537 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4539 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4540 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4541 port_id, RTE_UINT16);
4542 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4543 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4544 vlan_id, RTE_UINT16);
4545 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4546 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4549 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4550 .f = cmd_tx_vlan_set_pvid_parsed,
4552 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4554 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4555 (void *)&cmd_tx_vlan_set_pvid_set,
4556 (void *)&cmd_tx_vlan_set_pvid_pvid,
4557 (void *)&cmd_tx_vlan_set_pvid_port_id,
4558 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4559 (void *)&cmd_tx_vlan_set_pvid_mode,
4564 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4565 struct cmd_tx_vlan_reset_result {
4566 cmdline_fixed_string_t tx_vlan;
4567 cmdline_fixed_string_t reset;
4572 cmd_tx_vlan_reset_parsed(void *parsed_result,
4573 __rte_unused struct cmdline *cl,
4574 __rte_unused void *data)
4576 struct cmd_tx_vlan_reset_result *res = parsed_result;
4578 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4581 if (!port_is_stopped(res->port_id)) {
4582 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4586 tx_vlan_reset(res->port_id);
4588 cmd_reconfig_device_queue(res->port_id, 1, 1);
4591 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4592 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4593 tx_vlan, "tx_vlan");
4594 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4595 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4597 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4598 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4599 port_id, RTE_UINT16);
4601 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4602 .f = cmd_tx_vlan_reset_parsed,
4604 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4605 "VLAN header in packets sent on a port",
4607 (void *)&cmd_tx_vlan_reset_tx_vlan,
4608 (void *)&cmd_tx_vlan_reset_reset,
4609 (void *)&cmd_tx_vlan_reset_portid,
4615 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4616 struct cmd_csum_result {
4617 cmdline_fixed_string_t csum;
4618 cmdline_fixed_string_t mode;
4619 cmdline_fixed_string_t proto;
4620 cmdline_fixed_string_t hwsw;
4625 csum_show(int port_id)
4627 struct rte_eth_dev_info dev_info;
4628 uint64_t tx_offloads;
4631 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4632 printf("Parse tunnel is %s\n",
4633 (ports[port_id].parse_tunnel) ? "on" : "off");
4634 printf("IP checksum offload is %s\n",
4635 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4636 printf("UDP checksum offload is %s\n",
4637 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4638 printf("TCP checksum offload is %s\n",
4639 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4640 printf("SCTP checksum offload is %s\n",
4641 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4642 printf("Outer-Ip checksum offload is %s\n",
4643 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4644 printf("Outer-Udp checksum offload is %s\n",
4645 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4647 /* display warnings if configuration is not supported by the NIC */
4648 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4652 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4653 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4655 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4658 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4659 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4661 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4664 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4665 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4667 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4670 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4671 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4673 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4676 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4677 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4679 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4682 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4683 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4686 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4692 cmd_config_queue_tx_offloads(struct rte_port *port)
4696 /* Apply queue tx offloads configuration */
4697 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4698 port->tx_conf[k].offloads =
4699 port->dev_conf.txmode.offloads;
4703 cmd_csum_parsed(void *parsed_result,
4704 __rte_unused struct cmdline *cl,
4705 __rte_unused void *data)
4707 struct cmd_csum_result *res = parsed_result;
4709 uint64_t csum_offloads = 0;
4710 struct rte_eth_dev_info dev_info;
4713 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4714 fprintf(stderr, "invalid port %d\n", res->port_id);
4717 if (!port_is_stopped(res->port_id)) {
4718 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4722 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4726 if (!strcmp(res->mode, "set")) {
4728 if (!strcmp(res->hwsw, "hw"))
4731 if (!strcmp(res->proto, "ip")) {
4732 if (hw == 0 || (dev_info.tx_offload_capa &
4733 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4734 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4737 "IP checksum offload is not supported by port %u\n",
4740 } else if (!strcmp(res->proto, "udp")) {
4741 if (hw == 0 || (dev_info.tx_offload_capa &
4742 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4743 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4746 "UDP checksum offload is not supported by port %u\n",
4749 } else if (!strcmp(res->proto, "tcp")) {
4750 if (hw == 0 || (dev_info.tx_offload_capa &
4751 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4752 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4755 "TCP checksum offload is not supported by port %u\n",
4758 } else if (!strcmp(res->proto, "sctp")) {
4759 if (hw == 0 || (dev_info.tx_offload_capa &
4760 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4761 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4764 "SCTP checksum offload is not supported by port %u\n",
4767 } else if (!strcmp(res->proto, "outer-ip")) {
4768 if (hw == 0 || (dev_info.tx_offload_capa &
4769 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4771 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4774 "Outer IP checksum offload is not supported by port %u\n",
4777 } else if (!strcmp(res->proto, "outer-udp")) {
4778 if (hw == 0 || (dev_info.tx_offload_capa &
4779 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4781 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4784 "Outer UDP checksum offload is not supported by port %u\n",
4790 ports[res->port_id].dev_conf.txmode.offloads |=
4793 ports[res->port_id].dev_conf.txmode.offloads &=
4796 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4798 csum_show(res->port_id);
4800 cmd_reconfig_device_queue(res->port_id, 1, 1);
4803 cmdline_parse_token_string_t cmd_csum_csum =
4804 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4806 cmdline_parse_token_string_t cmd_csum_mode =
4807 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4809 cmdline_parse_token_string_t cmd_csum_proto =
4810 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4811 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4812 cmdline_parse_token_string_t cmd_csum_hwsw =
4813 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4815 cmdline_parse_token_num_t cmd_csum_portid =
4816 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4817 port_id, RTE_UINT16);
4819 cmdline_parse_inst_t cmd_csum_set = {
4820 .f = cmd_csum_parsed,
4822 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4823 "Enable/Disable hardware calculation of L3/L4 checksum when "
4824 "using csum forward engine",
4826 (void *)&cmd_csum_csum,
4827 (void *)&cmd_csum_mode,
4828 (void *)&cmd_csum_proto,
4829 (void *)&cmd_csum_hwsw,
4830 (void *)&cmd_csum_portid,
4835 cmdline_parse_token_string_t cmd_csum_mode_show =
4836 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4839 cmdline_parse_inst_t cmd_csum_show = {
4840 .f = cmd_csum_parsed,
4842 .help_str = "csum show <port_id>: Show checksum offload configuration",
4844 (void *)&cmd_csum_csum,
4845 (void *)&cmd_csum_mode_show,
4846 (void *)&cmd_csum_portid,
4851 /* Enable/disable tunnel parsing */
4852 struct cmd_csum_tunnel_result {
4853 cmdline_fixed_string_t csum;
4854 cmdline_fixed_string_t parse;
4855 cmdline_fixed_string_t onoff;
4860 cmd_csum_tunnel_parsed(void *parsed_result,
4861 __rte_unused struct cmdline *cl,
4862 __rte_unused void *data)
4864 struct cmd_csum_tunnel_result *res = parsed_result;
4866 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4869 if (!strcmp(res->onoff, "on"))
4870 ports[res->port_id].parse_tunnel = 1;
4872 ports[res->port_id].parse_tunnel = 0;
4874 csum_show(res->port_id);
4877 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4878 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4880 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4881 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4882 parse, "parse-tunnel");
4883 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4884 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4886 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4887 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4888 port_id, RTE_UINT16);
4890 cmdline_parse_inst_t cmd_csum_tunnel = {
4891 .f = cmd_csum_tunnel_parsed,
4893 .help_str = "csum parse-tunnel on|off <port_id>: "
4894 "Enable/Disable parsing of tunnels for csum engine",
4896 (void *)&cmd_csum_tunnel_csum,
4897 (void *)&cmd_csum_tunnel_parse,
4898 (void *)&cmd_csum_tunnel_onoff,
4899 (void *)&cmd_csum_tunnel_portid,
4904 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4905 struct cmd_tso_set_result {
4906 cmdline_fixed_string_t tso;
4907 cmdline_fixed_string_t mode;
4913 cmd_tso_set_parsed(void *parsed_result,
4914 __rte_unused struct cmdline *cl,
4915 __rte_unused void *data)
4917 struct cmd_tso_set_result *res = parsed_result;
4918 struct rte_eth_dev_info dev_info;
4921 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4923 if (!port_is_stopped(res->port_id)) {
4924 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4928 if (!strcmp(res->mode, "set"))
4929 ports[res->port_id].tso_segsz = res->tso_segsz;
4931 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4935 if ((ports[res->port_id].tso_segsz != 0) &&
4936 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4937 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4942 if (ports[res->port_id].tso_segsz == 0) {
4943 ports[res->port_id].dev_conf.txmode.offloads &=
4944 ~DEV_TX_OFFLOAD_TCP_TSO;
4945 printf("TSO for non-tunneled packets is disabled\n");
4947 ports[res->port_id].dev_conf.txmode.offloads |=
4948 DEV_TX_OFFLOAD_TCP_TSO;
4949 printf("TSO segment size for non-tunneled packets is %d\n",
4950 ports[res->port_id].tso_segsz);
4952 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4954 /* display warnings if configuration is not supported by the NIC */
4955 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4959 if ((ports[res->port_id].tso_segsz != 0) &&
4960 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4962 "Warning: TSO enabled but not supported by port %d\n",
4966 cmd_reconfig_device_queue(res->port_id, 1, 1);
4969 cmdline_parse_token_string_t cmd_tso_set_tso =
4970 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4972 cmdline_parse_token_string_t cmd_tso_set_mode =
4973 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4975 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4976 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4977 tso_segsz, RTE_UINT16);
4978 cmdline_parse_token_num_t cmd_tso_set_portid =
4979 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4980 port_id, RTE_UINT16);
4982 cmdline_parse_inst_t cmd_tso_set = {
4983 .f = cmd_tso_set_parsed,
4985 .help_str = "tso set <tso_segsz> <port_id>: "
4986 "Set TSO segment size of non-tunneled packets for csum engine "
4989 (void *)&cmd_tso_set_tso,
4990 (void *)&cmd_tso_set_mode,
4991 (void *)&cmd_tso_set_tso_segsz,
4992 (void *)&cmd_tso_set_portid,
4997 cmdline_parse_token_string_t cmd_tso_show_mode =
4998 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5002 cmdline_parse_inst_t cmd_tso_show = {
5003 .f = cmd_tso_set_parsed,
5005 .help_str = "tso show <port_id>: "
5006 "Show TSO segment size of non-tunneled packets for csum engine",
5008 (void *)&cmd_tso_set_tso,
5009 (void *)&cmd_tso_show_mode,
5010 (void *)&cmd_tso_set_portid,
5015 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5016 struct cmd_tunnel_tso_set_result {
5017 cmdline_fixed_string_t tso;
5018 cmdline_fixed_string_t mode;
5023 static struct rte_eth_dev_info
5024 check_tunnel_tso_nic_support(portid_t port_id)
5026 struct rte_eth_dev_info dev_info;
5028 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5031 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5033 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5035 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5037 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5039 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5041 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5043 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5045 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5047 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5049 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5051 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5053 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5059 cmd_tunnel_tso_set_parsed(void *parsed_result,
5060 __rte_unused struct cmdline *cl,
5061 __rte_unused void *data)
5063 struct cmd_tunnel_tso_set_result *res = parsed_result;
5064 struct rte_eth_dev_info dev_info;
5066 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5068 if (!port_is_stopped(res->port_id)) {
5069 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5073 if (!strcmp(res->mode, "set"))
5074 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5076 dev_info = check_tunnel_tso_nic_support(res->port_id);
5077 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5078 ports[res->port_id].dev_conf.txmode.offloads &=
5079 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5080 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5081 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5082 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5083 DEV_TX_OFFLOAD_IP_TNL_TSO |
5084 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5085 printf("TSO for tunneled packets is disabled\n");
5087 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5088 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5089 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5090 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5091 DEV_TX_OFFLOAD_IP_TNL_TSO |
5092 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5094 ports[res->port_id].dev_conf.txmode.offloads |=
5095 (tso_offloads & dev_info.tx_offload_capa);
5096 printf("TSO segment size for tunneled packets is %d\n",
5097 ports[res->port_id].tunnel_tso_segsz);
5099 /* Below conditions are needed to make it work:
5100 * (1) tunnel TSO is supported by the NIC;
5101 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5103 * (3) for tunneled pkts with outer L3 of IPv4,
5104 * "csum set outer-ip" must be set to hw, because after tso,
5105 * total_len of outer IP header is changed, and the checksum
5106 * of outer IP header calculated by sw should be wrong; that
5107 * is not necessary for IPv6 tunneled pkts because there's no
5108 * checksum in IP header anymore.
5111 if (!ports[res->port_id].parse_tunnel)
5113 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5114 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5115 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5117 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5120 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5121 cmd_reconfig_device_queue(res->port_id, 1, 1);
5124 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5125 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5127 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5128 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5130 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5131 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5132 tso_segsz, RTE_UINT16);
5133 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5134 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5135 port_id, RTE_UINT16);
5137 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5138 .f = cmd_tunnel_tso_set_parsed,
5140 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5141 "Set TSO segment size of tunneled packets for csum engine "
5144 (void *)&cmd_tunnel_tso_set_tso,
5145 (void *)&cmd_tunnel_tso_set_mode,
5146 (void *)&cmd_tunnel_tso_set_tso_segsz,
5147 (void *)&cmd_tunnel_tso_set_portid,
5152 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5153 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5157 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5158 .f = cmd_tunnel_tso_set_parsed,
5160 .help_str = "tunnel_tso show <port_id> "
5161 "Show TSO segment size of tunneled packets for csum engine",
5163 (void *)&cmd_tunnel_tso_set_tso,
5164 (void *)&cmd_tunnel_tso_show_mode,
5165 (void *)&cmd_tunnel_tso_set_portid,
5170 /* *** SET GRO FOR A PORT *** */
5171 struct cmd_gro_enable_result {
5172 cmdline_fixed_string_t cmd_set;
5173 cmdline_fixed_string_t cmd_port;
5174 cmdline_fixed_string_t cmd_keyword;
5175 cmdline_fixed_string_t cmd_onoff;
5180 cmd_gro_enable_parsed(void *parsed_result,
5181 __rte_unused struct cmdline *cl,
5182 __rte_unused void *data)
5184 struct cmd_gro_enable_result *res;
5186 res = parsed_result;
5187 if (!strcmp(res->cmd_keyword, "gro"))
5188 setup_gro(res->cmd_onoff, res->cmd_pid);
5191 cmdline_parse_token_string_t cmd_gro_enable_set =
5192 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5194 cmdline_parse_token_string_t cmd_gro_enable_port =
5195 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5196 cmd_keyword, "port");
5197 cmdline_parse_token_num_t cmd_gro_enable_pid =
5198 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5199 cmd_pid, RTE_UINT16);
5200 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5201 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5202 cmd_keyword, "gro");
5203 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5204 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5205 cmd_onoff, "on#off");
5207 cmdline_parse_inst_t cmd_gro_enable = {
5208 .f = cmd_gro_enable_parsed,
5210 .help_str = "set port <port_id> gro on|off",
5212 (void *)&cmd_gro_enable_set,
5213 (void *)&cmd_gro_enable_port,
5214 (void *)&cmd_gro_enable_pid,
5215 (void *)&cmd_gro_enable_keyword,
5216 (void *)&cmd_gro_enable_onoff,
5221 /* *** DISPLAY GRO CONFIGURATION *** */
5222 struct cmd_gro_show_result {
5223 cmdline_fixed_string_t cmd_show;
5224 cmdline_fixed_string_t cmd_port;
5225 cmdline_fixed_string_t cmd_keyword;
5230 cmd_gro_show_parsed(void *parsed_result,
5231 __rte_unused struct cmdline *cl,
5232 __rte_unused void *data)
5234 struct cmd_gro_show_result *res;
5236 res = parsed_result;
5237 if (!strcmp(res->cmd_keyword, "gro"))
5238 show_gro(res->cmd_pid);
5241 cmdline_parse_token_string_t cmd_gro_show_show =
5242 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5244 cmdline_parse_token_string_t cmd_gro_show_port =
5245 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5247 cmdline_parse_token_num_t cmd_gro_show_pid =
5248 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5249 cmd_pid, RTE_UINT16);
5250 cmdline_parse_token_string_t cmd_gro_show_keyword =
5251 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5252 cmd_keyword, "gro");
5254 cmdline_parse_inst_t cmd_gro_show = {
5255 .f = cmd_gro_show_parsed,
5257 .help_str = "show port <port_id> gro",
5259 (void *)&cmd_gro_show_show,
5260 (void *)&cmd_gro_show_port,
5261 (void *)&cmd_gro_show_pid,
5262 (void *)&cmd_gro_show_keyword,
5267 /* *** SET FLUSH CYCLES FOR GRO *** */
5268 struct cmd_gro_flush_result {
5269 cmdline_fixed_string_t cmd_set;
5270 cmdline_fixed_string_t cmd_keyword;
5271 cmdline_fixed_string_t cmd_flush;
5276 cmd_gro_flush_parsed(void *parsed_result,
5277 __rte_unused struct cmdline *cl,
5278 __rte_unused void *data)
5280 struct cmd_gro_flush_result *res;
5282 res = parsed_result;
5283 if ((!strcmp(res->cmd_keyword, "gro")) &&
5284 (!strcmp(res->cmd_flush, "flush")))
5285 setup_gro_flush_cycles(res->cmd_cycles);
5288 cmdline_parse_token_string_t cmd_gro_flush_set =
5289 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5291 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5292 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5293 cmd_keyword, "gro");
5294 cmdline_parse_token_string_t cmd_gro_flush_flush =
5295 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5296 cmd_flush, "flush");
5297 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5298 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5299 cmd_cycles, RTE_UINT8);
5301 cmdline_parse_inst_t cmd_gro_flush = {
5302 .f = cmd_gro_flush_parsed,
5304 .help_str = "set gro flush <cycles>",
5306 (void *)&cmd_gro_flush_set,
5307 (void *)&cmd_gro_flush_keyword,
5308 (void *)&cmd_gro_flush_flush,
5309 (void *)&cmd_gro_flush_cycles,
5314 /* *** ENABLE/DISABLE GSO *** */
5315 struct cmd_gso_enable_result {
5316 cmdline_fixed_string_t cmd_set;
5317 cmdline_fixed_string_t cmd_port;
5318 cmdline_fixed_string_t cmd_keyword;
5319 cmdline_fixed_string_t cmd_mode;
5324 cmd_gso_enable_parsed(void *parsed_result,
5325 __rte_unused struct cmdline *cl,
5326 __rte_unused void *data)
5328 struct cmd_gso_enable_result *res;
5330 res = parsed_result;
5331 if (!strcmp(res->cmd_keyword, "gso"))
5332 setup_gso(res->cmd_mode, res->cmd_pid);
5335 cmdline_parse_token_string_t cmd_gso_enable_set =
5336 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5338 cmdline_parse_token_string_t cmd_gso_enable_port =
5339 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5341 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5342 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5343 cmd_keyword, "gso");
5344 cmdline_parse_token_string_t cmd_gso_enable_mode =
5345 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5346 cmd_mode, "on#off");
5347 cmdline_parse_token_num_t cmd_gso_enable_pid =
5348 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5349 cmd_pid, RTE_UINT16);
5351 cmdline_parse_inst_t cmd_gso_enable = {
5352 .f = cmd_gso_enable_parsed,
5354 .help_str = "set port <port_id> gso on|off",
5356 (void *)&cmd_gso_enable_set,
5357 (void *)&cmd_gso_enable_port,
5358 (void *)&cmd_gso_enable_pid,
5359 (void *)&cmd_gso_enable_keyword,
5360 (void *)&cmd_gso_enable_mode,
5365 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5366 struct cmd_gso_size_result {
5367 cmdline_fixed_string_t cmd_set;
5368 cmdline_fixed_string_t cmd_keyword;
5369 cmdline_fixed_string_t cmd_segsz;
5374 cmd_gso_size_parsed(void *parsed_result,
5375 __rte_unused struct cmdline *cl,
5376 __rte_unused void *data)
5378 struct cmd_gso_size_result *res = parsed_result;
5380 if (test_done == 0) {
5382 "Before setting GSO segsz, please first stop forwarding\n");
5386 if (!strcmp(res->cmd_keyword, "gso") &&
5387 !strcmp(res->cmd_segsz, "segsz")) {
5388 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5390 "gso_size should be larger than %zu. Please input a legal value\n",
5391 RTE_GSO_SEG_SIZE_MIN);
5393 gso_max_segment_size = res->cmd_size;
5397 cmdline_parse_token_string_t cmd_gso_size_set =
5398 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5400 cmdline_parse_token_string_t cmd_gso_size_keyword =
5401 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5402 cmd_keyword, "gso");
5403 cmdline_parse_token_string_t cmd_gso_size_segsz =
5404 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5405 cmd_segsz, "segsz");
5406 cmdline_parse_token_num_t cmd_gso_size_size =
5407 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5408 cmd_size, RTE_UINT16);
5410 cmdline_parse_inst_t cmd_gso_size = {
5411 .f = cmd_gso_size_parsed,
5413 .help_str = "set gso segsz <length>",
5415 (void *)&cmd_gso_size_set,
5416 (void *)&cmd_gso_size_keyword,
5417 (void *)&cmd_gso_size_segsz,
5418 (void *)&cmd_gso_size_size,
5423 /* *** SHOW GSO CONFIGURATION *** */
5424 struct cmd_gso_show_result {
5425 cmdline_fixed_string_t cmd_show;
5426 cmdline_fixed_string_t cmd_port;
5427 cmdline_fixed_string_t cmd_keyword;
5432 cmd_gso_show_parsed(void *parsed_result,
5433 __rte_unused struct cmdline *cl,
5434 __rte_unused void *data)
5436 struct cmd_gso_show_result *res = parsed_result;
5438 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5439 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5442 if (!strcmp(res->cmd_keyword, "gso")) {
5443 if (gso_ports[res->cmd_pid].enable) {
5444 printf("Max GSO'd packet size: %uB\n"
5445 "Supported GSO types: TCP/IPv4, "
5446 "UDP/IPv4, VxLAN with inner "
5447 "TCP/IPv4 packet, GRE with inner "
5448 "TCP/IPv4 packet\n",
5449 gso_max_segment_size);
5451 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5455 cmdline_parse_token_string_t cmd_gso_show_show =
5456 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5458 cmdline_parse_token_string_t cmd_gso_show_port =
5459 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5461 cmdline_parse_token_string_t cmd_gso_show_keyword =
5462 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5463 cmd_keyword, "gso");
5464 cmdline_parse_token_num_t cmd_gso_show_pid =
5465 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5466 cmd_pid, RTE_UINT16);
5468 cmdline_parse_inst_t cmd_gso_show = {
5469 .f = cmd_gso_show_parsed,
5471 .help_str = "show port <port_id> gso",
5473 (void *)&cmd_gso_show_show,
5474 (void *)&cmd_gso_show_port,
5475 (void *)&cmd_gso_show_pid,
5476 (void *)&cmd_gso_show_keyword,
5481 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5482 struct cmd_set_flush_rx {
5483 cmdline_fixed_string_t set;
5484 cmdline_fixed_string_t flush_rx;
5485 cmdline_fixed_string_t mode;
5489 cmd_set_flush_rx_parsed(void *parsed_result,
5490 __rte_unused struct cmdline *cl,
5491 __rte_unused void *data)
5493 struct cmd_set_flush_rx *res = parsed_result;
5495 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5496 printf("multi-process doesn't support to flush Rx queues.\n");
5500 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5503 cmdline_parse_token_string_t cmd_setflushrx_set =
5504 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5506 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5507 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5508 flush_rx, "flush_rx");
5509 cmdline_parse_token_string_t cmd_setflushrx_mode =
5510 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5514 cmdline_parse_inst_t cmd_set_flush_rx = {
5515 .f = cmd_set_flush_rx_parsed,
5516 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5519 (void *)&cmd_setflushrx_set,
5520 (void *)&cmd_setflushrx_flush_rx,
5521 (void *)&cmd_setflushrx_mode,
5526 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5527 struct cmd_set_link_check {
5528 cmdline_fixed_string_t set;
5529 cmdline_fixed_string_t link_check;
5530 cmdline_fixed_string_t mode;
5534 cmd_set_link_check_parsed(void *parsed_result,
5535 __rte_unused struct cmdline *cl,
5536 __rte_unused void *data)
5538 struct cmd_set_link_check *res = parsed_result;
5539 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5542 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5545 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5547 link_check, "link_check");
5548 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5553 cmdline_parse_inst_t cmd_set_link_check = {
5554 .f = cmd_set_link_check_parsed,
5555 .help_str = "set link_check on|off: Enable/Disable link status check "
5556 "when starting/stopping a port",
5559 (void *)&cmd_setlinkcheck_set,
5560 (void *)&cmd_setlinkcheck_link_check,
5561 (void *)&cmd_setlinkcheck_mode,
5566 /* *** SET NIC BYPASS MODE *** */
5567 struct cmd_set_bypass_mode_result {
5568 cmdline_fixed_string_t set;
5569 cmdline_fixed_string_t bypass;
5570 cmdline_fixed_string_t mode;
5571 cmdline_fixed_string_t value;
5576 cmd_set_bypass_mode_parsed(void *parsed_result,
5577 __rte_unused struct cmdline *cl,
5578 __rte_unused void *data)
5580 struct cmd_set_bypass_mode_result *res = parsed_result;
5581 portid_t port_id = res->port_id;
5582 int32_t rc = -EINVAL;
5584 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5585 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5587 if (!strcmp(res->value, "bypass"))
5588 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5589 else if (!strcmp(res->value, "isolate"))
5590 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5592 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5594 /* Set the bypass mode for the relevant port. */
5595 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5598 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5602 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5603 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5605 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5606 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5608 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5609 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5611 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5612 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5613 value, "normal#bypass#isolate");
5614 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5615 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5616 port_id, RTE_UINT16);
5618 cmdline_parse_inst_t cmd_set_bypass_mode = {
5619 .f = cmd_set_bypass_mode_parsed,
5620 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5621 "Set the NIC bypass mode for port_id",
5624 (void *)&cmd_setbypass_mode_set,
5625 (void *)&cmd_setbypass_mode_bypass,
5626 (void *)&cmd_setbypass_mode_mode,
5627 (void *)&cmd_setbypass_mode_value,
5628 (void *)&cmd_setbypass_mode_port,
5633 /* *** SET NIC BYPASS EVENT *** */
5634 struct cmd_set_bypass_event_result {
5635 cmdline_fixed_string_t set;
5636 cmdline_fixed_string_t bypass;
5637 cmdline_fixed_string_t event;
5638 cmdline_fixed_string_t event_value;
5639 cmdline_fixed_string_t mode;
5640 cmdline_fixed_string_t mode_value;
5645 cmd_set_bypass_event_parsed(void *parsed_result,
5646 __rte_unused struct cmdline *cl,
5647 __rte_unused void *data)
5649 int32_t rc = -EINVAL;
5650 struct cmd_set_bypass_event_result *res = parsed_result;
5651 portid_t port_id = res->port_id;
5653 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5654 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5655 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5657 if (!strcmp(res->event_value, "timeout"))
5658 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5659 else if (!strcmp(res->event_value, "os_on"))
5660 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5661 else if (!strcmp(res->event_value, "os_off"))
5662 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5663 else if (!strcmp(res->event_value, "power_on"))
5664 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5665 else if (!strcmp(res->event_value, "power_off"))
5666 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5668 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5670 if (!strcmp(res->mode_value, "bypass"))
5671 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5672 else if (!strcmp(res->mode_value, "isolate"))
5673 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5675 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5677 /* Set the watchdog timeout. */
5678 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5681 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5682 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5687 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5688 bypass_timeout, port_id, rc);
5692 /* Set the bypass event to transition to bypass mode. */
5693 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5698 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5702 cmdline_parse_token_string_t cmd_setbypass_event_set =
5703 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5705 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5706 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5708 cmdline_parse_token_string_t cmd_setbypass_event_event =
5709 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5711 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5712 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5713 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5714 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5715 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5717 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5718 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5719 mode_value, "normal#bypass#isolate");
5720 cmdline_parse_token_num_t cmd_setbypass_event_port =
5721 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5722 port_id, RTE_UINT16);
5724 cmdline_parse_inst_t cmd_set_bypass_event = {
5725 .f = cmd_set_bypass_event_parsed,
5726 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5727 "power_off mode normal|bypass|isolate <port_id>: "
5728 "Set the NIC bypass event mode for port_id",
5731 (void *)&cmd_setbypass_event_set,
5732 (void *)&cmd_setbypass_event_bypass,
5733 (void *)&cmd_setbypass_event_event,
5734 (void *)&cmd_setbypass_event_event_value,
5735 (void *)&cmd_setbypass_event_mode,
5736 (void *)&cmd_setbypass_event_mode_value,
5737 (void *)&cmd_setbypass_event_port,
5743 /* *** SET NIC BYPASS TIMEOUT *** */
5744 struct cmd_set_bypass_timeout_result {
5745 cmdline_fixed_string_t set;
5746 cmdline_fixed_string_t bypass;
5747 cmdline_fixed_string_t timeout;
5748 cmdline_fixed_string_t value;
5752 cmd_set_bypass_timeout_parsed(void *parsed_result,
5753 __rte_unused struct cmdline *cl,
5754 __rte_unused void *data)
5756 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5758 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5759 if (!strcmp(res->value, "1.5"))
5760 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5761 else if (!strcmp(res->value, "2"))
5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5763 else if (!strcmp(res->value, "3"))
5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5765 else if (!strcmp(res->value, "4"))
5766 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5767 else if (!strcmp(res->value, "8"))
5768 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5769 else if (!strcmp(res->value, "16"))
5770 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5771 else if (!strcmp(res->value, "32"))
5772 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5774 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5778 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5779 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5781 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5784 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5785 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5786 timeout, "timeout");
5787 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5788 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5789 value, "0#1.5#2#3#4#8#16#32");
5791 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5792 .f = cmd_set_bypass_timeout_parsed,
5793 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5794 "Set the NIC bypass watchdog timeout in seconds",
5797 (void *)&cmd_setbypass_timeout_set,
5798 (void *)&cmd_setbypass_timeout_bypass,
5799 (void *)&cmd_setbypass_timeout_timeout,
5800 (void *)&cmd_setbypass_timeout_value,
5805 /* *** SHOW NIC BYPASS MODE *** */
5806 struct cmd_show_bypass_config_result {
5807 cmdline_fixed_string_t show;
5808 cmdline_fixed_string_t bypass;
5809 cmdline_fixed_string_t config;
5814 cmd_show_bypass_config_parsed(void *parsed_result,
5815 __rte_unused struct cmdline *cl,
5816 __rte_unused void *data)
5818 struct cmd_show_bypass_config_result *res = parsed_result;
5819 portid_t port_id = res->port_id;
5821 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5822 uint32_t event_mode;
5823 uint32_t bypass_mode;
5824 uint32_t timeout = bypass_timeout;
5827 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5828 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5829 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5830 {"UNKNOWN", "normal", "bypass", "isolate"};
5831 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5839 /* Display the bypass mode.*/
5840 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5841 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5846 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5847 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5849 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5852 /* Display the bypass timeout.*/
5853 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5854 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5856 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5858 /* Display the bypass events and associated modes. */
5859 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5861 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5863 "\tFailed to get bypass mode for event = %s\n",
5866 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5867 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5869 printf("\tbypass event: %-16s = %s\n", events[i],
5876 "\tFailed to get bypass configuration for port = %d\n",
5880 cmdline_parse_token_string_t cmd_showbypass_config_show =
5881 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5883 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5884 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5886 cmdline_parse_token_string_t cmd_showbypass_config_config =
5887 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5889 cmdline_parse_token_num_t cmd_showbypass_config_port =
5890 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5891 port_id, RTE_UINT16);
5893 cmdline_parse_inst_t cmd_show_bypass_config = {
5894 .f = cmd_show_bypass_config_parsed,
5895 .help_str = "show bypass config <port_id>: "
5896 "Show the NIC bypass config for port_id",
5899 (void *)&cmd_showbypass_config_show,
5900 (void *)&cmd_showbypass_config_bypass,
5901 (void *)&cmd_showbypass_config_config,
5902 (void *)&cmd_showbypass_config_port,
5908 /* *** SET BONDING MODE *** */
5909 struct cmd_set_bonding_mode_result {
5910 cmdline_fixed_string_t set;
5911 cmdline_fixed_string_t bonding;
5912 cmdline_fixed_string_t mode;
5917 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5918 __rte_unused struct cmdline *cl,
5919 __rte_unused void *data)
5921 struct cmd_set_bonding_mode_result *res = parsed_result;
5922 portid_t port_id = res->port_id;
5924 /* Set the bonding mode for the relevant port. */
5925 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5926 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5930 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5933 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5934 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5935 bonding, "bonding");
5936 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5937 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5939 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5940 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5942 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5943 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5944 port_id, RTE_UINT16);
5946 cmdline_parse_inst_t cmd_set_bonding_mode = {
5947 .f = cmd_set_bonding_mode_parsed,
5948 .help_str = "set bonding mode <mode_value> <port_id>: "
5949 "Set the bonding mode for port_id",
5952 (void *) &cmd_setbonding_mode_set,
5953 (void *) &cmd_setbonding_mode_bonding,
5954 (void *) &cmd_setbonding_mode_mode,
5955 (void *) &cmd_setbonding_mode_value,
5956 (void *) &cmd_setbonding_mode_port,
5961 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5962 struct cmd_set_bonding_lacp_dedicated_queues_result {
5963 cmdline_fixed_string_t set;
5964 cmdline_fixed_string_t bonding;
5965 cmdline_fixed_string_t lacp;
5966 cmdline_fixed_string_t dedicated_queues;
5968 cmdline_fixed_string_t mode;
5971 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5972 __rte_unused struct cmdline *cl,
5973 __rte_unused void *data)
5975 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5976 portid_t port_id = res->port_id;
5977 struct rte_port *port;
5979 port = &ports[port_id];
5981 /** Check if the port is not started **/
5982 if (port->port_status != RTE_PORT_STOPPED) {
5983 fprintf(stderr, "Please stop port %d first\n", port_id);
5987 if (!strcmp(res->mode, "enable")) {
5988 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5989 printf("Dedicate queues for LACP control packets"
5992 printf("Enabling dedicate queues for LACP control "
5993 "packets on port %d failed\n", port_id);
5994 } else if (!strcmp(res->mode, "disable")) {
5995 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5996 printf("Dedicated queues for LACP control packets "
5999 printf("Disabling dedicated queues for LACP control "
6000 "traffic on port %d failed\n", port_id);
6004 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6005 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6007 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6008 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6009 bonding, "bonding");
6010 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6011 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6013 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6014 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6015 dedicated_queues, "dedicated_queues");
6016 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6017 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6018 port_id, RTE_UINT16);
6019 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6020 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6021 mode, "enable#disable");
6023 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6024 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6025 .help_str = "set bonding lacp dedicated_queues <port_id> "
6027 "Enable/disable dedicated queues for LACP control traffic for port_id",
6030 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6031 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6032 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6033 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6034 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6035 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6040 /* *** SET BALANCE XMIT POLICY *** */
6041 struct cmd_set_bonding_balance_xmit_policy_result {
6042 cmdline_fixed_string_t set;
6043 cmdline_fixed_string_t bonding;
6044 cmdline_fixed_string_t balance_xmit_policy;
6046 cmdline_fixed_string_t policy;
6049 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6050 __rte_unused struct cmdline *cl,
6051 __rte_unused void *data)
6053 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6054 portid_t port_id = res->port_id;
6057 if (!strcmp(res->policy, "l2")) {
6058 policy = BALANCE_XMIT_POLICY_LAYER2;
6059 } else if (!strcmp(res->policy, "l23")) {
6060 policy = BALANCE_XMIT_POLICY_LAYER23;
6061 } else if (!strcmp(res->policy, "l34")) {
6062 policy = BALANCE_XMIT_POLICY_LAYER34;
6064 fprintf(stderr, "\t Invalid xmit policy selection");
6068 /* Set the bonding mode for the relevant port. */
6069 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6071 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6076 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6077 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6079 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6080 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6081 bonding, "bonding");
6082 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6083 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6084 balance_xmit_policy, "balance_xmit_policy");
6085 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6086 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6087 port_id, RTE_UINT16);
6088 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6089 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6090 policy, "l2#l23#l34");
6092 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6093 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6094 .help_str = "set bonding balance_xmit_policy <port_id> "
6096 "Set the bonding balance_xmit_policy for port_id",
6099 (void *)&cmd_setbonding_balance_xmit_policy_set,
6100 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6101 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6102 (void *)&cmd_setbonding_balance_xmit_policy_port,
6103 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6108 /* *** SHOW NIC BONDING CONFIGURATION *** */
6109 struct cmd_show_bonding_config_result {
6110 cmdline_fixed_string_t show;
6111 cmdline_fixed_string_t bonding;
6112 cmdline_fixed_string_t config;
6116 static void cmd_show_bonding_config_parsed(void *parsed_result,
6117 __rte_unused struct cmdline *cl,
6118 __rte_unused void *data)
6120 struct cmd_show_bonding_config_result *res = parsed_result;
6121 int bonding_mode, agg_mode;
6122 portid_t slaves[RTE_MAX_ETHPORTS];
6123 int num_slaves, num_active_slaves;
6126 portid_t port_id = res->port_id;
6128 /* Display the bonding mode.*/
6129 bonding_mode = rte_eth_bond_mode_get(port_id);
6130 if (bonding_mode < 0) {
6131 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6135 printf("\tBonding mode: %d\n", bonding_mode);
6137 if (bonding_mode == BONDING_MODE_BALANCE) {
6138 int balance_xmit_policy;
6140 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6141 if (balance_xmit_policy < 0) {
6143 "\tFailed to get balance xmit policy for port = %d\n",
6147 printf("\tBalance Xmit Policy: ");
6149 switch (balance_xmit_policy) {
6150 case BALANCE_XMIT_POLICY_LAYER2:
6151 printf("BALANCE_XMIT_POLICY_LAYER2");
6153 case BALANCE_XMIT_POLICY_LAYER23:
6154 printf("BALANCE_XMIT_POLICY_LAYER23");
6156 case BALANCE_XMIT_POLICY_LAYER34:
6157 printf("BALANCE_XMIT_POLICY_LAYER34");
6164 if (bonding_mode == BONDING_MODE_8023AD) {
6165 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6166 printf("\tIEEE802.3AD Aggregator Mode: ");
6169 printf("bandwidth");
6181 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6183 if (num_slaves < 0) {
6184 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6188 if (num_slaves > 0) {
6189 printf("\tSlaves (%d): [", num_slaves);
6190 for (i = 0; i < num_slaves - 1; i++)
6191 printf("%d ", slaves[i]);
6193 printf("%d]\n", slaves[num_slaves - 1]);
6195 printf("\tSlaves: []\n");
6199 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6202 if (num_active_slaves < 0) {
6204 "\tFailed to get active slave list for port = %d\n",
6208 if (num_active_slaves > 0) {
6209 printf("\tActive Slaves (%d): [", num_active_slaves);
6210 for (i = 0; i < num_active_slaves - 1; i++)
6211 printf("%d ", slaves[i]);
6213 printf("%d]\n", slaves[num_active_slaves - 1]);
6216 printf("\tActive Slaves: []\n");
6220 primary_id = rte_eth_bond_primary_get(port_id);
6221 if (primary_id < 0) {
6222 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6226 printf("\tPrimary: [%d]\n", primary_id);
6230 cmdline_parse_token_string_t cmd_showbonding_config_show =
6231 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6233 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6234 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6235 bonding, "bonding");
6236 cmdline_parse_token_string_t cmd_showbonding_config_config =
6237 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6239 cmdline_parse_token_num_t cmd_showbonding_config_port =
6240 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6241 port_id, RTE_UINT16);
6243 cmdline_parse_inst_t cmd_show_bonding_config = {
6244 .f = cmd_show_bonding_config_parsed,
6245 .help_str = "show bonding config <port_id>: "
6246 "Show the bonding config for port_id",
6249 (void *)&cmd_showbonding_config_show,
6250 (void *)&cmd_showbonding_config_bonding,
6251 (void *)&cmd_showbonding_config_config,
6252 (void *)&cmd_showbonding_config_port,
6257 /* *** SET BONDING PRIMARY *** */
6258 struct cmd_set_bonding_primary_result {
6259 cmdline_fixed_string_t set;
6260 cmdline_fixed_string_t bonding;
6261 cmdline_fixed_string_t primary;
6266 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6267 __rte_unused struct cmdline *cl,
6268 __rte_unused void *data)
6270 struct cmd_set_bonding_primary_result *res = parsed_result;
6271 portid_t master_port_id = res->port_id;
6272 portid_t slave_port_id = res->slave_id;
6274 /* Set the primary slave for a bonded device. */
6275 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6276 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6283 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6284 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6286 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6287 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6288 bonding, "bonding");
6289 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6290 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6291 primary, "primary");
6292 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6293 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6294 slave_id, RTE_UINT16);
6295 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6296 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6297 port_id, RTE_UINT16);
6299 cmdline_parse_inst_t cmd_set_bonding_primary = {
6300 .f = cmd_set_bonding_primary_parsed,
6301 .help_str = "set bonding primary <slave_id> <port_id>: "
6302 "Set the primary slave for port_id",
6305 (void *)&cmd_setbonding_primary_set,
6306 (void *)&cmd_setbonding_primary_bonding,
6307 (void *)&cmd_setbonding_primary_primary,
6308 (void *)&cmd_setbonding_primary_slave,
6309 (void *)&cmd_setbonding_primary_port,
6314 /* *** ADD SLAVE *** */
6315 struct cmd_add_bonding_slave_result {
6316 cmdline_fixed_string_t add;
6317 cmdline_fixed_string_t bonding;
6318 cmdline_fixed_string_t slave;
6323 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6324 __rte_unused struct cmdline *cl,
6325 __rte_unused void *data)
6327 struct cmd_add_bonding_slave_result *res = parsed_result;
6328 portid_t master_port_id = res->port_id;
6329 portid_t slave_port_id = res->slave_id;
6331 /* add the slave for a bonded device. */
6332 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6334 "\t Failed to add slave %d to master port = %d.\n",
6335 slave_port_id, master_port_id);
6339 set_port_slave_flag(slave_port_id);
6342 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6343 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6345 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6346 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6347 bonding, "bonding");
6348 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6349 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6351 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6352 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6353 slave_id, RTE_UINT16);
6354 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6355 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6356 port_id, RTE_UINT16);
6358 cmdline_parse_inst_t cmd_add_bonding_slave = {
6359 .f = cmd_add_bonding_slave_parsed,
6360 .help_str = "add bonding slave <slave_id> <port_id>: "
6361 "Add a slave device to a bonded device",
6364 (void *)&cmd_addbonding_slave_add,
6365 (void *)&cmd_addbonding_slave_bonding,
6366 (void *)&cmd_addbonding_slave_slave,
6367 (void *)&cmd_addbonding_slave_slaveid,
6368 (void *)&cmd_addbonding_slave_port,
6373 /* *** REMOVE SLAVE *** */
6374 struct cmd_remove_bonding_slave_result {
6375 cmdline_fixed_string_t remove;
6376 cmdline_fixed_string_t bonding;
6377 cmdline_fixed_string_t slave;
6382 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6383 __rte_unused struct cmdline *cl,
6384 __rte_unused void *data)
6386 struct cmd_remove_bonding_slave_result *res = parsed_result;
6387 portid_t master_port_id = res->port_id;
6388 portid_t slave_port_id = res->slave_id;
6390 /* remove the slave from a bonded device. */
6391 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6393 "\t Failed to remove slave %d from master port = %d.\n",
6394 slave_port_id, master_port_id);
6398 clear_port_slave_flag(slave_port_id);
6401 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6402 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6404 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6405 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6406 bonding, "bonding");
6407 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6408 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6410 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6411 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6412 slave_id, RTE_UINT16);
6413 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6414 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6415 port_id, RTE_UINT16);
6417 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6418 .f = cmd_remove_bonding_slave_parsed,
6419 .help_str = "remove bonding slave <slave_id> <port_id>: "
6420 "Remove a slave device from a bonded device",
6423 (void *)&cmd_removebonding_slave_remove,
6424 (void *)&cmd_removebonding_slave_bonding,
6425 (void *)&cmd_removebonding_slave_slave,
6426 (void *)&cmd_removebonding_slave_slaveid,
6427 (void *)&cmd_removebonding_slave_port,
6432 /* *** CREATE BONDED DEVICE *** */
6433 struct cmd_create_bonded_device_result {
6434 cmdline_fixed_string_t create;
6435 cmdline_fixed_string_t bonded;
6436 cmdline_fixed_string_t device;
6441 static int bond_dev_num = 0;
6443 static void cmd_create_bonded_device_parsed(void *parsed_result,
6444 __rte_unused struct cmdline *cl,
6445 __rte_unused void *data)
6447 struct cmd_create_bonded_device_result *res = parsed_result;
6448 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6452 if (test_done == 0) {
6453 fprintf(stderr, "Please stop forwarding first\n");
6457 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6460 /* Create a new bonded device. */
6461 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6463 fprintf(stderr, "\t Failed to create bonded device.\n");
6466 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6469 /* Update number of ports */
6470 nb_ports = rte_eth_dev_count_avail();
6471 reconfig(port_id, res->socket);
6472 ret = rte_eth_promiscuous_enable(port_id);
6475 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6476 port_id, rte_strerror(-ret));
6478 ports[port_id].need_setup = 0;
6479 ports[port_id].port_status = RTE_PORT_STOPPED;
6484 cmdline_parse_token_string_t cmd_createbonded_device_create =
6485 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6487 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6488 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6490 cmdline_parse_token_string_t cmd_createbonded_device_device =
6491 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6493 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6494 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6496 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6497 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6500 cmdline_parse_inst_t cmd_create_bonded_device = {
6501 .f = cmd_create_bonded_device_parsed,
6502 .help_str = "create bonded device <mode> <socket>: "
6503 "Create a new bonded device with specific bonding mode and socket",
6506 (void *)&cmd_createbonded_device_create,
6507 (void *)&cmd_createbonded_device_bonded,
6508 (void *)&cmd_createbonded_device_device,
6509 (void *)&cmd_createbonded_device_mode,
6510 (void *)&cmd_createbonded_device_socket,
6515 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6516 struct cmd_set_bond_mac_addr_result {
6517 cmdline_fixed_string_t set;
6518 cmdline_fixed_string_t bonding;
6519 cmdline_fixed_string_t mac_addr;
6521 struct rte_ether_addr address;
6524 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6525 __rte_unused struct cmdline *cl,
6526 __rte_unused void *data)
6528 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6531 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6534 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6536 /* check the return value and print it if is < 0 */
6538 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6542 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6543 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6544 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6545 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6547 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6548 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6550 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6551 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6552 port_num, RTE_UINT16);
6553 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6554 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6556 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6557 .f = cmd_set_bond_mac_addr_parsed,
6559 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6561 (void *)&cmd_set_bond_mac_addr_set,
6562 (void *)&cmd_set_bond_mac_addr_bonding,
6563 (void *)&cmd_set_bond_mac_addr_mac,
6564 (void *)&cmd_set_bond_mac_addr_portnum,
6565 (void *)&cmd_set_bond_mac_addr_addr,
6571 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6572 struct cmd_set_bond_mon_period_result {
6573 cmdline_fixed_string_t set;
6574 cmdline_fixed_string_t bonding;
6575 cmdline_fixed_string_t mon_period;
6580 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6581 __rte_unused struct cmdline *cl,
6582 __rte_unused void *data)
6584 struct cmd_set_bond_mon_period_result *res = parsed_result;
6587 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6589 /* check the return value and print it if is < 0 */
6591 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6595 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6596 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6598 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6599 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6600 bonding, "bonding");
6601 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6602 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6603 mon_period, "mon_period");
6604 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6605 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6606 port_num, RTE_UINT16);
6607 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6608 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6609 period_ms, RTE_UINT32);
6611 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6612 .f = cmd_set_bond_mon_period_parsed,
6614 .help_str = "set bonding mon_period <port_id> <period_ms>",
6616 (void *)&cmd_set_bond_mon_period_set,
6617 (void *)&cmd_set_bond_mon_period_bonding,
6618 (void *)&cmd_set_bond_mon_period_mon_period,
6619 (void *)&cmd_set_bond_mon_period_portnum,
6620 (void *)&cmd_set_bond_mon_period_period_ms,
6627 struct cmd_set_bonding_agg_mode_policy_result {
6628 cmdline_fixed_string_t set;
6629 cmdline_fixed_string_t bonding;
6630 cmdline_fixed_string_t agg_mode;
6632 cmdline_fixed_string_t policy;
6637 cmd_set_bonding_agg_mode(void *parsed_result,
6638 __rte_unused struct cmdline *cl,
6639 __rte_unused void *data)
6641 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6642 uint8_t policy = AGG_BANDWIDTH;
6644 if (!strcmp(res->policy, "bandwidth"))
6645 policy = AGG_BANDWIDTH;
6646 else if (!strcmp(res->policy, "stable"))
6647 policy = AGG_STABLE;
6648 else if (!strcmp(res->policy, "count"))
6651 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6655 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6656 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6658 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6659 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6660 bonding, "bonding");
6662 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6663 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6664 agg_mode, "agg_mode");
6666 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6667 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6668 port_num, RTE_UINT16);
6670 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6671 TOKEN_STRING_INITIALIZER(
6672 struct cmd_set_bonding_balance_xmit_policy_result,
6673 policy, "stable#bandwidth#count");
6675 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6676 .f = cmd_set_bonding_agg_mode,
6678 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6680 (void *)&cmd_set_bonding_agg_mode_set,
6681 (void *)&cmd_set_bonding_agg_mode_bonding,
6682 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6683 (void *)&cmd_set_bonding_agg_mode_portnum,
6684 (void *)&cmd_set_bonding_agg_mode_policy_string,
6690 #endif /* RTE_NET_BOND */
6692 /* *** SET FORWARDING MODE *** */
6693 struct cmd_set_fwd_mode_result {
6694 cmdline_fixed_string_t set;
6695 cmdline_fixed_string_t fwd;
6696 cmdline_fixed_string_t mode;
6699 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6700 __rte_unused struct cmdline *cl,
6701 __rte_unused void *data)
6703 struct cmd_set_fwd_mode_result *res = parsed_result;
6706 set_pkt_forwarding_mode(res->mode);
6709 cmdline_parse_token_string_t cmd_setfwd_set =
6710 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6711 cmdline_parse_token_string_t cmd_setfwd_fwd =
6712 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6713 cmdline_parse_token_string_t cmd_setfwd_mode =
6714 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6715 "" /* defined at init */);
6717 cmdline_parse_inst_t cmd_set_fwd_mode = {
6718 .f = cmd_set_fwd_mode_parsed,
6720 .help_str = NULL, /* defined at init */
6722 (void *)&cmd_setfwd_set,
6723 (void *)&cmd_setfwd_fwd,
6724 (void *)&cmd_setfwd_mode,
6729 static void cmd_set_fwd_mode_init(void)
6732 static char token[128];
6733 static char help[256];
6734 cmdline_parse_token_string_t *token_struct;
6736 modes = list_pkt_forwarding_modes();
6737 snprintf(help, sizeof(help), "set fwd %s: "
6738 "Set packet forwarding mode", modes);
6739 cmd_set_fwd_mode.help_str = help;
6741 /* string token separator is # */
6742 for (c = token; *modes != '\0'; modes++)
6747 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6748 token_struct->string_data.str = token;
6751 /* *** SET RETRY FORWARDING MODE *** */
6752 struct cmd_set_fwd_retry_mode_result {
6753 cmdline_fixed_string_t set;
6754 cmdline_fixed_string_t fwd;
6755 cmdline_fixed_string_t mode;
6756 cmdline_fixed_string_t retry;
6759 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6760 __rte_unused struct cmdline *cl,
6761 __rte_unused void *data)
6763 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6766 set_pkt_forwarding_mode(res->mode);
6769 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6770 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6772 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6773 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6775 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6776 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6778 "" /* defined at init */);
6779 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6780 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6783 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6784 .f = cmd_set_fwd_retry_mode_parsed,
6786 .help_str = NULL, /* defined at init */
6788 (void *)&cmd_setfwd_retry_set,
6789 (void *)&cmd_setfwd_retry_fwd,
6790 (void *)&cmd_setfwd_retry_mode,
6791 (void *)&cmd_setfwd_retry_retry,
6796 static void cmd_set_fwd_retry_mode_init(void)
6799 static char token[128];
6800 static char help[256];
6801 cmdline_parse_token_string_t *token_struct;
6803 modes = list_pkt_forwarding_retry_modes();
6804 snprintf(help, sizeof(help), "set fwd %s retry: "
6805 "Set packet forwarding mode with retry", modes);
6806 cmd_set_fwd_retry_mode.help_str = help;
6808 /* string token separator is # */
6809 for (c = token; *modes != '\0'; modes++)
6814 token_struct = (cmdline_parse_token_string_t *)
6815 cmd_set_fwd_retry_mode.tokens[2];
6816 token_struct->string_data.str = token;
6819 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6820 struct cmd_set_burst_tx_retry_result {
6821 cmdline_fixed_string_t set;
6822 cmdline_fixed_string_t burst;
6823 cmdline_fixed_string_t tx;
6824 cmdline_fixed_string_t delay;
6826 cmdline_fixed_string_t retry;
6830 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6831 __rte_unused struct cmdline *cl,
6832 __rte_unused void *data)
6834 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6836 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6837 && !strcmp(res->tx, "tx")) {
6838 if (!strcmp(res->delay, "delay"))
6839 burst_tx_delay_time = res->time;
6840 if (!strcmp(res->retry, "retry"))
6841 burst_tx_retry_num = res->retry_num;
6846 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6847 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6848 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6849 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6851 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6852 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6853 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6854 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6855 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6856 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6858 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6859 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6860 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6861 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6864 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6865 .f = cmd_set_burst_tx_retry_parsed,
6866 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6868 (void *)&cmd_set_burst_tx_retry_set,
6869 (void *)&cmd_set_burst_tx_retry_burst,
6870 (void *)&cmd_set_burst_tx_retry_tx,
6871 (void *)&cmd_set_burst_tx_retry_delay,
6872 (void *)&cmd_set_burst_tx_retry_time,
6873 (void *)&cmd_set_burst_tx_retry_retry,
6874 (void *)&cmd_set_burst_tx_retry_retry_num,
6879 /* *** SET PROMISC MODE *** */
6880 struct cmd_set_promisc_mode_result {
6881 cmdline_fixed_string_t set;
6882 cmdline_fixed_string_t promisc;
6883 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6884 uint16_t port_num; /* valid if "allports" argument == 0 */
6885 cmdline_fixed_string_t mode;
6888 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6889 __rte_unused struct cmdline *cl,
6892 struct cmd_set_promisc_mode_result *res = parsed_result;
6896 if (!strcmp(res->mode, "on"))
6903 RTE_ETH_FOREACH_DEV(i)
6904 eth_set_promisc_mode(i, enable);
6906 eth_set_promisc_mode(res->port_num, enable);
6910 cmdline_parse_token_string_t cmd_setpromisc_set =
6911 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6912 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6913 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6915 cmdline_parse_token_string_t cmd_setpromisc_portall =
6916 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6918 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6919 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6921 cmdline_parse_token_string_t cmd_setpromisc_mode =
6922 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6925 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6926 .f = cmd_set_promisc_mode_parsed,
6928 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6930 (void *)&cmd_setpromisc_set,
6931 (void *)&cmd_setpromisc_promisc,
6932 (void *)&cmd_setpromisc_portall,
6933 (void *)&cmd_setpromisc_mode,
6938 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6939 .f = cmd_set_promisc_mode_parsed,
6941 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6943 (void *)&cmd_setpromisc_set,
6944 (void *)&cmd_setpromisc_promisc,
6945 (void *)&cmd_setpromisc_portnum,
6946 (void *)&cmd_setpromisc_mode,
6951 /* *** SET ALLMULTI MODE *** */
6952 struct cmd_set_allmulti_mode_result {
6953 cmdline_fixed_string_t set;
6954 cmdline_fixed_string_t allmulti;
6955 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6956 uint16_t port_num; /* valid if "allports" argument == 0 */
6957 cmdline_fixed_string_t mode;
6960 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6961 __rte_unused struct cmdline *cl,
6964 struct cmd_set_allmulti_mode_result *res = parsed_result;
6968 if (!strcmp(res->mode, "on"))
6975 RTE_ETH_FOREACH_DEV(i) {
6976 eth_set_allmulticast_mode(i, enable);
6980 eth_set_allmulticast_mode(res->port_num, enable);
6984 cmdline_parse_token_string_t cmd_setallmulti_set =
6985 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6986 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6987 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6989 cmdline_parse_token_string_t cmd_setallmulti_portall =
6990 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6992 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6993 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6995 cmdline_parse_token_string_t cmd_setallmulti_mode =
6996 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6999 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7000 .f = cmd_set_allmulti_mode_parsed,
7002 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7004 (void *)&cmd_setallmulti_set,
7005 (void *)&cmd_setallmulti_allmulti,
7006 (void *)&cmd_setallmulti_portall,
7007 (void *)&cmd_setallmulti_mode,
7012 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7013 .f = cmd_set_allmulti_mode_parsed,
7015 .help_str = "set allmulti <port_id> on|off: "
7016 "Set allmulti mode on port_id",
7018 (void *)&cmd_setallmulti_set,
7019 (void *)&cmd_setallmulti_allmulti,
7020 (void *)&cmd_setallmulti_portnum,
7021 (void *)&cmd_setallmulti_mode,
7026 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7027 struct cmd_link_flow_ctrl_show {
7028 cmdline_fixed_string_t show;
7029 cmdline_fixed_string_t port;
7031 cmdline_fixed_string_t flow_ctrl;
7034 cmdline_parse_token_string_t cmd_lfc_show_show =
7035 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7037 cmdline_parse_token_string_t cmd_lfc_show_port =
7038 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7040 cmdline_parse_token_num_t cmd_lfc_show_portid =
7041 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7042 port_id, RTE_UINT16);
7043 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7044 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7045 flow_ctrl, "flow_ctrl");
7048 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7049 __rte_unused struct cmdline *cl,
7050 __rte_unused void *data)
7052 struct cmd_link_flow_ctrl_show *res = parsed_result;
7053 static const char *info_border = "*********************";
7054 struct rte_eth_fc_conf fc_conf;
7055 bool rx_fc_en = false;
7056 bool tx_fc_en = false;
7059 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7062 "Failed to get current flow ctrl information: err = %d\n",
7067 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7069 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7072 printf("\n%s Flow control infos for port %-2d %s\n",
7073 info_border, res->port_id, info_border);
7074 printf("FC mode:\n");
7075 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7076 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7077 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7078 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7079 printf("High waterline: 0x%x\n", fc_conf.high_water);
7080 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7081 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7082 printf("Forward MAC control frames: %s\n",
7083 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7084 printf("\n%s************** End ***********%s\n",
7085 info_border, info_border);
7088 cmdline_parse_inst_t cmd_link_flow_control_show = {
7089 .f = cmd_link_flow_ctrl_show_parsed,
7091 .help_str = "show port <port_id> flow_ctrl",
7093 (void *)&cmd_lfc_show_show,
7094 (void *)&cmd_lfc_show_port,
7095 (void *)&cmd_lfc_show_portid,
7096 (void *)&cmd_lfc_show_flow_ctrl,
7101 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7102 struct cmd_link_flow_ctrl_set_result {
7103 cmdline_fixed_string_t set;
7104 cmdline_fixed_string_t flow_ctrl;
7105 cmdline_fixed_string_t rx;
7106 cmdline_fixed_string_t rx_lfc_mode;
7107 cmdline_fixed_string_t tx;
7108 cmdline_fixed_string_t tx_lfc_mode;
7109 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7110 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7111 cmdline_fixed_string_t autoneg_str;
7112 cmdline_fixed_string_t autoneg;
7113 cmdline_fixed_string_t hw_str;
7114 uint32_t high_water;
7115 cmdline_fixed_string_t lw_str;
7117 cmdline_fixed_string_t pt_str;
7118 uint16_t pause_time;
7119 cmdline_fixed_string_t xon_str;
7124 cmdline_parse_token_string_t cmd_lfc_set_set =
7125 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7127 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7128 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7129 flow_ctrl, "flow_ctrl");
7130 cmdline_parse_token_string_t cmd_lfc_set_rx =
7131 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7133 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7134 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7135 rx_lfc_mode, "on#off");
7136 cmdline_parse_token_string_t cmd_lfc_set_tx =
7137 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7139 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7140 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7141 tx_lfc_mode, "on#off");
7142 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7143 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7144 hw_str, "high_water");
7145 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7146 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7147 high_water, RTE_UINT32);
7148 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7149 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7150 lw_str, "low_water");
7151 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7152 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7153 low_water, RTE_UINT32);
7154 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7155 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7156 pt_str, "pause_time");
7157 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7158 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7159 pause_time, RTE_UINT16);
7160 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7161 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7162 xon_str, "send_xon");
7163 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7164 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7165 send_xon, RTE_UINT16);
7166 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7168 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7169 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7171 mac_ctrl_frame_fwd_mode, "on#off");
7172 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7174 autoneg_str, "autoneg");
7175 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7176 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7178 cmdline_parse_token_num_t cmd_lfc_set_portid =
7179 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7180 port_id, RTE_UINT16);
7182 /* forward declaration */
7184 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7187 cmdline_parse_inst_t cmd_link_flow_control_set = {
7188 .f = cmd_link_flow_ctrl_set_parsed,
7190 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7191 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7192 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7194 (void *)&cmd_lfc_set_set,
7195 (void *)&cmd_lfc_set_flow_ctrl,
7196 (void *)&cmd_lfc_set_rx,
7197 (void *)&cmd_lfc_set_rx_mode,
7198 (void *)&cmd_lfc_set_tx,
7199 (void *)&cmd_lfc_set_tx_mode,
7200 (void *)&cmd_lfc_set_high_water,
7201 (void *)&cmd_lfc_set_low_water,
7202 (void *)&cmd_lfc_set_pause_time,
7203 (void *)&cmd_lfc_set_send_xon,
7204 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7205 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7206 (void *)&cmd_lfc_set_autoneg_str,
7207 (void *)&cmd_lfc_set_autoneg,
7208 (void *)&cmd_lfc_set_portid,
7213 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7214 .f = cmd_link_flow_ctrl_set_parsed,
7215 .data = (void *)&cmd_link_flow_control_set_rx,
7216 .help_str = "set flow_ctrl rx on|off <port_id>: "
7217 "Change rx flow control parameter",
7219 (void *)&cmd_lfc_set_set,
7220 (void *)&cmd_lfc_set_flow_ctrl,
7221 (void *)&cmd_lfc_set_rx,
7222 (void *)&cmd_lfc_set_rx_mode,
7223 (void *)&cmd_lfc_set_portid,
7228 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7229 .f = cmd_link_flow_ctrl_set_parsed,
7230 .data = (void *)&cmd_link_flow_control_set_tx,
7231 .help_str = "set flow_ctrl tx on|off <port_id>: "
7232 "Change tx flow control parameter",
7234 (void *)&cmd_lfc_set_set,
7235 (void *)&cmd_lfc_set_flow_ctrl,
7236 (void *)&cmd_lfc_set_tx,
7237 (void *)&cmd_lfc_set_tx_mode,
7238 (void *)&cmd_lfc_set_portid,
7243 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7244 .f = cmd_link_flow_ctrl_set_parsed,
7245 .data = (void *)&cmd_link_flow_control_set_hw,
7246 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7247 "Change high water flow control parameter",
7249 (void *)&cmd_lfc_set_set,
7250 (void *)&cmd_lfc_set_flow_ctrl,
7251 (void *)&cmd_lfc_set_high_water_str,
7252 (void *)&cmd_lfc_set_high_water,
7253 (void *)&cmd_lfc_set_portid,
7258 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7259 .f = cmd_link_flow_ctrl_set_parsed,
7260 .data = (void *)&cmd_link_flow_control_set_lw,
7261 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7262 "Change low water flow control parameter",
7264 (void *)&cmd_lfc_set_set,
7265 (void *)&cmd_lfc_set_flow_ctrl,
7266 (void *)&cmd_lfc_set_low_water_str,
7267 (void *)&cmd_lfc_set_low_water,
7268 (void *)&cmd_lfc_set_portid,
7273 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7274 .f = cmd_link_flow_ctrl_set_parsed,
7275 .data = (void *)&cmd_link_flow_control_set_pt,
7276 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7277 "Change pause time flow control parameter",
7279 (void *)&cmd_lfc_set_set,
7280 (void *)&cmd_lfc_set_flow_ctrl,
7281 (void *)&cmd_lfc_set_pause_time_str,
7282 (void *)&cmd_lfc_set_pause_time,
7283 (void *)&cmd_lfc_set_portid,
7288 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7289 .f = cmd_link_flow_ctrl_set_parsed,
7290 .data = (void *)&cmd_link_flow_control_set_xon,
7291 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7292 "Change send_xon flow control parameter",
7294 (void *)&cmd_lfc_set_set,
7295 (void *)&cmd_lfc_set_flow_ctrl,
7296 (void *)&cmd_lfc_set_send_xon_str,
7297 (void *)&cmd_lfc_set_send_xon,
7298 (void *)&cmd_lfc_set_portid,
7303 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7304 .f = cmd_link_flow_ctrl_set_parsed,
7305 .data = (void *)&cmd_link_flow_control_set_macfwd,
7306 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7307 "Change mac ctrl fwd flow control parameter",
7309 (void *)&cmd_lfc_set_set,
7310 (void *)&cmd_lfc_set_flow_ctrl,
7311 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7312 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7313 (void *)&cmd_lfc_set_portid,
7318 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7319 .f = cmd_link_flow_ctrl_set_parsed,
7320 .data = (void *)&cmd_link_flow_control_set_autoneg,
7321 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7322 "Change autoneg flow control parameter",
7324 (void *)&cmd_lfc_set_set,
7325 (void *)&cmd_lfc_set_flow_ctrl,
7326 (void *)&cmd_lfc_set_autoneg_str,
7327 (void *)&cmd_lfc_set_autoneg,
7328 (void *)&cmd_lfc_set_portid,
7334 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7335 __rte_unused struct cmdline *cl,
7338 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7339 cmdline_parse_inst_t *cmd = data;
7340 struct rte_eth_fc_conf fc_conf;
7346 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7347 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7348 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7349 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7351 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7352 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7355 /* Partial command line, retrieve current configuration */
7357 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7360 "cannot get current flow ctrl parameters, return code = %d\n",
7365 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7366 (fc_conf.mode == RTE_FC_FULL))
7368 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7369 (fc_conf.mode == RTE_FC_FULL))
7373 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7374 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7376 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7377 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7379 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7381 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7382 fc_conf.high_water = res->high_water;
7384 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7385 fc_conf.low_water = res->low_water;
7387 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7388 fc_conf.pause_time = res->pause_time;
7390 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7391 fc_conf.send_xon = res->send_xon;
7393 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7394 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7395 fc_conf.mac_ctrl_frame_fwd = 1;
7397 fc_conf.mac_ctrl_frame_fwd = 0;
7400 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7401 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7403 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7406 "bad flow control parameter, return code = %d\n",
7410 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7411 struct cmd_priority_flow_ctrl_set_result {
7412 cmdline_fixed_string_t set;
7413 cmdline_fixed_string_t pfc_ctrl;
7414 cmdline_fixed_string_t rx;
7415 cmdline_fixed_string_t rx_pfc_mode;
7416 cmdline_fixed_string_t tx;
7417 cmdline_fixed_string_t tx_pfc_mode;
7418 uint32_t high_water;
7420 uint16_t pause_time;
7426 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7427 __rte_unused struct cmdline *cl,
7428 __rte_unused void *data)
7430 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7431 struct rte_eth_pfc_conf pfc_conf;
7432 int rx_fc_enable, tx_fc_enable;
7436 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7437 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7438 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7439 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7441 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7442 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7445 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7446 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7447 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7448 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7449 pfc_conf.fc.high_water = res->high_water;
7450 pfc_conf.fc.low_water = res->low_water;
7451 pfc_conf.fc.pause_time = res->pause_time;
7452 pfc_conf.priority = res->priority;
7454 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7457 "bad priority flow control parameter, return code = %d\n",
7461 cmdline_parse_token_string_t cmd_pfc_set_set =
7462 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7464 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7465 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7466 pfc_ctrl, "pfc_ctrl");
7467 cmdline_parse_token_string_t cmd_pfc_set_rx =
7468 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7470 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7471 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7472 rx_pfc_mode, "on#off");
7473 cmdline_parse_token_string_t cmd_pfc_set_tx =
7474 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7476 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7477 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7478 tx_pfc_mode, "on#off");
7479 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7480 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7481 high_water, RTE_UINT32);
7482 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7483 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7484 low_water, RTE_UINT32);
7485 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7486 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7487 pause_time, RTE_UINT16);
7488 cmdline_parse_token_num_t cmd_pfc_set_priority =
7489 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7490 priority, RTE_UINT8);
7491 cmdline_parse_token_num_t cmd_pfc_set_portid =
7492 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7493 port_id, RTE_UINT16);
7495 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7496 .f = cmd_priority_flow_ctrl_set_parsed,
7498 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7499 "<pause_time> <priority> <port_id>: "
7500 "Configure the Ethernet priority flow control",
7502 (void *)&cmd_pfc_set_set,
7503 (void *)&cmd_pfc_set_flow_ctrl,
7504 (void *)&cmd_pfc_set_rx,
7505 (void *)&cmd_pfc_set_rx_mode,
7506 (void *)&cmd_pfc_set_tx,
7507 (void *)&cmd_pfc_set_tx_mode,
7508 (void *)&cmd_pfc_set_high_water,
7509 (void *)&cmd_pfc_set_low_water,
7510 (void *)&cmd_pfc_set_pause_time,
7511 (void *)&cmd_pfc_set_priority,
7512 (void *)&cmd_pfc_set_portid,
7517 /* *** RESET CONFIGURATION *** */
7518 struct cmd_reset_result {
7519 cmdline_fixed_string_t reset;
7520 cmdline_fixed_string_t def;
7523 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7525 __rte_unused void *data)
7527 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7528 set_def_fwd_config();
7531 cmdline_parse_token_string_t cmd_reset_set =
7532 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7533 cmdline_parse_token_string_t cmd_reset_def =
7534 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7537 cmdline_parse_inst_t cmd_reset = {
7538 .f = cmd_reset_parsed,
7540 .help_str = "set default: Reset default forwarding configuration",
7542 (void *)&cmd_reset_set,
7543 (void *)&cmd_reset_def,
7548 /* *** START FORWARDING *** */
7549 struct cmd_start_result {
7550 cmdline_fixed_string_t start;
7553 cmdline_parse_token_string_t cmd_start_start =
7554 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7556 static void cmd_start_parsed(__rte_unused void *parsed_result,
7557 __rte_unused struct cmdline *cl,
7558 __rte_unused void *data)
7560 start_packet_forwarding(0);
7563 cmdline_parse_inst_t cmd_start = {
7564 .f = cmd_start_parsed,
7566 .help_str = "start: Start packet forwarding",
7568 (void *)&cmd_start_start,
7573 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7574 struct cmd_start_tx_first_result {
7575 cmdline_fixed_string_t start;
7576 cmdline_fixed_string_t tx_first;
7580 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7581 __rte_unused struct cmdline *cl,
7582 __rte_unused void *data)
7584 start_packet_forwarding(1);
7587 cmdline_parse_token_string_t cmd_start_tx_first_start =
7588 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7590 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7591 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7592 tx_first, "tx_first");
7594 cmdline_parse_inst_t cmd_start_tx_first = {
7595 .f = cmd_start_tx_first_parsed,
7597 .help_str = "start tx_first: Start packet forwarding, "
7598 "after sending 1 burst of packets",
7600 (void *)&cmd_start_tx_first_start,
7601 (void *)&cmd_start_tx_first_tx_first,
7606 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7607 struct cmd_start_tx_first_n_result {
7608 cmdline_fixed_string_t start;
7609 cmdline_fixed_string_t tx_first;
7614 cmd_start_tx_first_n_parsed(void *parsed_result,
7615 __rte_unused struct cmdline *cl,
7616 __rte_unused void *data)
7618 struct cmd_start_tx_first_n_result *res = parsed_result;
7620 start_packet_forwarding(res->tx_num);
7623 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7624 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7626 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7627 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7628 tx_first, "tx_first");
7629 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7630 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7631 tx_num, RTE_UINT32);
7633 cmdline_parse_inst_t cmd_start_tx_first_n = {
7634 .f = cmd_start_tx_first_n_parsed,
7636 .help_str = "start tx_first <num>: "
7637 "packet forwarding, after sending <num> bursts of packets",
7639 (void *)&cmd_start_tx_first_n_start,
7640 (void *)&cmd_start_tx_first_n_tx_first,
7641 (void *)&cmd_start_tx_first_n_tx_num,
7646 /* *** SET LINK UP *** */
7647 struct cmd_set_link_up_result {
7648 cmdline_fixed_string_t set;
7649 cmdline_fixed_string_t link_up;
7650 cmdline_fixed_string_t port;
7654 cmdline_parse_token_string_t cmd_set_link_up_set =
7655 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7656 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7657 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7659 cmdline_parse_token_string_t cmd_set_link_up_port =
7660 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7661 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7662 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7665 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7666 __rte_unused struct cmdline *cl,
7667 __rte_unused void *data)
7669 struct cmd_set_link_up_result *res = parsed_result;
7670 dev_set_link_up(res->port_id);
7673 cmdline_parse_inst_t cmd_set_link_up = {
7674 .f = cmd_set_link_up_parsed,
7676 .help_str = "set link-up port <port id>",
7678 (void *)&cmd_set_link_up_set,
7679 (void *)&cmd_set_link_up_link_up,
7680 (void *)&cmd_set_link_up_port,
7681 (void *)&cmd_set_link_up_port_id,
7686 /* *** SET LINK DOWN *** */
7687 struct cmd_set_link_down_result {
7688 cmdline_fixed_string_t set;
7689 cmdline_fixed_string_t link_down;
7690 cmdline_fixed_string_t port;
7694 cmdline_parse_token_string_t cmd_set_link_down_set =
7695 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7696 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7697 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7699 cmdline_parse_token_string_t cmd_set_link_down_port =
7700 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7701 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7702 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7705 static void cmd_set_link_down_parsed(
7706 __rte_unused void *parsed_result,
7707 __rte_unused struct cmdline *cl,
7708 __rte_unused void *data)
7710 struct cmd_set_link_down_result *res = parsed_result;
7711 dev_set_link_down(res->port_id);
7714 cmdline_parse_inst_t cmd_set_link_down = {
7715 .f = cmd_set_link_down_parsed,
7717 .help_str = "set link-down port <port id>",
7719 (void *)&cmd_set_link_down_set,
7720 (void *)&cmd_set_link_down_link_down,
7721 (void *)&cmd_set_link_down_port,
7722 (void *)&cmd_set_link_down_port_id,
7727 /* *** SHOW CFG *** */
7728 struct cmd_showcfg_result {
7729 cmdline_fixed_string_t show;
7730 cmdline_fixed_string_t cfg;
7731 cmdline_fixed_string_t what;
7734 static void cmd_showcfg_parsed(void *parsed_result,
7735 __rte_unused struct cmdline *cl,
7736 __rte_unused void *data)
7738 struct cmd_showcfg_result *res = parsed_result;
7739 if (!strcmp(res->what, "rxtx"))
7740 rxtx_config_display();
7741 else if (!strcmp(res->what, "cores"))
7742 fwd_lcores_config_display();
7743 else if (!strcmp(res->what, "fwd"))
7744 pkt_fwd_config_display(&cur_fwd_config);
7745 else if (!strcmp(res->what, "rxoffs"))
7746 show_rx_pkt_offsets();
7747 else if (!strcmp(res->what, "rxpkts"))
7748 show_rx_pkt_segments();
7749 else if (!strcmp(res->what, "txpkts"))
7750 show_tx_pkt_segments();
7751 else if (!strcmp(res->what, "txtimes"))
7752 show_tx_pkt_times();
7755 cmdline_parse_token_string_t cmd_showcfg_show =
7756 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7757 cmdline_parse_token_string_t cmd_showcfg_port =
7758 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7759 cmdline_parse_token_string_t cmd_showcfg_what =
7760 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7761 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7763 cmdline_parse_inst_t cmd_showcfg = {
7764 .f = cmd_showcfg_parsed,
7766 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7768 (void *)&cmd_showcfg_show,
7769 (void *)&cmd_showcfg_port,
7770 (void *)&cmd_showcfg_what,
7775 /* *** SHOW ALL PORT INFO *** */
7776 struct cmd_showportall_result {
7777 cmdline_fixed_string_t show;
7778 cmdline_fixed_string_t port;
7779 cmdline_fixed_string_t what;
7780 cmdline_fixed_string_t all;
7783 static void cmd_showportall_parsed(void *parsed_result,
7784 __rte_unused struct cmdline *cl,
7785 __rte_unused void *data)
7789 struct cmd_showportall_result *res = parsed_result;
7790 if (!strcmp(res->show, "clear")) {
7791 if (!strcmp(res->what, "stats"))
7792 RTE_ETH_FOREACH_DEV(i)
7794 else if (!strcmp(res->what, "xstats"))
7795 RTE_ETH_FOREACH_DEV(i)
7796 nic_xstats_clear(i);
7797 } else if (!strcmp(res->what, "info"))
7798 RTE_ETH_FOREACH_DEV(i)
7799 port_infos_display(i);
7800 else if (!strcmp(res->what, "summary")) {
7801 port_summary_header_display();
7802 RTE_ETH_FOREACH_DEV(i)
7803 port_summary_display(i);
7805 else if (!strcmp(res->what, "stats"))
7806 RTE_ETH_FOREACH_DEV(i)
7807 nic_stats_display(i);
7808 else if (!strcmp(res->what, "xstats"))
7809 RTE_ETH_FOREACH_DEV(i)
7810 nic_xstats_display(i);
7811 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7812 else if (!strcmp(res->what, "fdir"))
7813 RTE_ETH_FOREACH_DEV(i)
7816 else if (!strcmp(res->what, "dcb_tc"))
7817 RTE_ETH_FOREACH_DEV(i)
7818 port_dcb_info_display(i);
7821 cmdline_parse_token_string_t cmd_showportall_show =
7822 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7824 cmdline_parse_token_string_t cmd_showportall_port =
7825 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7826 cmdline_parse_token_string_t cmd_showportall_what =
7827 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7828 "info#summary#stats#xstats#fdir#dcb_tc");
7829 cmdline_parse_token_string_t cmd_showportall_all =
7830 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7831 cmdline_parse_inst_t cmd_showportall = {
7832 .f = cmd_showportall_parsed,
7834 .help_str = "show|clear port "
7835 "info|summary|stats|xstats|fdir|dcb_tc all",
7837 (void *)&cmd_showportall_show,
7838 (void *)&cmd_showportall_port,
7839 (void *)&cmd_showportall_what,
7840 (void *)&cmd_showportall_all,
7845 /* *** SHOW PORT INFO *** */
7846 struct cmd_showport_result {
7847 cmdline_fixed_string_t show;
7848 cmdline_fixed_string_t port;
7849 cmdline_fixed_string_t what;
7853 static void cmd_showport_parsed(void *parsed_result,
7854 __rte_unused struct cmdline *cl,
7855 __rte_unused void *data)
7857 struct cmd_showport_result *res = parsed_result;
7858 if (!strcmp(res->show, "clear")) {
7859 if (!strcmp(res->what, "stats"))
7860 nic_stats_clear(res->portnum);
7861 else if (!strcmp(res->what, "xstats"))
7862 nic_xstats_clear(res->portnum);
7863 } else if (!strcmp(res->what, "info"))
7864 port_infos_display(res->portnum);
7865 else if (!strcmp(res->what, "summary")) {
7866 port_summary_header_display();
7867 port_summary_display(res->portnum);
7869 else if (!strcmp(res->what, "stats"))
7870 nic_stats_display(res->portnum);
7871 else if (!strcmp(res->what, "xstats"))
7872 nic_xstats_display(res->portnum);
7873 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7874 else if (!strcmp(res->what, "fdir"))
7875 fdir_get_infos(res->portnum);
7877 else if (!strcmp(res->what, "dcb_tc"))
7878 port_dcb_info_display(res->portnum);
7881 cmdline_parse_token_string_t cmd_showport_show =
7882 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7884 cmdline_parse_token_string_t cmd_showport_port =
7885 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7886 cmdline_parse_token_string_t cmd_showport_what =
7887 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7888 "info#summary#stats#xstats#fdir#dcb_tc");
7889 cmdline_parse_token_num_t cmd_showport_portnum =
7890 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7892 cmdline_parse_inst_t cmd_showport = {
7893 .f = cmd_showport_parsed,
7895 .help_str = "show|clear port "
7896 "info|summary|stats|xstats|fdir|dcb_tc "
7899 (void *)&cmd_showport_show,
7900 (void *)&cmd_showport_port,
7901 (void *)&cmd_showport_what,
7902 (void *)&cmd_showport_portnum,
7907 /* *** SHOW DEVICE INFO *** */
7908 struct cmd_showdevice_result {
7909 cmdline_fixed_string_t show;
7910 cmdline_fixed_string_t device;
7911 cmdline_fixed_string_t what;
7912 cmdline_fixed_string_t identifier;
7915 static void cmd_showdevice_parsed(void *parsed_result,
7916 __rte_unused struct cmdline *cl,
7917 __rte_unused void *data)
7919 struct cmd_showdevice_result *res = parsed_result;
7920 if (!strcmp(res->what, "info")) {
7921 if (!strcmp(res->identifier, "all"))
7922 device_infos_display(NULL);
7924 device_infos_display(res->identifier);
7928 cmdline_parse_token_string_t cmd_showdevice_show =
7929 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7931 cmdline_parse_token_string_t cmd_showdevice_device =
7932 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7933 cmdline_parse_token_string_t cmd_showdevice_what =
7934 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7936 cmdline_parse_token_string_t cmd_showdevice_identifier =
7937 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7940 cmdline_parse_inst_t cmd_showdevice = {
7941 .f = cmd_showdevice_parsed,
7943 .help_str = "show device info <identifier>|all",
7945 (void *)&cmd_showdevice_show,
7946 (void *)&cmd_showdevice_device,
7947 (void *)&cmd_showdevice_what,
7948 (void *)&cmd_showdevice_identifier,
7953 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7954 struct cmd_showeeprom_result {
7955 cmdline_fixed_string_t show;
7956 cmdline_fixed_string_t port;
7958 cmdline_fixed_string_t type;
7961 static void cmd_showeeprom_parsed(void *parsed_result,
7962 __rte_unused struct cmdline *cl,
7963 __rte_unused void *data)
7965 struct cmd_showeeprom_result *res = parsed_result;
7967 if (!strcmp(res->type, "eeprom"))
7968 port_eeprom_display(res->portnum);
7969 else if (!strcmp(res->type, "module_eeprom"))
7970 port_module_eeprom_display(res->portnum);
7972 fprintf(stderr, "Unknown argument\n");
7975 cmdline_parse_token_string_t cmd_showeeprom_show =
7976 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7977 cmdline_parse_token_string_t cmd_showeeprom_port =
7978 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7979 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7980 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7982 cmdline_parse_token_string_t cmd_showeeprom_type =
7983 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7985 cmdline_parse_inst_t cmd_showeeprom = {
7986 .f = cmd_showeeprom_parsed,
7988 .help_str = "show port <port_id> module_eeprom|eeprom",
7990 (void *)&cmd_showeeprom_show,
7991 (void *)&cmd_showeeprom_port,
7992 (void *)&cmd_showeeprom_portnum,
7993 (void *)&cmd_showeeprom_type,
7998 /* *** SHOW QUEUE INFO *** */
7999 struct cmd_showqueue_result {
8000 cmdline_fixed_string_t show;
8001 cmdline_fixed_string_t type;
8002 cmdline_fixed_string_t what;
8008 cmd_showqueue_parsed(void *parsed_result,
8009 __rte_unused struct cmdline *cl,
8010 __rte_unused void *data)
8012 struct cmd_showqueue_result *res = parsed_result;
8014 if (!strcmp(res->type, "rxq"))
8015 rx_queue_infos_display(res->portnum, res->queuenum);
8016 else if (!strcmp(res->type, "txq"))
8017 tx_queue_infos_display(res->portnum, res->queuenum);
8020 cmdline_parse_token_string_t cmd_showqueue_show =
8021 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8022 cmdline_parse_token_string_t cmd_showqueue_type =
8023 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8024 cmdline_parse_token_string_t cmd_showqueue_what =
8025 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8026 cmdline_parse_token_num_t cmd_showqueue_portnum =
8027 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8029 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8030 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8033 cmdline_parse_inst_t cmd_showqueue = {
8034 .f = cmd_showqueue_parsed,
8036 .help_str = "show rxq|txq info <port_id> <queue_id>",
8038 (void *)&cmd_showqueue_show,
8039 (void *)&cmd_showqueue_type,
8040 (void *)&cmd_showqueue_what,
8041 (void *)&cmd_showqueue_portnum,
8042 (void *)&cmd_showqueue_queuenum,
8047 /* show/clear fwd engine statistics */
8049 cmdline_fixed_string_t action;
8050 cmdline_fixed_string_t fwd;
8051 cmdline_fixed_string_t stats;
8052 cmdline_fixed_string_t all;
8055 cmdline_parse_token_string_t cmd_fwd_action =
8056 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8057 cmdline_parse_token_string_t cmd_fwd_fwd =
8058 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8059 cmdline_parse_token_string_t cmd_fwd_stats =
8060 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8061 cmdline_parse_token_string_t cmd_fwd_all =
8062 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8065 cmd_showfwdall_parsed(void *parsed_result,
8066 __rte_unused struct cmdline *cl,
8067 __rte_unused void *data)
8069 struct fwd_result *res = parsed_result;
8071 if (!strcmp(res->action, "show"))
8072 fwd_stats_display();
8077 static cmdline_parse_inst_t cmd_showfwdall = {
8078 .f = cmd_showfwdall_parsed,
8080 .help_str = "show|clear fwd stats all",
8082 (void *)&cmd_fwd_action,
8083 (void *)&cmd_fwd_fwd,
8084 (void *)&cmd_fwd_stats,
8085 (void *)&cmd_fwd_all,
8090 /* *** READ PORT REGISTER *** */
8091 struct cmd_read_reg_result {
8092 cmdline_fixed_string_t read;
8093 cmdline_fixed_string_t reg;
8099 cmd_read_reg_parsed(void *parsed_result,
8100 __rte_unused struct cmdline *cl,
8101 __rte_unused void *data)
8103 struct cmd_read_reg_result *res = parsed_result;
8104 port_reg_display(res->port_id, res->reg_off);
8107 cmdline_parse_token_string_t cmd_read_reg_read =
8108 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8109 cmdline_parse_token_string_t cmd_read_reg_reg =
8110 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8111 cmdline_parse_token_num_t cmd_read_reg_port_id =
8112 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8113 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8114 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8116 cmdline_parse_inst_t cmd_read_reg = {
8117 .f = cmd_read_reg_parsed,
8119 .help_str = "read reg <port_id> <reg_off>",
8121 (void *)&cmd_read_reg_read,
8122 (void *)&cmd_read_reg_reg,
8123 (void *)&cmd_read_reg_port_id,
8124 (void *)&cmd_read_reg_reg_off,
8129 /* *** READ PORT REGISTER BIT FIELD *** */
8130 struct cmd_read_reg_bit_field_result {
8131 cmdline_fixed_string_t read;
8132 cmdline_fixed_string_t regfield;
8140 cmd_read_reg_bit_field_parsed(void *parsed_result,
8141 __rte_unused struct cmdline *cl,
8142 __rte_unused void *data)
8144 struct cmd_read_reg_bit_field_result *res = parsed_result;
8145 port_reg_bit_field_display(res->port_id, res->reg_off,
8146 res->bit1_pos, res->bit2_pos);
8149 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8150 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8152 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8153 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8154 regfield, "regfield");
8155 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8156 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8158 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8159 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8161 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8162 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8164 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8165 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8168 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8169 .f = cmd_read_reg_bit_field_parsed,
8171 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8172 "Read register bit field between bit_x and bit_y included",
8174 (void *)&cmd_read_reg_bit_field_read,
8175 (void *)&cmd_read_reg_bit_field_regfield,
8176 (void *)&cmd_read_reg_bit_field_port_id,
8177 (void *)&cmd_read_reg_bit_field_reg_off,
8178 (void *)&cmd_read_reg_bit_field_bit1_pos,
8179 (void *)&cmd_read_reg_bit_field_bit2_pos,
8184 /* *** READ PORT REGISTER BIT *** */
8185 struct cmd_read_reg_bit_result {
8186 cmdline_fixed_string_t read;
8187 cmdline_fixed_string_t regbit;
8194 cmd_read_reg_bit_parsed(void *parsed_result,
8195 __rte_unused struct cmdline *cl,
8196 __rte_unused void *data)
8198 struct cmd_read_reg_bit_result *res = parsed_result;
8199 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8202 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8203 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8204 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8205 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8207 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8208 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8210 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8211 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8213 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8214 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8217 cmdline_parse_inst_t cmd_read_reg_bit = {
8218 .f = cmd_read_reg_bit_parsed,
8220 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8222 (void *)&cmd_read_reg_bit_read,
8223 (void *)&cmd_read_reg_bit_regbit,
8224 (void *)&cmd_read_reg_bit_port_id,
8225 (void *)&cmd_read_reg_bit_reg_off,
8226 (void *)&cmd_read_reg_bit_bit_pos,
8231 /* *** WRITE PORT REGISTER *** */
8232 struct cmd_write_reg_result {
8233 cmdline_fixed_string_t write;
8234 cmdline_fixed_string_t reg;
8241 cmd_write_reg_parsed(void *parsed_result,
8242 __rte_unused struct cmdline *cl,
8243 __rte_unused void *data)
8245 struct cmd_write_reg_result *res = parsed_result;
8246 port_reg_set(res->port_id, res->reg_off, res->value);
8249 cmdline_parse_token_string_t cmd_write_reg_write =
8250 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8251 cmdline_parse_token_string_t cmd_write_reg_reg =
8252 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8253 cmdline_parse_token_num_t cmd_write_reg_port_id =
8254 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8255 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8256 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8257 cmdline_parse_token_num_t cmd_write_reg_value =
8258 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8260 cmdline_parse_inst_t cmd_write_reg = {
8261 .f = cmd_write_reg_parsed,
8263 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8265 (void *)&cmd_write_reg_write,
8266 (void *)&cmd_write_reg_reg,
8267 (void *)&cmd_write_reg_port_id,
8268 (void *)&cmd_write_reg_reg_off,
8269 (void *)&cmd_write_reg_value,
8274 /* *** WRITE PORT REGISTER BIT FIELD *** */
8275 struct cmd_write_reg_bit_field_result {
8276 cmdline_fixed_string_t write;
8277 cmdline_fixed_string_t regfield;
8286 cmd_write_reg_bit_field_parsed(void *parsed_result,
8287 __rte_unused struct cmdline *cl,
8288 __rte_unused void *data)
8290 struct cmd_write_reg_bit_field_result *res = parsed_result;
8291 port_reg_bit_field_set(res->port_id, res->reg_off,
8292 res->bit1_pos, res->bit2_pos, res->value);
8295 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8296 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8298 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8299 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8300 regfield, "regfield");
8301 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8302 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8304 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8305 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8307 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8308 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8310 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8311 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8313 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8314 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8317 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8318 .f = cmd_write_reg_bit_field_parsed,
8320 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8322 "Set register bit field between bit_x and bit_y included",
8324 (void *)&cmd_write_reg_bit_field_write,
8325 (void *)&cmd_write_reg_bit_field_regfield,
8326 (void *)&cmd_write_reg_bit_field_port_id,
8327 (void *)&cmd_write_reg_bit_field_reg_off,
8328 (void *)&cmd_write_reg_bit_field_bit1_pos,
8329 (void *)&cmd_write_reg_bit_field_bit2_pos,
8330 (void *)&cmd_write_reg_bit_field_value,
8335 /* *** WRITE PORT REGISTER BIT *** */
8336 struct cmd_write_reg_bit_result {
8337 cmdline_fixed_string_t write;
8338 cmdline_fixed_string_t regbit;
8346 cmd_write_reg_bit_parsed(void *parsed_result,
8347 __rte_unused struct cmdline *cl,
8348 __rte_unused void *data)
8350 struct cmd_write_reg_bit_result *res = parsed_result;
8351 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8354 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8355 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8357 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8358 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8360 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8361 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8363 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8364 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8366 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8367 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8369 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8370 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8373 cmdline_parse_inst_t cmd_write_reg_bit = {
8374 .f = cmd_write_reg_bit_parsed,
8376 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8379 (void *)&cmd_write_reg_bit_write,
8380 (void *)&cmd_write_reg_bit_regbit,
8381 (void *)&cmd_write_reg_bit_port_id,
8382 (void *)&cmd_write_reg_bit_reg_off,
8383 (void *)&cmd_write_reg_bit_bit_pos,
8384 (void *)&cmd_write_reg_bit_value,
8389 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8390 struct cmd_read_rxd_txd_result {
8391 cmdline_fixed_string_t read;
8392 cmdline_fixed_string_t rxd_txd;
8399 cmd_read_rxd_txd_parsed(void *parsed_result,
8400 __rte_unused struct cmdline *cl,
8401 __rte_unused void *data)
8403 struct cmd_read_rxd_txd_result *res = parsed_result;
8405 if (!strcmp(res->rxd_txd, "rxd"))
8406 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8407 else if (!strcmp(res->rxd_txd, "txd"))
8408 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8411 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8412 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8413 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8414 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8416 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8417 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8419 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8420 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8422 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8423 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8426 cmdline_parse_inst_t cmd_read_rxd_txd = {
8427 .f = cmd_read_rxd_txd_parsed,
8429 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8431 (void *)&cmd_read_rxd_txd_read,
8432 (void *)&cmd_read_rxd_txd_rxd_txd,
8433 (void *)&cmd_read_rxd_txd_port_id,
8434 (void *)&cmd_read_rxd_txd_queue_id,
8435 (void *)&cmd_read_rxd_txd_desc_id,
8441 struct cmd_quit_result {
8442 cmdline_fixed_string_t quit;
8445 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8447 __rte_unused void *data)
8452 cmdline_parse_token_string_t cmd_quit_quit =
8453 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8455 cmdline_parse_inst_t cmd_quit = {
8456 .f = cmd_quit_parsed,
8458 .help_str = "quit: Exit application",
8460 (void *)&cmd_quit_quit,
8465 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8466 struct cmd_mac_addr_result {
8467 cmdline_fixed_string_t mac_addr_cmd;
8468 cmdline_fixed_string_t what;
8470 struct rte_ether_addr address;
8473 static void cmd_mac_addr_parsed(void *parsed_result,
8474 __rte_unused struct cmdline *cl,
8475 __rte_unused void *data)
8477 struct cmd_mac_addr_result *res = parsed_result;
8480 if (strcmp(res->what, "add") == 0)
8481 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8482 else if (strcmp(res->what, "set") == 0)
8483 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8486 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8488 /* check the return value and print it if is < 0 */
8490 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8494 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8495 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8497 cmdline_parse_token_string_t cmd_mac_addr_what =
8498 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8500 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8501 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8503 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8504 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8506 cmdline_parse_inst_t cmd_mac_addr = {
8507 .f = cmd_mac_addr_parsed,
8509 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8510 "Add/Remove/Set MAC address on port_id",
8512 (void *)&cmd_mac_addr_cmd,
8513 (void *)&cmd_mac_addr_what,
8514 (void *)&cmd_mac_addr_portnum,
8515 (void *)&cmd_mac_addr_addr,
8520 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8521 struct cmd_eth_peer_result {
8522 cmdline_fixed_string_t set;
8523 cmdline_fixed_string_t eth_peer;
8525 cmdline_fixed_string_t peer_addr;
8528 static void cmd_set_eth_peer_parsed(void *parsed_result,
8529 __rte_unused struct cmdline *cl,
8530 __rte_unused void *data)
8532 struct cmd_eth_peer_result *res = parsed_result;
8534 if (test_done == 0) {
8535 fprintf(stderr, "Please stop forwarding first\n");
8538 if (!strcmp(res->eth_peer, "eth-peer")) {
8539 set_fwd_eth_peer(res->port_id, res->peer_addr);
8543 cmdline_parse_token_string_t cmd_eth_peer_set =
8544 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8545 cmdline_parse_token_string_t cmd_eth_peer =
8546 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8547 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8548 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8550 cmdline_parse_token_string_t cmd_eth_peer_addr =
8551 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8553 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8554 .f = cmd_set_eth_peer_parsed,
8556 .help_str = "set eth-peer <port_id> <peer_mac>",
8558 (void *)&cmd_eth_peer_set,
8559 (void *)&cmd_eth_peer,
8560 (void *)&cmd_eth_peer_port_id,
8561 (void *)&cmd_eth_peer_addr,
8566 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8567 struct cmd_set_qmap_result {
8568 cmdline_fixed_string_t set;
8569 cmdline_fixed_string_t qmap;
8570 cmdline_fixed_string_t what;
8577 cmd_set_qmap_parsed(void *parsed_result,
8578 __rte_unused struct cmdline *cl,
8579 __rte_unused void *data)
8581 struct cmd_set_qmap_result *res = parsed_result;
8582 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8584 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8587 cmdline_parse_token_string_t cmd_setqmap_set =
8588 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8590 cmdline_parse_token_string_t cmd_setqmap_qmap =
8591 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8593 cmdline_parse_token_string_t cmd_setqmap_what =
8594 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8596 cmdline_parse_token_num_t cmd_setqmap_portid =
8597 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8598 port_id, RTE_UINT16);
8599 cmdline_parse_token_num_t cmd_setqmap_queueid =
8600 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8601 queue_id, RTE_UINT16);
8602 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8603 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8604 map_value, RTE_UINT8);
8606 cmdline_parse_inst_t cmd_set_qmap = {
8607 .f = cmd_set_qmap_parsed,
8609 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8610 "Set statistics mapping value on tx|rx queue_id of port_id",
8612 (void *)&cmd_setqmap_set,
8613 (void *)&cmd_setqmap_qmap,
8614 (void *)&cmd_setqmap_what,
8615 (void *)&cmd_setqmap_portid,
8616 (void *)&cmd_setqmap_queueid,
8617 (void *)&cmd_setqmap_mapvalue,
8622 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8623 struct cmd_set_xstats_hide_zero_result {
8624 cmdline_fixed_string_t keyword;
8625 cmdline_fixed_string_t name;
8626 cmdline_fixed_string_t on_off;
8630 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8631 __rte_unused struct cmdline *cl,
8632 __rte_unused void *data)
8634 struct cmd_set_xstats_hide_zero_result *res;
8635 uint16_t on_off = 0;
8637 res = parsed_result;
8638 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8639 set_xstats_hide_zero(on_off);
8642 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8643 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8645 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8646 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8647 name, "xstats-hide-zero");
8648 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8649 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8652 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8653 .f = cmd_set_xstats_hide_zero_parsed,
8655 .help_str = "set xstats-hide-zero on|off",
8657 (void *)&cmd_set_xstats_hide_zero_keyword,
8658 (void *)&cmd_set_xstats_hide_zero_name,
8659 (void *)&cmd_set_xstats_hide_zero_on_off,
8664 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8665 struct cmd_set_record_core_cycles_result {
8666 cmdline_fixed_string_t keyword;
8667 cmdline_fixed_string_t name;
8668 cmdline_fixed_string_t on_off;
8672 cmd_set_record_core_cycles_parsed(void *parsed_result,
8673 __rte_unused struct cmdline *cl,
8674 __rte_unused void *data)
8676 struct cmd_set_record_core_cycles_result *res;
8677 uint16_t on_off = 0;
8679 res = parsed_result;
8680 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8681 set_record_core_cycles(on_off);
8684 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8685 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8687 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8688 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8689 name, "record-core-cycles");
8690 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8691 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8694 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8695 .f = cmd_set_record_core_cycles_parsed,
8697 .help_str = "set record-core-cycles on|off",
8699 (void *)&cmd_set_record_core_cycles_keyword,
8700 (void *)&cmd_set_record_core_cycles_name,
8701 (void *)&cmd_set_record_core_cycles_on_off,
8706 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8707 struct cmd_set_record_burst_stats_result {
8708 cmdline_fixed_string_t keyword;
8709 cmdline_fixed_string_t name;
8710 cmdline_fixed_string_t on_off;
8714 cmd_set_record_burst_stats_parsed(void *parsed_result,
8715 __rte_unused struct cmdline *cl,
8716 __rte_unused void *data)
8718 struct cmd_set_record_burst_stats_result *res;
8719 uint16_t on_off = 0;
8721 res = parsed_result;
8722 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8723 set_record_burst_stats(on_off);
8726 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8727 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8729 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8730 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8731 name, "record-burst-stats");
8732 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8733 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8736 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8737 .f = cmd_set_record_burst_stats_parsed,
8739 .help_str = "set record-burst-stats on|off",
8741 (void *)&cmd_set_record_burst_stats_keyword,
8742 (void *)&cmd_set_record_burst_stats_name,
8743 (void *)&cmd_set_record_burst_stats_on_off,
8748 /* *** CONFIGURE UNICAST HASH TABLE *** */
8749 struct cmd_set_uc_hash_table {
8750 cmdline_fixed_string_t set;
8751 cmdline_fixed_string_t port;
8753 cmdline_fixed_string_t what;
8754 struct rte_ether_addr address;
8755 cmdline_fixed_string_t mode;
8759 cmd_set_uc_hash_parsed(void *parsed_result,
8760 __rte_unused struct cmdline *cl,
8761 __rte_unused void *data)
8764 struct cmd_set_uc_hash_table *res = parsed_result;
8766 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8768 if (strcmp(res->what, "uta") == 0)
8769 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8770 &res->address,(uint8_t)is_on);
8773 "bad unicast hash table parameter, return code = %d\n",
8778 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8779 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8781 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8782 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8784 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8785 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8786 port_id, RTE_UINT16);
8787 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8788 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8790 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8791 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8793 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8794 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8797 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8798 .f = cmd_set_uc_hash_parsed,
8800 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8802 (void *)&cmd_set_uc_hash_set,
8803 (void *)&cmd_set_uc_hash_port,
8804 (void *)&cmd_set_uc_hash_portid,
8805 (void *)&cmd_set_uc_hash_what,
8806 (void *)&cmd_set_uc_hash_mac,
8807 (void *)&cmd_set_uc_hash_mode,
8812 struct cmd_set_uc_all_hash_table {
8813 cmdline_fixed_string_t set;
8814 cmdline_fixed_string_t port;
8816 cmdline_fixed_string_t what;
8817 cmdline_fixed_string_t value;
8818 cmdline_fixed_string_t mode;
8822 cmd_set_uc_all_hash_parsed(void *parsed_result,
8823 __rte_unused struct cmdline *cl,
8824 __rte_unused void *data)
8827 struct cmd_set_uc_all_hash_table *res = parsed_result;
8829 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8831 if ((strcmp(res->what, "uta") == 0) &&
8832 (strcmp(res->value, "all") == 0))
8833 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8836 "bad unicast hash table parameter, return code = %d\n",
8840 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8841 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8843 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8844 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8846 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8847 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8848 port_id, RTE_UINT16);
8849 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8850 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8852 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8853 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8855 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8856 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8859 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8860 .f = cmd_set_uc_all_hash_parsed,
8862 .help_str = "set port <port_id> uta all on|off",
8864 (void *)&cmd_set_uc_all_hash_set,
8865 (void *)&cmd_set_uc_all_hash_port,
8866 (void *)&cmd_set_uc_all_hash_portid,
8867 (void *)&cmd_set_uc_all_hash_what,
8868 (void *)&cmd_set_uc_all_hash_value,
8869 (void *)&cmd_set_uc_all_hash_mode,
8874 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8875 struct cmd_set_vf_traffic {
8876 cmdline_fixed_string_t set;
8877 cmdline_fixed_string_t port;
8879 cmdline_fixed_string_t vf;
8881 cmdline_fixed_string_t what;
8882 cmdline_fixed_string_t mode;
8886 cmd_set_vf_traffic_parsed(void *parsed_result,
8887 __rte_unused struct cmdline *cl,
8888 __rte_unused void *data)
8890 struct cmd_set_vf_traffic *res = parsed_result;
8891 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8892 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8894 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8897 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8898 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8900 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8901 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8903 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8904 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8905 port_id, RTE_UINT16);
8906 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8907 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8909 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8910 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8912 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8913 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8915 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8916 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8919 cmdline_parse_inst_t cmd_set_vf_traffic = {
8920 .f = cmd_set_vf_traffic_parsed,
8922 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8924 (void *)&cmd_setvf_traffic_set,
8925 (void *)&cmd_setvf_traffic_port,
8926 (void *)&cmd_setvf_traffic_portid,
8927 (void *)&cmd_setvf_traffic_vf,
8928 (void *)&cmd_setvf_traffic_vfid,
8929 (void *)&cmd_setvf_traffic_what,
8930 (void *)&cmd_setvf_traffic_mode,
8935 /* *** CONFIGURE VF RECEIVE MODE *** */
8936 struct cmd_set_vf_rxmode {
8937 cmdline_fixed_string_t set;
8938 cmdline_fixed_string_t port;
8940 cmdline_fixed_string_t vf;
8942 cmdline_fixed_string_t what;
8943 cmdline_fixed_string_t mode;
8944 cmdline_fixed_string_t on;
8948 cmd_set_vf_rxmode_parsed(void *parsed_result,
8949 __rte_unused struct cmdline *cl,
8950 __rte_unused void *data)
8953 uint16_t vf_rxmode = 0;
8954 struct cmd_set_vf_rxmode *res = parsed_result;
8956 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8957 if (!strcmp(res->what,"rxmode")) {
8958 if (!strcmp(res->mode, "AUPE"))
8959 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8960 else if (!strcmp(res->mode, "ROPE"))
8961 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8962 else if (!strcmp(res->mode, "BAM"))
8963 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8964 else if (!strncmp(res->mode, "MPE",3))
8965 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8968 RTE_SET_USED(is_on);
8970 #ifdef RTE_NET_IXGBE
8971 if (ret == -ENOTSUP)
8972 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8973 vf_rxmode, (uint8_t)is_on);
8976 if (ret == -ENOTSUP)
8977 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8978 vf_rxmode, (uint8_t)is_on);
8982 "bad VF receive mode parameter, return code = %d\n",
8986 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8987 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8989 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8990 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8992 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8993 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8994 port_id, RTE_UINT16);
8995 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8996 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8998 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8999 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9001 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9002 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9004 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9005 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9006 mode, "AUPE#ROPE#BAM#MPE");
9007 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9008 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9011 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9012 .f = cmd_set_vf_rxmode_parsed,
9014 .help_str = "set port <port_id> vf <vf_id> rxmode "
9015 "AUPE|ROPE|BAM|MPE on|off",
9017 (void *)&cmd_set_vf_rxmode_set,
9018 (void *)&cmd_set_vf_rxmode_port,
9019 (void *)&cmd_set_vf_rxmode_portid,
9020 (void *)&cmd_set_vf_rxmode_vf,
9021 (void *)&cmd_set_vf_rxmode_vfid,
9022 (void *)&cmd_set_vf_rxmode_what,
9023 (void *)&cmd_set_vf_rxmode_mode,
9024 (void *)&cmd_set_vf_rxmode_on,
9029 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9030 struct cmd_vf_mac_addr_result {
9031 cmdline_fixed_string_t mac_addr_cmd;
9032 cmdline_fixed_string_t what;
9033 cmdline_fixed_string_t port;
9035 cmdline_fixed_string_t vf;
9037 struct rte_ether_addr address;
9040 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9041 __rte_unused struct cmdline *cl,
9042 __rte_unused void *data)
9044 struct cmd_vf_mac_addr_result *res = parsed_result;
9047 if (strcmp(res->what, "add") != 0)
9051 if (ret == -ENOTSUP)
9052 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9056 if (ret == -ENOTSUP)
9057 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9062 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9066 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9067 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9068 mac_addr_cmd,"mac_addr");
9069 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9070 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9072 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9073 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9075 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9076 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9077 port_num, RTE_UINT16);
9078 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9079 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9081 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9082 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9084 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9085 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9088 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9089 .f = cmd_vf_mac_addr_parsed,
9091 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9092 "Add MAC address filtering for a VF on port_id",
9094 (void *)&cmd_vf_mac_addr_cmd,
9095 (void *)&cmd_vf_mac_addr_what,
9096 (void *)&cmd_vf_mac_addr_port,
9097 (void *)&cmd_vf_mac_addr_portnum,
9098 (void *)&cmd_vf_mac_addr_vf,
9099 (void *)&cmd_vf_mac_addr_vfnum,
9100 (void *)&cmd_vf_mac_addr_addr,
9105 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9106 struct cmd_vf_rx_vlan_filter {
9107 cmdline_fixed_string_t rx_vlan;
9108 cmdline_fixed_string_t what;
9110 cmdline_fixed_string_t port;
9112 cmdline_fixed_string_t vf;
9117 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9118 __rte_unused struct cmdline *cl,
9119 __rte_unused void *data)
9121 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9124 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9126 #ifdef RTE_NET_IXGBE
9127 if (ret == -ENOTSUP)
9128 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9129 res->vlan_id, res->vf_mask, is_add);
9132 if (ret == -ENOTSUP)
9133 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9134 res->vlan_id, res->vf_mask, is_add);
9137 if (ret == -ENOTSUP)
9138 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9139 res->vlan_id, res->vf_mask, is_add);
9146 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9147 res->vlan_id, res->vf_mask);
9150 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9153 fprintf(stderr, "function not implemented or supported\n");
9156 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9160 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9161 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9162 rx_vlan, "rx_vlan");
9163 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9164 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9166 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9167 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9168 vlan_id, RTE_UINT16);
9169 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9170 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9172 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9173 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9174 port_id, RTE_UINT16);
9175 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9176 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9178 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9179 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9180 vf_mask, RTE_UINT64);
9182 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9183 .f = cmd_vf_rx_vlan_filter_parsed,
9185 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9186 "(vf_mask = hexadecimal VF mask)",
9188 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9189 (void *)&cmd_vf_rx_vlan_filter_what,
9190 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9191 (void *)&cmd_vf_rx_vlan_filter_port,
9192 (void *)&cmd_vf_rx_vlan_filter_portid,
9193 (void *)&cmd_vf_rx_vlan_filter_vf,
9194 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9199 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9200 struct cmd_queue_rate_limit_result {
9201 cmdline_fixed_string_t set;
9202 cmdline_fixed_string_t port;
9204 cmdline_fixed_string_t queue;
9206 cmdline_fixed_string_t rate;
9210 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9211 __rte_unused struct cmdline *cl,
9212 __rte_unused void *data)
9214 struct cmd_queue_rate_limit_result *res = parsed_result;
9217 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9218 && (strcmp(res->queue, "queue") == 0)
9219 && (strcmp(res->rate, "rate") == 0))
9220 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9223 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9228 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9229 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9231 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9232 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9234 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9235 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9236 port_num, RTE_UINT16);
9237 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9238 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9240 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9241 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9242 queue_num, RTE_UINT8);
9243 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9244 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9246 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9247 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9248 rate_num, RTE_UINT16);
9250 cmdline_parse_inst_t cmd_queue_rate_limit = {
9251 .f = cmd_queue_rate_limit_parsed,
9253 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9254 "Set rate limit for a queue on port_id",
9256 (void *)&cmd_queue_rate_limit_set,
9257 (void *)&cmd_queue_rate_limit_port,
9258 (void *)&cmd_queue_rate_limit_portnum,
9259 (void *)&cmd_queue_rate_limit_queue,
9260 (void *)&cmd_queue_rate_limit_queuenum,
9261 (void *)&cmd_queue_rate_limit_rate,
9262 (void *)&cmd_queue_rate_limit_ratenum,
9267 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9268 struct cmd_vf_rate_limit_result {
9269 cmdline_fixed_string_t set;
9270 cmdline_fixed_string_t port;
9272 cmdline_fixed_string_t vf;
9274 cmdline_fixed_string_t rate;
9276 cmdline_fixed_string_t q_msk;
9280 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9281 __rte_unused struct cmdline *cl,
9282 __rte_unused void *data)
9284 struct cmd_vf_rate_limit_result *res = parsed_result;
9287 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9288 && (strcmp(res->vf, "vf") == 0)
9289 && (strcmp(res->rate, "rate") == 0)
9290 && (strcmp(res->q_msk, "queue_mask") == 0))
9291 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9292 res->rate_num, res->q_msk_val);
9294 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9299 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9300 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9302 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9303 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9305 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9306 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9307 port_num, RTE_UINT16);
9308 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9309 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9311 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9312 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9314 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9315 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9317 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9318 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9319 rate_num, RTE_UINT16);
9320 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9321 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9322 q_msk, "queue_mask");
9323 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9324 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9325 q_msk_val, RTE_UINT64);
9327 cmdline_parse_inst_t cmd_vf_rate_limit = {
9328 .f = cmd_vf_rate_limit_parsed,
9330 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9331 "queue_mask <queue_mask_value>: "
9332 "Set rate limit for queues of VF on port_id",
9334 (void *)&cmd_vf_rate_limit_set,
9335 (void *)&cmd_vf_rate_limit_port,
9336 (void *)&cmd_vf_rate_limit_portnum,
9337 (void *)&cmd_vf_rate_limit_vf,
9338 (void *)&cmd_vf_rate_limit_vfnum,
9339 (void *)&cmd_vf_rate_limit_rate,
9340 (void *)&cmd_vf_rate_limit_ratenum,
9341 (void *)&cmd_vf_rate_limit_q_msk,
9342 (void *)&cmd_vf_rate_limit_q_msk_val,
9347 /* *** CONFIGURE TUNNEL UDP PORT *** */
9348 struct cmd_tunnel_udp_config {
9349 cmdline_fixed_string_t rx_vxlan_port;
9350 cmdline_fixed_string_t what;
9356 cmd_tunnel_udp_config_parsed(void *parsed_result,
9357 __rte_unused struct cmdline *cl,
9358 __rte_unused void *data)
9360 struct cmd_tunnel_udp_config *res = parsed_result;
9361 struct rte_eth_udp_tunnel tunnel_udp;
9364 tunnel_udp.udp_port = res->udp_port;
9365 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9367 if (!strcmp(res->what, "add"))
9368 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9371 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9375 fprintf(stderr, "udp tunneling add error: (%s)\n",
9379 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9380 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9381 rx_vxlan_port, "rx_vxlan_port");
9382 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9383 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9385 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9386 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9387 udp_port, RTE_UINT16);
9388 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9389 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9390 port_id, RTE_UINT16);
9392 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9393 .f = cmd_tunnel_udp_config_parsed,
9395 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9396 "Add/Remove a tunneling UDP port filter",
9398 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9399 (void *)&cmd_tunnel_udp_config_what,
9400 (void *)&cmd_tunnel_udp_config_udp_port,
9401 (void *)&cmd_tunnel_udp_config_port_id,
9406 struct cmd_config_tunnel_udp_port {
9407 cmdline_fixed_string_t port;
9408 cmdline_fixed_string_t config;
9410 cmdline_fixed_string_t udp_tunnel_port;
9411 cmdline_fixed_string_t action;
9412 cmdline_fixed_string_t tunnel_type;
9417 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9418 __rte_unused struct cmdline *cl,
9419 __rte_unused void *data)
9421 struct cmd_config_tunnel_udp_port *res = parsed_result;
9422 struct rte_eth_udp_tunnel tunnel_udp;
9425 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9428 tunnel_udp.udp_port = res->udp_port;
9430 if (!strcmp(res->tunnel_type, "vxlan")) {
9431 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9432 } else if (!strcmp(res->tunnel_type, "geneve")) {
9433 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9434 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9435 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9436 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9437 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9439 fprintf(stderr, "Invalid tunnel type\n");
9443 if (!strcmp(res->action, "add"))
9444 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9447 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9451 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9455 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9456 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9458 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9459 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9461 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9462 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9464 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9465 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9468 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9469 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9471 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9472 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9473 "vxlan#geneve#vxlan-gpe#ecpri");
9474 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9475 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9478 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9479 .f = cmd_cfg_tunnel_udp_port_parsed,
9481 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9482 "geneve|vxlan-gpe|ecpri <udp_port>",
9484 (void *)&cmd_config_tunnel_udp_port_port,
9485 (void *)&cmd_config_tunnel_udp_port_config,
9486 (void *)&cmd_config_tunnel_udp_port_port_id,
9487 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9488 (void *)&cmd_config_tunnel_udp_port_action,
9489 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9490 (void *)&cmd_config_tunnel_udp_port_value,
9495 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9496 struct cmd_set_mirror_mask_result {
9497 cmdline_fixed_string_t set;
9498 cmdline_fixed_string_t port;
9500 cmdline_fixed_string_t mirror;
9502 cmdline_fixed_string_t what;
9503 cmdline_fixed_string_t value;
9504 cmdline_fixed_string_t dstpool;
9506 cmdline_fixed_string_t on;
9509 cmdline_parse_token_string_t cmd_mirror_mask_set =
9510 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9512 cmdline_parse_token_string_t cmd_mirror_mask_port =
9513 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9515 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9516 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9517 port_id, RTE_UINT16);
9518 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9519 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9520 mirror, "mirror-rule");
9521 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9522 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9523 rule_id, RTE_UINT8);
9524 cmdline_parse_token_string_t cmd_mirror_mask_what =
9525 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9526 what, "pool-mirror-up#pool-mirror-down"
9528 cmdline_parse_token_string_t cmd_mirror_mask_value =
9529 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9531 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9532 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9533 dstpool, "dst-pool");
9534 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9535 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9536 dstpool_id, RTE_UINT8);
9537 cmdline_parse_token_string_t cmd_mirror_mask_on =
9538 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9542 cmd_set_mirror_mask_parsed(void *parsed_result,
9543 __rte_unused struct cmdline *cl,
9544 __rte_unused void *data)
9547 struct cmd_set_mirror_mask_result *res = parsed_result;
9548 struct rte_eth_mirror_conf mr_conf;
9550 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9552 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9554 mr_conf.dst_pool = res->dstpool_id;
9556 if (!strcmp(res->what, "pool-mirror-up")) {
9557 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9558 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9559 } else if (!strcmp(res->what, "pool-mirror-down")) {
9560 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9561 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9562 } else if (!strcmp(res->what, "vlan-mirror")) {
9563 mr_conf.rule_type = ETH_MIRROR_VLAN;
9564 nb_item = parse_item_list(res->value, "vlan",
9565 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9569 for (i = 0; i < nb_item; i++) {
9570 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9572 "Invalid vlan_id: must be < 4096\n");
9576 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9577 mr_conf.vlan.vlan_mask |= 1ULL << i;
9581 if (!strcmp(res->on, "on"))
9582 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9585 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9588 fprintf(stderr, "mirror rule add error: (%s)\n",
9592 cmdline_parse_inst_t cmd_set_mirror_mask = {
9593 .f = cmd_set_mirror_mask_parsed,
9595 .help_str = "set port <port_id> mirror-rule <rule_id> "
9596 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9597 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9599 (void *)&cmd_mirror_mask_set,
9600 (void *)&cmd_mirror_mask_port,
9601 (void *)&cmd_mirror_mask_portid,
9602 (void *)&cmd_mirror_mask_mirror,
9603 (void *)&cmd_mirror_mask_ruleid,
9604 (void *)&cmd_mirror_mask_what,
9605 (void *)&cmd_mirror_mask_value,
9606 (void *)&cmd_mirror_mask_dstpool,
9607 (void *)&cmd_mirror_mask_poolid,
9608 (void *)&cmd_mirror_mask_on,
9613 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9614 struct cmd_set_mirror_link_result {
9615 cmdline_fixed_string_t set;
9616 cmdline_fixed_string_t port;
9618 cmdline_fixed_string_t mirror;
9620 cmdline_fixed_string_t what;
9621 cmdline_fixed_string_t dstpool;
9623 cmdline_fixed_string_t on;
9626 cmdline_parse_token_string_t cmd_mirror_link_set =
9627 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9629 cmdline_parse_token_string_t cmd_mirror_link_port =
9630 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9632 cmdline_parse_token_num_t cmd_mirror_link_portid =
9633 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9634 port_id, RTE_UINT16);
9635 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9636 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9637 mirror, "mirror-rule");
9638 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9639 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9640 rule_id, RTE_UINT8);
9641 cmdline_parse_token_string_t cmd_mirror_link_what =
9642 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9643 what, "uplink-mirror#downlink-mirror");
9644 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9645 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9646 dstpool, "dst-pool");
9647 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9648 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9649 dstpool_id, RTE_UINT8);
9650 cmdline_parse_token_string_t cmd_mirror_link_on =
9651 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9655 cmd_set_mirror_link_parsed(void *parsed_result,
9656 __rte_unused struct cmdline *cl,
9657 __rte_unused void *data)
9660 struct cmd_set_mirror_link_result *res = parsed_result;
9661 struct rte_eth_mirror_conf mr_conf;
9663 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9664 if (!strcmp(res->what, "uplink-mirror"))
9665 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9667 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9669 mr_conf.dst_pool = res->dstpool_id;
9671 if (!strcmp(res->on, "on"))
9672 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9675 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9678 /* check the return value and print it if is < 0 */
9680 fprintf(stderr, "mirror rule add error: (%s)\n",
9685 cmdline_parse_inst_t cmd_set_mirror_link = {
9686 .f = cmd_set_mirror_link_parsed,
9688 .help_str = "set port <port_id> mirror-rule <rule_id> "
9689 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9691 (void *)&cmd_mirror_link_set,
9692 (void *)&cmd_mirror_link_port,
9693 (void *)&cmd_mirror_link_portid,
9694 (void *)&cmd_mirror_link_mirror,
9695 (void *)&cmd_mirror_link_ruleid,
9696 (void *)&cmd_mirror_link_what,
9697 (void *)&cmd_mirror_link_dstpool,
9698 (void *)&cmd_mirror_link_poolid,
9699 (void *)&cmd_mirror_link_on,
9704 /* *** RESET VM MIRROR RULE *** */
9705 struct cmd_rm_mirror_rule_result {
9706 cmdline_fixed_string_t reset;
9707 cmdline_fixed_string_t port;
9709 cmdline_fixed_string_t mirror;
9713 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9714 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9716 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9717 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9719 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9720 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9721 port_id, RTE_UINT16);
9722 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9723 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9724 mirror, "mirror-rule");
9725 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9726 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9727 rule_id, RTE_UINT8);
9730 cmd_reset_mirror_rule_parsed(void *parsed_result,
9731 __rte_unused struct cmdline *cl,
9732 __rte_unused void *data)
9735 struct cmd_set_mirror_link_result *res = parsed_result;
9737 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9739 fprintf(stderr, "mirror rule remove error: (%s)\n",
9743 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9744 .f = cmd_reset_mirror_rule_parsed,
9746 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9748 (void *)&cmd_rm_mirror_rule_reset,
9749 (void *)&cmd_rm_mirror_rule_port,
9750 (void *)&cmd_rm_mirror_rule_portid,
9751 (void *)&cmd_rm_mirror_rule_mirror,
9752 (void *)&cmd_rm_mirror_rule_ruleid,
9757 /* ******************************************************************************** */
9759 struct cmd_dump_result {
9760 cmdline_fixed_string_t dump;
9764 dump_struct_sizes(void)
9766 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9767 DUMP_SIZE(struct rte_mbuf);
9768 DUMP_SIZE(struct rte_mempool);
9769 DUMP_SIZE(struct rte_ring);
9774 /* Dump the socket memory statistics on console */
9776 dump_socket_mem(FILE *f)
9778 struct rte_malloc_socket_stats socket_stats;
9783 unsigned int n_alloc = 0;
9784 unsigned int n_free = 0;
9785 static size_t last_allocs;
9786 static size_t last_total;
9789 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9790 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9791 !socket_stats.heap_totalsz_bytes)
9793 total += socket_stats.heap_totalsz_bytes;
9794 alloc += socket_stats.heap_allocsz_bytes;
9795 free += socket_stats.heap_freesz_bytes;
9796 n_alloc += socket_stats.alloc_count;
9797 n_free += socket_stats.free_count;
9799 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9801 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9802 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9803 (double)socket_stats.heap_allocsz_bytes * 100 /
9804 (double)socket_stats.heap_totalsz_bytes,
9805 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9806 socket_stats.alloc_count,
9807 socket_stats.free_count);
9810 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9811 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9812 total ? ((double)alloc * 100 / (double)total) : 0,
9813 (double)free / (1024 * 1024),
9816 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9817 ((double)total - (double)last_total) / (1024 * 1024),
9818 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9819 last_allocs = alloc;
9823 static void cmd_dump_parsed(void *parsed_result,
9824 __rte_unused struct cmdline *cl,
9825 __rte_unused void *data)
9827 struct cmd_dump_result *res = parsed_result;
9829 if (!strcmp(res->dump, "dump_physmem"))
9830 rte_dump_physmem_layout(stdout);
9831 else if (!strcmp(res->dump, "dump_socket_mem"))
9832 dump_socket_mem(stdout);
9833 else if (!strcmp(res->dump, "dump_memzone"))
9834 rte_memzone_dump(stdout);
9835 else if (!strcmp(res->dump, "dump_struct_sizes"))
9836 dump_struct_sizes();
9837 else if (!strcmp(res->dump, "dump_ring"))
9838 rte_ring_list_dump(stdout);
9839 else if (!strcmp(res->dump, "dump_mempool"))
9840 rte_mempool_list_dump(stdout);
9841 else if (!strcmp(res->dump, "dump_devargs"))
9842 rte_devargs_dump(stdout);
9843 else if (!strcmp(res->dump, "dump_log_types"))
9844 rte_log_dump(stdout);
9847 cmdline_parse_token_string_t cmd_dump_dump =
9848 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9852 "dump_struct_sizes#"
9858 cmdline_parse_inst_t cmd_dump = {
9859 .f = cmd_dump_parsed, /* function to call */
9860 .data = NULL, /* 2nd arg of func */
9861 .help_str = "Dump status",
9862 .tokens = { /* token list, NULL terminated */
9863 (void *)&cmd_dump_dump,
9868 /* ******************************************************************************** */
9870 struct cmd_dump_one_result {
9871 cmdline_fixed_string_t dump;
9872 cmdline_fixed_string_t name;
9875 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9876 __rte_unused void *data)
9878 struct cmd_dump_one_result *res = parsed_result;
9880 if (!strcmp(res->dump, "dump_ring")) {
9882 r = rte_ring_lookup(res->name);
9884 cmdline_printf(cl, "Cannot find ring\n");
9887 rte_ring_dump(stdout, r);
9888 } else if (!strcmp(res->dump, "dump_mempool")) {
9889 struct rte_mempool *mp;
9890 mp = rte_mempool_lookup(res->name);
9892 cmdline_printf(cl, "Cannot find mempool\n");
9895 rte_mempool_dump(stdout, mp);
9899 cmdline_parse_token_string_t cmd_dump_one_dump =
9900 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9901 "dump_ring#dump_mempool");
9903 cmdline_parse_token_string_t cmd_dump_one_name =
9904 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9906 cmdline_parse_inst_t cmd_dump_one = {
9907 .f = cmd_dump_one_parsed, /* function to call */
9908 .data = NULL, /* 2nd arg of func */
9909 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9910 .tokens = { /* token list, NULL terminated */
9911 (void *)&cmd_dump_one_dump,
9912 (void *)&cmd_dump_one_name,
9917 /* *** queue region set *** */
9918 struct cmd_queue_region_result {
9919 cmdline_fixed_string_t set;
9920 cmdline_fixed_string_t port;
9922 cmdline_fixed_string_t cmd;
9923 cmdline_fixed_string_t region;
9925 cmdline_fixed_string_t queue_start_index;
9927 cmdline_fixed_string_t queue_num;
9928 uint8_t queue_num_value;
9932 cmd_queue_region_parsed(void *parsed_result,
9933 __rte_unused struct cmdline *cl,
9934 __rte_unused void *data)
9936 struct cmd_queue_region_result *res = parsed_result;
9939 struct rte_pmd_i40e_queue_region_conf region_conf;
9940 enum rte_pmd_i40e_queue_region_op op_type;
9943 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9947 memset(®ion_conf, 0, sizeof(region_conf));
9948 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9949 region_conf.region_id = res->region_id;
9950 region_conf.queue_num = res->queue_num_value;
9951 region_conf.queue_start_index = res->queue_id;
9953 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9954 op_type, ®ion_conf);
9961 fprintf(stderr, "function not implemented or supported\n");
9964 fprintf(stderr, "queue region config error: (%s)\n",
9969 cmdline_parse_token_string_t cmd_queue_region_set =
9970 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9972 cmdline_parse_token_string_t cmd_queue_region_port =
9973 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9974 cmdline_parse_token_num_t cmd_queue_region_port_id =
9975 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9976 port_id, RTE_UINT16);
9977 cmdline_parse_token_string_t cmd_queue_region_cmd =
9978 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9979 cmd, "queue-region");
9980 cmdline_parse_token_string_t cmd_queue_region_id =
9981 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9982 region, "region_id");
9983 cmdline_parse_token_num_t cmd_queue_region_index =
9984 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9985 region_id, RTE_UINT8);
9986 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9987 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9988 queue_start_index, "queue_start_index");
9989 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9990 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9991 queue_id, RTE_UINT8);
9992 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9993 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9994 queue_num, "queue_num");
9995 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9996 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9997 queue_num_value, RTE_UINT8);
9999 cmdline_parse_inst_t cmd_queue_region = {
10000 .f = cmd_queue_region_parsed,
10002 .help_str = "set port <port_id> queue-region region_id <value> "
10003 "queue_start_index <value> queue_num <value>: Set a queue region",
10005 (void *)&cmd_queue_region_set,
10006 (void *)&cmd_queue_region_port,
10007 (void *)&cmd_queue_region_port_id,
10008 (void *)&cmd_queue_region_cmd,
10009 (void *)&cmd_queue_region_id,
10010 (void *)&cmd_queue_region_index,
10011 (void *)&cmd_queue_region_queue_start_index,
10012 (void *)&cmd_queue_region_queue_id,
10013 (void *)&cmd_queue_region_queue_num,
10014 (void *)&cmd_queue_region_queue_num_value,
10019 /* *** queue region and flowtype set *** */
10020 struct cmd_region_flowtype_result {
10021 cmdline_fixed_string_t set;
10022 cmdline_fixed_string_t port;
10024 cmdline_fixed_string_t cmd;
10025 cmdline_fixed_string_t region;
10027 cmdline_fixed_string_t flowtype;
10028 uint8_t flowtype_id;
10032 cmd_region_flowtype_parsed(void *parsed_result,
10033 __rte_unused struct cmdline *cl,
10034 __rte_unused void *data)
10036 struct cmd_region_flowtype_result *res = parsed_result;
10037 int ret = -ENOTSUP;
10038 #ifdef RTE_NET_I40E
10039 struct rte_pmd_i40e_queue_region_conf region_conf;
10040 enum rte_pmd_i40e_queue_region_op op_type;
10043 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10046 #ifdef RTE_NET_I40E
10047 memset(®ion_conf, 0, sizeof(region_conf));
10049 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10050 region_conf.region_id = res->region_id;
10051 region_conf.hw_flowtype = res->flowtype_id;
10053 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10054 op_type, ®ion_conf);
10061 fprintf(stderr, "function not implemented or supported\n");
10064 fprintf(stderr, "region flowtype config error: (%s)\n",
10069 cmdline_parse_token_string_t cmd_region_flowtype_set =
10070 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10072 cmdline_parse_token_string_t cmd_region_flowtype_port =
10073 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10075 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10076 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10077 port_id, RTE_UINT16);
10078 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10079 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10080 cmd, "queue-region");
10081 cmdline_parse_token_string_t cmd_region_flowtype_index =
10082 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10083 region, "region_id");
10084 cmdline_parse_token_num_t cmd_region_flowtype_id =
10085 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10086 region_id, RTE_UINT8);
10087 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10088 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10089 flowtype, "flowtype");
10090 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10091 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10092 flowtype_id, RTE_UINT8);
10093 cmdline_parse_inst_t cmd_region_flowtype = {
10094 .f = cmd_region_flowtype_parsed,
10096 .help_str = "set port <port_id> queue-region region_id <value> "
10097 "flowtype <value>: Set a flowtype region index",
10099 (void *)&cmd_region_flowtype_set,
10100 (void *)&cmd_region_flowtype_port,
10101 (void *)&cmd_region_flowtype_port_index,
10102 (void *)&cmd_region_flowtype_cmd,
10103 (void *)&cmd_region_flowtype_index,
10104 (void *)&cmd_region_flowtype_id,
10105 (void *)&cmd_region_flowtype_flow_index,
10106 (void *)&cmd_region_flowtype_flow_id,
10111 /* *** User Priority (UP) to queue region (region_id) set *** */
10112 struct cmd_user_priority_region_result {
10113 cmdline_fixed_string_t set;
10114 cmdline_fixed_string_t port;
10116 cmdline_fixed_string_t cmd;
10117 cmdline_fixed_string_t user_priority;
10118 uint8_t user_priority_id;
10119 cmdline_fixed_string_t region;
10124 cmd_user_priority_region_parsed(void *parsed_result,
10125 __rte_unused struct cmdline *cl,
10126 __rte_unused void *data)
10128 struct cmd_user_priority_region_result *res = parsed_result;
10129 int ret = -ENOTSUP;
10130 #ifdef RTE_NET_I40E
10131 struct rte_pmd_i40e_queue_region_conf region_conf;
10132 enum rte_pmd_i40e_queue_region_op op_type;
10135 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10138 #ifdef RTE_NET_I40E
10139 memset(®ion_conf, 0, sizeof(region_conf));
10140 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10141 region_conf.user_priority = res->user_priority_id;
10142 region_conf.region_id = res->region_id;
10144 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10145 op_type, ®ion_conf);
10152 fprintf(stderr, "function not implemented or supported\n");
10155 fprintf(stderr, "user_priority region config error: (%s)\n",
10160 cmdline_parse_token_string_t cmd_user_priority_region_set =
10161 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10163 cmdline_parse_token_string_t cmd_user_priority_region_port =
10164 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10166 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10167 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10168 port_id, RTE_UINT16);
10169 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10170 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10171 cmd, "queue-region");
10172 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10173 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10174 user_priority, "UP");
10175 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10176 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10177 user_priority_id, RTE_UINT8);
10178 cmdline_parse_token_string_t cmd_user_priority_region_region =
10179 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10180 region, "region_id");
10181 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10182 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10183 region_id, RTE_UINT8);
10185 cmdline_parse_inst_t cmd_user_priority_region = {
10186 .f = cmd_user_priority_region_parsed,
10188 .help_str = "set port <port_id> queue-region UP <value> "
10189 "region_id <value>: Set the mapping of User Priority (UP) "
10190 "to queue region (region_id) ",
10192 (void *)&cmd_user_priority_region_set,
10193 (void *)&cmd_user_priority_region_port,
10194 (void *)&cmd_user_priority_region_port_index,
10195 (void *)&cmd_user_priority_region_cmd,
10196 (void *)&cmd_user_priority_region_UP,
10197 (void *)&cmd_user_priority_region_UP_id,
10198 (void *)&cmd_user_priority_region_region,
10199 (void *)&cmd_user_priority_region_region_id,
10204 /* *** flush all queue region related configuration *** */
10205 struct cmd_flush_queue_region_result {
10206 cmdline_fixed_string_t set;
10207 cmdline_fixed_string_t port;
10209 cmdline_fixed_string_t cmd;
10210 cmdline_fixed_string_t flush;
10211 cmdline_fixed_string_t what;
10215 cmd_flush_queue_region_parsed(void *parsed_result,
10216 __rte_unused struct cmdline *cl,
10217 __rte_unused void *data)
10219 struct cmd_flush_queue_region_result *res = parsed_result;
10220 int ret = -ENOTSUP;
10221 #ifdef RTE_NET_I40E
10222 struct rte_pmd_i40e_queue_region_conf region_conf;
10223 enum rte_pmd_i40e_queue_region_op op_type;
10226 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10229 #ifdef RTE_NET_I40E
10230 memset(®ion_conf, 0, sizeof(region_conf));
10232 if (strcmp(res->what, "on") == 0)
10233 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10235 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10237 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10238 op_type, ®ion_conf);
10245 fprintf(stderr, "function not implemented or supported\n");
10248 fprintf(stderr, "queue region config flush error: (%s)\n",
10253 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10254 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10256 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10257 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10259 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10260 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10261 port_id, RTE_UINT16);
10262 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10263 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10264 cmd, "queue-region");
10265 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10266 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10268 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10269 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10272 cmdline_parse_inst_t cmd_flush_queue_region = {
10273 .f = cmd_flush_queue_region_parsed,
10275 .help_str = "set port <port_id> queue-region flush on|off"
10276 ": flush all queue region related configuration",
10278 (void *)&cmd_flush_queue_region_set,
10279 (void *)&cmd_flush_queue_region_port,
10280 (void *)&cmd_flush_queue_region_port_index,
10281 (void *)&cmd_flush_queue_region_cmd,
10282 (void *)&cmd_flush_queue_region_flush,
10283 (void *)&cmd_flush_queue_region_what,
10288 /* *** get all queue region related configuration info *** */
10289 struct cmd_show_queue_region_info {
10290 cmdline_fixed_string_t show;
10291 cmdline_fixed_string_t port;
10293 cmdline_fixed_string_t cmd;
10297 cmd_show_queue_region_info_parsed(void *parsed_result,
10298 __rte_unused struct cmdline *cl,
10299 __rte_unused void *data)
10301 struct cmd_show_queue_region_info *res = parsed_result;
10302 int ret = -ENOTSUP;
10303 #ifdef RTE_NET_I40E
10304 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10305 enum rte_pmd_i40e_queue_region_op op_type;
10308 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10311 #ifdef RTE_NET_I40E
10312 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10314 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10316 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10317 op_type, &rte_pmd_regions);
10319 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10326 fprintf(stderr, "function not implemented or supported\n");
10329 fprintf(stderr, "queue region config info show error: (%s)\n",
10334 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10335 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10337 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10338 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10340 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10341 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10342 port_id, RTE_UINT16);
10343 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10344 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10345 cmd, "queue-region");
10347 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10348 .f = cmd_show_queue_region_info_parsed,
10350 .help_str = "show port <port_id> queue-region"
10351 ": show all queue region related configuration info",
10353 (void *)&cmd_show_queue_region_info_get,
10354 (void *)&cmd_show_queue_region_info_port,
10355 (void *)&cmd_show_queue_region_info_port_index,
10356 (void *)&cmd_show_queue_region_info_cmd,
10361 /* *** Filters Control *** */
10363 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10365 if ((ip_addr).family == AF_INET) \
10366 (ip) = (ip_addr).addr.ipv4.s_addr; \
10368 fprintf(stderr, "invalid parameter.\n"); \
10373 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10375 if ((ip_addr).family == AF_INET6) \
10376 rte_memcpy(&(ip), \
10377 &((ip_addr).addr.ipv6), \
10378 sizeof(struct in6_addr)); \
10380 fprintf(stderr, "invalid parameter.\n"); \
10385 #ifdef RTE_NET_I40E
10388 str2flowtype(char *string)
10391 static const struct {
10394 } flowtype_str[] = {
10395 {"raw", RTE_ETH_FLOW_RAW},
10396 {"ipv4", RTE_ETH_FLOW_IPV4},
10397 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10398 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10399 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10400 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10401 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10402 {"ipv6", RTE_ETH_FLOW_IPV6},
10403 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10404 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10405 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10406 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10407 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10408 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10411 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10412 if (!strcmp(flowtype_str[i].str, string))
10413 return flowtype_str[i].type;
10416 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10417 return (uint16_t)atoi(string);
10419 return RTE_ETH_FLOW_UNKNOWN;
10422 /* *** deal with flow director filter *** */
10423 struct cmd_flow_director_result {
10424 cmdline_fixed_string_t flow_director_filter;
10426 cmdline_fixed_string_t mode;
10427 cmdline_fixed_string_t mode_value;
10428 cmdline_fixed_string_t ops;
10429 cmdline_fixed_string_t flow;
10430 cmdline_fixed_string_t flow_type;
10431 cmdline_fixed_string_t drop;
10432 cmdline_fixed_string_t queue;
10434 cmdline_fixed_string_t fd_id;
10435 uint32_t fd_id_value;
10436 cmdline_fixed_string_t packet;
10441 cmd_flow_director_filter_parsed(void *parsed_result,
10442 __rte_unused struct cmdline *cl,
10443 __rte_unused void *data)
10445 struct cmd_flow_director_result *res = parsed_result;
10447 struct rte_pmd_i40e_flow_type_mapping
10448 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10449 struct rte_pmd_i40e_pkt_template_conf conf;
10450 uint16_t flow_type = str2flowtype(res->flow_type);
10451 uint16_t i, port = res->port_id;
10454 memset(&conf, 0, sizeof(conf));
10456 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10457 fprintf(stderr, "Invalid flow type specified.\n");
10460 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10464 if (mapping[flow_type].pctype == 0ULL) {
10465 fprintf(stderr, "Invalid flow type specified.\n");
10468 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10469 if (mapping[flow_type].pctype & (1ULL << i)) {
10470 conf.input.pctype = i;
10475 conf.input.packet = open_file(res->filepath,
10476 &conf.input.length);
10477 if (!conf.input.packet)
10479 if (!strcmp(res->drop, "drop"))
10480 conf.action.behavior =
10481 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10483 conf.action.behavior =
10484 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10485 conf.action.report_status =
10486 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10487 conf.action.rx_queue = res->queue_id;
10488 conf.soft_id = res->fd_id_value;
10489 add = strcmp(res->ops, "del") ? 1 : 0;
10490 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10494 fprintf(stderr, "flow director config error: (%s)\n",
10496 close_file(conf.input.packet);
10499 cmdline_parse_token_string_t cmd_flow_director_filter =
10500 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10501 flow_director_filter, "flow_director_filter");
10502 cmdline_parse_token_num_t cmd_flow_director_port_id =
10503 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10504 port_id, RTE_UINT16);
10505 cmdline_parse_token_string_t cmd_flow_director_ops =
10506 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10507 ops, "add#del#update");
10508 cmdline_parse_token_string_t cmd_flow_director_flow =
10509 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10511 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10512 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10514 cmdline_parse_token_string_t cmd_flow_director_drop =
10515 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10517 cmdline_parse_token_string_t cmd_flow_director_queue =
10518 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10520 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10521 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10522 queue_id, RTE_UINT16);
10523 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10524 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10526 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10527 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10528 fd_id_value, RTE_UINT32);
10530 cmdline_parse_token_string_t cmd_flow_director_mode =
10531 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10533 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10534 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10535 mode_value, "raw");
10536 cmdline_parse_token_string_t cmd_flow_director_packet =
10537 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10539 cmdline_parse_token_string_t cmd_flow_director_filepath =
10540 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10543 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10544 .f = cmd_flow_director_filter_parsed,
10546 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10547 "director entry on NIC",
10549 (void *)&cmd_flow_director_filter,
10550 (void *)&cmd_flow_director_port_id,
10551 (void *)&cmd_flow_director_mode,
10552 (void *)&cmd_flow_director_mode_raw,
10553 (void *)&cmd_flow_director_ops,
10554 (void *)&cmd_flow_director_flow,
10555 (void *)&cmd_flow_director_flow_type,
10556 (void *)&cmd_flow_director_drop,
10557 (void *)&cmd_flow_director_queue,
10558 (void *)&cmd_flow_director_queue_id,
10559 (void *)&cmd_flow_director_fd_id,
10560 (void *)&cmd_flow_director_fd_id_value,
10561 (void *)&cmd_flow_director_packet,
10562 (void *)&cmd_flow_director_filepath,
10567 #endif /* RTE_NET_I40E */
10569 /* *** deal with flow director mask *** */
10570 struct cmd_flow_director_mask_result {
10571 cmdline_fixed_string_t flow_director_mask;
10573 cmdline_fixed_string_t mode;
10574 cmdline_fixed_string_t mode_value;
10575 cmdline_fixed_string_t vlan;
10576 uint16_t vlan_mask;
10577 cmdline_fixed_string_t src_mask;
10578 cmdline_ipaddr_t ipv4_src;
10579 cmdline_ipaddr_t ipv6_src;
10581 cmdline_fixed_string_t dst_mask;
10582 cmdline_ipaddr_t ipv4_dst;
10583 cmdline_ipaddr_t ipv6_dst;
10585 cmdline_fixed_string_t mac;
10586 uint8_t mac_addr_byte_mask;
10587 cmdline_fixed_string_t tunnel_id;
10588 uint32_t tunnel_id_mask;
10589 cmdline_fixed_string_t tunnel_type;
10590 uint8_t tunnel_type_mask;
10594 cmd_flow_director_mask_parsed(void *parsed_result,
10595 __rte_unused struct cmdline *cl,
10596 __rte_unused void *data)
10598 struct cmd_flow_director_mask_result *res = parsed_result;
10599 struct rte_eth_fdir_masks *mask;
10600 struct rte_port *port;
10602 port = &ports[res->port_id];
10603 /** Check if the port is not started **/
10604 if (port->port_status != RTE_PORT_STOPPED) {
10605 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10609 mask = &port->dev_conf.fdir_conf.mask;
10611 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10612 if (strcmp(res->mode_value, "MAC-VLAN")) {
10613 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10617 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10618 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10619 if (strcmp(res->mode_value, "Tunnel")) {
10620 fprintf(stderr, "Please set mode to Tunnel.\n");
10624 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10625 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10626 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10627 mask->tunnel_type_mask = res->tunnel_type_mask;
10629 if (strcmp(res->mode_value, "IP")) {
10630 fprintf(stderr, "Please set mode to IP.\n");
10634 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10635 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10636 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10637 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10638 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10639 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10640 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10643 cmd_reconfig_device_queue(res->port_id, 1, 1);
10646 cmdline_parse_token_string_t cmd_flow_director_mask =
10647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10648 flow_director_mask, "flow_director_mask");
10649 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10650 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10651 port_id, RTE_UINT16);
10652 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10655 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10656 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10657 vlan_mask, RTE_UINT16);
10658 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10659 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10660 src_mask, "src_mask");
10661 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10662 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10664 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10665 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10667 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10668 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10669 port_src, RTE_UINT16);
10670 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10671 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10672 dst_mask, "dst_mask");
10673 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10674 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10676 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10677 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10679 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10680 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10681 port_dst, RTE_UINT16);
10683 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10686 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10687 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10689 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10691 mode_value, "MAC-VLAN");
10692 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10693 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10694 mode_value, "Tunnel");
10695 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10696 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10698 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10699 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10700 mac_addr_byte_mask, RTE_UINT8);
10701 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10702 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10703 tunnel_type, "tunnel-type");
10704 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10705 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10706 tunnel_type_mask, RTE_UINT8);
10707 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10709 tunnel_id, "tunnel-id");
10710 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10711 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10712 tunnel_id_mask, RTE_UINT32);
10714 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10715 .f = cmd_flow_director_mask_parsed,
10717 .help_str = "flow_director_mask ... : "
10718 "Set IP mode flow director's mask on NIC",
10720 (void *)&cmd_flow_director_mask,
10721 (void *)&cmd_flow_director_mask_port_id,
10722 (void *)&cmd_flow_director_mask_mode,
10723 (void *)&cmd_flow_director_mask_mode_ip,
10724 (void *)&cmd_flow_director_mask_vlan,
10725 (void *)&cmd_flow_director_mask_vlan_value,
10726 (void *)&cmd_flow_director_mask_src,
10727 (void *)&cmd_flow_director_mask_ipv4_src,
10728 (void *)&cmd_flow_director_mask_ipv6_src,
10729 (void *)&cmd_flow_director_mask_port_src,
10730 (void *)&cmd_flow_director_mask_dst,
10731 (void *)&cmd_flow_director_mask_ipv4_dst,
10732 (void *)&cmd_flow_director_mask_ipv6_dst,
10733 (void *)&cmd_flow_director_mask_port_dst,
10738 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10739 .f = cmd_flow_director_mask_parsed,
10741 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10742 "flow director's mask on NIC",
10744 (void *)&cmd_flow_director_mask,
10745 (void *)&cmd_flow_director_mask_port_id,
10746 (void *)&cmd_flow_director_mask_mode,
10747 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10748 (void *)&cmd_flow_director_mask_vlan,
10749 (void *)&cmd_flow_director_mask_vlan_value,
10754 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10755 .f = cmd_flow_director_mask_parsed,
10757 .help_str = "flow_director_mask ... : Set tunnel mode "
10758 "flow director's mask on NIC",
10760 (void *)&cmd_flow_director_mask,
10761 (void *)&cmd_flow_director_mask_port_id,
10762 (void *)&cmd_flow_director_mask_mode,
10763 (void *)&cmd_flow_director_mask_mode_tunnel,
10764 (void *)&cmd_flow_director_mask_vlan,
10765 (void *)&cmd_flow_director_mask_vlan_value,
10766 (void *)&cmd_flow_director_mask_mac,
10767 (void *)&cmd_flow_director_mask_mac_value,
10768 (void *)&cmd_flow_director_mask_tunnel_type,
10769 (void *)&cmd_flow_director_mask_tunnel_type_value,
10770 (void *)&cmd_flow_director_mask_tunnel_id,
10771 (void *)&cmd_flow_director_mask_tunnel_id_value,
10776 /* *** deal with flow director flexible payload configuration *** */
10777 struct cmd_flow_director_flexpayload_result {
10778 cmdline_fixed_string_t flow_director_flexpayload;
10780 cmdline_fixed_string_t payload_layer;
10781 cmdline_fixed_string_t payload_cfg;
10785 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10788 const char *p, *p0 = q_arg;
10790 unsigned long int_fld;
10791 char *str_fld[max_num];
10796 p = strchr(p0, '(');
10800 p0 = strchr(p, ')');
10805 if (size >= sizeof(s))
10808 snprintf(s, sizeof(s), "%.*s", size, p);
10809 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10810 if (ret < 0 || ret > max_num)
10812 for (i = 0; i < ret; i++) {
10814 int_fld = strtoul(str_fld[i], &end, 0);
10815 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10817 offsets[i] = (uint16_t)int_fld;
10823 cmd_flow_director_flxpld_parsed(void *parsed_result,
10824 __rte_unused struct cmdline *cl,
10825 __rte_unused void *data)
10827 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10828 struct rte_eth_flex_payload_cfg flex_cfg;
10829 struct rte_port *port;
10832 port = &ports[res->port_id];
10833 /** Check if the port is not started **/
10834 if (port->port_status != RTE_PORT_STOPPED) {
10835 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10839 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10841 if (!strcmp(res->payload_layer, "raw"))
10842 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10843 else if (!strcmp(res->payload_layer, "l2"))
10844 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10845 else if (!strcmp(res->payload_layer, "l3"))
10846 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10847 else if (!strcmp(res->payload_layer, "l4"))
10848 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10850 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10851 RTE_ETH_FDIR_MAX_FLEXLEN);
10853 fprintf(stderr, "error: Cannot parse flex payload input.\n");
10857 fdir_set_flex_payload(res->port_id, &flex_cfg);
10858 cmd_reconfig_device_queue(res->port_id, 1, 1);
10861 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10863 flow_director_flexpayload,
10864 "flow_director_flex_payload");
10865 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10866 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10867 port_id, RTE_UINT16);
10868 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10870 payload_layer, "raw#l2#l3#l4");
10871 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10873 payload_cfg, NULL);
10875 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10876 .f = cmd_flow_director_flxpld_parsed,
10878 .help_str = "flow_director_flexpayload ... : "
10879 "Set flow director's flex payload on NIC",
10881 (void *)&cmd_flow_director_flexpayload,
10882 (void *)&cmd_flow_director_flexpayload_port_id,
10883 (void *)&cmd_flow_director_flexpayload_payload_layer,
10884 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10889 /* Generic flow interface command. */
10890 extern cmdline_parse_inst_t cmd_flow;
10892 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10893 struct cmd_mcast_addr_result {
10894 cmdline_fixed_string_t mcast_addr_cmd;
10895 cmdline_fixed_string_t what;
10897 struct rte_ether_addr mc_addr;
10900 static void cmd_mcast_addr_parsed(void *parsed_result,
10901 __rte_unused struct cmdline *cl,
10902 __rte_unused void *data)
10904 struct cmd_mcast_addr_result *res = parsed_result;
10906 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10908 "Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10909 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10910 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10911 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10914 if (strcmp(res->what, "add") == 0)
10915 mcast_addr_add(res->port_num, &res->mc_addr);
10917 mcast_addr_remove(res->port_num, &res->mc_addr);
10920 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10921 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10922 mcast_addr_cmd, "mcast_addr");
10923 cmdline_parse_token_string_t cmd_mcast_addr_what =
10924 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10926 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10927 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10929 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10930 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10932 cmdline_parse_inst_t cmd_mcast_addr = {
10933 .f = cmd_mcast_addr_parsed,
10935 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10936 "Add/Remove multicast MAC address on port_id",
10938 (void *)&cmd_mcast_addr_cmd,
10939 (void *)&cmd_mcast_addr_what,
10940 (void *)&cmd_mcast_addr_portnum,
10941 (void *)&cmd_mcast_addr_addr,
10946 /* vf vlan anti spoof configuration */
10948 /* Common result structure for vf vlan anti spoof */
10949 struct cmd_vf_vlan_anti_spoof_result {
10950 cmdline_fixed_string_t set;
10951 cmdline_fixed_string_t vf;
10952 cmdline_fixed_string_t vlan;
10953 cmdline_fixed_string_t antispoof;
10956 cmdline_fixed_string_t on_off;
10959 /* Common CLI fields for vf vlan anti spoof enable disable */
10960 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10961 TOKEN_STRING_INITIALIZER
10962 (struct cmd_vf_vlan_anti_spoof_result,
10964 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10965 TOKEN_STRING_INITIALIZER
10966 (struct cmd_vf_vlan_anti_spoof_result,
10968 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10969 TOKEN_STRING_INITIALIZER
10970 (struct cmd_vf_vlan_anti_spoof_result,
10972 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10973 TOKEN_STRING_INITIALIZER
10974 (struct cmd_vf_vlan_anti_spoof_result,
10975 antispoof, "antispoof");
10976 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10977 TOKEN_NUM_INITIALIZER
10978 (struct cmd_vf_vlan_anti_spoof_result,
10979 port_id, RTE_UINT16);
10980 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10981 TOKEN_NUM_INITIALIZER
10982 (struct cmd_vf_vlan_anti_spoof_result,
10983 vf_id, RTE_UINT32);
10984 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10985 TOKEN_STRING_INITIALIZER
10986 (struct cmd_vf_vlan_anti_spoof_result,
10990 cmd_set_vf_vlan_anti_spoof_parsed(
10991 void *parsed_result,
10992 __rte_unused struct cmdline *cl,
10993 __rte_unused void *data)
10995 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10996 int ret = -ENOTSUP;
10998 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11003 #ifdef RTE_NET_IXGBE
11004 if (ret == -ENOTSUP)
11005 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11006 res->vf_id, is_on);
11008 #ifdef RTE_NET_I40E
11009 if (ret == -ENOTSUP)
11010 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11011 res->vf_id, is_on);
11013 #ifdef RTE_NET_BNXT
11014 if (ret == -ENOTSUP)
11015 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11016 res->vf_id, is_on);
11023 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11026 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11029 fprintf(stderr, "function not implemented\n");
11032 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11036 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11037 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11039 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11041 (void *)&cmd_vf_vlan_anti_spoof_set,
11042 (void *)&cmd_vf_vlan_anti_spoof_vf,
11043 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11044 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11045 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11046 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11047 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11052 /* vf mac anti spoof configuration */
11054 /* Common result structure for vf mac anti spoof */
11055 struct cmd_vf_mac_anti_spoof_result {
11056 cmdline_fixed_string_t set;
11057 cmdline_fixed_string_t vf;
11058 cmdline_fixed_string_t mac;
11059 cmdline_fixed_string_t antispoof;
11062 cmdline_fixed_string_t on_off;
11065 /* Common CLI fields for vf mac anti spoof enable disable */
11066 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11067 TOKEN_STRING_INITIALIZER
11068 (struct cmd_vf_mac_anti_spoof_result,
11070 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11071 TOKEN_STRING_INITIALIZER
11072 (struct cmd_vf_mac_anti_spoof_result,
11074 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11075 TOKEN_STRING_INITIALIZER
11076 (struct cmd_vf_mac_anti_spoof_result,
11078 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11079 TOKEN_STRING_INITIALIZER
11080 (struct cmd_vf_mac_anti_spoof_result,
11081 antispoof, "antispoof");
11082 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11083 TOKEN_NUM_INITIALIZER
11084 (struct cmd_vf_mac_anti_spoof_result,
11085 port_id, RTE_UINT16);
11086 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11087 TOKEN_NUM_INITIALIZER
11088 (struct cmd_vf_mac_anti_spoof_result,
11089 vf_id, RTE_UINT32);
11090 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11091 TOKEN_STRING_INITIALIZER
11092 (struct cmd_vf_mac_anti_spoof_result,
11096 cmd_set_vf_mac_anti_spoof_parsed(
11097 void *parsed_result,
11098 __rte_unused struct cmdline *cl,
11099 __rte_unused void *data)
11101 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11102 int ret = -ENOTSUP;
11104 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11106 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11109 #ifdef RTE_NET_IXGBE
11110 if (ret == -ENOTSUP)
11111 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11112 res->vf_id, is_on);
11114 #ifdef RTE_NET_I40E
11115 if (ret == -ENOTSUP)
11116 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11117 res->vf_id, is_on);
11119 #ifdef RTE_NET_BNXT
11120 if (ret == -ENOTSUP)
11121 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11122 res->vf_id, is_on);
11129 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11130 res->vf_id, is_on);
11133 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11136 fprintf(stderr, "function not implemented\n");
11139 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11143 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11144 .f = cmd_set_vf_mac_anti_spoof_parsed,
11146 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11148 (void *)&cmd_vf_mac_anti_spoof_set,
11149 (void *)&cmd_vf_mac_anti_spoof_vf,
11150 (void *)&cmd_vf_mac_anti_spoof_mac,
11151 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11152 (void *)&cmd_vf_mac_anti_spoof_port_id,
11153 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11154 (void *)&cmd_vf_mac_anti_spoof_on_off,
11159 /* vf vlan strip queue configuration */
11161 /* Common result structure for vf mac anti spoof */
11162 struct cmd_vf_vlan_stripq_result {
11163 cmdline_fixed_string_t set;
11164 cmdline_fixed_string_t vf;
11165 cmdline_fixed_string_t vlan;
11166 cmdline_fixed_string_t stripq;
11169 cmdline_fixed_string_t on_off;
11172 /* Common CLI fields for vf vlan strip enable disable */
11173 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11174 TOKEN_STRING_INITIALIZER
11175 (struct cmd_vf_vlan_stripq_result,
11177 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11178 TOKEN_STRING_INITIALIZER
11179 (struct cmd_vf_vlan_stripq_result,
11181 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11182 TOKEN_STRING_INITIALIZER
11183 (struct cmd_vf_vlan_stripq_result,
11185 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11186 TOKEN_STRING_INITIALIZER
11187 (struct cmd_vf_vlan_stripq_result,
11189 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11190 TOKEN_NUM_INITIALIZER
11191 (struct cmd_vf_vlan_stripq_result,
11192 port_id, RTE_UINT16);
11193 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11194 TOKEN_NUM_INITIALIZER
11195 (struct cmd_vf_vlan_stripq_result,
11196 vf_id, RTE_UINT16);
11197 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11198 TOKEN_STRING_INITIALIZER
11199 (struct cmd_vf_vlan_stripq_result,
11203 cmd_set_vf_vlan_stripq_parsed(
11204 void *parsed_result,
11205 __rte_unused struct cmdline *cl,
11206 __rte_unused void *data)
11208 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11209 int ret = -ENOTSUP;
11211 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11213 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11216 #ifdef RTE_NET_IXGBE
11217 if (ret == -ENOTSUP)
11218 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11219 res->vf_id, is_on);
11221 #ifdef RTE_NET_I40E
11222 if (ret == -ENOTSUP)
11223 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11224 res->vf_id, is_on);
11226 #ifdef RTE_NET_BNXT
11227 if (ret == -ENOTSUP)
11228 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11229 res->vf_id, is_on);
11236 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11237 res->vf_id, is_on);
11240 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11243 fprintf(stderr, "function not implemented\n");
11246 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11250 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11251 .f = cmd_set_vf_vlan_stripq_parsed,
11253 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11255 (void *)&cmd_vf_vlan_stripq_set,
11256 (void *)&cmd_vf_vlan_stripq_vf,
11257 (void *)&cmd_vf_vlan_stripq_vlan,
11258 (void *)&cmd_vf_vlan_stripq_stripq,
11259 (void *)&cmd_vf_vlan_stripq_port_id,
11260 (void *)&cmd_vf_vlan_stripq_vf_id,
11261 (void *)&cmd_vf_vlan_stripq_on_off,
11266 /* vf vlan insert configuration */
11268 /* Common result structure for vf vlan insert */
11269 struct cmd_vf_vlan_insert_result {
11270 cmdline_fixed_string_t set;
11271 cmdline_fixed_string_t vf;
11272 cmdline_fixed_string_t vlan;
11273 cmdline_fixed_string_t insert;
11279 /* Common CLI fields for vf vlan insert enable disable */
11280 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11281 TOKEN_STRING_INITIALIZER
11282 (struct cmd_vf_vlan_insert_result,
11284 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11285 TOKEN_STRING_INITIALIZER
11286 (struct cmd_vf_vlan_insert_result,
11288 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11289 TOKEN_STRING_INITIALIZER
11290 (struct cmd_vf_vlan_insert_result,
11292 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11293 TOKEN_STRING_INITIALIZER
11294 (struct cmd_vf_vlan_insert_result,
11296 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11297 TOKEN_NUM_INITIALIZER
11298 (struct cmd_vf_vlan_insert_result,
11299 port_id, RTE_UINT16);
11300 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11301 TOKEN_NUM_INITIALIZER
11302 (struct cmd_vf_vlan_insert_result,
11303 vf_id, RTE_UINT16);
11304 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11305 TOKEN_NUM_INITIALIZER
11306 (struct cmd_vf_vlan_insert_result,
11307 vlan_id, RTE_UINT16);
11310 cmd_set_vf_vlan_insert_parsed(
11311 void *parsed_result,
11312 __rte_unused struct cmdline *cl,
11313 __rte_unused void *data)
11315 struct cmd_vf_vlan_insert_result *res = parsed_result;
11316 int ret = -ENOTSUP;
11318 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11321 #ifdef RTE_NET_IXGBE
11322 if (ret == -ENOTSUP)
11323 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11326 #ifdef RTE_NET_I40E
11327 if (ret == -ENOTSUP)
11328 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11331 #ifdef RTE_NET_BNXT
11332 if (ret == -ENOTSUP)
11333 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11341 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11342 res->vf_id, res->vlan_id);
11345 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11348 fprintf(stderr, "function not implemented\n");
11351 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11355 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11356 .f = cmd_set_vf_vlan_insert_parsed,
11358 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11360 (void *)&cmd_vf_vlan_insert_set,
11361 (void *)&cmd_vf_vlan_insert_vf,
11362 (void *)&cmd_vf_vlan_insert_vlan,
11363 (void *)&cmd_vf_vlan_insert_insert,
11364 (void *)&cmd_vf_vlan_insert_port_id,
11365 (void *)&cmd_vf_vlan_insert_vf_id,
11366 (void *)&cmd_vf_vlan_insert_vlan_id,
11371 /* tx loopback configuration */
11373 /* Common result structure for tx loopback */
11374 struct cmd_tx_loopback_result {
11375 cmdline_fixed_string_t set;
11376 cmdline_fixed_string_t tx;
11377 cmdline_fixed_string_t loopback;
11379 cmdline_fixed_string_t on_off;
11382 /* Common CLI fields for tx loopback enable disable */
11383 cmdline_parse_token_string_t cmd_tx_loopback_set =
11384 TOKEN_STRING_INITIALIZER
11385 (struct cmd_tx_loopback_result,
11387 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11388 TOKEN_STRING_INITIALIZER
11389 (struct cmd_tx_loopback_result,
11391 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11392 TOKEN_STRING_INITIALIZER
11393 (struct cmd_tx_loopback_result,
11394 loopback, "loopback");
11395 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11396 TOKEN_NUM_INITIALIZER
11397 (struct cmd_tx_loopback_result,
11398 port_id, RTE_UINT16);
11399 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11400 TOKEN_STRING_INITIALIZER
11401 (struct cmd_tx_loopback_result,
11405 cmd_set_tx_loopback_parsed(
11406 void *parsed_result,
11407 __rte_unused struct cmdline *cl,
11408 __rte_unused void *data)
11410 struct cmd_tx_loopback_result *res = parsed_result;
11411 int ret = -ENOTSUP;
11413 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11415 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11418 #ifdef RTE_NET_IXGBE
11419 if (ret == -ENOTSUP)
11420 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11422 #ifdef RTE_NET_I40E
11423 if (ret == -ENOTSUP)
11424 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11426 #ifdef RTE_NET_BNXT
11427 if (ret == -ENOTSUP)
11428 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11430 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11431 if (ret == -ENOTSUP)
11432 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11439 fprintf(stderr, "invalid is_on %d\n", is_on);
11442 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11445 fprintf(stderr, "function not implemented\n");
11448 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11452 cmdline_parse_inst_t cmd_set_tx_loopback = {
11453 .f = cmd_set_tx_loopback_parsed,
11455 .help_str = "set tx loopback <port_id> on|off",
11457 (void *)&cmd_tx_loopback_set,
11458 (void *)&cmd_tx_loopback_tx,
11459 (void *)&cmd_tx_loopback_loopback,
11460 (void *)&cmd_tx_loopback_port_id,
11461 (void *)&cmd_tx_loopback_on_off,
11466 /* all queues drop enable configuration */
11468 /* Common result structure for all queues drop enable */
11469 struct cmd_all_queues_drop_en_result {
11470 cmdline_fixed_string_t set;
11471 cmdline_fixed_string_t all;
11472 cmdline_fixed_string_t queues;
11473 cmdline_fixed_string_t drop;
11475 cmdline_fixed_string_t on_off;
11478 /* Common CLI fields for tx loopback enable disable */
11479 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11480 TOKEN_STRING_INITIALIZER
11481 (struct cmd_all_queues_drop_en_result,
11483 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11484 TOKEN_STRING_INITIALIZER
11485 (struct cmd_all_queues_drop_en_result,
11487 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11488 TOKEN_STRING_INITIALIZER
11489 (struct cmd_all_queues_drop_en_result,
11491 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11492 TOKEN_STRING_INITIALIZER
11493 (struct cmd_all_queues_drop_en_result,
11495 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11496 TOKEN_NUM_INITIALIZER
11497 (struct cmd_all_queues_drop_en_result,
11498 port_id, RTE_UINT16);
11499 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11500 TOKEN_STRING_INITIALIZER
11501 (struct cmd_all_queues_drop_en_result,
11505 cmd_set_all_queues_drop_en_parsed(
11506 void *parsed_result,
11507 __rte_unused struct cmdline *cl,
11508 __rte_unused void *data)
11510 struct cmd_all_queues_drop_en_result *res = parsed_result;
11511 int ret = -ENOTSUP;
11512 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11514 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11517 #ifdef RTE_NET_IXGBE
11518 if (ret == -ENOTSUP)
11519 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11521 #ifdef RTE_NET_BNXT
11522 if (ret == -ENOTSUP)
11523 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11529 fprintf(stderr, "invalid is_on %d\n", is_on);
11532 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11535 fprintf(stderr, "function not implemented\n");
11538 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11542 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11543 .f = cmd_set_all_queues_drop_en_parsed,
11545 .help_str = "set all queues drop <port_id> on|off",
11547 (void *)&cmd_all_queues_drop_en_set,
11548 (void *)&cmd_all_queues_drop_en_all,
11549 (void *)&cmd_all_queues_drop_en_queues,
11550 (void *)&cmd_all_queues_drop_en_drop,
11551 (void *)&cmd_all_queues_drop_en_port_id,
11552 (void *)&cmd_all_queues_drop_en_on_off,
11557 /* vf split drop enable configuration */
11559 /* Common result structure for vf split drop enable */
11560 struct cmd_vf_split_drop_en_result {
11561 cmdline_fixed_string_t set;
11562 cmdline_fixed_string_t vf;
11563 cmdline_fixed_string_t split;
11564 cmdline_fixed_string_t drop;
11567 cmdline_fixed_string_t on_off;
11570 /* Common CLI fields for vf split drop enable disable */
11571 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11572 TOKEN_STRING_INITIALIZER
11573 (struct cmd_vf_split_drop_en_result,
11575 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11576 TOKEN_STRING_INITIALIZER
11577 (struct cmd_vf_split_drop_en_result,
11579 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11580 TOKEN_STRING_INITIALIZER
11581 (struct cmd_vf_split_drop_en_result,
11583 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11584 TOKEN_STRING_INITIALIZER
11585 (struct cmd_vf_split_drop_en_result,
11587 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11588 TOKEN_NUM_INITIALIZER
11589 (struct cmd_vf_split_drop_en_result,
11590 port_id, RTE_UINT16);
11591 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11592 TOKEN_NUM_INITIALIZER
11593 (struct cmd_vf_split_drop_en_result,
11594 vf_id, RTE_UINT16);
11595 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11596 TOKEN_STRING_INITIALIZER
11597 (struct cmd_vf_split_drop_en_result,
11601 cmd_set_vf_split_drop_en_parsed(
11602 void *parsed_result,
11603 __rte_unused struct cmdline *cl,
11604 __rte_unused void *data)
11606 struct cmd_vf_split_drop_en_result *res = parsed_result;
11607 int ret = -ENOTSUP;
11608 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11610 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11613 #ifdef RTE_NET_IXGBE
11614 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11621 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11622 res->vf_id, is_on);
11625 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11628 fprintf(stderr, "not supported on port %d\n", res->port_id);
11631 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11635 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11636 .f = cmd_set_vf_split_drop_en_parsed,
11638 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11640 (void *)&cmd_vf_split_drop_en_set,
11641 (void *)&cmd_vf_split_drop_en_vf,
11642 (void *)&cmd_vf_split_drop_en_split,
11643 (void *)&cmd_vf_split_drop_en_drop,
11644 (void *)&cmd_vf_split_drop_en_port_id,
11645 (void *)&cmd_vf_split_drop_en_vf_id,
11646 (void *)&cmd_vf_split_drop_en_on_off,
11651 /* vf mac address configuration */
11653 /* Common result structure for vf mac address */
11654 struct cmd_set_vf_mac_addr_result {
11655 cmdline_fixed_string_t set;
11656 cmdline_fixed_string_t vf;
11657 cmdline_fixed_string_t mac;
11658 cmdline_fixed_string_t addr;
11661 struct rte_ether_addr mac_addr;
11665 /* Common CLI fields for vf split drop enable disable */
11666 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11667 TOKEN_STRING_INITIALIZER
11668 (struct cmd_set_vf_mac_addr_result,
11670 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11671 TOKEN_STRING_INITIALIZER
11672 (struct cmd_set_vf_mac_addr_result,
11674 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11675 TOKEN_STRING_INITIALIZER
11676 (struct cmd_set_vf_mac_addr_result,
11678 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11679 TOKEN_STRING_INITIALIZER
11680 (struct cmd_set_vf_mac_addr_result,
11682 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11683 TOKEN_NUM_INITIALIZER
11684 (struct cmd_set_vf_mac_addr_result,
11685 port_id, RTE_UINT16);
11686 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11687 TOKEN_NUM_INITIALIZER
11688 (struct cmd_set_vf_mac_addr_result,
11689 vf_id, RTE_UINT16);
11690 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11691 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11695 cmd_set_vf_mac_addr_parsed(
11696 void *parsed_result,
11697 __rte_unused struct cmdline *cl,
11698 __rte_unused void *data)
11700 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11701 int ret = -ENOTSUP;
11703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11706 #ifdef RTE_NET_IXGBE
11707 if (ret == -ENOTSUP)
11708 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11711 #ifdef RTE_NET_I40E
11712 if (ret == -ENOTSUP)
11713 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11716 #ifdef RTE_NET_BNXT
11717 if (ret == -ENOTSUP)
11718 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11726 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11729 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11732 fprintf(stderr, "function not implemented\n");
11735 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11739 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11740 .f = cmd_set_vf_mac_addr_parsed,
11742 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11744 (void *)&cmd_set_vf_mac_addr_set,
11745 (void *)&cmd_set_vf_mac_addr_vf,
11746 (void *)&cmd_set_vf_mac_addr_mac,
11747 (void *)&cmd_set_vf_mac_addr_addr,
11748 (void *)&cmd_set_vf_mac_addr_port_id,
11749 (void *)&cmd_set_vf_mac_addr_vf_id,
11750 (void *)&cmd_set_vf_mac_addr_mac_addr,
11755 /* MACsec configuration */
11757 /* Common result structure for MACsec offload enable */
11758 struct cmd_macsec_offload_on_result {
11759 cmdline_fixed_string_t set;
11760 cmdline_fixed_string_t macsec;
11761 cmdline_fixed_string_t offload;
11763 cmdline_fixed_string_t on;
11764 cmdline_fixed_string_t encrypt;
11765 cmdline_fixed_string_t en_on_off;
11766 cmdline_fixed_string_t replay_protect;
11767 cmdline_fixed_string_t rp_on_off;
11770 /* Common CLI fields for MACsec offload disable */
11771 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11772 TOKEN_STRING_INITIALIZER
11773 (struct cmd_macsec_offload_on_result,
11775 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11776 TOKEN_STRING_INITIALIZER
11777 (struct cmd_macsec_offload_on_result,
11779 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11780 TOKEN_STRING_INITIALIZER
11781 (struct cmd_macsec_offload_on_result,
11782 offload, "offload");
11783 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11784 TOKEN_NUM_INITIALIZER
11785 (struct cmd_macsec_offload_on_result,
11786 port_id, RTE_UINT16);
11787 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11788 TOKEN_STRING_INITIALIZER
11789 (struct cmd_macsec_offload_on_result,
11791 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11792 TOKEN_STRING_INITIALIZER
11793 (struct cmd_macsec_offload_on_result,
11794 encrypt, "encrypt");
11795 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11796 TOKEN_STRING_INITIALIZER
11797 (struct cmd_macsec_offload_on_result,
11798 en_on_off, "on#off");
11799 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11800 TOKEN_STRING_INITIALIZER
11801 (struct cmd_macsec_offload_on_result,
11802 replay_protect, "replay-protect");
11803 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11804 TOKEN_STRING_INITIALIZER
11805 (struct cmd_macsec_offload_on_result,
11806 rp_on_off, "on#off");
11809 cmd_set_macsec_offload_on_parsed(
11810 void *parsed_result,
11811 __rte_unused struct cmdline *cl,
11812 __rte_unused void *data)
11814 struct cmd_macsec_offload_on_result *res = parsed_result;
11815 int ret = -ENOTSUP;
11816 portid_t port_id = res->port_id;
11817 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11818 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11819 struct rte_eth_dev_info dev_info;
11821 if (port_id_is_invalid(port_id, ENABLED_WARN))
11823 if (!port_is_stopped(port_id)) {
11824 fprintf(stderr, "Please stop port %d first\n", port_id);
11828 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11832 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11833 #ifdef RTE_NET_IXGBE
11834 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11842 ports[port_id].dev_conf.txmode.offloads |=
11843 DEV_TX_OFFLOAD_MACSEC_INSERT;
11844 cmd_reconfig_device_queue(port_id, 1, 1);
11847 fprintf(stderr, "invalid port_id %d\n", port_id);
11850 fprintf(stderr, "not supported on port %d\n", port_id);
11853 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11857 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11858 .f = cmd_set_macsec_offload_on_parsed,
11860 .help_str = "set macsec offload <port_id> on "
11861 "encrypt on|off replay-protect on|off",
11863 (void *)&cmd_macsec_offload_on_set,
11864 (void *)&cmd_macsec_offload_on_macsec,
11865 (void *)&cmd_macsec_offload_on_offload,
11866 (void *)&cmd_macsec_offload_on_port_id,
11867 (void *)&cmd_macsec_offload_on_on,
11868 (void *)&cmd_macsec_offload_on_encrypt,
11869 (void *)&cmd_macsec_offload_on_en_on_off,
11870 (void *)&cmd_macsec_offload_on_replay_protect,
11871 (void *)&cmd_macsec_offload_on_rp_on_off,
11876 /* Common result structure for MACsec offload disable */
11877 struct cmd_macsec_offload_off_result {
11878 cmdline_fixed_string_t set;
11879 cmdline_fixed_string_t macsec;
11880 cmdline_fixed_string_t offload;
11882 cmdline_fixed_string_t off;
11885 /* Common CLI fields for MACsec offload disable */
11886 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11887 TOKEN_STRING_INITIALIZER
11888 (struct cmd_macsec_offload_off_result,
11890 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11891 TOKEN_STRING_INITIALIZER
11892 (struct cmd_macsec_offload_off_result,
11894 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11895 TOKEN_STRING_INITIALIZER
11896 (struct cmd_macsec_offload_off_result,
11897 offload, "offload");
11898 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11899 TOKEN_NUM_INITIALIZER
11900 (struct cmd_macsec_offload_off_result,
11901 port_id, RTE_UINT16);
11902 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11903 TOKEN_STRING_INITIALIZER
11904 (struct cmd_macsec_offload_off_result,
11908 cmd_set_macsec_offload_off_parsed(
11909 void *parsed_result,
11910 __rte_unused struct cmdline *cl,
11911 __rte_unused void *data)
11913 struct cmd_macsec_offload_off_result *res = parsed_result;
11914 int ret = -ENOTSUP;
11915 struct rte_eth_dev_info dev_info;
11916 portid_t port_id = res->port_id;
11918 if (port_id_is_invalid(port_id, ENABLED_WARN))
11920 if (!port_is_stopped(port_id)) {
11921 fprintf(stderr, "Please stop port %d first\n", port_id);
11925 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11929 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11930 #ifdef RTE_NET_IXGBE
11931 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11936 ports[port_id].dev_conf.txmode.offloads &=
11937 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11938 cmd_reconfig_device_queue(port_id, 1, 1);
11941 fprintf(stderr, "invalid port_id %d\n", port_id);
11944 fprintf(stderr, "not supported on port %d\n", port_id);
11947 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11951 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11952 .f = cmd_set_macsec_offload_off_parsed,
11954 .help_str = "set macsec offload <port_id> off",
11956 (void *)&cmd_macsec_offload_off_set,
11957 (void *)&cmd_macsec_offload_off_macsec,
11958 (void *)&cmd_macsec_offload_off_offload,
11959 (void *)&cmd_macsec_offload_off_port_id,
11960 (void *)&cmd_macsec_offload_off_off,
11965 /* Common result structure for MACsec secure connection configure */
11966 struct cmd_macsec_sc_result {
11967 cmdline_fixed_string_t set;
11968 cmdline_fixed_string_t macsec;
11969 cmdline_fixed_string_t sc;
11970 cmdline_fixed_string_t tx_rx;
11972 struct rte_ether_addr mac;
11976 /* Common CLI fields for MACsec secure connection configure */
11977 cmdline_parse_token_string_t cmd_macsec_sc_set =
11978 TOKEN_STRING_INITIALIZER
11979 (struct cmd_macsec_sc_result,
11981 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11982 TOKEN_STRING_INITIALIZER
11983 (struct cmd_macsec_sc_result,
11985 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11986 TOKEN_STRING_INITIALIZER
11987 (struct cmd_macsec_sc_result,
11989 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11990 TOKEN_STRING_INITIALIZER
11991 (struct cmd_macsec_sc_result,
11993 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11994 TOKEN_NUM_INITIALIZER
11995 (struct cmd_macsec_sc_result,
11996 port_id, RTE_UINT16);
11997 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11998 TOKEN_ETHERADDR_INITIALIZER
11999 (struct cmd_macsec_sc_result,
12001 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12002 TOKEN_NUM_INITIALIZER
12003 (struct cmd_macsec_sc_result,
12007 cmd_set_macsec_sc_parsed(
12008 void *parsed_result,
12009 __rte_unused struct cmdline *cl,
12010 __rte_unused void *data)
12012 struct cmd_macsec_sc_result *res = parsed_result;
12013 int ret = -ENOTSUP;
12014 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12016 #ifdef RTE_NET_IXGBE
12018 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12019 res->mac.addr_bytes) :
12020 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12021 res->mac.addr_bytes, res->pi);
12023 RTE_SET_USED(is_tx);
12029 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12032 fprintf(stderr, "not supported on port %d\n", res->port_id);
12035 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12039 cmdline_parse_inst_t cmd_set_macsec_sc = {
12040 .f = cmd_set_macsec_sc_parsed,
12042 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12044 (void *)&cmd_macsec_sc_set,
12045 (void *)&cmd_macsec_sc_macsec,
12046 (void *)&cmd_macsec_sc_sc,
12047 (void *)&cmd_macsec_sc_tx_rx,
12048 (void *)&cmd_macsec_sc_port_id,
12049 (void *)&cmd_macsec_sc_mac,
12050 (void *)&cmd_macsec_sc_pi,
12055 /* Common result structure for MACsec secure connection configure */
12056 struct cmd_macsec_sa_result {
12057 cmdline_fixed_string_t set;
12058 cmdline_fixed_string_t macsec;
12059 cmdline_fixed_string_t sa;
12060 cmdline_fixed_string_t tx_rx;
12065 cmdline_fixed_string_t key;
12068 /* Common CLI fields for MACsec secure connection configure */
12069 cmdline_parse_token_string_t cmd_macsec_sa_set =
12070 TOKEN_STRING_INITIALIZER
12071 (struct cmd_macsec_sa_result,
12073 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12074 TOKEN_STRING_INITIALIZER
12075 (struct cmd_macsec_sa_result,
12077 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12078 TOKEN_STRING_INITIALIZER
12079 (struct cmd_macsec_sa_result,
12081 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12082 TOKEN_STRING_INITIALIZER
12083 (struct cmd_macsec_sa_result,
12085 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12086 TOKEN_NUM_INITIALIZER
12087 (struct cmd_macsec_sa_result,
12088 port_id, RTE_UINT16);
12089 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12090 TOKEN_NUM_INITIALIZER
12091 (struct cmd_macsec_sa_result,
12093 cmdline_parse_token_num_t cmd_macsec_sa_an =
12094 TOKEN_NUM_INITIALIZER
12095 (struct cmd_macsec_sa_result,
12097 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12098 TOKEN_NUM_INITIALIZER
12099 (struct cmd_macsec_sa_result,
12101 cmdline_parse_token_string_t cmd_macsec_sa_key =
12102 TOKEN_STRING_INITIALIZER
12103 (struct cmd_macsec_sa_result,
12107 cmd_set_macsec_sa_parsed(
12108 void *parsed_result,
12109 __rte_unused struct cmdline *cl,
12110 __rte_unused void *data)
12112 struct cmd_macsec_sa_result *res = parsed_result;
12113 int ret = -ENOTSUP;
12114 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12115 uint8_t key[16] = { 0 };
12121 key_len = strlen(res->key) / 2;
12125 for (i = 0; i < key_len; i++) {
12126 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12129 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12132 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12135 #ifdef RTE_NET_IXGBE
12137 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12138 res->idx, res->an, res->pn, key) :
12139 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12140 res->idx, res->an, res->pn, key);
12142 RTE_SET_USED(is_tx);
12149 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12152 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12155 fprintf(stderr, "not supported on port %d\n", res->port_id);
12158 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12162 cmdline_parse_inst_t cmd_set_macsec_sa = {
12163 .f = cmd_set_macsec_sa_parsed,
12165 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12167 (void *)&cmd_macsec_sa_set,
12168 (void *)&cmd_macsec_sa_macsec,
12169 (void *)&cmd_macsec_sa_sa,
12170 (void *)&cmd_macsec_sa_tx_rx,
12171 (void *)&cmd_macsec_sa_port_id,
12172 (void *)&cmd_macsec_sa_idx,
12173 (void *)&cmd_macsec_sa_an,
12174 (void *)&cmd_macsec_sa_pn,
12175 (void *)&cmd_macsec_sa_key,
12180 /* VF unicast promiscuous mode configuration */
12182 /* Common result structure for VF unicast promiscuous mode */
12183 struct cmd_vf_promisc_result {
12184 cmdline_fixed_string_t set;
12185 cmdline_fixed_string_t vf;
12186 cmdline_fixed_string_t promisc;
12189 cmdline_fixed_string_t on_off;
12192 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12193 cmdline_parse_token_string_t cmd_vf_promisc_set =
12194 TOKEN_STRING_INITIALIZER
12195 (struct cmd_vf_promisc_result,
12197 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12198 TOKEN_STRING_INITIALIZER
12199 (struct cmd_vf_promisc_result,
12201 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12202 TOKEN_STRING_INITIALIZER
12203 (struct cmd_vf_promisc_result,
12204 promisc, "promisc");
12205 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12206 TOKEN_NUM_INITIALIZER
12207 (struct cmd_vf_promisc_result,
12208 port_id, RTE_UINT16);
12209 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12210 TOKEN_NUM_INITIALIZER
12211 (struct cmd_vf_promisc_result,
12212 vf_id, RTE_UINT32);
12213 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12214 TOKEN_STRING_INITIALIZER
12215 (struct cmd_vf_promisc_result,
12219 cmd_set_vf_promisc_parsed(
12220 void *parsed_result,
12221 __rte_unused struct cmdline *cl,
12222 __rte_unused void *data)
12224 struct cmd_vf_promisc_result *res = parsed_result;
12225 int ret = -ENOTSUP;
12227 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12232 #ifdef RTE_NET_I40E
12233 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12234 res->vf_id, is_on);
12241 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12244 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12247 fprintf(stderr, "function not implemented\n");
12250 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12254 cmdline_parse_inst_t cmd_set_vf_promisc = {
12255 .f = cmd_set_vf_promisc_parsed,
12257 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12258 "Set unicast promiscuous mode for a VF from the PF",
12260 (void *)&cmd_vf_promisc_set,
12261 (void *)&cmd_vf_promisc_vf,
12262 (void *)&cmd_vf_promisc_promisc,
12263 (void *)&cmd_vf_promisc_port_id,
12264 (void *)&cmd_vf_promisc_vf_id,
12265 (void *)&cmd_vf_promisc_on_off,
12270 /* VF multicast promiscuous mode configuration */
12272 /* Common result structure for VF multicast promiscuous mode */
12273 struct cmd_vf_allmulti_result {
12274 cmdline_fixed_string_t set;
12275 cmdline_fixed_string_t vf;
12276 cmdline_fixed_string_t allmulti;
12279 cmdline_fixed_string_t on_off;
12282 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12283 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12284 TOKEN_STRING_INITIALIZER
12285 (struct cmd_vf_allmulti_result,
12287 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12288 TOKEN_STRING_INITIALIZER
12289 (struct cmd_vf_allmulti_result,
12291 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12292 TOKEN_STRING_INITIALIZER
12293 (struct cmd_vf_allmulti_result,
12294 allmulti, "allmulti");
12295 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12296 TOKEN_NUM_INITIALIZER
12297 (struct cmd_vf_allmulti_result,
12298 port_id, RTE_UINT16);
12299 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12300 TOKEN_NUM_INITIALIZER
12301 (struct cmd_vf_allmulti_result,
12302 vf_id, RTE_UINT32);
12303 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12304 TOKEN_STRING_INITIALIZER
12305 (struct cmd_vf_allmulti_result,
12309 cmd_set_vf_allmulti_parsed(
12310 void *parsed_result,
12311 __rte_unused struct cmdline *cl,
12312 __rte_unused void *data)
12314 struct cmd_vf_allmulti_result *res = parsed_result;
12315 int ret = -ENOTSUP;
12317 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12319 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12322 #ifdef RTE_NET_I40E
12323 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12324 res->vf_id, is_on);
12331 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12334 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12337 fprintf(stderr, "function not implemented\n");
12340 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12344 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12345 .f = cmd_set_vf_allmulti_parsed,
12347 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12348 "Set multicast promiscuous mode for a VF from the PF",
12350 (void *)&cmd_vf_allmulti_set,
12351 (void *)&cmd_vf_allmulti_vf,
12352 (void *)&cmd_vf_allmulti_allmulti,
12353 (void *)&cmd_vf_allmulti_port_id,
12354 (void *)&cmd_vf_allmulti_vf_id,
12355 (void *)&cmd_vf_allmulti_on_off,
12360 /* vf broadcast mode configuration */
12362 /* Common result structure for vf broadcast */
12363 struct cmd_set_vf_broadcast_result {
12364 cmdline_fixed_string_t set;
12365 cmdline_fixed_string_t vf;
12366 cmdline_fixed_string_t broadcast;
12369 cmdline_fixed_string_t on_off;
12372 /* Common CLI fields for vf broadcast enable disable */
12373 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_set_vf_broadcast_result,
12377 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_set_vf_broadcast_result,
12381 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12382 TOKEN_STRING_INITIALIZER
12383 (struct cmd_set_vf_broadcast_result,
12384 broadcast, "broadcast");
12385 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12386 TOKEN_NUM_INITIALIZER
12387 (struct cmd_set_vf_broadcast_result,
12388 port_id, RTE_UINT16);
12389 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12390 TOKEN_NUM_INITIALIZER
12391 (struct cmd_set_vf_broadcast_result,
12392 vf_id, RTE_UINT16);
12393 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12394 TOKEN_STRING_INITIALIZER
12395 (struct cmd_set_vf_broadcast_result,
12399 cmd_set_vf_broadcast_parsed(
12400 void *parsed_result,
12401 __rte_unused struct cmdline *cl,
12402 __rte_unused void *data)
12404 struct cmd_set_vf_broadcast_result *res = parsed_result;
12405 int ret = -ENOTSUP;
12407 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12412 #ifdef RTE_NET_I40E
12413 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12414 res->vf_id, is_on);
12421 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12422 res->vf_id, is_on);
12425 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12428 fprintf(stderr, "function not implemented\n");
12431 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12435 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12436 .f = cmd_set_vf_broadcast_parsed,
12438 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12440 (void *)&cmd_set_vf_broadcast_set,
12441 (void *)&cmd_set_vf_broadcast_vf,
12442 (void *)&cmd_set_vf_broadcast_broadcast,
12443 (void *)&cmd_set_vf_broadcast_port_id,
12444 (void *)&cmd_set_vf_broadcast_vf_id,
12445 (void *)&cmd_set_vf_broadcast_on_off,
12450 /* vf vlan tag configuration */
12452 /* Common result structure for vf vlan tag */
12453 struct cmd_set_vf_vlan_tag_result {
12454 cmdline_fixed_string_t set;
12455 cmdline_fixed_string_t vf;
12456 cmdline_fixed_string_t vlan;
12457 cmdline_fixed_string_t tag;
12460 cmdline_fixed_string_t on_off;
12463 /* Common CLI fields for vf vlan tag enable disable */
12464 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12465 TOKEN_STRING_INITIALIZER
12466 (struct cmd_set_vf_vlan_tag_result,
12468 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_set_vf_vlan_tag_result,
12472 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12473 TOKEN_STRING_INITIALIZER
12474 (struct cmd_set_vf_vlan_tag_result,
12476 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_set_vf_vlan_tag_result,
12480 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12481 TOKEN_NUM_INITIALIZER
12482 (struct cmd_set_vf_vlan_tag_result,
12483 port_id, RTE_UINT16);
12484 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12485 TOKEN_NUM_INITIALIZER
12486 (struct cmd_set_vf_vlan_tag_result,
12487 vf_id, RTE_UINT16);
12488 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_set_vf_vlan_tag_result,
12494 cmd_set_vf_vlan_tag_parsed(
12495 void *parsed_result,
12496 __rte_unused struct cmdline *cl,
12497 __rte_unused void *data)
12499 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12500 int ret = -ENOTSUP;
12502 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12507 #ifdef RTE_NET_I40E
12508 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12509 res->vf_id, is_on);
12516 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12517 res->vf_id, is_on);
12520 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12523 fprintf(stderr, "function not implemented\n");
12526 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12530 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12531 .f = cmd_set_vf_vlan_tag_parsed,
12533 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12535 (void *)&cmd_set_vf_vlan_tag_set,
12536 (void *)&cmd_set_vf_vlan_tag_vf,
12537 (void *)&cmd_set_vf_vlan_tag_vlan,
12538 (void *)&cmd_set_vf_vlan_tag_tag,
12539 (void *)&cmd_set_vf_vlan_tag_port_id,
12540 (void *)&cmd_set_vf_vlan_tag_vf_id,
12541 (void *)&cmd_set_vf_vlan_tag_on_off,
12546 /* Common definition of VF and TC TX bandwidth configuration */
12547 struct cmd_vf_tc_bw_result {
12548 cmdline_fixed_string_t set;
12549 cmdline_fixed_string_t vf;
12550 cmdline_fixed_string_t tc;
12551 cmdline_fixed_string_t tx;
12552 cmdline_fixed_string_t min_bw;
12553 cmdline_fixed_string_t max_bw;
12554 cmdline_fixed_string_t strict_link_prio;
12559 cmdline_fixed_string_t bw_list;
12563 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12564 TOKEN_STRING_INITIALIZER
12565 (struct cmd_vf_tc_bw_result,
12567 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12568 TOKEN_STRING_INITIALIZER
12569 (struct cmd_vf_tc_bw_result,
12571 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12572 TOKEN_STRING_INITIALIZER
12573 (struct cmd_vf_tc_bw_result,
12575 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12576 TOKEN_STRING_INITIALIZER
12577 (struct cmd_vf_tc_bw_result,
12579 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12580 TOKEN_STRING_INITIALIZER
12581 (struct cmd_vf_tc_bw_result,
12582 strict_link_prio, "strict-link-priority");
12583 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12584 TOKEN_STRING_INITIALIZER
12585 (struct cmd_vf_tc_bw_result,
12586 min_bw, "min-bandwidth");
12587 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12588 TOKEN_STRING_INITIALIZER
12589 (struct cmd_vf_tc_bw_result,
12590 max_bw, "max-bandwidth");
12591 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12592 TOKEN_NUM_INITIALIZER
12593 (struct cmd_vf_tc_bw_result,
12594 port_id, RTE_UINT16);
12595 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12596 TOKEN_NUM_INITIALIZER
12597 (struct cmd_vf_tc_bw_result,
12598 vf_id, RTE_UINT16);
12599 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12600 TOKEN_NUM_INITIALIZER
12601 (struct cmd_vf_tc_bw_result,
12603 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12604 TOKEN_NUM_INITIALIZER
12605 (struct cmd_vf_tc_bw_result,
12607 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12608 TOKEN_STRING_INITIALIZER
12609 (struct cmd_vf_tc_bw_result,
12611 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12612 TOKEN_NUM_INITIALIZER
12613 (struct cmd_vf_tc_bw_result,
12614 tc_map, RTE_UINT8);
12616 /* VF max bandwidth setting */
12618 cmd_vf_max_bw_parsed(
12619 void *parsed_result,
12620 __rte_unused struct cmdline *cl,
12621 __rte_unused void *data)
12623 struct cmd_vf_tc_bw_result *res = parsed_result;
12624 int ret = -ENOTSUP;
12626 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12629 #ifdef RTE_NET_I40E
12630 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12631 res->vf_id, res->bw);
12638 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12639 res->vf_id, res->bw);
12642 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12645 fprintf(stderr, "function not implemented\n");
12648 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12652 cmdline_parse_inst_t cmd_vf_max_bw = {
12653 .f = cmd_vf_max_bw_parsed,
12655 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12657 (void *)&cmd_vf_tc_bw_set,
12658 (void *)&cmd_vf_tc_bw_vf,
12659 (void *)&cmd_vf_tc_bw_tx,
12660 (void *)&cmd_vf_tc_bw_max_bw,
12661 (void *)&cmd_vf_tc_bw_port_id,
12662 (void *)&cmd_vf_tc_bw_vf_id,
12663 (void *)&cmd_vf_tc_bw_bw,
12669 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12674 const char *p, *p0 = str;
12681 p = strchr(p0, '(');
12684 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12688 p0 = strchr(p, ')');
12691 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12695 if (size >= sizeof(s)) {
12697 "The string size exceeds the internal buffer size\n");
12700 snprintf(s, sizeof(s), "%.*s", size, p);
12701 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12703 fprintf(stderr, "Failed to get the bandwidth list.\n");
12707 for (i = 0; i < ret; i++)
12708 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12713 /* TC min bandwidth setting */
12715 cmd_vf_tc_min_bw_parsed(
12716 void *parsed_result,
12717 __rte_unused struct cmdline *cl,
12718 __rte_unused void *data)
12720 struct cmd_vf_tc_bw_result *res = parsed_result;
12723 int ret = -ENOTSUP;
12725 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12728 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12732 #ifdef RTE_NET_I40E
12733 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12741 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12744 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12747 fprintf(stderr, "function not implemented\n");
12750 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12754 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12755 .f = cmd_vf_tc_min_bw_parsed,
12757 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12758 " <bw1, bw2, ...>",
12760 (void *)&cmd_vf_tc_bw_set,
12761 (void *)&cmd_vf_tc_bw_vf,
12762 (void *)&cmd_vf_tc_bw_tc,
12763 (void *)&cmd_vf_tc_bw_tx,
12764 (void *)&cmd_vf_tc_bw_min_bw,
12765 (void *)&cmd_vf_tc_bw_port_id,
12766 (void *)&cmd_vf_tc_bw_vf_id,
12767 (void *)&cmd_vf_tc_bw_bw_list,
12773 cmd_tc_min_bw_parsed(
12774 void *parsed_result,
12775 __rte_unused struct cmdline *cl,
12776 __rte_unused void *data)
12778 struct cmd_vf_tc_bw_result *res = parsed_result;
12779 struct rte_port *port;
12782 int ret = -ENOTSUP;
12784 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12787 port = &ports[res->port_id];
12788 /** Check if the port is not started **/
12789 if (port->port_status != RTE_PORT_STOPPED) {
12790 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12794 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12798 #ifdef RTE_NET_IXGBE
12799 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12806 fprintf(stderr, "invalid bandwidth\n");
12809 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12812 fprintf(stderr, "function not implemented\n");
12815 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12819 cmdline_parse_inst_t cmd_tc_min_bw = {
12820 .f = cmd_tc_min_bw_parsed,
12822 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12824 (void *)&cmd_vf_tc_bw_set,
12825 (void *)&cmd_vf_tc_bw_tc,
12826 (void *)&cmd_vf_tc_bw_tx,
12827 (void *)&cmd_vf_tc_bw_min_bw,
12828 (void *)&cmd_vf_tc_bw_port_id,
12829 (void *)&cmd_vf_tc_bw_bw_list,
12834 /* TC max bandwidth setting */
12836 cmd_vf_tc_max_bw_parsed(
12837 void *parsed_result,
12838 __rte_unused struct cmdline *cl,
12839 __rte_unused void *data)
12841 struct cmd_vf_tc_bw_result *res = parsed_result;
12842 int ret = -ENOTSUP;
12844 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12847 #ifdef RTE_NET_I40E
12848 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12849 res->tc_no, res->bw);
12857 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
12858 res->vf_id, res->tc_no, res->bw);
12861 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12864 fprintf(stderr, "function not implemented\n");
12867 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12871 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12872 .f = cmd_vf_tc_max_bw_parsed,
12874 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12877 (void *)&cmd_vf_tc_bw_set,
12878 (void *)&cmd_vf_tc_bw_vf,
12879 (void *)&cmd_vf_tc_bw_tc,
12880 (void *)&cmd_vf_tc_bw_tx,
12881 (void *)&cmd_vf_tc_bw_max_bw,
12882 (void *)&cmd_vf_tc_bw_port_id,
12883 (void *)&cmd_vf_tc_bw_vf_id,
12884 (void *)&cmd_vf_tc_bw_tc_no,
12885 (void *)&cmd_vf_tc_bw_bw,
12890 /** Set VXLAN encapsulation details */
12891 struct cmd_set_vxlan_result {
12892 cmdline_fixed_string_t set;
12893 cmdline_fixed_string_t vxlan;
12894 cmdline_fixed_string_t pos_token;
12895 cmdline_fixed_string_t ip_version;
12896 uint32_t vlan_present:1;
12900 cmdline_ipaddr_t ip_src;
12901 cmdline_ipaddr_t ip_dst;
12905 struct rte_ether_addr eth_src;
12906 struct rte_ether_addr eth_dst;
12909 cmdline_parse_token_string_t cmd_set_vxlan_set =
12910 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12911 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12912 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12913 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12914 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12916 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12917 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12918 "vxlan-with-vlan");
12919 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12920 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12922 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12923 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12925 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12926 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12928 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12929 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12930 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12931 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12933 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12934 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12935 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12936 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12938 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12939 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12940 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12941 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12943 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12944 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12945 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12946 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12948 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12949 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12950 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12951 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12953 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12954 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12955 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12956 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12958 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12959 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12960 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12961 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12963 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12964 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12965 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12966 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12968 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12969 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12970 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12971 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12973 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12974 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12976 static void cmd_set_vxlan_parsed(void *parsed_result,
12977 __rte_unused struct cmdline *cl,
12978 __rte_unused void *data)
12980 struct cmd_set_vxlan_result *res = parsed_result;
12985 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12988 vxlan_encap_conf.select_tos_ttl = 0;
12989 if (strcmp(res->vxlan, "vxlan") == 0)
12990 vxlan_encap_conf.select_vlan = 0;
12991 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12992 vxlan_encap_conf.select_vlan = 1;
12993 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12994 vxlan_encap_conf.select_vlan = 0;
12995 vxlan_encap_conf.select_tos_ttl = 1;
12997 if (strcmp(res->ip_version, "ipv4") == 0)
12998 vxlan_encap_conf.select_ipv4 = 1;
12999 else if (strcmp(res->ip_version, "ipv6") == 0)
13000 vxlan_encap_conf.select_ipv4 = 0;
13003 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13004 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13005 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13006 vxlan_encap_conf.ip_tos = res->tos;
13007 vxlan_encap_conf.ip_ttl = res->ttl;
13008 if (vxlan_encap_conf.select_ipv4) {
13009 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13010 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13012 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13013 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13015 if (vxlan_encap_conf.select_vlan)
13016 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13017 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13018 RTE_ETHER_ADDR_LEN);
13019 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13020 RTE_ETHER_ADDR_LEN);
13023 cmdline_parse_inst_t cmd_set_vxlan = {
13024 .f = cmd_set_vxlan_parsed,
13026 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13027 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13028 " eth-src <eth-src> eth-dst <eth-dst>",
13030 (void *)&cmd_set_vxlan_set,
13031 (void *)&cmd_set_vxlan_vxlan,
13032 (void *)&cmd_set_vxlan_ip_version,
13033 (void *)&cmd_set_vxlan_ip_version_value,
13034 (void *)&cmd_set_vxlan_vni,
13035 (void *)&cmd_set_vxlan_vni_value,
13036 (void *)&cmd_set_vxlan_udp_src,
13037 (void *)&cmd_set_vxlan_udp_src_value,
13038 (void *)&cmd_set_vxlan_udp_dst,
13039 (void *)&cmd_set_vxlan_udp_dst_value,
13040 (void *)&cmd_set_vxlan_ip_src,
13041 (void *)&cmd_set_vxlan_ip_src_value,
13042 (void *)&cmd_set_vxlan_ip_dst,
13043 (void *)&cmd_set_vxlan_ip_dst_value,
13044 (void *)&cmd_set_vxlan_eth_src,
13045 (void *)&cmd_set_vxlan_eth_src_value,
13046 (void *)&cmd_set_vxlan_eth_dst,
13047 (void *)&cmd_set_vxlan_eth_dst_value,
13052 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13053 .f = cmd_set_vxlan_parsed,
13055 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13056 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13057 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13058 " eth-dst <eth-dst>",
13060 (void *)&cmd_set_vxlan_set,
13061 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13062 (void *)&cmd_set_vxlan_ip_version,
13063 (void *)&cmd_set_vxlan_ip_version_value,
13064 (void *)&cmd_set_vxlan_vni,
13065 (void *)&cmd_set_vxlan_vni_value,
13066 (void *)&cmd_set_vxlan_udp_src,
13067 (void *)&cmd_set_vxlan_udp_src_value,
13068 (void *)&cmd_set_vxlan_udp_dst,
13069 (void *)&cmd_set_vxlan_udp_dst_value,
13070 (void *)&cmd_set_vxlan_ip_tos,
13071 (void *)&cmd_set_vxlan_ip_tos_value,
13072 (void *)&cmd_set_vxlan_ip_ttl,
13073 (void *)&cmd_set_vxlan_ip_ttl_value,
13074 (void *)&cmd_set_vxlan_ip_src,
13075 (void *)&cmd_set_vxlan_ip_src_value,
13076 (void *)&cmd_set_vxlan_ip_dst,
13077 (void *)&cmd_set_vxlan_ip_dst_value,
13078 (void *)&cmd_set_vxlan_eth_src,
13079 (void *)&cmd_set_vxlan_eth_src_value,
13080 (void *)&cmd_set_vxlan_eth_dst,
13081 (void *)&cmd_set_vxlan_eth_dst_value,
13086 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13087 .f = cmd_set_vxlan_parsed,
13089 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13090 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13091 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13094 (void *)&cmd_set_vxlan_set,
13095 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13096 (void *)&cmd_set_vxlan_ip_version,
13097 (void *)&cmd_set_vxlan_ip_version_value,
13098 (void *)&cmd_set_vxlan_vni,
13099 (void *)&cmd_set_vxlan_vni_value,
13100 (void *)&cmd_set_vxlan_udp_src,
13101 (void *)&cmd_set_vxlan_udp_src_value,
13102 (void *)&cmd_set_vxlan_udp_dst,
13103 (void *)&cmd_set_vxlan_udp_dst_value,
13104 (void *)&cmd_set_vxlan_ip_src,
13105 (void *)&cmd_set_vxlan_ip_src_value,
13106 (void *)&cmd_set_vxlan_ip_dst,
13107 (void *)&cmd_set_vxlan_ip_dst_value,
13108 (void *)&cmd_set_vxlan_vlan,
13109 (void *)&cmd_set_vxlan_vlan_value,
13110 (void *)&cmd_set_vxlan_eth_src,
13111 (void *)&cmd_set_vxlan_eth_src_value,
13112 (void *)&cmd_set_vxlan_eth_dst,
13113 (void *)&cmd_set_vxlan_eth_dst_value,
13118 /** Set NVGRE encapsulation details */
13119 struct cmd_set_nvgre_result {
13120 cmdline_fixed_string_t set;
13121 cmdline_fixed_string_t nvgre;
13122 cmdline_fixed_string_t pos_token;
13123 cmdline_fixed_string_t ip_version;
13125 cmdline_ipaddr_t ip_src;
13126 cmdline_ipaddr_t ip_dst;
13128 struct rte_ether_addr eth_src;
13129 struct rte_ether_addr eth_dst;
13132 cmdline_parse_token_string_t cmd_set_nvgre_set =
13133 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13134 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13135 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13136 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13137 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13138 "nvgre-with-vlan");
13139 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13140 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13142 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13143 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13145 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13146 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13148 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13149 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13150 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13151 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13153 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13154 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13155 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13156 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13158 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13159 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13160 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13161 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13163 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13164 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13165 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13166 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13168 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13169 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13170 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13171 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13173 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13174 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13176 static void cmd_set_nvgre_parsed(void *parsed_result,
13177 __rte_unused struct cmdline *cl,
13178 __rte_unused void *data)
13180 struct cmd_set_nvgre_result *res = parsed_result;
13182 uint32_t nvgre_tni;
13185 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13188 if (strcmp(res->nvgre, "nvgre") == 0)
13189 nvgre_encap_conf.select_vlan = 0;
13190 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13191 nvgre_encap_conf.select_vlan = 1;
13192 if (strcmp(res->ip_version, "ipv4") == 0)
13193 nvgre_encap_conf.select_ipv4 = 1;
13194 else if (strcmp(res->ip_version, "ipv6") == 0)
13195 nvgre_encap_conf.select_ipv4 = 0;
13198 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13199 if (nvgre_encap_conf.select_ipv4) {
13200 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13201 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13203 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13204 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13206 if (nvgre_encap_conf.select_vlan)
13207 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13208 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13209 RTE_ETHER_ADDR_LEN);
13210 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13211 RTE_ETHER_ADDR_LEN);
13214 cmdline_parse_inst_t cmd_set_nvgre = {
13215 .f = cmd_set_nvgre_parsed,
13217 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13218 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13219 " eth-dst <eth-dst>",
13221 (void *)&cmd_set_nvgre_set,
13222 (void *)&cmd_set_nvgre_nvgre,
13223 (void *)&cmd_set_nvgre_ip_version,
13224 (void *)&cmd_set_nvgre_ip_version_value,
13225 (void *)&cmd_set_nvgre_tni,
13226 (void *)&cmd_set_nvgre_tni_value,
13227 (void *)&cmd_set_nvgre_ip_src,
13228 (void *)&cmd_set_nvgre_ip_src_value,
13229 (void *)&cmd_set_nvgre_ip_dst,
13230 (void *)&cmd_set_nvgre_ip_dst_value,
13231 (void *)&cmd_set_nvgre_eth_src,
13232 (void *)&cmd_set_nvgre_eth_src_value,
13233 (void *)&cmd_set_nvgre_eth_dst,
13234 (void *)&cmd_set_nvgre_eth_dst_value,
13239 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13240 .f = cmd_set_nvgre_parsed,
13242 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13243 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13244 " eth-src <eth-src> eth-dst <eth-dst>",
13246 (void *)&cmd_set_nvgre_set,
13247 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13248 (void *)&cmd_set_nvgre_ip_version,
13249 (void *)&cmd_set_nvgre_ip_version_value,
13250 (void *)&cmd_set_nvgre_tni,
13251 (void *)&cmd_set_nvgre_tni_value,
13252 (void *)&cmd_set_nvgre_ip_src,
13253 (void *)&cmd_set_nvgre_ip_src_value,
13254 (void *)&cmd_set_nvgre_ip_dst,
13255 (void *)&cmd_set_nvgre_ip_dst_value,
13256 (void *)&cmd_set_nvgre_vlan,
13257 (void *)&cmd_set_nvgre_vlan_value,
13258 (void *)&cmd_set_nvgre_eth_src,
13259 (void *)&cmd_set_nvgre_eth_src_value,
13260 (void *)&cmd_set_nvgre_eth_dst,
13261 (void *)&cmd_set_nvgre_eth_dst_value,
13266 /** Set L2 encapsulation details */
13267 struct cmd_set_l2_encap_result {
13268 cmdline_fixed_string_t set;
13269 cmdline_fixed_string_t l2_encap;
13270 cmdline_fixed_string_t pos_token;
13271 cmdline_fixed_string_t ip_version;
13272 uint32_t vlan_present:1;
13274 struct rte_ether_addr eth_src;
13275 struct rte_ether_addr eth_dst;
13278 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13279 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13280 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13281 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13282 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13283 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13284 "l2_encap-with-vlan");
13285 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13286 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13288 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13289 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13291 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13292 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13294 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13295 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13296 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13297 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13299 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13300 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13301 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13302 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13304 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13305 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13307 static void cmd_set_l2_encap_parsed(void *parsed_result,
13308 __rte_unused struct cmdline *cl,
13309 __rte_unused void *data)
13311 struct cmd_set_l2_encap_result *res = parsed_result;
13313 if (strcmp(res->l2_encap, "l2_encap") == 0)
13314 l2_encap_conf.select_vlan = 0;
13315 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13316 l2_encap_conf.select_vlan = 1;
13317 if (strcmp(res->ip_version, "ipv4") == 0)
13318 l2_encap_conf.select_ipv4 = 1;
13319 else if (strcmp(res->ip_version, "ipv6") == 0)
13320 l2_encap_conf.select_ipv4 = 0;
13323 if (l2_encap_conf.select_vlan)
13324 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13325 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13326 RTE_ETHER_ADDR_LEN);
13327 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13328 RTE_ETHER_ADDR_LEN);
13331 cmdline_parse_inst_t cmd_set_l2_encap = {
13332 .f = cmd_set_l2_encap_parsed,
13334 .help_str = "set l2_encap ip-version ipv4|ipv6"
13335 " eth-src <eth-src> eth-dst <eth-dst>",
13337 (void *)&cmd_set_l2_encap_set,
13338 (void *)&cmd_set_l2_encap_l2_encap,
13339 (void *)&cmd_set_l2_encap_ip_version,
13340 (void *)&cmd_set_l2_encap_ip_version_value,
13341 (void *)&cmd_set_l2_encap_eth_src,
13342 (void *)&cmd_set_l2_encap_eth_src_value,
13343 (void *)&cmd_set_l2_encap_eth_dst,
13344 (void *)&cmd_set_l2_encap_eth_dst_value,
13349 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13350 .f = cmd_set_l2_encap_parsed,
13352 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13353 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13355 (void *)&cmd_set_l2_encap_set,
13356 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13357 (void *)&cmd_set_l2_encap_ip_version,
13358 (void *)&cmd_set_l2_encap_ip_version_value,
13359 (void *)&cmd_set_l2_encap_vlan,
13360 (void *)&cmd_set_l2_encap_vlan_value,
13361 (void *)&cmd_set_l2_encap_eth_src,
13362 (void *)&cmd_set_l2_encap_eth_src_value,
13363 (void *)&cmd_set_l2_encap_eth_dst,
13364 (void *)&cmd_set_l2_encap_eth_dst_value,
13369 /** Set L2 decapsulation details */
13370 struct cmd_set_l2_decap_result {
13371 cmdline_fixed_string_t set;
13372 cmdline_fixed_string_t l2_decap;
13373 cmdline_fixed_string_t pos_token;
13374 uint32_t vlan_present:1;
13377 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13378 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13379 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13380 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13382 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13383 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13384 "l2_decap-with-vlan");
13386 static void cmd_set_l2_decap_parsed(void *parsed_result,
13387 __rte_unused struct cmdline *cl,
13388 __rte_unused void *data)
13390 struct cmd_set_l2_decap_result *res = parsed_result;
13392 if (strcmp(res->l2_decap, "l2_decap") == 0)
13393 l2_decap_conf.select_vlan = 0;
13394 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13395 l2_decap_conf.select_vlan = 1;
13398 cmdline_parse_inst_t cmd_set_l2_decap = {
13399 .f = cmd_set_l2_decap_parsed,
13401 .help_str = "set l2_decap",
13403 (void *)&cmd_set_l2_decap_set,
13404 (void *)&cmd_set_l2_decap_l2_decap,
13409 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13410 .f = cmd_set_l2_decap_parsed,
13412 .help_str = "set l2_decap-with-vlan",
13414 (void *)&cmd_set_l2_decap_set,
13415 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13420 /** Set MPLSoGRE encapsulation details */
13421 struct cmd_set_mplsogre_encap_result {
13422 cmdline_fixed_string_t set;
13423 cmdline_fixed_string_t mplsogre;
13424 cmdline_fixed_string_t pos_token;
13425 cmdline_fixed_string_t ip_version;
13426 uint32_t vlan_present:1;
13428 cmdline_ipaddr_t ip_src;
13429 cmdline_ipaddr_t ip_dst;
13431 struct rte_ether_addr eth_src;
13432 struct rte_ether_addr eth_dst;
13435 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13436 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13438 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13439 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13441 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13442 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13443 mplsogre, "mplsogre_encap-with-vlan");
13444 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13445 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13446 pos_token, "ip-version");
13447 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13448 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13449 ip_version, "ipv4#ipv6");
13450 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13451 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13452 pos_token, "label");
13453 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13454 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13456 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13457 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13458 pos_token, "ip-src");
13459 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13460 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13461 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13462 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13463 pos_token, "ip-dst");
13464 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13465 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13466 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13467 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13468 pos_token, "vlan-tci");
13469 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13470 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13472 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13473 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13474 pos_token, "eth-src");
13475 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13476 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13478 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13479 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13480 pos_token, "eth-dst");
13481 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13482 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13485 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13486 __rte_unused struct cmdline *cl,
13487 __rte_unused void *data)
13489 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13491 uint32_t mplsogre_label;
13494 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13497 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13498 mplsogre_encap_conf.select_vlan = 0;
13499 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13500 mplsogre_encap_conf.select_vlan = 1;
13501 if (strcmp(res->ip_version, "ipv4") == 0)
13502 mplsogre_encap_conf.select_ipv4 = 1;
13503 else if (strcmp(res->ip_version, "ipv6") == 0)
13504 mplsogre_encap_conf.select_ipv4 = 0;
13507 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13508 if (mplsogre_encap_conf.select_ipv4) {
13509 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13510 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13512 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13513 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13515 if (mplsogre_encap_conf.select_vlan)
13516 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13517 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13518 RTE_ETHER_ADDR_LEN);
13519 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13520 RTE_ETHER_ADDR_LEN);
13523 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13524 .f = cmd_set_mplsogre_encap_parsed,
13526 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13527 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13528 " eth-dst <eth-dst>",
13530 (void *)&cmd_set_mplsogre_encap_set,
13531 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13532 (void *)&cmd_set_mplsogre_encap_ip_version,
13533 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13534 (void *)&cmd_set_mplsogre_encap_label,
13535 (void *)&cmd_set_mplsogre_encap_label_value,
13536 (void *)&cmd_set_mplsogre_encap_ip_src,
13537 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13538 (void *)&cmd_set_mplsogre_encap_ip_dst,
13539 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13540 (void *)&cmd_set_mplsogre_encap_eth_src,
13541 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13542 (void *)&cmd_set_mplsogre_encap_eth_dst,
13543 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13548 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13549 .f = cmd_set_mplsogre_encap_parsed,
13551 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13552 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13553 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13555 (void *)&cmd_set_mplsogre_encap_set,
13556 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13557 (void *)&cmd_set_mplsogre_encap_ip_version,
13558 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13559 (void *)&cmd_set_mplsogre_encap_label,
13560 (void *)&cmd_set_mplsogre_encap_label_value,
13561 (void *)&cmd_set_mplsogre_encap_ip_src,
13562 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13563 (void *)&cmd_set_mplsogre_encap_ip_dst,
13564 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13565 (void *)&cmd_set_mplsogre_encap_vlan,
13566 (void *)&cmd_set_mplsogre_encap_vlan_value,
13567 (void *)&cmd_set_mplsogre_encap_eth_src,
13568 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13569 (void *)&cmd_set_mplsogre_encap_eth_dst,
13570 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13575 /** Set MPLSoGRE decapsulation details */
13576 struct cmd_set_mplsogre_decap_result {
13577 cmdline_fixed_string_t set;
13578 cmdline_fixed_string_t mplsogre;
13579 cmdline_fixed_string_t pos_token;
13580 cmdline_fixed_string_t ip_version;
13581 uint32_t vlan_present:1;
13584 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13585 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13587 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13588 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13590 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13591 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13592 mplsogre, "mplsogre_decap-with-vlan");
13593 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13594 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13595 pos_token, "ip-version");
13596 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13597 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13598 ip_version, "ipv4#ipv6");
13600 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13601 __rte_unused struct cmdline *cl,
13602 __rte_unused void *data)
13604 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13606 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13607 mplsogre_decap_conf.select_vlan = 0;
13608 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13609 mplsogre_decap_conf.select_vlan = 1;
13610 if (strcmp(res->ip_version, "ipv4") == 0)
13611 mplsogre_decap_conf.select_ipv4 = 1;
13612 else if (strcmp(res->ip_version, "ipv6") == 0)
13613 mplsogre_decap_conf.select_ipv4 = 0;
13616 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13617 .f = cmd_set_mplsogre_decap_parsed,
13619 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13621 (void *)&cmd_set_mplsogre_decap_set,
13622 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13623 (void *)&cmd_set_mplsogre_decap_ip_version,
13624 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13629 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13630 .f = cmd_set_mplsogre_decap_parsed,
13632 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13634 (void *)&cmd_set_mplsogre_decap_set,
13635 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13636 (void *)&cmd_set_mplsogre_decap_ip_version,
13637 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13642 /** Set MPLSoUDP encapsulation details */
13643 struct cmd_set_mplsoudp_encap_result {
13644 cmdline_fixed_string_t set;
13645 cmdline_fixed_string_t mplsoudp;
13646 cmdline_fixed_string_t pos_token;
13647 cmdline_fixed_string_t ip_version;
13648 uint32_t vlan_present:1;
13652 cmdline_ipaddr_t ip_src;
13653 cmdline_ipaddr_t ip_dst;
13655 struct rte_ether_addr eth_src;
13656 struct rte_ether_addr eth_dst;
13659 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13660 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13662 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13663 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13665 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13666 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13667 mplsoudp, "mplsoudp_encap-with-vlan");
13668 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13669 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13670 pos_token, "ip-version");
13671 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13672 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13673 ip_version, "ipv4#ipv6");
13674 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13675 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13676 pos_token, "label");
13677 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13678 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13680 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13681 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13682 pos_token, "udp-src");
13683 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13684 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13686 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13687 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13688 pos_token, "udp-dst");
13689 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13690 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13692 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13693 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13694 pos_token, "ip-src");
13695 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13696 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13697 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13698 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13699 pos_token, "ip-dst");
13700 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13701 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13702 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13703 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13704 pos_token, "vlan-tci");
13705 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13706 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13708 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13709 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13710 pos_token, "eth-src");
13711 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13712 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13714 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13715 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13716 pos_token, "eth-dst");
13717 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13718 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13721 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13722 __rte_unused struct cmdline *cl,
13723 __rte_unused void *data)
13725 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13727 uint32_t mplsoudp_label;
13730 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13733 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13734 mplsoudp_encap_conf.select_vlan = 0;
13735 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13736 mplsoudp_encap_conf.select_vlan = 1;
13737 if (strcmp(res->ip_version, "ipv4") == 0)
13738 mplsoudp_encap_conf.select_ipv4 = 1;
13739 else if (strcmp(res->ip_version, "ipv6") == 0)
13740 mplsoudp_encap_conf.select_ipv4 = 0;
13743 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13744 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13745 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13746 if (mplsoudp_encap_conf.select_ipv4) {
13747 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13748 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13750 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13751 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13753 if (mplsoudp_encap_conf.select_vlan)
13754 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13755 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13756 RTE_ETHER_ADDR_LEN);
13757 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13758 RTE_ETHER_ADDR_LEN);
13761 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13762 .f = cmd_set_mplsoudp_encap_parsed,
13764 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13765 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13766 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13768 (void *)&cmd_set_mplsoudp_encap_set,
13769 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13770 (void *)&cmd_set_mplsoudp_encap_ip_version,
13771 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13772 (void *)&cmd_set_mplsoudp_encap_label,
13773 (void *)&cmd_set_mplsoudp_encap_label_value,
13774 (void *)&cmd_set_mplsoudp_encap_udp_src,
13775 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13776 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13777 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13778 (void *)&cmd_set_mplsoudp_encap_ip_src,
13779 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13780 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13781 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13782 (void *)&cmd_set_mplsoudp_encap_eth_src,
13783 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13784 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13785 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13790 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13791 .f = cmd_set_mplsoudp_encap_parsed,
13793 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13794 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13795 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13796 " eth-src <eth-src> eth-dst <eth-dst>",
13798 (void *)&cmd_set_mplsoudp_encap_set,
13799 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13800 (void *)&cmd_set_mplsoudp_encap_ip_version,
13801 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13802 (void *)&cmd_set_mplsoudp_encap_label,
13803 (void *)&cmd_set_mplsoudp_encap_label_value,
13804 (void *)&cmd_set_mplsoudp_encap_udp_src,
13805 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13806 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13807 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13808 (void *)&cmd_set_mplsoudp_encap_ip_src,
13809 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13810 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13811 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13812 (void *)&cmd_set_mplsoudp_encap_vlan,
13813 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13814 (void *)&cmd_set_mplsoudp_encap_eth_src,
13815 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13816 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13817 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13822 /** Set MPLSoUDP decapsulation details */
13823 struct cmd_set_mplsoudp_decap_result {
13824 cmdline_fixed_string_t set;
13825 cmdline_fixed_string_t mplsoudp;
13826 cmdline_fixed_string_t pos_token;
13827 cmdline_fixed_string_t ip_version;
13828 uint32_t vlan_present:1;
13831 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13832 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13834 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13835 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13837 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13838 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13839 mplsoudp, "mplsoudp_decap-with-vlan");
13840 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13841 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13842 pos_token, "ip-version");
13843 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13844 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13845 ip_version, "ipv4#ipv6");
13847 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13848 __rte_unused struct cmdline *cl,
13849 __rte_unused void *data)
13851 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13853 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13854 mplsoudp_decap_conf.select_vlan = 0;
13855 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13856 mplsoudp_decap_conf.select_vlan = 1;
13857 if (strcmp(res->ip_version, "ipv4") == 0)
13858 mplsoudp_decap_conf.select_ipv4 = 1;
13859 else if (strcmp(res->ip_version, "ipv6") == 0)
13860 mplsoudp_decap_conf.select_ipv4 = 0;
13863 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13864 .f = cmd_set_mplsoudp_decap_parsed,
13866 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13868 (void *)&cmd_set_mplsoudp_decap_set,
13869 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13870 (void *)&cmd_set_mplsoudp_decap_ip_version,
13871 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13876 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13877 .f = cmd_set_mplsoudp_decap_parsed,
13879 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13881 (void *)&cmd_set_mplsoudp_decap_set,
13882 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13883 (void *)&cmd_set_mplsoudp_decap_ip_version,
13884 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13889 /** Set connection tracking object common details */
13890 struct cmd_set_conntrack_common_result {
13891 cmdline_fixed_string_t set;
13892 cmdline_fixed_string_t conntrack;
13893 cmdline_fixed_string_t common;
13894 cmdline_fixed_string_t peer;
13895 cmdline_fixed_string_t is_orig;
13896 cmdline_fixed_string_t enable;
13897 cmdline_fixed_string_t live;
13898 cmdline_fixed_string_t sack;
13899 cmdline_fixed_string_t cack;
13900 cmdline_fixed_string_t last_dir;
13901 cmdline_fixed_string_t liberal;
13902 cmdline_fixed_string_t state;
13903 cmdline_fixed_string_t max_ack_win;
13904 cmdline_fixed_string_t retrans;
13905 cmdline_fixed_string_t last_win;
13906 cmdline_fixed_string_t last_seq;
13907 cmdline_fixed_string_t last_ack;
13908 cmdline_fixed_string_t last_end;
13909 cmdline_fixed_string_t last_index;
13912 uint16_t peer_port;
13913 uint32_t is_original;
13928 cmdline_parse_token_string_t cmd_set_conntrack_set =
13929 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13931 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13932 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13933 conntrack, "conntrack");
13934 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13935 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13937 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13938 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13940 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13941 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13942 peer_port, RTE_UINT16);
13943 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13944 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13945 is_orig, "is_orig");
13946 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13947 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13948 is_original, RTE_UINT32);
13949 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13950 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13952 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13953 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13955 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13956 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13958 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13959 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13960 is_live, RTE_UINT32);
13961 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13962 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13964 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13965 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13966 s_ack, RTE_UINT32);
13967 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13968 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13970 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13971 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13972 c_ack, RTE_UINT32);
13973 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13974 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13975 last_dir, "last_dir");
13976 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13977 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13979 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13980 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13981 liberal, "liberal");
13982 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13983 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13985 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13986 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13988 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13989 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13991 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13992 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13993 max_ack_win, "max_ack_win");
13994 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13995 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13996 factor, RTE_UINT8);
13997 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13998 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14000 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14001 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14002 re_num, RTE_UINT8);
14003 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14004 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14005 last_win, "last_win");
14006 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14007 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14009 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14010 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14011 last_seq, "last_seq");
14012 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14013 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14015 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14016 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14017 last_ack, "last_ack");
14018 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14019 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14021 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14022 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14023 last_end, "last_end");
14024 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14025 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14027 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14028 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14029 last_index, "last_index");
14030 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14031 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14034 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14035 __rte_unused struct cmdline *cl,
14036 __rte_unused void *data)
14038 struct cmd_set_conntrack_common_result *res = parsed_result;
14040 /* No need to swap to big endian. */
14041 conntrack_context.peer_port = res->peer_port;
14042 conntrack_context.is_original_dir = res->is_original;
14043 conntrack_context.enable = res->en;
14044 conntrack_context.live_connection = res->is_live;
14045 conntrack_context.selective_ack = res->s_ack;
14046 conntrack_context.challenge_ack_passed = res->c_ack;
14047 conntrack_context.last_direction = res->ld;
14048 conntrack_context.liberal_mode = res->lb;
14049 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14050 conntrack_context.max_ack_window = res->factor;
14051 conntrack_context.retransmission_limit = res->re_num;
14052 conntrack_context.last_window = res->lw;
14053 conntrack_context.last_index =
14054 (enum rte_flow_conntrack_tcp_last_index)res->li;
14055 conntrack_context.last_seq = res->ls;
14056 conntrack_context.last_ack = res->la;
14057 conntrack_context.last_end = res->le;
14060 cmdline_parse_inst_t cmd_set_conntrack_common = {
14061 .f = cmd_set_conntrack_common_parsed,
14063 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14064 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14065 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14066 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14067 " last_index <flag>",
14069 (void *)&cmd_set_conntrack_set,
14070 (void *)&cmd_set_conntrack_conntrack,
14071 (void *)&cmd_set_conntrack_common_com,
14072 (void *)&cmd_set_conntrack_common_peer,
14073 (void *)&cmd_set_conntrack_common_peer_value,
14074 (void *)&cmd_set_conntrack_common_is_orig,
14075 (void *)&cmd_set_conntrack_common_is_orig_value,
14076 (void *)&cmd_set_conntrack_common_enable,
14077 (void *)&cmd_set_conntrack_common_enable_value,
14078 (void *)&cmd_set_conntrack_common_live,
14079 (void *)&cmd_set_conntrack_common_live_value,
14080 (void *)&cmd_set_conntrack_common_sack,
14081 (void *)&cmd_set_conntrack_common_sack_value,
14082 (void *)&cmd_set_conntrack_common_cack,
14083 (void *)&cmd_set_conntrack_common_cack_value,
14084 (void *)&cmd_set_conntrack_common_last_dir,
14085 (void *)&cmd_set_conntrack_common_last_dir_value,
14086 (void *)&cmd_set_conntrack_common_liberal,
14087 (void *)&cmd_set_conntrack_common_liberal_value,
14088 (void *)&cmd_set_conntrack_common_state,
14089 (void *)&cmd_set_conntrack_common_state_value,
14090 (void *)&cmd_set_conntrack_common_max_ackwin,
14091 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14092 (void *)&cmd_set_conntrack_common_retrans,
14093 (void *)&cmd_set_conntrack_common_retrans_value,
14094 (void *)&cmd_set_conntrack_common_last_win,
14095 (void *)&cmd_set_conntrack_common_last_win_value,
14096 (void *)&cmd_set_conntrack_common_last_seq,
14097 (void *)&cmd_set_conntrack_common_last_seq_value,
14098 (void *)&cmd_set_conntrack_common_last_ack,
14099 (void *)&cmd_set_conntrack_common_last_ack_value,
14100 (void *)&cmd_set_conntrack_common_last_end,
14101 (void *)&cmd_set_conntrack_common_last_end_value,
14102 (void *)&cmd_set_conntrack_common_last_index,
14103 (void *)&cmd_set_conntrack_common_last_index_value,
14108 /** Set connection tracking object both directions' details */
14109 struct cmd_set_conntrack_dir_result {
14110 cmdline_fixed_string_t set;
14111 cmdline_fixed_string_t conntrack;
14112 cmdline_fixed_string_t dir;
14113 cmdline_fixed_string_t scale;
14114 cmdline_fixed_string_t fin;
14115 cmdline_fixed_string_t ack_seen;
14116 cmdline_fixed_string_t unack;
14117 cmdline_fixed_string_t sent_end;
14118 cmdline_fixed_string_t reply_end;
14119 cmdline_fixed_string_t max_win;
14120 cmdline_fixed_string_t max_ack;
14131 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14132 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14134 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14135 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14136 conntrack, "conntrack");
14137 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14138 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14140 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14141 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14143 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14144 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14145 factor, RTE_UINT32);
14146 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14147 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14149 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14150 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14152 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14153 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14154 ack_seen, "acked");
14155 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14156 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14158 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14159 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14160 unack, "unack_data");
14161 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14162 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14164 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14165 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14166 sent_end, "sent_end");
14167 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14168 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14170 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14171 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14172 reply_end, "reply_end");
14173 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14174 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14176 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14177 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14178 max_win, "max_win");
14179 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14180 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14182 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14183 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14184 max_ack, "max_ack");
14185 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14186 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14189 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14190 __rte_unused struct cmdline *cl,
14191 __rte_unused void *data)
14193 struct cmd_set_conntrack_dir_result *res = parsed_result;
14194 struct rte_flow_tcp_dir_param *dir = NULL;
14196 if (strcmp(res->dir, "orig") == 0)
14197 dir = &conntrack_context.original_dir;
14198 else if (strcmp(res->dir, "rply") == 0)
14199 dir = &conntrack_context.reply_dir;
14202 dir->scale = res->factor;
14203 dir->close_initiated = res->f;
14204 dir->last_ack_seen = res->as;
14205 dir->data_unacked = res->un;
14206 dir->sent_end = res->se;
14207 dir->reply_end = res->re;
14208 dir->max_ack = res->ma;
14209 dir->max_win = res->mw;
14212 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14213 .f = cmd_set_conntrack_dir_parsed,
14215 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14216 " acked <seen> unack_data <unack> sent_end <sent>"
14217 " reply_end <reply> max_win <win> max_ack <ack>",
14219 (void *)&cmd_set_conntrack_set,
14220 (void *)&cmd_set_conntrack_conntrack,
14221 (void *)&cmd_set_conntrack_dir_dir,
14222 (void *)&cmd_set_conntrack_dir_scale,
14223 (void *)&cmd_set_conntrack_dir_scale_value,
14224 (void *)&cmd_set_conntrack_dir_fin,
14225 (void *)&cmd_set_conntrack_dir_fin_value,
14226 (void *)&cmd_set_conntrack_dir_ack,
14227 (void *)&cmd_set_conntrack_dir_ack_value,
14228 (void *)&cmd_set_conntrack_dir_unack_data,
14229 (void *)&cmd_set_conntrack_dir_unack_data_value,
14230 (void *)&cmd_set_conntrack_dir_sent_end,
14231 (void *)&cmd_set_conntrack_dir_sent_end_value,
14232 (void *)&cmd_set_conntrack_dir_reply_end,
14233 (void *)&cmd_set_conntrack_dir_reply_end_value,
14234 (void *)&cmd_set_conntrack_dir_max_win,
14235 (void *)&cmd_set_conntrack_dir_max_win_value,
14236 (void *)&cmd_set_conntrack_dir_max_ack,
14237 (void *)&cmd_set_conntrack_dir_max_ack_value,
14242 /* Strict link priority scheduling mode setting */
14244 cmd_strict_link_prio_parsed(
14245 void *parsed_result,
14246 __rte_unused struct cmdline *cl,
14247 __rte_unused void *data)
14249 struct cmd_vf_tc_bw_result *res = parsed_result;
14250 int ret = -ENOTSUP;
14252 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14255 #ifdef RTE_NET_I40E
14256 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14263 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14266 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14269 fprintf(stderr, "function not implemented\n");
14272 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14276 cmdline_parse_inst_t cmd_strict_link_prio = {
14277 .f = cmd_strict_link_prio_parsed,
14279 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14281 (void *)&cmd_vf_tc_bw_set,
14282 (void *)&cmd_vf_tc_bw_tx,
14283 (void *)&cmd_vf_tc_bw_strict_link_prio,
14284 (void *)&cmd_vf_tc_bw_port_id,
14285 (void *)&cmd_vf_tc_bw_tc_map,
14290 /* Load dynamic device personalization*/
14291 struct cmd_ddp_add_result {
14292 cmdline_fixed_string_t ddp;
14293 cmdline_fixed_string_t add;
14298 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14299 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14300 cmdline_parse_token_string_t cmd_ddp_add_add =
14301 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14302 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14303 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14305 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14306 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14309 cmd_ddp_add_parsed(
14310 void *parsed_result,
14311 __rte_unused struct cmdline *cl,
14312 __rte_unused void *data)
14314 struct cmd_ddp_add_result *res = parsed_result;
14320 int ret = -ENOTSUP;
14322 if (!all_ports_stopped()) {
14323 fprintf(stderr, "Please stop all ports first\n");
14327 filepath = strdup(res->filepath);
14328 if (filepath == NULL) {
14329 fprintf(stderr, "Failed to allocate memory\n");
14332 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14334 buff = open_file(file_fld[0], &size);
14336 free((void *)filepath);
14340 #ifdef RTE_NET_I40E
14341 if (ret == -ENOTSUP)
14342 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14344 RTE_PMD_I40E_PKG_OP_WR_ADD);
14347 if (ret == -EEXIST)
14348 fprintf(stderr, "Profile has already existed.\n");
14350 fprintf(stderr, "Failed to load profile.\n");
14351 else if (file_num == 2)
14352 save_file(file_fld[1], buff, size);
14355 free((void *)filepath);
14358 cmdline_parse_inst_t cmd_ddp_add = {
14359 .f = cmd_ddp_add_parsed,
14361 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14363 (void *)&cmd_ddp_add_ddp,
14364 (void *)&cmd_ddp_add_add,
14365 (void *)&cmd_ddp_add_port_id,
14366 (void *)&cmd_ddp_add_filepath,
14371 /* Delete dynamic device personalization*/
14372 struct cmd_ddp_del_result {
14373 cmdline_fixed_string_t ddp;
14374 cmdline_fixed_string_t del;
14379 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14380 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14381 cmdline_parse_token_string_t cmd_ddp_del_del =
14382 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14383 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14384 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14385 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14386 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14389 cmd_ddp_del_parsed(
14390 void *parsed_result,
14391 __rte_unused struct cmdline *cl,
14392 __rte_unused void *data)
14394 struct cmd_ddp_del_result *res = parsed_result;
14397 int ret = -ENOTSUP;
14399 if (!all_ports_stopped()) {
14400 fprintf(stderr, "Please stop all ports first\n");
14404 buff = open_file(res->filepath, &size);
14408 #ifdef RTE_NET_I40E
14409 if (ret == -ENOTSUP)
14410 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14412 RTE_PMD_I40E_PKG_OP_WR_DEL);
14415 if (ret == -EACCES)
14416 fprintf(stderr, "Profile does not exist.\n");
14418 fprintf(stderr, "Failed to delete profile.\n");
14423 cmdline_parse_inst_t cmd_ddp_del = {
14424 .f = cmd_ddp_del_parsed,
14426 .help_str = "ddp del <port_id> <backup_profile_path>",
14428 (void *)&cmd_ddp_del_ddp,
14429 (void *)&cmd_ddp_del_del,
14430 (void *)&cmd_ddp_del_port_id,
14431 (void *)&cmd_ddp_del_filepath,
14436 /* Get dynamic device personalization profile info */
14437 struct cmd_ddp_info_result {
14438 cmdline_fixed_string_t ddp;
14439 cmdline_fixed_string_t get;
14440 cmdline_fixed_string_t info;
14444 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14445 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14446 cmdline_parse_token_string_t cmd_ddp_info_get =
14447 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14448 cmdline_parse_token_string_t cmd_ddp_info_info =
14449 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14450 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14451 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14454 cmd_ddp_info_parsed(
14455 void *parsed_result,
14456 __rte_unused struct cmdline *cl,
14457 __rte_unused void *data)
14459 struct cmd_ddp_info_result *res = parsed_result;
14462 int ret = -ENOTSUP;
14463 #ifdef RTE_NET_I40E
14466 uint32_t buff_size = 0;
14467 struct rte_pmd_i40e_profile_info info;
14468 uint32_t dev_num = 0;
14469 struct rte_pmd_i40e_ddp_device_id *devs;
14470 uint32_t proto_num = 0;
14471 struct rte_pmd_i40e_proto_info *proto = NULL;
14472 uint32_t pctype_num = 0;
14473 struct rte_pmd_i40e_ptype_info *pctype;
14474 uint32_t ptype_num = 0;
14475 struct rte_pmd_i40e_ptype_info *ptype;
14480 pkg = open_file(res->filepath, &pkg_size);
14484 #ifdef RTE_NET_I40E
14485 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14486 (uint8_t *)&info, sizeof(info),
14487 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14489 printf("Global Track id: 0x%x\n", info.track_id);
14490 printf("Global Version: %d.%d.%d.%d\n",
14491 info.version.major,
14492 info.version.minor,
14493 info.version.update,
14494 info.version.draft);
14495 printf("Global Package name: %s\n\n", info.name);
14498 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14499 (uint8_t *)&info, sizeof(info),
14500 RTE_PMD_I40E_PKG_INFO_HEADER);
14502 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14503 printf("i40e Profile Version: %d.%d.%d.%d\n",
14504 info.version.major,
14505 info.version.minor,
14506 info.version.update,
14507 info.version.draft);
14508 printf("i40e Profile name: %s\n\n", info.name);
14511 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14512 (uint8_t *)&buff_size, sizeof(buff_size),
14513 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14514 if (!ret && buff_size) {
14515 buff = (uint8_t *)malloc(buff_size);
14517 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14519 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14521 printf("Package Notes:\n%s\n\n", buff);
14526 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14527 (uint8_t *)&dev_num, sizeof(dev_num),
14528 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14529 if (!ret && dev_num) {
14530 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14531 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14533 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14534 (uint8_t *)devs, buff_size,
14535 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14537 printf("List of supported devices:\n");
14538 for (i = 0; i < dev_num; i++) {
14539 printf(" %04X:%04X %04X:%04X\n",
14540 devs[i].vendor_dev_id >> 16,
14541 devs[i].vendor_dev_id & 0xFFFF,
14542 devs[i].sub_vendor_dev_id >> 16,
14543 devs[i].sub_vendor_dev_id & 0xFFFF);
14551 /* get information about protocols and packet types */
14552 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14553 (uint8_t *)&proto_num, sizeof(proto_num),
14554 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14555 if (ret || !proto_num)
14556 goto no_print_return;
14558 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14559 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14561 goto no_print_return;
14563 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14565 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14567 printf("List of used protocols:\n");
14568 for (i = 0; i < proto_num; i++)
14569 printf(" %2u: %s\n", proto[i].proto_id,
14573 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14574 (uint8_t *)&pctype_num, sizeof(pctype_num),
14575 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14576 if (ret || !pctype_num)
14577 goto no_print_pctypes;
14579 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14580 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14582 goto no_print_pctypes;
14584 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14586 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14589 goto no_print_pctypes;
14592 printf("List of defined packet classification types:\n");
14593 for (i = 0; i < pctype_num; i++) {
14594 printf(" %2u:", pctype[i].ptype_id);
14595 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14596 proto_id = pctype[i].protocols[j];
14597 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14598 for (n = 0; n < proto_num; n++) {
14599 if (proto[n].proto_id == proto_id) {
14600 printf(" %s", proto[n].name);
14613 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14615 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14616 if (ret || !ptype_num)
14617 goto no_print_return;
14619 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14620 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14622 goto no_print_return;
14624 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14626 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14629 goto no_print_return;
14631 printf("List of defined packet types:\n");
14632 for (i = 0; i < ptype_num; i++) {
14633 printf(" %2u:", ptype[i].ptype_id);
14634 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14635 proto_id = ptype[i].protocols[j];
14636 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14637 for (n = 0; n < proto_num; n++) {
14638 if (proto[n].proto_id == proto_id) {
14639 printf(" %s", proto[n].name);
14655 if (ret == -ENOTSUP)
14656 fprintf(stderr, "Function not supported in PMD driver\n");
14660 cmdline_parse_inst_t cmd_ddp_get_info = {
14661 .f = cmd_ddp_info_parsed,
14663 .help_str = "ddp get info <profile_path>",
14665 (void *)&cmd_ddp_info_ddp,
14666 (void *)&cmd_ddp_info_get,
14667 (void *)&cmd_ddp_info_info,
14668 (void *)&cmd_ddp_info_filepath,
14673 /* Get dynamic device personalization profile info list*/
14674 #define PROFILE_INFO_SIZE 48
14675 #define MAX_PROFILE_NUM 16
14677 struct cmd_ddp_get_list_result {
14678 cmdline_fixed_string_t ddp;
14679 cmdline_fixed_string_t get;
14680 cmdline_fixed_string_t list;
14684 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14685 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14686 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14687 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14688 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14689 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14690 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14691 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14695 cmd_ddp_get_list_parsed(
14696 __rte_unused void *parsed_result,
14697 __rte_unused struct cmdline *cl,
14698 __rte_unused void *data)
14700 #ifdef RTE_NET_I40E
14701 struct cmd_ddp_get_list_result *res = parsed_result;
14702 struct rte_pmd_i40e_profile_list *p_list;
14703 struct rte_pmd_i40e_profile_info *p_info;
14708 int ret = -ENOTSUP;
14710 #ifdef RTE_NET_I40E
14711 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14712 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14714 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14718 if (ret == -ENOTSUP)
14719 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14720 (uint8_t *)p_list, size);
14723 p_num = p_list->p_count;
14724 printf("Profile number is: %d\n\n", p_num);
14726 for (i = 0; i < p_num; i++) {
14727 p_info = &p_list->p_info[i];
14728 printf("Profile %d:\n", i);
14729 printf("Track id: 0x%x\n", p_info->track_id);
14730 printf("Version: %d.%d.%d.%d\n",
14731 p_info->version.major,
14732 p_info->version.minor,
14733 p_info->version.update,
14734 p_info->version.draft);
14735 printf("Profile name: %s\n\n", p_info->name);
14743 fprintf(stderr, "Failed to get ddp list\n");
14746 cmdline_parse_inst_t cmd_ddp_get_list = {
14747 .f = cmd_ddp_get_list_parsed,
14749 .help_str = "ddp get list <port_id>",
14751 (void *)&cmd_ddp_get_list_ddp,
14752 (void *)&cmd_ddp_get_list_get,
14753 (void *)&cmd_ddp_get_list_list,
14754 (void *)&cmd_ddp_get_list_port_id,
14759 /* Configure input set */
14760 struct cmd_cfg_input_set_result {
14761 cmdline_fixed_string_t port;
14762 cmdline_fixed_string_t cfg;
14764 cmdline_fixed_string_t pctype;
14766 cmdline_fixed_string_t inset_type;
14767 cmdline_fixed_string_t opt;
14768 cmdline_fixed_string_t field;
14773 cmd_cfg_input_set_parsed(
14774 __rte_unused void *parsed_result,
14775 __rte_unused struct cmdline *cl,
14776 __rte_unused void *data)
14778 #ifdef RTE_NET_I40E
14779 struct cmd_cfg_input_set_result *res = parsed_result;
14780 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14781 struct rte_pmd_i40e_inset inset;
14783 int ret = -ENOTSUP;
14785 if (!all_ports_stopped()) {
14786 fprintf(stderr, "Please stop all ports first\n");
14790 #ifdef RTE_NET_I40E
14791 if (!strcmp(res->inset_type, "hash_inset"))
14792 inset_type = INSET_HASH;
14793 else if (!strcmp(res->inset_type, "fdir_inset"))
14794 inset_type = INSET_FDIR;
14795 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14796 inset_type = INSET_FDIR_FLX;
14797 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14798 &inset, inset_type);
14800 fprintf(stderr, "Failed to get input set.\n");
14804 if (!strcmp(res->opt, "get")) {
14805 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14808 printf("Field index %d is enabled.\n", res->field_idx);
14810 printf("Field index %d is disabled.\n", res->field_idx);
14812 } else if (!strcmp(res->opt, "set"))
14813 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14815 else if (!strcmp(res->opt, "clear"))
14816 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14819 fprintf(stderr, "Failed to configure input set field.\n");
14823 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14824 &inset, inset_type);
14826 fprintf(stderr, "Failed to set input set.\n");
14831 if (ret == -ENOTSUP)
14832 fprintf(stderr, "Function not supported\n");
14835 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14836 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14838 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14839 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14841 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14842 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14843 port_id, RTE_UINT16);
14844 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14845 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14847 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14848 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14849 pctype_id, RTE_UINT8);
14850 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14851 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14853 "hash_inset#fdir_inset#fdir_flx_inset");
14854 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14855 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14856 opt, "get#set#clear");
14857 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14858 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14860 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14861 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14862 field_idx, RTE_UINT8);
14864 cmdline_parse_inst_t cmd_cfg_input_set = {
14865 .f = cmd_cfg_input_set_parsed,
14867 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14868 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14870 (void *)&cmd_cfg_input_set_port,
14871 (void *)&cmd_cfg_input_set_cfg,
14872 (void *)&cmd_cfg_input_set_port_id,
14873 (void *)&cmd_cfg_input_set_pctype,
14874 (void *)&cmd_cfg_input_set_pctype_id,
14875 (void *)&cmd_cfg_input_set_inset_type,
14876 (void *)&cmd_cfg_input_set_opt,
14877 (void *)&cmd_cfg_input_set_field,
14878 (void *)&cmd_cfg_input_set_field_idx,
14883 /* Clear input set */
14884 struct cmd_clear_input_set_result {
14885 cmdline_fixed_string_t port;
14886 cmdline_fixed_string_t cfg;
14888 cmdline_fixed_string_t pctype;
14890 cmdline_fixed_string_t inset_type;
14891 cmdline_fixed_string_t clear;
14892 cmdline_fixed_string_t all;
14896 cmd_clear_input_set_parsed(
14897 __rte_unused void *parsed_result,
14898 __rte_unused struct cmdline *cl,
14899 __rte_unused void *data)
14901 #ifdef RTE_NET_I40E
14902 struct cmd_clear_input_set_result *res = parsed_result;
14903 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14904 struct rte_pmd_i40e_inset inset;
14906 int ret = -ENOTSUP;
14908 if (!all_ports_stopped()) {
14909 fprintf(stderr, "Please stop all ports first\n");
14913 #ifdef RTE_NET_I40E
14914 if (!strcmp(res->inset_type, "hash_inset"))
14915 inset_type = INSET_HASH;
14916 else if (!strcmp(res->inset_type, "fdir_inset"))
14917 inset_type = INSET_FDIR;
14918 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14919 inset_type = INSET_FDIR_FLX;
14921 memset(&inset, 0, sizeof(inset));
14923 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14924 &inset, inset_type);
14926 fprintf(stderr, "Failed to clear input set.\n");
14932 if (ret == -ENOTSUP)
14933 fprintf(stderr, "Function not supported\n");
14936 cmdline_parse_token_string_t cmd_clear_input_set_port =
14937 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14939 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14940 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14942 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14943 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14944 port_id, RTE_UINT16);
14945 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14946 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14948 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14949 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14950 pctype_id, RTE_UINT8);
14951 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14952 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14954 "hash_inset#fdir_inset#fdir_flx_inset");
14955 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14956 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14958 cmdline_parse_token_string_t cmd_clear_input_set_all =
14959 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14962 cmdline_parse_inst_t cmd_clear_input_set = {
14963 .f = cmd_clear_input_set_parsed,
14965 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14966 "fdir_inset|fdir_flx_inset clear all",
14968 (void *)&cmd_clear_input_set_port,
14969 (void *)&cmd_clear_input_set_cfg,
14970 (void *)&cmd_clear_input_set_port_id,
14971 (void *)&cmd_clear_input_set_pctype,
14972 (void *)&cmd_clear_input_set_pctype_id,
14973 (void *)&cmd_clear_input_set_inset_type,
14974 (void *)&cmd_clear_input_set_clear,
14975 (void *)&cmd_clear_input_set_all,
14980 /* show vf stats */
14982 /* Common result structure for show vf stats */
14983 struct cmd_show_vf_stats_result {
14984 cmdline_fixed_string_t show;
14985 cmdline_fixed_string_t vf;
14986 cmdline_fixed_string_t stats;
14991 /* Common CLI fields show vf stats*/
14992 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14993 TOKEN_STRING_INITIALIZER
14994 (struct cmd_show_vf_stats_result,
14996 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14997 TOKEN_STRING_INITIALIZER
14998 (struct cmd_show_vf_stats_result,
15000 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15001 TOKEN_STRING_INITIALIZER
15002 (struct cmd_show_vf_stats_result,
15004 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15005 TOKEN_NUM_INITIALIZER
15006 (struct cmd_show_vf_stats_result,
15007 port_id, RTE_UINT16);
15008 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15009 TOKEN_NUM_INITIALIZER
15010 (struct cmd_show_vf_stats_result,
15011 vf_id, RTE_UINT16);
15014 cmd_show_vf_stats_parsed(
15015 void *parsed_result,
15016 __rte_unused struct cmdline *cl,
15017 __rte_unused void *data)
15019 struct cmd_show_vf_stats_result *res = parsed_result;
15020 struct rte_eth_stats stats;
15021 int ret = -ENOTSUP;
15022 static const char *nic_stats_border = "########################";
15024 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15027 memset(&stats, 0, sizeof(stats));
15029 #ifdef RTE_NET_I40E
15030 if (ret == -ENOTSUP)
15031 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15035 #ifdef RTE_NET_BNXT
15036 if (ret == -ENOTSUP)
15037 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15046 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15049 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15052 fprintf(stderr, "function not implemented\n");
15055 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15058 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15059 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15061 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15063 stats.ipackets, stats.imissed, stats.ibytes);
15064 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15065 printf(" RX-nombuf: %-10"PRIu64"\n",
15067 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15069 stats.opackets, stats.oerrors, stats.obytes);
15071 printf(" %s############################%s\n",
15072 nic_stats_border, nic_stats_border);
15075 cmdline_parse_inst_t cmd_show_vf_stats = {
15076 .f = cmd_show_vf_stats_parsed,
15078 .help_str = "show vf stats <port_id> <vf_id>",
15080 (void *)&cmd_show_vf_stats_show,
15081 (void *)&cmd_show_vf_stats_vf,
15082 (void *)&cmd_show_vf_stats_stats,
15083 (void *)&cmd_show_vf_stats_port_id,
15084 (void *)&cmd_show_vf_stats_vf_id,
15089 /* clear vf stats */
15091 /* Common result structure for clear vf stats */
15092 struct cmd_clear_vf_stats_result {
15093 cmdline_fixed_string_t clear;
15094 cmdline_fixed_string_t vf;
15095 cmdline_fixed_string_t stats;
15100 /* Common CLI fields clear vf stats*/
15101 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15102 TOKEN_STRING_INITIALIZER
15103 (struct cmd_clear_vf_stats_result,
15105 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15106 TOKEN_STRING_INITIALIZER
15107 (struct cmd_clear_vf_stats_result,
15109 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15110 TOKEN_STRING_INITIALIZER
15111 (struct cmd_clear_vf_stats_result,
15113 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15114 TOKEN_NUM_INITIALIZER
15115 (struct cmd_clear_vf_stats_result,
15116 port_id, RTE_UINT16);
15117 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15118 TOKEN_NUM_INITIALIZER
15119 (struct cmd_clear_vf_stats_result,
15120 vf_id, RTE_UINT16);
15123 cmd_clear_vf_stats_parsed(
15124 void *parsed_result,
15125 __rte_unused struct cmdline *cl,
15126 __rte_unused void *data)
15128 struct cmd_clear_vf_stats_result *res = parsed_result;
15129 int ret = -ENOTSUP;
15131 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15134 #ifdef RTE_NET_I40E
15135 if (ret == -ENOTSUP)
15136 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15139 #ifdef RTE_NET_BNXT
15140 if (ret == -ENOTSUP)
15141 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15149 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15152 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15155 fprintf(stderr, "function not implemented\n");
15158 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15162 cmdline_parse_inst_t cmd_clear_vf_stats = {
15163 .f = cmd_clear_vf_stats_parsed,
15165 .help_str = "clear vf stats <port_id> <vf_id>",
15167 (void *)&cmd_clear_vf_stats_clear,
15168 (void *)&cmd_clear_vf_stats_vf,
15169 (void *)&cmd_clear_vf_stats_stats,
15170 (void *)&cmd_clear_vf_stats_port_id,
15171 (void *)&cmd_clear_vf_stats_vf_id,
15176 /* port config pctype mapping reset */
15178 /* Common result structure for port config pctype mapping reset */
15179 struct cmd_pctype_mapping_reset_result {
15180 cmdline_fixed_string_t port;
15181 cmdline_fixed_string_t config;
15183 cmdline_fixed_string_t pctype;
15184 cmdline_fixed_string_t mapping;
15185 cmdline_fixed_string_t reset;
15188 /* Common CLI fields for port config pctype mapping reset*/
15189 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15190 TOKEN_STRING_INITIALIZER
15191 (struct cmd_pctype_mapping_reset_result,
15193 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15194 TOKEN_STRING_INITIALIZER
15195 (struct cmd_pctype_mapping_reset_result,
15197 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15198 TOKEN_NUM_INITIALIZER
15199 (struct cmd_pctype_mapping_reset_result,
15200 port_id, RTE_UINT16);
15201 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15202 TOKEN_STRING_INITIALIZER
15203 (struct cmd_pctype_mapping_reset_result,
15205 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15206 TOKEN_STRING_INITIALIZER
15207 (struct cmd_pctype_mapping_reset_result,
15208 mapping, "mapping");
15209 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15210 TOKEN_STRING_INITIALIZER
15211 (struct cmd_pctype_mapping_reset_result,
15215 cmd_pctype_mapping_reset_parsed(
15216 void *parsed_result,
15217 __rte_unused struct cmdline *cl,
15218 __rte_unused void *data)
15220 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15221 int ret = -ENOTSUP;
15223 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15226 #ifdef RTE_NET_I40E
15227 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15234 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15237 fprintf(stderr, "function not implemented\n");
15240 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15244 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15245 .f = cmd_pctype_mapping_reset_parsed,
15247 .help_str = "port config <port_id> pctype mapping reset",
15249 (void *)&cmd_pctype_mapping_reset_port,
15250 (void *)&cmd_pctype_mapping_reset_config,
15251 (void *)&cmd_pctype_mapping_reset_port_id,
15252 (void *)&cmd_pctype_mapping_reset_pctype,
15253 (void *)&cmd_pctype_mapping_reset_mapping,
15254 (void *)&cmd_pctype_mapping_reset_reset,
15259 /* show port pctype mapping */
15261 /* Common result structure for show port pctype mapping */
15262 struct cmd_pctype_mapping_get_result {
15263 cmdline_fixed_string_t show;
15264 cmdline_fixed_string_t port;
15266 cmdline_fixed_string_t pctype;
15267 cmdline_fixed_string_t mapping;
15270 /* Common CLI fields for pctype mapping get */
15271 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15272 TOKEN_STRING_INITIALIZER
15273 (struct cmd_pctype_mapping_get_result,
15275 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15276 TOKEN_STRING_INITIALIZER
15277 (struct cmd_pctype_mapping_get_result,
15279 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15280 TOKEN_NUM_INITIALIZER
15281 (struct cmd_pctype_mapping_get_result,
15282 port_id, RTE_UINT16);
15283 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15284 TOKEN_STRING_INITIALIZER
15285 (struct cmd_pctype_mapping_get_result,
15287 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15288 TOKEN_STRING_INITIALIZER
15289 (struct cmd_pctype_mapping_get_result,
15290 mapping, "mapping");
15293 cmd_pctype_mapping_get_parsed(
15294 void *parsed_result,
15295 __rte_unused struct cmdline *cl,
15296 __rte_unused void *data)
15298 struct cmd_pctype_mapping_get_result *res = parsed_result;
15299 int ret = -ENOTSUP;
15300 #ifdef RTE_NET_I40E
15301 struct rte_pmd_i40e_flow_type_mapping
15302 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15303 int i, j, first_pctype;
15306 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15309 #ifdef RTE_NET_I40E
15310 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15317 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15320 fprintf(stderr, "function not implemented\n");
15323 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15327 #ifdef RTE_NET_I40E
15328 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15329 if (mapping[i].pctype != 0ULL) {
15332 printf("pctype: ");
15333 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15334 if (mapping[i].pctype & (1ULL << j)) {
15335 printf(first_pctype ?
15336 "%02d" : ",%02d", j);
15340 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15346 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15347 .f = cmd_pctype_mapping_get_parsed,
15349 .help_str = "show port <port_id> pctype mapping",
15351 (void *)&cmd_pctype_mapping_get_show,
15352 (void *)&cmd_pctype_mapping_get_port,
15353 (void *)&cmd_pctype_mapping_get_port_id,
15354 (void *)&cmd_pctype_mapping_get_pctype,
15355 (void *)&cmd_pctype_mapping_get_mapping,
15360 /* port config pctype mapping update */
15362 /* Common result structure for port config pctype mapping update */
15363 struct cmd_pctype_mapping_update_result {
15364 cmdline_fixed_string_t port;
15365 cmdline_fixed_string_t config;
15367 cmdline_fixed_string_t pctype;
15368 cmdline_fixed_string_t mapping;
15369 cmdline_fixed_string_t update;
15370 cmdline_fixed_string_t pctype_list;
15371 uint16_t flow_type;
15374 /* Common CLI fields for pctype mapping update*/
15375 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15376 TOKEN_STRING_INITIALIZER
15377 (struct cmd_pctype_mapping_update_result,
15379 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15380 TOKEN_STRING_INITIALIZER
15381 (struct cmd_pctype_mapping_update_result,
15383 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15384 TOKEN_NUM_INITIALIZER
15385 (struct cmd_pctype_mapping_update_result,
15386 port_id, RTE_UINT16);
15387 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15388 TOKEN_STRING_INITIALIZER
15389 (struct cmd_pctype_mapping_update_result,
15391 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15392 TOKEN_STRING_INITIALIZER
15393 (struct cmd_pctype_mapping_update_result,
15394 mapping, "mapping");
15395 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15396 TOKEN_STRING_INITIALIZER
15397 (struct cmd_pctype_mapping_update_result,
15399 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15400 TOKEN_STRING_INITIALIZER
15401 (struct cmd_pctype_mapping_update_result,
15402 pctype_list, NULL);
15403 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15404 TOKEN_NUM_INITIALIZER
15405 (struct cmd_pctype_mapping_update_result,
15406 flow_type, RTE_UINT16);
15409 cmd_pctype_mapping_update_parsed(
15410 void *parsed_result,
15411 __rte_unused struct cmdline *cl,
15412 __rte_unused void *data)
15414 struct cmd_pctype_mapping_update_result *res = parsed_result;
15415 int ret = -ENOTSUP;
15416 #ifdef RTE_NET_I40E
15417 struct rte_pmd_i40e_flow_type_mapping mapping;
15419 unsigned int nb_item;
15420 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15423 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15426 #ifdef RTE_NET_I40E
15427 nb_item = parse_item_list(res->pctype_list, "pctypes",
15428 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15429 mapping.flow_type = res->flow_type;
15430 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15431 mapping.pctype |= (1ULL << pctype_list[i]);
15432 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15442 fprintf(stderr, "invalid pctype or flow type\n");
15445 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15448 fprintf(stderr, "function not implemented\n");
15451 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15455 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15456 .f = cmd_pctype_mapping_update_parsed,
15458 .help_str = "port config <port_id> pctype mapping update"
15459 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15461 (void *)&cmd_pctype_mapping_update_port,
15462 (void *)&cmd_pctype_mapping_update_config,
15463 (void *)&cmd_pctype_mapping_update_port_id,
15464 (void *)&cmd_pctype_mapping_update_pctype,
15465 (void *)&cmd_pctype_mapping_update_mapping,
15466 (void *)&cmd_pctype_mapping_update_update,
15467 (void *)&cmd_pctype_mapping_update_pc_type,
15468 (void *)&cmd_pctype_mapping_update_flow_type,
15473 /* ptype mapping get */
15475 /* Common result structure for ptype mapping get */
15476 struct cmd_ptype_mapping_get_result {
15477 cmdline_fixed_string_t ptype;
15478 cmdline_fixed_string_t mapping;
15479 cmdline_fixed_string_t get;
15481 uint8_t valid_only;
15484 /* Common CLI fields for ptype mapping get */
15485 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15486 TOKEN_STRING_INITIALIZER
15487 (struct cmd_ptype_mapping_get_result,
15489 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15490 TOKEN_STRING_INITIALIZER
15491 (struct cmd_ptype_mapping_get_result,
15492 mapping, "mapping");
15493 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15494 TOKEN_STRING_INITIALIZER
15495 (struct cmd_ptype_mapping_get_result,
15497 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15498 TOKEN_NUM_INITIALIZER
15499 (struct cmd_ptype_mapping_get_result,
15500 port_id, RTE_UINT16);
15501 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15502 TOKEN_NUM_INITIALIZER
15503 (struct cmd_ptype_mapping_get_result,
15504 valid_only, RTE_UINT8);
15507 cmd_ptype_mapping_get_parsed(
15508 void *parsed_result,
15509 __rte_unused struct cmdline *cl,
15510 __rte_unused void *data)
15512 struct cmd_ptype_mapping_get_result *res = parsed_result;
15513 int ret = -ENOTSUP;
15514 #ifdef RTE_NET_I40E
15515 int max_ptype_num = 256;
15516 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15521 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15524 #ifdef RTE_NET_I40E
15525 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15536 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15539 fprintf(stderr, "function not implemented\n");
15542 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15545 #ifdef RTE_NET_I40E
15547 for (i = 0; i < count; i++)
15548 printf("%3d\t0x%08x\n",
15549 mapping[i].hw_ptype, mapping[i].sw_ptype);
15554 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15555 .f = cmd_ptype_mapping_get_parsed,
15557 .help_str = "ptype mapping get <port_id> <valid_only>",
15559 (void *)&cmd_ptype_mapping_get_ptype,
15560 (void *)&cmd_ptype_mapping_get_mapping,
15561 (void *)&cmd_ptype_mapping_get_get,
15562 (void *)&cmd_ptype_mapping_get_port_id,
15563 (void *)&cmd_ptype_mapping_get_valid_only,
15568 /* ptype mapping replace */
15570 /* Common result structure for ptype mapping replace */
15571 struct cmd_ptype_mapping_replace_result {
15572 cmdline_fixed_string_t ptype;
15573 cmdline_fixed_string_t mapping;
15574 cmdline_fixed_string_t replace;
15581 /* Common CLI fields for ptype mapping replace */
15582 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15583 TOKEN_STRING_INITIALIZER
15584 (struct cmd_ptype_mapping_replace_result,
15586 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15587 TOKEN_STRING_INITIALIZER
15588 (struct cmd_ptype_mapping_replace_result,
15589 mapping, "mapping");
15590 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15591 TOKEN_STRING_INITIALIZER
15592 (struct cmd_ptype_mapping_replace_result,
15593 replace, "replace");
15594 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15595 TOKEN_NUM_INITIALIZER
15596 (struct cmd_ptype_mapping_replace_result,
15597 port_id, RTE_UINT16);
15598 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15599 TOKEN_NUM_INITIALIZER
15600 (struct cmd_ptype_mapping_replace_result,
15601 target, RTE_UINT32);
15602 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15603 TOKEN_NUM_INITIALIZER
15604 (struct cmd_ptype_mapping_replace_result,
15606 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15607 TOKEN_NUM_INITIALIZER
15608 (struct cmd_ptype_mapping_replace_result,
15609 pkt_type, RTE_UINT32);
15612 cmd_ptype_mapping_replace_parsed(
15613 void *parsed_result,
15614 __rte_unused struct cmdline *cl,
15615 __rte_unused void *data)
15617 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15618 int ret = -ENOTSUP;
15620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15623 #ifdef RTE_NET_I40E
15624 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15634 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15635 res->target, res->pkt_type);
15638 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15641 fprintf(stderr, "function not implemented\n");
15644 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15648 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15649 .f = cmd_ptype_mapping_replace_parsed,
15652 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15654 (void *)&cmd_ptype_mapping_replace_ptype,
15655 (void *)&cmd_ptype_mapping_replace_mapping,
15656 (void *)&cmd_ptype_mapping_replace_replace,
15657 (void *)&cmd_ptype_mapping_replace_port_id,
15658 (void *)&cmd_ptype_mapping_replace_target,
15659 (void *)&cmd_ptype_mapping_replace_mask,
15660 (void *)&cmd_ptype_mapping_replace_pkt_type,
15665 /* ptype mapping reset */
15667 /* Common result structure for ptype mapping reset */
15668 struct cmd_ptype_mapping_reset_result {
15669 cmdline_fixed_string_t ptype;
15670 cmdline_fixed_string_t mapping;
15671 cmdline_fixed_string_t reset;
15675 /* Common CLI fields for ptype mapping reset*/
15676 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15677 TOKEN_STRING_INITIALIZER
15678 (struct cmd_ptype_mapping_reset_result,
15680 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15681 TOKEN_STRING_INITIALIZER
15682 (struct cmd_ptype_mapping_reset_result,
15683 mapping, "mapping");
15684 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15685 TOKEN_STRING_INITIALIZER
15686 (struct cmd_ptype_mapping_reset_result,
15688 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15689 TOKEN_NUM_INITIALIZER
15690 (struct cmd_ptype_mapping_reset_result,
15691 port_id, RTE_UINT16);
15694 cmd_ptype_mapping_reset_parsed(
15695 void *parsed_result,
15696 __rte_unused struct cmdline *cl,
15697 __rte_unused void *data)
15699 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15700 int ret = -ENOTSUP;
15702 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15705 #ifdef RTE_NET_I40E
15706 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15713 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15716 fprintf(stderr, "function not implemented\n");
15719 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15723 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15724 .f = cmd_ptype_mapping_reset_parsed,
15726 .help_str = "ptype mapping reset <port_id>",
15728 (void *)&cmd_ptype_mapping_reset_ptype,
15729 (void *)&cmd_ptype_mapping_reset_mapping,
15730 (void *)&cmd_ptype_mapping_reset_reset,
15731 (void *)&cmd_ptype_mapping_reset_port_id,
15736 /* ptype mapping update */
15738 /* Common result structure for ptype mapping update */
15739 struct cmd_ptype_mapping_update_result {
15740 cmdline_fixed_string_t ptype;
15741 cmdline_fixed_string_t mapping;
15742 cmdline_fixed_string_t reset;
15748 /* Common CLI fields for ptype mapping update*/
15749 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15750 TOKEN_STRING_INITIALIZER
15751 (struct cmd_ptype_mapping_update_result,
15753 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15754 TOKEN_STRING_INITIALIZER
15755 (struct cmd_ptype_mapping_update_result,
15756 mapping, "mapping");
15757 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15758 TOKEN_STRING_INITIALIZER
15759 (struct cmd_ptype_mapping_update_result,
15761 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15762 TOKEN_NUM_INITIALIZER
15763 (struct cmd_ptype_mapping_update_result,
15764 port_id, RTE_UINT16);
15765 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15766 TOKEN_NUM_INITIALIZER
15767 (struct cmd_ptype_mapping_update_result,
15768 hw_ptype, RTE_UINT8);
15769 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15770 TOKEN_NUM_INITIALIZER
15771 (struct cmd_ptype_mapping_update_result,
15772 sw_ptype, RTE_UINT32);
15775 cmd_ptype_mapping_update_parsed(
15776 void *parsed_result,
15777 __rte_unused struct cmdline *cl,
15778 __rte_unused void *data)
15780 struct cmd_ptype_mapping_update_result *res = parsed_result;
15781 int ret = -ENOTSUP;
15782 #ifdef RTE_NET_I40E
15783 struct rte_pmd_i40e_ptype_mapping mapping;
15785 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15788 #ifdef RTE_NET_I40E
15789 mapping.hw_ptype = res->hw_ptype;
15790 mapping.sw_ptype = res->sw_ptype;
15791 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15801 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15804 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15807 fprintf(stderr, "function not implemented\n");
15810 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15814 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15815 .f = cmd_ptype_mapping_update_parsed,
15817 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15819 (void *)&cmd_ptype_mapping_update_ptype,
15820 (void *)&cmd_ptype_mapping_update_mapping,
15821 (void *)&cmd_ptype_mapping_update_update,
15822 (void *)&cmd_ptype_mapping_update_port_id,
15823 (void *)&cmd_ptype_mapping_update_hw_ptype,
15824 (void *)&cmd_ptype_mapping_update_sw_ptype,
15829 /* Common result structure for file commands */
15830 struct cmd_cmdfile_result {
15831 cmdline_fixed_string_t load;
15832 cmdline_fixed_string_t filename;
15835 /* Common CLI fields for file commands */
15836 cmdline_parse_token_string_t cmd_load_cmdfile =
15837 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15838 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15839 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15842 cmd_load_from_file_parsed(
15843 void *parsed_result,
15844 __rte_unused struct cmdline *cl,
15845 __rte_unused void *data)
15847 struct cmd_cmdfile_result *res = parsed_result;
15849 cmdline_read_from_file(res->filename);
15852 cmdline_parse_inst_t cmd_load_from_file = {
15853 .f = cmd_load_from_file_parsed,
15855 .help_str = "load <filename>",
15857 (void *)&cmd_load_cmdfile,
15858 (void *)&cmd_load_cmdfile_filename,
15863 /* Get Rx offloads capabilities */
15864 struct cmd_rx_offload_get_capa_result {
15865 cmdline_fixed_string_t show;
15866 cmdline_fixed_string_t port;
15868 cmdline_fixed_string_t rx_offload;
15869 cmdline_fixed_string_t capabilities;
15872 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15873 TOKEN_STRING_INITIALIZER
15874 (struct cmd_rx_offload_get_capa_result,
15876 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15877 TOKEN_STRING_INITIALIZER
15878 (struct cmd_rx_offload_get_capa_result,
15880 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15881 TOKEN_NUM_INITIALIZER
15882 (struct cmd_rx_offload_get_capa_result,
15883 port_id, RTE_UINT16);
15884 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15885 TOKEN_STRING_INITIALIZER
15886 (struct cmd_rx_offload_get_capa_result,
15887 rx_offload, "rx_offload");
15888 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15889 TOKEN_STRING_INITIALIZER
15890 (struct cmd_rx_offload_get_capa_result,
15891 capabilities, "capabilities");
15894 print_rx_offloads(uint64_t offloads)
15896 uint64_t single_offload;
15904 begin = __builtin_ctzll(offloads);
15905 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15907 single_offload = 1ULL << begin;
15908 for (bit = begin; bit < end; bit++) {
15909 if (offloads & single_offload)
15911 rte_eth_dev_rx_offload_name(single_offload));
15912 single_offload <<= 1;
15917 cmd_rx_offload_get_capa_parsed(
15918 void *parsed_result,
15919 __rte_unused struct cmdline *cl,
15920 __rte_unused void *data)
15922 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15923 struct rte_eth_dev_info dev_info;
15924 portid_t port_id = res->port_id;
15925 uint64_t queue_offloads;
15926 uint64_t port_offloads;
15929 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15933 queue_offloads = dev_info.rx_queue_offload_capa;
15934 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15936 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15937 printf(" Per Queue :");
15938 print_rx_offloads(queue_offloads);
15941 printf(" Per Port :");
15942 print_rx_offloads(port_offloads);
15946 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15947 .f = cmd_rx_offload_get_capa_parsed,
15949 .help_str = "show port <port_id> rx_offload capabilities",
15951 (void *)&cmd_rx_offload_get_capa_show,
15952 (void *)&cmd_rx_offload_get_capa_port,
15953 (void *)&cmd_rx_offload_get_capa_port_id,
15954 (void *)&cmd_rx_offload_get_capa_rx_offload,
15955 (void *)&cmd_rx_offload_get_capa_capabilities,
15960 /* Get Rx offloads configuration */
15961 struct cmd_rx_offload_get_configuration_result {
15962 cmdline_fixed_string_t show;
15963 cmdline_fixed_string_t port;
15965 cmdline_fixed_string_t rx_offload;
15966 cmdline_fixed_string_t configuration;
15969 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15970 TOKEN_STRING_INITIALIZER
15971 (struct cmd_rx_offload_get_configuration_result,
15973 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15974 TOKEN_STRING_INITIALIZER
15975 (struct cmd_rx_offload_get_configuration_result,
15977 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15978 TOKEN_NUM_INITIALIZER
15979 (struct cmd_rx_offload_get_configuration_result,
15980 port_id, RTE_UINT16);
15981 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15982 TOKEN_STRING_INITIALIZER
15983 (struct cmd_rx_offload_get_configuration_result,
15984 rx_offload, "rx_offload");
15985 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15986 TOKEN_STRING_INITIALIZER
15987 (struct cmd_rx_offload_get_configuration_result,
15988 configuration, "configuration");
15991 cmd_rx_offload_get_configuration_parsed(
15992 void *parsed_result,
15993 __rte_unused struct cmdline *cl,
15994 __rte_unused void *data)
15996 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15997 struct rte_eth_dev_info dev_info;
15998 portid_t port_id = res->port_id;
15999 struct rte_port *port = &ports[port_id];
16000 uint64_t port_offloads;
16001 uint64_t queue_offloads;
16002 uint16_t nb_rx_queues;
16006 printf("Rx Offloading Configuration of port %d :\n", port_id);
16008 port_offloads = port->dev_conf.rxmode.offloads;
16010 print_rx_offloads(port_offloads);
16013 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16017 nb_rx_queues = dev_info.nb_rx_queues;
16018 for (q = 0; q < nb_rx_queues; q++) {
16019 queue_offloads = port->rx_conf[q].offloads;
16020 printf(" Queue[%2d] :", q);
16021 print_rx_offloads(queue_offloads);
16027 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16028 .f = cmd_rx_offload_get_configuration_parsed,
16030 .help_str = "show port <port_id> rx_offload configuration",
16032 (void *)&cmd_rx_offload_get_configuration_show,
16033 (void *)&cmd_rx_offload_get_configuration_port,
16034 (void *)&cmd_rx_offload_get_configuration_port_id,
16035 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16036 (void *)&cmd_rx_offload_get_configuration_configuration,
16041 /* Enable/Disable a per port offloading */
16042 struct cmd_config_per_port_rx_offload_result {
16043 cmdline_fixed_string_t port;
16044 cmdline_fixed_string_t config;
16046 cmdline_fixed_string_t rx_offload;
16047 cmdline_fixed_string_t offload;
16048 cmdline_fixed_string_t on_off;
16051 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16052 TOKEN_STRING_INITIALIZER
16053 (struct cmd_config_per_port_rx_offload_result,
16055 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16056 TOKEN_STRING_INITIALIZER
16057 (struct cmd_config_per_port_rx_offload_result,
16059 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16060 TOKEN_NUM_INITIALIZER
16061 (struct cmd_config_per_port_rx_offload_result,
16062 port_id, RTE_UINT16);
16063 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16064 TOKEN_STRING_INITIALIZER
16065 (struct cmd_config_per_port_rx_offload_result,
16066 rx_offload, "rx_offload");
16067 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16068 TOKEN_STRING_INITIALIZER
16069 (struct cmd_config_per_port_rx_offload_result,
16070 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16071 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16072 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16073 "scatter#buffer_split#timestamp#security#"
16074 "keep_crc#rss_hash");
16075 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16076 TOKEN_STRING_INITIALIZER
16077 (struct cmd_config_per_port_rx_offload_result,
16081 search_rx_offload(const char *name)
16083 uint64_t single_offload;
16084 const char *single_name;
16088 single_offload = 1;
16089 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16090 single_name = rte_eth_dev_rx_offload_name(single_offload);
16091 if (!strcasecmp(single_name, name)) {
16095 single_offload <<= 1;
16099 return single_offload;
16105 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16106 __rte_unused struct cmdline *cl,
16107 __rte_unused void *data)
16109 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16110 portid_t port_id = res->port_id;
16111 struct rte_eth_dev_info dev_info;
16112 struct rte_port *port = &ports[port_id];
16113 uint64_t single_offload;
16114 uint16_t nb_rx_queues;
16118 if (port->port_status != RTE_PORT_STOPPED) {
16120 "Error: Can't config offload when Port %d is not stopped\n",
16125 single_offload = search_rx_offload(res->offload);
16126 if (single_offload == 0) {
16127 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16131 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16135 nb_rx_queues = dev_info.nb_rx_queues;
16136 if (!strcmp(res->on_off, "on")) {
16137 port->dev_conf.rxmode.offloads |= single_offload;
16138 for (q = 0; q < nb_rx_queues; q++)
16139 port->rx_conf[q].offloads |= single_offload;
16141 port->dev_conf.rxmode.offloads &= ~single_offload;
16142 for (q = 0; q < nb_rx_queues; q++)
16143 port->rx_conf[q].offloads &= ~single_offload;
16146 cmd_reconfig_device_queue(port_id, 1, 1);
16149 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16150 .f = cmd_config_per_port_rx_offload_parsed,
16152 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16153 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16154 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16155 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16156 "keep_crc|rss_hash on|off",
16158 (void *)&cmd_config_per_port_rx_offload_result_port,
16159 (void *)&cmd_config_per_port_rx_offload_result_config,
16160 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16161 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16162 (void *)&cmd_config_per_port_rx_offload_result_offload,
16163 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16168 /* Enable/Disable a per queue offloading */
16169 struct cmd_config_per_queue_rx_offload_result {
16170 cmdline_fixed_string_t port;
16172 cmdline_fixed_string_t rxq;
16174 cmdline_fixed_string_t rx_offload;
16175 cmdline_fixed_string_t offload;
16176 cmdline_fixed_string_t on_off;
16179 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16180 TOKEN_STRING_INITIALIZER
16181 (struct cmd_config_per_queue_rx_offload_result,
16183 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16184 TOKEN_NUM_INITIALIZER
16185 (struct cmd_config_per_queue_rx_offload_result,
16186 port_id, RTE_UINT16);
16187 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16188 TOKEN_STRING_INITIALIZER
16189 (struct cmd_config_per_queue_rx_offload_result,
16191 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16192 TOKEN_NUM_INITIALIZER
16193 (struct cmd_config_per_queue_rx_offload_result,
16194 queue_id, RTE_UINT16);
16195 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16196 TOKEN_STRING_INITIALIZER
16197 (struct cmd_config_per_queue_rx_offload_result,
16198 rx_offload, "rx_offload");
16199 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16200 TOKEN_STRING_INITIALIZER
16201 (struct cmd_config_per_queue_rx_offload_result,
16202 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16203 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16204 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16205 "scatter#buffer_split#timestamp#security#keep_crc");
16206 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16207 TOKEN_STRING_INITIALIZER
16208 (struct cmd_config_per_queue_rx_offload_result,
16212 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16213 __rte_unused struct cmdline *cl,
16214 __rte_unused void *data)
16216 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16217 struct rte_eth_dev_info dev_info;
16218 portid_t port_id = res->port_id;
16219 uint16_t queue_id = res->queue_id;
16220 struct rte_port *port = &ports[port_id];
16221 uint64_t single_offload;
16224 if (port->port_status != RTE_PORT_STOPPED) {
16226 "Error: Can't config offload when Port %d is not stopped\n",
16231 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16235 if (queue_id >= dev_info.nb_rx_queues) {
16237 "Error: input queue_id should be 0 ... %d\n",
16238 dev_info.nb_rx_queues - 1);
16242 single_offload = search_rx_offload(res->offload);
16243 if (single_offload == 0) {
16244 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16248 if (!strcmp(res->on_off, "on"))
16249 port->rx_conf[queue_id].offloads |= single_offload;
16251 port->rx_conf[queue_id].offloads &= ~single_offload;
16253 cmd_reconfig_device_queue(port_id, 1, 1);
16256 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16257 .f = cmd_config_per_queue_rx_offload_parsed,
16259 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16260 "vlan_strip|ipv4_cksum|"
16261 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16262 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16263 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16266 (void *)&cmd_config_per_queue_rx_offload_result_port,
16267 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16268 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16269 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16270 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16271 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16272 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16277 /* Get Tx offloads capabilities */
16278 struct cmd_tx_offload_get_capa_result {
16279 cmdline_fixed_string_t show;
16280 cmdline_fixed_string_t port;
16282 cmdline_fixed_string_t tx_offload;
16283 cmdline_fixed_string_t capabilities;
16286 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16287 TOKEN_STRING_INITIALIZER
16288 (struct cmd_tx_offload_get_capa_result,
16290 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16291 TOKEN_STRING_INITIALIZER
16292 (struct cmd_tx_offload_get_capa_result,
16294 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16295 TOKEN_NUM_INITIALIZER
16296 (struct cmd_tx_offload_get_capa_result,
16297 port_id, RTE_UINT16);
16298 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16299 TOKEN_STRING_INITIALIZER
16300 (struct cmd_tx_offload_get_capa_result,
16301 tx_offload, "tx_offload");
16302 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16303 TOKEN_STRING_INITIALIZER
16304 (struct cmd_tx_offload_get_capa_result,
16305 capabilities, "capabilities");
16308 print_tx_offloads(uint64_t offloads)
16310 uint64_t single_offload;
16318 begin = __builtin_ctzll(offloads);
16319 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16321 single_offload = 1ULL << begin;
16322 for (bit = begin; bit < end; bit++) {
16323 if (offloads & single_offload)
16325 rte_eth_dev_tx_offload_name(single_offload));
16326 single_offload <<= 1;
16331 cmd_tx_offload_get_capa_parsed(
16332 void *parsed_result,
16333 __rte_unused struct cmdline *cl,
16334 __rte_unused void *data)
16336 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16337 struct rte_eth_dev_info dev_info;
16338 portid_t port_id = res->port_id;
16339 uint64_t queue_offloads;
16340 uint64_t port_offloads;
16343 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16347 queue_offloads = dev_info.tx_queue_offload_capa;
16348 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16350 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16351 printf(" Per Queue :");
16352 print_tx_offloads(queue_offloads);
16355 printf(" Per Port :");
16356 print_tx_offloads(port_offloads);
16360 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16361 .f = cmd_tx_offload_get_capa_parsed,
16363 .help_str = "show port <port_id> tx_offload capabilities",
16365 (void *)&cmd_tx_offload_get_capa_show,
16366 (void *)&cmd_tx_offload_get_capa_port,
16367 (void *)&cmd_tx_offload_get_capa_port_id,
16368 (void *)&cmd_tx_offload_get_capa_tx_offload,
16369 (void *)&cmd_tx_offload_get_capa_capabilities,
16374 /* Get Tx offloads configuration */
16375 struct cmd_tx_offload_get_configuration_result {
16376 cmdline_fixed_string_t show;
16377 cmdline_fixed_string_t port;
16379 cmdline_fixed_string_t tx_offload;
16380 cmdline_fixed_string_t configuration;
16383 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16384 TOKEN_STRING_INITIALIZER
16385 (struct cmd_tx_offload_get_configuration_result,
16387 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16388 TOKEN_STRING_INITIALIZER
16389 (struct cmd_tx_offload_get_configuration_result,
16391 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16392 TOKEN_NUM_INITIALIZER
16393 (struct cmd_tx_offload_get_configuration_result,
16394 port_id, RTE_UINT16);
16395 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16396 TOKEN_STRING_INITIALIZER
16397 (struct cmd_tx_offload_get_configuration_result,
16398 tx_offload, "tx_offload");
16399 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16400 TOKEN_STRING_INITIALIZER
16401 (struct cmd_tx_offload_get_configuration_result,
16402 configuration, "configuration");
16405 cmd_tx_offload_get_configuration_parsed(
16406 void *parsed_result,
16407 __rte_unused struct cmdline *cl,
16408 __rte_unused void *data)
16410 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16411 struct rte_eth_dev_info dev_info;
16412 portid_t port_id = res->port_id;
16413 struct rte_port *port = &ports[port_id];
16414 uint64_t port_offloads;
16415 uint64_t queue_offloads;
16416 uint16_t nb_tx_queues;
16420 printf("Tx Offloading Configuration of port %d :\n", port_id);
16422 port_offloads = port->dev_conf.txmode.offloads;
16424 print_tx_offloads(port_offloads);
16427 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16431 nb_tx_queues = dev_info.nb_tx_queues;
16432 for (q = 0; q < nb_tx_queues; q++) {
16433 queue_offloads = port->tx_conf[q].offloads;
16434 printf(" Queue[%2d] :", q);
16435 print_tx_offloads(queue_offloads);
16441 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16442 .f = cmd_tx_offload_get_configuration_parsed,
16444 .help_str = "show port <port_id> tx_offload configuration",
16446 (void *)&cmd_tx_offload_get_configuration_show,
16447 (void *)&cmd_tx_offload_get_configuration_port,
16448 (void *)&cmd_tx_offload_get_configuration_port_id,
16449 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16450 (void *)&cmd_tx_offload_get_configuration_configuration,
16455 /* Enable/Disable a per port offloading */
16456 struct cmd_config_per_port_tx_offload_result {
16457 cmdline_fixed_string_t port;
16458 cmdline_fixed_string_t config;
16460 cmdline_fixed_string_t tx_offload;
16461 cmdline_fixed_string_t offload;
16462 cmdline_fixed_string_t on_off;
16465 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16466 TOKEN_STRING_INITIALIZER
16467 (struct cmd_config_per_port_tx_offload_result,
16469 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16470 TOKEN_STRING_INITIALIZER
16471 (struct cmd_config_per_port_tx_offload_result,
16473 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16474 TOKEN_NUM_INITIALIZER
16475 (struct cmd_config_per_port_tx_offload_result,
16476 port_id, RTE_UINT16);
16477 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16478 TOKEN_STRING_INITIALIZER
16479 (struct cmd_config_per_port_tx_offload_result,
16480 tx_offload, "tx_offload");
16481 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16482 TOKEN_STRING_INITIALIZER
16483 (struct cmd_config_per_port_tx_offload_result,
16484 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16485 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16486 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16487 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16488 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16489 "send_on_timestamp");
16490 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16491 TOKEN_STRING_INITIALIZER
16492 (struct cmd_config_per_port_tx_offload_result,
16496 search_tx_offload(const char *name)
16498 uint64_t single_offload;
16499 const char *single_name;
16503 single_offload = 1;
16504 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16505 single_name = rte_eth_dev_tx_offload_name(single_offload);
16506 if (single_name == NULL)
16508 if (!strcasecmp(single_name, name)) {
16511 } else if (!strcasecmp(single_name, "UNKNOWN"))
16513 single_offload <<= 1;
16517 return single_offload;
16523 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16524 __rte_unused struct cmdline *cl,
16525 __rte_unused void *data)
16527 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16528 portid_t port_id = res->port_id;
16529 struct rte_eth_dev_info dev_info;
16530 struct rte_port *port = &ports[port_id];
16531 uint64_t single_offload;
16532 uint16_t nb_tx_queues;
16536 if (port->port_status != RTE_PORT_STOPPED) {
16538 "Error: Can't config offload when Port %d is not stopped\n",
16543 single_offload = search_tx_offload(res->offload);
16544 if (single_offload == 0) {
16545 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16549 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16553 nb_tx_queues = dev_info.nb_tx_queues;
16554 if (!strcmp(res->on_off, "on")) {
16555 port->dev_conf.txmode.offloads |= single_offload;
16556 for (q = 0; q < nb_tx_queues; q++)
16557 port->tx_conf[q].offloads |= single_offload;
16559 port->dev_conf.txmode.offloads &= ~single_offload;
16560 for (q = 0; q < nb_tx_queues; q++)
16561 port->tx_conf[q].offloads &= ~single_offload;
16564 cmd_reconfig_device_queue(port_id, 1, 1);
16567 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16568 .f = cmd_config_per_port_tx_offload_parsed,
16570 .help_str = "port config <port_id> tx_offload "
16571 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16572 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16573 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16574 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16575 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16576 "send_on_timestamp on|off",
16578 (void *)&cmd_config_per_port_tx_offload_result_port,
16579 (void *)&cmd_config_per_port_tx_offload_result_config,
16580 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16581 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16582 (void *)&cmd_config_per_port_tx_offload_result_offload,
16583 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16588 /* Enable/Disable a per queue offloading */
16589 struct cmd_config_per_queue_tx_offload_result {
16590 cmdline_fixed_string_t port;
16592 cmdline_fixed_string_t txq;
16594 cmdline_fixed_string_t tx_offload;
16595 cmdline_fixed_string_t offload;
16596 cmdline_fixed_string_t on_off;
16599 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16600 TOKEN_STRING_INITIALIZER
16601 (struct cmd_config_per_queue_tx_offload_result,
16603 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16604 TOKEN_NUM_INITIALIZER
16605 (struct cmd_config_per_queue_tx_offload_result,
16606 port_id, RTE_UINT16);
16607 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16608 TOKEN_STRING_INITIALIZER
16609 (struct cmd_config_per_queue_tx_offload_result,
16611 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16612 TOKEN_NUM_INITIALIZER
16613 (struct cmd_config_per_queue_tx_offload_result,
16614 queue_id, RTE_UINT16);
16615 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16616 TOKEN_STRING_INITIALIZER
16617 (struct cmd_config_per_queue_tx_offload_result,
16618 tx_offload, "tx_offload");
16619 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16620 TOKEN_STRING_INITIALIZER
16621 (struct cmd_config_per_queue_tx_offload_result,
16622 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16623 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16624 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16625 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16626 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16627 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16628 TOKEN_STRING_INITIALIZER
16629 (struct cmd_config_per_queue_tx_offload_result,
16633 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16634 __rte_unused struct cmdline *cl,
16635 __rte_unused void *data)
16637 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16638 struct rte_eth_dev_info dev_info;
16639 portid_t port_id = res->port_id;
16640 uint16_t queue_id = res->queue_id;
16641 struct rte_port *port = &ports[port_id];
16642 uint64_t single_offload;
16645 if (port->port_status != RTE_PORT_STOPPED) {
16647 "Error: Can't config offload when Port %d is not stopped\n",
16652 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16656 if (queue_id >= dev_info.nb_tx_queues) {
16658 "Error: input queue_id should be 0 ... %d\n",
16659 dev_info.nb_tx_queues - 1);
16663 single_offload = search_tx_offload(res->offload);
16664 if (single_offload == 0) {
16665 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16669 if (!strcmp(res->on_off, "on"))
16670 port->tx_conf[queue_id].offloads |= single_offload;
16672 port->tx_conf[queue_id].offloads &= ~single_offload;
16674 cmd_reconfig_device_queue(port_id, 1, 1);
16677 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16678 .f = cmd_config_per_queue_tx_offload_parsed,
16680 .help_str = "port <port_id> txq <queue_id> tx_offload "
16681 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16682 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16683 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16684 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16685 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16688 (void *)&cmd_config_per_queue_tx_offload_result_port,
16689 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16690 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16691 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16692 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16693 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16694 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16699 /* *** configure tx_metadata for specific port *** */
16700 struct cmd_config_tx_metadata_specific_result {
16701 cmdline_fixed_string_t port;
16702 cmdline_fixed_string_t keyword;
16704 cmdline_fixed_string_t item;
16709 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16710 __rte_unused struct cmdline *cl,
16711 __rte_unused void *data)
16713 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16715 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16717 ports[res->port_id].tx_metadata = res->value;
16718 /* Add/remove callback to insert valid metadata in every Tx packet. */
16719 if (ports[res->port_id].tx_metadata)
16720 add_tx_md_callback(res->port_id);
16722 remove_tx_md_callback(res->port_id);
16723 rte_flow_dynf_metadata_register();
16726 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16727 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16729 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16730 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16731 keyword, "config");
16732 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16733 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16734 port_id, RTE_UINT16);
16735 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16736 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16737 item, "tx_metadata");
16738 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16739 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16740 value, RTE_UINT32);
16742 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16743 .f = cmd_config_tx_metadata_specific_parsed,
16745 .help_str = "port config <port_id> tx_metadata <value>",
16747 (void *)&cmd_config_tx_metadata_specific_port,
16748 (void *)&cmd_config_tx_metadata_specific_keyword,
16749 (void *)&cmd_config_tx_metadata_specific_id,
16750 (void *)&cmd_config_tx_metadata_specific_item,
16751 (void *)&cmd_config_tx_metadata_specific_value,
16756 /* *** set dynf *** */
16757 struct cmd_config_tx_dynf_specific_result {
16758 cmdline_fixed_string_t port;
16759 cmdline_fixed_string_t keyword;
16761 cmdline_fixed_string_t item;
16762 cmdline_fixed_string_t name;
16763 cmdline_fixed_string_t value;
16767 cmd_config_dynf_specific_parsed(void *parsed_result,
16768 __rte_unused struct cmdline *cl,
16769 __rte_unused void *data)
16771 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16772 struct rte_mbuf_dynflag desc_flag;
16774 uint64_t old_port_flags;
16776 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16778 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16780 if (strlcpy(desc_flag.name, res->name,
16781 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16782 fprintf(stderr, "Flag name too long\n");
16785 desc_flag.flags = 0;
16786 flag = rte_mbuf_dynflag_register(&desc_flag);
16788 fprintf(stderr, "Can't register flag\n");
16791 strcpy(dynf_names[flag], desc_flag.name);
16793 old_port_flags = ports[res->port_id].mbuf_dynf;
16794 if (!strcmp(res->value, "set")) {
16795 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16796 if (old_port_flags == 0)
16797 add_tx_dynf_callback(res->port_id);
16799 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16800 if (ports[res->port_id].mbuf_dynf == 0)
16801 remove_tx_dynf_callback(res->port_id);
16805 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16806 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16808 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16809 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16810 keyword, "config");
16811 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16812 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16813 port_id, RTE_UINT16);
16814 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16815 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16817 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16818 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16820 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16821 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16822 value, "set#clear");
16824 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16825 .f = cmd_config_dynf_specific_parsed,
16827 .help_str = "port config <port id> dynf <name> set|clear",
16829 (void *)&cmd_config_tx_dynf_specific_port,
16830 (void *)&cmd_config_tx_dynf_specific_keyword,
16831 (void *)&cmd_config_tx_dynf_specific_port_id,
16832 (void *)&cmd_config_tx_dynf_specific_item,
16833 (void *)&cmd_config_tx_dynf_specific_name,
16834 (void *)&cmd_config_tx_dynf_specific_value,
16839 /* *** display tx_metadata per port configuration *** */
16840 struct cmd_show_tx_metadata_result {
16841 cmdline_fixed_string_t cmd_show;
16842 cmdline_fixed_string_t cmd_port;
16843 cmdline_fixed_string_t cmd_keyword;
16848 cmd_show_tx_metadata_parsed(void *parsed_result,
16849 __rte_unused struct cmdline *cl,
16850 __rte_unused void *data)
16852 struct cmd_show_tx_metadata_result *res = parsed_result;
16854 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16855 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16858 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16859 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16860 ports[res->cmd_pid].tx_metadata);
16864 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16865 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16867 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16868 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16870 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16871 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16872 cmd_pid, RTE_UINT16);
16873 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16874 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16875 cmd_keyword, "tx_metadata");
16877 cmdline_parse_inst_t cmd_show_tx_metadata = {
16878 .f = cmd_show_tx_metadata_parsed,
16880 .help_str = "show port <port_id> tx_metadata",
16882 (void *)&cmd_show_tx_metadata_show,
16883 (void *)&cmd_show_tx_metadata_port,
16884 (void *)&cmd_show_tx_metadata_pid,
16885 (void *)&cmd_show_tx_metadata_keyword,
16890 /* *** show fec capability per port configuration *** */
16891 struct cmd_show_fec_capability_result {
16892 cmdline_fixed_string_t cmd_show;
16893 cmdline_fixed_string_t cmd_port;
16894 cmdline_fixed_string_t cmd_fec;
16895 cmdline_fixed_string_t cmd_keyword;
16900 cmd_show_fec_capability_parsed(void *parsed_result,
16901 __rte_unused struct cmdline *cl,
16902 __rte_unused void *data)
16904 struct cmd_show_fec_capability_result *res = parsed_result;
16905 struct rte_eth_fec_capa *speed_fec_capa;
16909 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16910 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16914 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16915 if (ret == -ENOTSUP) {
16916 fprintf(stderr, "Function not implemented\n");
16918 } else if (ret < 0) {
16919 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16923 num = (unsigned int)ret;
16924 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16925 if (speed_fec_capa == NULL) {
16926 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16930 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16932 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
16936 show_fec_capability(num, speed_fec_capa);
16938 free(speed_fec_capa);
16941 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16942 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16944 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16945 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16947 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16948 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16949 cmd_pid, RTE_UINT16);
16950 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16951 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16953 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16954 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16955 cmd_keyword, "capabilities");
16957 cmdline_parse_inst_t cmd_show_capability = {
16958 .f = cmd_show_fec_capability_parsed,
16960 .help_str = "show port <port_id> fec capabilities",
16962 (void *)&cmd_show_fec_capability_show,
16963 (void *)&cmd_show_fec_capability_port,
16964 (void *)&cmd_show_fec_capability_pid,
16965 (void *)&cmd_show_fec_capability_fec,
16966 (void *)&cmd_show_fec_capability_keyword,
16971 /* *** show fec mode per port configuration *** */
16972 struct cmd_show_fec_metadata_result {
16973 cmdline_fixed_string_t cmd_show;
16974 cmdline_fixed_string_t cmd_port;
16975 cmdline_fixed_string_t cmd_keyword;
16980 cmd_show_fec_mode_parsed(void *parsed_result,
16981 __rte_unused struct cmdline *cl,
16982 __rte_unused void *data)
16984 #define FEC_NAME_SIZE 16
16985 struct cmd_show_fec_metadata_result *res = parsed_result;
16987 char buf[FEC_NAME_SIZE];
16990 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16991 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16994 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16995 if (ret == -ENOTSUP) {
16996 fprintf(stderr, "Function not implemented\n");
16998 } else if (ret < 0) {
16999 fprintf(stderr, "Get FEC mode failed\n");
17004 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17005 strlcpy(buf, "off", sizeof(buf));
17007 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17008 strlcpy(buf, "auto", sizeof(buf));
17010 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17011 strlcpy(buf, "baser", sizeof(buf));
17013 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17014 strlcpy(buf, "rs", sizeof(buf));
17020 printf("%s\n", buf);
17023 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17024 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17026 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17027 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17029 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17030 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17031 cmd_pid, RTE_UINT16);
17032 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17033 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17034 cmd_keyword, "fec_mode");
17036 cmdline_parse_inst_t cmd_show_fec_mode = {
17037 .f = cmd_show_fec_mode_parsed,
17039 .help_str = "show port <port_id> fec_mode",
17041 (void *)&cmd_show_fec_mode_show,
17042 (void *)&cmd_show_fec_mode_port,
17043 (void *)&cmd_show_fec_mode_pid,
17044 (void *)&cmd_show_fec_mode_keyword,
17049 /* *** set fec mode per port configuration *** */
17050 struct cmd_set_port_fec_mode {
17051 cmdline_fixed_string_t set;
17052 cmdline_fixed_string_t port;
17054 cmdline_fixed_string_t fec_mode;
17055 cmdline_fixed_string_t fec_value;
17058 /* Common CLI fields for set fec mode */
17059 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17060 TOKEN_STRING_INITIALIZER
17061 (struct cmd_set_port_fec_mode,
17063 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17064 TOKEN_STRING_INITIALIZER
17065 (struct cmd_set_port_fec_mode,
17067 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17068 TOKEN_NUM_INITIALIZER
17069 (struct cmd_set_port_fec_mode,
17070 port_id, RTE_UINT16);
17071 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17072 TOKEN_STRING_INITIALIZER
17073 (struct cmd_set_port_fec_mode,
17074 fec_mode, "fec_mode");
17075 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17076 TOKEN_STRING_INITIALIZER
17077 (struct cmd_set_port_fec_mode,
17081 cmd_set_port_fec_mode_parsed(
17082 void *parsed_result,
17083 __rte_unused struct cmdline *cl,
17084 __rte_unused void *data)
17086 struct cmd_set_port_fec_mode *res = parsed_result;
17087 uint16_t port_id = res->port_id;
17091 ret = parse_fec_mode(res->fec_value, &fec_capa);
17093 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17094 res->fec_value, port_id);
17098 ret = rte_eth_fec_set(port_id, fec_capa);
17099 if (ret == -ENOTSUP) {
17100 fprintf(stderr, "Function not implemented\n");
17102 } else if (ret < 0) {
17103 fprintf(stderr, "Set FEC mode failed\n");
17108 cmdline_parse_inst_t cmd_set_fec_mode = {
17109 .f = cmd_set_port_fec_mode_parsed,
17111 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17113 (void *)&cmd_set_port_fec_mode_set,
17114 (void *)&cmd_set_port_fec_mode_port,
17115 (void *)&cmd_set_port_fec_mode_port_id,
17116 (void *)&cmd_set_port_fec_mode_str,
17117 (void *)&cmd_set_port_fec_mode_value,
17122 /* show port supported ptypes */
17124 /* Common result structure for show port ptypes */
17125 struct cmd_show_port_supported_ptypes_result {
17126 cmdline_fixed_string_t show;
17127 cmdline_fixed_string_t port;
17129 cmdline_fixed_string_t ptypes;
17132 /* Common CLI fields for show port ptypes */
17133 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17134 TOKEN_STRING_INITIALIZER
17135 (struct cmd_show_port_supported_ptypes_result,
17137 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17138 TOKEN_STRING_INITIALIZER
17139 (struct cmd_show_port_supported_ptypes_result,
17141 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17142 TOKEN_NUM_INITIALIZER
17143 (struct cmd_show_port_supported_ptypes_result,
17144 port_id, RTE_UINT16);
17145 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17146 TOKEN_STRING_INITIALIZER
17147 (struct cmd_show_port_supported_ptypes_result,
17151 cmd_show_port_supported_ptypes_parsed(
17152 void *parsed_result,
17153 __rte_unused struct cmdline *cl,
17154 __rte_unused void *data)
17156 #define RSVD_PTYPE_MASK 0xf0000000
17157 #define MAX_PTYPES_PER_LAYER 16
17158 #define LTYPE_NAMESIZE 32
17159 #define PTYPE_NAMESIZE 256
17160 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17161 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17162 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17163 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17164 uint16_t port_id = res->port_id;
17167 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17171 while (ptype_mask != RSVD_PTYPE_MASK) {
17173 switch (ptype_mask) {
17174 case RTE_PTYPE_L2_MASK:
17175 strlcpy(ltype, "L2", sizeof(ltype));
17177 case RTE_PTYPE_L3_MASK:
17178 strlcpy(ltype, "L3", sizeof(ltype));
17180 case RTE_PTYPE_L4_MASK:
17181 strlcpy(ltype, "L4", sizeof(ltype));
17183 case RTE_PTYPE_TUNNEL_MASK:
17184 strlcpy(ltype, "Tunnel", sizeof(ltype));
17186 case RTE_PTYPE_INNER_L2_MASK:
17187 strlcpy(ltype, "Inner L2", sizeof(ltype));
17189 case RTE_PTYPE_INNER_L3_MASK:
17190 strlcpy(ltype, "Inner L3", sizeof(ltype));
17192 case RTE_PTYPE_INNER_L4_MASK:
17193 strlcpy(ltype, "Inner L4", sizeof(ltype));
17199 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17200 ptype_mask, ptypes,
17201 MAX_PTYPES_PER_LAYER);
17204 printf("Supported %s ptypes:\n", ltype);
17206 printf("%s ptypes unsupported\n", ltype);
17208 for (i = 0; i < ret; ++i) {
17209 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17210 printf("%s\n", buf);
17217 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17218 .f = cmd_show_port_supported_ptypes_parsed,
17220 .help_str = "show port <port_id> ptypes",
17222 (void *)&cmd_show_port_supported_ptypes_show,
17223 (void *)&cmd_show_port_supported_ptypes_port,
17224 (void *)&cmd_show_port_supported_ptypes_port_id,
17225 (void *)&cmd_show_port_supported_ptypes_ptypes,
17230 /* *** display rx/tx descriptor status *** */
17231 struct cmd_show_rx_tx_desc_status_result {
17232 cmdline_fixed_string_t cmd_show;
17233 cmdline_fixed_string_t cmd_port;
17234 cmdline_fixed_string_t cmd_keyword;
17235 cmdline_fixed_string_t cmd_desc;
17236 cmdline_fixed_string_t cmd_status;
17243 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17244 __rte_unused struct cmdline *cl,
17245 __rte_unused void *data)
17247 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17250 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17251 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17255 if (!strcmp(res->cmd_keyword, "rxq")) {
17256 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17260 "Invalid input: queue id = %d, desc id = %d\n",
17261 res->cmd_qid, res->cmd_did);
17264 if (rc == RTE_ETH_RX_DESC_AVAIL)
17265 printf("Desc status = AVAILABLE\n");
17266 else if (rc == RTE_ETH_RX_DESC_DONE)
17267 printf("Desc status = DONE\n");
17269 printf("Desc status = UNAVAILABLE\n");
17270 } else if (!strcmp(res->cmd_keyword, "txq")) {
17271 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17275 "Invalid input: queue id = %d, desc id = %d\n",
17276 res->cmd_qid, res->cmd_did);
17279 if (rc == RTE_ETH_TX_DESC_FULL)
17280 printf("Desc status = FULL\n");
17281 else if (rc == RTE_ETH_TX_DESC_DONE)
17282 printf("Desc status = DONE\n");
17284 printf("Desc status = UNAVAILABLE\n");
17288 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17289 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17291 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17292 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17294 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17295 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17296 cmd_pid, RTE_UINT16);
17297 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17298 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17299 cmd_keyword, "rxq#txq");
17300 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17301 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17302 cmd_qid, RTE_UINT16);
17303 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17304 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17306 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17307 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17308 cmd_did, RTE_UINT16);
17309 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17310 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17311 cmd_status, "status");
17312 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17313 .f = cmd_show_rx_tx_desc_status_parsed,
17315 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17318 (void *)&cmd_show_rx_tx_desc_status_show,
17319 (void *)&cmd_show_rx_tx_desc_status_port,
17320 (void *)&cmd_show_rx_tx_desc_status_pid,
17321 (void *)&cmd_show_rx_tx_desc_status_keyword,
17322 (void *)&cmd_show_rx_tx_desc_status_qid,
17323 (void *)&cmd_show_rx_tx_desc_status_desc,
17324 (void *)&cmd_show_rx_tx_desc_status_did,
17325 (void *)&cmd_show_rx_tx_desc_status_status,
17330 /* *** display rx queue desc used count *** */
17331 struct cmd_show_rx_queue_desc_used_count_result {
17332 cmdline_fixed_string_t cmd_show;
17333 cmdline_fixed_string_t cmd_port;
17334 cmdline_fixed_string_t cmd_rxq;
17335 cmdline_fixed_string_t cmd_desc;
17336 cmdline_fixed_string_t cmd_used;
17337 cmdline_fixed_string_t cmd_count;
17343 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17344 __rte_unused struct cmdline *cl,
17345 __rte_unused void *data)
17347 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17350 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17351 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17355 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17357 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17360 printf("Used desc count = %d\n", rc);
17363 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17364 TOKEN_STRING_INITIALIZER
17365 (struct cmd_show_rx_queue_desc_used_count_result,
17367 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17368 TOKEN_STRING_INITIALIZER
17369 (struct cmd_show_rx_queue_desc_used_count_result,
17371 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17372 TOKEN_NUM_INITIALIZER
17373 (struct cmd_show_rx_queue_desc_used_count_result,
17374 cmd_pid, RTE_UINT16);
17375 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17376 TOKEN_STRING_INITIALIZER
17377 (struct cmd_show_rx_queue_desc_used_count_result,
17379 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17380 TOKEN_NUM_INITIALIZER
17381 (struct cmd_show_rx_queue_desc_used_count_result,
17382 cmd_qid, RTE_UINT16);
17383 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17384 TOKEN_STRING_INITIALIZER
17385 (struct cmd_show_rx_queue_desc_used_count_result,
17386 cmd_count, "desc");
17387 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17388 TOKEN_STRING_INITIALIZER
17389 (struct cmd_show_rx_queue_desc_used_count_result,
17390 cmd_count, "used");
17391 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17392 TOKEN_STRING_INITIALIZER
17393 (struct cmd_show_rx_queue_desc_used_count_result,
17394 cmd_count, "count");
17395 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17396 .f = cmd_show_rx_queue_desc_used_count_parsed,
17398 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17400 (void *)&cmd_show_rx_queue_desc_used_count_show,
17401 (void *)&cmd_show_rx_queue_desc_used_count_port,
17402 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17403 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17404 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17405 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17406 (void *)&cmd_show_rx_queue_desc_used_count_used,
17407 (void *)&cmd_show_rx_queue_desc_used_count_count,
17412 /* Common result structure for set port ptypes */
17413 struct cmd_set_port_ptypes_result {
17414 cmdline_fixed_string_t set;
17415 cmdline_fixed_string_t port;
17417 cmdline_fixed_string_t ptype_mask;
17421 /* Common CLI fields for set port ptypes */
17422 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17423 TOKEN_STRING_INITIALIZER
17424 (struct cmd_set_port_ptypes_result,
17426 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17427 TOKEN_STRING_INITIALIZER
17428 (struct cmd_set_port_ptypes_result,
17430 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17431 TOKEN_NUM_INITIALIZER
17432 (struct cmd_set_port_ptypes_result,
17433 port_id, RTE_UINT16);
17434 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17435 TOKEN_STRING_INITIALIZER
17436 (struct cmd_set_port_ptypes_result,
17437 ptype_mask, "ptype_mask");
17438 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17439 TOKEN_NUM_INITIALIZER
17440 (struct cmd_set_port_ptypes_result,
17444 cmd_set_port_ptypes_parsed(
17445 void *parsed_result,
17446 __rte_unused struct cmdline *cl,
17447 __rte_unused void *data)
17449 struct cmd_set_port_ptypes_result *res = parsed_result;
17450 #define PTYPE_NAMESIZE 256
17451 char ptype_name[PTYPE_NAMESIZE];
17452 uint16_t port_id = res->port_id;
17453 uint32_t ptype_mask = res->mask;
17456 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17459 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17464 uint32_t ptypes[ret];
17466 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17468 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17473 printf("Successfully set following ptypes for Port %d\n", port_id);
17474 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17475 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17476 printf("%s\n", ptype_name);
17479 clear_ptypes = false;
17482 cmdline_parse_inst_t cmd_set_port_ptypes = {
17483 .f = cmd_set_port_ptypes_parsed,
17485 .help_str = "set port <port_id> ptype_mask <mask>",
17487 (void *)&cmd_set_port_ptypes_set,
17488 (void *)&cmd_set_port_ptypes_port,
17489 (void *)&cmd_set_port_ptypes_port_id,
17490 (void *)&cmd_set_port_ptypes_mask_str,
17491 (void *)&cmd_set_port_ptypes_mask_u32,
17496 /* *** display mac addresses added to a port *** */
17497 struct cmd_showport_macs_result {
17498 cmdline_fixed_string_t cmd_show;
17499 cmdline_fixed_string_t cmd_port;
17500 cmdline_fixed_string_t cmd_keyword;
17505 cmd_showport_macs_parsed(void *parsed_result,
17506 __rte_unused struct cmdline *cl,
17507 __rte_unused void *data)
17509 struct cmd_showport_macs_result *res = parsed_result;
17511 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17514 if (!strcmp(res->cmd_keyword, "macs"))
17515 show_macs(res->cmd_pid);
17516 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17517 show_mcast_macs(res->cmd_pid);
17520 cmdline_parse_token_string_t cmd_showport_macs_show =
17521 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17523 cmdline_parse_token_string_t cmd_showport_macs_port =
17524 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17526 cmdline_parse_token_num_t cmd_showport_macs_pid =
17527 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17528 cmd_pid, RTE_UINT16);
17529 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17530 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17531 cmd_keyword, "macs#mcast_macs");
17533 cmdline_parse_inst_t cmd_showport_macs = {
17534 .f = cmd_showport_macs_parsed,
17536 .help_str = "show port <port_id> macs|mcast_macs",
17538 (void *)&cmd_showport_macs_show,
17539 (void *)&cmd_showport_macs_port,
17540 (void *)&cmd_showport_macs_pid,
17541 (void *)&cmd_showport_macs_keyword,
17546 /* ******************************************************************************** */
17548 /* list of instructions */
17549 cmdline_parse_ctx_t main_ctx[] = {
17550 (cmdline_parse_inst_t *)&cmd_help_brief,
17551 (cmdline_parse_inst_t *)&cmd_help_long,
17552 (cmdline_parse_inst_t *)&cmd_quit,
17553 (cmdline_parse_inst_t *)&cmd_load_from_file,
17554 (cmdline_parse_inst_t *)&cmd_showport,
17555 (cmdline_parse_inst_t *)&cmd_showqueue,
17556 (cmdline_parse_inst_t *)&cmd_showeeprom,
17557 (cmdline_parse_inst_t *)&cmd_showportall,
17558 (cmdline_parse_inst_t *)&cmd_showdevice,
17559 (cmdline_parse_inst_t *)&cmd_showcfg,
17560 (cmdline_parse_inst_t *)&cmd_showfwdall,
17561 (cmdline_parse_inst_t *)&cmd_start,
17562 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17563 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17564 (cmdline_parse_inst_t *)&cmd_set_link_up,
17565 (cmdline_parse_inst_t *)&cmd_set_link_down,
17566 (cmdline_parse_inst_t *)&cmd_reset,
17567 (cmdline_parse_inst_t *)&cmd_set_numbers,
17568 (cmdline_parse_inst_t *)&cmd_set_log,
17569 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17570 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17571 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17572 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17573 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17574 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17575 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17576 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17577 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17578 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17579 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17580 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17581 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17582 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17583 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17584 (cmdline_parse_inst_t *)&cmd_set_link_check,
17585 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17586 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17587 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17588 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17589 #ifdef RTE_NET_BOND
17590 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17591 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17592 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17593 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17594 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17595 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17596 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17597 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17598 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17599 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17600 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17602 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17603 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17604 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17605 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17606 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17607 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17608 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17609 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17610 (cmdline_parse_inst_t *)&cmd_csum_set,
17611 (cmdline_parse_inst_t *)&cmd_csum_show,
17612 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17613 (cmdline_parse_inst_t *)&cmd_tso_set,
17614 (cmdline_parse_inst_t *)&cmd_tso_show,
17615 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17616 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17617 (cmdline_parse_inst_t *)&cmd_gro_enable,
17618 (cmdline_parse_inst_t *)&cmd_gro_flush,
17619 (cmdline_parse_inst_t *)&cmd_gro_show,
17620 (cmdline_parse_inst_t *)&cmd_gso_enable,
17621 (cmdline_parse_inst_t *)&cmd_gso_size,
17622 (cmdline_parse_inst_t *)&cmd_gso_show,
17623 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17624 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17625 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17626 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17627 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17628 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17629 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17630 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17631 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17632 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17633 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17634 (cmdline_parse_inst_t *)&cmd_config_dcb,
17635 (cmdline_parse_inst_t *)&cmd_read_reg,
17636 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17637 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17638 (cmdline_parse_inst_t *)&cmd_write_reg,
17639 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17640 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17641 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17642 (cmdline_parse_inst_t *)&cmd_stop,
17643 (cmdline_parse_inst_t *)&cmd_mac_addr,
17644 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17645 (cmdline_parse_inst_t *)&cmd_set_qmap,
17646 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17647 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17648 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17649 (cmdline_parse_inst_t *)&cmd_operate_port,
17650 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17651 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17652 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17653 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17654 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17655 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17656 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17657 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17658 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17659 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17660 (cmdline_parse_inst_t *)&cmd_config_mtu,
17661 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17662 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17663 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17664 (cmdline_parse_inst_t *)&cmd_config_rss,
17665 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17666 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17667 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17668 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17669 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17670 (cmdline_parse_inst_t *)&cmd_showport_reta,
17671 (cmdline_parse_inst_t *)&cmd_showport_macs,
17672 (cmdline_parse_inst_t *)&cmd_config_burst,
17673 (cmdline_parse_inst_t *)&cmd_config_thresh,
17674 (cmdline_parse_inst_t *)&cmd_config_threshold,
17675 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17676 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17677 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17678 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17679 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17680 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17681 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17682 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17683 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17684 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17685 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17686 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17687 (cmdline_parse_inst_t *)&cmd_dump,
17688 (cmdline_parse_inst_t *)&cmd_dump_one,
17689 #ifdef RTE_NET_I40E
17690 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17692 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17693 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17694 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17695 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17696 (cmdline_parse_inst_t *)&cmd_flow,
17697 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17698 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17699 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17700 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17701 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17702 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17703 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17704 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17705 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17706 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17707 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17708 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17709 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17710 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17711 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17712 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17713 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17714 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17715 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17716 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17717 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17718 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17719 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17720 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17721 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17722 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17723 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17724 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17725 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17726 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17727 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17728 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17729 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17730 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17731 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17732 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17733 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17734 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17735 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17736 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17737 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17738 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17739 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17740 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17741 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17742 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17743 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17744 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17745 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17746 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17747 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17748 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17749 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17750 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17751 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17752 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17753 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17754 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17755 (cmdline_parse_inst_t *)&cmd_ddp_add,
17756 (cmdline_parse_inst_t *)&cmd_ddp_del,
17757 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17758 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17759 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17760 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17761 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17762 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17763 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17764 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17765 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17766 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17767 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17768 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17770 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17771 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17772 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17773 (cmdline_parse_inst_t *)&cmd_queue_region,
17774 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17775 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17776 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17777 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17778 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17779 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17780 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17781 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17782 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17783 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17784 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17785 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17786 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17787 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17788 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17789 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17790 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17791 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17792 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17793 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17794 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17795 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17796 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17797 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17798 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17799 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17800 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17801 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17802 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17803 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17804 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17805 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17806 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17807 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17808 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17809 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17811 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17812 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17814 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17815 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17816 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17817 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17818 (cmdline_parse_inst_t *)&cmd_set_raw,
17819 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17820 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17821 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17822 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17823 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17824 (cmdline_parse_inst_t *)&cmd_show_capability,
17828 /* read cmdline commands from file */
17830 cmdline_read_from_file(const char *filename)
17832 struct cmdline *cl;
17834 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17837 "Failed to create file based cmdline context: %s\n",
17842 cmdline_interact(cl);
17847 printf("Read CLI commands from %s\n", filename);
17850 /* prompt function, called from main on MAIN lcore */
17855 /* initialize non-constant commands */
17856 cmd_set_fwd_mode_init();
17857 cmd_set_fwd_retry_mode_init();
17859 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17860 if (testpmd_cl == NULL)
17863 ret = atexit(prompt_exit);
17865 fprintf(stderr, "Cannot set exit function for cmdline\n");
17867 cmdline_interact(testpmd_cl);
17869 cmdline_stdin_exit(testpmd_cl);
17875 if (testpmd_cl != NULL) {
17876 cmdline_quit(testpmd_cl);
17877 cmdline_stdin_exit(testpmd_cl);
17882 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17884 if (id == (portid_t)RTE_PORT_ALL) {
17887 RTE_ETH_FOREACH_DEV(pid) {
17888 /* check if need_reconfig has been set to 1 */
17889 if (ports[pid].need_reconfig == 0)
17890 ports[pid].need_reconfig = dev;
17891 /* check if need_reconfig_queues has been set to 1 */
17892 if (ports[pid].need_reconfig_queues == 0)
17893 ports[pid].need_reconfig_queues = queue;
17895 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17896 /* check if need_reconfig has been set to 1 */
17897 if (ports[id].need_reconfig == 0)
17898 ports[id].need_reconfig = dev;
17899 /* check if need_reconfig_queues has been set to 1 */
17900 if (ports[id].need_reconfig_queues == 0)
17901 ports[id].need_reconfig_queues = queue;