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;
5494 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5497 cmdline_parse_token_string_t cmd_setflushrx_set =
5498 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5500 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5501 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5502 flush_rx, "flush_rx");
5503 cmdline_parse_token_string_t cmd_setflushrx_mode =
5504 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5508 cmdline_parse_inst_t cmd_set_flush_rx = {
5509 .f = cmd_set_flush_rx_parsed,
5510 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5513 (void *)&cmd_setflushrx_set,
5514 (void *)&cmd_setflushrx_flush_rx,
5515 (void *)&cmd_setflushrx_mode,
5520 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5521 struct cmd_set_link_check {
5522 cmdline_fixed_string_t set;
5523 cmdline_fixed_string_t link_check;
5524 cmdline_fixed_string_t mode;
5528 cmd_set_link_check_parsed(void *parsed_result,
5529 __rte_unused struct cmdline *cl,
5530 __rte_unused void *data)
5532 struct cmd_set_link_check *res = parsed_result;
5533 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5536 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5537 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5539 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5540 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5541 link_check, "link_check");
5542 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5547 cmdline_parse_inst_t cmd_set_link_check = {
5548 .f = cmd_set_link_check_parsed,
5549 .help_str = "set link_check on|off: Enable/Disable link status check "
5550 "when starting/stopping a port",
5553 (void *)&cmd_setlinkcheck_set,
5554 (void *)&cmd_setlinkcheck_link_check,
5555 (void *)&cmd_setlinkcheck_mode,
5560 /* *** SET NIC BYPASS MODE *** */
5561 struct cmd_set_bypass_mode_result {
5562 cmdline_fixed_string_t set;
5563 cmdline_fixed_string_t bypass;
5564 cmdline_fixed_string_t mode;
5565 cmdline_fixed_string_t value;
5570 cmd_set_bypass_mode_parsed(void *parsed_result,
5571 __rte_unused struct cmdline *cl,
5572 __rte_unused void *data)
5574 struct cmd_set_bypass_mode_result *res = parsed_result;
5575 portid_t port_id = res->port_id;
5576 int32_t rc = -EINVAL;
5578 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5579 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5581 if (!strcmp(res->value, "bypass"))
5582 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5583 else if (!strcmp(res->value, "isolate"))
5584 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5586 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5588 /* Set the bypass mode for the relevant port. */
5589 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5592 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5596 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5597 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5599 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5600 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5602 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5603 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5605 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5606 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5607 value, "normal#bypass#isolate");
5608 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5609 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5610 port_id, RTE_UINT16);
5612 cmdline_parse_inst_t cmd_set_bypass_mode = {
5613 .f = cmd_set_bypass_mode_parsed,
5614 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5615 "Set the NIC bypass mode for port_id",
5618 (void *)&cmd_setbypass_mode_set,
5619 (void *)&cmd_setbypass_mode_bypass,
5620 (void *)&cmd_setbypass_mode_mode,
5621 (void *)&cmd_setbypass_mode_value,
5622 (void *)&cmd_setbypass_mode_port,
5627 /* *** SET NIC BYPASS EVENT *** */
5628 struct cmd_set_bypass_event_result {
5629 cmdline_fixed_string_t set;
5630 cmdline_fixed_string_t bypass;
5631 cmdline_fixed_string_t event;
5632 cmdline_fixed_string_t event_value;
5633 cmdline_fixed_string_t mode;
5634 cmdline_fixed_string_t mode_value;
5639 cmd_set_bypass_event_parsed(void *parsed_result,
5640 __rte_unused struct cmdline *cl,
5641 __rte_unused void *data)
5643 int32_t rc = -EINVAL;
5644 struct cmd_set_bypass_event_result *res = parsed_result;
5645 portid_t port_id = res->port_id;
5647 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5648 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5649 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5651 if (!strcmp(res->event_value, "timeout"))
5652 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5653 else if (!strcmp(res->event_value, "os_on"))
5654 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5655 else if (!strcmp(res->event_value, "os_off"))
5656 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5657 else if (!strcmp(res->event_value, "power_on"))
5658 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5659 else if (!strcmp(res->event_value, "power_off"))
5660 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5662 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5664 if (!strcmp(res->mode_value, "bypass"))
5665 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5666 else if (!strcmp(res->mode_value, "isolate"))
5667 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5669 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5671 /* Set the watchdog timeout. */
5672 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5675 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5676 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5681 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5682 bypass_timeout, port_id, rc);
5686 /* Set the bypass event to transition to bypass mode. */
5687 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5692 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5696 cmdline_parse_token_string_t cmd_setbypass_event_set =
5697 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5699 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5700 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5702 cmdline_parse_token_string_t cmd_setbypass_event_event =
5703 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5705 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5706 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5707 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5708 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5709 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5711 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5712 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5713 mode_value, "normal#bypass#isolate");
5714 cmdline_parse_token_num_t cmd_setbypass_event_port =
5715 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5716 port_id, RTE_UINT16);
5718 cmdline_parse_inst_t cmd_set_bypass_event = {
5719 .f = cmd_set_bypass_event_parsed,
5720 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5721 "power_off mode normal|bypass|isolate <port_id>: "
5722 "Set the NIC bypass event mode for port_id",
5725 (void *)&cmd_setbypass_event_set,
5726 (void *)&cmd_setbypass_event_bypass,
5727 (void *)&cmd_setbypass_event_event,
5728 (void *)&cmd_setbypass_event_event_value,
5729 (void *)&cmd_setbypass_event_mode,
5730 (void *)&cmd_setbypass_event_mode_value,
5731 (void *)&cmd_setbypass_event_port,
5737 /* *** SET NIC BYPASS TIMEOUT *** */
5738 struct cmd_set_bypass_timeout_result {
5739 cmdline_fixed_string_t set;
5740 cmdline_fixed_string_t bypass;
5741 cmdline_fixed_string_t timeout;
5742 cmdline_fixed_string_t value;
5746 cmd_set_bypass_timeout_parsed(void *parsed_result,
5747 __rte_unused struct cmdline *cl,
5748 __rte_unused void *data)
5750 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5752 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5753 if (!strcmp(res->value, "1.5"))
5754 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5755 else if (!strcmp(res->value, "2"))
5756 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5757 else if (!strcmp(res->value, "3"))
5758 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5759 else if (!strcmp(res->value, "4"))
5760 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5761 else if (!strcmp(res->value, "8"))
5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5763 else if (!strcmp(res->value, "16"))
5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5765 else if (!strcmp(res->value, "32"))
5766 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5768 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5772 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5773 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5775 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5776 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5778 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5779 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5780 timeout, "timeout");
5781 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5783 value, "0#1.5#2#3#4#8#16#32");
5785 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5786 .f = cmd_set_bypass_timeout_parsed,
5787 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5788 "Set the NIC bypass watchdog timeout in seconds",
5791 (void *)&cmd_setbypass_timeout_set,
5792 (void *)&cmd_setbypass_timeout_bypass,
5793 (void *)&cmd_setbypass_timeout_timeout,
5794 (void *)&cmd_setbypass_timeout_value,
5799 /* *** SHOW NIC BYPASS MODE *** */
5800 struct cmd_show_bypass_config_result {
5801 cmdline_fixed_string_t show;
5802 cmdline_fixed_string_t bypass;
5803 cmdline_fixed_string_t config;
5808 cmd_show_bypass_config_parsed(void *parsed_result,
5809 __rte_unused struct cmdline *cl,
5810 __rte_unused void *data)
5812 struct cmd_show_bypass_config_result *res = parsed_result;
5813 portid_t port_id = res->port_id;
5815 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5816 uint32_t event_mode;
5817 uint32_t bypass_mode;
5818 uint32_t timeout = bypass_timeout;
5821 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5822 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5823 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5824 {"UNKNOWN", "normal", "bypass", "isolate"};
5825 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5833 /* Display the bypass mode.*/
5834 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5835 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5840 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5841 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5843 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5846 /* Display the bypass timeout.*/
5847 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5848 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5850 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5852 /* Display the bypass events and associated modes. */
5853 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5855 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5857 "\tFailed to get bypass mode for event = %s\n",
5860 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5861 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5863 printf("\tbypass event: %-16s = %s\n", events[i],
5870 "\tFailed to get bypass configuration for port = %d\n",
5874 cmdline_parse_token_string_t cmd_showbypass_config_show =
5875 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5877 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5878 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5880 cmdline_parse_token_string_t cmd_showbypass_config_config =
5881 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5883 cmdline_parse_token_num_t cmd_showbypass_config_port =
5884 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5885 port_id, RTE_UINT16);
5887 cmdline_parse_inst_t cmd_show_bypass_config = {
5888 .f = cmd_show_bypass_config_parsed,
5889 .help_str = "show bypass config <port_id>: "
5890 "Show the NIC bypass config for port_id",
5893 (void *)&cmd_showbypass_config_show,
5894 (void *)&cmd_showbypass_config_bypass,
5895 (void *)&cmd_showbypass_config_config,
5896 (void *)&cmd_showbypass_config_port,
5902 /* *** SET BONDING MODE *** */
5903 struct cmd_set_bonding_mode_result {
5904 cmdline_fixed_string_t set;
5905 cmdline_fixed_string_t bonding;
5906 cmdline_fixed_string_t mode;
5911 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5912 __rte_unused struct cmdline *cl,
5913 __rte_unused void *data)
5915 struct cmd_set_bonding_mode_result *res = parsed_result;
5916 portid_t port_id = res->port_id;
5918 /* Set the bonding mode for the relevant port. */
5919 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5920 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5924 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5925 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5927 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5929 bonding, "bonding");
5930 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5933 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5934 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5936 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5937 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5938 port_id, RTE_UINT16);
5940 cmdline_parse_inst_t cmd_set_bonding_mode = {
5941 .f = cmd_set_bonding_mode_parsed,
5942 .help_str = "set bonding mode <mode_value> <port_id>: "
5943 "Set the bonding mode for port_id",
5946 (void *) &cmd_setbonding_mode_set,
5947 (void *) &cmd_setbonding_mode_bonding,
5948 (void *) &cmd_setbonding_mode_mode,
5949 (void *) &cmd_setbonding_mode_value,
5950 (void *) &cmd_setbonding_mode_port,
5955 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5956 struct cmd_set_bonding_lacp_dedicated_queues_result {
5957 cmdline_fixed_string_t set;
5958 cmdline_fixed_string_t bonding;
5959 cmdline_fixed_string_t lacp;
5960 cmdline_fixed_string_t dedicated_queues;
5962 cmdline_fixed_string_t mode;
5965 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5966 __rte_unused struct cmdline *cl,
5967 __rte_unused void *data)
5969 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5970 portid_t port_id = res->port_id;
5971 struct rte_port *port;
5973 port = &ports[port_id];
5975 /** Check if the port is not started **/
5976 if (port->port_status != RTE_PORT_STOPPED) {
5977 fprintf(stderr, "Please stop port %d first\n", port_id);
5981 if (!strcmp(res->mode, "enable")) {
5982 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5983 printf("Dedicate queues for LACP control packets"
5986 printf("Enabling dedicate queues for LACP control "
5987 "packets on port %d failed\n", port_id);
5988 } else if (!strcmp(res->mode, "disable")) {
5989 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5990 printf("Dedicated queues for LACP control packets "
5993 printf("Disabling dedicated queues for LACP control "
5994 "traffic on port %d failed\n", port_id);
5998 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5999 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6001 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6002 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6003 bonding, "bonding");
6004 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6005 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6007 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6008 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6009 dedicated_queues, "dedicated_queues");
6010 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6011 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6012 port_id, RTE_UINT16);
6013 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6014 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6015 mode, "enable#disable");
6017 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6018 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6019 .help_str = "set bonding lacp dedicated_queues <port_id> "
6021 "Enable/disable dedicated queues for LACP control traffic for port_id",
6024 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6025 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6026 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6027 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6028 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6029 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6034 /* *** SET BALANCE XMIT POLICY *** */
6035 struct cmd_set_bonding_balance_xmit_policy_result {
6036 cmdline_fixed_string_t set;
6037 cmdline_fixed_string_t bonding;
6038 cmdline_fixed_string_t balance_xmit_policy;
6040 cmdline_fixed_string_t policy;
6043 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6044 __rte_unused struct cmdline *cl,
6045 __rte_unused void *data)
6047 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6048 portid_t port_id = res->port_id;
6051 if (!strcmp(res->policy, "l2")) {
6052 policy = BALANCE_XMIT_POLICY_LAYER2;
6053 } else if (!strcmp(res->policy, "l23")) {
6054 policy = BALANCE_XMIT_POLICY_LAYER23;
6055 } else if (!strcmp(res->policy, "l34")) {
6056 policy = BALANCE_XMIT_POLICY_LAYER34;
6058 fprintf(stderr, "\t Invalid xmit policy selection");
6062 /* Set the bonding mode for the relevant port. */
6063 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6065 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6070 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6071 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6073 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6074 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6075 bonding, "bonding");
6076 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6077 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6078 balance_xmit_policy, "balance_xmit_policy");
6079 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6080 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6081 port_id, RTE_UINT16);
6082 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6083 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6084 policy, "l2#l23#l34");
6086 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6087 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6088 .help_str = "set bonding balance_xmit_policy <port_id> "
6090 "Set the bonding balance_xmit_policy for port_id",
6093 (void *)&cmd_setbonding_balance_xmit_policy_set,
6094 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6095 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6096 (void *)&cmd_setbonding_balance_xmit_policy_port,
6097 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6102 /* *** SHOW NIC BONDING CONFIGURATION *** */
6103 struct cmd_show_bonding_config_result {
6104 cmdline_fixed_string_t show;
6105 cmdline_fixed_string_t bonding;
6106 cmdline_fixed_string_t config;
6110 static void cmd_show_bonding_config_parsed(void *parsed_result,
6111 __rte_unused struct cmdline *cl,
6112 __rte_unused void *data)
6114 struct cmd_show_bonding_config_result *res = parsed_result;
6115 int bonding_mode, agg_mode;
6116 portid_t slaves[RTE_MAX_ETHPORTS];
6117 int num_slaves, num_active_slaves;
6120 portid_t port_id = res->port_id;
6122 /* Display the bonding mode.*/
6123 bonding_mode = rte_eth_bond_mode_get(port_id);
6124 if (bonding_mode < 0) {
6125 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6129 printf("\tBonding mode: %d\n", bonding_mode);
6131 if (bonding_mode == BONDING_MODE_BALANCE) {
6132 int balance_xmit_policy;
6134 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6135 if (balance_xmit_policy < 0) {
6137 "\tFailed to get balance xmit policy for port = %d\n",
6141 printf("\tBalance Xmit Policy: ");
6143 switch (balance_xmit_policy) {
6144 case BALANCE_XMIT_POLICY_LAYER2:
6145 printf("BALANCE_XMIT_POLICY_LAYER2");
6147 case BALANCE_XMIT_POLICY_LAYER23:
6148 printf("BALANCE_XMIT_POLICY_LAYER23");
6150 case BALANCE_XMIT_POLICY_LAYER34:
6151 printf("BALANCE_XMIT_POLICY_LAYER34");
6158 if (bonding_mode == BONDING_MODE_8023AD) {
6159 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6160 printf("\tIEEE802.3AD Aggregator Mode: ");
6163 printf("bandwidth");
6175 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6177 if (num_slaves < 0) {
6178 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6182 if (num_slaves > 0) {
6183 printf("\tSlaves (%d): [", num_slaves);
6184 for (i = 0; i < num_slaves - 1; i++)
6185 printf("%d ", slaves[i]);
6187 printf("%d]\n", slaves[num_slaves - 1]);
6189 printf("\tSlaves: []\n");
6193 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6196 if (num_active_slaves < 0) {
6198 "\tFailed to get active slave list for port = %d\n",
6202 if (num_active_slaves > 0) {
6203 printf("\tActive Slaves (%d): [", num_active_slaves);
6204 for (i = 0; i < num_active_slaves - 1; i++)
6205 printf("%d ", slaves[i]);
6207 printf("%d]\n", slaves[num_active_slaves - 1]);
6210 printf("\tActive Slaves: []\n");
6214 primary_id = rte_eth_bond_primary_get(port_id);
6215 if (primary_id < 0) {
6216 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6220 printf("\tPrimary: [%d]\n", primary_id);
6224 cmdline_parse_token_string_t cmd_showbonding_config_show =
6225 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6227 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6228 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6229 bonding, "bonding");
6230 cmdline_parse_token_string_t cmd_showbonding_config_config =
6231 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6233 cmdline_parse_token_num_t cmd_showbonding_config_port =
6234 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6235 port_id, RTE_UINT16);
6237 cmdline_parse_inst_t cmd_show_bonding_config = {
6238 .f = cmd_show_bonding_config_parsed,
6239 .help_str = "show bonding config <port_id>: "
6240 "Show the bonding config for port_id",
6243 (void *)&cmd_showbonding_config_show,
6244 (void *)&cmd_showbonding_config_bonding,
6245 (void *)&cmd_showbonding_config_config,
6246 (void *)&cmd_showbonding_config_port,
6251 /* *** SET BONDING PRIMARY *** */
6252 struct cmd_set_bonding_primary_result {
6253 cmdline_fixed_string_t set;
6254 cmdline_fixed_string_t bonding;
6255 cmdline_fixed_string_t primary;
6260 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6261 __rte_unused struct cmdline *cl,
6262 __rte_unused void *data)
6264 struct cmd_set_bonding_primary_result *res = parsed_result;
6265 portid_t master_port_id = res->port_id;
6266 portid_t slave_port_id = res->slave_id;
6268 /* Set the primary slave for a bonded device. */
6269 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6270 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6277 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6278 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6280 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6281 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6282 bonding, "bonding");
6283 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6284 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6285 primary, "primary");
6286 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6287 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6288 slave_id, RTE_UINT16);
6289 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6290 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6291 port_id, RTE_UINT16);
6293 cmdline_parse_inst_t cmd_set_bonding_primary = {
6294 .f = cmd_set_bonding_primary_parsed,
6295 .help_str = "set bonding primary <slave_id> <port_id>: "
6296 "Set the primary slave for port_id",
6299 (void *)&cmd_setbonding_primary_set,
6300 (void *)&cmd_setbonding_primary_bonding,
6301 (void *)&cmd_setbonding_primary_primary,
6302 (void *)&cmd_setbonding_primary_slave,
6303 (void *)&cmd_setbonding_primary_port,
6308 /* *** ADD SLAVE *** */
6309 struct cmd_add_bonding_slave_result {
6310 cmdline_fixed_string_t add;
6311 cmdline_fixed_string_t bonding;
6312 cmdline_fixed_string_t slave;
6317 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6318 __rte_unused struct cmdline *cl,
6319 __rte_unused void *data)
6321 struct cmd_add_bonding_slave_result *res = parsed_result;
6322 portid_t master_port_id = res->port_id;
6323 portid_t slave_port_id = res->slave_id;
6325 /* add the slave for a bonded device. */
6326 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6328 "\t Failed to add slave %d to master port = %d.\n",
6329 slave_port_id, master_port_id);
6333 set_port_slave_flag(slave_port_id);
6336 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6337 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6339 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6340 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6341 bonding, "bonding");
6342 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6343 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6345 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6346 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6347 slave_id, RTE_UINT16);
6348 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6349 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6350 port_id, RTE_UINT16);
6352 cmdline_parse_inst_t cmd_add_bonding_slave = {
6353 .f = cmd_add_bonding_slave_parsed,
6354 .help_str = "add bonding slave <slave_id> <port_id>: "
6355 "Add a slave device to a bonded device",
6358 (void *)&cmd_addbonding_slave_add,
6359 (void *)&cmd_addbonding_slave_bonding,
6360 (void *)&cmd_addbonding_slave_slave,
6361 (void *)&cmd_addbonding_slave_slaveid,
6362 (void *)&cmd_addbonding_slave_port,
6367 /* *** REMOVE SLAVE *** */
6368 struct cmd_remove_bonding_slave_result {
6369 cmdline_fixed_string_t remove;
6370 cmdline_fixed_string_t bonding;
6371 cmdline_fixed_string_t slave;
6376 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6377 __rte_unused struct cmdline *cl,
6378 __rte_unused void *data)
6380 struct cmd_remove_bonding_slave_result *res = parsed_result;
6381 portid_t master_port_id = res->port_id;
6382 portid_t slave_port_id = res->slave_id;
6384 /* remove the slave from a bonded device. */
6385 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6387 "\t Failed to remove slave %d from master port = %d.\n",
6388 slave_port_id, master_port_id);
6392 clear_port_slave_flag(slave_port_id);
6395 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6396 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6398 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6399 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6400 bonding, "bonding");
6401 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6402 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6404 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6405 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6406 slave_id, RTE_UINT16);
6407 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6408 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6409 port_id, RTE_UINT16);
6411 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6412 .f = cmd_remove_bonding_slave_parsed,
6413 .help_str = "remove bonding slave <slave_id> <port_id>: "
6414 "Remove a slave device from a bonded device",
6417 (void *)&cmd_removebonding_slave_remove,
6418 (void *)&cmd_removebonding_slave_bonding,
6419 (void *)&cmd_removebonding_slave_slave,
6420 (void *)&cmd_removebonding_slave_slaveid,
6421 (void *)&cmd_removebonding_slave_port,
6426 /* *** CREATE BONDED DEVICE *** */
6427 struct cmd_create_bonded_device_result {
6428 cmdline_fixed_string_t create;
6429 cmdline_fixed_string_t bonded;
6430 cmdline_fixed_string_t device;
6435 static int bond_dev_num = 0;
6437 static void cmd_create_bonded_device_parsed(void *parsed_result,
6438 __rte_unused struct cmdline *cl,
6439 __rte_unused void *data)
6441 struct cmd_create_bonded_device_result *res = parsed_result;
6442 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6446 if (test_done == 0) {
6447 fprintf(stderr, "Please stop forwarding first\n");
6451 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6454 /* Create a new bonded device. */
6455 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6457 fprintf(stderr, "\t Failed to create bonded device.\n");
6460 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6463 /* Update number of ports */
6464 nb_ports = rte_eth_dev_count_avail();
6465 reconfig(port_id, res->socket);
6466 ret = rte_eth_promiscuous_enable(port_id);
6469 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6470 port_id, rte_strerror(-ret));
6472 ports[port_id].need_setup = 0;
6473 ports[port_id].port_status = RTE_PORT_STOPPED;
6478 cmdline_parse_token_string_t cmd_createbonded_device_create =
6479 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6481 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6482 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6484 cmdline_parse_token_string_t cmd_createbonded_device_device =
6485 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6487 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6488 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6490 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6491 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6494 cmdline_parse_inst_t cmd_create_bonded_device = {
6495 .f = cmd_create_bonded_device_parsed,
6496 .help_str = "create bonded device <mode> <socket>: "
6497 "Create a new bonded device with specific bonding mode and socket",
6500 (void *)&cmd_createbonded_device_create,
6501 (void *)&cmd_createbonded_device_bonded,
6502 (void *)&cmd_createbonded_device_device,
6503 (void *)&cmd_createbonded_device_mode,
6504 (void *)&cmd_createbonded_device_socket,
6509 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6510 struct cmd_set_bond_mac_addr_result {
6511 cmdline_fixed_string_t set;
6512 cmdline_fixed_string_t bonding;
6513 cmdline_fixed_string_t mac_addr;
6515 struct rte_ether_addr address;
6518 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6519 __rte_unused struct cmdline *cl,
6520 __rte_unused void *data)
6522 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6525 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6528 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6530 /* check the return value and print it if is < 0 */
6532 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6536 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6537 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6538 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6539 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6541 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6542 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6544 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6545 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6546 port_num, RTE_UINT16);
6547 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6548 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6550 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6551 .f = cmd_set_bond_mac_addr_parsed,
6553 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6555 (void *)&cmd_set_bond_mac_addr_set,
6556 (void *)&cmd_set_bond_mac_addr_bonding,
6557 (void *)&cmd_set_bond_mac_addr_mac,
6558 (void *)&cmd_set_bond_mac_addr_portnum,
6559 (void *)&cmd_set_bond_mac_addr_addr,
6565 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6566 struct cmd_set_bond_mon_period_result {
6567 cmdline_fixed_string_t set;
6568 cmdline_fixed_string_t bonding;
6569 cmdline_fixed_string_t mon_period;
6574 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6575 __rte_unused struct cmdline *cl,
6576 __rte_unused void *data)
6578 struct cmd_set_bond_mon_period_result *res = parsed_result;
6581 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6583 /* check the return value and print it if is < 0 */
6585 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6589 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6590 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6592 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6593 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6594 bonding, "bonding");
6595 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6596 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6597 mon_period, "mon_period");
6598 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6599 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6600 port_num, RTE_UINT16);
6601 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6602 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6603 period_ms, RTE_UINT32);
6605 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6606 .f = cmd_set_bond_mon_period_parsed,
6608 .help_str = "set bonding mon_period <port_id> <period_ms>",
6610 (void *)&cmd_set_bond_mon_period_set,
6611 (void *)&cmd_set_bond_mon_period_bonding,
6612 (void *)&cmd_set_bond_mon_period_mon_period,
6613 (void *)&cmd_set_bond_mon_period_portnum,
6614 (void *)&cmd_set_bond_mon_period_period_ms,
6621 struct cmd_set_bonding_agg_mode_policy_result {
6622 cmdline_fixed_string_t set;
6623 cmdline_fixed_string_t bonding;
6624 cmdline_fixed_string_t agg_mode;
6626 cmdline_fixed_string_t policy;
6631 cmd_set_bonding_agg_mode(void *parsed_result,
6632 __rte_unused struct cmdline *cl,
6633 __rte_unused void *data)
6635 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6636 uint8_t policy = AGG_BANDWIDTH;
6638 if (!strcmp(res->policy, "bandwidth"))
6639 policy = AGG_BANDWIDTH;
6640 else if (!strcmp(res->policy, "stable"))
6641 policy = AGG_STABLE;
6642 else if (!strcmp(res->policy, "count"))
6645 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6649 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6650 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6652 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6653 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6654 bonding, "bonding");
6656 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6657 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6658 agg_mode, "agg_mode");
6660 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6661 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6662 port_num, RTE_UINT16);
6664 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6665 TOKEN_STRING_INITIALIZER(
6666 struct cmd_set_bonding_balance_xmit_policy_result,
6667 policy, "stable#bandwidth#count");
6669 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6670 .f = cmd_set_bonding_agg_mode,
6672 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6674 (void *)&cmd_set_bonding_agg_mode_set,
6675 (void *)&cmd_set_bonding_agg_mode_bonding,
6676 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6677 (void *)&cmd_set_bonding_agg_mode_portnum,
6678 (void *)&cmd_set_bonding_agg_mode_policy_string,
6684 #endif /* RTE_NET_BOND */
6686 /* *** SET FORWARDING MODE *** */
6687 struct cmd_set_fwd_mode_result {
6688 cmdline_fixed_string_t set;
6689 cmdline_fixed_string_t fwd;
6690 cmdline_fixed_string_t mode;
6693 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6694 __rte_unused struct cmdline *cl,
6695 __rte_unused void *data)
6697 struct cmd_set_fwd_mode_result *res = parsed_result;
6700 set_pkt_forwarding_mode(res->mode);
6703 cmdline_parse_token_string_t cmd_setfwd_set =
6704 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6705 cmdline_parse_token_string_t cmd_setfwd_fwd =
6706 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6707 cmdline_parse_token_string_t cmd_setfwd_mode =
6708 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6709 "" /* defined at init */);
6711 cmdline_parse_inst_t cmd_set_fwd_mode = {
6712 .f = cmd_set_fwd_mode_parsed,
6714 .help_str = NULL, /* defined at init */
6716 (void *)&cmd_setfwd_set,
6717 (void *)&cmd_setfwd_fwd,
6718 (void *)&cmd_setfwd_mode,
6723 static void cmd_set_fwd_mode_init(void)
6726 static char token[128];
6727 static char help[256];
6728 cmdline_parse_token_string_t *token_struct;
6730 modes = list_pkt_forwarding_modes();
6731 snprintf(help, sizeof(help), "set fwd %s: "
6732 "Set packet forwarding mode", modes);
6733 cmd_set_fwd_mode.help_str = help;
6735 /* string token separator is # */
6736 for (c = token; *modes != '\0'; modes++)
6741 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6742 token_struct->string_data.str = token;
6745 /* *** SET RETRY FORWARDING MODE *** */
6746 struct cmd_set_fwd_retry_mode_result {
6747 cmdline_fixed_string_t set;
6748 cmdline_fixed_string_t fwd;
6749 cmdline_fixed_string_t mode;
6750 cmdline_fixed_string_t retry;
6753 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6754 __rte_unused struct cmdline *cl,
6755 __rte_unused void *data)
6757 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6760 set_pkt_forwarding_mode(res->mode);
6763 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6764 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6766 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6767 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6769 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6770 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6772 "" /* defined at init */);
6773 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6774 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6777 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6778 .f = cmd_set_fwd_retry_mode_parsed,
6780 .help_str = NULL, /* defined at init */
6782 (void *)&cmd_setfwd_retry_set,
6783 (void *)&cmd_setfwd_retry_fwd,
6784 (void *)&cmd_setfwd_retry_mode,
6785 (void *)&cmd_setfwd_retry_retry,
6790 static void cmd_set_fwd_retry_mode_init(void)
6793 static char token[128];
6794 static char help[256];
6795 cmdline_parse_token_string_t *token_struct;
6797 modes = list_pkt_forwarding_retry_modes();
6798 snprintf(help, sizeof(help), "set fwd %s retry: "
6799 "Set packet forwarding mode with retry", modes);
6800 cmd_set_fwd_retry_mode.help_str = help;
6802 /* string token separator is # */
6803 for (c = token; *modes != '\0'; modes++)
6808 token_struct = (cmdline_parse_token_string_t *)
6809 cmd_set_fwd_retry_mode.tokens[2];
6810 token_struct->string_data.str = token;
6813 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6814 struct cmd_set_burst_tx_retry_result {
6815 cmdline_fixed_string_t set;
6816 cmdline_fixed_string_t burst;
6817 cmdline_fixed_string_t tx;
6818 cmdline_fixed_string_t delay;
6820 cmdline_fixed_string_t retry;
6824 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6825 __rte_unused struct cmdline *cl,
6826 __rte_unused void *data)
6828 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6830 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6831 && !strcmp(res->tx, "tx")) {
6832 if (!strcmp(res->delay, "delay"))
6833 burst_tx_delay_time = res->time;
6834 if (!strcmp(res->retry, "retry"))
6835 burst_tx_retry_num = res->retry_num;
6840 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6841 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6842 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6843 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6845 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6846 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6847 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6848 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6849 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6850 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6852 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6853 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6854 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6855 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6858 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6859 .f = cmd_set_burst_tx_retry_parsed,
6860 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6862 (void *)&cmd_set_burst_tx_retry_set,
6863 (void *)&cmd_set_burst_tx_retry_burst,
6864 (void *)&cmd_set_burst_tx_retry_tx,
6865 (void *)&cmd_set_burst_tx_retry_delay,
6866 (void *)&cmd_set_burst_tx_retry_time,
6867 (void *)&cmd_set_burst_tx_retry_retry,
6868 (void *)&cmd_set_burst_tx_retry_retry_num,
6873 /* *** SET PROMISC MODE *** */
6874 struct cmd_set_promisc_mode_result {
6875 cmdline_fixed_string_t set;
6876 cmdline_fixed_string_t promisc;
6877 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6878 uint16_t port_num; /* valid if "allports" argument == 0 */
6879 cmdline_fixed_string_t mode;
6882 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6883 __rte_unused struct cmdline *cl,
6886 struct cmd_set_promisc_mode_result *res = parsed_result;
6890 if (!strcmp(res->mode, "on"))
6897 RTE_ETH_FOREACH_DEV(i)
6898 eth_set_promisc_mode(i, enable);
6900 eth_set_promisc_mode(res->port_num, enable);
6904 cmdline_parse_token_string_t cmd_setpromisc_set =
6905 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6906 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6907 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6909 cmdline_parse_token_string_t cmd_setpromisc_portall =
6910 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6912 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6913 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6915 cmdline_parse_token_string_t cmd_setpromisc_mode =
6916 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6919 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6920 .f = cmd_set_promisc_mode_parsed,
6922 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6924 (void *)&cmd_setpromisc_set,
6925 (void *)&cmd_setpromisc_promisc,
6926 (void *)&cmd_setpromisc_portall,
6927 (void *)&cmd_setpromisc_mode,
6932 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6933 .f = cmd_set_promisc_mode_parsed,
6935 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6937 (void *)&cmd_setpromisc_set,
6938 (void *)&cmd_setpromisc_promisc,
6939 (void *)&cmd_setpromisc_portnum,
6940 (void *)&cmd_setpromisc_mode,
6945 /* *** SET ALLMULTI MODE *** */
6946 struct cmd_set_allmulti_mode_result {
6947 cmdline_fixed_string_t set;
6948 cmdline_fixed_string_t allmulti;
6949 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6950 uint16_t port_num; /* valid if "allports" argument == 0 */
6951 cmdline_fixed_string_t mode;
6954 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6955 __rte_unused struct cmdline *cl,
6958 struct cmd_set_allmulti_mode_result *res = parsed_result;
6962 if (!strcmp(res->mode, "on"))
6969 RTE_ETH_FOREACH_DEV(i) {
6970 eth_set_allmulticast_mode(i, enable);
6974 eth_set_allmulticast_mode(res->port_num, enable);
6978 cmdline_parse_token_string_t cmd_setallmulti_set =
6979 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6980 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6981 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6983 cmdline_parse_token_string_t cmd_setallmulti_portall =
6984 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6986 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6987 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6989 cmdline_parse_token_string_t cmd_setallmulti_mode =
6990 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6993 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6994 .f = cmd_set_allmulti_mode_parsed,
6996 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6998 (void *)&cmd_setallmulti_set,
6999 (void *)&cmd_setallmulti_allmulti,
7000 (void *)&cmd_setallmulti_portall,
7001 (void *)&cmd_setallmulti_mode,
7006 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7007 .f = cmd_set_allmulti_mode_parsed,
7009 .help_str = "set allmulti <port_id> on|off: "
7010 "Set allmulti mode on port_id",
7012 (void *)&cmd_setallmulti_set,
7013 (void *)&cmd_setallmulti_allmulti,
7014 (void *)&cmd_setallmulti_portnum,
7015 (void *)&cmd_setallmulti_mode,
7020 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7021 struct cmd_link_flow_ctrl_show {
7022 cmdline_fixed_string_t show;
7023 cmdline_fixed_string_t port;
7025 cmdline_fixed_string_t flow_ctrl;
7028 cmdline_parse_token_string_t cmd_lfc_show_show =
7029 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7031 cmdline_parse_token_string_t cmd_lfc_show_port =
7032 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7034 cmdline_parse_token_num_t cmd_lfc_show_portid =
7035 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7036 port_id, RTE_UINT16);
7037 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7038 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7039 flow_ctrl, "flow_ctrl");
7042 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7043 __rte_unused struct cmdline *cl,
7044 __rte_unused void *data)
7046 struct cmd_link_flow_ctrl_show *res = parsed_result;
7047 static const char *info_border = "*********************";
7048 struct rte_eth_fc_conf fc_conf;
7049 bool rx_fc_en = false;
7050 bool tx_fc_en = false;
7053 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7056 "Failed to get current flow ctrl information: err = %d\n",
7061 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7063 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7066 printf("\n%s Flow control infos for port %-2d %s\n",
7067 info_border, res->port_id, info_border);
7068 printf("FC mode:\n");
7069 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7070 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7071 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7072 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7073 printf("High waterline: 0x%x\n", fc_conf.high_water);
7074 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7075 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7076 printf("Forward MAC control frames: %s\n",
7077 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7078 printf("\n%s************** End ***********%s\n",
7079 info_border, info_border);
7082 cmdline_parse_inst_t cmd_link_flow_control_show = {
7083 .f = cmd_link_flow_ctrl_show_parsed,
7085 .help_str = "show port <port_id> flow_ctrl",
7087 (void *)&cmd_lfc_show_show,
7088 (void *)&cmd_lfc_show_port,
7089 (void *)&cmd_lfc_show_portid,
7090 (void *)&cmd_lfc_show_flow_ctrl,
7095 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7096 struct cmd_link_flow_ctrl_set_result {
7097 cmdline_fixed_string_t set;
7098 cmdline_fixed_string_t flow_ctrl;
7099 cmdline_fixed_string_t rx;
7100 cmdline_fixed_string_t rx_lfc_mode;
7101 cmdline_fixed_string_t tx;
7102 cmdline_fixed_string_t tx_lfc_mode;
7103 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7104 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7105 cmdline_fixed_string_t autoneg_str;
7106 cmdline_fixed_string_t autoneg;
7107 cmdline_fixed_string_t hw_str;
7108 uint32_t high_water;
7109 cmdline_fixed_string_t lw_str;
7111 cmdline_fixed_string_t pt_str;
7112 uint16_t pause_time;
7113 cmdline_fixed_string_t xon_str;
7118 cmdline_parse_token_string_t cmd_lfc_set_set =
7119 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7121 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7122 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7123 flow_ctrl, "flow_ctrl");
7124 cmdline_parse_token_string_t cmd_lfc_set_rx =
7125 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7127 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7128 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7129 rx_lfc_mode, "on#off");
7130 cmdline_parse_token_string_t cmd_lfc_set_tx =
7131 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7133 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7134 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7135 tx_lfc_mode, "on#off");
7136 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7137 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7138 hw_str, "high_water");
7139 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7140 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7141 high_water, RTE_UINT32);
7142 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7143 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7144 lw_str, "low_water");
7145 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7146 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7147 low_water, RTE_UINT32);
7148 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7149 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7150 pt_str, "pause_time");
7151 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7152 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7153 pause_time, RTE_UINT16);
7154 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7155 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7156 xon_str, "send_xon");
7157 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7158 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7159 send_xon, RTE_UINT16);
7160 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7161 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7162 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7163 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7164 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7165 mac_ctrl_frame_fwd_mode, "on#off");
7166 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7168 autoneg_str, "autoneg");
7169 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7172 cmdline_parse_token_num_t cmd_lfc_set_portid =
7173 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7174 port_id, RTE_UINT16);
7176 /* forward declaration */
7178 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7181 cmdline_parse_inst_t cmd_link_flow_control_set = {
7182 .f = cmd_link_flow_ctrl_set_parsed,
7184 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7185 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7186 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7188 (void *)&cmd_lfc_set_set,
7189 (void *)&cmd_lfc_set_flow_ctrl,
7190 (void *)&cmd_lfc_set_rx,
7191 (void *)&cmd_lfc_set_rx_mode,
7192 (void *)&cmd_lfc_set_tx,
7193 (void *)&cmd_lfc_set_tx_mode,
7194 (void *)&cmd_lfc_set_high_water,
7195 (void *)&cmd_lfc_set_low_water,
7196 (void *)&cmd_lfc_set_pause_time,
7197 (void *)&cmd_lfc_set_send_xon,
7198 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7199 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7200 (void *)&cmd_lfc_set_autoneg_str,
7201 (void *)&cmd_lfc_set_autoneg,
7202 (void *)&cmd_lfc_set_portid,
7207 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7208 .f = cmd_link_flow_ctrl_set_parsed,
7209 .data = (void *)&cmd_link_flow_control_set_rx,
7210 .help_str = "set flow_ctrl rx on|off <port_id>: "
7211 "Change rx flow control parameter",
7213 (void *)&cmd_lfc_set_set,
7214 (void *)&cmd_lfc_set_flow_ctrl,
7215 (void *)&cmd_lfc_set_rx,
7216 (void *)&cmd_lfc_set_rx_mode,
7217 (void *)&cmd_lfc_set_portid,
7222 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7223 .f = cmd_link_flow_ctrl_set_parsed,
7224 .data = (void *)&cmd_link_flow_control_set_tx,
7225 .help_str = "set flow_ctrl tx on|off <port_id>: "
7226 "Change tx flow control parameter",
7228 (void *)&cmd_lfc_set_set,
7229 (void *)&cmd_lfc_set_flow_ctrl,
7230 (void *)&cmd_lfc_set_tx,
7231 (void *)&cmd_lfc_set_tx_mode,
7232 (void *)&cmd_lfc_set_portid,
7237 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7238 .f = cmd_link_flow_ctrl_set_parsed,
7239 .data = (void *)&cmd_link_flow_control_set_hw,
7240 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7241 "Change high water flow control parameter",
7243 (void *)&cmd_lfc_set_set,
7244 (void *)&cmd_lfc_set_flow_ctrl,
7245 (void *)&cmd_lfc_set_high_water_str,
7246 (void *)&cmd_lfc_set_high_water,
7247 (void *)&cmd_lfc_set_portid,
7252 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7253 .f = cmd_link_flow_ctrl_set_parsed,
7254 .data = (void *)&cmd_link_flow_control_set_lw,
7255 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7256 "Change low water flow control parameter",
7258 (void *)&cmd_lfc_set_set,
7259 (void *)&cmd_lfc_set_flow_ctrl,
7260 (void *)&cmd_lfc_set_low_water_str,
7261 (void *)&cmd_lfc_set_low_water,
7262 (void *)&cmd_lfc_set_portid,
7267 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7268 .f = cmd_link_flow_ctrl_set_parsed,
7269 .data = (void *)&cmd_link_flow_control_set_pt,
7270 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7271 "Change pause time flow control parameter",
7273 (void *)&cmd_lfc_set_set,
7274 (void *)&cmd_lfc_set_flow_ctrl,
7275 (void *)&cmd_lfc_set_pause_time_str,
7276 (void *)&cmd_lfc_set_pause_time,
7277 (void *)&cmd_lfc_set_portid,
7282 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7283 .f = cmd_link_flow_ctrl_set_parsed,
7284 .data = (void *)&cmd_link_flow_control_set_xon,
7285 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7286 "Change send_xon flow control parameter",
7288 (void *)&cmd_lfc_set_set,
7289 (void *)&cmd_lfc_set_flow_ctrl,
7290 (void *)&cmd_lfc_set_send_xon_str,
7291 (void *)&cmd_lfc_set_send_xon,
7292 (void *)&cmd_lfc_set_portid,
7297 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7298 .f = cmd_link_flow_ctrl_set_parsed,
7299 .data = (void *)&cmd_link_flow_control_set_macfwd,
7300 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7301 "Change mac ctrl fwd flow control parameter",
7303 (void *)&cmd_lfc_set_set,
7304 (void *)&cmd_lfc_set_flow_ctrl,
7305 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7306 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7307 (void *)&cmd_lfc_set_portid,
7312 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7313 .f = cmd_link_flow_ctrl_set_parsed,
7314 .data = (void *)&cmd_link_flow_control_set_autoneg,
7315 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7316 "Change autoneg flow control parameter",
7318 (void *)&cmd_lfc_set_set,
7319 (void *)&cmd_lfc_set_flow_ctrl,
7320 (void *)&cmd_lfc_set_autoneg_str,
7321 (void *)&cmd_lfc_set_autoneg,
7322 (void *)&cmd_lfc_set_portid,
7328 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7329 __rte_unused struct cmdline *cl,
7332 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7333 cmdline_parse_inst_t *cmd = data;
7334 struct rte_eth_fc_conf fc_conf;
7340 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7341 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7342 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7343 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7345 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7346 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7349 /* Partial command line, retrieve current configuration */
7351 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7354 "cannot get current flow ctrl parameters, return code = %d\n",
7359 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7360 (fc_conf.mode == RTE_FC_FULL))
7362 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7363 (fc_conf.mode == RTE_FC_FULL))
7367 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7368 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7370 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7371 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7373 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7375 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7376 fc_conf.high_water = res->high_water;
7378 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7379 fc_conf.low_water = res->low_water;
7381 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7382 fc_conf.pause_time = res->pause_time;
7384 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7385 fc_conf.send_xon = res->send_xon;
7387 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7388 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7389 fc_conf.mac_ctrl_frame_fwd = 1;
7391 fc_conf.mac_ctrl_frame_fwd = 0;
7394 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7395 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7397 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7400 "bad flow control parameter, return code = %d\n",
7404 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7405 struct cmd_priority_flow_ctrl_set_result {
7406 cmdline_fixed_string_t set;
7407 cmdline_fixed_string_t pfc_ctrl;
7408 cmdline_fixed_string_t rx;
7409 cmdline_fixed_string_t rx_pfc_mode;
7410 cmdline_fixed_string_t tx;
7411 cmdline_fixed_string_t tx_pfc_mode;
7412 uint32_t high_water;
7414 uint16_t pause_time;
7420 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7421 __rte_unused struct cmdline *cl,
7422 __rte_unused void *data)
7424 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7425 struct rte_eth_pfc_conf pfc_conf;
7426 int rx_fc_enable, tx_fc_enable;
7430 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7431 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7432 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7433 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7435 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7436 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7439 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7440 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7441 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7442 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7443 pfc_conf.fc.high_water = res->high_water;
7444 pfc_conf.fc.low_water = res->low_water;
7445 pfc_conf.fc.pause_time = res->pause_time;
7446 pfc_conf.priority = res->priority;
7448 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7451 "bad priority flow control parameter, return code = %d\n",
7455 cmdline_parse_token_string_t cmd_pfc_set_set =
7456 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7458 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7459 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7460 pfc_ctrl, "pfc_ctrl");
7461 cmdline_parse_token_string_t cmd_pfc_set_rx =
7462 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7464 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7465 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7466 rx_pfc_mode, "on#off");
7467 cmdline_parse_token_string_t cmd_pfc_set_tx =
7468 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7470 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7471 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7472 tx_pfc_mode, "on#off");
7473 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7474 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7475 high_water, RTE_UINT32);
7476 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7477 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7478 low_water, RTE_UINT32);
7479 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7480 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7481 pause_time, RTE_UINT16);
7482 cmdline_parse_token_num_t cmd_pfc_set_priority =
7483 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7484 priority, RTE_UINT8);
7485 cmdline_parse_token_num_t cmd_pfc_set_portid =
7486 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7487 port_id, RTE_UINT16);
7489 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7490 .f = cmd_priority_flow_ctrl_set_parsed,
7492 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7493 "<pause_time> <priority> <port_id>: "
7494 "Configure the Ethernet priority flow control",
7496 (void *)&cmd_pfc_set_set,
7497 (void *)&cmd_pfc_set_flow_ctrl,
7498 (void *)&cmd_pfc_set_rx,
7499 (void *)&cmd_pfc_set_rx_mode,
7500 (void *)&cmd_pfc_set_tx,
7501 (void *)&cmd_pfc_set_tx_mode,
7502 (void *)&cmd_pfc_set_high_water,
7503 (void *)&cmd_pfc_set_low_water,
7504 (void *)&cmd_pfc_set_pause_time,
7505 (void *)&cmd_pfc_set_priority,
7506 (void *)&cmd_pfc_set_portid,
7511 /* *** RESET CONFIGURATION *** */
7512 struct cmd_reset_result {
7513 cmdline_fixed_string_t reset;
7514 cmdline_fixed_string_t def;
7517 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7519 __rte_unused void *data)
7521 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7522 set_def_fwd_config();
7525 cmdline_parse_token_string_t cmd_reset_set =
7526 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7527 cmdline_parse_token_string_t cmd_reset_def =
7528 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7531 cmdline_parse_inst_t cmd_reset = {
7532 .f = cmd_reset_parsed,
7534 .help_str = "set default: Reset default forwarding configuration",
7536 (void *)&cmd_reset_set,
7537 (void *)&cmd_reset_def,
7542 /* *** START FORWARDING *** */
7543 struct cmd_start_result {
7544 cmdline_fixed_string_t start;
7547 cmdline_parse_token_string_t cmd_start_start =
7548 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7550 static void cmd_start_parsed(__rte_unused void *parsed_result,
7551 __rte_unused struct cmdline *cl,
7552 __rte_unused void *data)
7554 start_packet_forwarding(0);
7557 cmdline_parse_inst_t cmd_start = {
7558 .f = cmd_start_parsed,
7560 .help_str = "start: Start packet forwarding",
7562 (void *)&cmd_start_start,
7567 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7568 struct cmd_start_tx_first_result {
7569 cmdline_fixed_string_t start;
7570 cmdline_fixed_string_t tx_first;
7574 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7575 __rte_unused struct cmdline *cl,
7576 __rte_unused void *data)
7578 start_packet_forwarding(1);
7581 cmdline_parse_token_string_t cmd_start_tx_first_start =
7582 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7584 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7585 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7586 tx_first, "tx_first");
7588 cmdline_parse_inst_t cmd_start_tx_first = {
7589 .f = cmd_start_tx_first_parsed,
7591 .help_str = "start tx_first: Start packet forwarding, "
7592 "after sending 1 burst of packets",
7594 (void *)&cmd_start_tx_first_start,
7595 (void *)&cmd_start_tx_first_tx_first,
7600 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7601 struct cmd_start_tx_first_n_result {
7602 cmdline_fixed_string_t start;
7603 cmdline_fixed_string_t tx_first;
7608 cmd_start_tx_first_n_parsed(void *parsed_result,
7609 __rte_unused struct cmdline *cl,
7610 __rte_unused void *data)
7612 struct cmd_start_tx_first_n_result *res = parsed_result;
7614 start_packet_forwarding(res->tx_num);
7617 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7618 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7620 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7621 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7622 tx_first, "tx_first");
7623 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7624 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7625 tx_num, RTE_UINT32);
7627 cmdline_parse_inst_t cmd_start_tx_first_n = {
7628 .f = cmd_start_tx_first_n_parsed,
7630 .help_str = "start tx_first <num>: "
7631 "packet forwarding, after sending <num> bursts of packets",
7633 (void *)&cmd_start_tx_first_n_start,
7634 (void *)&cmd_start_tx_first_n_tx_first,
7635 (void *)&cmd_start_tx_first_n_tx_num,
7640 /* *** SET LINK UP *** */
7641 struct cmd_set_link_up_result {
7642 cmdline_fixed_string_t set;
7643 cmdline_fixed_string_t link_up;
7644 cmdline_fixed_string_t port;
7648 cmdline_parse_token_string_t cmd_set_link_up_set =
7649 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7650 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7651 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7653 cmdline_parse_token_string_t cmd_set_link_up_port =
7654 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7655 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7656 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7659 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7660 __rte_unused struct cmdline *cl,
7661 __rte_unused void *data)
7663 struct cmd_set_link_up_result *res = parsed_result;
7664 dev_set_link_up(res->port_id);
7667 cmdline_parse_inst_t cmd_set_link_up = {
7668 .f = cmd_set_link_up_parsed,
7670 .help_str = "set link-up port <port id>",
7672 (void *)&cmd_set_link_up_set,
7673 (void *)&cmd_set_link_up_link_up,
7674 (void *)&cmd_set_link_up_port,
7675 (void *)&cmd_set_link_up_port_id,
7680 /* *** SET LINK DOWN *** */
7681 struct cmd_set_link_down_result {
7682 cmdline_fixed_string_t set;
7683 cmdline_fixed_string_t link_down;
7684 cmdline_fixed_string_t port;
7688 cmdline_parse_token_string_t cmd_set_link_down_set =
7689 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7690 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7691 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7693 cmdline_parse_token_string_t cmd_set_link_down_port =
7694 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7695 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7696 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7699 static void cmd_set_link_down_parsed(
7700 __rte_unused void *parsed_result,
7701 __rte_unused struct cmdline *cl,
7702 __rte_unused void *data)
7704 struct cmd_set_link_down_result *res = parsed_result;
7705 dev_set_link_down(res->port_id);
7708 cmdline_parse_inst_t cmd_set_link_down = {
7709 .f = cmd_set_link_down_parsed,
7711 .help_str = "set link-down port <port id>",
7713 (void *)&cmd_set_link_down_set,
7714 (void *)&cmd_set_link_down_link_down,
7715 (void *)&cmd_set_link_down_port,
7716 (void *)&cmd_set_link_down_port_id,
7721 /* *** SHOW CFG *** */
7722 struct cmd_showcfg_result {
7723 cmdline_fixed_string_t show;
7724 cmdline_fixed_string_t cfg;
7725 cmdline_fixed_string_t what;
7728 static void cmd_showcfg_parsed(void *parsed_result,
7729 __rte_unused struct cmdline *cl,
7730 __rte_unused void *data)
7732 struct cmd_showcfg_result *res = parsed_result;
7733 if (!strcmp(res->what, "rxtx"))
7734 rxtx_config_display();
7735 else if (!strcmp(res->what, "cores"))
7736 fwd_lcores_config_display();
7737 else if (!strcmp(res->what, "fwd"))
7738 pkt_fwd_config_display(&cur_fwd_config);
7739 else if (!strcmp(res->what, "rxoffs"))
7740 show_rx_pkt_offsets();
7741 else if (!strcmp(res->what, "rxpkts"))
7742 show_rx_pkt_segments();
7743 else if (!strcmp(res->what, "txpkts"))
7744 show_tx_pkt_segments();
7745 else if (!strcmp(res->what, "txtimes"))
7746 show_tx_pkt_times();
7749 cmdline_parse_token_string_t cmd_showcfg_show =
7750 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7751 cmdline_parse_token_string_t cmd_showcfg_port =
7752 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7753 cmdline_parse_token_string_t cmd_showcfg_what =
7754 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7755 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7757 cmdline_parse_inst_t cmd_showcfg = {
7758 .f = cmd_showcfg_parsed,
7760 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7762 (void *)&cmd_showcfg_show,
7763 (void *)&cmd_showcfg_port,
7764 (void *)&cmd_showcfg_what,
7769 /* *** SHOW ALL PORT INFO *** */
7770 struct cmd_showportall_result {
7771 cmdline_fixed_string_t show;
7772 cmdline_fixed_string_t port;
7773 cmdline_fixed_string_t what;
7774 cmdline_fixed_string_t all;
7777 static void cmd_showportall_parsed(void *parsed_result,
7778 __rte_unused struct cmdline *cl,
7779 __rte_unused void *data)
7783 struct cmd_showportall_result *res = parsed_result;
7784 if (!strcmp(res->show, "clear")) {
7785 if (!strcmp(res->what, "stats"))
7786 RTE_ETH_FOREACH_DEV(i)
7788 else if (!strcmp(res->what, "xstats"))
7789 RTE_ETH_FOREACH_DEV(i)
7790 nic_xstats_clear(i);
7791 } else if (!strcmp(res->what, "info"))
7792 RTE_ETH_FOREACH_DEV(i)
7793 port_infos_display(i);
7794 else if (!strcmp(res->what, "summary")) {
7795 port_summary_header_display();
7796 RTE_ETH_FOREACH_DEV(i)
7797 port_summary_display(i);
7799 else if (!strcmp(res->what, "stats"))
7800 RTE_ETH_FOREACH_DEV(i)
7801 nic_stats_display(i);
7802 else if (!strcmp(res->what, "xstats"))
7803 RTE_ETH_FOREACH_DEV(i)
7804 nic_xstats_display(i);
7805 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7806 else if (!strcmp(res->what, "fdir"))
7807 RTE_ETH_FOREACH_DEV(i)
7810 else if (!strcmp(res->what, "dcb_tc"))
7811 RTE_ETH_FOREACH_DEV(i)
7812 port_dcb_info_display(i);
7815 cmdline_parse_token_string_t cmd_showportall_show =
7816 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7818 cmdline_parse_token_string_t cmd_showportall_port =
7819 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7820 cmdline_parse_token_string_t cmd_showportall_what =
7821 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7822 "info#summary#stats#xstats#fdir#dcb_tc");
7823 cmdline_parse_token_string_t cmd_showportall_all =
7824 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7825 cmdline_parse_inst_t cmd_showportall = {
7826 .f = cmd_showportall_parsed,
7828 .help_str = "show|clear port "
7829 "info|summary|stats|xstats|fdir|dcb_tc all",
7831 (void *)&cmd_showportall_show,
7832 (void *)&cmd_showportall_port,
7833 (void *)&cmd_showportall_what,
7834 (void *)&cmd_showportall_all,
7839 /* *** SHOW PORT INFO *** */
7840 struct cmd_showport_result {
7841 cmdline_fixed_string_t show;
7842 cmdline_fixed_string_t port;
7843 cmdline_fixed_string_t what;
7847 static void cmd_showport_parsed(void *parsed_result,
7848 __rte_unused struct cmdline *cl,
7849 __rte_unused void *data)
7851 struct cmd_showport_result *res = parsed_result;
7852 if (!strcmp(res->show, "clear")) {
7853 if (!strcmp(res->what, "stats"))
7854 nic_stats_clear(res->portnum);
7855 else if (!strcmp(res->what, "xstats"))
7856 nic_xstats_clear(res->portnum);
7857 } else if (!strcmp(res->what, "info"))
7858 port_infos_display(res->portnum);
7859 else if (!strcmp(res->what, "summary")) {
7860 port_summary_header_display();
7861 port_summary_display(res->portnum);
7863 else if (!strcmp(res->what, "stats"))
7864 nic_stats_display(res->portnum);
7865 else if (!strcmp(res->what, "xstats"))
7866 nic_xstats_display(res->portnum);
7867 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7868 else if (!strcmp(res->what, "fdir"))
7869 fdir_get_infos(res->portnum);
7871 else if (!strcmp(res->what, "dcb_tc"))
7872 port_dcb_info_display(res->portnum);
7875 cmdline_parse_token_string_t cmd_showport_show =
7876 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7878 cmdline_parse_token_string_t cmd_showport_port =
7879 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7880 cmdline_parse_token_string_t cmd_showport_what =
7881 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7882 "info#summary#stats#xstats#fdir#dcb_tc");
7883 cmdline_parse_token_num_t cmd_showport_portnum =
7884 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7886 cmdline_parse_inst_t cmd_showport = {
7887 .f = cmd_showport_parsed,
7889 .help_str = "show|clear port "
7890 "info|summary|stats|xstats|fdir|dcb_tc "
7893 (void *)&cmd_showport_show,
7894 (void *)&cmd_showport_port,
7895 (void *)&cmd_showport_what,
7896 (void *)&cmd_showport_portnum,
7901 /* *** SHOW DEVICE INFO *** */
7902 struct cmd_showdevice_result {
7903 cmdline_fixed_string_t show;
7904 cmdline_fixed_string_t device;
7905 cmdline_fixed_string_t what;
7906 cmdline_fixed_string_t identifier;
7909 static void cmd_showdevice_parsed(void *parsed_result,
7910 __rte_unused struct cmdline *cl,
7911 __rte_unused void *data)
7913 struct cmd_showdevice_result *res = parsed_result;
7914 if (!strcmp(res->what, "info")) {
7915 if (!strcmp(res->identifier, "all"))
7916 device_infos_display(NULL);
7918 device_infos_display(res->identifier);
7922 cmdline_parse_token_string_t cmd_showdevice_show =
7923 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7925 cmdline_parse_token_string_t cmd_showdevice_device =
7926 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7927 cmdline_parse_token_string_t cmd_showdevice_what =
7928 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7930 cmdline_parse_token_string_t cmd_showdevice_identifier =
7931 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7934 cmdline_parse_inst_t cmd_showdevice = {
7935 .f = cmd_showdevice_parsed,
7937 .help_str = "show device info <identifier>|all",
7939 (void *)&cmd_showdevice_show,
7940 (void *)&cmd_showdevice_device,
7941 (void *)&cmd_showdevice_what,
7942 (void *)&cmd_showdevice_identifier,
7947 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7948 struct cmd_showeeprom_result {
7949 cmdline_fixed_string_t show;
7950 cmdline_fixed_string_t port;
7952 cmdline_fixed_string_t type;
7955 static void cmd_showeeprom_parsed(void *parsed_result,
7956 __rte_unused struct cmdline *cl,
7957 __rte_unused void *data)
7959 struct cmd_showeeprom_result *res = parsed_result;
7961 if (!strcmp(res->type, "eeprom"))
7962 port_eeprom_display(res->portnum);
7963 else if (!strcmp(res->type, "module_eeprom"))
7964 port_module_eeprom_display(res->portnum);
7966 fprintf(stderr, "Unknown argument\n");
7969 cmdline_parse_token_string_t cmd_showeeprom_show =
7970 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7971 cmdline_parse_token_string_t cmd_showeeprom_port =
7972 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7973 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7974 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7976 cmdline_parse_token_string_t cmd_showeeprom_type =
7977 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7979 cmdline_parse_inst_t cmd_showeeprom = {
7980 .f = cmd_showeeprom_parsed,
7982 .help_str = "show port <port_id> module_eeprom|eeprom",
7984 (void *)&cmd_showeeprom_show,
7985 (void *)&cmd_showeeprom_port,
7986 (void *)&cmd_showeeprom_portnum,
7987 (void *)&cmd_showeeprom_type,
7992 /* *** SHOW QUEUE INFO *** */
7993 struct cmd_showqueue_result {
7994 cmdline_fixed_string_t show;
7995 cmdline_fixed_string_t type;
7996 cmdline_fixed_string_t what;
8002 cmd_showqueue_parsed(void *parsed_result,
8003 __rte_unused struct cmdline *cl,
8004 __rte_unused void *data)
8006 struct cmd_showqueue_result *res = parsed_result;
8008 if (!strcmp(res->type, "rxq"))
8009 rx_queue_infos_display(res->portnum, res->queuenum);
8010 else if (!strcmp(res->type, "txq"))
8011 tx_queue_infos_display(res->portnum, res->queuenum);
8014 cmdline_parse_token_string_t cmd_showqueue_show =
8015 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8016 cmdline_parse_token_string_t cmd_showqueue_type =
8017 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8018 cmdline_parse_token_string_t cmd_showqueue_what =
8019 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8020 cmdline_parse_token_num_t cmd_showqueue_portnum =
8021 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8023 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8024 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8027 cmdline_parse_inst_t cmd_showqueue = {
8028 .f = cmd_showqueue_parsed,
8030 .help_str = "show rxq|txq info <port_id> <queue_id>",
8032 (void *)&cmd_showqueue_show,
8033 (void *)&cmd_showqueue_type,
8034 (void *)&cmd_showqueue_what,
8035 (void *)&cmd_showqueue_portnum,
8036 (void *)&cmd_showqueue_queuenum,
8041 /* show/clear fwd engine statistics */
8043 cmdline_fixed_string_t action;
8044 cmdline_fixed_string_t fwd;
8045 cmdline_fixed_string_t stats;
8046 cmdline_fixed_string_t all;
8049 cmdline_parse_token_string_t cmd_fwd_action =
8050 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8051 cmdline_parse_token_string_t cmd_fwd_fwd =
8052 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8053 cmdline_parse_token_string_t cmd_fwd_stats =
8054 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8055 cmdline_parse_token_string_t cmd_fwd_all =
8056 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8059 cmd_showfwdall_parsed(void *parsed_result,
8060 __rte_unused struct cmdline *cl,
8061 __rte_unused void *data)
8063 struct fwd_result *res = parsed_result;
8065 if (!strcmp(res->action, "show"))
8066 fwd_stats_display();
8071 static cmdline_parse_inst_t cmd_showfwdall = {
8072 .f = cmd_showfwdall_parsed,
8074 .help_str = "show|clear fwd stats all",
8076 (void *)&cmd_fwd_action,
8077 (void *)&cmd_fwd_fwd,
8078 (void *)&cmd_fwd_stats,
8079 (void *)&cmd_fwd_all,
8084 /* *** READ PORT REGISTER *** */
8085 struct cmd_read_reg_result {
8086 cmdline_fixed_string_t read;
8087 cmdline_fixed_string_t reg;
8093 cmd_read_reg_parsed(void *parsed_result,
8094 __rte_unused struct cmdline *cl,
8095 __rte_unused void *data)
8097 struct cmd_read_reg_result *res = parsed_result;
8098 port_reg_display(res->port_id, res->reg_off);
8101 cmdline_parse_token_string_t cmd_read_reg_read =
8102 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8103 cmdline_parse_token_string_t cmd_read_reg_reg =
8104 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8105 cmdline_parse_token_num_t cmd_read_reg_port_id =
8106 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8107 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8108 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8110 cmdline_parse_inst_t cmd_read_reg = {
8111 .f = cmd_read_reg_parsed,
8113 .help_str = "read reg <port_id> <reg_off>",
8115 (void *)&cmd_read_reg_read,
8116 (void *)&cmd_read_reg_reg,
8117 (void *)&cmd_read_reg_port_id,
8118 (void *)&cmd_read_reg_reg_off,
8123 /* *** READ PORT REGISTER BIT FIELD *** */
8124 struct cmd_read_reg_bit_field_result {
8125 cmdline_fixed_string_t read;
8126 cmdline_fixed_string_t regfield;
8134 cmd_read_reg_bit_field_parsed(void *parsed_result,
8135 __rte_unused struct cmdline *cl,
8136 __rte_unused void *data)
8138 struct cmd_read_reg_bit_field_result *res = parsed_result;
8139 port_reg_bit_field_display(res->port_id, res->reg_off,
8140 res->bit1_pos, res->bit2_pos);
8143 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8144 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8146 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8147 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8148 regfield, "regfield");
8149 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8150 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8152 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8153 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8155 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8156 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8158 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8159 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8162 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8163 .f = cmd_read_reg_bit_field_parsed,
8165 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8166 "Read register bit field between bit_x and bit_y included",
8168 (void *)&cmd_read_reg_bit_field_read,
8169 (void *)&cmd_read_reg_bit_field_regfield,
8170 (void *)&cmd_read_reg_bit_field_port_id,
8171 (void *)&cmd_read_reg_bit_field_reg_off,
8172 (void *)&cmd_read_reg_bit_field_bit1_pos,
8173 (void *)&cmd_read_reg_bit_field_bit2_pos,
8178 /* *** READ PORT REGISTER BIT *** */
8179 struct cmd_read_reg_bit_result {
8180 cmdline_fixed_string_t read;
8181 cmdline_fixed_string_t regbit;
8188 cmd_read_reg_bit_parsed(void *parsed_result,
8189 __rte_unused struct cmdline *cl,
8190 __rte_unused void *data)
8192 struct cmd_read_reg_bit_result *res = parsed_result;
8193 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8196 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8197 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8198 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8199 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8201 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8202 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8204 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8205 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8207 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8208 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8211 cmdline_parse_inst_t cmd_read_reg_bit = {
8212 .f = cmd_read_reg_bit_parsed,
8214 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8216 (void *)&cmd_read_reg_bit_read,
8217 (void *)&cmd_read_reg_bit_regbit,
8218 (void *)&cmd_read_reg_bit_port_id,
8219 (void *)&cmd_read_reg_bit_reg_off,
8220 (void *)&cmd_read_reg_bit_bit_pos,
8225 /* *** WRITE PORT REGISTER *** */
8226 struct cmd_write_reg_result {
8227 cmdline_fixed_string_t write;
8228 cmdline_fixed_string_t reg;
8235 cmd_write_reg_parsed(void *parsed_result,
8236 __rte_unused struct cmdline *cl,
8237 __rte_unused void *data)
8239 struct cmd_write_reg_result *res = parsed_result;
8240 port_reg_set(res->port_id, res->reg_off, res->value);
8243 cmdline_parse_token_string_t cmd_write_reg_write =
8244 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8245 cmdline_parse_token_string_t cmd_write_reg_reg =
8246 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8247 cmdline_parse_token_num_t cmd_write_reg_port_id =
8248 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8249 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8250 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8251 cmdline_parse_token_num_t cmd_write_reg_value =
8252 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8254 cmdline_parse_inst_t cmd_write_reg = {
8255 .f = cmd_write_reg_parsed,
8257 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8259 (void *)&cmd_write_reg_write,
8260 (void *)&cmd_write_reg_reg,
8261 (void *)&cmd_write_reg_port_id,
8262 (void *)&cmd_write_reg_reg_off,
8263 (void *)&cmd_write_reg_value,
8268 /* *** WRITE PORT REGISTER BIT FIELD *** */
8269 struct cmd_write_reg_bit_field_result {
8270 cmdline_fixed_string_t write;
8271 cmdline_fixed_string_t regfield;
8280 cmd_write_reg_bit_field_parsed(void *parsed_result,
8281 __rte_unused struct cmdline *cl,
8282 __rte_unused void *data)
8284 struct cmd_write_reg_bit_field_result *res = parsed_result;
8285 port_reg_bit_field_set(res->port_id, res->reg_off,
8286 res->bit1_pos, res->bit2_pos, res->value);
8289 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8290 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8292 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8293 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8294 regfield, "regfield");
8295 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8296 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8298 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8299 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8301 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8302 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8304 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8305 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8307 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8308 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8311 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8312 .f = cmd_write_reg_bit_field_parsed,
8314 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8316 "Set register bit field between bit_x and bit_y included",
8318 (void *)&cmd_write_reg_bit_field_write,
8319 (void *)&cmd_write_reg_bit_field_regfield,
8320 (void *)&cmd_write_reg_bit_field_port_id,
8321 (void *)&cmd_write_reg_bit_field_reg_off,
8322 (void *)&cmd_write_reg_bit_field_bit1_pos,
8323 (void *)&cmd_write_reg_bit_field_bit2_pos,
8324 (void *)&cmd_write_reg_bit_field_value,
8329 /* *** WRITE PORT REGISTER BIT *** */
8330 struct cmd_write_reg_bit_result {
8331 cmdline_fixed_string_t write;
8332 cmdline_fixed_string_t regbit;
8340 cmd_write_reg_bit_parsed(void *parsed_result,
8341 __rte_unused struct cmdline *cl,
8342 __rte_unused void *data)
8344 struct cmd_write_reg_bit_result *res = parsed_result;
8345 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8348 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8349 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8351 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8352 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8354 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8355 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8357 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8358 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8360 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8361 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8363 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8364 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8367 cmdline_parse_inst_t cmd_write_reg_bit = {
8368 .f = cmd_write_reg_bit_parsed,
8370 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8373 (void *)&cmd_write_reg_bit_write,
8374 (void *)&cmd_write_reg_bit_regbit,
8375 (void *)&cmd_write_reg_bit_port_id,
8376 (void *)&cmd_write_reg_bit_reg_off,
8377 (void *)&cmd_write_reg_bit_bit_pos,
8378 (void *)&cmd_write_reg_bit_value,
8383 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8384 struct cmd_read_rxd_txd_result {
8385 cmdline_fixed_string_t read;
8386 cmdline_fixed_string_t rxd_txd;
8393 cmd_read_rxd_txd_parsed(void *parsed_result,
8394 __rte_unused struct cmdline *cl,
8395 __rte_unused void *data)
8397 struct cmd_read_rxd_txd_result *res = parsed_result;
8399 if (!strcmp(res->rxd_txd, "rxd"))
8400 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8401 else if (!strcmp(res->rxd_txd, "txd"))
8402 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8405 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8406 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8407 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8408 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8410 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8411 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8413 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8414 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8416 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8417 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8420 cmdline_parse_inst_t cmd_read_rxd_txd = {
8421 .f = cmd_read_rxd_txd_parsed,
8423 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8425 (void *)&cmd_read_rxd_txd_read,
8426 (void *)&cmd_read_rxd_txd_rxd_txd,
8427 (void *)&cmd_read_rxd_txd_port_id,
8428 (void *)&cmd_read_rxd_txd_queue_id,
8429 (void *)&cmd_read_rxd_txd_desc_id,
8435 struct cmd_quit_result {
8436 cmdline_fixed_string_t quit;
8439 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8441 __rte_unused void *data)
8446 cmdline_parse_token_string_t cmd_quit_quit =
8447 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8449 cmdline_parse_inst_t cmd_quit = {
8450 .f = cmd_quit_parsed,
8452 .help_str = "quit: Exit application",
8454 (void *)&cmd_quit_quit,
8459 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8460 struct cmd_mac_addr_result {
8461 cmdline_fixed_string_t mac_addr_cmd;
8462 cmdline_fixed_string_t what;
8464 struct rte_ether_addr address;
8467 static void cmd_mac_addr_parsed(void *parsed_result,
8468 __rte_unused struct cmdline *cl,
8469 __rte_unused void *data)
8471 struct cmd_mac_addr_result *res = parsed_result;
8474 if (strcmp(res->what, "add") == 0)
8475 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8476 else if (strcmp(res->what, "set") == 0)
8477 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8480 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8482 /* check the return value and print it if is < 0 */
8484 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8488 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8489 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8491 cmdline_parse_token_string_t cmd_mac_addr_what =
8492 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8494 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8495 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8497 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8498 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8500 cmdline_parse_inst_t cmd_mac_addr = {
8501 .f = cmd_mac_addr_parsed,
8503 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8504 "Add/Remove/Set MAC address on port_id",
8506 (void *)&cmd_mac_addr_cmd,
8507 (void *)&cmd_mac_addr_what,
8508 (void *)&cmd_mac_addr_portnum,
8509 (void *)&cmd_mac_addr_addr,
8514 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8515 struct cmd_eth_peer_result {
8516 cmdline_fixed_string_t set;
8517 cmdline_fixed_string_t eth_peer;
8519 cmdline_fixed_string_t peer_addr;
8522 static void cmd_set_eth_peer_parsed(void *parsed_result,
8523 __rte_unused struct cmdline *cl,
8524 __rte_unused void *data)
8526 struct cmd_eth_peer_result *res = parsed_result;
8528 if (test_done == 0) {
8529 fprintf(stderr, "Please stop forwarding first\n");
8532 if (!strcmp(res->eth_peer, "eth-peer")) {
8533 set_fwd_eth_peer(res->port_id, res->peer_addr);
8537 cmdline_parse_token_string_t cmd_eth_peer_set =
8538 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8539 cmdline_parse_token_string_t cmd_eth_peer =
8540 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8541 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8542 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8544 cmdline_parse_token_string_t cmd_eth_peer_addr =
8545 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8547 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8548 .f = cmd_set_eth_peer_parsed,
8550 .help_str = "set eth-peer <port_id> <peer_mac>",
8552 (void *)&cmd_eth_peer_set,
8553 (void *)&cmd_eth_peer,
8554 (void *)&cmd_eth_peer_port_id,
8555 (void *)&cmd_eth_peer_addr,
8560 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8561 struct cmd_set_qmap_result {
8562 cmdline_fixed_string_t set;
8563 cmdline_fixed_string_t qmap;
8564 cmdline_fixed_string_t what;
8571 cmd_set_qmap_parsed(void *parsed_result,
8572 __rte_unused struct cmdline *cl,
8573 __rte_unused void *data)
8575 struct cmd_set_qmap_result *res = parsed_result;
8576 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8578 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8581 cmdline_parse_token_string_t cmd_setqmap_set =
8582 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8584 cmdline_parse_token_string_t cmd_setqmap_qmap =
8585 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8587 cmdline_parse_token_string_t cmd_setqmap_what =
8588 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8590 cmdline_parse_token_num_t cmd_setqmap_portid =
8591 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8592 port_id, RTE_UINT16);
8593 cmdline_parse_token_num_t cmd_setqmap_queueid =
8594 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8595 queue_id, RTE_UINT16);
8596 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8597 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8598 map_value, RTE_UINT8);
8600 cmdline_parse_inst_t cmd_set_qmap = {
8601 .f = cmd_set_qmap_parsed,
8603 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8604 "Set statistics mapping value on tx|rx queue_id of port_id",
8606 (void *)&cmd_setqmap_set,
8607 (void *)&cmd_setqmap_qmap,
8608 (void *)&cmd_setqmap_what,
8609 (void *)&cmd_setqmap_portid,
8610 (void *)&cmd_setqmap_queueid,
8611 (void *)&cmd_setqmap_mapvalue,
8616 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8617 struct cmd_set_xstats_hide_zero_result {
8618 cmdline_fixed_string_t keyword;
8619 cmdline_fixed_string_t name;
8620 cmdline_fixed_string_t on_off;
8624 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8625 __rte_unused struct cmdline *cl,
8626 __rte_unused void *data)
8628 struct cmd_set_xstats_hide_zero_result *res;
8629 uint16_t on_off = 0;
8631 res = parsed_result;
8632 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8633 set_xstats_hide_zero(on_off);
8636 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8637 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8639 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8640 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8641 name, "xstats-hide-zero");
8642 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8643 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8646 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8647 .f = cmd_set_xstats_hide_zero_parsed,
8649 .help_str = "set xstats-hide-zero on|off",
8651 (void *)&cmd_set_xstats_hide_zero_keyword,
8652 (void *)&cmd_set_xstats_hide_zero_name,
8653 (void *)&cmd_set_xstats_hide_zero_on_off,
8658 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8659 struct cmd_set_record_core_cycles_result {
8660 cmdline_fixed_string_t keyword;
8661 cmdline_fixed_string_t name;
8662 cmdline_fixed_string_t on_off;
8666 cmd_set_record_core_cycles_parsed(void *parsed_result,
8667 __rte_unused struct cmdline *cl,
8668 __rte_unused void *data)
8670 struct cmd_set_record_core_cycles_result *res;
8671 uint16_t on_off = 0;
8673 res = parsed_result;
8674 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8675 set_record_core_cycles(on_off);
8678 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8679 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8681 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8682 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8683 name, "record-core-cycles");
8684 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8685 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8688 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8689 .f = cmd_set_record_core_cycles_parsed,
8691 .help_str = "set record-core-cycles on|off",
8693 (void *)&cmd_set_record_core_cycles_keyword,
8694 (void *)&cmd_set_record_core_cycles_name,
8695 (void *)&cmd_set_record_core_cycles_on_off,
8700 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8701 struct cmd_set_record_burst_stats_result {
8702 cmdline_fixed_string_t keyword;
8703 cmdline_fixed_string_t name;
8704 cmdline_fixed_string_t on_off;
8708 cmd_set_record_burst_stats_parsed(void *parsed_result,
8709 __rte_unused struct cmdline *cl,
8710 __rte_unused void *data)
8712 struct cmd_set_record_burst_stats_result *res;
8713 uint16_t on_off = 0;
8715 res = parsed_result;
8716 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8717 set_record_burst_stats(on_off);
8720 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8721 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8723 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8724 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8725 name, "record-burst-stats");
8726 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8727 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8730 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8731 .f = cmd_set_record_burst_stats_parsed,
8733 .help_str = "set record-burst-stats on|off",
8735 (void *)&cmd_set_record_burst_stats_keyword,
8736 (void *)&cmd_set_record_burst_stats_name,
8737 (void *)&cmd_set_record_burst_stats_on_off,
8742 /* *** CONFIGURE UNICAST HASH TABLE *** */
8743 struct cmd_set_uc_hash_table {
8744 cmdline_fixed_string_t set;
8745 cmdline_fixed_string_t port;
8747 cmdline_fixed_string_t what;
8748 struct rte_ether_addr address;
8749 cmdline_fixed_string_t mode;
8753 cmd_set_uc_hash_parsed(void *parsed_result,
8754 __rte_unused struct cmdline *cl,
8755 __rte_unused void *data)
8758 struct cmd_set_uc_hash_table *res = parsed_result;
8760 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8762 if (strcmp(res->what, "uta") == 0)
8763 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8764 &res->address,(uint8_t)is_on);
8767 "bad unicast hash table parameter, return code = %d\n",
8772 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8773 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8775 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8776 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8778 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8779 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8780 port_id, RTE_UINT16);
8781 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8782 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8784 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8785 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8787 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8788 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8791 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8792 .f = cmd_set_uc_hash_parsed,
8794 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8796 (void *)&cmd_set_uc_hash_set,
8797 (void *)&cmd_set_uc_hash_port,
8798 (void *)&cmd_set_uc_hash_portid,
8799 (void *)&cmd_set_uc_hash_what,
8800 (void *)&cmd_set_uc_hash_mac,
8801 (void *)&cmd_set_uc_hash_mode,
8806 struct cmd_set_uc_all_hash_table {
8807 cmdline_fixed_string_t set;
8808 cmdline_fixed_string_t port;
8810 cmdline_fixed_string_t what;
8811 cmdline_fixed_string_t value;
8812 cmdline_fixed_string_t mode;
8816 cmd_set_uc_all_hash_parsed(void *parsed_result,
8817 __rte_unused struct cmdline *cl,
8818 __rte_unused void *data)
8821 struct cmd_set_uc_all_hash_table *res = parsed_result;
8823 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8825 if ((strcmp(res->what, "uta") == 0) &&
8826 (strcmp(res->value, "all") == 0))
8827 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8830 "bad unicast hash table parameter, return code = %d\n",
8834 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8835 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8837 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8838 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8840 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8841 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8842 port_id, RTE_UINT16);
8843 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8844 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8846 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8847 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8849 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8850 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8853 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8854 .f = cmd_set_uc_all_hash_parsed,
8856 .help_str = "set port <port_id> uta all on|off",
8858 (void *)&cmd_set_uc_all_hash_set,
8859 (void *)&cmd_set_uc_all_hash_port,
8860 (void *)&cmd_set_uc_all_hash_portid,
8861 (void *)&cmd_set_uc_all_hash_what,
8862 (void *)&cmd_set_uc_all_hash_value,
8863 (void *)&cmd_set_uc_all_hash_mode,
8868 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8869 struct cmd_set_vf_traffic {
8870 cmdline_fixed_string_t set;
8871 cmdline_fixed_string_t port;
8873 cmdline_fixed_string_t vf;
8875 cmdline_fixed_string_t what;
8876 cmdline_fixed_string_t mode;
8880 cmd_set_vf_traffic_parsed(void *parsed_result,
8881 __rte_unused struct cmdline *cl,
8882 __rte_unused void *data)
8884 struct cmd_set_vf_traffic *res = parsed_result;
8885 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8886 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8888 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8891 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8892 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8894 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8895 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8897 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8898 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8899 port_id, RTE_UINT16);
8900 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8901 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8903 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8904 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8906 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8907 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8909 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8910 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8913 cmdline_parse_inst_t cmd_set_vf_traffic = {
8914 .f = cmd_set_vf_traffic_parsed,
8916 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8918 (void *)&cmd_setvf_traffic_set,
8919 (void *)&cmd_setvf_traffic_port,
8920 (void *)&cmd_setvf_traffic_portid,
8921 (void *)&cmd_setvf_traffic_vf,
8922 (void *)&cmd_setvf_traffic_vfid,
8923 (void *)&cmd_setvf_traffic_what,
8924 (void *)&cmd_setvf_traffic_mode,
8929 /* *** CONFIGURE VF RECEIVE MODE *** */
8930 struct cmd_set_vf_rxmode {
8931 cmdline_fixed_string_t set;
8932 cmdline_fixed_string_t port;
8934 cmdline_fixed_string_t vf;
8936 cmdline_fixed_string_t what;
8937 cmdline_fixed_string_t mode;
8938 cmdline_fixed_string_t on;
8942 cmd_set_vf_rxmode_parsed(void *parsed_result,
8943 __rte_unused struct cmdline *cl,
8944 __rte_unused void *data)
8947 uint16_t vf_rxmode = 0;
8948 struct cmd_set_vf_rxmode *res = parsed_result;
8950 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8951 if (!strcmp(res->what,"rxmode")) {
8952 if (!strcmp(res->mode, "AUPE"))
8953 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8954 else if (!strcmp(res->mode, "ROPE"))
8955 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8956 else if (!strcmp(res->mode, "BAM"))
8957 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8958 else if (!strncmp(res->mode, "MPE",3))
8959 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8962 RTE_SET_USED(is_on);
8964 #ifdef RTE_NET_IXGBE
8965 if (ret == -ENOTSUP)
8966 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8967 vf_rxmode, (uint8_t)is_on);
8970 if (ret == -ENOTSUP)
8971 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8972 vf_rxmode, (uint8_t)is_on);
8976 "bad VF receive mode parameter, return code = %d\n",
8980 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8981 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8983 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8984 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8986 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8987 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8988 port_id, RTE_UINT16);
8989 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8990 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8992 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8993 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8995 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8996 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8998 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8999 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9000 mode, "AUPE#ROPE#BAM#MPE");
9001 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9002 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9005 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9006 .f = cmd_set_vf_rxmode_parsed,
9008 .help_str = "set port <port_id> vf <vf_id> rxmode "
9009 "AUPE|ROPE|BAM|MPE on|off",
9011 (void *)&cmd_set_vf_rxmode_set,
9012 (void *)&cmd_set_vf_rxmode_port,
9013 (void *)&cmd_set_vf_rxmode_portid,
9014 (void *)&cmd_set_vf_rxmode_vf,
9015 (void *)&cmd_set_vf_rxmode_vfid,
9016 (void *)&cmd_set_vf_rxmode_what,
9017 (void *)&cmd_set_vf_rxmode_mode,
9018 (void *)&cmd_set_vf_rxmode_on,
9023 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9024 struct cmd_vf_mac_addr_result {
9025 cmdline_fixed_string_t mac_addr_cmd;
9026 cmdline_fixed_string_t what;
9027 cmdline_fixed_string_t port;
9029 cmdline_fixed_string_t vf;
9031 struct rte_ether_addr address;
9034 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9035 __rte_unused struct cmdline *cl,
9036 __rte_unused void *data)
9038 struct cmd_vf_mac_addr_result *res = parsed_result;
9041 if (strcmp(res->what, "add") != 0)
9045 if (ret == -ENOTSUP)
9046 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9050 if (ret == -ENOTSUP)
9051 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9056 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9060 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9061 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9062 mac_addr_cmd,"mac_addr");
9063 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9064 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9066 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9067 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9069 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9070 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9071 port_num, RTE_UINT16);
9072 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9073 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9075 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9076 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9078 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9079 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9082 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9083 .f = cmd_vf_mac_addr_parsed,
9085 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9086 "Add MAC address filtering for a VF on port_id",
9088 (void *)&cmd_vf_mac_addr_cmd,
9089 (void *)&cmd_vf_mac_addr_what,
9090 (void *)&cmd_vf_mac_addr_port,
9091 (void *)&cmd_vf_mac_addr_portnum,
9092 (void *)&cmd_vf_mac_addr_vf,
9093 (void *)&cmd_vf_mac_addr_vfnum,
9094 (void *)&cmd_vf_mac_addr_addr,
9099 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9100 struct cmd_vf_rx_vlan_filter {
9101 cmdline_fixed_string_t rx_vlan;
9102 cmdline_fixed_string_t what;
9104 cmdline_fixed_string_t port;
9106 cmdline_fixed_string_t vf;
9111 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9112 __rte_unused struct cmdline *cl,
9113 __rte_unused void *data)
9115 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9118 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9120 #ifdef RTE_NET_IXGBE
9121 if (ret == -ENOTSUP)
9122 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9123 res->vlan_id, res->vf_mask, is_add);
9126 if (ret == -ENOTSUP)
9127 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9128 res->vlan_id, res->vf_mask, is_add);
9131 if (ret == -ENOTSUP)
9132 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9133 res->vlan_id, res->vf_mask, is_add);
9140 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9141 res->vlan_id, res->vf_mask);
9144 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9147 fprintf(stderr, "function not implemented or supported\n");
9150 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9154 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9155 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9156 rx_vlan, "rx_vlan");
9157 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9158 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9160 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9161 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9162 vlan_id, RTE_UINT16);
9163 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9164 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9166 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9167 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9168 port_id, RTE_UINT16);
9169 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9170 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9172 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9173 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9174 vf_mask, RTE_UINT64);
9176 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9177 .f = cmd_vf_rx_vlan_filter_parsed,
9179 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9180 "(vf_mask = hexadecimal VF mask)",
9182 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9183 (void *)&cmd_vf_rx_vlan_filter_what,
9184 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9185 (void *)&cmd_vf_rx_vlan_filter_port,
9186 (void *)&cmd_vf_rx_vlan_filter_portid,
9187 (void *)&cmd_vf_rx_vlan_filter_vf,
9188 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9193 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9194 struct cmd_queue_rate_limit_result {
9195 cmdline_fixed_string_t set;
9196 cmdline_fixed_string_t port;
9198 cmdline_fixed_string_t queue;
9200 cmdline_fixed_string_t rate;
9204 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9205 __rte_unused struct cmdline *cl,
9206 __rte_unused void *data)
9208 struct cmd_queue_rate_limit_result *res = parsed_result;
9211 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9212 && (strcmp(res->queue, "queue") == 0)
9213 && (strcmp(res->rate, "rate") == 0))
9214 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9217 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9222 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9223 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9225 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9226 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9228 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9229 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9230 port_num, RTE_UINT16);
9231 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9232 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9234 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9235 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9236 queue_num, RTE_UINT8);
9237 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9238 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9240 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9241 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9242 rate_num, RTE_UINT16);
9244 cmdline_parse_inst_t cmd_queue_rate_limit = {
9245 .f = cmd_queue_rate_limit_parsed,
9247 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9248 "Set rate limit for a queue on port_id",
9250 (void *)&cmd_queue_rate_limit_set,
9251 (void *)&cmd_queue_rate_limit_port,
9252 (void *)&cmd_queue_rate_limit_portnum,
9253 (void *)&cmd_queue_rate_limit_queue,
9254 (void *)&cmd_queue_rate_limit_queuenum,
9255 (void *)&cmd_queue_rate_limit_rate,
9256 (void *)&cmd_queue_rate_limit_ratenum,
9261 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9262 struct cmd_vf_rate_limit_result {
9263 cmdline_fixed_string_t set;
9264 cmdline_fixed_string_t port;
9266 cmdline_fixed_string_t vf;
9268 cmdline_fixed_string_t rate;
9270 cmdline_fixed_string_t q_msk;
9274 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9275 __rte_unused struct cmdline *cl,
9276 __rte_unused void *data)
9278 struct cmd_vf_rate_limit_result *res = parsed_result;
9281 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9282 && (strcmp(res->vf, "vf") == 0)
9283 && (strcmp(res->rate, "rate") == 0)
9284 && (strcmp(res->q_msk, "queue_mask") == 0))
9285 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9286 res->rate_num, res->q_msk_val);
9288 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9293 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9294 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9296 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9297 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9299 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9300 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9301 port_num, RTE_UINT16);
9302 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9303 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9305 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9306 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9308 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9309 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9311 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9312 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9313 rate_num, RTE_UINT16);
9314 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9315 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9316 q_msk, "queue_mask");
9317 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9318 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9319 q_msk_val, RTE_UINT64);
9321 cmdline_parse_inst_t cmd_vf_rate_limit = {
9322 .f = cmd_vf_rate_limit_parsed,
9324 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9325 "queue_mask <queue_mask_value>: "
9326 "Set rate limit for queues of VF on port_id",
9328 (void *)&cmd_vf_rate_limit_set,
9329 (void *)&cmd_vf_rate_limit_port,
9330 (void *)&cmd_vf_rate_limit_portnum,
9331 (void *)&cmd_vf_rate_limit_vf,
9332 (void *)&cmd_vf_rate_limit_vfnum,
9333 (void *)&cmd_vf_rate_limit_rate,
9334 (void *)&cmd_vf_rate_limit_ratenum,
9335 (void *)&cmd_vf_rate_limit_q_msk,
9336 (void *)&cmd_vf_rate_limit_q_msk_val,
9341 /* *** CONFIGURE TUNNEL UDP PORT *** */
9342 struct cmd_tunnel_udp_config {
9343 cmdline_fixed_string_t rx_vxlan_port;
9344 cmdline_fixed_string_t what;
9350 cmd_tunnel_udp_config_parsed(void *parsed_result,
9351 __rte_unused struct cmdline *cl,
9352 __rte_unused void *data)
9354 struct cmd_tunnel_udp_config *res = parsed_result;
9355 struct rte_eth_udp_tunnel tunnel_udp;
9358 tunnel_udp.udp_port = res->udp_port;
9359 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9361 if (!strcmp(res->what, "add"))
9362 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9365 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9369 fprintf(stderr, "udp tunneling add error: (%s)\n",
9373 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9374 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9375 rx_vxlan_port, "rx_vxlan_port");
9376 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9377 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9379 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9380 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9381 udp_port, RTE_UINT16);
9382 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9383 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9384 port_id, RTE_UINT16);
9386 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9387 .f = cmd_tunnel_udp_config_parsed,
9389 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9390 "Add/Remove a tunneling UDP port filter",
9392 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9393 (void *)&cmd_tunnel_udp_config_what,
9394 (void *)&cmd_tunnel_udp_config_udp_port,
9395 (void *)&cmd_tunnel_udp_config_port_id,
9400 struct cmd_config_tunnel_udp_port {
9401 cmdline_fixed_string_t port;
9402 cmdline_fixed_string_t config;
9404 cmdline_fixed_string_t udp_tunnel_port;
9405 cmdline_fixed_string_t action;
9406 cmdline_fixed_string_t tunnel_type;
9411 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9412 __rte_unused struct cmdline *cl,
9413 __rte_unused void *data)
9415 struct cmd_config_tunnel_udp_port *res = parsed_result;
9416 struct rte_eth_udp_tunnel tunnel_udp;
9419 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9422 tunnel_udp.udp_port = res->udp_port;
9424 if (!strcmp(res->tunnel_type, "vxlan")) {
9425 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9426 } else if (!strcmp(res->tunnel_type, "geneve")) {
9427 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9428 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9429 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9430 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9431 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9433 fprintf(stderr, "Invalid tunnel type\n");
9437 if (!strcmp(res->action, "add"))
9438 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9441 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9445 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9449 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9450 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9452 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9453 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9455 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9456 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9458 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9459 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9462 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9463 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9465 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9466 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9467 "vxlan#geneve#vxlan-gpe#ecpri");
9468 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9469 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9472 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9473 .f = cmd_cfg_tunnel_udp_port_parsed,
9475 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9476 "geneve|vxlan-gpe|ecpri <udp_port>",
9478 (void *)&cmd_config_tunnel_udp_port_port,
9479 (void *)&cmd_config_tunnel_udp_port_config,
9480 (void *)&cmd_config_tunnel_udp_port_port_id,
9481 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9482 (void *)&cmd_config_tunnel_udp_port_action,
9483 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9484 (void *)&cmd_config_tunnel_udp_port_value,
9489 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9490 struct cmd_set_mirror_mask_result {
9491 cmdline_fixed_string_t set;
9492 cmdline_fixed_string_t port;
9494 cmdline_fixed_string_t mirror;
9496 cmdline_fixed_string_t what;
9497 cmdline_fixed_string_t value;
9498 cmdline_fixed_string_t dstpool;
9500 cmdline_fixed_string_t on;
9503 cmdline_parse_token_string_t cmd_mirror_mask_set =
9504 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9506 cmdline_parse_token_string_t cmd_mirror_mask_port =
9507 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9509 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9510 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9511 port_id, RTE_UINT16);
9512 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9513 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9514 mirror, "mirror-rule");
9515 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9516 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9517 rule_id, RTE_UINT8);
9518 cmdline_parse_token_string_t cmd_mirror_mask_what =
9519 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9520 what, "pool-mirror-up#pool-mirror-down"
9522 cmdline_parse_token_string_t cmd_mirror_mask_value =
9523 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9525 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9526 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9527 dstpool, "dst-pool");
9528 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9529 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9530 dstpool_id, RTE_UINT8);
9531 cmdline_parse_token_string_t cmd_mirror_mask_on =
9532 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9536 cmd_set_mirror_mask_parsed(void *parsed_result,
9537 __rte_unused struct cmdline *cl,
9538 __rte_unused void *data)
9541 struct cmd_set_mirror_mask_result *res = parsed_result;
9542 struct rte_eth_mirror_conf mr_conf;
9544 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9546 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9548 mr_conf.dst_pool = res->dstpool_id;
9550 if (!strcmp(res->what, "pool-mirror-up")) {
9551 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9552 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9553 } else if (!strcmp(res->what, "pool-mirror-down")) {
9554 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9555 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9556 } else if (!strcmp(res->what, "vlan-mirror")) {
9557 mr_conf.rule_type = ETH_MIRROR_VLAN;
9558 nb_item = parse_item_list(res->value, "vlan",
9559 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9563 for (i = 0; i < nb_item; i++) {
9564 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9566 "Invalid vlan_id: must be < 4096\n");
9570 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9571 mr_conf.vlan.vlan_mask |= 1ULL << i;
9575 if (!strcmp(res->on, "on"))
9576 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9579 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9582 fprintf(stderr, "mirror rule add error: (%s)\n",
9586 cmdline_parse_inst_t cmd_set_mirror_mask = {
9587 .f = cmd_set_mirror_mask_parsed,
9589 .help_str = "set port <port_id> mirror-rule <rule_id> "
9590 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9591 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9593 (void *)&cmd_mirror_mask_set,
9594 (void *)&cmd_mirror_mask_port,
9595 (void *)&cmd_mirror_mask_portid,
9596 (void *)&cmd_mirror_mask_mirror,
9597 (void *)&cmd_mirror_mask_ruleid,
9598 (void *)&cmd_mirror_mask_what,
9599 (void *)&cmd_mirror_mask_value,
9600 (void *)&cmd_mirror_mask_dstpool,
9601 (void *)&cmd_mirror_mask_poolid,
9602 (void *)&cmd_mirror_mask_on,
9607 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9608 struct cmd_set_mirror_link_result {
9609 cmdline_fixed_string_t set;
9610 cmdline_fixed_string_t port;
9612 cmdline_fixed_string_t mirror;
9614 cmdline_fixed_string_t what;
9615 cmdline_fixed_string_t dstpool;
9617 cmdline_fixed_string_t on;
9620 cmdline_parse_token_string_t cmd_mirror_link_set =
9621 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9623 cmdline_parse_token_string_t cmd_mirror_link_port =
9624 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9626 cmdline_parse_token_num_t cmd_mirror_link_portid =
9627 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9628 port_id, RTE_UINT16);
9629 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9630 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9631 mirror, "mirror-rule");
9632 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9633 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9634 rule_id, RTE_UINT8);
9635 cmdline_parse_token_string_t cmd_mirror_link_what =
9636 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9637 what, "uplink-mirror#downlink-mirror");
9638 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9639 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9640 dstpool, "dst-pool");
9641 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9642 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9643 dstpool_id, RTE_UINT8);
9644 cmdline_parse_token_string_t cmd_mirror_link_on =
9645 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9649 cmd_set_mirror_link_parsed(void *parsed_result,
9650 __rte_unused struct cmdline *cl,
9651 __rte_unused void *data)
9654 struct cmd_set_mirror_link_result *res = parsed_result;
9655 struct rte_eth_mirror_conf mr_conf;
9657 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9658 if (!strcmp(res->what, "uplink-mirror"))
9659 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9661 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9663 mr_conf.dst_pool = res->dstpool_id;
9665 if (!strcmp(res->on, "on"))
9666 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9669 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9672 /* check the return value and print it if is < 0 */
9674 fprintf(stderr, "mirror rule add error: (%s)\n",
9679 cmdline_parse_inst_t cmd_set_mirror_link = {
9680 .f = cmd_set_mirror_link_parsed,
9682 .help_str = "set port <port_id> mirror-rule <rule_id> "
9683 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9685 (void *)&cmd_mirror_link_set,
9686 (void *)&cmd_mirror_link_port,
9687 (void *)&cmd_mirror_link_portid,
9688 (void *)&cmd_mirror_link_mirror,
9689 (void *)&cmd_mirror_link_ruleid,
9690 (void *)&cmd_mirror_link_what,
9691 (void *)&cmd_mirror_link_dstpool,
9692 (void *)&cmd_mirror_link_poolid,
9693 (void *)&cmd_mirror_link_on,
9698 /* *** RESET VM MIRROR RULE *** */
9699 struct cmd_rm_mirror_rule_result {
9700 cmdline_fixed_string_t reset;
9701 cmdline_fixed_string_t port;
9703 cmdline_fixed_string_t mirror;
9707 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9708 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9710 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9711 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9713 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9714 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9715 port_id, RTE_UINT16);
9716 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9717 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9718 mirror, "mirror-rule");
9719 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9720 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9721 rule_id, RTE_UINT8);
9724 cmd_reset_mirror_rule_parsed(void *parsed_result,
9725 __rte_unused struct cmdline *cl,
9726 __rte_unused void *data)
9729 struct cmd_set_mirror_link_result *res = parsed_result;
9731 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9733 fprintf(stderr, "mirror rule remove error: (%s)\n",
9737 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9738 .f = cmd_reset_mirror_rule_parsed,
9740 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9742 (void *)&cmd_rm_mirror_rule_reset,
9743 (void *)&cmd_rm_mirror_rule_port,
9744 (void *)&cmd_rm_mirror_rule_portid,
9745 (void *)&cmd_rm_mirror_rule_mirror,
9746 (void *)&cmd_rm_mirror_rule_ruleid,
9751 /* ******************************************************************************** */
9753 struct cmd_dump_result {
9754 cmdline_fixed_string_t dump;
9758 dump_struct_sizes(void)
9760 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9761 DUMP_SIZE(struct rte_mbuf);
9762 DUMP_SIZE(struct rte_mempool);
9763 DUMP_SIZE(struct rte_ring);
9768 /* Dump the socket memory statistics on console */
9770 dump_socket_mem(FILE *f)
9772 struct rte_malloc_socket_stats socket_stats;
9777 unsigned int n_alloc = 0;
9778 unsigned int n_free = 0;
9779 static size_t last_allocs;
9780 static size_t last_total;
9783 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9784 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9785 !socket_stats.heap_totalsz_bytes)
9787 total += socket_stats.heap_totalsz_bytes;
9788 alloc += socket_stats.heap_allocsz_bytes;
9789 free += socket_stats.heap_freesz_bytes;
9790 n_alloc += socket_stats.alloc_count;
9791 n_free += socket_stats.free_count;
9793 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9795 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9796 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9797 (double)socket_stats.heap_allocsz_bytes * 100 /
9798 (double)socket_stats.heap_totalsz_bytes,
9799 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9800 socket_stats.alloc_count,
9801 socket_stats.free_count);
9804 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9805 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9806 total ? ((double)alloc * 100 / (double)total) : 0,
9807 (double)free / (1024 * 1024),
9810 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9811 ((double)total - (double)last_total) / (1024 * 1024),
9812 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9813 last_allocs = alloc;
9817 static void cmd_dump_parsed(void *parsed_result,
9818 __rte_unused struct cmdline *cl,
9819 __rte_unused void *data)
9821 struct cmd_dump_result *res = parsed_result;
9823 if (!strcmp(res->dump, "dump_physmem"))
9824 rte_dump_physmem_layout(stdout);
9825 else if (!strcmp(res->dump, "dump_socket_mem"))
9826 dump_socket_mem(stdout);
9827 else if (!strcmp(res->dump, "dump_memzone"))
9828 rte_memzone_dump(stdout);
9829 else if (!strcmp(res->dump, "dump_struct_sizes"))
9830 dump_struct_sizes();
9831 else if (!strcmp(res->dump, "dump_ring"))
9832 rte_ring_list_dump(stdout);
9833 else if (!strcmp(res->dump, "dump_mempool"))
9834 rte_mempool_list_dump(stdout);
9835 else if (!strcmp(res->dump, "dump_devargs"))
9836 rte_devargs_dump(stdout);
9837 else if (!strcmp(res->dump, "dump_log_types"))
9838 rte_log_dump(stdout);
9841 cmdline_parse_token_string_t cmd_dump_dump =
9842 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9846 "dump_struct_sizes#"
9852 cmdline_parse_inst_t cmd_dump = {
9853 .f = cmd_dump_parsed, /* function to call */
9854 .data = NULL, /* 2nd arg of func */
9855 .help_str = "Dump status",
9856 .tokens = { /* token list, NULL terminated */
9857 (void *)&cmd_dump_dump,
9862 /* ******************************************************************************** */
9864 struct cmd_dump_one_result {
9865 cmdline_fixed_string_t dump;
9866 cmdline_fixed_string_t name;
9869 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9870 __rte_unused void *data)
9872 struct cmd_dump_one_result *res = parsed_result;
9874 if (!strcmp(res->dump, "dump_ring")) {
9876 r = rte_ring_lookup(res->name);
9878 cmdline_printf(cl, "Cannot find ring\n");
9881 rte_ring_dump(stdout, r);
9882 } else if (!strcmp(res->dump, "dump_mempool")) {
9883 struct rte_mempool *mp;
9884 mp = rte_mempool_lookup(res->name);
9886 cmdline_printf(cl, "Cannot find mempool\n");
9889 rte_mempool_dump(stdout, mp);
9893 cmdline_parse_token_string_t cmd_dump_one_dump =
9894 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9895 "dump_ring#dump_mempool");
9897 cmdline_parse_token_string_t cmd_dump_one_name =
9898 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9900 cmdline_parse_inst_t cmd_dump_one = {
9901 .f = cmd_dump_one_parsed, /* function to call */
9902 .data = NULL, /* 2nd arg of func */
9903 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9904 .tokens = { /* token list, NULL terminated */
9905 (void *)&cmd_dump_one_dump,
9906 (void *)&cmd_dump_one_name,
9911 /* *** queue region set *** */
9912 struct cmd_queue_region_result {
9913 cmdline_fixed_string_t set;
9914 cmdline_fixed_string_t port;
9916 cmdline_fixed_string_t cmd;
9917 cmdline_fixed_string_t region;
9919 cmdline_fixed_string_t queue_start_index;
9921 cmdline_fixed_string_t queue_num;
9922 uint8_t queue_num_value;
9926 cmd_queue_region_parsed(void *parsed_result,
9927 __rte_unused struct cmdline *cl,
9928 __rte_unused void *data)
9930 struct cmd_queue_region_result *res = parsed_result;
9933 struct rte_pmd_i40e_queue_region_conf region_conf;
9934 enum rte_pmd_i40e_queue_region_op op_type;
9937 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9941 memset(®ion_conf, 0, sizeof(region_conf));
9942 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9943 region_conf.region_id = res->region_id;
9944 region_conf.queue_num = res->queue_num_value;
9945 region_conf.queue_start_index = res->queue_id;
9947 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9948 op_type, ®ion_conf);
9955 fprintf(stderr, "function not implemented or supported\n");
9958 fprintf(stderr, "queue region config error: (%s)\n",
9963 cmdline_parse_token_string_t cmd_queue_region_set =
9964 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9966 cmdline_parse_token_string_t cmd_queue_region_port =
9967 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9968 cmdline_parse_token_num_t cmd_queue_region_port_id =
9969 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9970 port_id, RTE_UINT16);
9971 cmdline_parse_token_string_t cmd_queue_region_cmd =
9972 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9973 cmd, "queue-region");
9974 cmdline_parse_token_string_t cmd_queue_region_id =
9975 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9976 region, "region_id");
9977 cmdline_parse_token_num_t cmd_queue_region_index =
9978 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9979 region_id, RTE_UINT8);
9980 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9981 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9982 queue_start_index, "queue_start_index");
9983 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9984 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9985 queue_id, RTE_UINT8);
9986 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9987 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9988 queue_num, "queue_num");
9989 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9990 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9991 queue_num_value, RTE_UINT8);
9993 cmdline_parse_inst_t cmd_queue_region = {
9994 .f = cmd_queue_region_parsed,
9996 .help_str = "set port <port_id> queue-region region_id <value> "
9997 "queue_start_index <value> queue_num <value>: Set a queue region",
9999 (void *)&cmd_queue_region_set,
10000 (void *)&cmd_queue_region_port,
10001 (void *)&cmd_queue_region_port_id,
10002 (void *)&cmd_queue_region_cmd,
10003 (void *)&cmd_queue_region_id,
10004 (void *)&cmd_queue_region_index,
10005 (void *)&cmd_queue_region_queue_start_index,
10006 (void *)&cmd_queue_region_queue_id,
10007 (void *)&cmd_queue_region_queue_num,
10008 (void *)&cmd_queue_region_queue_num_value,
10013 /* *** queue region and flowtype set *** */
10014 struct cmd_region_flowtype_result {
10015 cmdline_fixed_string_t set;
10016 cmdline_fixed_string_t port;
10018 cmdline_fixed_string_t cmd;
10019 cmdline_fixed_string_t region;
10021 cmdline_fixed_string_t flowtype;
10022 uint8_t flowtype_id;
10026 cmd_region_flowtype_parsed(void *parsed_result,
10027 __rte_unused struct cmdline *cl,
10028 __rte_unused void *data)
10030 struct cmd_region_flowtype_result *res = parsed_result;
10031 int ret = -ENOTSUP;
10032 #ifdef RTE_NET_I40E
10033 struct rte_pmd_i40e_queue_region_conf region_conf;
10034 enum rte_pmd_i40e_queue_region_op op_type;
10037 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10040 #ifdef RTE_NET_I40E
10041 memset(®ion_conf, 0, sizeof(region_conf));
10043 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10044 region_conf.region_id = res->region_id;
10045 region_conf.hw_flowtype = res->flowtype_id;
10047 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10048 op_type, ®ion_conf);
10055 fprintf(stderr, "function not implemented or supported\n");
10058 fprintf(stderr, "region flowtype config error: (%s)\n",
10063 cmdline_parse_token_string_t cmd_region_flowtype_set =
10064 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10066 cmdline_parse_token_string_t cmd_region_flowtype_port =
10067 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10069 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10070 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10071 port_id, RTE_UINT16);
10072 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10073 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10074 cmd, "queue-region");
10075 cmdline_parse_token_string_t cmd_region_flowtype_index =
10076 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10077 region, "region_id");
10078 cmdline_parse_token_num_t cmd_region_flowtype_id =
10079 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10080 region_id, RTE_UINT8);
10081 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10082 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10083 flowtype, "flowtype");
10084 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10085 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10086 flowtype_id, RTE_UINT8);
10087 cmdline_parse_inst_t cmd_region_flowtype = {
10088 .f = cmd_region_flowtype_parsed,
10090 .help_str = "set port <port_id> queue-region region_id <value> "
10091 "flowtype <value>: Set a flowtype region index",
10093 (void *)&cmd_region_flowtype_set,
10094 (void *)&cmd_region_flowtype_port,
10095 (void *)&cmd_region_flowtype_port_index,
10096 (void *)&cmd_region_flowtype_cmd,
10097 (void *)&cmd_region_flowtype_index,
10098 (void *)&cmd_region_flowtype_id,
10099 (void *)&cmd_region_flowtype_flow_index,
10100 (void *)&cmd_region_flowtype_flow_id,
10105 /* *** User Priority (UP) to queue region (region_id) set *** */
10106 struct cmd_user_priority_region_result {
10107 cmdline_fixed_string_t set;
10108 cmdline_fixed_string_t port;
10110 cmdline_fixed_string_t cmd;
10111 cmdline_fixed_string_t user_priority;
10112 uint8_t user_priority_id;
10113 cmdline_fixed_string_t region;
10118 cmd_user_priority_region_parsed(void *parsed_result,
10119 __rte_unused struct cmdline *cl,
10120 __rte_unused void *data)
10122 struct cmd_user_priority_region_result *res = parsed_result;
10123 int ret = -ENOTSUP;
10124 #ifdef RTE_NET_I40E
10125 struct rte_pmd_i40e_queue_region_conf region_conf;
10126 enum rte_pmd_i40e_queue_region_op op_type;
10129 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10132 #ifdef RTE_NET_I40E
10133 memset(®ion_conf, 0, sizeof(region_conf));
10134 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10135 region_conf.user_priority = res->user_priority_id;
10136 region_conf.region_id = res->region_id;
10138 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10139 op_type, ®ion_conf);
10146 fprintf(stderr, "function not implemented or supported\n");
10149 fprintf(stderr, "user_priority region config error: (%s)\n",
10154 cmdline_parse_token_string_t cmd_user_priority_region_set =
10155 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10157 cmdline_parse_token_string_t cmd_user_priority_region_port =
10158 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10160 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10161 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10162 port_id, RTE_UINT16);
10163 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10164 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10165 cmd, "queue-region");
10166 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10167 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10168 user_priority, "UP");
10169 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10170 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10171 user_priority_id, RTE_UINT8);
10172 cmdline_parse_token_string_t cmd_user_priority_region_region =
10173 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10174 region, "region_id");
10175 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10176 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10177 region_id, RTE_UINT8);
10179 cmdline_parse_inst_t cmd_user_priority_region = {
10180 .f = cmd_user_priority_region_parsed,
10182 .help_str = "set port <port_id> queue-region UP <value> "
10183 "region_id <value>: Set the mapping of User Priority (UP) "
10184 "to queue region (region_id) ",
10186 (void *)&cmd_user_priority_region_set,
10187 (void *)&cmd_user_priority_region_port,
10188 (void *)&cmd_user_priority_region_port_index,
10189 (void *)&cmd_user_priority_region_cmd,
10190 (void *)&cmd_user_priority_region_UP,
10191 (void *)&cmd_user_priority_region_UP_id,
10192 (void *)&cmd_user_priority_region_region,
10193 (void *)&cmd_user_priority_region_region_id,
10198 /* *** flush all queue region related configuration *** */
10199 struct cmd_flush_queue_region_result {
10200 cmdline_fixed_string_t set;
10201 cmdline_fixed_string_t port;
10203 cmdline_fixed_string_t cmd;
10204 cmdline_fixed_string_t flush;
10205 cmdline_fixed_string_t what;
10209 cmd_flush_queue_region_parsed(void *parsed_result,
10210 __rte_unused struct cmdline *cl,
10211 __rte_unused void *data)
10213 struct cmd_flush_queue_region_result *res = parsed_result;
10214 int ret = -ENOTSUP;
10215 #ifdef RTE_NET_I40E
10216 struct rte_pmd_i40e_queue_region_conf region_conf;
10217 enum rte_pmd_i40e_queue_region_op op_type;
10220 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10223 #ifdef RTE_NET_I40E
10224 memset(®ion_conf, 0, sizeof(region_conf));
10226 if (strcmp(res->what, "on") == 0)
10227 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10229 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10231 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10232 op_type, ®ion_conf);
10239 fprintf(stderr, "function not implemented or supported\n");
10242 fprintf(stderr, "queue region config flush error: (%s)\n",
10247 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10248 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10250 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10251 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10253 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10254 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10255 port_id, RTE_UINT16);
10256 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10257 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10258 cmd, "queue-region");
10259 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10260 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10262 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10263 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10266 cmdline_parse_inst_t cmd_flush_queue_region = {
10267 .f = cmd_flush_queue_region_parsed,
10269 .help_str = "set port <port_id> queue-region flush on|off"
10270 ": flush all queue region related configuration",
10272 (void *)&cmd_flush_queue_region_set,
10273 (void *)&cmd_flush_queue_region_port,
10274 (void *)&cmd_flush_queue_region_port_index,
10275 (void *)&cmd_flush_queue_region_cmd,
10276 (void *)&cmd_flush_queue_region_flush,
10277 (void *)&cmd_flush_queue_region_what,
10282 /* *** get all queue region related configuration info *** */
10283 struct cmd_show_queue_region_info {
10284 cmdline_fixed_string_t show;
10285 cmdline_fixed_string_t port;
10287 cmdline_fixed_string_t cmd;
10291 cmd_show_queue_region_info_parsed(void *parsed_result,
10292 __rte_unused struct cmdline *cl,
10293 __rte_unused void *data)
10295 struct cmd_show_queue_region_info *res = parsed_result;
10296 int ret = -ENOTSUP;
10297 #ifdef RTE_NET_I40E
10298 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10299 enum rte_pmd_i40e_queue_region_op op_type;
10302 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10305 #ifdef RTE_NET_I40E
10306 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10308 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10310 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10311 op_type, &rte_pmd_regions);
10313 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10320 fprintf(stderr, "function not implemented or supported\n");
10323 fprintf(stderr, "queue region config info show error: (%s)\n",
10328 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10329 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10331 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10332 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10334 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10335 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10336 port_id, RTE_UINT16);
10337 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10338 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10339 cmd, "queue-region");
10341 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10342 .f = cmd_show_queue_region_info_parsed,
10344 .help_str = "show port <port_id> queue-region"
10345 ": show all queue region related configuration info",
10347 (void *)&cmd_show_queue_region_info_get,
10348 (void *)&cmd_show_queue_region_info_port,
10349 (void *)&cmd_show_queue_region_info_port_index,
10350 (void *)&cmd_show_queue_region_info_cmd,
10355 /* *** Filters Control *** */
10357 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10359 if ((ip_addr).family == AF_INET) \
10360 (ip) = (ip_addr).addr.ipv4.s_addr; \
10362 fprintf(stderr, "invalid parameter.\n"); \
10367 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10369 if ((ip_addr).family == AF_INET6) \
10370 rte_memcpy(&(ip), \
10371 &((ip_addr).addr.ipv6), \
10372 sizeof(struct in6_addr)); \
10374 fprintf(stderr, "invalid parameter.\n"); \
10379 #ifdef RTE_NET_I40E
10382 str2flowtype(char *string)
10385 static const struct {
10388 } flowtype_str[] = {
10389 {"raw", RTE_ETH_FLOW_RAW},
10390 {"ipv4", RTE_ETH_FLOW_IPV4},
10391 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10392 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10393 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10394 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10395 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10396 {"ipv6", RTE_ETH_FLOW_IPV6},
10397 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10398 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10399 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10400 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10401 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10402 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10405 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10406 if (!strcmp(flowtype_str[i].str, string))
10407 return flowtype_str[i].type;
10410 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10411 return (uint16_t)atoi(string);
10413 return RTE_ETH_FLOW_UNKNOWN;
10416 /* *** deal with flow director filter *** */
10417 struct cmd_flow_director_result {
10418 cmdline_fixed_string_t flow_director_filter;
10420 cmdline_fixed_string_t mode;
10421 cmdline_fixed_string_t mode_value;
10422 cmdline_fixed_string_t ops;
10423 cmdline_fixed_string_t flow;
10424 cmdline_fixed_string_t flow_type;
10425 cmdline_fixed_string_t drop;
10426 cmdline_fixed_string_t queue;
10428 cmdline_fixed_string_t fd_id;
10429 uint32_t fd_id_value;
10430 cmdline_fixed_string_t packet;
10435 cmd_flow_director_filter_parsed(void *parsed_result,
10436 __rte_unused struct cmdline *cl,
10437 __rte_unused void *data)
10439 struct cmd_flow_director_result *res = parsed_result;
10441 struct rte_pmd_i40e_flow_type_mapping
10442 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10443 struct rte_pmd_i40e_pkt_template_conf conf;
10444 uint16_t flow_type = str2flowtype(res->flow_type);
10445 uint16_t i, port = res->port_id;
10448 memset(&conf, 0, sizeof(conf));
10450 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10451 fprintf(stderr, "Invalid flow type specified.\n");
10454 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10458 if (mapping[flow_type].pctype == 0ULL) {
10459 fprintf(stderr, "Invalid flow type specified.\n");
10462 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10463 if (mapping[flow_type].pctype & (1ULL << i)) {
10464 conf.input.pctype = i;
10469 conf.input.packet = open_file(res->filepath,
10470 &conf.input.length);
10471 if (!conf.input.packet)
10473 if (!strcmp(res->drop, "drop"))
10474 conf.action.behavior =
10475 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10477 conf.action.behavior =
10478 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10479 conf.action.report_status =
10480 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10481 conf.action.rx_queue = res->queue_id;
10482 conf.soft_id = res->fd_id_value;
10483 add = strcmp(res->ops, "del") ? 1 : 0;
10484 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10488 fprintf(stderr, "flow director config error: (%s)\n",
10490 close_file(conf.input.packet);
10493 cmdline_parse_token_string_t cmd_flow_director_filter =
10494 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10495 flow_director_filter, "flow_director_filter");
10496 cmdline_parse_token_num_t cmd_flow_director_port_id =
10497 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10498 port_id, RTE_UINT16);
10499 cmdline_parse_token_string_t cmd_flow_director_ops =
10500 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10501 ops, "add#del#update");
10502 cmdline_parse_token_string_t cmd_flow_director_flow =
10503 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10505 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10506 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10508 cmdline_parse_token_string_t cmd_flow_director_drop =
10509 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10511 cmdline_parse_token_string_t cmd_flow_director_queue =
10512 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10514 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10515 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10516 queue_id, RTE_UINT16);
10517 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10518 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10520 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10521 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10522 fd_id_value, RTE_UINT32);
10524 cmdline_parse_token_string_t cmd_flow_director_mode =
10525 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10527 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10528 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10529 mode_value, "raw");
10530 cmdline_parse_token_string_t cmd_flow_director_packet =
10531 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10533 cmdline_parse_token_string_t cmd_flow_director_filepath =
10534 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10537 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10538 .f = cmd_flow_director_filter_parsed,
10540 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10541 "director entry on NIC",
10543 (void *)&cmd_flow_director_filter,
10544 (void *)&cmd_flow_director_port_id,
10545 (void *)&cmd_flow_director_mode,
10546 (void *)&cmd_flow_director_mode_raw,
10547 (void *)&cmd_flow_director_ops,
10548 (void *)&cmd_flow_director_flow,
10549 (void *)&cmd_flow_director_flow_type,
10550 (void *)&cmd_flow_director_drop,
10551 (void *)&cmd_flow_director_queue,
10552 (void *)&cmd_flow_director_queue_id,
10553 (void *)&cmd_flow_director_fd_id,
10554 (void *)&cmd_flow_director_fd_id_value,
10555 (void *)&cmd_flow_director_packet,
10556 (void *)&cmd_flow_director_filepath,
10561 #endif /* RTE_NET_I40E */
10563 /* *** deal with flow director mask *** */
10564 struct cmd_flow_director_mask_result {
10565 cmdline_fixed_string_t flow_director_mask;
10567 cmdline_fixed_string_t mode;
10568 cmdline_fixed_string_t mode_value;
10569 cmdline_fixed_string_t vlan;
10570 uint16_t vlan_mask;
10571 cmdline_fixed_string_t src_mask;
10572 cmdline_ipaddr_t ipv4_src;
10573 cmdline_ipaddr_t ipv6_src;
10575 cmdline_fixed_string_t dst_mask;
10576 cmdline_ipaddr_t ipv4_dst;
10577 cmdline_ipaddr_t ipv6_dst;
10579 cmdline_fixed_string_t mac;
10580 uint8_t mac_addr_byte_mask;
10581 cmdline_fixed_string_t tunnel_id;
10582 uint32_t tunnel_id_mask;
10583 cmdline_fixed_string_t tunnel_type;
10584 uint8_t tunnel_type_mask;
10588 cmd_flow_director_mask_parsed(void *parsed_result,
10589 __rte_unused struct cmdline *cl,
10590 __rte_unused void *data)
10592 struct cmd_flow_director_mask_result *res = parsed_result;
10593 struct rte_eth_fdir_masks *mask;
10594 struct rte_port *port;
10596 port = &ports[res->port_id];
10597 /** Check if the port is not started **/
10598 if (port->port_status != RTE_PORT_STOPPED) {
10599 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10603 mask = &port->dev_conf.fdir_conf.mask;
10605 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10606 if (strcmp(res->mode_value, "MAC-VLAN")) {
10607 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10611 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10612 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10613 if (strcmp(res->mode_value, "Tunnel")) {
10614 fprintf(stderr, "Please set mode to Tunnel.\n");
10618 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10619 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10620 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10621 mask->tunnel_type_mask = res->tunnel_type_mask;
10623 if (strcmp(res->mode_value, "IP")) {
10624 fprintf(stderr, "Please set mode to IP.\n");
10628 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10629 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10630 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10631 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10632 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10633 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10634 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10637 cmd_reconfig_device_queue(res->port_id, 1, 1);
10640 cmdline_parse_token_string_t cmd_flow_director_mask =
10641 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10642 flow_director_mask, "flow_director_mask");
10643 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10644 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10645 port_id, RTE_UINT16);
10646 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10649 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10650 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10651 vlan_mask, RTE_UINT16);
10652 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10654 src_mask, "src_mask");
10655 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10656 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10658 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10659 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10661 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10662 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10663 port_src, RTE_UINT16);
10664 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10665 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10666 dst_mask, "dst_mask");
10667 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10668 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10670 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10671 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10673 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10674 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10675 port_dst, RTE_UINT16);
10677 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10678 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10680 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10681 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10683 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10685 mode_value, "MAC-VLAN");
10686 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10687 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10688 mode_value, "Tunnel");
10689 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10692 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10693 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10694 mac_addr_byte_mask, RTE_UINT8);
10695 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10696 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10697 tunnel_type, "tunnel-type");
10698 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10699 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10700 tunnel_type_mask, RTE_UINT8);
10701 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10702 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10703 tunnel_id, "tunnel-id");
10704 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10705 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10706 tunnel_id_mask, RTE_UINT32);
10708 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10709 .f = cmd_flow_director_mask_parsed,
10711 .help_str = "flow_director_mask ... : "
10712 "Set IP mode flow director's mask on NIC",
10714 (void *)&cmd_flow_director_mask,
10715 (void *)&cmd_flow_director_mask_port_id,
10716 (void *)&cmd_flow_director_mask_mode,
10717 (void *)&cmd_flow_director_mask_mode_ip,
10718 (void *)&cmd_flow_director_mask_vlan,
10719 (void *)&cmd_flow_director_mask_vlan_value,
10720 (void *)&cmd_flow_director_mask_src,
10721 (void *)&cmd_flow_director_mask_ipv4_src,
10722 (void *)&cmd_flow_director_mask_ipv6_src,
10723 (void *)&cmd_flow_director_mask_port_src,
10724 (void *)&cmd_flow_director_mask_dst,
10725 (void *)&cmd_flow_director_mask_ipv4_dst,
10726 (void *)&cmd_flow_director_mask_ipv6_dst,
10727 (void *)&cmd_flow_director_mask_port_dst,
10732 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10733 .f = cmd_flow_director_mask_parsed,
10735 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10736 "flow director's mask on NIC",
10738 (void *)&cmd_flow_director_mask,
10739 (void *)&cmd_flow_director_mask_port_id,
10740 (void *)&cmd_flow_director_mask_mode,
10741 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10742 (void *)&cmd_flow_director_mask_vlan,
10743 (void *)&cmd_flow_director_mask_vlan_value,
10748 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10749 .f = cmd_flow_director_mask_parsed,
10751 .help_str = "flow_director_mask ... : Set tunnel mode "
10752 "flow director's mask on NIC",
10754 (void *)&cmd_flow_director_mask,
10755 (void *)&cmd_flow_director_mask_port_id,
10756 (void *)&cmd_flow_director_mask_mode,
10757 (void *)&cmd_flow_director_mask_mode_tunnel,
10758 (void *)&cmd_flow_director_mask_vlan,
10759 (void *)&cmd_flow_director_mask_vlan_value,
10760 (void *)&cmd_flow_director_mask_mac,
10761 (void *)&cmd_flow_director_mask_mac_value,
10762 (void *)&cmd_flow_director_mask_tunnel_type,
10763 (void *)&cmd_flow_director_mask_tunnel_type_value,
10764 (void *)&cmd_flow_director_mask_tunnel_id,
10765 (void *)&cmd_flow_director_mask_tunnel_id_value,
10770 /* *** deal with flow director flexible payload configuration *** */
10771 struct cmd_flow_director_flexpayload_result {
10772 cmdline_fixed_string_t flow_director_flexpayload;
10774 cmdline_fixed_string_t payload_layer;
10775 cmdline_fixed_string_t payload_cfg;
10779 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10782 const char *p, *p0 = q_arg;
10784 unsigned long int_fld;
10785 char *str_fld[max_num];
10790 p = strchr(p0, '(');
10794 p0 = strchr(p, ')');
10799 if (size >= sizeof(s))
10802 snprintf(s, sizeof(s), "%.*s", size, p);
10803 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10804 if (ret < 0 || ret > max_num)
10806 for (i = 0; i < ret; i++) {
10808 int_fld = strtoul(str_fld[i], &end, 0);
10809 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10811 offsets[i] = (uint16_t)int_fld;
10817 cmd_flow_director_flxpld_parsed(void *parsed_result,
10818 __rte_unused struct cmdline *cl,
10819 __rte_unused void *data)
10821 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10822 struct rte_eth_flex_payload_cfg flex_cfg;
10823 struct rte_port *port;
10826 port = &ports[res->port_id];
10827 /** Check if the port is not started **/
10828 if (port->port_status != RTE_PORT_STOPPED) {
10829 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10833 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10835 if (!strcmp(res->payload_layer, "raw"))
10836 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10837 else if (!strcmp(res->payload_layer, "l2"))
10838 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10839 else if (!strcmp(res->payload_layer, "l3"))
10840 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10841 else if (!strcmp(res->payload_layer, "l4"))
10842 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10844 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10845 RTE_ETH_FDIR_MAX_FLEXLEN);
10847 fprintf(stderr, "error: Cannot parse flex payload input.\n");
10851 fdir_set_flex_payload(res->port_id, &flex_cfg);
10852 cmd_reconfig_device_queue(res->port_id, 1, 1);
10855 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10857 flow_director_flexpayload,
10858 "flow_director_flex_payload");
10859 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10860 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10861 port_id, RTE_UINT16);
10862 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10864 payload_layer, "raw#l2#l3#l4");
10865 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10866 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10867 payload_cfg, NULL);
10869 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10870 .f = cmd_flow_director_flxpld_parsed,
10872 .help_str = "flow_director_flexpayload ... : "
10873 "Set flow director's flex payload on NIC",
10875 (void *)&cmd_flow_director_flexpayload,
10876 (void *)&cmd_flow_director_flexpayload_port_id,
10877 (void *)&cmd_flow_director_flexpayload_payload_layer,
10878 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10883 /* Generic flow interface command. */
10884 extern cmdline_parse_inst_t cmd_flow;
10886 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10887 struct cmd_mcast_addr_result {
10888 cmdline_fixed_string_t mcast_addr_cmd;
10889 cmdline_fixed_string_t what;
10891 struct rte_ether_addr mc_addr;
10894 static void cmd_mcast_addr_parsed(void *parsed_result,
10895 __rte_unused struct cmdline *cl,
10896 __rte_unused void *data)
10898 struct cmd_mcast_addr_result *res = parsed_result;
10900 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10902 "Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10903 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10904 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10905 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10908 if (strcmp(res->what, "add") == 0)
10909 mcast_addr_add(res->port_num, &res->mc_addr);
10911 mcast_addr_remove(res->port_num, &res->mc_addr);
10914 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10915 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10916 mcast_addr_cmd, "mcast_addr");
10917 cmdline_parse_token_string_t cmd_mcast_addr_what =
10918 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10920 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10921 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10923 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10924 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10926 cmdline_parse_inst_t cmd_mcast_addr = {
10927 .f = cmd_mcast_addr_parsed,
10929 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10930 "Add/Remove multicast MAC address on port_id",
10932 (void *)&cmd_mcast_addr_cmd,
10933 (void *)&cmd_mcast_addr_what,
10934 (void *)&cmd_mcast_addr_portnum,
10935 (void *)&cmd_mcast_addr_addr,
10940 /* vf vlan anti spoof configuration */
10942 /* Common result structure for vf vlan anti spoof */
10943 struct cmd_vf_vlan_anti_spoof_result {
10944 cmdline_fixed_string_t set;
10945 cmdline_fixed_string_t vf;
10946 cmdline_fixed_string_t vlan;
10947 cmdline_fixed_string_t antispoof;
10950 cmdline_fixed_string_t on_off;
10953 /* Common CLI fields for vf vlan anti spoof enable disable */
10954 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10955 TOKEN_STRING_INITIALIZER
10956 (struct cmd_vf_vlan_anti_spoof_result,
10958 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10959 TOKEN_STRING_INITIALIZER
10960 (struct cmd_vf_vlan_anti_spoof_result,
10962 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10963 TOKEN_STRING_INITIALIZER
10964 (struct cmd_vf_vlan_anti_spoof_result,
10966 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10967 TOKEN_STRING_INITIALIZER
10968 (struct cmd_vf_vlan_anti_spoof_result,
10969 antispoof, "antispoof");
10970 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10971 TOKEN_NUM_INITIALIZER
10972 (struct cmd_vf_vlan_anti_spoof_result,
10973 port_id, RTE_UINT16);
10974 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10975 TOKEN_NUM_INITIALIZER
10976 (struct cmd_vf_vlan_anti_spoof_result,
10977 vf_id, RTE_UINT32);
10978 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10979 TOKEN_STRING_INITIALIZER
10980 (struct cmd_vf_vlan_anti_spoof_result,
10984 cmd_set_vf_vlan_anti_spoof_parsed(
10985 void *parsed_result,
10986 __rte_unused struct cmdline *cl,
10987 __rte_unused void *data)
10989 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10990 int ret = -ENOTSUP;
10992 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10994 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10997 #ifdef RTE_NET_IXGBE
10998 if (ret == -ENOTSUP)
10999 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11000 res->vf_id, is_on);
11002 #ifdef RTE_NET_I40E
11003 if (ret == -ENOTSUP)
11004 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11005 res->vf_id, is_on);
11007 #ifdef RTE_NET_BNXT
11008 if (ret == -ENOTSUP)
11009 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11010 res->vf_id, is_on);
11017 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11020 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11023 fprintf(stderr, "function not implemented\n");
11026 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11030 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11031 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11033 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11035 (void *)&cmd_vf_vlan_anti_spoof_set,
11036 (void *)&cmd_vf_vlan_anti_spoof_vf,
11037 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11038 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11039 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11040 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11041 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11046 /* vf mac anti spoof configuration */
11048 /* Common result structure for vf mac anti spoof */
11049 struct cmd_vf_mac_anti_spoof_result {
11050 cmdline_fixed_string_t set;
11051 cmdline_fixed_string_t vf;
11052 cmdline_fixed_string_t mac;
11053 cmdline_fixed_string_t antispoof;
11056 cmdline_fixed_string_t on_off;
11059 /* Common CLI fields for vf mac anti spoof enable disable */
11060 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11061 TOKEN_STRING_INITIALIZER
11062 (struct cmd_vf_mac_anti_spoof_result,
11064 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11065 TOKEN_STRING_INITIALIZER
11066 (struct cmd_vf_mac_anti_spoof_result,
11068 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11069 TOKEN_STRING_INITIALIZER
11070 (struct cmd_vf_mac_anti_spoof_result,
11072 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11073 TOKEN_STRING_INITIALIZER
11074 (struct cmd_vf_mac_anti_spoof_result,
11075 antispoof, "antispoof");
11076 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11077 TOKEN_NUM_INITIALIZER
11078 (struct cmd_vf_mac_anti_spoof_result,
11079 port_id, RTE_UINT16);
11080 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11081 TOKEN_NUM_INITIALIZER
11082 (struct cmd_vf_mac_anti_spoof_result,
11083 vf_id, RTE_UINT32);
11084 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11085 TOKEN_STRING_INITIALIZER
11086 (struct cmd_vf_mac_anti_spoof_result,
11090 cmd_set_vf_mac_anti_spoof_parsed(
11091 void *parsed_result,
11092 __rte_unused struct cmdline *cl,
11093 __rte_unused void *data)
11095 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11096 int ret = -ENOTSUP;
11098 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11100 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11103 #ifdef RTE_NET_IXGBE
11104 if (ret == -ENOTSUP)
11105 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11106 res->vf_id, is_on);
11108 #ifdef RTE_NET_I40E
11109 if (ret == -ENOTSUP)
11110 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11111 res->vf_id, is_on);
11113 #ifdef RTE_NET_BNXT
11114 if (ret == -ENOTSUP)
11115 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11116 res->vf_id, is_on);
11123 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11124 res->vf_id, is_on);
11127 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11130 fprintf(stderr, "function not implemented\n");
11133 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11137 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11138 .f = cmd_set_vf_mac_anti_spoof_parsed,
11140 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11142 (void *)&cmd_vf_mac_anti_spoof_set,
11143 (void *)&cmd_vf_mac_anti_spoof_vf,
11144 (void *)&cmd_vf_mac_anti_spoof_mac,
11145 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11146 (void *)&cmd_vf_mac_anti_spoof_port_id,
11147 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11148 (void *)&cmd_vf_mac_anti_spoof_on_off,
11153 /* vf vlan strip queue configuration */
11155 /* Common result structure for vf mac anti spoof */
11156 struct cmd_vf_vlan_stripq_result {
11157 cmdline_fixed_string_t set;
11158 cmdline_fixed_string_t vf;
11159 cmdline_fixed_string_t vlan;
11160 cmdline_fixed_string_t stripq;
11163 cmdline_fixed_string_t on_off;
11166 /* Common CLI fields for vf vlan strip enable disable */
11167 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11168 TOKEN_STRING_INITIALIZER
11169 (struct cmd_vf_vlan_stripq_result,
11171 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11172 TOKEN_STRING_INITIALIZER
11173 (struct cmd_vf_vlan_stripq_result,
11175 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11176 TOKEN_STRING_INITIALIZER
11177 (struct cmd_vf_vlan_stripq_result,
11179 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11180 TOKEN_STRING_INITIALIZER
11181 (struct cmd_vf_vlan_stripq_result,
11183 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11184 TOKEN_NUM_INITIALIZER
11185 (struct cmd_vf_vlan_stripq_result,
11186 port_id, RTE_UINT16);
11187 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11188 TOKEN_NUM_INITIALIZER
11189 (struct cmd_vf_vlan_stripq_result,
11190 vf_id, RTE_UINT16);
11191 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11192 TOKEN_STRING_INITIALIZER
11193 (struct cmd_vf_vlan_stripq_result,
11197 cmd_set_vf_vlan_stripq_parsed(
11198 void *parsed_result,
11199 __rte_unused struct cmdline *cl,
11200 __rte_unused void *data)
11202 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11203 int ret = -ENOTSUP;
11205 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11207 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11210 #ifdef RTE_NET_IXGBE
11211 if (ret == -ENOTSUP)
11212 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11213 res->vf_id, is_on);
11215 #ifdef RTE_NET_I40E
11216 if (ret == -ENOTSUP)
11217 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11218 res->vf_id, is_on);
11220 #ifdef RTE_NET_BNXT
11221 if (ret == -ENOTSUP)
11222 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11223 res->vf_id, is_on);
11230 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11231 res->vf_id, is_on);
11234 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11237 fprintf(stderr, "function not implemented\n");
11240 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11244 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11245 .f = cmd_set_vf_vlan_stripq_parsed,
11247 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11249 (void *)&cmd_vf_vlan_stripq_set,
11250 (void *)&cmd_vf_vlan_stripq_vf,
11251 (void *)&cmd_vf_vlan_stripq_vlan,
11252 (void *)&cmd_vf_vlan_stripq_stripq,
11253 (void *)&cmd_vf_vlan_stripq_port_id,
11254 (void *)&cmd_vf_vlan_stripq_vf_id,
11255 (void *)&cmd_vf_vlan_stripq_on_off,
11260 /* vf vlan insert configuration */
11262 /* Common result structure for vf vlan insert */
11263 struct cmd_vf_vlan_insert_result {
11264 cmdline_fixed_string_t set;
11265 cmdline_fixed_string_t vf;
11266 cmdline_fixed_string_t vlan;
11267 cmdline_fixed_string_t insert;
11273 /* Common CLI fields for vf vlan insert enable disable */
11274 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11275 TOKEN_STRING_INITIALIZER
11276 (struct cmd_vf_vlan_insert_result,
11278 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11279 TOKEN_STRING_INITIALIZER
11280 (struct cmd_vf_vlan_insert_result,
11282 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11283 TOKEN_STRING_INITIALIZER
11284 (struct cmd_vf_vlan_insert_result,
11286 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11287 TOKEN_STRING_INITIALIZER
11288 (struct cmd_vf_vlan_insert_result,
11290 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11291 TOKEN_NUM_INITIALIZER
11292 (struct cmd_vf_vlan_insert_result,
11293 port_id, RTE_UINT16);
11294 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11295 TOKEN_NUM_INITIALIZER
11296 (struct cmd_vf_vlan_insert_result,
11297 vf_id, RTE_UINT16);
11298 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11299 TOKEN_NUM_INITIALIZER
11300 (struct cmd_vf_vlan_insert_result,
11301 vlan_id, RTE_UINT16);
11304 cmd_set_vf_vlan_insert_parsed(
11305 void *parsed_result,
11306 __rte_unused struct cmdline *cl,
11307 __rte_unused void *data)
11309 struct cmd_vf_vlan_insert_result *res = parsed_result;
11310 int ret = -ENOTSUP;
11312 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11315 #ifdef RTE_NET_IXGBE
11316 if (ret == -ENOTSUP)
11317 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11320 #ifdef RTE_NET_I40E
11321 if (ret == -ENOTSUP)
11322 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11325 #ifdef RTE_NET_BNXT
11326 if (ret == -ENOTSUP)
11327 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11335 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11336 res->vf_id, res->vlan_id);
11339 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11342 fprintf(stderr, "function not implemented\n");
11345 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11349 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11350 .f = cmd_set_vf_vlan_insert_parsed,
11352 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11354 (void *)&cmd_vf_vlan_insert_set,
11355 (void *)&cmd_vf_vlan_insert_vf,
11356 (void *)&cmd_vf_vlan_insert_vlan,
11357 (void *)&cmd_vf_vlan_insert_insert,
11358 (void *)&cmd_vf_vlan_insert_port_id,
11359 (void *)&cmd_vf_vlan_insert_vf_id,
11360 (void *)&cmd_vf_vlan_insert_vlan_id,
11365 /* tx loopback configuration */
11367 /* Common result structure for tx loopback */
11368 struct cmd_tx_loopback_result {
11369 cmdline_fixed_string_t set;
11370 cmdline_fixed_string_t tx;
11371 cmdline_fixed_string_t loopback;
11373 cmdline_fixed_string_t on_off;
11376 /* Common CLI fields for tx loopback enable disable */
11377 cmdline_parse_token_string_t cmd_tx_loopback_set =
11378 TOKEN_STRING_INITIALIZER
11379 (struct cmd_tx_loopback_result,
11381 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11382 TOKEN_STRING_INITIALIZER
11383 (struct cmd_tx_loopback_result,
11385 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11386 TOKEN_STRING_INITIALIZER
11387 (struct cmd_tx_loopback_result,
11388 loopback, "loopback");
11389 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11390 TOKEN_NUM_INITIALIZER
11391 (struct cmd_tx_loopback_result,
11392 port_id, RTE_UINT16);
11393 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11394 TOKEN_STRING_INITIALIZER
11395 (struct cmd_tx_loopback_result,
11399 cmd_set_tx_loopback_parsed(
11400 void *parsed_result,
11401 __rte_unused struct cmdline *cl,
11402 __rte_unused void *data)
11404 struct cmd_tx_loopback_result *res = parsed_result;
11405 int ret = -ENOTSUP;
11407 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11412 #ifdef RTE_NET_IXGBE
11413 if (ret == -ENOTSUP)
11414 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11416 #ifdef RTE_NET_I40E
11417 if (ret == -ENOTSUP)
11418 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11420 #ifdef RTE_NET_BNXT
11421 if (ret == -ENOTSUP)
11422 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11424 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11425 if (ret == -ENOTSUP)
11426 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11433 fprintf(stderr, "invalid is_on %d\n", is_on);
11436 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11439 fprintf(stderr, "function not implemented\n");
11442 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11446 cmdline_parse_inst_t cmd_set_tx_loopback = {
11447 .f = cmd_set_tx_loopback_parsed,
11449 .help_str = "set tx loopback <port_id> on|off",
11451 (void *)&cmd_tx_loopback_set,
11452 (void *)&cmd_tx_loopback_tx,
11453 (void *)&cmd_tx_loopback_loopback,
11454 (void *)&cmd_tx_loopback_port_id,
11455 (void *)&cmd_tx_loopback_on_off,
11460 /* all queues drop enable configuration */
11462 /* Common result structure for all queues drop enable */
11463 struct cmd_all_queues_drop_en_result {
11464 cmdline_fixed_string_t set;
11465 cmdline_fixed_string_t all;
11466 cmdline_fixed_string_t queues;
11467 cmdline_fixed_string_t drop;
11469 cmdline_fixed_string_t on_off;
11472 /* Common CLI fields for tx loopback enable disable */
11473 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11474 TOKEN_STRING_INITIALIZER
11475 (struct cmd_all_queues_drop_en_result,
11477 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11478 TOKEN_STRING_INITIALIZER
11479 (struct cmd_all_queues_drop_en_result,
11481 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11482 TOKEN_STRING_INITIALIZER
11483 (struct cmd_all_queues_drop_en_result,
11485 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11486 TOKEN_STRING_INITIALIZER
11487 (struct cmd_all_queues_drop_en_result,
11489 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11490 TOKEN_NUM_INITIALIZER
11491 (struct cmd_all_queues_drop_en_result,
11492 port_id, RTE_UINT16);
11493 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11494 TOKEN_STRING_INITIALIZER
11495 (struct cmd_all_queues_drop_en_result,
11499 cmd_set_all_queues_drop_en_parsed(
11500 void *parsed_result,
11501 __rte_unused struct cmdline *cl,
11502 __rte_unused void *data)
11504 struct cmd_all_queues_drop_en_result *res = parsed_result;
11505 int ret = -ENOTSUP;
11506 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11508 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11511 #ifdef RTE_NET_IXGBE
11512 if (ret == -ENOTSUP)
11513 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11515 #ifdef RTE_NET_BNXT
11516 if (ret == -ENOTSUP)
11517 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11523 fprintf(stderr, "invalid is_on %d\n", is_on);
11526 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11529 fprintf(stderr, "function not implemented\n");
11532 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11536 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11537 .f = cmd_set_all_queues_drop_en_parsed,
11539 .help_str = "set all queues drop <port_id> on|off",
11541 (void *)&cmd_all_queues_drop_en_set,
11542 (void *)&cmd_all_queues_drop_en_all,
11543 (void *)&cmd_all_queues_drop_en_queues,
11544 (void *)&cmd_all_queues_drop_en_drop,
11545 (void *)&cmd_all_queues_drop_en_port_id,
11546 (void *)&cmd_all_queues_drop_en_on_off,
11551 /* vf split drop enable configuration */
11553 /* Common result structure for vf split drop enable */
11554 struct cmd_vf_split_drop_en_result {
11555 cmdline_fixed_string_t set;
11556 cmdline_fixed_string_t vf;
11557 cmdline_fixed_string_t split;
11558 cmdline_fixed_string_t drop;
11561 cmdline_fixed_string_t on_off;
11564 /* Common CLI fields for vf split drop enable disable */
11565 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11566 TOKEN_STRING_INITIALIZER
11567 (struct cmd_vf_split_drop_en_result,
11569 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11570 TOKEN_STRING_INITIALIZER
11571 (struct cmd_vf_split_drop_en_result,
11573 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11574 TOKEN_STRING_INITIALIZER
11575 (struct cmd_vf_split_drop_en_result,
11577 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11578 TOKEN_STRING_INITIALIZER
11579 (struct cmd_vf_split_drop_en_result,
11581 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11582 TOKEN_NUM_INITIALIZER
11583 (struct cmd_vf_split_drop_en_result,
11584 port_id, RTE_UINT16);
11585 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11586 TOKEN_NUM_INITIALIZER
11587 (struct cmd_vf_split_drop_en_result,
11588 vf_id, RTE_UINT16);
11589 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11590 TOKEN_STRING_INITIALIZER
11591 (struct cmd_vf_split_drop_en_result,
11595 cmd_set_vf_split_drop_en_parsed(
11596 void *parsed_result,
11597 __rte_unused struct cmdline *cl,
11598 __rte_unused void *data)
11600 struct cmd_vf_split_drop_en_result *res = parsed_result;
11601 int ret = -ENOTSUP;
11602 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11607 #ifdef RTE_NET_IXGBE
11608 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11615 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11616 res->vf_id, is_on);
11619 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11622 fprintf(stderr, "not supported on port %d\n", res->port_id);
11625 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11629 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11630 .f = cmd_set_vf_split_drop_en_parsed,
11632 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11634 (void *)&cmd_vf_split_drop_en_set,
11635 (void *)&cmd_vf_split_drop_en_vf,
11636 (void *)&cmd_vf_split_drop_en_split,
11637 (void *)&cmd_vf_split_drop_en_drop,
11638 (void *)&cmd_vf_split_drop_en_port_id,
11639 (void *)&cmd_vf_split_drop_en_vf_id,
11640 (void *)&cmd_vf_split_drop_en_on_off,
11645 /* vf mac address configuration */
11647 /* Common result structure for vf mac address */
11648 struct cmd_set_vf_mac_addr_result {
11649 cmdline_fixed_string_t set;
11650 cmdline_fixed_string_t vf;
11651 cmdline_fixed_string_t mac;
11652 cmdline_fixed_string_t addr;
11655 struct rte_ether_addr mac_addr;
11659 /* Common CLI fields for vf split drop enable disable */
11660 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11661 TOKEN_STRING_INITIALIZER
11662 (struct cmd_set_vf_mac_addr_result,
11664 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11665 TOKEN_STRING_INITIALIZER
11666 (struct cmd_set_vf_mac_addr_result,
11668 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11669 TOKEN_STRING_INITIALIZER
11670 (struct cmd_set_vf_mac_addr_result,
11672 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11673 TOKEN_STRING_INITIALIZER
11674 (struct cmd_set_vf_mac_addr_result,
11676 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11677 TOKEN_NUM_INITIALIZER
11678 (struct cmd_set_vf_mac_addr_result,
11679 port_id, RTE_UINT16);
11680 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11681 TOKEN_NUM_INITIALIZER
11682 (struct cmd_set_vf_mac_addr_result,
11683 vf_id, RTE_UINT16);
11684 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11685 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11689 cmd_set_vf_mac_addr_parsed(
11690 void *parsed_result,
11691 __rte_unused struct cmdline *cl,
11692 __rte_unused void *data)
11694 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11695 int ret = -ENOTSUP;
11697 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11700 #ifdef RTE_NET_IXGBE
11701 if (ret == -ENOTSUP)
11702 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11705 #ifdef RTE_NET_I40E
11706 if (ret == -ENOTSUP)
11707 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11710 #ifdef RTE_NET_BNXT
11711 if (ret == -ENOTSUP)
11712 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11720 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11723 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11726 fprintf(stderr, "function not implemented\n");
11729 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11733 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11734 .f = cmd_set_vf_mac_addr_parsed,
11736 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11738 (void *)&cmd_set_vf_mac_addr_set,
11739 (void *)&cmd_set_vf_mac_addr_vf,
11740 (void *)&cmd_set_vf_mac_addr_mac,
11741 (void *)&cmd_set_vf_mac_addr_addr,
11742 (void *)&cmd_set_vf_mac_addr_port_id,
11743 (void *)&cmd_set_vf_mac_addr_vf_id,
11744 (void *)&cmd_set_vf_mac_addr_mac_addr,
11749 /* MACsec configuration */
11751 /* Common result structure for MACsec offload enable */
11752 struct cmd_macsec_offload_on_result {
11753 cmdline_fixed_string_t set;
11754 cmdline_fixed_string_t macsec;
11755 cmdline_fixed_string_t offload;
11757 cmdline_fixed_string_t on;
11758 cmdline_fixed_string_t encrypt;
11759 cmdline_fixed_string_t en_on_off;
11760 cmdline_fixed_string_t replay_protect;
11761 cmdline_fixed_string_t rp_on_off;
11764 /* Common CLI fields for MACsec offload disable */
11765 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11766 TOKEN_STRING_INITIALIZER
11767 (struct cmd_macsec_offload_on_result,
11769 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11770 TOKEN_STRING_INITIALIZER
11771 (struct cmd_macsec_offload_on_result,
11773 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11774 TOKEN_STRING_INITIALIZER
11775 (struct cmd_macsec_offload_on_result,
11776 offload, "offload");
11777 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11778 TOKEN_NUM_INITIALIZER
11779 (struct cmd_macsec_offload_on_result,
11780 port_id, RTE_UINT16);
11781 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11782 TOKEN_STRING_INITIALIZER
11783 (struct cmd_macsec_offload_on_result,
11785 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11786 TOKEN_STRING_INITIALIZER
11787 (struct cmd_macsec_offload_on_result,
11788 encrypt, "encrypt");
11789 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11790 TOKEN_STRING_INITIALIZER
11791 (struct cmd_macsec_offload_on_result,
11792 en_on_off, "on#off");
11793 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11794 TOKEN_STRING_INITIALIZER
11795 (struct cmd_macsec_offload_on_result,
11796 replay_protect, "replay-protect");
11797 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11798 TOKEN_STRING_INITIALIZER
11799 (struct cmd_macsec_offload_on_result,
11800 rp_on_off, "on#off");
11803 cmd_set_macsec_offload_on_parsed(
11804 void *parsed_result,
11805 __rte_unused struct cmdline *cl,
11806 __rte_unused void *data)
11808 struct cmd_macsec_offload_on_result *res = parsed_result;
11809 int ret = -ENOTSUP;
11810 portid_t port_id = res->port_id;
11811 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11812 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11813 struct rte_eth_dev_info dev_info;
11815 if (port_id_is_invalid(port_id, ENABLED_WARN))
11817 if (!port_is_stopped(port_id)) {
11818 fprintf(stderr, "Please stop port %d first\n", port_id);
11822 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11826 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11827 #ifdef RTE_NET_IXGBE
11828 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11836 ports[port_id].dev_conf.txmode.offloads |=
11837 DEV_TX_OFFLOAD_MACSEC_INSERT;
11838 cmd_reconfig_device_queue(port_id, 1, 1);
11841 fprintf(stderr, "invalid port_id %d\n", port_id);
11844 fprintf(stderr, "not supported on port %d\n", port_id);
11847 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11851 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11852 .f = cmd_set_macsec_offload_on_parsed,
11854 .help_str = "set macsec offload <port_id> on "
11855 "encrypt on|off replay-protect on|off",
11857 (void *)&cmd_macsec_offload_on_set,
11858 (void *)&cmd_macsec_offload_on_macsec,
11859 (void *)&cmd_macsec_offload_on_offload,
11860 (void *)&cmd_macsec_offload_on_port_id,
11861 (void *)&cmd_macsec_offload_on_on,
11862 (void *)&cmd_macsec_offload_on_encrypt,
11863 (void *)&cmd_macsec_offload_on_en_on_off,
11864 (void *)&cmd_macsec_offload_on_replay_protect,
11865 (void *)&cmd_macsec_offload_on_rp_on_off,
11870 /* Common result structure for MACsec offload disable */
11871 struct cmd_macsec_offload_off_result {
11872 cmdline_fixed_string_t set;
11873 cmdline_fixed_string_t macsec;
11874 cmdline_fixed_string_t offload;
11876 cmdline_fixed_string_t off;
11879 /* Common CLI fields for MACsec offload disable */
11880 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11881 TOKEN_STRING_INITIALIZER
11882 (struct cmd_macsec_offload_off_result,
11884 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11885 TOKEN_STRING_INITIALIZER
11886 (struct cmd_macsec_offload_off_result,
11888 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11889 TOKEN_STRING_INITIALIZER
11890 (struct cmd_macsec_offload_off_result,
11891 offload, "offload");
11892 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11893 TOKEN_NUM_INITIALIZER
11894 (struct cmd_macsec_offload_off_result,
11895 port_id, RTE_UINT16);
11896 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11897 TOKEN_STRING_INITIALIZER
11898 (struct cmd_macsec_offload_off_result,
11902 cmd_set_macsec_offload_off_parsed(
11903 void *parsed_result,
11904 __rte_unused struct cmdline *cl,
11905 __rte_unused void *data)
11907 struct cmd_macsec_offload_off_result *res = parsed_result;
11908 int ret = -ENOTSUP;
11909 struct rte_eth_dev_info dev_info;
11910 portid_t port_id = res->port_id;
11912 if (port_id_is_invalid(port_id, ENABLED_WARN))
11914 if (!port_is_stopped(port_id)) {
11915 fprintf(stderr, "Please stop port %d first\n", port_id);
11919 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11923 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11924 #ifdef RTE_NET_IXGBE
11925 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11930 ports[port_id].dev_conf.txmode.offloads &=
11931 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11932 cmd_reconfig_device_queue(port_id, 1, 1);
11935 fprintf(stderr, "invalid port_id %d\n", port_id);
11938 fprintf(stderr, "not supported on port %d\n", port_id);
11941 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11945 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11946 .f = cmd_set_macsec_offload_off_parsed,
11948 .help_str = "set macsec offload <port_id> off",
11950 (void *)&cmd_macsec_offload_off_set,
11951 (void *)&cmd_macsec_offload_off_macsec,
11952 (void *)&cmd_macsec_offload_off_offload,
11953 (void *)&cmd_macsec_offload_off_port_id,
11954 (void *)&cmd_macsec_offload_off_off,
11959 /* Common result structure for MACsec secure connection configure */
11960 struct cmd_macsec_sc_result {
11961 cmdline_fixed_string_t set;
11962 cmdline_fixed_string_t macsec;
11963 cmdline_fixed_string_t sc;
11964 cmdline_fixed_string_t tx_rx;
11966 struct rte_ether_addr mac;
11970 /* Common CLI fields for MACsec secure connection configure */
11971 cmdline_parse_token_string_t cmd_macsec_sc_set =
11972 TOKEN_STRING_INITIALIZER
11973 (struct cmd_macsec_sc_result,
11975 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11976 TOKEN_STRING_INITIALIZER
11977 (struct cmd_macsec_sc_result,
11979 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11980 TOKEN_STRING_INITIALIZER
11981 (struct cmd_macsec_sc_result,
11983 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11984 TOKEN_STRING_INITIALIZER
11985 (struct cmd_macsec_sc_result,
11987 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11988 TOKEN_NUM_INITIALIZER
11989 (struct cmd_macsec_sc_result,
11990 port_id, RTE_UINT16);
11991 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11992 TOKEN_ETHERADDR_INITIALIZER
11993 (struct cmd_macsec_sc_result,
11995 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11996 TOKEN_NUM_INITIALIZER
11997 (struct cmd_macsec_sc_result,
12001 cmd_set_macsec_sc_parsed(
12002 void *parsed_result,
12003 __rte_unused struct cmdline *cl,
12004 __rte_unused void *data)
12006 struct cmd_macsec_sc_result *res = parsed_result;
12007 int ret = -ENOTSUP;
12008 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12010 #ifdef RTE_NET_IXGBE
12012 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12013 res->mac.addr_bytes) :
12014 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12015 res->mac.addr_bytes, res->pi);
12017 RTE_SET_USED(is_tx);
12023 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12026 fprintf(stderr, "not supported on port %d\n", res->port_id);
12029 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12033 cmdline_parse_inst_t cmd_set_macsec_sc = {
12034 .f = cmd_set_macsec_sc_parsed,
12036 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12038 (void *)&cmd_macsec_sc_set,
12039 (void *)&cmd_macsec_sc_macsec,
12040 (void *)&cmd_macsec_sc_sc,
12041 (void *)&cmd_macsec_sc_tx_rx,
12042 (void *)&cmd_macsec_sc_port_id,
12043 (void *)&cmd_macsec_sc_mac,
12044 (void *)&cmd_macsec_sc_pi,
12049 /* Common result structure for MACsec secure connection configure */
12050 struct cmd_macsec_sa_result {
12051 cmdline_fixed_string_t set;
12052 cmdline_fixed_string_t macsec;
12053 cmdline_fixed_string_t sa;
12054 cmdline_fixed_string_t tx_rx;
12059 cmdline_fixed_string_t key;
12062 /* Common CLI fields for MACsec secure connection configure */
12063 cmdline_parse_token_string_t cmd_macsec_sa_set =
12064 TOKEN_STRING_INITIALIZER
12065 (struct cmd_macsec_sa_result,
12067 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12068 TOKEN_STRING_INITIALIZER
12069 (struct cmd_macsec_sa_result,
12071 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12072 TOKEN_STRING_INITIALIZER
12073 (struct cmd_macsec_sa_result,
12075 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12076 TOKEN_STRING_INITIALIZER
12077 (struct cmd_macsec_sa_result,
12079 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12080 TOKEN_NUM_INITIALIZER
12081 (struct cmd_macsec_sa_result,
12082 port_id, RTE_UINT16);
12083 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12084 TOKEN_NUM_INITIALIZER
12085 (struct cmd_macsec_sa_result,
12087 cmdline_parse_token_num_t cmd_macsec_sa_an =
12088 TOKEN_NUM_INITIALIZER
12089 (struct cmd_macsec_sa_result,
12091 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12092 TOKEN_NUM_INITIALIZER
12093 (struct cmd_macsec_sa_result,
12095 cmdline_parse_token_string_t cmd_macsec_sa_key =
12096 TOKEN_STRING_INITIALIZER
12097 (struct cmd_macsec_sa_result,
12101 cmd_set_macsec_sa_parsed(
12102 void *parsed_result,
12103 __rte_unused struct cmdline *cl,
12104 __rte_unused void *data)
12106 struct cmd_macsec_sa_result *res = parsed_result;
12107 int ret = -ENOTSUP;
12108 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12109 uint8_t key[16] = { 0 };
12115 key_len = strlen(res->key) / 2;
12119 for (i = 0; i < key_len; i++) {
12120 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12123 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12126 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12129 #ifdef RTE_NET_IXGBE
12131 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12132 res->idx, res->an, res->pn, key) :
12133 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12134 res->idx, res->an, res->pn, key);
12136 RTE_SET_USED(is_tx);
12143 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12146 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12149 fprintf(stderr, "not supported on port %d\n", res->port_id);
12152 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12156 cmdline_parse_inst_t cmd_set_macsec_sa = {
12157 .f = cmd_set_macsec_sa_parsed,
12159 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12161 (void *)&cmd_macsec_sa_set,
12162 (void *)&cmd_macsec_sa_macsec,
12163 (void *)&cmd_macsec_sa_sa,
12164 (void *)&cmd_macsec_sa_tx_rx,
12165 (void *)&cmd_macsec_sa_port_id,
12166 (void *)&cmd_macsec_sa_idx,
12167 (void *)&cmd_macsec_sa_an,
12168 (void *)&cmd_macsec_sa_pn,
12169 (void *)&cmd_macsec_sa_key,
12174 /* VF unicast promiscuous mode configuration */
12176 /* Common result structure for VF unicast promiscuous mode */
12177 struct cmd_vf_promisc_result {
12178 cmdline_fixed_string_t set;
12179 cmdline_fixed_string_t vf;
12180 cmdline_fixed_string_t promisc;
12183 cmdline_fixed_string_t on_off;
12186 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12187 cmdline_parse_token_string_t cmd_vf_promisc_set =
12188 TOKEN_STRING_INITIALIZER
12189 (struct cmd_vf_promisc_result,
12191 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12192 TOKEN_STRING_INITIALIZER
12193 (struct cmd_vf_promisc_result,
12195 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12196 TOKEN_STRING_INITIALIZER
12197 (struct cmd_vf_promisc_result,
12198 promisc, "promisc");
12199 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12200 TOKEN_NUM_INITIALIZER
12201 (struct cmd_vf_promisc_result,
12202 port_id, RTE_UINT16);
12203 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12204 TOKEN_NUM_INITIALIZER
12205 (struct cmd_vf_promisc_result,
12206 vf_id, RTE_UINT32);
12207 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12208 TOKEN_STRING_INITIALIZER
12209 (struct cmd_vf_promisc_result,
12213 cmd_set_vf_promisc_parsed(
12214 void *parsed_result,
12215 __rte_unused struct cmdline *cl,
12216 __rte_unused void *data)
12218 struct cmd_vf_promisc_result *res = parsed_result;
12219 int ret = -ENOTSUP;
12221 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12223 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12226 #ifdef RTE_NET_I40E
12227 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12228 res->vf_id, is_on);
12235 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12238 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12241 fprintf(stderr, "function not implemented\n");
12244 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12248 cmdline_parse_inst_t cmd_set_vf_promisc = {
12249 .f = cmd_set_vf_promisc_parsed,
12251 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12252 "Set unicast promiscuous mode for a VF from the PF",
12254 (void *)&cmd_vf_promisc_set,
12255 (void *)&cmd_vf_promisc_vf,
12256 (void *)&cmd_vf_promisc_promisc,
12257 (void *)&cmd_vf_promisc_port_id,
12258 (void *)&cmd_vf_promisc_vf_id,
12259 (void *)&cmd_vf_promisc_on_off,
12264 /* VF multicast promiscuous mode configuration */
12266 /* Common result structure for VF multicast promiscuous mode */
12267 struct cmd_vf_allmulti_result {
12268 cmdline_fixed_string_t set;
12269 cmdline_fixed_string_t vf;
12270 cmdline_fixed_string_t allmulti;
12273 cmdline_fixed_string_t on_off;
12276 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12277 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12278 TOKEN_STRING_INITIALIZER
12279 (struct cmd_vf_allmulti_result,
12281 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12282 TOKEN_STRING_INITIALIZER
12283 (struct cmd_vf_allmulti_result,
12285 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12286 TOKEN_STRING_INITIALIZER
12287 (struct cmd_vf_allmulti_result,
12288 allmulti, "allmulti");
12289 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12290 TOKEN_NUM_INITIALIZER
12291 (struct cmd_vf_allmulti_result,
12292 port_id, RTE_UINT16);
12293 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12294 TOKEN_NUM_INITIALIZER
12295 (struct cmd_vf_allmulti_result,
12296 vf_id, RTE_UINT32);
12297 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12298 TOKEN_STRING_INITIALIZER
12299 (struct cmd_vf_allmulti_result,
12303 cmd_set_vf_allmulti_parsed(
12304 void *parsed_result,
12305 __rte_unused struct cmdline *cl,
12306 __rte_unused void *data)
12308 struct cmd_vf_allmulti_result *res = parsed_result;
12309 int ret = -ENOTSUP;
12311 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12313 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12316 #ifdef RTE_NET_I40E
12317 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12318 res->vf_id, is_on);
12325 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12328 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12331 fprintf(stderr, "function not implemented\n");
12334 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12338 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12339 .f = cmd_set_vf_allmulti_parsed,
12341 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12342 "Set multicast promiscuous mode for a VF from the PF",
12344 (void *)&cmd_vf_allmulti_set,
12345 (void *)&cmd_vf_allmulti_vf,
12346 (void *)&cmd_vf_allmulti_allmulti,
12347 (void *)&cmd_vf_allmulti_port_id,
12348 (void *)&cmd_vf_allmulti_vf_id,
12349 (void *)&cmd_vf_allmulti_on_off,
12354 /* vf broadcast mode configuration */
12356 /* Common result structure for vf broadcast */
12357 struct cmd_set_vf_broadcast_result {
12358 cmdline_fixed_string_t set;
12359 cmdline_fixed_string_t vf;
12360 cmdline_fixed_string_t broadcast;
12363 cmdline_fixed_string_t on_off;
12366 /* Common CLI fields for vf broadcast enable disable */
12367 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12368 TOKEN_STRING_INITIALIZER
12369 (struct cmd_set_vf_broadcast_result,
12371 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12372 TOKEN_STRING_INITIALIZER
12373 (struct cmd_set_vf_broadcast_result,
12375 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12376 TOKEN_STRING_INITIALIZER
12377 (struct cmd_set_vf_broadcast_result,
12378 broadcast, "broadcast");
12379 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12380 TOKEN_NUM_INITIALIZER
12381 (struct cmd_set_vf_broadcast_result,
12382 port_id, RTE_UINT16);
12383 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12384 TOKEN_NUM_INITIALIZER
12385 (struct cmd_set_vf_broadcast_result,
12386 vf_id, RTE_UINT16);
12387 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12388 TOKEN_STRING_INITIALIZER
12389 (struct cmd_set_vf_broadcast_result,
12393 cmd_set_vf_broadcast_parsed(
12394 void *parsed_result,
12395 __rte_unused struct cmdline *cl,
12396 __rte_unused void *data)
12398 struct cmd_set_vf_broadcast_result *res = parsed_result;
12399 int ret = -ENOTSUP;
12401 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12403 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12406 #ifdef RTE_NET_I40E
12407 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12408 res->vf_id, is_on);
12415 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12416 res->vf_id, is_on);
12419 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12422 fprintf(stderr, "function not implemented\n");
12425 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12429 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12430 .f = cmd_set_vf_broadcast_parsed,
12432 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12434 (void *)&cmd_set_vf_broadcast_set,
12435 (void *)&cmd_set_vf_broadcast_vf,
12436 (void *)&cmd_set_vf_broadcast_broadcast,
12437 (void *)&cmd_set_vf_broadcast_port_id,
12438 (void *)&cmd_set_vf_broadcast_vf_id,
12439 (void *)&cmd_set_vf_broadcast_on_off,
12444 /* vf vlan tag configuration */
12446 /* Common result structure for vf vlan tag */
12447 struct cmd_set_vf_vlan_tag_result {
12448 cmdline_fixed_string_t set;
12449 cmdline_fixed_string_t vf;
12450 cmdline_fixed_string_t vlan;
12451 cmdline_fixed_string_t tag;
12454 cmdline_fixed_string_t on_off;
12457 /* Common CLI fields for vf vlan tag enable disable */
12458 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12459 TOKEN_STRING_INITIALIZER
12460 (struct cmd_set_vf_vlan_tag_result,
12462 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12463 TOKEN_STRING_INITIALIZER
12464 (struct cmd_set_vf_vlan_tag_result,
12466 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12467 TOKEN_STRING_INITIALIZER
12468 (struct cmd_set_vf_vlan_tag_result,
12470 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12471 TOKEN_STRING_INITIALIZER
12472 (struct cmd_set_vf_vlan_tag_result,
12474 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12475 TOKEN_NUM_INITIALIZER
12476 (struct cmd_set_vf_vlan_tag_result,
12477 port_id, RTE_UINT16);
12478 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12479 TOKEN_NUM_INITIALIZER
12480 (struct cmd_set_vf_vlan_tag_result,
12481 vf_id, RTE_UINT16);
12482 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12483 TOKEN_STRING_INITIALIZER
12484 (struct cmd_set_vf_vlan_tag_result,
12488 cmd_set_vf_vlan_tag_parsed(
12489 void *parsed_result,
12490 __rte_unused struct cmdline *cl,
12491 __rte_unused void *data)
12493 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12494 int ret = -ENOTSUP;
12496 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12498 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12501 #ifdef RTE_NET_I40E
12502 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12503 res->vf_id, is_on);
12510 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12511 res->vf_id, is_on);
12514 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12517 fprintf(stderr, "function not implemented\n");
12520 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12524 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12525 .f = cmd_set_vf_vlan_tag_parsed,
12527 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12529 (void *)&cmd_set_vf_vlan_tag_set,
12530 (void *)&cmd_set_vf_vlan_tag_vf,
12531 (void *)&cmd_set_vf_vlan_tag_vlan,
12532 (void *)&cmd_set_vf_vlan_tag_tag,
12533 (void *)&cmd_set_vf_vlan_tag_port_id,
12534 (void *)&cmd_set_vf_vlan_tag_vf_id,
12535 (void *)&cmd_set_vf_vlan_tag_on_off,
12540 /* Common definition of VF and TC TX bandwidth configuration */
12541 struct cmd_vf_tc_bw_result {
12542 cmdline_fixed_string_t set;
12543 cmdline_fixed_string_t vf;
12544 cmdline_fixed_string_t tc;
12545 cmdline_fixed_string_t tx;
12546 cmdline_fixed_string_t min_bw;
12547 cmdline_fixed_string_t max_bw;
12548 cmdline_fixed_string_t strict_link_prio;
12553 cmdline_fixed_string_t bw_list;
12557 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12558 TOKEN_STRING_INITIALIZER
12559 (struct cmd_vf_tc_bw_result,
12561 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12562 TOKEN_STRING_INITIALIZER
12563 (struct cmd_vf_tc_bw_result,
12565 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12566 TOKEN_STRING_INITIALIZER
12567 (struct cmd_vf_tc_bw_result,
12569 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12570 TOKEN_STRING_INITIALIZER
12571 (struct cmd_vf_tc_bw_result,
12573 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12574 TOKEN_STRING_INITIALIZER
12575 (struct cmd_vf_tc_bw_result,
12576 strict_link_prio, "strict-link-priority");
12577 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12578 TOKEN_STRING_INITIALIZER
12579 (struct cmd_vf_tc_bw_result,
12580 min_bw, "min-bandwidth");
12581 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12582 TOKEN_STRING_INITIALIZER
12583 (struct cmd_vf_tc_bw_result,
12584 max_bw, "max-bandwidth");
12585 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12586 TOKEN_NUM_INITIALIZER
12587 (struct cmd_vf_tc_bw_result,
12588 port_id, RTE_UINT16);
12589 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12590 TOKEN_NUM_INITIALIZER
12591 (struct cmd_vf_tc_bw_result,
12592 vf_id, RTE_UINT16);
12593 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12594 TOKEN_NUM_INITIALIZER
12595 (struct cmd_vf_tc_bw_result,
12597 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12598 TOKEN_NUM_INITIALIZER
12599 (struct cmd_vf_tc_bw_result,
12601 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12602 TOKEN_STRING_INITIALIZER
12603 (struct cmd_vf_tc_bw_result,
12605 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12606 TOKEN_NUM_INITIALIZER
12607 (struct cmd_vf_tc_bw_result,
12608 tc_map, RTE_UINT8);
12610 /* VF max bandwidth setting */
12612 cmd_vf_max_bw_parsed(
12613 void *parsed_result,
12614 __rte_unused struct cmdline *cl,
12615 __rte_unused void *data)
12617 struct cmd_vf_tc_bw_result *res = parsed_result;
12618 int ret = -ENOTSUP;
12620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12623 #ifdef RTE_NET_I40E
12624 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12625 res->vf_id, res->bw);
12632 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12633 res->vf_id, res->bw);
12636 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12639 fprintf(stderr, "function not implemented\n");
12642 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12646 cmdline_parse_inst_t cmd_vf_max_bw = {
12647 .f = cmd_vf_max_bw_parsed,
12649 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12651 (void *)&cmd_vf_tc_bw_set,
12652 (void *)&cmd_vf_tc_bw_vf,
12653 (void *)&cmd_vf_tc_bw_tx,
12654 (void *)&cmd_vf_tc_bw_max_bw,
12655 (void *)&cmd_vf_tc_bw_port_id,
12656 (void *)&cmd_vf_tc_bw_vf_id,
12657 (void *)&cmd_vf_tc_bw_bw,
12663 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12668 const char *p, *p0 = str;
12675 p = strchr(p0, '(');
12678 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12682 p0 = strchr(p, ')');
12685 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12689 if (size >= sizeof(s)) {
12691 "The string size exceeds the internal buffer size\n");
12694 snprintf(s, sizeof(s), "%.*s", size, p);
12695 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12697 fprintf(stderr, "Failed to get the bandwidth list.\n");
12701 for (i = 0; i < ret; i++)
12702 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12707 /* TC min bandwidth setting */
12709 cmd_vf_tc_min_bw_parsed(
12710 void *parsed_result,
12711 __rte_unused struct cmdline *cl,
12712 __rte_unused void *data)
12714 struct cmd_vf_tc_bw_result *res = parsed_result;
12717 int ret = -ENOTSUP;
12719 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12722 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12726 #ifdef RTE_NET_I40E
12727 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12735 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12738 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12741 fprintf(stderr, "function not implemented\n");
12744 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12748 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12749 .f = cmd_vf_tc_min_bw_parsed,
12751 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12752 " <bw1, bw2, ...>",
12754 (void *)&cmd_vf_tc_bw_set,
12755 (void *)&cmd_vf_tc_bw_vf,
12756 (void *)&cmd_vf_tc_bw_tc,
12757 (void *)&cmd_vf_tc_bw_tx,
12758 (void *)&cmd_vf_tc_bw_min_bw,
12759 (void *)&cmd_vf_tc_bw_port_id,
12760 (void *)&cmd_vf_tc_bw_vf_id,
12761 (void *)&cmd_vf_tc_bw_bw_list,
12767 cmd_tc_min_bw_parsed(
12768 void *parsed_result,
12769 __rte_unused struct cmdline *cl,
12770 __rte_unused void *data)
12772 struct cmd_vf_tc_bw_result *res = parsed_result;
12773 struct rte_port *port;
12776 int ret = -ENOTSUP;
12778 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12781 port = &ports[res->port_id];
12782 /** Check if the port is not started **/
12783 if (port->port_status != RTE_PORT_STOPPED) {
12784 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12788 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12792 #ifdef RTE_NET_IXGBE
12793 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12800 fprintf(stderr, "invalid bandwidth\n");
12803 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12806 fprintf(stderr, "function not implemented\n");
12809 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12813 cmdline_parse_inst_t cmd_tc_min_bw = {
12814 .f = cmd_tc_min_bw_parsed,
12816 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12818 (void *)&cmd_vf_tc_bw_set,
12819 (void *)&cmd_vf_tc_bw_tc,
12820 (void *)&cmd_vf_tc_bw_tx,
12821 (void *)&cmd_vf_tc_bw_min_bw,
12822 (void *)&cmd_vf_tc_bw_port_id,
12823 (void *)&cmd_vf_tc_bw_bw_list,
12828 /* TC max bandwidth setting */
12830 cmd_vf_tc_max_bw_parsed(
12831 void *parsed_result,
12832 __rte_unused struct cmdline *cl,
12833 __rte_unused void *data)
12835 struct cmd_vf_tc_bw_result *res = parsed_result;
12836 int ret = -ENOTSUP;
12838 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12841 #ifdef RTE_NET_I40E
12842 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12843 res->tc_no, res->bw);
12851 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
12852 res->vf_id, res->tc_no, res->bw);
12855 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12858 fprintf(stderr, "function not implemented\n");
12861 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12865 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12866 .f = cmd_vf_tc_max_bw_parsed,
12868 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12871 (void *)&cmd_vf_tc_bw_set,
12872 (void *)&cmd_vf_tc_bw_vf,
12873 (void *)&cmd_vf_tc_bw_tc,
12874 (void *)&cmd_vf_tc_bw_tx,
12875 (void *)&cmd_vf_tc_bw_max_bw,
12876 (void *)&cmd_vf_tc_bw_port_id,
12877 (void *)&cmd_vf_tc_bw_vf_id,
12878 (void *)&cmd_vf_tc_bw_tc_no,
12879 (void *)&cmd_vf_tc_bw_bw,
12884 /** Set VXLAN encapsulation details */
12885 struct cmd_set_vxlan_result {
12886 cmdline_fixed_string_t set;
12887 cmdline_fixed_string_t vxlan;
12888 cmdline_fixed_string_t pos_token;
12889 cmdline_fixed_string_t ip_version;
12890 uint32_t vlan_present:1;
12894 cmdline_ipaddr_t ip_src;
12895 cmdline_ipaddr_t ip_dst;
12899 struct rte_ether_addr eth_src;
12900 struct rte_ether_addr eth_dst;
12903 cmdline_parse_token_string_t cmd_set_vxlan_set =
12904 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12905 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12906 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12907 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12908 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12910 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12911 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12912 "vxlan-with-vlan");
12913 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12914 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12916 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12917 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12919 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12920 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12922 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12923 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12924 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12925 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12927 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12928 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12929 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12930 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12932 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12933 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12934 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12935 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12937 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12938 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12939 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12940 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12942 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12943 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12944 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12945 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12947 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12948 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12949 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12950 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12952 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12953 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12954 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12955 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12957 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12958 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12959 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12960 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12962 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12963 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12964 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12965 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12967 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12968 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12970 static void cmd_set_vxlan_parsed(void *parsed_result,
12971 __rte_unused struct cmdline *cl,
12972 __rte_unused void *data)
12974 struct cmd_set_vxlan_result *res = parsed_result;
12979 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12982 vxlan_encap_conf.select_tos_ttl = 0;
12983 if (strcmp(res->vxlan, "vxlan") == 0)
12984 vxlan_encap_conf.select_vlan = 0;
12985 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12986 vxlan_encap_conf.select_vlan = 1;
12987 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12988 vxlan_encap_conf.select_vlan = 0;
12989 vxlan_encap_conf.select_tos_ttl = 1;
12991 if (strcmp(res->ip_version, "ipv4") == 0)
12992 vxlan_encap_conf.select_ipv4 = 1;
12993 else if (strcmp(res->ip_version, "ipv6") == 0)
12994 vxlan_encap_conf.select_ipv4 = 0;
12997 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12998 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12999 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13000 vxlan_encap_conf.ip_tos = res->tos;
13001 vxlan_encap_conf.ip_ttl = res->ttl;
13002 if (vxlan_encap_conf.select_ipv4) {
13003 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13004 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13006 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13007 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13009 if (vxlan_encap_conf.select_vlan)
13010 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13011 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13012 RTE_ETHER_ADDR_LEN);
13013 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13014 RTE_ETHER_ADDR_LEN);
13017 cmdline_parse_inst_t cmd_set_vxlan = {
13018 .f = cmd_set_vxlan_parsed,
13020 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13021 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13022 " eth-src <eth-src> eth-dst <eth-dst>",
13024 (void *)&cmd_set_vxlan_set,
13025 (void *)&cmd_set_vxlan_vxlan,
13026 (void *)&cmd_set_vxlan_ip_version,
13027 (void *)&cmd_set_vxlan_ip_version_value,
13028 (void *)&cmd_set_vxlan_vni,
13029 (void *)&cmd_set_vxlan_vni_value,
13030 (void *)&cmd_set_vxlan_udp_src,
13031 (void *)&cmd_set_vxlan_udp_src_value,
13032 (void *)&cmd_set_vxlan_udp_dst,
13033 (void *)&cmd_set_vxlan_udp_dst_value,
13034 (void *)&cmd_set_vxlan_ip_src,
13035 (void *)&cmd_set_vxlan_ip_src_value,
13036 (void *)&cmd_set_vxlan_ip_dst,
13037 (void *)&cmd_set_vxlan_ip_dst_value,
13038 (void *)&cmd_set_vxlan_eth_src,
13039 (void *)&cmd_set_vxlan_eth_src_value,
13040 (void *)&cmd_set_vxlan_eth_dst,
13041 (void *)&cmd_set_vxlan_eth_dst_value,
13046 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13047 .f = cmd_set_vxlan_parsed,
13049 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13050 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13051 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13052 " eth-dst <eth-dst>",
13054 (void *)&cmd_set_vxlan_set,
13055 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13056 (void *)&cmd_set_vxlan_ip_version,
13057 (void *)&cmd_set_vxlan_ip_version_value,
13058 (void *)&cmd_set_vxlan_vni,
13059 (void *)&cmd_set_vxlan_vni_value,
13060 (void *)&cmd_set_vxlan_udp_src,
13061 (void *)&cmd_set_vxlan_udp_src_value,
13062 (void *)&cmd_set_vxlan_udp_dst,
13063 (void *)&cmd_set_vxlan_udp_dst_value,
13064 (void *)&cmd_set_vxlan_ip_tos,
13065 (void *)&cmd_set_vxlan_ip_tos_value,
13066 (void *)&cmd_set_vxlan_ip_ttl,
13067 (void *)&cmd_set_vxlan_ip_ttl_value,
13068 (void *)&cmd_set_vxlan_ip_src,
13069 (void *)&cmd_set_vxlan_ip_src_value,
13070 (void *)&cmd_set_vxlan_ip_dst,
13071 (void *)&cmd_set_vxlan_ip_dst_value,
13072 (void *)&cmd_set_vxlan_eth_src,
13073 (void *)&cmd_set_vxlan_eth_src_value,
13074 (void *)&cmd_set_vxlan_eth_dst,
13075 (void *)&cmd_set_vxlan_eth_dst_value,
13080 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13081 .f = cmd_set_vxlan_parsed,
13083 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13084 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13085 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13088 (void *)&cmd_set_vxlan_set,
13089 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13090 (void *)&cmd_set_vxlan_ip_version,
13091 (void *)&cmd_set_vxlan_ip_version_value,
13092 (void *)&cmd_set_vxlan_vni,
13093 (void *)&cmd_set_vxlan_vni_value,
13094 (void *)&cmd_set_vxlan_udp_src,
13095 (void *)&cmd_set_vxlan_udp_src_value,
13096 (void *)&cmd_set_vxlan_udp_dst,
13097 (void *)&cmd_set_vxlan_udp_dst_value,
13098 (void *)&cmd_set_vxlan_ip_src,
13099 (void *)&cmd_set_vxlan_ip_src_value,
13100 (void *)&cmd_set_vxlan_ip_dst,
13101 (void *)&cmd_set_vxlan_ip_dst_value,
13102 (void *)&cmd_set_vxlan_vlan,
13103 (void *)&cmd_set_vxlan_vlan_value,
13104 (void *)&cmd_set_vxlan_eth_src,
13105 (void *)&cmd_set_vxlan_eth_src_value,
13106 (void *)&cmd_set_vxlan_eth_dst,
13107 (void *)&cmd_set_vxlan_eth_dst_value,
13112 /** Set NVGRE encapsulation details */
13113 struct cmd_set_nvgre_result {
13114 cmdline_fixed_string_t set;
13115 cmdline_fixed_string_t nvgre;
13116 cmdline_fixed_string_t pos_token;
13117 cmdline_fixed_string_t ip_version;
13119 cmdline_ipaddr_t ip_src;
13120 cmdline_ipaddr_t ip_dst;
13122 struct rte_ether_addr eth_src;
13123 struct rte_ether_addr eth_dst;
13126 cmdline_parse_token_string_t cmd_set_nvgre_set =
13127 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13128 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13129 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13130 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13131 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13132 "nvgre-with-vlan");
13133 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13134 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13136 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13137 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13139 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13140 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13142 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13143 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13144 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13145 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13147 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13148 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13149 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13150 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13152 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13153 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13154 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13155 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13157 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13158 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13159 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13160 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13162 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13163 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13164 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13165 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13167 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13168 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13170 static void cmd_set_nvgre_parsed(void *parsed_result,
13171 __rte_unused struct cmdline *cl,
13172 __rte_unused void *data)
13174 struct cmd_set_nvgre_result *res = parsed_result;
13176 uint32_t nvgre_tni;
13179 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13182 if (strcmp(res->nvgre, "nvgre") == 0)
13183 nvgre_encap_conf.select_vlan = 0;
13184 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13185 nvgre_encap_conf.select_vlan = 1;
13186 if (strcmp(res->ip_version, "ipv4") == 0)
13187 nvgre_encap_conf.select_ipv4 = 1;
13188 else if (strcmp(res->ip_version, "ipv6") == 0)
13189 nvgre_encap_conf.select_ipv4 = 0;
13192 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13193 if (nvgre_encap_conf.select_ipv4) {
13194 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13195 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13197 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13198 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13200 if (nvgre_encap_conf.select_vlan)
13201 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13202 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13203 RTE_ETHER_ADDR_LEN);
13204 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13205 RTE_ETHER_ADDR_LEN);
13208 cmdline_parse_inst_t cmd_set_nvgre = {
13209 .f = cmd_set_nvgre_parsed,
13211 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13212 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13213 " eth-dst <eth-dst>",
13215 (void *)&cmd_set_nvgre_set,
13216 (void *)&cmd_set_nvgre_nvgre,
13217 (void *)&cmd_set_nvgre_ip_version,
13218 (void *)&cmd_set_nvgre_ip_version_value,
13219 (void *)&cmd_set_nvgre_tni,
13220 (void *)&cmd_set_nvgre_tni_value,
13221 (void *)&cmd_set_nvgre_ip_src,
13222 (void *)&cmd_set_nvgre_ip_src_value,
13223 (void *)&cmd_set_nvgre_ip_dst,
13224 (void *)&cmd_set_nvgre_ip_dst_value,
13225 (void *)&cmd_set_nvgre_eth_src,
13226 (void *)&cmd_set_nvgre_eth_src_value,
13227 (void *)&cmd_set_nvgre_eth_dst,
13228 (void *)&cmd_set_nvgre_eth_dst_value,
13233 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13234 .f = cmd_set_nvgre_parsed,
13236 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13237 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13238 " eth-src <eth-src> eth-dst <eth-dst>",
13240 (void *)&cmd_set_nvgre_set,
13241 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13242 (void *)&cmd_set_nvgre_ip_version,
13243 (void *)&cmd_set_nvgre_ip_version_value,
13244 (void *)&cmd_set_nvgre_tni,
13245 (void *)&cmd_set_nvgre_tni_value,
13246 (void *)&cmd_set_nvgre_ip_src,
13247 (void *)&cmd_set_nvgre_ip_src_value,
13248 (void *)&cmd_set_nvgre_ip_dst,
13249 (void *)&cmd_set_nvgre_ip_dst_value,
13250 (void *)&cmd_set_nvgre_vlan,
13251 (void *)&cmd_set_nvgre_vlan_value,
13252 (void *)&cmd_set_nvgre_eth_src,
13253 (void *)&cmd_set_nvgre_eth_src_value,
13254 (void *)&cmd_set_nvgre_eth_dst,
13255 (void *)&cmd_set_nvgre_eth_dst_value,
13260 /** Set L2 encapsulation details */
13261 struct cmd_set_l2_encap_result {
13262 cmdline_fixed_string_t set;
13263 cmdline_fixed_string_t l2_encap;
13264 cmdline_fixed_string_t pos_token;
13265 cmdline_fixed_string_t ip_version;
13266 uint32_t vlan_present:1;
13268 struct rte_ether_addr eth_src;
13269 struct rte_ether_addr eth_dst;
13272 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13273 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13274 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13275 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13276 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13277 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13278 "l2_encap-with-vlan");
13279 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13280 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13282 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13283 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13285 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13286 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13288 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13289 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13290 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13291 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13293 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13294 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13295 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13296 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13298 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13299 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13301 static void cmd_set_l2_encap_parsed(void *parsed_result,
13302 __rte_unused struct cmdline *cl,
13303 __rte_unused void *data)
13305 struct cmd_set_l2_encap_result *res = parsed_result;
13307 if (strcmp(res->l2_encap, "l2_encap") == 0)
13308 l2_encap_conf.select_vlan = 0;
13309 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13310 l2_encap_conf.select_vlan = 1;
13311 if (strcmp(res->ip_version, "ipv4") == 0)
13312 l2_encap_conf.select_ipv4 = 1;
13313 else if (strcmp(res->ip_version, "ipv6") == 0)
13314 l2_encap_conf.select_ipv4 = 0;
13317 if (l2_encap_conf.select_vlan)
13318 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13319 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13320 RTE_ETHER_ADDR_LEN);
13321 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13322 RTE_ETHER_ADDR_LEN);
13325 cmdline_parse_inst_t cmd_set_l2_encap = {
13326 .f = cmd_set_l2_encap_parsed,
13328 .help_str = "set l2_encap ip-version ipv4|ipv6"
13329 " eth-src <eth-src> eth-dst <eth-dst>",
13331 (void *)&cmd_set_l2_encap_set,
13332 (void *)&cmd_set_l2_encap_l2_encap,
13333 (void *)&cmd_set_l2_encap_ip_version,
13334 (void *)&cmd_set_l2_encap_ip_version_value,
13335 (void *)&cmd_set_l2_encap_eth_src,
13336 (void *)&cmd_set_l2_encap_eth_src_value,
13337 (void *)&cmd_set_l2_encap_eth_dst,
13338 (void *)&cmd_set_l2_encap_eth_dst_value,
13343 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13344 .f = cmd_set_l2_encap_parsed,
13346 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13347 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13349 (void *)&cmd_set_l2_encap_set,
13350 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13351 (void *)&cmd_set_l2_encap_ip_version,
13352 (void *)&cmd_set_l2_encap_ip_version_value,
13353 (void *)&cmd_set_l2_encap_vlan,
13354 (void *)&cmd_set_l2_encap_vlan_value,
13355 (void *)&cmd_set_l2_encap_eth_src,
13356 (void *)&cmd_set_l2_encap_eth_src_value,
13357 (void *)&cmd_set_l2_encap_eth_dst,
13358 (void *)&cmd_set_l2_encap_eth_dst_value,
13363 /** Set L2 decapsulation details */
13364 struct cmd_set_l2_decap_result {
13365 cmdline_fixed_string_t set;
13366 cmdline_fixed_string_t l2_decap;
13367 cmdline_fixed_string_t pos_token;
13368 uint32_t vlan_present:1;
13371 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13372 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13373 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13374 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13376 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13377 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13378 "l2_decap-with-vlan");
13380 static void cmd_set_l2_decap_parsed(void *parsed_result,
13381 __rte_unused struct cmdline *cl,
13382 __rte_unused void *data)
13384 struct cmd_set_l2_decap_result *res = parsed_result;
13386 if (strcmp(res->l2_decap, "l2_decap") == 0)
13387 l2_decap_conf.select_vlan = 0;
13388 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13389 l2_decap_conf.select_vlan = 1;
13392 cmdline_parse_inst_t cmd_set_l2_decap = {
13393 .f = cmd_set_l2_decap_parsed,
13395 .help_str = "set l2_decap",
13397 (void *)&cmd_set_l2_decap_set,
13398 (void *)&cmd_set_l2_decap_l2_decap,
13403 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13404 .f = cmd_set_l2_decap_parsed,
13406 .help_str = "set l2_decap-with-vlan",
13408 (void *)&cmd_set_l2_decap_set,
13409 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13414 /** Set MPLSoGRE encapsulation details */
13415 struct cmd_set_mplsogre_encap_result {
13416 cmdline_fixed_string_t set;
13417 cmdline_fixed_string_t mplsogre;
13418 cmdline_fixed_string_t pos_token;
13419 cmdline_fixed_string_t ip_version;
13420 uint32_t vlan_present:1;
13422 cmdline_ipaddr_t ip_src;
13423 cmdline_ipaddr_t ip_dst;
13425 struct rte_ether_addr eth_src;
13426 struct rte_ether_addr eth_dst;
13429 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13430 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13432 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13433 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13435 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13436 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13437 mplsogre, "mplsogre_encap-with-vlan");
13438 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13439 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13440 pos_token, "ip-version");
13441 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13442 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13443 ip_version, "ipv4#ipv6");
13444 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13445 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13446 pos_token, "label");
13447 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13448 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13450 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13451 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13452 pos_token, "ip-src");
13453 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13454 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13455 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13456 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13457 pos_token, "ip-dst");
13458 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13459 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13460 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13461 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13462 pos_token, "vlan-tci");
13463 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13464 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13466 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13467 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13468 pos_token, "eth-src");
13469 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13470 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13472 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13473 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13474 pos_token, "eth-dst");
13475 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13476 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13479 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13480 __rte_unused struct cmdline *cl,
13481 __rte_unused void *data)
13483 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13485 uint32_t mplsogre_label;
13488 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13491 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13492 mplsogre_encap_conf.select_vlan = 0;
13493 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13494 mplsogre_encap_conf.select_vlan = 1;
13495 if (strcmp(res->ip_version, "ipv4") == 0)
13496 mplsogre_encap_conf.select_ipv4 = 1;
13497 else if (strcmp(res->ip_version, "ipv6") == 0)
13498 mplsogre_encap_conf.select_ipv4 = 0;
13501 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13502 if (mplsogre_encap_conf.select_ipv4) {
13503 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13504 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13506 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13507 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13509 if (mplsogre_encap_conf.select_vlan)
13510 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13511 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13512 RTE_ETHER_ADDR_LEN);
13513 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13514 RTE_ETHER_ADDR_LEN);
13517 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13518 .f = cmd_set_mplsogre_encap_parsed,
13520 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13521 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13522 " eth-dst <eth-dst>",
13524 (void *)&cmd_set_mplsogre_encap_set,
13525 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13526 (void *)&cmd_set_mplsogre_encap_ip_version,
13527 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13528 (void *)&cmd_set_mplsogre_encap_label,
13529 (void *)&cmd_set_mplsogre_encap_label_value,
13530 (void *)&cmd_set_mplsogre_encap_ip_src,
13531 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13532 (void *)&cmd_set_mplsogre_encap_ip_dst,
13533 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13534 (void *)&cmd_set_mplsogre_encap_eth_src,
13535 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13536 (void *)&cmd_set_mplsogre_encap_eth_dst,
13537 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13542 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13543 .f = cmd_set_mplsogre_encap_parsed,
13545 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13546 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13547 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13549 (void *)&cmd_set_mplsogre_encap_set,
13550 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13551 (void *)&cmd_set_mplsogre_encap_ip_version,
13552 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13553 (void *)&cmd_set_mplsogre_encap_label,
13554 (void *)&cmd_set_mplsogre_encap_label_value,
13555 (void *)&cmd_set_mplsogre_encap_ip_src,
13556 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13557 (void *)&cmd_set_mplsogre_encap_ip_dst,
13558 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13559 (void *)&cmd_set_mplsogre_encap_vlan,
13560 (void *)&cmd_set_mplsogre_encap_vlan_value,
13561 (void *)&cmd_set_mplsogre_encap_eth_src,
13562 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13563 (void *)&cmd_set_mplsogre_encap_eth_dst,
13564 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13569 /** Set MPLSoGRE decapsulation details */
13570 struct cmd_set_mplsogre_decap_result {
13571 cmdline_fixed_string_t set;
13572 cmdline_fixed_string_t mplsogre;
13573 cmdline_fixed_string_t pos_token;
13574 cmdline_fixed_string_t ip_version;
13575 uint32_t vlan_present:1;
13578 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13579 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13581 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13582 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13584 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13585 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13586 mplsogre, "mplsogre_decap-with-vlan");
13587 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13588 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13589 pos_token, "ip-version");
13590 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13591 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13592 ip_version, "ipv4#ipv6");
13594 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13595 __rte_unused struct cmdline *cl,
13596 __rte_unused void *data)
13598 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13600 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13601 mplsogre_decap_conf.select_vlan = 0;
13602 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13603 mplsogre_decap_conf.select_vlan = 1;
13604 if (strcmp(res->ip_version, "ipv4") == 0)
13605 mplsogre_decap_conf.select_ipv4 = 1;
13606 else if (strcmp(res->ip_version, "ipv6") == 0)
13607 mplsogre_decap_conf.select_ipv4 = 0;
13610 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13611 .f = cmd_set_mplsogre_decap_parsed,
13613 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13615 (void *)&cmd_set_mplsogre_decap_set,
13616 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13617 (void *)&cmd_set_mplsogre_decap_ip_version,
13618 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13623 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13624 .f = cmd_set_mplsogre_decap_parsed,
13626 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13628 (void *)&cmd_set_mplsogre_decap_set,
13629 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13630 (void *)&cmd_set_mplsogre_decap_ip_version,
13631 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13636 /** Set MPLSoUDP encapsulation details */
13637 struct cmd_set_mplsoudp_encap_result {
13638 cmdline_fixed_string_t set;
13639 cmdline_fixed_string_t mplsoudp;
13640 cmdline_fixed_string_t pos_token;
13641 cmdline_fixed_string_t ip_version;
13642 uint32_t vlan_present:1;
13646 cmdline_ipaddr_t ip_src;
13647 cmdline_ipaddr_t ip_dst;
13649 struct rte_ether_addr eth_src;
13650 struct rte_ether_addr eth_dst;
13653 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13654 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13656 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13657 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13659 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13660 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13661 mplsoudp, "mplsoudp_encap-with-vlan");
13662 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13663 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13664 pos_token, "ip-version");
13665 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13666 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13667 ip_version, "ipv4#ipv6");
13668 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13669 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13670 pos_token, "label");
13671 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13672 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13674 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13675 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13676 pos_token, "udp-src");
13677 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13678 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13680 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13681 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13682 pos_token, "udp-dst");
13683 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13684 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13686 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13687 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13688 pos_token, "ip-src");
13689 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13690 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13691 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13692 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13693 pos_token, "ip-dst");
13694 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13695 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13696 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13697 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13698 pos_token, "vlan-tci");
13699 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13700 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13702 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13703 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13704 pos_token, "eth-src");
13705 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13706 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13708 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13709 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13710 pos_token, "eth-dst");
13711 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13712 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13715 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13716 __rte_unused struct cmdline *cl,
13717 __rte_unused void *data)
13719 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13721 uint32_t mplsoudp_label;
13724 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13727 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13728 mplsoudp_encap_conf.select_vlan = 0;
13729 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13730 mplsoudp_encap_conf.select_vlan = 1;
13731 if (strcmp(res->ip_version, "ipv4") == 0)
13732 mplsoudp_encap_conf.select_ipv4 = 1;
13733 else if (strcmp(res->ip_version, "ipv6") == 0)
13734 mplsoudp_encap_conf.select_ipv4 = 0;
13737 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13738 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13739 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13740 if (mplsoudp_encap_conf.select_ipv4) {
13741 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13742 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13744 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13745 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13747 if (mplsoudp_encap_conf.select_vlan)
13748 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13749 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13750 RTE_ETHER_ADDR_LEN);
13751 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13752 RTE_ETHER_ADDR_LEN);
13755 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13756 .f = cmd_set_mplsoudp_encap_parsed,
13758 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13759 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13760 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13762 (void *)&cmd_set_mplsoudp_encap_set,
13763 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13764 (void *)&cmd_set_mplsoudp_encap_ip_version,
13765 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13766 (void *)&cmd_set_mplsoudp_encap_label,
13767 (void *)&cmd_set_mplsoudp_encap_label_value,
13768 (void *)&cmd_set_mplsoudp_encap_udp_src,
13769 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13770 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13771 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13772 (void *)&cmd_set_mplsoudp_encap_ip_src,
13773 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13774 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13775 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13776 (void *)&cmd_set_mplsoudp_encap_eth_src,
13777 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13778 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13779 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13784 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13785 .f = cmd_set_mplsoudp_encap_parsed,
13787 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13788 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13789 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13790 " eth-src <eth-src> eth-dst <eth-dst>",
13792 (void *)&cmd_set_mplsoudp_encap_set,
13793 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13794 (void *)&cmd_set_mplsoudp_encap_ip_version,
13795 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13796 (void *)&cmd_set_mplsoudp_encap_label,
13797 (void *)&cmd_set_mplsoudp_encap_label_value,
13798 (void *)&cmd_set_mplsoudp_encap_udp_src,
13799 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13800 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13801 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13802 (void *)&cmd_set_mplsoudp_encap_ip_src,
13803 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13804 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13805 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13806 (void *)&cmd_set_mplsoudp_encap_vlan,
13807 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13808 (void *)&cmd_set_mplsoudp_encap_eth_src,
13809 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13810 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13811 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13816 /** Set MPLSoUDP decapsulation details */
13817 struct cmd_set_mplsoudp_decap_result {
13818 cmdline_fixed_string_t set;
13819 cmdline_fixed_string_t mplsoudp;
13820 cmdline_fixed_string_t pos_token;
13821 cmdline_fixed_string_t ip_version;
13822 uint32_t vlan_present:1;
13825 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13826 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13828 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13829 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13831 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13832 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13833 mplsoudp, "mplsoudp_decap-with-vlan");
13834 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13835 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13836 pos_token, "ip-version");
13837 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13838 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13839 ip_version, "ipv4#ipv6");
13841 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13842 __rte_unused struct cmdline *cl,
13843 __rte_unused void *data)
13845 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13847 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13848 mplsoudp_decap_conf.select_vlan = 0;
13849 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13850 mplsoudp_decap_conf.select_vlan = 1;
13851 if (strcmp(res->ip_version, "ipv4") == 0)
13852 mplsoudp_decap_conf.select_ipv4 = 1;
13853 else if (strcmp(res->ip_version, "ipv6") == 0)
13854 mplsoudp_decap_conf.select_ipv4 = 0;
13857 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13858 .f = cmd_set_mplsoudp_decap_parsed,
13860 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13862 (void *)&cmd_set_mplsoudp_decap_set,
13863 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13864 (void *)&cmd_set_mplsoudp_decap_ip_version,
13865 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13870 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13871 .f = cmd_set_mplsoudp_decap_parsed,
13873 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13875 (void *)&cmd_set_mplsoudp_decap_set,
13876 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13877 (void *)&cmd_set_mplsoudp_decap_ip_version,
13878 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13883 /** Set connection tracking object common details */
13884 struct cmd_set_conntrack_common_result {
13885 cmdline_fixed_string_t set;
13886 cmdline_fixed_string_t conntrack;
13887 cmdline_fixed_string_t common;
13888 cmdline_fixed_string_t peer;
13889 cmdline_fixed_string_t is_orig;
13890 cmdline_fixed_string_t enable;
13891 cmdline_fixed_string_t live;
13892 cmdline_fixed_string_t sack;
13893 cmdline_fixed_string_t cack;
13894 cmdline_fixed_string_t last_dir;
13895 cmdline_fixed_string_t liberal;
13896 cmdline_fixed_string_t state;
13897 cmdline_fixed_string_t max_ack_win;
13898 cmdline_fixed_string_t retrans;
13899 cmdline_fixed_string_t last_win;
13900 cmdline_fixed_string_t last_seq;
13901 cmdline_fixed_string_t last_ack;
13902 cmdline_fixed_string_t last_end;
13903 cmdline_fixed_string_t last_index;
13906 uint16_t peer_port;
13907 uint32_t is_original;
13922 cmdline_parse_token_string_t cmd_set_conntrack_set =
13923 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13925 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13926 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13927 conntrack, "conntrack");
13928 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13929 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13931 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13932 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13934 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13935 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13936 peer_port, RTE_UINT16);
13937 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13938 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13939 is_orig, "is_orig");
13940 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13941 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13942 is_original, RTE_UINT32);
13943 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13944 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13946 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13947 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13949 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13950 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13952 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13953 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13954 is_live, RTE_UINT32);
13955 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13956 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13958 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13959 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13960 s_ack, RTE_UINT32);
13961 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13962 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13964 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13965 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13966 c_ack, RTE_UINT32);
13967 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13968 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13969 last_dir, "last_dir");
13970 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13971 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13973 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13974 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13975 liberal, "liberal");
13976 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13977 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13979 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13980 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13982 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13983 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13985 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13986 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13987 max_ack_win, "max_ack_win");
13988 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13989 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13990 factor, RTE_UINT8);
13991 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13992 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13994 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13995 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13996 re_num, RTE_UINT8);
13997 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13998 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13999 last_win, "last_win");
14000 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14001 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14003 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14004 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14005 last_seq, "last_seq");
14006 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14007 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14009 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14010 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14011 last_ack, "last_ack");
14012 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14013 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14015 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14016 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14017 last_end, "last_end");
14018 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14019 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14021 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14022 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14023 last_index, "last_index");
14024 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14025 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14028 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14029 __rte_unused struct cmdline *cl,
14030 __rte_unused void *data)
14032 struct cmd_set_conntrack_common_result *res = parsed_result;
14034 /* No need to swap to big endian. */
14035 conntrack_context.peer_port = res->peer_port;
14036 conntrack_context.is_original_dir = res->is_original;
14037 conntrack_context.enable = res->en;
14038 conntrack_context.live_connection = res->is_live;
14039 conntrack_context.selective_ack = res->s_ack;
14040 conntrack_context.challenge_ack_passed = res->c_ack;
14041 conntrack_context.last_direction = res->ld;
14042 conntrack_context.liberal_mode = res->lb;
14043 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14044 conntrack_context.max_ack_window = res->factor;
14045 conntrack_context.retransmission_limit = res->re_num;
14046 conntrack_context.last_window = res->lw;
14047 conntrack_context.last_index =
14048 (enum rte_flow_conntrack_tcp_last_index)res->li;
14049 conntrack_context.last_seq = res->ls;
14050 conntrack_context.last_ack = res->la;
14051 conntrack_context.last_end = res->le;
14054 cmdline_parse_inst_t cmd_set_conntrack_common = {
14055 .f = cmd_set_conntrack_common_parsed,
14057 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14058 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14059 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14060 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14061 " last_index <flag>",
14063 (void *)&cmd_set_conntrack_set,
14064 (void *)&cmd_set_conntrack_conntrack,
14065 (void *)&cmd_set_conntrack_common_com,
14066 (void *)&cmd_set_conntrack_common_peer,
14067 (void *)&cmd_set_conntrack_common_peer_value,
14068 (void *)&cmd_set_conntrack_common_is_orig,
14069 (void *)&cmd_set_conntrack_common_is_orig_value,
14070 (void *)&cmd_set_conntrack_common_enable,
14071 (void *)&cmd_set_conntrack_common_enable_value,
14072 (void *)&cmd_set_conntrack_common_live,
14073 (void *)&cmd_set_conntrack_common_live_value,
14074 (void *)&cmd_set_conntrack_common_sack,
14075 (void *)&cmd_set_conntrack_common_sack_value,
14076 (void *)&cmd_set_conntrack_common_cack,
14077 (void *)&cmd_set_conntrack_common_cack_value,
14078 (void *)&cmd_set_conntrack_common_last_dir,
14079 (void *)&cmd_set_conntrack_common_last_dir_value,
14080 (void *)&cmd_set_conntrack_common_liberal,
14081 (void *)&cmd_set_conntrack_common_liberal_value,
14082 (void *)&cmd_set_conntrack_common_state,
14083 (void *)&cmd_set_conntrack_common_state_value,
14084 (void *)&cmd_set_conntrack_common_max_ackwin,
14085 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14086 (void *)&cmd_set_conntrack_common_retrans,
14087 (void *)&cmd_set_conntrack_common_retrans_value,
14088 (void *)&cmd_set_conntrack_common_last_win,
14089 (void *)&cmd_set_conntrack_common_last_win_value,
14090 (void *)&cmd_set_conntrack_common_last_seq,
14091 (void *)&cmd_set_conntrack_common_last_seq_value,
14092 (void *)&cmd_set_conntrack_common_last_ack,
14093 (void *)&cmd_set_conntrack_common_last_ack_value,
14094 (void *)&cmd_set_conntrack_common_last_end,
14095 (void *)&cmd_set_conntrack_common_last_end_value,
14096 (void *)&cmd_set_conntrack_common_last_index,
14097 (void *)&cmd_set_conntrack_common_last_index_value,
14102 /** Set connection tracking object both directions' details */
14103 struct cmd_set_conntrack_dir_result {
14104 cmdline_fixed_string_t set;
14105 cmdline_fixed_string_t conntrack;
14106 cmdline_fixed_string_t dir;
14107 cmdline_fixed_string_t scale;
14108 cmdline_fixed_string_t fin;
14109 cmdline_fixed_string_t ack_seen;
14110 cmdline_fixed_string_t unack;
14111 cmdline_fixed_string_t sent_end;
14112 cmdline_fixed_string_t reply_end;
14113 cmdline_fixed_string_t max_win;
14114 cmdline_fixed_string_t max_ack;
14125 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14126 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14128 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14129 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14130 conntrack, "conntrack");
14131 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14132 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14134 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14135 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14137 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14138 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14139 factor, RTE_UINT32);
14140 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14141 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14143 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14144 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14146 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14147 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14148 ack_seen, "acked");
14149 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14150 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14152 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14153 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14154 unack, "unack_data");
14155 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14156 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14158 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14159 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14160 sent_end, "sent_end");
14161 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14162 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14164 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14165 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14166 reply_end, "reply_end");
14167 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14168 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14170 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14171 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14172 max_win, "max_win");
14173 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14174 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14176 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14177 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14178 max_ack, "max_ack");
14179 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14180 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14183 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14184 __rte_unused struct cmdline *cl,
14185 __rte_unused void *data)
14187 struct cmd_set_conntrack_dir_result *res = parsed_result;
14188 struct rte_flow_tcp_dir_param *dir = NULL;
14190 if (strcmp(res->dir, "orig") == 0)
14191 dir = &conntrack_context.original_dir;
14192 else if (strcmp(res->dir, "rply") == 0)
14193 dir = &conntrack_context.reply_dir;
14196 dir->scale = res->factor;
14197 dir->close_initiated = res->f;
14198 dir->last_ack_seen = res->as;
14199 dir->data_unacked = res->un;
14200 dir->sent_end = res->se;
14201 dir->reply_end = res->re;
14202 dir->max_ack = res->ma;
14203 dir->max_win = res->mw;
14206 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14207 .f = cmd_set_conntrack_dir_parsed,
14209 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14210 " acked <seen> unack_data <unack> sent_end <sent>"
14211 " reply_end <reply> max_win <win> max_ack <ack>",
14213 (void *)&cmd_set_conntrack_set,
14214 (void *)&cmd_set_conntrack_conntrack,
14215 (void *)&cmd_set_conntrack_dir_dir,
14216 (void *)&cmd_set_conntrack_dir_scale,
14217 (void *)&cmd_set_conntrack_dir_scale_value,
14218 (void *)&cmd_set_conntrack_dir_fin,
14219 (void *)&cmd_set_conntrack_dir_fin_value,
14220 (void *)&cmd_set_conntrack_dir_ack,
14221 (void *)&cmd_set_conntrack_dir_ack_value,
14222 (void *)&cmd_set_conntrack_dir_unack_data,
14223 (void *)&cmd_set_conntrack_dir_unack_data_value,
14224 (void *)&cmd_set_conntrack_dir_sent_end,
14225 (void *)&cmd_set_conntrack_dir_sent_end_value,
14226 (void *)&cmd_set_conntrack_dir_reply_end,
14227 (void *)&cmd_set_conntrack_dir_reply_end_value,
14228 (void *)&cmd_set_conntrack_dir_max_win,
14229 (void *)&cmd_set_conntrack_dir_max_win_value,
14230 (void *)&cmd_set_conntrack_dir_max_ack,
14231 (void *)&cmd_set_conntrack_dir_max_ack_value,
14236 /* Strict link priority scheduling mode setting */
14238 cmd_strict_link_prio_parsed(
14239 void *parsed_result,
14240 __rte_unused struct cmdline *cl,
14241 __rte_unused void *data)
14243 struct cmd_vf_tc_bw_result *res = parsed_result;
14244 int ret = -ENOTSUP;
14246 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14249 #ifdef RTE_NET_I40E
14250 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14257 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14260 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14263 fprintf(stderr, "function not implemented\n");
14266 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14270 cmdline_parse_inst_t cmd_strict_link_prio = {
14271 .f = cmd_strict_link_prio_parsed,
14273 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14275 (void *)&cmd_vf_tc_bw_set,
14276 (void *)&cmd_vf_tc_bw_tx,
14277 (void *)&cmd_vf_tc_bw_strict_link_prio,
14278 (void *)&cmd_vf_tc_bw_port_id,
14279 (void *)&cmd_vf_tc_bw_tc_map,
14284 /* Load dynamic device personalization*/
14285 struct cmd_ddp_add_result {
14286 cmdline_fixed_string_t ddp;
14287 cmdline_fixed_string_t add;
14292 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14293 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14294 cmdline_parse_token_string_t cmd_ddp_add_add =
14295 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14296 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14297 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14299 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14300 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14303 cmd_ddp_add_parsed(
14304 void *parsed_result,
14305 __rte_unused struct cmdline *cl,
14306 __rte_unused void *data)
14308 struct cmd_ddp_add_result *res = parsed_result;
14314 int ret = -ENOTSUP;
14316 if (!all_ports_stopped()) {
14317 fprintf(stderr, "Please stop all ports first\n");
14321 filepath = strdup(res->filepath);
14322 if (filepath == NULL) {
14323 fprintf(stderr, "Failed to allocate memory\n");
14326 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14328 buff = open_file(file_fld[0], &size);
14330 free((void *)filepath);
14334 #ifdef RTE_NET_I40E
14335 if (ret == -ENOTSUP)
14336 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14338 RTE_PMD_I40E_PKG_OP_WR_ADD);
14341 if (ret == -EEXIST)
14342 fprintf(stderr, "Profile has already existed.\n");
14344 fprintf(stderr, "Failed to load profile.\n");
14345 else if (file_num == 2)
14346 save_file(file_fld[1], buff, size);
14349 free((void *)filepath);
14352 cmdline_parse_inst_t cmd_ddp_add = {
14353 .f = cmd_ddp_add_parsed,
14355 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14357 (void *)&cmd_ddp_add_ddp,
14358 (void *)&cmd_ddp_add_add,
14359 (void *)&cmd_ddp_add_port_id,
14360 (void *)&cmd_ddp_add_filepath,
14365 /* Delete dynamic device personalization*/
14366 struct cmd_ddp_del_result {
14367 cmdline_fixed_string_t ddp;
14368 cmdline_fixed_string_t del;
14373 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14374 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14375 cmdline_parse_token_string_t cmd_ddp_del_del =
14376 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14377 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14378 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14379 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14380 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14383 cmd_ddp_del_parsed(
14384 void *parsed_result,
14385 __rte_unused struct cmdline *cl,
14386 __rte_unused void *data)
14388 struct cmd_ddp_del_result *res = parsed_result;
14391 int ret = -ENOTSUP;
14393 if (!all_ports_stopped()) {
14394 fprintf(stderr, "Please stop all ports first\n");
14398 buff = open_file(res->filepath, &size);
14402 #ifdef RTE_NET_I40E
14403 if (ret == -ENOTSUP)
14404 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14406 RTE_PMD_I40E_PKG_OP_WR_DEL);
14409 if (ret == -EACCES)
14410 fprintf(stderr, "Profile does not exist.\n");
14412 fprintf(stderr, "Failed to delete profile.\n");
14417 cmdline_parse_inst_t cmd_ddp_del = {
14418 .f = cmd_ddp_del_parsed,
14420 .help_str = "ddp del <port_id> <backup_profile_path>",
14422 (void *)&cmd_ddp_del_ddp,
14423 (void *)&cmd_ddp_del_del,
14424 (void *)&cmd_ddp_del_port_id,
14425 (void *)&cmd_ddp_del_filepath,
14430 /* Get dynamic device personalization profile info */
14431 struct cmd_ddp_info_result {
14432 cmdline_fixed_string_t ddp;
14433 cmdline_fixed_string_t get;
14434 cmdline_fixed_string_t info;
14438 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14439 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14440 cmdline_parse_token_string_t cmd_ddp_info_get =
14441 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14442 cmdline_parse_token_string_t cmd_ddp_info_info =
14443 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14444 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14445 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14448 cmd_ddp_info_parsed(
14449 void *parsed_result,
14450 __rte_unused struct cmdline *cl,
14451 __rte_unused void *data)
14453 struct cmd_ddp_info_result *res = parsed_result;
14456 int ret = -ENOTSUP;
14457 #ifdef RTE_NET_I40E
14460 uint32_t buff_size = 0;
14461 struct rte_pmd_i40e_profile_info info;
14462 uint32_t dev_num = 0;
14463 struct rte_pmd_i40e_ddp_device_id *devs;
14464 uint32_t proto_num = 0;
14465 struct rte_pmd_i40e_proto_info *proto = NULL;
14466 uint32_t pctype_num = 0;
14467 struct rte_pmd_i40e_ptype_info *pctype;
14468 uint32_t ptype_num = 0;
14469 struct rte_pmd_i40e_ptype_info *ptype;
14474 pkg = open_file(res->filepath, &pkg_size);
14478 #ifdef RTE_NET_I40E
14479 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14480 (uint8_t *)&info, sizeof(info),
14481 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14483 printf("Global Track id: 0x%x\n", info.track_id);
14484 printf("Global Version: %d.%d.%d.%d\n",
14485 info.version.major,
14486 info.version.minor,
14487 info.version.update,
14488 info.version.draft);
14489 printf("Global Package name: %s\n\n", info.name);
14492 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14493 (uint8_t *)&info, sizeof(info),
14494 RTE_PMD_I40E_PKG_INFO_HEADER);
14496 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14497 printf("i40e Profile Version: %d.%d.%d.%d\n",
14498 info.version.major,
14499 info.version.minor,
14500 info.version.update,
14501 info.version.draft);
14502 printf("i40e Profile name: %s\n\n", info.name);
14505 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14506 (uint8_t *)&buff_size, sizeof(buff_size),
14507 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14508 if (!ret && buff_size) {
14509 buff = (uint8_t *)malloc(buff_size);
14511 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14513 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14515 printf("Package Notes:\n%s\n\n", buff);
14520 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14521 (uint8_t *)&dev_num, sizeof(dev_num),
14522 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14523 if (!ret && dev_num) {
14524 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14525 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14527 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14528 (uint8_t *)devs, buff_size,
14529 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14531 printf("List of supported devices:\n");
14532 for (i = 0; i < dev_num; i++) {
14533 printf(" %04X:%04X %04X:%04X\n",
14534 devs[i].vendor_dev_id >> 16,
14535 devs[i].vendor_dev_id & 0xFFFF,
14536 devs[i].sub_vendor_dev_id >> 16,
14537 devs[i].sub_vendor_dev_id & 0xFFFF);
14545 /* get information about protocols and packet types */
14546 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14547 (uint8_t *)&proto_num, sizeof(proto_num),
14548 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14549 if (ret || !proto_num)
14550 goto no_print_return;
14552 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14553 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14555 goto no_print_return;
14557 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14559 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14561 printf("List of used protocols:\n");
14562 for (i = 0; i < proto_num; i++)
14563 printf(" %2u: %s\n", proto[i].proto_id,
14567 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14568 (uint8_t *)&pctype_num, sizeof(pctype_num),
14569 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14570 if (ret || !pctype_num)
14571 goto no_print_pctypes;
14573 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14574 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14576 goto no_print_pctypes;
14578 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14580 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14583 goto no_print_pctypes;
14586 printf("List of defined packet classification types:\n");
14587 for (i = 0; i < pctype_num; i++) {
14588 printf(" %2u:", pctype[i].ptype_id);
14589 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14590 proto_id = pctype[i].protocols[j];
14591 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14592 for (n = 0; n < proto_num; n++) {
14593 if (proto[n].proto_id == proto_id) {
14594 printf(" %s", proto[n].name);
14607 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14609 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14610 if (ret || !ptype_num)
14611 goto no_print_return;
14613 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14614 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14616 goto no_print_return;
14618 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14620 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14623 goto no_print_return;
14625 printf("List of defined packet types:\n");
14626 for (i = 0; i < ptype_num; i++) {
14627 printf(" %2u:", ptype[i].ptype_id);
14628 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14629 proto_id = ptype[i].protocols[j];
14630 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14631 for (n = 0; n < proto_num; n++) {
14632 if (proto[n].proto_id == proto_id) {
14633 printf(" %s", proto[n].name);
14649 if (ret == -ENOTSUP)
14650 fprintf(stderr, "Function not supported in PMD driver\n");
14654 cmdline_parse_inst_t cmd_ddp_get_info = {
14655 .f = cmd_ddp_info_parsed,
14657 .help_str = "ddp get info <profile_path>",
14659 (void *)&cmd_ddp_info_ddp,
14660 (void *)&cmd_ddp_info_get,
14661 (void *)&cmd_ddp_info_info,
14662 (void *)&cmd_ddp_info_filepath,
14667 /* Get dynamic device personalization profile info list*/
14668 #define PROFILE_INFO_SIZE 48
14669 #define MAX_PROFILE_NUM 16
14671 struct cmd_ddp_get_list_result {
14672 cmdline_fixed_string_t ddp;
14673 cmdline_fixed_string_t get;
14674 cmdline_fixed_string_t list;
14678 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14679 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14680 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14681 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14682 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14683 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14684 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14685 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14689 cmd_ddp_get_list_parsed(
14690 __rte_unused void *parsed_result,
14691 __rte_unused struct cmdline *cl,
14692 __rte_unused void *data)
14694 #ifdef RTE_NET_I40E
14695 struct cmd_ddp_get_list_result *res = parsed_result;
14696 struct rte_pmd_i40e_profile_list *p_list;
14697 struct rte_pmd_i40e_profile_info *p_info;
14702 int ret = -ENOTSUP;
14704 #ifdef RTE_NET_I40E
14705 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14706 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14708 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14712 if (ret == -ENOTSUP)
14713 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14714 (uint8_t *)p_list, size);
14717 p_num = p_list->p_count;
14718 printf("Profile number is: %d\n\n", p_num);
14720 for (i = 0; i < p_num; i++) {
14721 p_info = &p_list->p_info[i];
14722 printf("Profile %d:\n", i);
14723 printf("Track id: 0x%x\n", p_info->track_id);
14724 printf("Version: %d.%d.%d.%d\n",
14725 p_info->version.major,
14726 p_info->version.minor,
14727 p_info->version.update,
14728 p_info->version.draft);
14729 printf("Profile name: %s\n\n", p_info->name);
14737 fprintf(stderr, "Failed to get ddp list\n");
14740 cmdline_parse_inst_t cmd_ddp_get_list = {
14741 .f = cmd_ddp_get_list_parsed,
14743 .help_str = "ddp get list <port_id>",
14745 (void *)&cmd_ddp_get_list_ddp,
14746 (void *)&cmd_ddp_get_list_get,
14747 (void *)&cmd_ddp_get_list_list,
14748 (void *)&cmd_ddp_get_list_port_id,
14753 /* Configure input set */
14754 struct cmd_cfg_input_set_result {
14755 cmdline_fixed_string_t port;
14756 cmdline_fixed_string_t cfg;
14758 cmdline_fixed_string_t pctype;
14760 cmdline_fixed_string_t inset_type;
14761 cmdline_fixed_string_t opt;
14762 cmdline_fixed_string_t field;
14767 cmd_cfg_input_set_parsed(
14768 __rte_unused void *parsed_result,
14769 __rte_unused struct cmdline *cl,
14770 __rte_unused void *data)
14772 #ifdef RTE_NET_I40E
14773 struct cmd_cfg_input_set_result *res = parsed_result;
14774 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14775 struct rte_pmd_i40e_inset inset;
14777 int ret = -ENOTSUP;
14779 if (!all_ports_stopped()) {
14780 fprintf(stderr, "Please stop all ports first\n");
14784 #ifdef RTE_NET_I40E
14785 if (!strcmp(res->inset_type, "hash_inset"))
14786 inset_type = INSET_HASH;
14787 else if (!strcmp(res->inset_type, "fdir_inset"))
14788 inset_type = INSET_FDIR;
14789 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14790 inset_type = INSET_FDIR_FLX;
14791 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14792 &inset, inset_type);
14794 fprintf(stderr, "Failed to get input set.\n");
14798 if (!strcmp(res->opt, "get")) {
14799 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14802 printf("Field index %d is enabled.\n", res->field_idx);
14804 printf("Field index %d is disabled.\n", res->field_idx);
14806 } else if (!strcmp(res->opt, "set"))
14807 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14809 else if (!strcmp(res->opt, "clear"))
14810 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14813 fprintf(stderr, "Failed to configure input set field.\n");
14817 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14818 &inset, inset_type);
14820 fprintf(stderr, "Failed to set input set.\n");
14825 if (ret == -ENOTSUP)
14826 fprintf(stderr, "Function not supported\n");
14829 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14830 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14832 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14833 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14835 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14836 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14837 port_id, RTE_UINT16);
14838 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14839 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14841 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14842 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14843 pctype_id, RTE_UINT8);
14844 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14845 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14847 "hash_inset#fdir_inset#fdir_flx_inset");
14848 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14849 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14850 opt, "get#set#clear");
14851 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14852 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14854 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14855 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14856 field_idx, RTE_UINT8);
14858 cmdline_parse_inst_t cmd_cfg_input_set = {
14859 .f = cmd_cfg_input_set_parsed,
14861 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14862 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14864 (void *)&cmd_cfg_input_set_port,
14865 (void *)&cmd_cfg_input_set_cfg,
14866 (void *)&cmd_cfg_input_set_port_id,
14867 (void *)&cmd_cfg_input_set_pctype,
14868 (void *)&cmd_cfg_input_set_pctype_id,
14869 (void *)&cmd_cfg_input_set_inset_type,
14870 (void *)&cmd_cfg_input_set_opt,
14871 (void *)&cmd_cfg_input_set_field,
14872 (void *)&cmd_cfg_input_set_field_idx,
14877 /* Clear input set */
14878 struct cmd_clear_input_set_result {
14879 cmdline_fixed_string_t port;
14880 cmdline_fixed_string_t cfg;
14882 cmdline_fixed_string_t pctype;
14884 cmdline_fixed_string_t inset_type;
14885 cmdline_fixed_string_t clear;
14886 cmdline_fixed_string_t all;
14890 cmd_clear_input_set_parsed(
14891 __rte_unused void *parsed_result,
14892 __rte_unused struct cmdline *cl,
14893 __rte_unused void *data)
14895 #ifdef RTE_NET_I40E
14896 struct cmd_clear_input_set_result *res = parsed_result;
14897 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14898 struct rte_pmd_i40e_inset inset;
14900 int ret = -ENOTSUP;
14902 if (!all_ports_stopped()) {
14903 fprintf(stderr, "Please stop all ports first\n");
14907 #ifdef RTE_NET_I40E
14908 if (!strcmp(res->inset_type, "hash_inset"))
14909 inset_type = INSET_HASH;
14910 else if (!strcmp(res->inset_type, "fdir_inset"))
14911 inset_type = INSET_FDIR;
14912 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14913 inset_type = INSET_FDIR_FLX;
14915 memset(&inset, 0, sizeof(inset));
14917 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14918 &inset, inset_type);
14920 fprintf(stderr, "Failed to clear input set.\n");
14926 if (ret == -ENOTSUP)
14927 fprintf(stderr, "Function not supported\n");
14930 cmdline_parse_token_string_t cmd_clear_input_set_port =
14931 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14933 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14934 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14936 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14937 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14938 port_id, RTE_UINT16);
14939 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14940 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14942 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14943 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14944 pctype_id, RTE_UINT8);
14945 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14946 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14948 "hash_inset#fdir_inset#fdir_flx_inset");
14949 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14950 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14952 cmdline_parse_token_string_t cmd_clear_input_set_all =
14953 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14956 cmdline_parse_inst_t cmd_clear_input_set = {
14957 .f = cmd_clear_input_set_parsed,
14959 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14960 "fdir_inset|fdir_flx_inset clear all",
14962 (void *)&cmd_clear_input_set_port,
14963 (void *)&cmd_clear_input_set_cfg,
14964 (void *)&cmd_clear_input_set_port_id,
14965 (void *)&cmd_clear_input_set_pctype,
14966 (void *)&cmd_clear_input_set_pctype_id,
14967 (void *)&cmd_clear_input_set_inset_type,
14968 (void *)&cmd_clear_input_set_clear,
14969 (void *)&cmd_clear_input_set_all,
14974 /* show vf stats */
14976 /* Common result structure for show vf stats */
14977 struct cmd_show_vf_stats_result {
14978 cmdline_fixed_string_t show;
14979 cmdline_fixed_string_t vf;
14980 cmdline_fixed_string_t stats;
14985 /* Common CLI fields show vf stats*/
14986 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14987 TOKEN_STRING_INITIALIZER
14988 (struct cmd_show_vf_stats_result,
14990 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14991 TOKEN_STRING_INITIALIZER
14992 (struct cmd_show_vf_stats_result,
14994 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14995 TOKEN_STRING_INITIALIZER
14996 (struct cmd_show_vf_stats_result,
14998 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14999 TOKEN_NUM_INITIALIZER
15000 (struct cmd_show_vf_stats_result,
15001 port_id, RTE_UINT16);
15002 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15003 TOKEN_NUM_INITIALIZER
15004 (struct cmd_show_vf_stats_result,
15005 vf_id, RTE_UINT16);
15008 cmd_show_vf_stats_parsed(
15009 void *parsed_result,
15010 __rte_unused struct cmdline *cl,
15011 __rte_unused void *data)
15013 struct cmd_show_vf_stats_result *res = parsed_result;
15014 struct rte_eth_stats stats;
15015 int ret = -ENOTSUP;
15016 static const char *nic_stats_border = "########################";
15018 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15021 memset(&stats, 0, sizeof(stats));
15023 #ifdef RTE_NET_I40E
15024 if (ret == -ENOTSUP)
15025 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15029 #ifdef RTE_NET_BNXT
15030 if (ret == -ENOTSUP)
15031 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15040 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15043 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15046 fprintf(stderr, "function not implemented\n");
15049 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15052 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15053 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15055 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15057 stats.ipackets, stats.imissed, stats.ibytes);
15058 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15059 printf(" RX-nombuf: %-10"PRIu64"\n",
15061 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15063 stats.opackets, stats.oerrors, stats.obytes);
15065 printf(" %s############################%s\n",
15066 nic_stats_border, nic_stats_border);
15069 cmdline_parse_inst_t cmd_show_vf_stats = {
15070 .f = cmd_show_vf_stats_parsed,
15072 .help_str = "show vf stats <port_id> <vf_id>",
15074 (void *)&cmd_show_vf_stats_show,
15075 (void *)&cmd_show_vf_stats_vf,
15076 (void *)&cmd_show_vf_stats_stats,
15077 (void *)&cmd_show_vf_stats_port_id,
15078 (void *)&cmd_show_vf_stats_vf_id,
15083 /* clear vf stats */
15085 /* Common result structure for clear vf stats */
15086 struct cmd_clear_vf_stats_result {
15087 cmdline_fixed_string_t clear;
15088 cmdline_fixed_string_t vf;
15089 cmdline_fixed_string_t stats;
15094 /* Common CLI fields clear vf stats*/
15095 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15096 TOKEN_STRING_INITIALIZER
15097 (struct cmd_clear_vf_stats_result,
15099 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15100 TOKEN_STRING_INITIALIZER
15101 (struct cmd_clear_vf_stats_result,
15103 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15104 TOKEN_STRING_INITIALIZER
15105 (struct cmd_clear_vf_stats_result,
15107 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15108 TOKEN_NUM_INITIALIZER
15109 (struct cmd_clear_vf_stats_result,
15110 port_id, RTE_UINT16);
15111 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15112 TOKEN_NUM_INITIALIZER
15113 (struct cmd_clear_vf_stats_result,
15114 vf_id, RTE_UINT16);
15117 cmd_clear_vf_stats_parsed(
15118 void *parsed_result,
15119 __rte_unused struct cmdline *cl,
15120 __rte_unused void *data)
15122 struct cmd_clear_vf_stats_result *res = parsed_result;
15123 int ret = -ENOTSUP;
15125 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15128 #ifdef RTE_NET_I40E
15129 if (ret == -ENOTSUP)
15130 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15133 #ifdef RTE_NET_BNXT
15134 if (ret == -ENOTSUP)
15135 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15143 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15146 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15149 fprintf(stderr, "function not implemented\n");
15152 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15156 cmdline_parse_inst_t cmd_clear_vf_stats = {
15157 .f = cmd_clear_vf_stats_parsed,
15159 .help_str = "clear vf stats <port_id> <vf_id>",
15161 (void *)&cmd_clear_vf_stats_clear,
15162 (void *)&cmd_clear_vf_stats_vf,
15163 (void *)&cmd_clear_vf_stats_stats,
15164 (void *)&cmd_clear_vf_stats_port_id,
15165 (void *)&cmd_clear_vf_stats_vf_id,
15170 /* port config pctype mapping reset */
15172 /* Common result structure for port config pctype mapping reset */
15173 struct cmd_pctype_mapping_reset_result {
15174 cmdline_fixed_string_t port;
15175 cmdline_fixed_string_t config;
15177 cmdline_fixed_string_t pctype;
15178 cmdline_fixed_string_t mapping;
15179 cmdline_fixed_string_t reset;
15182 /* Common CLI fields for port config pctype mapping reset*/
15183 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15184 TOKEN_STRING_INITIALIZER
15185 (struct cmd_pctype_mapping_reset_result,
15187 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15188 TOKEN_STRING_INITIALIZER
15189 (struct cmd_pctype_mapping_reset_result,
15191 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15192 TOKEN_NUM_INITIALIZER
15193 (struct cmd_pctype_mapping_reset_result,
15194 port_id, RTE_UINT16);
15195 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15196 TOKEN_STRING_INITIALIZER
15197 (struct cmd_pctype_mapping_reset_result,
15199 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15200 TOKEN_STRING_INITIALIZER
15201 (struct cmd_pctype_mapping_reset_result,
15202 mapping, "mapping");
15203 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15204 TOKEN_STRING_INITIALIZER
15205 (struct cmd_pctype_mapping_reset_result,
15209 cmd_pctype_mapping_reset_parsed(
15210 void *parsed_result,
15211 __rte_unused struct cmdline *cl,
15212 __rte_unused void *data)
15214 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15215 int ret = -ENOTSUP;
15217 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15220 #ifdef RTE_NET_I40E
15221 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15228 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15231 fprintf(stderr, "function not implemented\n");
15234 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15238 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15239 .f = cmd_pctype_mapping_reset_parsed,
15241 .help_str = "port config <port_id> pctype mapping reset",
15243 (void *)&cmd_pctype_mapping_reset_port,
15244 (void *)&cmd_pctype_mapping_reset_config,
15245 (void *)&cmd_pctype_mapping_reset_port_id,
15246 (void *)&cmd_pctype_mapping_reset_pctype,
15247 (void *)&cmd_pctype_mapping_reset_mapping,
15248 (void *)&cmd_pctype_mapping_reset_reset,
15253 /* show port pctype mapping */
15255 /* Common result structure for show port pctype mapping */
15256 struct cmd_pctype_mapping_get_result {
15257 cmdline_fixed_string_t show;
15258 cmdline_fixed_string_t port;
15260 cmdline_fixed_string_t pctype;
15261 cmdline_fixed_string_t mapping;
15264 /* Common CLI fields for pctype mapping get */
15265 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15266 TOKEN_STRING_INITIALIZER
15267 (struct cmd_pctype_mapping_get_result,
15269 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15270 TOKEN_STRING_INITIALIZER
15271 (struct cmd_pctype_mapping_get_result,
15273 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15274 TOKEN_NUM_INITIALIZER
15275 (struct cmd_pctype_mapping_get_result,
15276 port_id, RTE_UINT16);
15277 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15278 TOKEN_STRING_INITIALIZER
15279 (struct cmd_pctype_mapping_get_result,
15281 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15282 TOKEN_STRING_INITIALIZER
15283 (struct cmd_pctype_mapping_get_result,
15284 mapping, "mapping");
15287 cmd_pctype_mapping_get_parsed(
15288 void *parsed_result,
15289 __rte_unused struct cmdline *cl,
15290 __rte_unused void *data)
15292 struct cmd_pctype_mapping_get_result *res = parsed_result;
15293 int ret = -ENOTSUP;
15294 #ifdef RTE_NET_I40E
15295 struct rte_pmd_i40e_flow_type_mapping
15296 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15297 int i, j, first_pctype;
15300 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15303 #ifdef RTE_NET_I40E
15304 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15311 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15314 fprintf(stderr, "function not implemented\n");
15317 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15321 #ifdef RTE_NET_I40E
15322 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15323 if (mapping[i].pctype != 0ULL) {
15326 printf("pctype: ");
15327 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15328 if (mapping[i].pctype & (1ULL << j)) {
15329 printf(first_pctype ?
15330 "%02d" : ",%02d", j);
15334 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15340 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15341 .f = cmd_pctype_mapping_get_parsed,
15343 .help_str = "show port <port_id> pctype mapping",
15345 (void *)&cmd_pctype_mapping_get_show,
15346 (void *)&cmd_pctype_mapping_get_port,
15347 (void *)&cmd_pctype_mapping_get_port_id,
15348 (void *)&cmd_pctype_mapping_get_pctype,
15349 (void *)&cmd_pctype_mapping_get_mapping,
15354 /* port config pctype mapping update */
15356 /* Common result structure for port config pctype mapping update */
15357 struct cmd_pctype_mapping_update_result {
15358 cmdline_fixed_string_t port;
15359 cmdline_fixed_string_t config;
15361 cmdline_fixed_string_t pctype;
15362 cmdline_fixed_string_t mapping;
15363 cmdline_fixed_string_t update;
15364 cmdline_fixed_string_t pctype_list;
15365 uint16_t flow_type;
15368 /* Common CLI fields for pctype mapping update*/
15369 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15370 TOKEN_STRING_INITIALIZER
15371 (struct cmd_pctype_mapping_update_result,
15373 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15374 TOKEN_STRING_INITIALIZER
15375 (struct cmd_pctype_mapping_update_result,
15377 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15378 TOKEN_NUM_INITIALIZER
15379 (struct cmd_pctype_mapping_update_result,
15380 port_id, RTE_UINT16);
15381 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15382 TOKEN_STRING_INITIALIZER
15383 (struct cmd_pctype_mapping_update_result,
15385 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15386 TOKEN_STRING_INITIALIZER
15387 (struct cmd_pctype_mapping_update_result,
15388 mapping, "mapping");
15389 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15390 TOKEN_STRING_INITIALIZER
15391 (struct cmd_pctype_mapping_update_result,
15393 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15394 TOKEN_STRING_INITIALIZER
15395 (struct cmd_pctype_mapping_update_result,
15396 pctype_list, NULL);
15397 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15398 TOKEN_NUM_INITIALIZER
15399 (struct cmd_pctype_mapping_update_result,
15400 flow_type, RTE_UINT16);
15403 cmd_pctype_mapping_update_parsed(
15404 void *parsed_result,
15405 __rte_unused struct cmdline *cl,
15406 __rte_unused void *data)
15408 struct cmd_pctype_mapping_update_result *res = parsed_result;
15409 int ret = -ENOTSUP;
15410 #ifdef RTE_NET_I40E
15411 struct rte_pmd_i40e_flow_type_mapping mapping;
15413 unsigned int nb_item;
15414 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15417 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15420 #ifdef RTE_NET_I40E
15421 nb_item = parse_item_list(res->pctype_list, "pctypes",
15422 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15423 mapping.flow_type = res->flow_type;
15424 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15425 mapping.pctype |= (1ULL << pctype_list[i]);
15426 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15436 fprintf(stderr, "invalid pctype or flow type\n");
15439 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15442 fprintf(stderr, "function not implemented\n");
15445 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15449 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15450 .f = cmd_pctype_mapping_update_parsed,
15452 .help_str = "port config <port_id> pctype mapping update"
15453 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15455 (void *)&cmd_pctype_mapping_update_port,
15456 (void *)&cmd_pctype_mapping_update_config,
15457 (void *)&cmd_pctype_mapping_update_port_id,
15458 (void *)&cmd_pctype_mapping_update_pctype,
15459 (void *)&cmd_pctype_mapping_update_mapping,
15460 (void *)&cmd_pctype_mapping_update_update,
15461 (void *)&cmd_pctype_mapping_update_pc_type,
15462 (void *)&cmd_pctype_mapping_update_flow_type,
15467 /* ptype mapping get */
15469 /* Common result structure for ptype mapping get */
15470 struct cmd_ptype_mapping_get_result {
15471 cmdline_fixed_string_t ptype;
15472 cmdline_fixed_string_t mapping;
15473 cmdline_fixed_string_t get;
15475 uint8_t valid_only;
15478 /* Common CLI fields for ptype mapping get */
15479 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15480 TOKEN_STRING_INITIALIZER
15481 (struct cmd_ptype_mapping_get_result,
15483 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15484 TOKEN_STRING_INITIALIZER
15485 (struct cmd_ptype_mapping_get_result,
15486 mapping, "mapping");
15487 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15488 TOKEN_STRING_INITIALIZER
15489 (struct cmd_ptype_mapping_get_result,
15491 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15492 TOKEN_NUM_INITIALIZER
15493 (struct cmd_ptype_mapping_get_result,
15494 port_id, RTE_UINT16);
15495 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15496 TOKEN_NUM_INITIALIZER
15497 (struct cmd_ptype_mapping_get_result,
15498 valid_only, RTE_UINT8);
15501 cmd_ptype_mapping_get_parsed(
15502 void *parsed_result,
15503 __rte_unused struct cmdline *cl,
15504 __rte_unused void *data)
15506 struct cmd_ptype_mapping_get_result *res = parsed_result;
15507 int ret = -ENOTSUP;
15508 #ifdef RTE_NET_I40E
15509 int max_ptype_num = 256;
15510 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15515 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15518 #ifdef RTE_NET_I40E
15519 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15530 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15533 fprintf(stderr, "function not implemented\n");
15536 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15539 #ifdef RTE_NET_I40E
15541 for (i = 0; i < count; i++)
15542 printf("%3d\t0x%08x\n",
15543 mapping[i].hw_ptype, mapping[i].sw_ptype);
15548 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15549 .f = cmd_ptype_mapping_get_parsed,
15551 .help_str = "ptype mapping get <port_id> <valid_only>",
15553 (void *)&cmd_ptype_mapping_get_ptype,
15554 (void *)&cmd_ptype_mapping_get_mapping,
15555 (void *)&cmd_ptype_mapping_get_get,
15556 (void *)&cmd_ptype_mapping_get_port_id,
15557 (void *)&cmd_ptype_mapping_get_valid_only,
15562 /* ptype mapping replace */
15564 /* Common result structure for ptype mapping replace */
15565 struct cmd_ptype_mapping_replace_result {
15566 cmdline_fixed_string_t ptype;
15567 cmdline_fixed_string_t mapping;
15568 cmdline_fixed_string_t replace;
15575 /* Common CLI fields for ptype mapping replace */
15576 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15577 TOKEN_STRING_INITIALIZER
15578 (struct cmd_ptype_mapping_replace_result,
15580 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15581 TOKEN_STRING_INITIALIZER
15582 (struct cmd_ptype_mapping_replace_result,
15583 mapping, "mapping");
15584 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15585 TOKEN_STRING_INITIALIZER
15586 (struct cmd_ptype_mapping_replace_result,
15587 replace, "replace");
15588 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15589 TOKEN_NUM_INITIALIZER
15590 (struct cmd_ptype_mapping_replace_result,
15591 port_id, RTE_UINT16);
15592 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15593 TOKEN_NUM_INITIALIZER
15594 (struct cmd_ptype_mapping_replace_result,
15595 target, RTE_UINT32);
15596 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15597 TOKEN_NUM_INITIALIZER
15598 (struct cmd_ptype_mapping_replace_result,
15600 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15601 TOKEN_NUM_INITIALIZER
15602 (struct cmd_ptype_mapping_replace_result,
15603 pkt_type, RTE_UINT32);
15606 cmd_ptype_mapping_replace_parsed(
15607 void *parsed_result,
15608 __rte_unused struct cmdline *cl,
15609 __rte_unused void *data)
15611 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15612 int ret = -ENOTSUP;
15614 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15617 #ifdef RTE_NET_I40E
15618 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15628 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15629 res->target, res->pkt_type);
15632 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15635 fprintf(stderr, "function not implemented\n");
15638 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15642 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15643 .f = cmd_ptype_mapping_replace_parsed,
15646 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15648 (void *)&cmd_ptype_mapping_replace_ptype,
15649 (void *)&cmd_ptype_mapping_replace_mapping,
15650 (void *)&cmd_ptype_mapping_replace_replace,
15651 (void *)&cmd_ptype_mapping_replace_port_id,
15652 (void *)&cmd_ptype_mapping_replace_target,
15653 (void *)&cmd_ptype_mapping_replace_mask,
15654 (void *)&cmd_ptype_mapping_replace_pkt_type,
15659 /* ptype mapping reset */
15661 /* Common result structure for ptype mapping reset */
15662 struct cmd_ptype_mapping_reset_result {
15663 cmdline_fixed_string_t ptype;
15664 cmdline_fixed_string_t mapping;
15665 cmdline_fixed_string_t reset;
15669 /* Common CLI fields for ptype mapping reset*/
15670 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15671 TOKEN_STRING_INITIALIZER
15672 (struct cmd_ptype_mapping_reset_result,
15674 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15675 TOKEN_STRING_INITIALIZER
15676 (struct cmd_ptype_mapping_reset_result,
15677 mapping, "mapping");
15678 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15679 TOKEN_STRING_INITIALIZER
15680 (struct cmd_ptype_mapping_reset_result,
15682 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15683 TOKEN_NUM_INITIALIZER
15684 (struct cmd_ptype_mapping_reset_result,
15685 port_id, RTE_UINT16);
15688 cmd_ptype_mapping_reset_parsed(
15689 void *parsed_result,
15690 __rte_unused struct cmdline *cl,
15691 __rte_unused void *data)
15693 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15694 int ret = -ENOTSUP;
15696 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15699 #ifdef RTE_NET_I40E
15700 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15707 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15710 fprintf(stderr, "function not implemented\n");
15713 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15717 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15718 .f = cmd_ptype_mapping_reset_parsed,
15720 .help_str = "ptype mapping reset <port_id>",
15722 (void *)&cmd_ptype_mapping_reset_ptype,
15723 (void *)&cmd_ptype_mapping_reset_mapping,
15724 (void *)&cmd_ptype_mapping_reset_reset,
15725 (void *)&cmd_ptype_mapping_reset_port_id,
15730 /* ptype mapping update */
15732 /* Common result structure for ptype mapping update */
15733 struct cmd_ptype_mapping_update_result {
15734 cmdline_fixed_string_t ptype;
15735 cmdline_fixed_string_t mapping;
15736 cmdline_fixed_string_t reset;
15742 /* Common CLI fields for ptype mapping update*/
15743 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15744 TOKEN_STRING_INITIALIZER
15745 (struct cmd_ptype_mapping_update_result,
15747 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15748 TOKEN_STRING_INITIALIZER
15749 (struct cmd_ptype_mapping_update_result,
15750 mapping, "mapping");
15751 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15752 TOKEN_STRING_INITIALIZER
15753 (struct cmd_ptype_mapping_update_result,
15755 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15756 TOKEN_NUM_INITIALIZER
15757 (struct cmd_ptype_mapping_update_result,
15758 port_id, RTE_UINT16);
15759 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15760 TOKEN_NUM_INITIALIZER
15761 (struct cmd_ptype_mapping_update_result,
15762 hw_ptype, RTE_UINT8);
15763 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15764 TOKEN_NUM_INITIALIZER
15765 (struct cmd_ptype_mapping_update_result,
15766 sw_ptype, RTE_UINT32);
15769 cmd_ptype_mapping_update_parsed(
15770 void *parsed_result,
15771 __rte_unused struct cmdline *cl,
15772 __rte_unused void *data)
15774 struct cmd_ptype_mapping_update_result *res = parsed_result;
15775 int ret = -ENOTSUP;
15776 #ifdef RTE_NET_I40E
15777 struct rte_pmd_i40e_ptype_mapping mapping;
15779 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15782 #ifdef RTE_NET_I40E
15783 mapping.hw_ptype = res->hw_ptype;
15784 mapping.sw_ptype = res->sw_ptype;
15785 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15795 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15798 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15801 fprintf(stderr, "function not implemented\n");
15804 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15808 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15809 .f = cmd_ptype_mapping_update_parsed,
15811 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15813 (void *)&cmd_ptype_mapping_update_ptype,
15814 (void *)&cmd_ptype_mapping_update_mapping,
15815 (void *)&cmd_ptype_mapping_update_update,
15816 (void *)&cmd_ptype_mapping_update_port_id,
15817 (void *)&cmd_ptype_mapping_update_hw_ptype,
15818 (void *)&cmd_ptype_mapping_update_sw_ptype,
15823 /* Common result structure for file commands */
15824 struct cmd_cmdfile_result {
15825 cmdline_fixed_string_t load;
15826 cmdline_fixed_string_t filename;
15829 /* Common CLI fields for file commands */
15830 cmdline_parse_token_string_t cmd_load_cmdfile =
15831 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15832 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15833 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15836 cmd_load_from_file_parsed(
15837 void *parsed_result,
15838 __rte_unused struct cmdline *cl,
15839 __rte_unused void *data)
15841 struct cmd_cmdfile_result *res = parsed_result;
15843 cmdline_read_from_file(res->filename);
15846 cmdline_parse_inst_t cmd_load_from_file = {
15847 .f = cmd_load_from_file_parsed,
15849 .help_str = "load <filename>",
15851 (void *)&cmd_load_cmdfile,
15852 (void *)&cmd_load_cmdfile_filename,
15857 /* Get Rx offloads capabilities */
15858 struct cmd_rx_offload_get_capa_result {
15859 cmdline_fixed_string_t show;
15860 cmdline_fixed_string_t port;
15862 cmdline_fixed_string_t rx_offload;
15863 cmdline_fixed_string_t capabilities;
15866 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15867 TOKEN_STRING_INITIALIZER
15868 (struct cmd_rx_offload_get_capa_result,
15870 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15871 TOKEN_STRING_INITIALIZER
15872 (struct cmd_rx_offload_get_capa_result,
15874 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15875 TOKEN_NUM_INITIALIZER
15876 (struct cmd_rx_offload_get_capa_result,
15877 port_id, RTE_UINT16);
15878 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15879 TOKEN_STRING_INITIALIZER
15880 (struct cmd_rx_offload_get_capa_result,
15881 rx_offload, "rx_offload");
15882 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15883 TOKEN_STRING_INITIALIZER
15884 (struct cmd_rx_offload_get_capa_result,
15885 capabilities, "capabilities");
15888 print_rx_offloads(uint64_t offloads)
15890 uint64_t single_offload;
15898 begin = __builtin_ctzll(offloads);
15899 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15901 single_offload = 1ULL << begin;
15902 for (bit = begin; bit < end; bit++) {
15903 if (offloads & single_offload)
15905 rte_eth_dev_rx_offload_name(single_offload));
15906 single_offload <<= 1;
15911 cmd_rx_offload_get_capa_parsed(
15912 void *parsed_result,
15913 __rte_unused struct cmdline *cl,
15914 __rte_unused void *data)
15916 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15917 struct rte_eth_dev_info dev_info;
15918 portid_t port_id = res->port_id;
15919 uint64_t queue_offloads;
15920 uint64_t port_offloads;
15923 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15927 queue_offloads = dev_info.rx_queue_offload_capa;
15928 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15930 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15931 printf(" Per Queue :");
15932 print_rx_offloads(queue_offloads);
15935 printf(" Per Port :");
15936 print_rx_offloads(port_offloads);
15940 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15941 .f = cmd_rx_offload_get_capa_parsed,
15943 .help_str = "show port <port_id> rx_offload capabilities",
15945 (void *)&cmd_rx_offload_get_capa_show,
15946 (void *)&cmd_rx_offload_get_capa_port,
15947 (void *)&cmd_rx_offload_get_capa_port_id,
15948 (void *)&cmd_rx_offload_get_capa_rx_offload,
15949 (void *)&cmd_rx_offload_get_capa_capabilities,
15954 /* Get Rx offloads configuration */
15955 struct cmd_rx_offload_get_configuration_result {
15956 cmdline_fixed_string_t show;
15957 cmdline_fixed_string_t port;
15959 cmdline_fixed_string_t rx_offload;
15960 cmdline_fixed_string_t configuration;
15963 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15964 TOKEN_STRING_INITIALIZER
15965 (struct cmd_rx_offload_get_configuration_result,
15967 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15968 TOKEN_STRING_INITIALIZER
15969 (struct cmd_rx_offload_get_configuration_result,
15971 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15972 TOKEN_NUM_INITIALIZER
15973 (struct cmd_rx_offload_get_configuration_result,
15974 port_id, RTE_UINT16);
15975 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15976 TOKEN_STRING_INITIALIZER
15977 (struct cmd_rx_offload_get_configuration_result,
15978 rx_offload, "rx_offload");
15979 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15980 TOKEN_STRING_INITIALIZER
15981 (struct cmd_rx_offload_get_configuration_result,
15982 configuration, "configuration");
15985 cmd_rx_offload_get_configuration_parsed(
15986 void *parsed_result,
15987 __rte_unused struct cmdline *cl,
15988 __rte_unused void *data)
15990 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15991 struct rte_eth_dev_info dev_info;
15992 portid_t port_id = res->port_id;
15993 struct rte_port *port = &ports[port_id];
15994 uint64_t port_offloads;
15995 uint64_t queue_offloads;
15996 uint16_t nb_rx_queues;
16000 printf("Rx Offloading Configuration of port %d :\n", port_id);
16002 port_offloads = port->dev_conf.rxmode.offloads;
16004 print_rx_offloads(port_offloads);
16007 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16011 nb_rx_queues = dev_info.nb_rx_queues;
16012 for (q = 0; q < nb_rx_queues; q++) {
16013 queue_offloads = port->rx_conf[q].offloads;
16014 printf(" Queue[%2d] :", q);
16015 print_rx_offloads(queue_offloads);
16021 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16022 .f = cmd_rx_offload_get_configuration_parsed,
16024 .help_str = "show port <port_id> rx_offload configuration",
16026 (void *)&cmd_rx_offload_get_configuration_show,
16027 (void *)&cmd_rx_offload_get_configuration_port,
16028 (void *)&cmd_rx_offload_get_configuration_port_id,
16029 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16030 (void *)&cmd_rx_offload_get_configuration_configuration,
16035 /* Enable/Disable a per port offloading */
16036 struct cmd_config_per_port_rx_offload_result {
16037 cmdline_fixed_string_t port;
16038 cmdline_fixed_string_t config;
16040 cmdline_fixed_string_t rx_offload;
16041 cmdline_fixed_string_t offload;
16042 cmdline_fixed_string_t on_off;
16045 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16046 TOKEN_STRING_INITIALIZER
16047 (struct cmd_config_per_port_rx_offload_result,
16049 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16050 TOKEN_STRING_INITIALIZER
16051 (struct cmd_config_per_port_rx_offload_result,
16053 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16054 TOKEN_NUM_INITIALIZER
16055 (struct cmd_config_per_port_rx_offload_result,
16056 port_id, RTE_UINT16);
16057 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16058 TOKEN_STRING_INITIALIZER
16059 (struct cmd_config_per_port_rx_offload_result,
16060 rx_offload, "rx_offload");
16061 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16062 TOKEN_STRING_INITIALIZER
16063 (struct cmd_config_per_port_rx_offload_result,
16064 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16065 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16066 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16067 "scatter#buffer_split#timestamp#security#"
16068 "keep_crc#rss_hash");
16069 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16070 TOKEN_STRING_INITIALIZER
16071 (struct cmd_config_per_port_rx_offload_result,
16075 search_rx_offload(const char *name)
16077 uint64_t single_offload;
16078 const char *single_name;
16082 single_offload = 1;
16083 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16084 single_name = rte_eth_dev_rx_offload_name(single_offload);
16085 if (!strcasecmp(single_name, name)) {
16089 single_offload <<= 1;
16093 return single_offload;
16099 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16100 __rte_unused struct cmdline *cl,
16101 __rte_unused void *data)
16103 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16104 portid_t port_id = res->port_id;
16105 struct rte_eth_dev_info dev_info;
16106 struct rte_port *port = &ports[port_id];
16107 uint64_t single_offload;
16108 uint16_t nb_rx_queues;
16112 if (port->port_status != RTE_PORT_STOPPED) {
16114 "Error: Can't config offload when Port %d is not stopped\n",
16119 single_offload = search_rx_offload(res->offload);
16120 if (single_offload == 0) {
16121 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16125 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16129 nb_rx_queues = dev_info.nb_rx_queues;
16130 if (!strcmp(res->on_off, "on")) {
16131 port->dev_conf.rxmode.offloads |= single_offload;
16132 for (q = 0; q < nb_rx_queues; q++)
16133 port->rx_conf[q].offloads |= single_offload;
16135 port->dev_conf.rxmode.offloads &= ~single_offload;
16136 for (q = 0; q < nb_rx_queues; q++)
16137 port->rx_conf[q].offloads &= ~single_offload;
16140 cmd_reconfig_device_queue(port_id, 1, 1);
16143 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16144 .f = cmd_config_per_port_rx_offload_parsed,
16146 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16147 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16148 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16149 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16150 "keep_crc|rss_hash on|off",
16152 (void *)&cmd_config_per_port_rx_offload_result_port,
16153 (void *)&cmd_config_per_port_rx_offload_result_config,
16154 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16155 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16156 (void *)&cmd_config_per_port_rx_offload_result_offload,
16157 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16162 /* Enable/Disable a per queue offloading */
16163 struct cmd_config_per_queue_rx_offload_result {
16164 cmdline_fixed_string_t port;
16166 cmdline_fixed_string_t rxq;
16168 cmdline_fixed_string_t rx_offload;
16169 cmdline_fixed_string_t offload;
16170 cmdline_fixed_string_t on_off;
16173 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16174 TOKEN_STRING_INITIALIZER
16175 (struct cmd_config_per_queue_rx_offload_result,
16177 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16178 TOKEN_NUM_INITIALIZER
16179 (struct cmd_config_per_queue_rx_offload_result,
16180 port_id, RTE_UINT16);
16181 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16182 TOKEN_STRING_INITIALIZER
16183 (struct cmd_config_per_queue_rx_offload_result,
16185 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16186 TOKEN_NUM_INITIALIZER
16187 (struct cmd_config_per_queue_rx_offload_result,
16188 queue_id, RTE_UINT16);
16189 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16190 TOKEN_STRING_INITIALIZER
16191 (struct cmd_config_per_queue_rx_offload_result,
16192 rx_offload, "rx_offload");
16193 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16194 TOKEN_STRING_INITIALIZER
16195 (struct cmd_config_per_queue_rx_offload_result,
16196 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16197 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16198 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16199 "scatter#buffer_split#timestamp#security#keep_crc");
16200 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16201 TOKEN_STRING_INITIALIZER
16202 (struct cmd_config_per_queue_rx_offload_result,
16206 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16207 __rte_unused struct cmdline *cl,
16208 __rte_unused void *data)
16210 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16211 struct rte_eth_dev_info dev_info;
16212 portid_t port_id = res->port_id;
16213 uint16_t queue_id = res->queue_id;
16214 struct rte_port *port = &ports[port_id];
16215 uint64_t single_offload;
16218 if (port->port_status != RTE_PORT_STOPPED) {
16220 "Error: Can't config offload when Port %d is not stopped\n",
16225 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16229 if (queue_id >= dev_info.nb_rx_queues) {
16231 "Error: input queue_id should be 0 ... %d\n",
16232 dev_info.nb_rx_queues - 1);
16236 single_offload = search_rx_offload(res->offload);
16237 if (single_offload == 0) {
16238 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16242 if (!strcmp(res->on_off, "on"))
16243 port->rx_conf[queue_id].offloads |= single_offload;
16245 port->rx_conf[queue_id].offloads &= ~single_offload;
16247 cmd_reconfig_device_queue(port_id, 1, 1);
16250 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16251 .f = cmd_config_per_queue_rx_offload_parsed,
16253 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16254 "vlan_strip|ipv4_cksum|"
16255 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16256 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16257 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16260 (void *)&cmd_config_per_queue_rx_offload_result_port,
16261 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16262 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16263 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16264 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16265 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16266 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16271 /* Get Tx offloads capabilities */
16272 struct cmd_tx_offload_get_capa_result {
16273 cmdline_fixed_string_t show;
16274 cmdline_fixed_string_t port;
16276 cmdline_fixed_string_t tx_offload;
16277 cmdline_fixed_string_t capabilities;
16280 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16281 TOKEN_STRING_INITIALIZER
16282 (struct cmd_tx_offload_get_capa_result,
16284 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16285 TOKEN_STRING_INITIALIZER
16286 (struct cmd_tx_offload_get_capa_result,
16288 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16289 TOKEN_NUM_INITIALIZER
16290 (struct cmd_tx_offload_get_capa_result,
16291 port_id, RTE_UINT16);
16292 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16293 TOKEN_STRING_INITIALIZER
16294 (struct cmd_tx_offload_get_capa_result,
16295 tx_offload, "tx_offload");
16296 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16297 TOKEN_STRING_INITIALIZER
16298 (struct cmd_tx_offload_get_capa_result,
16299 capabilities, "capabilities");
16302 print_tx_offloads(uint64_t offloads)
16304 uint64_t single_offload;
16312 begin = __builtin_ctzll(offloads);
16313 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16315 single_offload = 1ULL << begin;
16316 for (bit = begin; bit < end; bit++) {
16317 if (offloads & single_offload)
16319 rte_eth_dev_tx_offload_name(single_offload));
16320 single_offload <<= 1;
16325 cmd_tx_offload_get_capa_parsed(
16326 void *parsed_result,
16327 __rte_unused struct cmdline *cl,
16328 __rte_unused void *data)
16330 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16331 struct rte_eth_dev_info dev_info;
16332 portid_t port_id = res->port_id;
16333 uint64_t queue_offloads;
16334 uint64_t port_offloads;
16337 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16341 queue_offloads = dev_info.tx_queue_offload_capa;
16342 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16344 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16345 printf(" Per Queue :");
16346 print_tx_offloads(queue_offloads);
16349 printf(" Per Port :");
16350 print_tx_offloads(port_offloads);
16354 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16355 .f = cmd_tx_offload_get_capa_parsed,
16357 .help_str = "show port <port_id> tx_offload capabilities",
16359 (void *)&cmd_tx_offload_get_capa_show,
16360 (void *)&cmd_tx_offload_get_capa_port,
16361 (void *)&cmd_tx_offload_get_capa_port_id,
16362 (void *)&cmd_tx_offload_get_capa_tx_offload,
16363 (void *)&cmd_tx_offload_get_capa_capabilities,
16368 /* Get Tx offloads configuration */
16369 struct cmd_tx_offload_get_configuration_result {
16370 cmdline_fixed_string_t show;
16371 cmdline_fixed_string_t port;
16373 cmdline_fixed_string_t tx_offload;
16374 cmdline_fixed_string_t configuration;
16377 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16378 TOKEN_STRING_INITIALIZER
16379 (struct cmd_tx_offload_get_configuration_result,
16381 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16382 TOKEN_STRING_INITIALIZER
16383 (struct cmd_tx_offload_get_configuration_result,
16385 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16386 TOKEN_NUM_INITIALIZER
16387 (struct cmd_tx_offload_get_configuration_result,
16388 port_id, RTE_UINT16);
16389 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16390 TOKEN_STRING_INITIALIZER
16391 (struct cmd_tx_offload_get_configuration_result,
16392 tx_offload, "tx_offload");
16393 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16394 TOKEN_STRING_INITIALIZER
16395 (struct cmd_tx_offload_get_configuration_result,
16396 configuration, "configuration");
16399 cmd_tx_offload_get_configuration_parsed(
16400 void *parsed_result,
16401 __rte_unused struct cmdline *cl,
16402 __rte_unused void *data)
16404 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16405 struct rte_eth_dev_info dev_info;
16406 portid_t port_id = res->port_id;
16407 struct rte_port *port = &ports[port_id];
16408 uint64_t port_offloads;
16409 uint64_t queue_offloads;
16410 uint16_t nb_tx_queues;
16414 printf("Tx Offloading Configuration of port %d :\n", port_id);
16416 port_offloads = port->dev_conf.txmode.offloads;
16418 print_tx_offloads(port_offloads);
16421 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16425 nb_tx_queues = dev_info.nb_tx_queues;
16426 for (q = 0; q < nb_tx_queues; q++) {
16427 queue_offloads = port->tx_conf[q].offloads;
16428 printf(" Queue[%2d] :", q);
16429 print_tx_offloads(queue_offloads);
16435 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16436 .f = cmd_tx_offload_get_configuration_parsed,
16438 .help_str = "show port <port_id> tx_offload configuration",
16440 (void *)&cmd_tx_offload_get_configuration_show,
16441 (void *)&cmd_tx_offload_get_configuration_port,
16442 (void *)&cmd_tx_offload_get_configuration_port_id,
16443 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16444 (void *)&cmd_tx_offload_get_configuration_configuration,
16449 /* Enable/Disable a per port offloading */
16450 struct cmd_config_per_port_tx_offload_result {
16451 cmdline_fixed_string_t port;
16452 cmdline_fixed_string_t config;
16454 cmdline_fixed_string_t tx_offload;
16455 cmdline_fixed_string_t offload;
16456 cmdline_fixed_string_t on_off;
16459 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16460 TOKEN_STRING_INITIALIZER
16461 (struct cmd_config_per_port_tx_offload_result,
16463 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16464 TOKEN_STRING_INITIALIZER
16465 (struct cmd_config_per_port_tx_offload_result,
16467 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16468 TOKEN_NUM_INITIALIZER
16469 (struct cmd_config_per_port_tx_offload_result,
16470 port_id, RTE_UINT16);
16471 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16472 TOKEN_STRING_INITIALIZER
16473 (struct cmd_config_per_port_tx_offload_result,
16474 tx_offload, "tx_offload");
16475 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16476 TOKEN_STRING_INITIALIZER
16477 (struct cmd_config_per_port_tx_offload_result,
16478 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16479 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16480 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16481 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16482 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16483 "send_on_timestamp");
16484 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16485 TOKEN_STRING_INITIALIZER
16486 (struct cmd_config_per_port_tx_offload_result,
16490 search_tx_offload(const char *name)
16492 uint64_t single_offload;
16493 const char *single_name;
16497 single_offload = 1;
16498 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16499 single_name = rte_eth_dev_tx_offload_name(single_offload);
16500 if (single_name == NULL)
16502 if (!strcasecmp(single_name, name)) {
16505 } else if (!strcasecmp(single_name, "UNKNOWN"))
16507 single_offload <<= 1;
16511 return single_offload;
16517 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16518 __rte_unused struct cmdline *cl,
16519 __rte_unused void *data)
16521 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16522 portid_t port_id = res->port_id;
16523 struct rte_eth_dev_info dev_info;
16524 struct rte_port *port = &ports[port_id];
16525 uint64_t single_offload;
16526 uint16_t nb_tx_queues;
16530 if (port->port_status != RTE_PORT_STOPPED) {
16532 "Error: Can't config offload when Port %d is not stopped\n",
16537 single_offload = search_tx_offload(res->offload);
16538 if (single_offload == 0) {
16539 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16543 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16547 nb_tx_queues = dev_info.nb_tx_queues;
16548 if (!strcmp(res->on_off, "on")) {
16549 port->dev_conf.txmode.offloads |= single_offload;
16550 for (q = 0; q < nb_tx_queues; q++)
16551 port->tx_conf[q].offloads |= single_offload;
16553 port->dev_conf.txmode.offloads &= ~single_offload;
16554 for (q = 0; q < nb_tx_queues; q++)
16555 port->tx_conf[q].offloads &= ~single_offload;
16558 cmd_reconfig_device_queue(port_id, 1, 1);
16561 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16562 .f = cmd_config_per_port_tx_offload_parsed,
16564 .help_str = "port config <port_id> tx_offload "
16565 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16566 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16567 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16568 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16569 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16570 "send_on_timestamp on|off",
16572 (void *)&cmd_config_per_port_tx_offload_result_port,
16573 (void *)&cmd_config_per_port_tx_offload_result_config,
16574 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16575 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16576 (void *)&cmd_config_per_port_tx_offload_result_offload,
16577 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16582 /* Enable/Disable a per queue offloading */
16583 struct cmd_config_per_queue_tx_offload_result {
16584 cmdline_fixed_string_t port;
16586 cmdline_fixed_string_t txq;
16588 cmdline_fixed_string_t tx_offload;
16589 cmdline_fixed_string_t offload;
16590 cmdline_fixed_string_t on_off;
16593 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16594 TOKEN_STRING_INITIALIZER
16595 (struct cmd_config_per_queue_tx_offload_result,
16597 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16598 TOKEN_NUM_INITIALIZER
16599 (struct cmd_config_per_queue_tx_offload_result,
16600 port_id, RTE_UINT16);
16601 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16602 TOKEN_STRING_INITIALIZER
16603 (struct cmd_config_per_queue_tx_offload_result,
16605 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16606 TOKEN_NUM_INITIALIZER
16607 (struct cmd_config_per_queue_tx_offload_result,
16608 queue_id, RTE_UINT16);
16609 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16610 TOKEN_STRING_INITIALIZER
16611 (struct cmd_config_per_queue_tx_offload_result,
16612 tx_offload, "tx_offload");
16613 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16614 TOKEN_STRING_INITIALIZER
16615 (struct cmd_config_per_queue_tx_offload_result,
16616 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16617 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16618 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16619 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16620 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16621 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16622 TOKEN_STRING_INITIALIZER
16623 (struct cmd_config_per_queue_tx_offload_result,
16627 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16628 __rte_unused struct cmdline *cl,
16629 __rte_unused void *data)
16631 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16632 struct rte_eth_dev_info dev_info;
16633 portid_t port_id = res->port_id;
16634 uint16_t queue_id = res->queue_id;
16635 struct rte_port *port = &ports[port_id];
16636 uint64_t single_offload;
16639 if (port->port_status != RTE_PORT_STOPPED) {
16641 "Error: Can't config offload when Port %d is not stopped\n",
16646 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16650 if (queue_id >= dev_info.nb_tx_queues) {
16652 "Error: input queue_id should be 0 ... %d\n",
16653 dev_info.nb_tx_queues - 1);
16657 single_offload = search_tx_offload(res->offload);
16658 if (single_offload == 0) {
16659 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16663 if (!strcmp(res->on_off, "on"))
16664 port->tx_conf[queue_id].offloads |= single_offload;
16666 port->tx_conf[queue_id].offloads &= ~single_offload;
16668 cmd_reconfig_device_queue(port_id, 1, 1);
16671 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16672 .f = cmd_config_per_queue_tx_offload_parsed,
16674 .help_str = "port <port_id> txq <queue_id> tx_offload "
16675 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16676 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16677 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16678 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16679 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16682 (void *)&cmd_config_per_queue_tx_offload_result_port,
16683 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16684 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16685 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16686 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16687 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16688 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16693 /* *** configure tx_metadata for specific port *** */
16694 struct cmd_config_tx_metadata_specific_result {
16695 cmdline_fixed_string_t port;
16696 cmdline_fixed_string_t keyword;
16698 cmdline_fixed_string_t item;
16703 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16704 __rte_unused struct cmdline *cl,
16705 __rte_unused void *data)
16707 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16709 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16711 ports[res->port_id].tx_metadata = res->value;
16712 /* Add/remove callback to insert valid metadata in every Tx packet. */
16713 if (ports[res->port_id].tx_metadata)
16714 add_tx_md_callback(res->port_id);
16716 remove_tx_md_callback(res->port_id);
16717 rte_flow_dynf_metadata_register();
16720 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16721 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16723 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16724 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16725 keyword, "config");
16726 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16727 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16728 port_id, RTE_UINT16);
16729 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16730 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16731 item, "tx_metadata");
16732 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16733 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16734 value, RTE_UINT32);
16736 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16737 .f = cmd_config_tx_metadata_specific_parsed,
16739 .help_str = "port config <port_id> tx_metadata <value>",
16741 (void *)&cmd_config_tx_metadata_specific_port,
16742 (void *)&cmd_config_tx_metadata_specific_keyword,
16743 (void *)&cmd_config_tx_metadata_specific_id,
16744 (void *)&cmd_config_tx_metadata_specific_item,
16745 (void *)&cmd_config_tx_metadata_specific_value,
16750 /* *** set dynf *** */
16751 struct cmd_config_tx_dynf_specific_result {
16752 cmdline_fixed_string_t port;
16753 cmdline_fixed_string_t keyword;
16755 cmdline_fixed_string_t item;
16756 cmdline_fixed_string_t name;
16757 cmdline_fixed_string_t value;
16761 cmd_config_dynf_specific_parsed(void *parsed_result,
16762 __rte_unused struct cmdline *cl,
16763 __rte_unused void *data)
16765 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16766 struct rte_mbuf_dynflag desc_flag;
16768 uint64_t old_port_flags;
16770 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16772 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16774 if (strlcpy(desc_flag.name, res->name,
16775 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16776 fprintf(stderr, "Flag name too long\n");
16779 desc_flag.flags = 0;
16780 flag = rte_mbuf_dynflag_register(&desc_flag);
16782 fprintf(stderr, "Can't register flag\n");
16785 strcpy(dynf_names[flag], desc_flag.name);
16787 old_port_flags = ports[res->port_id].mbuf_dynf;
16788 if (!strcmp(res->value, "set")) {
16789 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16790 if (old_port_flags == 0)
16791 add_tx_dynf_callback(res->port_id);
16793 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16794 if (ports[res->port_id].mbuf_dynf == 0)
16795 remove_tx_dynf_callback(res->port_id);
16799 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16800 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16802 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16803 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16804 keyword, "config");
16805 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16806 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16807 port_id, RTE_UINT16);
16808 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16809 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16811 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16812 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16814 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16815 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16816 value, "set#clear");
16818 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16819 .f = cmd_config_dynf_specific_parsed,
16821 .help_str = "port config <port id> dynf <name> set|clear",
16823 (void *)&cmd_config_tx_dynf_specific_port,
16824 (void *)&cmd_config_tx_dynf_specific_keyword,
16825 (void *)&cmd_config_tx_dynf_specific_port_id,
16826 (void *)&cmd_config_tx_dynf_specific_item,
16827 (void *)&cmd_config_tx_dynf_specific_name,
16828 (void *)&cmd_config_tx_dynf_specific_value,
16833 /* *** display tx_metadata per port configuration *** */
16834 struct cmd_show_tx_metadata_result {
16835 cmdline_fixed_string_t cmd_show;
16836 cmdline_fixed_string_t cmd_port;
16837 cmdline_fixed_string_t cmd_keyword;
16842 cmd_show_tx_metadata_parsed(void *parsed_result,
16843 __rte_unused struct cmdline *cl,
16844 __rte_unused void *data)
16846 struct cmd_show_tx_metadata_result *res = parsed_result;
16848 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16849 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16852 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16853 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16854 ports[res->cmd_pid].tx_metadata);
16858 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16859 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16861 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16862 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16864 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16865 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16866 cmd_pid, RTE_UINT16);
16867 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16868 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16869 cmd_keyword, "tx_metadata");
16871 cmdline_parse_inst_t cmd_show_tx_metadata = {
16872 .f = cmd_show_tx_metadata_parsed,
16874 .help_str = "show port <port_id> tx_metadata",
16876 (void *)&cmd_show_tx_metadata_show,
16877 (void *)&cmd_show_tx_metadata_port,
16878 (void *)&cmd_show_tx_metadata_pid,
16879 (void *)&cmd_show_tx_metadata_keyword,
16884 /* *** show fec capability per port configuration *** */
16885 struct cmd_show_fec_capability_result {
16886 cmdline_fixed_string_t cmd_show;
16887 cmdline_fixed_string_t cmd_port;
16888 cmdline_fixed_string_t cmd_fec;
16889 cmdline_fixed_string_t cmd_keyword;
16894 cmd_show_fec_capability_parsed(void *parsed_result,
16895 __rte_unused struct cmdline *cl,
16896 __rte_unused void *data)
16898 struct cmd_show_fec_capability_result *res = parsed_result;
16899 struct rte_eth_fec_capa *speed_fec_capa;
16903 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16904 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16908 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16909 if (ret == -ENOTSUP) {
16910 fprintf(stderr, "Function not implemented\n");
16912 } else if (ret < 0) {
16913 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16917 num = (unsigned int)ret;
16918 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16919 if (speed_fec_capa == NULL) {
16920 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16924 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16926 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
16930 show_fec_capability(num, speed_fec_capa);
16932 free(speed_fec_capa);
16935 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16936 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16938 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16939 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16941 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16942 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16943 cmd_pid, RTE_UINT16);
16944 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16945 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16947 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16948 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16949 cmd_keyword, "capabilities");
16951 cmdline_parse_inst_t cmd_show_capability = {
16952 .f = cmd_show_fec_capability_parsed,
16954 .help_str = "show port <port_id> fec capabilities",
16956 (void *)&cmd_show_fec_capability_show,
16957 (void *)&cmd_show_fec_capability_port,
16958 (void *)&cmd_show_fec_capability_pid,
16959 (void *)&cmd_show_fec_capability_fec,
16960 (void *)&cmd_show_fec_capability_keyword,
16965 /* *** show fec mode per port configuration *** */
16966 struct cmd_show_fec_metadata_result {
16967 cmdline_fixed_string_t cmd_show;
16968 cmdline_fixed_string_t cmd_port;
16969 cmdline_fixed_string_t cmd_keyword;
16974 cmd_show_fec_mode_parsed(void *parsed_result,
16975 __rte_unused struct cmdline *cl,
16976 __rte_unused void *data)
16978 #define FEC_NAME_SIZE 16
16979 struct cmd_show_fec_metadata_result *res = parsed_result;
16981 char buf[FEC_NAME_SIZE];
16984 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16985 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16988 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16989 if (ret == -ENOTSUP) {
16990 fprintf(stderr, "Function not implemented\n");
16992 } else if (ret < 0) {
16993 fprintf(stderr, "Get FEC mode failed\n");
16998 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16999 strlcpy(buf, "off", sizeof(buf));
17001 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17002 strlcpy(buf, "auto", sizeof(buf));
17004 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17005 strlcpy(buf, "baser", sizeof(buf));
17007 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17008 strlcpy(buf, "rs", sizeof(buf));
17014 printf("%s\n", buf);
17017 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17018 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17020 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17021 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17023 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17024 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17025 cmd_pid, RTE_UINT16);
17026 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17027 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17028 cmd_keyword, "fec_mode");
17030 cmdline_parse_inst_t cmd_show_fec_mode = {
17031 .f = cmd_show_fec_mode_parsed,
17033 .help_str = "show port <port_id> fec_mode",
17035 (void *)&cmd_show_fec_mode_show,
17036 (void *)&cmd_show_fec_mode_port,
17037 (void *)&cmd_show_fec_mode_pid,
17038 (void *)&cmd_show_fec_mode_keyword,
17043 /* *** set fec mode per port configuration *** */
17044 struct cmd_set_port_fec_mode {
17045 cmdline_fixed_string_t set;
17046 cmdline_fixed_string_t port;
17048 cmdline_fixed_string_t fec_mode;
17049 cmdline_fixed_string_t fec_value;
17052 /* Common CLI fields for set fec mode */
17053 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17054 TOKEN_STRING_INITIALIZER
17055 (struct cmd_set_port_fec_mode,
17057 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17058 TOKEN_STRING_INITIALIZER
17059 (struct cmd_set_port_fec_mode,
17061 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17062 TOKEN_NUM_INITIALIZER
17063 (struct cmd_set_port_fec_mode,
17064 port_id, RTE_UINT16);
17065 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17066 TOKEN_STRING_INITIALIZER
17067 (struct cmd_set_port_fec_mode,
17068 fec_mode, "fec_mode");
17069 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17070 TOKEN_STRING_INITIALIZER
17071 (struct cmd_set_port_fec_mode,
17075 cmd_set_port_fec_mode_parsed(
17076 void *parsed_result,
17077 __rte_unused struct cmdline *cl,
17078 __rte_unused void *data)
17080 struct cmd_set_port_fec_mode *res = parsed_result;
17081 uint16_t port_id = res->port_id;
17085 ret = parse_fec_mode(res->fec_value, &fec_capa);
17087 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17088 res->fec_value, port_id);
17092 ret = rte_eth_fec_set(port_id, fec_capa);
17093 if (ret == -ENOTSUP) {
17094 fprintf(stderr, "Function not implemented\n");
17096 } else if (ret < 0) {
17097 fprintf(stderr, "Set FEC mode failed\n");
17102 cmdline_parse_inst_t cmd_set_fec_mode = {
17103 .f = cmd_set_port_fec_mode_parsed,
17105 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17107 (void *)&cmd_set_port_fec_mode_set,
17108 (void *)&cmd_set_port_fec_mode_port,
17109 (void *)&cmd_set_port_fec_mode_port_id,
17110 (void *)&cmd_set_port_fec_mode_str,
17111 (void *)&cmd_set_port_fec_mode_value,
17116 /* show port supported ptypes */
17118 /* Common result structure for show port ptypes */
17119 struct cmd_show_port_supported_ptypes_result {
17120 cmdline_fixed_string_t show;
17121 cmdline_fixed_string_t port;
17123 cmdline_fixed_string_t ptypes;
17126 /* Common CLI fields for show port ptypes */
17127 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17128 TOKEN_STRING_INITIALIZER
17129 (struct cmd_show_port_supported_ptypes_result,
17131 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17132 TOKEN_STRING_INITIALIZER
17133 (struct cmd_show_port_supported_ptypes_result,
17135 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17136 TOKEN_NUM_INITIALIZER
17137 (struct cmd_show_port_supported_ptypes_result,
17138 port_id, RTE_UINT16);
17139 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17140 TOKEN_STRING_INITIALIZER
17141 (struct cmd_show_port_supported_ptypes_result,
17145 cmd_show_port_supported_ptypes_parsed(
17146 void *parsed_result,
17147 __rte_unused struct cmdline *cl,
17148 __rte_unused void *data)
17150 #define RSVD_PTYPE_MASK 0xf0000000
17151 #define MAX_PTYPES_PER_LAYER 16
17152 #define LTYPE_NAMESIZE 32
17153 #define PTYPE_NAMESIZE 256
17154 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17155 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17156 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17157 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17158 uint16_t port_id = res->port_id;
17161 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17165 while (ptype_mask != RSVD_PTYPE_MASK) {
17167 switch (ptype_mask) {
17168 case RTE_PTYPE_L2_MASK:
17169 strlcpy(ltype, "L2", sizeof(ltype));
17171 case RTE_PTYPE_L3_MASK:
17172 strlcpy(ltype, "L3", sizeof(ltype));
17174 case RTE_PTYPE_L4_MASK:
17175 strlcpy(ltype, "L4", sizeof(ltype));
17177 case RTE_PTYPE_TUNNEL_MASK:
17178 strlcpy(ltype, "Tunnel", sizeof(ltype));
17180 case RTE_PTYPE_INNER_L2_MASK:
17181 strlcpy(ltype, "Inner L2", sizeof(ltype));
17183 case RTE_PTYPE_INNER_L3_MASK:
17184 strlcpy(ltype, "Inner L3", sizeof(ltype));
17186 case RTE_PTYPE_INNER_L4_MASK:
17187 strlcpy(ltype, "Inner L4", sizeof(ltype));
17193 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17194 ptype_mask, ptypes,
17195 MAX_PTYPES_PER_LAYER);
17198 printf("Supported %s ptypes:\n", ltype);
17200 printf("%s ptypes unsupported\n", ltype);
17202 for (i = 0; i < ret; ++i) {
17203 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17204 printf("%s\n", buf);
17211 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17212 .f = cmd_show_port_supported_ptypes_parsed,
17214 .help_str = "show port <port_id> ptypes",
17216 (void *)&cmd_show_port_supported_ptypes_show,
17217 (void *)&cmd_show_port_supported_ptypes_port,
17218 (void *)&cmd_show_port_supported_ptypes_port_id,
17219 (void *)&cmd_show_port_supported_ptypes_ptypes,
17224 /* *** display rx/tx descriptor status *** */
17225 struct cmd_show_rx_tx_desc_status_result {
17226 cmdline_fixed_string_t cmd_show;
17227 cmdline_fixed_string_t cmd_port;
17228 cmdline_fixed_string_t cmd_keyword;
17229 cmdline_fixed_string_t cmd_desc;
17230 cmdline_fixed_string_t cmd_status;
17237 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17238 __rte_unused struct cmdline *cl,
17239 __rte_unused void *data)
17241 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17244 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17245 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17249 if (!strcmp(res->cmd_keyword, "rxq")) {
17250 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17254 "Invalid input: queue id = %d, desc id = %d\n",
17255 res->cmd_qid, res->cmd_did);
17258 if (rc == RTE_ETH_RX_DESC_AVAIL)
17259 printf("Desc status = AVAILABLE\n");
17260 else if (rc == RTE_ETH_RX_DESC_DONE)
17261 printf("Desc status = DONE\n");
17263 printf("Desc status = UNAVAILABLE\n");
17264 } else if (!strcmp(res->cmd_keyword, "txq")) {
17265 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17269 "Invalid input: queue id = %d, desc id = %d\n",
17270 res->cmd_qid, res->cmd_did);
17273 if (rc == RTE_ETH_TX_DESC_FULL)
17274 printf("Desc status = FULL\n");
17275 else if (rc == RTE_ETH_TX_DESC_DONE)
17276 printf("Desc status = DONE\n");
17278 printf("Desc status = UNAVAILABLE\n");
17282 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17283 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17285 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17286 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17288 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17289 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17290 cmd_pid, RTE_UINT16);
17291 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17292 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17293 cmd_keyword, "rxq#txq");
17294 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17295 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17296 cmd_qid, RTE_UINT16);
17297 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17298 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17300 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17301 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17302 cmd_did, RTE_UINT16);
17303 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17304 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17305 cmd_status, "status");
17306 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17307 .f = cmd_show_rx_tx_desc_status_parsed,
17309 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17312 (void *)&cmd_show_rx_tx_desc_status_show,
17313 (void *)&cmd_show_rx_tx_desc_status_port,
17314 (void *)&cmd_show_rx_tx_desc_status_pid,
17315 (void *)&cmd_show_rx_tx_desc_status_keyword,
17316 (void *)&cmd_show_rx_tx_desc_status_qid,
17317 (void *)&cmd_show_rx_tx_desc_status_desc,
17318 (void *)&cmd_show_rx_tx_desc_status_did,
17319 (void *)&cmd_show_rx_tx_desc_status_status,
17324 /* *** display rx queue desc used count *** */
17325 struct cmd_show_rx_queue_desc_used_count_result {
17326 cmdline_fixed_string_t cmd_show;
17327 cmdline_fixed_string_t cmd_port;
17328 cmdline_fixed_string_t cmd_rxq;
17329 cmdline_fixed_string_t cmd_desc;
17330 cmdline_fixed_string_t cmd_used;
17331 cmdline_fixed_string_t cmd_count;
17337 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17338 __rte_unused struct cmdline *cl,
17339 __rte_unused void *data)
17341 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17344 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17345 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17349 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17351 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17354 printf("Used desc count = %d\n", rc);
17357 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17358 TOKEN_STRING_INITIALIZER
17359 (struct cmd_show_rx_queue_desc_used_count_result,
17361 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17362 TOKEN_STRING_INITIALIZER
17363 (struct cmd_show_rx_queue_desc_used_count_result,
17365 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17366 TOKEN_NUM_INITIALIZER
17367 (struct cmd_show_rx_queue_desc_used_count_result,
17368 cmd_pid, RTE_UINT16);
17369 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17370 TOKEN_STRING_INITIALIZER
17371 (struct cmd_show_rx_queue_desc_used_count_result,
17373 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17374 TOKEN_NUM_INITIALIZER
17375 (struct cmd_show_rx_queue_desc_used_count_result,
17376 cmd_qid, RTE_UINT16);
17377 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17378 TOKEN_STRING_INITIALIZER
17379 (struct cmd_show_rx_queue_desc_used_count_result,
17380 cmd_count, "desc");
17381 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17382 TOKEN_STRING_INITIALIZER
17383 (struct cmd_show_rx_queue_desc_used_count_result,
17384 cmd_count, "used");
17385 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17386 TOKEN_STRING_INITIALIZER
17387 (struct cmd_show_rx_queue_desc_used_count_result,
17388 cmd_count, "count");
17389 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17390 .f = cmd_show_rx_queue_desc_used_count_parsed,
17392 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17394 (void *)&cmd_show_rx_queue_desc_used_count_show,
17395 (void *)&cmd_show_rx_queue_desc_used_count_port,
17396 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17397 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17398 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17399 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17400 (void *)&cmd_show_rx_queue_desc_used_count_used,
17401 (void *)&cmd_show_rx_queue_desc_used_count_count,
17406 /* Common result structure for set port ptypes */
17407 struct cmd_set_port_ptypes_result {
17408 cmdline_fixed_string_t set;
17409 cmdline_fixed_string_t port;
17411 cmdline_fixed_string_t ptype_mask;
17415 /* Common CLI fields for set port ptypes */
17416 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17417 TOKEN_STRING_INITIALIZER
17418 (struct cmd_set_port_ptypes_result,
17420 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17421 TOKEN_STRING_INITIALIZER
17422 (struct cmd_set_port_ptypes_result,
17424 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17425 TOKEN_NUM_INITIALIZER
17426 (struct cmd_set_port_ptypes_result,
17427 port_id, RTE_UINT16);
17428 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17429 TOKEN_STRING_INITIALIZER
17430 (struct cmd_set_port_ptypes_result,
17431 ptype_mask, "ptype_mask");
17432 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17433 TOKEN_NUM_INITIALIZER
17434 (struct cmd_set_port_ptypes_result,
17438 cmd_set_port_ptypes_parsed(
17439 void *parsed_result,
17440 __rte_unused struct cmdline *cl,
17441 __rte_unused void *data)
17443 struct cmd_set_port_ptypes_result *res = parsed_result;
17444 #define PTYPE_NAMESIZE 256
17445 char ptype_name[PTYPE_NAMESIZE];
17446 uint16_t port_id = res->port_id;
17447 uint32_t ptype_mask = res->mask;
17450 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17453 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17458 uint32_t ptypes[ret];
17460 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17462 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17467 printf("Successfully set following ptypes for Port %d\n", port_id);
17468 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17469 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17470 printf("%s\n", ptype_name);
17473 clear_ptypes = false;
17476 cmdline_parse_inst_t cmd_set_port_ptypes = {
17477 .f = cmd_set_port_ptypes_parsed,
17479 .help_str = "set port <port_id> ptype_mask <mask>",
17481 (void *)&cmd_set_port_ptypes_set,
17482 (void *)&cmd_set_port_ptypes_port,
17483 (void *)&cmd_set_port_ptypes_port_id,
17484 (void *)&cmd_set_port_ptypes_mask_str,
17485 (void *)&cmd_set_port_ptypes_mask_u32,
17490 /* *** display mac addresses added to a port *** */
17491 struct cmd_showport_macs_result {
17492 cmdline_fixed_string_t cmd_show;
17493 cmdline_fixed_string_t cmd_port;
17494 cmdline_fixed_string_t cmd_keyword;
17499 cmd_showport_macs_parsed(void *parsed_result,
17500 __rte_unused struct cmdline *cl,
17501 __rte_unused void *data)
17503 struct cmd_showport_macs_result *res = parsed_result;
17505 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17508 if (!strcmp(res->cmd_keyword, "macs"))
17509 show_macs(res->cmd_pid);
17510 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17511 show_mcast_macs(res->cmd_pid);
17514 cmdline_parse_token_string_t cmd_showport_macs_show =
17515 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17517 cmdline_parse_token_string_t cmd_showport_macs_port =
17518 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17520 cmdline_parse_token_num_t cmd_showport_macs_pid =
17521 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17522 cmd_pid, RTE_UINT16);
17523 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17524 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17525 cmd_keyword, "macs#mcast_macs");
17527 cmdline_parse_inst_t cmd_showport_macs = {
17528 .f = cmd_showport_macs_parsed,
17530 .help_str = "show port <port_id> macs|mcast_macs",
17532 (void *)&cmd_showport_macs_show,
17533 (void *)&cmd_showport_macs_port,
17534 (void *)&cmd_showport_macs_pid,
17535 (void *)&cmd_showport_macs_keyword,
17540 /* ******************************************************************************** */
17542 /* list of instructions */
17543 cmdline_parse_ctx_t main_ctx[] = {
17544 (cmdline_parse_inst_t *)&cmd_help_brief,
17545 (cmdline_parse_inst_t *)&cmd_help_long,
17546 (cmdline_parse_inst_t *)&cmd_quit,
17547 (cmdline_parse_inst_t *)&cmd_load_from_file,
17548 (cmdline_parse_inst_t *)&cmd_showport,
17549 (cmdline_parse_inst_t *)&cmd_showqueue,
17550 (cmdline_parse_inst_t *)&cmd_showeeprom,
17551 (cmdline_parse_inst_t *)&cmd_showportall,
17552 (cmdline_parse_inst_t *)&cmd_showdevice,
17553 (cmdline_parse_inst_t *)&cmd_showcfg,
17554 (cmdline_parse_inst_t *)&cmd_showfwdall,
17555 (cmdline_parse_inst_t *)&cmd_start,
17556 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17557 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17558 (cmdline_parse_inst_t *)&cmd_set_link_up,
17559 (cmdline_parse_inst_t *)&cmd_set_link_down,
17560 (cmdline_parse_inst_t *)&cmd_reset,
17561 (cmdline_parse_inst_t *)&cmd_set_numbers,
17562 (cmdline_parse_inst_t *)&cmd_set_log,
17563 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17564 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17565 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17566 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17567 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17568 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17569 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17570 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17571 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17572 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17573 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17574 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17575 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17576 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17577 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17578 (cmdline_parse_inst_t *)&cmd_set_link_check,
17579 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17580 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17581 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17582 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17583 #ifdef RTE_NET_BOND
17584 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17585 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17586 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17587 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17588 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17589 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17590 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17591 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17592 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17593 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17594 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17596 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17597 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17598 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17599 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17600 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17601 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17602 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17603 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17604 (cmdline_parse_inst_t *)&cmd_csum_set,
17605 (cmdline_parse_inst_t *)&cmd_csum_show,
17606 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17607 (cmdline_parse_inst_t *)&cmd_tso_set,
17608 (cmdline_parse_inst_t *)&cmd_tso_show,
17609 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17610 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17611 (cmdline_parse_inst_t *)&cmd_gro_enable,
17612 (cmdline_parse_inst_t *)&cmd_gro_flush,
17613 (cmdline_parse_inst_t *)&cmd_gro_show,
17614 (cmdline_parse_inst_t *)&cmd_gso_enable,
17615 (cmdline_parse_inst_t *)&cmd_gso_size,
17616 (cmdline_parse_inst_t *)&cmd_gso_show,
17617 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17618 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17619 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17620 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17621 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17622 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17623 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17624 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17625 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17626 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17627 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17628 (cmdline_parse_inst_t *)&cmd_config_dcb,
17629 (cmdline_parse_inst_t *)&cmd_read_reg,
17630 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17631 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17632 (cmdline_parse_inst_t *)&cmd_write_reg,
17633 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17634 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17635 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17636 (cmdline_parse_inst_t *)&cmd_stop,
17637 (cmdline_parse_inst_t *)&cmd_mac_addr,
17638 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17639 (cmdline_parse_inst_t *)&cmd_set_qmap,
17640 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17641 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17642 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17643 (cmdline_parse_inst_t *)&cmd_operate_port,
17644 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17645 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17646 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17647 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17648 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17649 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17650 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17651 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17652 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17653 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17654 (cmdline_parse_inst_t *)&cmd_config_mtu,
17655 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17656 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17657 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17658 (cmdline_parse_inst_t *)&cmd_config_rss,
17659 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17660 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17661 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17662 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17663 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17664 (cmdline_parse_inst_t *)&cmd_showport_reta,
17665 (cmdline_parse_inst_t *)&cmd_showport_macs,
17666 (cmdline_parse_inst_t *)&cmd_config_burst,
17667 (cmdline_parse_inst_t *)&cmd_config_thresh,
17668 (cmdline_parse_inst_t *)&cmd_config_threshold,
17669 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17670 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17671 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17672 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17673 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17674 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17675 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17676 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17677 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17678 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17679 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17680 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17681 (cmdline_parse_inst_t *)&cmd_dump,
17682 (cmdline_parse_inst_t *)&cmd_dump_one,
17683 #ifdef RTE_NET_I40E
17684 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17686 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17687 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17688 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17689 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17690 (cmdline_parse_inst_t *)&cmd_flow,
17691 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17692 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17693 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17694 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17695 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17696 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17697 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17698 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17699 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17700 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17701 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17702 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17703 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17704 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17705 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17706 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17707 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17708 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17709 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17710 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17711 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17712 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17713 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17714 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17715 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17716 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17717 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17718 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17719 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17720 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17721 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17722 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17723 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17724 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17725 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17726 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17727 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17728 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17729 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17730 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17731 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17732 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17733 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17734 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17735 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17736 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17737 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17738 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17739 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17740 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17741 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17742 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17743 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17744 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17745 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17746 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17747 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17748 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17749 (cmdline_parse_inst_t *)&cmd_ddp_add,
17750 (cmdline_parse_inst_t *)&cmd_ddp_del,
17751 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17752 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17753 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17754 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17755 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17756 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17757 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17758 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17759 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17760 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17761 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17762 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17764 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17765 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17766 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17767 (cmdline_parse_inst_t *)&cmd_queue_region,
17768 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17769 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17770 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17771 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17772 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17773 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17774 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17775 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17776 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17777 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17778 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17779 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17780 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17781 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17782 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17783 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17784 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17785 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17786 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17787 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17788 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17789 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17790 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17791 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17792 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17793 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17794 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17795 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17796 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17797 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17798 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17799 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17800 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17801 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17802 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17803 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17805 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17806 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17808 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17809 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17810 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17811 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17812 (cmdline_parse_inst_t *)&cmd_set_raw,
17813 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17814 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17815 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17816 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17817 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17818 (cmdline_parse_inst_t *)&cmd_show_capability,
17822 /* read cmdline commands from file */
17824 cmdline_read_from_file(const char *filename)
17826 struct cmdline *cl;
17828 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17831 "Failed to create file based cmdline context: %s\n",
17836 cmdline_interact(cl);
17841 printf("Read CLI commands from %s\n", filename);
17844 /* prompt function, called from main on MAIN lcore */
17849 /* initialize non-constant commands */
17850 cmd_set_fwd_mode_init();
17851 cmd_set_fwd_retry_mode_init();
17853 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17854 if (testpmd_cl == NULL)
17857 ret = atexit(prompt_exit);
17859 fprintf(stderr, "Cannot set exit function for cmdline\n");
17861 cmdline_interact(testpmd_cl);
17863 cmdline_stdin_exit(testpmd_cl);
17869 if (testpmd_cl != NULL) {
17870 cmdline_quit(testpmd_cl);
17871 cmdline_stdin_exit(testpmd_cl);
17876 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17878 if (id == (portid_t)RTE_PORT_ALL) {
17881 RTE_ETH_FOREACH_DEV(pid) {
17882 /* check if need_reconfig has been set to 1 */
17883 if (ports[pid].need_reconfig == 0)
17884 ports[pid].need_reconfig = dev;
17885 /* check if need_reconfig_queues has been set to 1 */
17886 if (ports[pid].need_reconfig_queues == 0)
17887 ports[pid].need_reconfig_queues = queue;
17889 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17890 /* check if need_reconfig has been set to 1 */
17891 if (ports[id].need_reconfig == 0)
17892 ports[id].need_reconfig = dev;
17893 /* check if need_reconfig_queues has been set to 1 */
17894 if (ports[id].need_reconfig_queues == 0)
17895 ports[id].need_reconfig_queues = queue;