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_branch_prediction.h>
29 #include <rte_mempool.h>
30 #include <rte_interrupts.h>
32 #include <rte_ether.h>
33 #include <rte_ethdev.h>
34 #include <rte_string_fns.h>
35 #include <rte_devargs.h>
40 #include <rte_mbuf_dyn.h>
42 #include <cmdline_rdline.h>
43 #include <cmdline_parse.h>
44 #include <cmdline_parse_num.h>
45 #include <cmdline_parse_string.h>
46 #include <cmdline_parse_ipaddr.h>
47 #include <cmdline_parse_etheraddr.h>
48 #include <cmdline_socket.h>
51 #include <rte_eth_bond.h>
52 #include <rte_eth_bond_8023ad.h>
54 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
55 #include <rte_pmd_dpaa.h>
58 #include <rte_pmd_ixgbe.h>
61 #include <rte_pmd_i40e.h>
64 #include <rte_pmd_bnxt.h>
67 #include "cmdline_mtr.h"
68 #include "cmdline_tm.h"
71 static struct cmdline *testpmd_cl;
73 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
75 /* *** Help command with introduction. *** */
76 struct cmd_help_brief_result {
77 cmdline_fixed_string_t help;
80 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
82 __rte_unused void *data)
87 "Help is available for the following sections:\n\n"
88 " help control : Start and stop forwarding.\n"
89 " help display : Displaying port, stats and config "
91 " help config : Configuration information.\n"
92 " help ports : Configuring ports.\n"
93 " help registers : Reading and setting port registers.\n"
94 " help filters : Filters configuration help.\n"
95 " help traffic_management : Traffic Management commands.\n"
96 " help devices : Device related cmds.\n"
97 " help all : All of the above sections.\n\n"
102 cmdline_parse_token_string_t cmd_help_brief_help =
103 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
105 cmdline_parse_inst_t cmd_help_brief = {
106 .f = cmd_help_brief_parsed,
108 .help_str = "help: Show help",
110 (void *)&cmd_help_brief_help,
115 /* *** Help command with help sections. *** */
116 struct cmd_help_long_result {
117 cmdline_fixed_string_t help;
118 cmdline_fixed_string_t section;
121 static void cmd_help_long_parsed(void *parsed_result,
123 __rte_unused void *data)
126 struct cmd_help_long_result *res = parsed_result;
128 if (!strcmp(res->section, "all"))
131 if (show_all || !strcmp(res->section, "control")) {
136 "Control forwarding:\n"
137 "-------------------\n\n"
140 " Start packet forwarding with current configuration.\n\n"
143 " Start packet forwarding with current config"
144 " after sending one burst of packets.\n\n"
147 " Stop packet forwarding, and display accumulated"
151 " Quit to prompt.\n\n"
155 if (show_all || !strcmp(res->section, "display")) {
163 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
164 " Display information for port_id, or all.\n\n"
166 "show port info (port_id) representor\n"
167 " Show supported representors for a specific port\n\n"
169 "show port port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) rxq (queue_id) desc used count\n"
250 " Show current number of filled receive"
251 " packet descriptors.\n\n"
253 "show port (port_id) macs|mcast_macs"
254 " Display list of mac addresses added to port.\n\n"
256 "show port (port_id) flow transfer proxy\n"
257 " Display proxy port to manage transfer flows\n\n"
259 "show port (port_id) fec capabilities"
260 " Show fec capabilities of a port.\n\n"
262 "show port (port_id) fec_mode"
263 " Show fec mode of a port.\n\n"
265 "show port (port_id) flow_ctrl"
266 " Show flow control info of a port.\n\n"
270 if (show_all || !strcmp(res->section, "config")) {
276 "Configuration changes only become active when"
277 " forwarding is started/restarted.\n\n"
280 " Reset forwarding to the default configuration.\n\n"
282 "set verbose (level)\n"
283 " Set the debug verbosity level X.\n\n"
285 "set log global|(type) (level)\n"
286 " Set the log level.\n\n"
289 " Set number of ports.\n\n"
292 " Set number of cores.\n\n"
294 "set coremask (mask)\n"
295 " Set the forwarding cores hexadecimal mask.\n\n"
297 "set portmask (mask)\n"
298 " Set the forwarding ports hexadecimal mask.\n\n"
301 " Set number of packets per burst.\n\n"
303 "set burst tx delay (microseconds) retry (num)\n"
304 " Set the transmit delay time and number of retries,"
305 " effective when retry is enabled.\n\n"
307 "set rxoffs (x[,y]*)\n"
308 " Set the offset of each packet segment on"
309 " receiving if split feature is engaged."
310 " Affects only the queues configured with split"
313 "set rxpkts (x[,y]*)\n"
314 " Set the length of each segment to scatter"
315 " packets on receiving if split feature is engaged."
316 " Affects only the queues configured with split"
319 "set txpkts (x[,y]*)\n"
320 " Set the length of each segment of TXONLY"
321 " and optionally CSUM packets.\n\n"
323 "set txsplit (off|on|rand)\n"
324 " Set the split policy for the TX packets."
325 " Right now only applicable for CSUM and TXONLY"
328 "set txtimes (x, y)\n"
329 " Set the scheduling on timestamps"
330 " timings for the TXONLY mode\n\n"
332 "set corelist (x[,y]*)\n"
333 " Set the list of forwarding cores.\n\n"
335 "set portlist (x[,y]*)\n"
336 " Set the list of forwarding ports.\n\n"
338 "set port setup on (iterator|event)\n"
339 " Select how attached port is retrieved for setup.\n\n"
341 "set tx loopback (port_id) (on|off)\n"
342 " Enable or disable tx loopback.\n\n"
344 "set all queues drop (port_id) (on|off)\n"
345 " Set drop enable bit for all queues.\n\n"
347 "set vf split drop (port_id) (vf_id) (on|off)\n"
348 " Set split drop enable bit for a VF from the PF.\n\n"
350 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
351 " Set MAC antispoof for a VF from the PF.\n\n"
353 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
354 " Enable MACsec offload.\n\n"
356 "set macsec offload (port_id) off\n"
357 " Disable MACsec offload.\n\n"
359 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
360 " Configure MACsec secure connection (SC).\n\n"
362 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
363 " Configure MACsec secure association (SA).\n\n"
365 "set vf broadcast (port_id) (vf_id) (on|off)\n"
366 " Set VF broadcast for a VF from the PF.\n\n"
368 "vlan set stripq (on|off) (port_id,queue_id)\n"
369 " Set the VLAN strip for a queue on a port.\n\n"
371 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
372 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
374 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
375 " Set VLAN insert for a VF from the PF.\n\n"
377 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
378 " Set VLAN antispoof for a VF from the PF.\n\n"
380 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
381 " Set VLAN tag for a VF from the PF.\n\n"
383 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
384 " Set a VF's max bandwidth(Mbps).\n\n"
386 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
387 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
389 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
390 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
392 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
393 " Set some TCs' strict link priority mode on a physical port.\n\n"
395 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
396 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
398 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
399 " Set the VLAN strip or filter or qinq strip or extend\n\n"
401 "vlan set (inner|outer) tpid (value) (port_id)\n"
402 " Set the VLAN TPID for Packet Filtering on"
405 "rx_vlan add (vlan_id|all) (port_id)\n"
406 " Add a vlan_id, or all identifiers, to the set"
407 " of VLAN identifiers filtered by port_id.\n\n"
409 "rx_vlan rm (vlan_id|all) (port_id)\n"
410 " Remove a vlan_id, or all identifiers, from the set"
411 " of VLAN identifiers filtered by port_id.\n\n"
413 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
414 " Add a vlan_id, to the set of VLAN identifiers"
415 "filtered for VF(s) from port_id.\n\n"
417 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
418 " Remove a vlan_id, to the set of VLAN identifiers"
419 "filtered for VF(s) from port_id.\n\n"
421 "rx_vxlan_port add (udp_port) (port_id)\n"
422 " Add an UDP port for VXLAN packet filter on a port\n\n"
424 "rx_vxlan_port rm (udp_port) (port_id)\n"
425 " Remove an UDP port for VXLAN packet filter on a port\n\n"
427 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
428 " Set hardware insertion of VLAN IDs (single or double VLAN "
429 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
431 "tx_vlan set pvid port_id vlan_id (on|off)\n"
432 " Set port based TX VLAN insertion.\n\n"
434 "tx_vlan reset (port_id)\n"
435 " Disable hardware insertion of a VLAN header in"
436 " packets sent on a port.\n\n"
438 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
439 " Select hardware or software calculation of the"
440 " checksum when transmitting a packet using the"
441 " csum forward engine.\n"
442 " ip|udp|tcp|sctp always concern the inner layer.\n"
443 " outer-ip concerns the outer IP layer in"
444 " outer-udp concerns the outer UDP layer in"
445 " case the packet is recognized as a tunnel packet by"
446 " the forward engine (vxlan, gre and ipip are supported)\n"
447 " Please check the NIC datasheet for HW limits.\n\n"
449 "csum parse-tunnel (on|off) (tx_port_id)\n"
450 " If disabled, treat tunnel packets as non-tunneled"
451 " packets (treat inner headers as payload). The port\n"
452 " argument is the port used for TX in csum forward"
455 "csum show (port_id)\n"
456 " Display tx checksum offload configuration\n\n"
458 "tso set (segsize) (portid)\n"
459 " Enable TCP Segmentation Offload in csum forward"
461 " Please check the NIC datasheet for HW limits.\n\n"
464 " Display the status of TCP Segmentation Offload.\n\n"
467 "set port (port_id) gro on|off\n"
468 " Enable or disable Generic Receive Offload in"
469 " csum forwarding engine.\n\n"
471 "show port (port_id) gro\n"
472 " Display GRO configuration.\n\n"
474 "set gro flush (cycles)\n"
475 " Set the cycle to flush GROed packets from"
476 " reassembly tables.\n\n"
480 "set port (port_id) gso (on|off)"
481 " Enable or disable Generic Segmentation Offload in"
482 " csum forwarding engine.\n\n"
484 "set gso segsz (length)\n"
485 " Set max packet length for output GSO segments,"
486 " including packet header and payload.\n\n"
488 "show port (port_id) gso\n"
489 " Show GSO configuration.\n\n"
493 " Set packet forwarding mode.\n\n"
495 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
496 " Add a MAC address on port_id.\n\n"
498 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
499 " Remove a MAC address from port_id.\n\n"
501 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
502 " Set the default MAC address for port_id.\n\n"
504 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
505 " Add a MAC address for a VF on the port.\n\n"
507 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
508 " Set the MAC address for a VF from the PF.\n\n"
510 "set eth-peer (port_id) (peer_addr)\n"
511 " set the peer address for certain port.\n\n"
513 "set port (port_id) uta (mac_address|all) (on|off)\n"
514 " Add/Remove a or all unicast hash filter(s)"
517 "set promisc (port_id|all) (on|off)\n"
518 " Set the promiscuous mode on port_id, or all.\n\n"
520 "set allmulti (port_id|all) (on|off)\n"
521 " Set the allmulti mode on port_id, or all.\n\n"
523 "set vf promisc (port_id) (vf_id) (on|off)\n"
524 " Set unicast promiscuous mode for a VF from the PF.\n\n"
526 "set vf allmulti (port_id) (vf_id) (on|off)\n"
527 " Set multicast promiscuous mode for a VF from the PF.\n\n"
529 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
530 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
531 " (on|off) autoneg (on|off) (port_id)\n"
532 "set flow_ctrl rx (on|off) (portid)\n"
533 "set flow_ctrl tx (on|off) (portid)\n"
534 "set flow_ctrl high_water (high_water) (portid)\n"
535 "set flow_ctrl low_water (low_water) (portid)\n"
536 "set flow_ctrl pause_time (pause_time) (portid)\n"
537 "set flow_ctrl send_xon (send_xon) (portid)\n"
538 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
539 "set flow_ctrl autoneg (on|off) (port_id)\n"
540 " Set the link flow control parameter on a port.\n\n"
542 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
543 " (low_water) (pause_time) (priority) (port_id)\n"
544 " Set the priority flow control parameter on a"
547 "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
548 " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
549 " Set the queue priority flow control parameter on a"
550 " given Rx and Tx queues of a port.\n\n"
552 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
553 " Set statistics mapping (qmapping 0..15) for RX/TX"
555 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
556 " on port 0 to mapping 5.\n\n"
558 "set xstats-hide-zero on|off\n"
559 " Set the option to hide the zero values"
560 " for xstats display.\n"
562 "set record-core-cycles on|off\n"
563 " Set the option to enable measurement of CPU cycles.\n"
565 "set record-burst-stats on|off\n"
566 " Set the option to enable display of RX and TX bursts.\n"
568 "set port (port_id) vf (vf_id) rx|tx on|off\n"
569 " Enable/Disable a VF receive/transmit from a port\n\n"
571 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
573 " AUPE:accepts untagged VLAN;"
574 "ROPE:accept unicast hash\n\n"
575 " BAM:accepts broadcast packets;"
576 "MPE:accepts all multicast packets\n\n"
577 " Enable/Disable a VF receive mode of a port\n\n"
579 "set port (port_id) queue (queue_id) rate (rate_num)\n"
580 " Set rate limit for a queue of a port\n\n"
582 "set port (port_id) vf (vf_id) rate (rate_num) "
583 "queue_mask (queue_mask_value)\n"
584 " Set rate limit for queues in VF of a port\n\n"
586 "set flush_rx (on|off)\n"
587 " Flush (default) or don't flush RX streams before"
588 " forwarding. Mainly used with PCAP drivers.\n\n"
590 "set bypass mode (normal|bypass|isolate) (port_id)\n"
591 " Set the bypass mode for the lowest port on bypass enabled"
594 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
595 "mode (normal|bypass|isolate) (port_id)\n"
596 " Set the event required to initiate specified bypass mode for"
597 " the lowest port on a bypass enabled NIC where:\n"
598 " timeout = enable bypass after watchdog timeout.\n"
599 " os_on = enable bypass when OS/board is powered on.\n"
600 " os_off = enable bypass when OS/board is powered off.\n"
601 " power_on = enable bypass when power supply is turned on.\n"
602 " power_off = enable bypass when power supply is turned off."
605 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
606 " Set the bypass watchdog timeout to 'n' seconds"
607 " where 0 = instant.\n\n"
609 "show bypass config (port_id)\n"
610 " Show the bypass configuration for a bypass enabled NIC"
611 " using the lowest port on the NIC.\n\n"
614 "create bonded device (mode) (socket)\n"
615 " Create a new bonded device with specific bonding mode and socket.\n\n"
617 "add bonding slave (slave_id) (port_id)\n"
618 " Add a slave device to a bonded device.\n\n"
620 "remove bonding slave (slave_id) (port_id)\n"
621 " Remove a slave device from a bonded device.\n\n"
623 "set bonding mode (value) (port_id)\n"
624 " Set the bonding mode on a bonded device.\n\n"
626 "set bonding primary (slave_id) (port_id)\n"
627 " Set the primary slave for a bonded device.\n\n"
629 "show bonding config (port_id)\n"
630 " Show the bonding config for port_id.\n\n"
632 "show bonding lacp info (port_id)\n"
633 " Show the bonding lacp information for port_id.\n\n"
635 "set bonding mac_addr (port_id) (address)\n"
636 " Set the MAC address of a bonded device.\n\n"
638 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
639 " Set Aggregation mode for IEEE802.3AD (mode 4)"
641 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
642 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
644 "set bonding mon_period (port_id) (value)\n"
645 " Set the bonding link status monitoring polling period in ms.\n\n"
647 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
648 " Enable/disable dedicated queues for LACP control traffic.\n\n"
651 "set link-up port (port_id)\n"
652 " Set link up for a port.\n\n"
654 "set link-down port (port_id)\n"
655 " Set link down for a port.\n\n"
657 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
658 " Load a profile package on a port\n\n"
660 "ddp del (port_id) (backup_profile_path)\n"
661 " Delete a profile package from a port\n\n"
663 "ptype mapping get (port_id) (valid_only)\n"
664 " Get ptype mapping on a port\n\n"
666 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
667 " Replace target with the pkt_type in ptype mapping\n\n"
669 "ptype mapping reset (port_id)\n"
670 " Reset ptype mapping on a port\n\n"
672 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
673 " Update a ptype mapping item on a port\n\n"
675 "set port (port_id) ptype_mask (ptype_mask)\n"
676 " set packet types classification for a specific port\n\n"
678 "set port (port_id) queue-region region_id (value) "
679 "queue_start_index (value) queue_num (value)\n"
680 " Set a queue region on a port\n\n"
682 "set port (port_id) queue-region region_id (value) "
684 " Set a flowtype region index on a port\n\n"
686 "set port (port_id) queue-region UP (value) region_id (value)\n"
687 " Set the mapping of User Priority to "
688 "queue region on a port\n\n"
690 "set port (port_id) queue-region flush (on|off)\n"
691 " flush all queue region related configuration\n\n"
693 "show port meter cap (port_id)\n"
694 " Show port meter capability information\n\n"
696 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
697 " meter profile add - srtcm rfc 2697\n\n"
699 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
700 " meter profile add - trtcm rfc 2698\n\n"
702 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
703 " meter profile add - trtcm rfc 4115\n\n"
705 "del port meter profile (port_id) (profile_id)\n"
706 " meter profile delete\n\n"
708 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
709 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
710 "(dscp_tbl_entry63)]\n"
713 "enable port meter (port_id) (mtr_id)\n"
716 "disable port meter (port_id) (mtr_id)\n"
719 "del port meter (port_id) (mtr_id)\n"
722 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
723 "y_actions (actions) r_actions (actions)\n"
724 " meter policy add\n\n"
726 "del port meter policy (port_id) (policy_id)\n"
727 " meter policy delete\n\n"
729 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
730 " meter update meter profile\n\n"
732 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
733 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
734 " update meter dscp table entries\n\n"
736 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
737 "(action0) [(action1) (action2)]\n"
738 " meter update policer action\n\n"
740 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
741 " meter update stats\n\n"
743 "show port (port_id) queue-region\n"
744 " show all queue region related configuration info\n\n"
746 "set port (port_id) fec_mode auto|off|rs|baser\n"
747 " set fec mode for a specific port\n\n"
749 , list_pkt_forwarding_modes()
753 if (show_all || !strcmp(res->section, "ports")) {
759 "----------------\n\n"
761 "port start (port_id|all)\n"
762 " Start all ports or port_id.\n\n"
764 "port stop (port_id|all)\n"
765 " Stop all ports or port_id.\n\n"
767 "port close (port_id|all)\n"
768 " Close all ports or port_id.\n\n"
770 "port reset (port_id|all)\n"
771 " Reset all ports or port_id.\n\n"
773 "port attach (ident)\n"
774 " Attach physical or virtual dev by pci address or virtual device name\n\n"
776 "port detach (port_id)\n"
777 " Detach physical or virtual dev by port_id\n\n"
779 "port config (port_id|all)"
780 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
781 " duplex (half|full|auto)\n"
782 " Set speed and duplex for all ports or port_id\n\n"
784 "port config (port_id|all) loopback (mode)\n"
785 " Set loopback mode for all ports or port_id\n\n"
787 "port config all (rxq|txq|rxd|txd) (value)\n"
788 " Set number for rxq/txq/rxd/txd.\n\n"
790 "port config all max-pkt-len (value)\n"
791 " Set the max packet length.\n\n"
793 "port config all max-lro-pkt-size (value)\n"
794 " Set the max LRO aggregated packet size.\n\n"
796 "port config all drop-en (on|off)\n"
797 " Enable or disable packet drop on all RX queues of all ports when no "
798 "receive buffers available.\n\n"
800 "port config all rss (all|default|ip|tcp|udp|sctp|"
801 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|l2tpv2|"
802 "none|level-default|level-outer|level-inner|<flowtype_id>)\n"
803 " Set the RSS mode.\n\n"
805 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
806 " Set the RSS redirection table.\n\n"
808 "port config (port_id) dcb vt (on|off) (traffic_class)"
810 " Set the DCB mode.\n\n"
812 "port config all burst (value)\n"
813 " Set the number of packets per burst.\n\n"
815 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
817 " Set the ring prefetch/host/writeback threshold"
818 " for tx/rx queue.\n\n"
820 "port config all (txfreet|txrst|rxfreet) (value)\n"
821 " Set free threshold for rx/tx, or set"
822 " tx rs bit threshold.\n\n"
823 "port config mtu X value\n"
824 " Set the MTU of port X to a given value\n\n"
826 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
827 " Set a rx/tx queue's ring size configuration, the new"
828 " value will take effect after command that (re-)start the port"
829 " or command that setup the specific queue\n\n"
831 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
832 " Start/stop a rx/tx queue of port X. Only take effect"
833 " when port X is started\n\n"
835 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
836 " Switch on/off a deferred start of port X rx/tx queue. Only"
837 " take effect when port X is stopped.\n\n"
839 "port (port_id) (rxq|txq) (queue_id) setup\n"
840 " Setup a rx/tx queue of port X.\n\n"
842 "port config (port_id) pctype mapping reset\n"
843 " Reset flow type to pctype mapping on a port\n\n"
845 "port config (port_id) pctype mapping update"
846 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
847 " Update a flow type to pctype mapping item on a port\n\n"
849 "port config (port_id) pctype (pctype_id) hash_inset|"
850 "fdir_inset|fdir_flx_inset get|set|clear field\n"
852 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
854 "port config (port_id) pctype (pctype_id) hash_inset|"
855 "fdir_inset|fdir_flx_inset clear all"
856 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
858 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
859 " Add/remove UDP tunnel port for tunneling offload\n\n"
861 "port config <port_id> rx_offload vlan_strip|"
862 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
863 "outer_ipv4_cksum|macsec_strip|header_split|"
864 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
865 "buffer_split|timestamp|security|keep_crc on|off\n"
866 " Enable or disable a per port Rx offloading"
867 " on all Rx queues of a port\n\n"
869 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
870 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
871 "outer_ipv4_cksum|macsec_strip|header_split|"
872 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
873 "buffer_split|timestamp|security|keep_crc on|off\n"
874 " Enable or disable a per queue Rx offloading"
875 " only on a specific Rx queue\n\n"
877 "port config (port_id) tx_offload vlan_insert|"
878 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
879 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
880 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
881 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
883 " Enable or disable a per port Tx offloading"
884 " on all Tx queues of a port\n\n"
886 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
887 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
888 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
889 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
890 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
892 " Enable or disable a per queue Tx offloading"
893 " only on a specific Tx queue\n\n"
895 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
896 " Load an eBPF program as a callback"
897 " for particular RX/TX queue\n\n"
899 "bpf-unload rx|tx (port) (queue)\n"
900 " Unload previously loaded eBPF program"
901 " for particular RX/TX queue\n\n"
903 "port config (port_id) tx_metadata (value)\n"
904 " Set Tx metadata value per port. Testpmd will add this value"
905 " to any Tx packet sent from this port\n\n"
907 "port config (port_id) dynf (name) set|clear\n"
908 " Register a dynf and Set/clear this flag on Tx. "
909 "Testpmd will set this value to any Tx packet "
910 "sent from this port\n\n"
912 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
913 " Cleanup txq mbufs for a specific Tx queue\n\n"
917 if (show_all || !strcmp(res->section, "registers")) {
925 "read reg (port_id) (address)\n"
926 " Display value of a port register.\n\n"
928 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
929 " Display a port register bit field.\n\n"
931 "read regbit (port_id) (address) (bit_x)\n"
932 " Display a single port register bit.\n\n"
934 "write reg (port_id) (address) (value)\n"
935 " Set value of a port register.\n\n"
937 "write regfield (port_id) (address) (bit_x) (bit_y)"
939 " Set bit field of a port register.\n\n"
941 "write regbit (port_id) (address) (bit_x) (value)\n"
942 " Set single bit value of a port register.\n\n"
945 if (show_all || !strcmp(res->section, "filters")) {
954 "flow_director_filter (port_id) mode raw (add|del|update)"
955 " flow (flow_id) (drop|fwd) queue (queue_id)"
956 " fd_id (fd_id_value) packet (packet file name)\n"
957 " Add/Del a raw type flow director filter.\n\n"
960 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
961 " src_mask (ipv4_src) (ipv6_src) (src_port)"
962 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
963 " Set flow director IP mask.\n\n"
965 "flow_director_mask (port_id) mode MAC-VLAN"
966 " vlan (vlan_value)\n"
967 " Set flow director MAC-VLAN mask.\n\n"
969 "flow_director_mask (port_id) mode Tunnel"
970 " vlan (vlan_value) mac (mac_value)"
971 " tunnel-type (tunnel_type_value)"
972 " tunnel-id (tunnel_id_value)\n"
973 " Set flow director Tunnel mask.\n\n"
975 "flow_director_flex_payload (port_id)"
976 " (raw|l2|l3|l4) (config)\n"
977 " Configure flex payload selection.\n\n"
979 "flow validate {port_id}"
980 " [group {group_id}] [priority {level}]"
981 " [ingress] [egress]"
982 " pattern {item} [/ {item} [...]] / end"
983 " actions {action} [/ {action} [...]] / end\n"
984 " Check whether a flow rule can be created.\n\n"
986 "flow create {port_id}"
987 " [group {group_id}] [priority {level}]"
988 " [ingress] [egress]"
989 " pattern {item} [/ {item} [...]] / end"
990 " actions {action} [/ {action} [...]] / end\n"
991 " Create a flow rule.\n\n"
993 "flow destroy {port_id} rule {rule_id} [...]\n"
994 " Destroy specific flow rules.\n\n"
996 "flow flush {port_id}\n"
997 " Destroy all flow rules.\n\n"
999 "flow query {port_id} {rule_id} {action}\n"
1000 " Query an existing flow rule.\n\n"
1002 "flow list {port_id} [group {group_id}] [...]\n"
1003 " List existing flow rules sorted by priority,"
1004 " filtered by group identifiers.\n\n"
1006 "flow isolate {port_id} {boolean}\n"
1007 " Restrict ingress traffic to the defined"
1010 "flow aged {port_id} [destroy]\n"
1011 " List and destroy aged flows"
1014 "flow indirect_action {port_id} create"
1015 " [action_id {indirect_action_id}]"
1016 " [ingress] [egress]"
1017 " action {action} / end\n"
1018 " Create indirect action.\n\n"
1020 "flow indirect_action {port_id} update"
1021 " {indirect_action_id} action {action} / end\n"
1022 " Update indirect action.\n\n"
1024 "flow indirect_action {port_id} destroy"
1025 " action_id {indirect_action_id} [...]\n"
1026 " Destroy specific indirect actions.\n\n"
1028 "flow indirect_action {port_id} query"
1029 " {indirect_action_id}\n"
1030 " Query an existing indirect action.\n\n"
1032 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1033 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1034 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1035 " Configure the VXLAN encapsulation for flows.\n\n"
1037 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1038 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1039 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1040 " eth-dst (eth-dst)\n"
1041 " Configure the VXLAN encapsulation for flows.\n\n"
1043 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1044 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1045 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1046 " eth-dst (eth-dst)\n"
1047 " Configure the VXLAN encapsulation for flows.\n\n"
1049 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1050 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1052 " Configure the NVGRE encapsulation for flows.\n\n"
1054 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1055 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1056 " eth-src (eth-src) eth-dst (eth-dst)\n"
1057 " Configure the NVGRE encapsulation for flows.\n\n"
1059 "set raw_encap {flow items}\n"
1060 " Configure the encapsulation with raw data.\n\n"
1062 "set raw_decap {flow items}\n"
1063 " Configure the decapsulation with raw data.\n\n"
1068 if (show_all || !strcmp(res->section, "traffic_management")) {
1072 "Traffic Management:\n"
1074 "show port tm cap (port_id)\n"
1075 " Display the port TM capability.\n\n"
1077 "show port tm level cap (port_id) (level_id)\n"
1078 " Display the port TM hierarchical level capability.\n\n"
1080 "show port tm node cap (port_id) (node_id)\n"
1081 " Display the port TM node capability.\n\n"
1083 "show port tm node type (port_id) (node_id)\n"
1084 " Display the port TM node type.\n\n"
1086 "show port tm node stats (port_id) (node_id) (clear)\n"
1087 " Display the port TM node stats.\n\n"
1089 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1090 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1091 " (packet_length_adjust) (packet_mode)\n"
1092 " Add port tm node private shaper profile.\n\n"
1094 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1095 " Delete port tm node private shaper profile.\n\n"
1097 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1098 " (shaper_profile_id)\n"
1099 " Add/update port tm node shared shaper.\n\n"
1101 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1102 " Delete port tm node shared shaper.\n\n"
1104 "set port tm node shaper profile (port_id) (node_id)"
1105 " (shaper_profile_id)\n"
1106 " Set port tm node shaper profile.\n\n"
1108 "add port tm node wred profile (port_id) (wred_profile_id)"
1109 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1110 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1111 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1112 " Add port tm node wred profile.\n\n"
1114 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1115 " Delete port tm node wred profile.\n\n"
1117 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1118 " (priority) (weight) (level_id) (shaper_profile_id)"
1119 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1120 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1121 " Add port tm nonleaf node.\n\n"
1123 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1124 " (priority) (weight) (level_id) (shaper_profile_id)"
1125 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1126 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1127 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1129 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1130 " (priority) (weight) (level_id) (shaper_profile_id)"
1131 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1132 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1133 " Add port tm leaf node.\n\n"
1135 "del port tm node (port_id) (node_id)\n"
1136 " Delete port tm node.\n\n"
1138 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1139 " (priority) (weight)\n"
1140 " Set port tm node parent.\n\n"
1142 "suspend port tm node (port_id) (node_id)"
1143 " Suspend tm node.\n\n"
1145 "resume port tm node (port_id) (node_id)"
1146 " Resume tm node.\n\n"
1148 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1149 " Commit tm hierarchy.\n\n"
1151 "set port tm mark ip_ecn (port) (green) (yellow)"
1153 " Enables/Disables the traffic management marking"
1154 " for IP ECN (Explicit Congestion Notification)"
1155 " packets on a given port\n\n"
1157 "set port tm mark ip_dscp (port) (green) (yellow)"
1159 " Enables/Disables the traffic management marking"
1160 " on the port for IP dscp packets\n\n"
1162 "set port tm mark vlan_dei (port) (green) (yellow)"
1164 " Enables/Disables the traffic management marking"
1165 " on the port for VLAN packets with DEI enabled\n\n"
1169 if (show_all || !strcmp(res->section, "devices")) {
1173 "Device Operations:\n"
1175 "device detach (identifier)\n"
1176 " Detach device by identifier.\n\n"
1182 cmdline_parse_token_string_t cmd_help_long_help =
1183 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1185 cmdline_parse_token_string_t cmd_help_long_section =
1186 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1187 "all#control#display#config#"
1188 "ports#registers#filters#traffic_management#devices");
1190 cmdline_parse_inst_t cmd_help_long = {
1191 .f = cmd_help_long_parsed,
1193 .help_str = "help all|control|display|config|ports|register|"
1194 "filters|traffic_management|devices: "
1197 (void *)&cmd_help_long_help,
1198 (void *)&cmd_help_long_section,
1204 /* *** start/stop/close all ports *** */
1205 struct cmd_operate_port_result {
1206 cmdline_fixed_string_t keyword;
1207 cmdline_fixed_string_t name;
1208 cmdline_fixed_string_t value;
1211 static void cmd_operate_port_parsed(void *parsed_result,
1212 __rte_unused struct cmdline *cl,
1213 __rte_unused void *data)
1215 struct cmd_operate_port_result *res = parsed_result;
1217 if (!strcmp(res->name, "start"))
1218 start_port(RTE_PORT_ALL);
1219 else if (!strcmp(res->name, "stop"))
1220 stop_port(RTE_PORT_ALL);
1221 else if (!strcmp(res->name, "close"))
1222 close_port(RTE_PORT_ALL);
1223 else if (!strcmp(res->name, "reset"))
1224 reset_port(RTE_PORT_ALL);
1226 fprintf(stderr, "Unknown parameter\n");
1229 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1230 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1232 cmdline_parse_token_string_t cmd_operate_port_all_port =
1233 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1234 "start#stop#close#reset");
1235 cmdline_parse_token_string_t cmd_operate_port_all_all =
1236 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1238 cmdline_parse_inst_t cmd_operate_port = {
1239 .f = cmd_operate_port_parsed,
1241 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1243 (void *)&cmd_operate_port_all_cmd,
1244 (void *)&cmd_operate_port_all_port,
1245 (void *)&cmd_operate_port_all_all,
1250 /* *** start/stop/close specific port *** */
1251 struct cmd_operate_specific_port_result {
1252 cmdline_fixed_string_t keyword;
1253 cmdline_fixed_string_t name;
1257 static void cmd_operate_specific_port_parsed(void *parsed_result,
1258 __rte_unused struct cmdline *cl,
1259 __rte_unused void *data)
1261 struct cmd_operate_specific_port_result *res = parsed_result;
1263 if (!strcmp(res->name, "start"))
1264 start_port(res->value);
1265 else if (!strcmp(res->name, "stop"))
1266 stop_port(res->value);
1267 else if (!strcmp(res->name, "close"))
1268 close_port(res->value);
1269 else if (!strcmp(res->name, "reset"))
1270 reset_port(res->value);
1272 fprintf(stderr, "Unknown parameter\n");
1275 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1278 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1280 name, "start#stop#close#reset");
1281 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1282 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1285 cmdline_parse_inst_t cmd_operate_specific_port = {
1286 .f = cmd_operate_specific_port_parsed,
1288 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1290 (void *)&cmd_operate_specific_port_cmd,
1291 (void *)&cmd_operate_specific_port_port,
1292 (void *)&cmd_operate_specific_port_id,
1297 /* *** enable port setup (after attach) via iterator or event *** */
1298 struct cmd_set_port_setup_on_result {
1299 cmdline_fixed_string_t set;
1300 cmdline_fixed_string_t port;
1301 cmdline_fixed_string_t setup;
1302 cmdline_fixed_string_t on;
1303 cmdline_fixed_string_t mode;
1306 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1307 __rte_unused struct cmdline *cl,
1308 __rte_unused void *data)
1310 struct cmd_set_port_setup_on_result *res = parsed_result;
1312 if (strcmp(res->mode, "event") == 0)
1313 setup_on_probe_event = true;
1314 else if (strcmp(res->mode, "iterator") == 0)
1315 setup_on_probe_event = false;
1317 fprintf(stderr, "Unknown mode\n");
1320 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1321 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1323 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1324 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1326 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1327 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1329 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1330 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1332 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1333 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1334 mode, "iterator#event");
1336 cmdline_parse_inst_t cmd_set_port_setup_on = {
1337 .f = cmd_set_port_setup_on_parsed,
1339 .help_str = "set port setup on iterator|event",
1341 (void *)&cmd_set_port_setup_on_set,
1342 (void *)&cmd_set_port_setup_on_port,
1343 (void *)&cmd_set_port_setup_on_setup,
1344 (void *)&cmd_set_port_setup_on_on,
1345 (void *)&cmd_set_port_setup_on_mode,
1350 /* *** attach a specified port *** */
1351 struct cmd_operate_attach_port_result {
1352 cmdline_fixed_string_t port;
1353 cmdline_fixed_string_t keyword;
1354 cmdline_multi_string_t identifier;
1357 static void cmd_operate_attach_port_parsed(void *parsed_result,
1358 __rte_unused struct cmdline *cl,
1359 __rte_unused void *data)
1361 struct cmd_operate_attach_port_result *res = parsed_result;
1363 if (!strcmp(res->keyword, "attach"))
1364 attach_port(res->identifier);
1366 fprintf(stderr, "Unknown parameter\n");
1369 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1370 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1372 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1373 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1375 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1376 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1377 identifier, TOKEN_STRING_MULTI);
1379 cmdline_parse_inst_t cmd_operate_attach_port = {
1380 .f = cmd_operate_attach_port_parsed,
1382 .help_str = "port attach <identifier>: "
1383 "(identifier: pci address or virtual dev name)",
1385 (void *)&cmd_operate_attach_port_port,
1386 (void *)&cmd_operate_attach_port_keyword,
1387 (void *)&cmd_operate_attach_port_identifier,
1392 /* *** detach a specified port *** */
1393 struct cmd_operate_detach_port_result {
1394 cmdline_fixed_string_t port;
1395 cmdline_fixed_string_t keyword;
1399 static void cmd_operate_detach_port_parsed(void *parsed_result,
1400 __rte_unused struct cmdline *cl,
1401 __rte_unused void *data)
1403 struct cmd_operate_detach_port_result *res = parsed_result;
1405 if (!strcmp(res->keyword, "detach")) {
1406 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1407 detach_port_device(res->port_id);
1409 fprintf(stderr, "Unknown parameter\n");
1413 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1414 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1416 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1417 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1419 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1420 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1421 port_id, RTE_UINT16);
1423 cmdline_parse_inst_t cmd_operate_detach_port = {
1424 .f = cmd_operate_detach_port_parsed,
1426 .help_str = "port detach <port_id>",
1428 (void *)&cmd_operate_detach_port_port,
1429 (void *)&cmd_operate_detach_port_keyword,
1430 (void *)&cmd_operate_detach_port_port_id,
1435 /* *** detach device by identifier *** */
1436 struct cmd_operate_detach_device_result {
1437 cmdline_fixed_string_t device;
1438 cmdline_fixed_string_t keyword;
1439 cmdline_fixed_string_t identifier;
1442 static void cmd_operate_detach_device_parsed(void *parsed_result,
1443 __rte_unused struct cmdline *cl,
1444 __rte_unused void *data)
1446 struct cmd_operate_detach_device_result *res = parsed_result;
1448 if (!strcmp(res->keyword, "detach"))
1449 detach_devargs(res->identifier);
1451 fprintf(stderr, "Unknown parameter\n");
1454 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1457 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1460 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1461 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1464 cmdline_parse_inst_t cmd_operate_detach_device = {
1465 .f = cmd_operate_detach_device_parsed,
1467 .help_str = "device detach <identifier>:"
1468 "(identifier: pci address or virtual dev name)",
1470 (void *)&cmd_operate_detach_device_device,
1471 (void *)&cmd_operate_detach_device_keyword,
1472 (void *)&cmd_operate_detach_device_identifier,
1476 /* *** configure speed for all ports *** */
1477 struct cmd_config_speed_all {
1478 cmdline_fixed_string_t port;
1479 cmdline_fixed_string_t keyword;
1480 cmdline_fixed_string_t all;
1481 cmdline_fixed_string_t item1;
1482 cmdline_fixed_string_t item2;
1483 cmdline_fixed_string_t value1;
1484 cmdline_fixed_string_t value2;
1488 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1493 if (!strcmp(duplexstr, "half")) {
1494 duplex = RTE_ETH_LINK_HALF_DUPLEX;
1495 } else if (!strcmp(duplexstr, "full")) {
1496 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1497 } else if (!strcmp(duplexstr, "auto")) {
1498 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1500 fprintf(stderr, "Unknown duplex parameter\n");
1504 if (!strcmp(speedstr, "10")) {
1505 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1506 RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1507 } else if (!strcmp(speedstr, "100")) {
1508 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1509 RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1511 if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1512 fprintf(stderr, "Invalid speed/duplex parameters\n");
1515 if (!strcmp(speedstr, "1000")) {
1516 *speed = RTE_ETH_LINK_SPEED_1G;
1517 } else if (!strcmp(speedstr, "10000")) {
1518 *speed = RTE_ETH_LINK_SPEED_10G;
1519 } else if (!strcmp(speedstr, "25000")) {
1520 *speed = RTE_ETH_LINK_SPEED_25G;
1521 } else if (!strcmp(speedstr, "40000")) {
1522 *speed = RTE_ETH_LINK_SPEED_40G;
1523 } else if (!strcmp(speedstr, "50000")) {
1524 *speed = RTE_ETH_LINK_SPEED_50G;
1525 } else if (!strcmp(speedstr, "100000")) {
1526 *speed = RTE_ETH_LINK_SPEED_100G;
1527 } else if (!strcmp(speedstr, "200000")) {
1528 *speed = RTE_ETH_LINK_SPEED_200G;
1529 } else if (!strcmp(speedstr, "auto")) {
1530 *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1532 fprintf(stderr, "Unknown speed parameter\n");
1537 if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1538 *speed |= RTE_ETH_LINK_SPEED_FIXED;
1544 cmd_config_speed_all_parsed(void *parsed_result,
1545 __rte_unused struct cmdline *cl,
1546 __rte_unused void *data)
1548 struct cmd_config_speed_all *res = parsed_result;
1549 uint32_t link_speed;
1552 if (!all_ports_stopped()) {
1553 fprintf(stderr, "Please stop all ports first\n");
1557 if (parse_and_check_speed_duplex(res->value1, res->value2,
1561 RTE_ETH_FOREACH_DEV(pid) {
1562 ports[pid].dev_conf.link_speeds = link_speed;
1565 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1568 cmdline_parse_token_string_t cmd_config_speed_all_port =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1570 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1573 cmdline_parse_token_string_t cmd_config_speed_all_all =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1575 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1576 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1577 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1579 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1580 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1582 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1586 cmdline_parse_inst_t cmd_config_speed_all = {
1587 .f = cmd_config_speed_all_parsed,
1589 .help_str = "port config all speed "
1590 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1593 (void *)&cmd_config_speed_all_port,
1594 (void *)&cmd_config_speed_all_keyword,
1595 (void *)&cmd_config_speed_all_all,
1596 (void *)&cmd_config_speed_all_item1,
1597 (void *)&cmd_config_speed_all_value1,
1598 (void *)&cmd_config_speed_all_item2,
1599 (void *)&cmd_config_speed_all_value2,
1604 /* *** configure speed for specific port *** */
1605 struct cmd_config_speed_specific {
1606 cmdline_fixed_string_t port;
1607 cmdline_fixed_string_t keyword;
1609 cmdline_fixed_string_t item1;
1610 cmdline_fixed_string_t item2;
1611 cmdline_fixed_string_t value1;
1612 cmdline_fixed_string_t value2;
1616 cmd_config_speed_specific_parsed(void *parsed_result,
1617 __rte_unused struct cmdline *cl,
1618 __rte_unused void *data)
1620 struct cmd_config_speed_specific *res = parsed_result;
1621 uint32_t link_speed;
1623 if (port_id_is_invalid(res->id, ENABLED_WARN))
1626 if (!port_is_stopped(res->id)) {
1627 fprintf(stderr, "Please stop port %d first\n", res->id);
1631 if (parse_and_check_speed_duplex(res->value1, res->value2,
1635 ports[res->id].dev_conf.link_speeds = link_speed;
1637 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1641 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1644 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1647 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1648 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1649 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1652 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1654 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1655 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1658 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1662 cmdline_parse_inst_t cmd_config_speed_specific = {
1663 .f = cmd_config_speed_specific_parsed,
1665 .help_str = "port config <port_id> speed "
1666 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1669 (void *)&cmd_config_speed_specific_port,
1670 (void *)&cmd_config_speed_specific_keyword,
1671 (void *)&cmd_config_speed_specific_id,
1672 (void *)&cmd_config_speed_specific_item1,
1673 (void *)&cmd_config_speed_specific_value1,
1674 (void *)&cmd_config_speed_specific_item2,
1675 (void *)&cmd_config_speed_specific_value2,
1680 /* *** configure loopback for all ports *** */
1681 struct cmd_config_loopback_all {
1682 cmdline_fixed_string_t port;
1683 cmdline_fixed_string_t keyword;
1684 cmdline_fixed_string_t all;
1685 cmdline_fixed_string_t item;
1690 cmd_config_loopback_all_parsed(void *parsed_result,
1691 __rte_unused struct cmdline *cl,
1692 __rte_unused void *data)
1694 struct cmd_config_loopback_all *res = parsed_result;
1697 if (!all_ports_stopped()) {
1698 fprintf(stderr, "Please stop all ports first\n");
1702 RTE_ETH_FOREACH_DEV(pid) {
1703 ports[pid].dev_conf.lpbk_mode = res->mode;
1706 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1709 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1711 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1714 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1716 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1719 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1720 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1722 cmdline_parse_inst_t cmd_config_loopback_all = {
1723 .f = cmd_config_loopback_all_parsed,
1725 .help_str = "port config all loopback <mode>",
1727 (void *)&cmd_config_loopback_all_port,
1728 (void *)&cmd_config_loopback_all_keyword,
1729 (void *)&cmd_config_loopback_all_all,
1730 (void *)&cmd_config_loopback_all_item,
1731 (void *)&cmd_config_loopback_all_mode,
1736 /* *** configure loopback for specific port *** */
1737 struct cmd_config_loopback_specific {
1738 cmdline_fixed_string_t port;
1739 cmdline_fixed_string_t keyword;
1741 cmdline_fixed_string_t item;
1746 cmd_config_loopback_specific_parsed(void *parsed_result,
1747 __rte_unused struct cmdline *cl,
1748 __rte_unused void *data)
1750 struct cmd_config_loopback_specific *res = parsed_result;
1752 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1755 if (!port_is_stopped(res->port_id)) {
1756 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1760 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1762 cmd_reconfig_device_queue(res->port_id, 1, 1);
1766 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1767 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1769 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1772 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1773 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1775 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1778 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1779 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1782 cmdline_parse_inst_t cmd_config_loopback_specific = {
1783 .f = cmd_config_loopback_specific_parsed,
1785 .help_str = "port config <port_id> loopback <mode>",
1787 (void *)&cmd_config_loopback_specific_port,
1788 (void *)&cmd_config_loopback_specific_keyword,
1789 (void *)&cmd_config_loopback_specific_id,
1790 (void *)&cmd_config_loopback_specific_item,
1791 (void *)&cmd_config_loopback_specific_mode,
1796 /* *** configure txq/rxq, txd/rxd *** */
1797 struct cmd_config_rx_tx {
1798 cmdline_fixed_string_t port;
1799 cmdline_fixed_string_t keyword;
1800 cmdline_fixed_string_t all;
1801 cmdline_fixed_string_t name;
1806 cmd_config_rx_tx_parsed(void *parsed_result,
1807 __rte_unused struct cmdline *cl,
1808 __rte_unused void *data)
1810 struct cmd_config_rx_tx *res = parsed_result;
1812 if (!all_ports_stopped()) {
1813 fprintf(stderr, "Please stop all ports first\n");
1816 if (!strcmp(res->name, "rxq")) {
1817 if (!res->value && !nb_txq) {
1818 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1821 if (check_nb_rxq(res->value) != 0)
1823 nb_rxq = res->value;
1825 else if (!strcmp(res->name, "txq")) {
1826 if (!res->value && !nb_rxq) {
1827 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1830 if (check_nb_txq(res->value) != 0)
1832 nb_txq = res->value;
1834 else if (!strcmp(res->name, "rxd")) {
1835 if (check_nb_rxd(res->value) != 0)
1837 nb_rxd = res->value;
1838 } else if (!strcmp(res->name, "txd")) {
1839 if (check_nb_txd(res->value) != 0)
1842 nb_txd = res->value;
1844 fprintf(stderr, "Unknown parameter\n");
1852 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1855 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1856 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1857 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1859 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1861 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1864 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1865 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1867 cmdline_parse_inst_t cmd_config_rx_tx = {
1868 .f = cmd_config_rx_tx_parsed,
1870 .help_str = "port config all rxq|txq|rxd|txd <value>",
1872 (void *)&cmd_config_rx_tx_port,
1873 (void *)&cmd_config_rx_tx_keyword,
1874 (void *)&cmd_config_rx_tx_all,
1875 (void *)&cmd_config_rx_tx_name,
1876 (void *)&cmd_config_rx_tx_value,
1881 /* *** config max packet length *** */
1882 struct cmd_config_max_pkt_len_result {
1883 cmdline_fixed_string_t port;
1884 cmdline_fixed_string_t keyword;
1885 cmdline_fixed_string_t all;
1886 cmdline_fixed_string_t name;
1891 cmd_config_max_pkt_len_parsed(void *parsed_result,
1892 __rte_unused struct cmdline *cl,
1893 __rte_unused void *data)
1895 struct cmd_config_max_pkt_len_result *res = parsed_result;
1899 if (strcmp(res->name, "max-pkt-len") != 0) {
1900 printf("Unknown parameter\n");
1904 if (!all_ports_stopped()) {
1905 fprintf(stderr, "Please stop all ports first\n");
1909 RTE_ETH_FOREACH_DEV(port_id) {
1910 struct rte_port *port = &ports[port_id];
1912 if (res->value < RTE_ETHER_MIN_LEN) {
1914 "max-pkt-len can not be less than %d\n",
1919 ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1922 "rte_eth_dev_info_get() failed for port %u\n",
1927 update_mtu_from_frame_size(port_id, res->value);
1932 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1935 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1938 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1941 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1944 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1947 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1948 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1951 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1952 .f = cmd_config_max_pkt_len_parsed,
1954 .help_str = "port config all max-pkt-len <value>",
1956 (void *)&cmd_config_max_pkt_len_port,
1957 (void *)&cmd_config_max_pkt_len_keyword,
1958 (void *)&cmd_config_max_pkt_len_all,
1959 (void *)&cmd_config_max_pkt_len_name,
1960 (void *)&cmd_config_max_pkt_len_value,
1965 /* *** config max LRO aggregated packet size *** */
1966 struct cmd_config_max_lro_pkt_size_result {
1967 cmdline_fixed_string_t port;
1968 cmdline_fixed_string_t keyword;
1969 cmdline_fixed_string_t all;
1970 cmdline_fixed_string_t name;
1975 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1976 __rte_unused struct cmdline *cl,
1977 __rte_unused void *data)
1979 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1982 if (!all_ports_stopped()) {
1983 fprintf(stderr, "Please stop all ports first\n");
1987 RTE_ETH_FOREACH_DEV(pid) {
1988 struct rte_port *port = &ports[pid];
1990 if (!strcmp(res->name, "max-lro-pkt-size")) {
1992 port->dev_conf.rxmode.max_lro_pkt_size)
1995 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1997 fprintf(stderr, "Unknown parameter\n");
2004 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2007 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2010 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2011 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2013 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2016 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2018 name, "max-lro-pkt-size");
2019 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2020 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2023 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2024 .f = cmd_config_max_lro_pkt_size_parsed,
2026 .help_str = "port config all max-lro-pkt-size <value>",
2028 (void *)&cmd_config_max_lro_pkt_size_port,
2029 (void *)&cmd_config_max_lro_pkt_size_keyword,
2030 (void *)&cmd_config_max_lro_pkt_size_all,
2031 (void *)&cmd_config_max_lro_pkt_size_name,
2032 (void *)&cmd_config_max_lro_pkt_size_value,
2037 /* *** configure port MTU *** */
2038 struct cmd_config_mtu_result {
2039 cmdline_fixed_string_t port;
2040 cmdline_fixed_string_t keyword;
2041 cmdline_fixed_string_t mtu;
2047 cmd_config_mtu_parsed(void *parsed_result,
2048 __rte_unused struct cmdline *cl,
2049 __rte_unused void *data)
2051 struct cmd_config_mtu_result *res = parsed_result;
2053 port_mtu_set(res->port_id, res->value);
2056 cmdline_parse_token_string_t cmd_config_mtu_port =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2059 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2060 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2062 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2063 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2065 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2066 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2068 cmdline_parse_token_num_t cmd_config_mtu_value =
2069 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2072 cmdline_parse_inst_t cmd_config_mtu = {
2073 .f = cmd_config_mtu_parsed,
2075 .help_str = "port config mtu <port_id> <value>",
2077 (void *)&cmd_config_mtu_port,
2078 (void *)&cmd_config_mtu_keyword,
2079 (void *)&cmd_config_mtu_mtu,
2080 (void *)&cmd_config_mtu_port_id,
2081 (void *)&cmd_config_mtu_value,
2086 /* *** configure rx mode *** */
2087 struct cmd_config_rx_mode_flag {
2088 cmdline_fixed_string_t port;
2089 cmdline_fixed_string_t keyword;
2090 cmdline_fixed_string_t all;
2091 cmdline_fixed_string_t name;
2092 cmdline_fixed_string_t value;
2096 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2097 __rte_unused struct cmdline *cl,
2098 __rte_unused void *data)
2100 struct cmd_config_rx_mode_flag *res = parsed_result;
2102 if (!all_ports_stopped()) {
2103 fprintf(stderr, "Please stop all ports first\n");
2107 if (!strcmp(res->name, "drop-en")) {
2108 if (!strcmp(res->value, "on"))
2110 else if (!strcmp(res->value, "off"))
2113 fprintf(stderr, "Unknown parameter\n");
2117 fprintf(stderr, "Unknown parameter\n");
2123 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2126 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2127 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2128 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2129 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2131 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2133 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2134 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2140 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2141 .f = cmd_config_rx_mode_flag_parsed,
2143 .help_str = "port config all drop-en on|off",
2145 (void *)&cmd_config_rx_mode_flag_port,
2146 (void *)&cmd_config_rx_mode_flag_keyword,
2147 (void *)&cmd_config_rx_mode_flag_all,
2148 (void *)&cmd_config_rx_mode_flag_name,
2149 (void *)&cmd_config_rx_mode_flag_value,
2154 /* *** configure rss *** */
2155 struct cmd_config_rss {
2156 cmdline_fixed_string_t port;
2157 cmdline_fixed_string_t keyword;
2158 cmdline_fixed_string_t all;
2159 cmdline_fixed_string_t name;
2160 cmdline_fixed_string_t value;
2164 cmd_config_rss_parsed(void *parsed_result,
2165 __rte_unused struct cmdline *cl,
2166 __rte_unused void *data)
2168 struct cmd_config_rss *res = parsed_result;
2169 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2170 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2171 int use_default = 0;
2172 int all_updated = 1;
2177 if (!strcmp(res->value, "all"))
2178 rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2179 RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2180 RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2181 RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2182 RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_L2TPV2;
2183 else if (!strcmp(res->value, "eth"))
2184 rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2185 else if (!strcmp(res->value, "vlan"))
2186 rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2187 else if (!strcmp(res->value, "ip"))
2188 rss_conf.rss_hf = RTE_ETH_RSS_IP;
2189 else if (!strcmp(res->value, "udp"))
2190 rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2191 else if (!strcmp(res->value, "tcp"))
2192 rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2193 else if (!strcmp(res->value, "sctp"))
2194 rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2195 else if (!strcmp(res->value, "ether"))
2196 rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2197 else if (!strcmp(res->value, "port"))
2198 rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2199 else if (!strcmp(res->value, "vxlan"))
2200 rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2201 else if (!strcmp(res->value, "geneve"))
2202 rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2203 else if (!strcmp(res->value, "nvgre"))
2204 rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2205 else if (!strcmp(res->value, "l3-pre32"))
2206 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2207 else if (!strcmp(res->value, "l3-pre40"))
2208 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2209 else if (!strcmp(res->value, "l3-pre48"))
2210 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2211 else if (!strcmp(res->value, "l3-pre56"))
2212 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2213 else if (!strcmp(res->value, "l3-pre64"))
2214 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2215 else if (!strcmp(res->value, "l3-pre96"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2217 else if (!strcmp(res->value, "l3-src-only"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2219 else if (!strcmp(res->value, "l3-dst-only"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2221 else if (!strcmp(res->value, "l4-src-only"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2223 else if (!strcmp(res->value, "l4-dst-only"))
2224 rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2225 else if (!strcmp(res->value, "l2-src-only"))
2226 rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2227 else if (!strcmp(res->value, "l2-dst-only"))
2228 rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2229 else if (!strcmp(res->value, "l2tpv3"))
2230 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2231 else if (!strcmp(res->value, "esp"))
2232 rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2233 else if (!strcmp(res->value, "ah"))
2234 rss_conf.rss_hf = RTE_ETH_RSS_AH;
2235 else if (!strcmp(res->value, "pfcp"))
2236 rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2237 else if (!strcmp(res->value, "pppoe"))
2238 rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2239 else if (!strcmp(res->value, "gtpu"))
2240 rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2241 else if (!strcmp(res->value, "ecpri"))
2242 rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2243 else if (!strcmp(res->value, "mpls"))
2244 rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2245 else if (!strcmp(res->value, "ipv4-chksum"))
2246 rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2247 else if (!strcmp(res->value, "l2tpv2"))
2248 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV2;
2249 else if (!strcmp(res->value, "none"))
2250 rss_conf.rss_hf = 0;
2251 else if (!strcmp(res->value, "level-default")) {
2252 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2253 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2254 } else if (!strcmp(res->value, "level-outer")) {
2255 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2256 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2257 } else if (!strcmp(res->value, "level-inner")) {
2258 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2259 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2260 } else if (!strcmp(res->value, "default"))
2262 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2263 atoi(res->value) < 64)
2264 rss_conf.rss_hf = 1ULL << atoi(res->value);
2266 fprintf(stderr, "Unknown parameter\n");
2269 rss_conf.rss_key = NULL;
2270 /* Update global configuration for RSS types. */
2271 RTE_ETH_FOREACH_DEV(i) {
2272 struct rte_eth_rss_conf local_rss_conf;
2274 ret = eth_dev_info_get_print_err(i, &dev_info);
2279 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2281 local_rss_conf = rss_conf;
2282 local_rss_conf.rss_hf = rss_conf.rss_hf &
2283 dev_info.flow_type_rss_offloads;
2284 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2285 printf("Port %u modified RSS hash function based on hardware support,"
2286 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2287 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2289 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2293 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2294 i, -diag, strerror(-diag));
2297 if (all_updated && !use_default) {
2298 rss_hf = rss_conf.rss_hf;
2299 printf("rss_hf %#"PRIx64"\n", rss_hf);
2303 cmdline_parse_token_string_t cmd_config_rss_port =
2304 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2305 cmdline_parse_token_string_t cmd_config_rss_keyword =
2306 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2307 cmdline_parse_token_string_t cmd_config_rss_all =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2309 cmdline_parse_token_string_t cmd_config_rss_name =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2311 cmdline_parse_token_string_t cmd_config_rss_value =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2314 cmdline_parse_inst_t cmd_config_rss = {
2315 .f = cmd_config_rss_parsed,
2317 .help_str = "port config all rss "
2318 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2319 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|l2tpv2|"
2320 "none|level-default|level-outer|level-inner|<flowtype_id>",
2322 (void *)&cmd_config_rss_port,
2323 (void *)&cmd_config_rss_keyword,
2324 (void *)&cmd_config_rss_all,
2325 (void *)&cmd_config_rss_name,
2326 (void *)&cmd_config_rss_value,
2331 /* *** configure rss hash key *** */
2332 struct cmd_config_rss_hash_key {
2333 cmdline_fixed_string_t port;
2334 cmdline_fixed_string_t config;
2336 cmdline_fixed_string_t rss_hash_key;
2337 cmdline_fixed_string_t rss_type;
2338 cmdline_fixed_string_t key;
2342 hexa_digit_to_value(char hexa_digit)
2344 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2345 return (uint8_t) (hexa_digit - '0');
2346 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2347 return (uint8_t) ((hexa_digit - 'a') + 10);
2348 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2349 return (uint8_t) ((hexa_digit - 'A') + 10);
2350 /* Invalid hexa digit */
2355 parse_and_check_key_hexa_digit(char *key, int idx)
2359 hexa_v = hexa_digit_to_value(key[idx]);
2362 "invalid key: character %c at position %d is not a valid hexa digit\n",
2368 cmd_config_rss_hash_key_parsed(void *parsed_result,
2369 __rte_unused struct cmdline *cl,
2370 __rte_unused void *data)
2372 struct cmd_config_rss_hash_key *res = parsed_result;
2373 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2377 struct rte_eth_dev_info dev_info;
2378 uint8_t hash_key_size;
2382 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2386 if (dev_info.hash_key_size > 0 &&
2387 dev_info.hash_key_size <= sizeof(hash_key))
2388 hash_key_size = dev_info.hash_key_size;
2391 "dev_info did not provide a valid hash key size\n");
2394 /* Check the length of the RSS hash key */
2395 key_len = strlen(res->key);
2396 if (key_len != (hash_key_size * 2)) {
2398 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2399 (int)key_len, hash_key_size * 2);
2402 /* Translate RSS hash key into binary representation */
2403 for (i = 0; i < hash_key_size; i++) {
2404 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2407 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2410 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2412 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2416 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2417 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2418 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2421 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2422 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2425 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2426 rss_hash_key, "rss-hash-key");
2427 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2428 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2429 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2430 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2431 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2432 "ipv6-tcp-ex#ipv6-udp-ex#"
2433 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2434 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2435 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2436 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2437 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2439 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2440 .f = cmd_config_rss_hash_key_parsed,
2442 .help_str = "port config <port_id> rss-hash-key "
2443 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2444 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2445 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2446 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2447 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2448 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2449 "<string of hex digits (variable length, NIC dependent)>",
2451 (void *)&cmd_config_rss_hash_key_port,
2452 (void *)&cmd_config_rss_hash_key_config,
2453 (void *)&cmd_config_rss_hash_key_port_id,
2454 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2455 (void *)&cmd_config_rss_hash_key_rss_type,
2456 (void *)&cmd_config_rss_hash_key_value,
2461 /* *** cleanup txq mbufs *** */
2462 struct cmd_cleanup_txq_mbufs_result {
2463 cmdline_fixed_string_t port;
2464 cmdline_fixed_string_t keyword;
2465 cmdline_fixed_string_t name;
2472 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2473 __rte_unused struct cmdline *cl,
2474 __rte_unused void *data)
2476 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2477 uint16_t port_id = res->port_id;
2478 uint16_t queue_id = res->queue_id;
2479 uint32_t free_cnt = res->free_cnt;
2480 struct rte_eth_txq_info qinfo;
2483 if (test_done == 0) {
2484 fprintf(stderr, "Please stop forwarding first\n");
2488 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2489 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2494 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2495 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2499 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2502 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2503 port_id, queue_id, strerror(-ret), ret);
2507 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2508 port_id, queue_id, ret);
2511 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2512 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2514 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2515 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2517 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2518 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2520 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2521 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2523 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2524 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2526 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2527 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2530 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2531 .f = cmd_cleanup_txq_mbufs_parsed,
2533 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2535 (void *)&cmd_cleanup_txq_mbufs_port,
2536 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2537 (void *)&cmd_cleanup_txq_mbufs_port_id,
2538 (void *)&cmd_cleanup_txq_mbufs_txq,
2539 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2540 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2545 /* *** configure port rxq/txq ring size *** */
2546 struct cmd_config_rxtx_ring_size {
2547 cmdline_fixed_string_t port;
2548 cmdline_fixed_string_t config;
2550 cmdline_fixed_string_t rxtxq;
2552 cmdline_fixed_string_t rsize;
2557 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2558 __rte_unused struct cmdline *cl,
2559 __rte_unused void *data)
2561 struct cmd_config_rxtx_ring_size *res = parsed_result;
2562 struct rte_port *port;
2565 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2568 if (res->portid == (portid_t)RTE_PORT_ALL) {
2569 fprintf(stderr, "Invalid port id\n");
2573 port = &ports[res->portid];
2575 if (!strcmp(res->rxtxq, "rxq"))
2577 else if (!strcmp(res->rxtxq, "txq"))
2580 fprintf(stderr, "Unknown parameter\n");
2584 if (isrx && rx_queue_id_is_invalid(res->qid))
2586 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2589 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2591 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2597 port->nb_rx_desc[res->qid] = res->size;
2599 port->nb_tx_desc[res->qid] = res->size;
2601 cmd_reconfig_device_queue(res->portid, 0, 1);
2604 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2605 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2607 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2608 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2611 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2612 portid, RTE_UINT16);
2613 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2614 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2616 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2617 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2619 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2621 rsize, "ring_size");
2622 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2623 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2626 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2627 .f = cmd_config_rxtx_ring_size_parsed,
2629 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2631 (void *)&cmd_config_rxtx_ring_size_port,
2632 (void *)&cmd_config_rxtx_ring_size_config,
2633 (void *)&cmd_config_rxtx_ring_size_portid,
2634 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2635 (void *)&cmd_config_rxtx_ring_size_qid,
2636 (void *)&cmd_config_rxtx_ring_size_rsize,
2637 (void *)&cmd_config_rxtx_ring_size_size,
2642 /* *** configure port rxq/txq start/stop *** */
2643 struct cmd_config_rxtx_queue {
2644 cmdline_fixed_string_t port;
2646 cmdline_fixed_string_t rxtxq;
2648 cmdline_fixed_string_t opname;
2652 cmd_config_rxtx_queue_parsed(void *parsed_result,
2653 __rte_unused struct cmdline *cl,
2654 __rte_unused void *data)
2656 struct cmd_config_rxtx_queue *res = parsed_result;
2661 if (test_done == 0) {
2662 fprintf(stderr, "Please stop forwarding first\n");
2666 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2669 if (port_is_started(res->portid) != 1) {
2670 fprintf(stderr, "Please start port %u first\n", res->portid);
2674 if (!strcmp(res->rxtxq, "rxq"))
2676 else if (!strcmp(res->rxtxq, "txq"))
2679 fprintf(stderr, "Unknown parameter\n");
2683 if (isrx && rx_queue_id_is_invalid(res->qid))
2685 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2688 if (!strcmp(res->opname, "start"))
2690 else if (!strcmp(res->opname, "stop"))
2693 fprintf(stderr, "Unknown parameter\n");
2697 if (isstart && isrx)
2698 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2699 else if (!isstart && isrx)
2700 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2701 else if (isstart && !isrx)
2702 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2704 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2706 if (ret == -ENOTSUP)
2707 fprintf(stderr, "Function not supported in PMD\n");
2710 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2711 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2712 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2713 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2714 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2715 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2716 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2717 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2718 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2719 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2722 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2723 .f = cmd_config_rxtx_queue_parsed,
2725 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2727 (void *)&cmd_config_rxtx_queue_port,
2728 (void *)&cmd_config_rxtx_queue_portid,
2729 (void *)&cmd_config_rxtx_queue_rxtxq,
2730 (void *)&cmd_config_rxtx_queue_qid,
2731 (void *)&cmd_config_rxtx_queue_opname,
2736 /* *** configure port rxq/txq deferred start on/off *** */
2737 struct cmd_config_deferred_start_rxtx_queue {
2738 cmdline_fixed_string_t port;
2740 cmdline_fixed_string_t rxtxq;
2742 cmdline_fixed_string_t opname;
2743 cmdline_fixed_string_t state;
2747 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2748 __rte_unused struct cmdline *cl,
2749 __rte_unused void *data)
2751 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2752 struct rte_port *port;
2755 uint8_t needreconfig = 0;
2757 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2760 if (port_is_started(res->port_id) != 0) {
2761 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2765 port = &ports[res->port_id];
2767 isrx = !strcmp(res->rxtxq, "rxq");
2769 if (isrx && rx_queue_id_is_invalid(res->qid))
2771 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2774 ison = !strcmp(res->state, "on");
2776 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2777 port->rx_conf[res->qid].rx_deferred_start = ison;
2779 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2780 port->tx_conf[res->qid].tx_deferred_start = ison;
2785 cmd_reconfig_device_queue(res->port_id, 0, 1);
2788 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2789 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2791 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2792 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2793 port_id, RTE_UINT16);
2794 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2795 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2797 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2798 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2800 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2801 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2802 opname, "deferred_start");
2803 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2804 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2807 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2808 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2810 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2812 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2813 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2814 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2815 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2816 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2817 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2822 /* *** configure port rxq/txq setup *** */
2823 struct cmd_setup_rxtx_queue {
2824 cmdline_fixed_string_t port;
2826 cmdline_fixed_string_t rxtxq;
2828 cmdline_fixed_string_t setup;
2831 /* Common CLI fields for queue setup */
2832 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2833 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2834 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2835 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2836 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2837 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2838 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2839 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2840 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2841 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2844 cmd_setup_rxtx_queue_parsed(
2845 void *parsed_result,
2846 __rte_unused struct cmdline *cl,
2847 __rte_unused void *data)
2849 struct cmd_setup_rxtx_queue *res = parsed_result;
2850 struct rte_port *port;
2851 struct rte_mempool *mp;
2852 unsigned int socket_id;
2856 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2859 if (res->portid == (portid_t)RTE_PORT_ALL) {
2860 fprintf(stderr, "Invalid port id\n");
2864 if (!strcmp(res->rxtxq, "rxq"))
2866 else if (!strcmp(res->rxtxq, "txq"))
2869 fprintf(stderr, "Unknown parameter\n");
2873 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2874 fprintf(stderr, "Invalid rx queue\n");
2876 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2877 fprintf(stderr, "Invalid tx queue\n");
2881 port = &ports[res->portid];
2883 socket_id = rxring_numa[res->portid];
2884 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2885 socket_id = port->socket_id;
2887 mp = mbuf_pool_find(socket_id, 0);
2890 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2891 rxring_numa[res->portid]);
2894 ret = rx_queue_setup(res->portid,
2896 port->nb_rx_desc[res->qid],
2898 &port->rx_conf[res->qid],
2901 fprintf(stderr, "Failed to setup RX queue\n");
2903 socket_id = txring_numa[res->portid];
2904 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2905 socket_id = port->socket_id;
2907 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2909 "Failed to setup TX queue: not enough descriptors\n");
2912 ret = rte_eth_tx_queue_setup(res->portid,
2914 port->nb_tx_desc[res->qid],
2916 &port->tx_conf[res->qid]);
2918 fprintf(stderr, "Failed to setup TX queue\n");
2922 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2923 .f = cmd_setup_rxtx_queue_parsed,
2925 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2927 (void *)&cmd_setup_rxtx_queue_port,
2928 (void *)&cmd_setup_rxtx_queue_portid,
2929 (void *)&cmd_setup_rxtx_queue_rxtxq,
2930 (void *)&cmd_setup_rxtx_queue_qid,
2931 (void *)&cmd_setup_rxtx_queue_setup,
2937 /* *** Configure RSS RETA *** */
2938 struct cmd_config_rss_reta {
2939 cmdline_fixed_string_t port;
2940 cmdline_fixed_string_t keyword;
2942 cmdline_fixed_string_t name;
2943 cmdline_fixed_string_t list_name;
2944 cmdline_fixed_string_t list_of_items;
2948 parse_reta_config(const char *str,
2949 struct rte_eth_rss_reta_entry64 *reta_conf,
2950 uint16_t nb_entries)
2954 uint16_t hash_index, idx, shift;
2957 const char *p, *p0 = str;
2964 unsigned long int_fld[_NUM_FLD];
2965 char *str_fld[_NUM_FLD];
2967 while ((p = strchr(p0,'(')) != NULL) {
2969 if((p0 = strchr(p,')')) == NULL)
2973 if(size >= sizeof(s))
2976 snprintf(s, sizeof(s), "%.*s", size, p);
2977 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2979 for (i = 0; i < _NUM_FLD; i++) {
2981 int_fld[i] = strtoul(str_fld[i], &end, 0);
2982 if (errno != 0 || end == str_fld[i] ||
2987 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2988 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2990 if (hash_index >= nb_entries) {
2991 fprintf(stderr, "Invalid RETA hash index=%d\n",
2996 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
2997 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
2998 reta_conf[idx].mask |= (1ULL << shift);
2999 reta_conf[idx].reta[shift] = nb_queue;
3006 cmd_set_rss_reta_parsed(void *parsed_result,
3007 __rte_unused struct cmdline *cl,
3008 __rte_unused void *data)
3011 struct rte_eth_dev_info dev_info;
3012 struct rte_eth_rss_reta_entry64 reta_conf[8];
3013 struct cmd_config_rss_reta *res = parsed_result;
3015 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3019 if (dev_info.reta_size == 0) {
3021 "Redirection table size is 0 which is invalid for RSS\n");
3024 printf("The reta size of port %d is %u\n",
3025 res->port_id, dev_info.reta_size);
3026 if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3028 "Currently do not support more than %u entries of redirection table\n",
3029 RTE_ETH_RSS_RETA_SIZE_512);
3033 memset(reta_conf, 0, sizeof(reta_conf));
3034 if (!strcmp(res->list_name, "reta")) {
3035 if (parse_reta_config(res->list_of_items, reta_conf,
3036 dev_info.reta_size)) {
3038 "Invalid RSS Redirection Table config entered\n");
3041 ret = rte_eth_dev_rss_reta_update(res->port_id,
3042 reta_conf, dev_info.reta_size);
3045 "Bad redirection table parameter, return code = %d\n",
3050 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3051 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3052 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3054 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3055 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3056 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3058 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3060 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3063 cmdline_parse_inst_t cmd_config_rss_reta = {
3064 .f = cmd_set_rss_reta_parsed,
3066 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3068 (void *)&cmd_config_rss_reta_port,
3069 (void *)&cmd_config_rss_reta_keyword,
3070 (void *)&cmd_config_rss_reta_port_id,
3071 (void *)&cmd_config_rss_reta_name,
3072 (void *)&cmd_config_rss_reta_list_name,
3073 (void *)&cmd_config_rss_reta_list_of_items,
3078 /* *** SHOW PORT RETA INFO *** */
3079 struct cmd_showport_reta {
3080 cmdline_fixed_string_t show;
3081 cmdline_fixed_string_t port;
3083 cmdline_fixed_string_t rss;
3084 cmdline_fixed_string_t reta;
3086 cmdline_fixed_string_t list_of_items;
3090 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3091 uint16_t nb_entries,
3095 const char *p, *p0 = str;
3100 uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3101 RTE_ETH_RETA_GROUP_SIZE;
3104 p = strchr(p0, '(');
3108 p0 = strchr(p, ')');
3112 if (size >= sizeof(s)) {
3114 "The string size exceeds the internal buffer size\n");
3117 snprintf(s, sizeof(s), "%.*s", size, p);
3118 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3119 if (ret <= 0 || ret != num) {
3121 "The bits of masks do not match the number of reta entries: %u\n",
3125 for (i = 0; i < ret; i++)
3126 conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3132 cmd_showport_reta_parsed(void *parsed_result,
3133 __rte_unused struct cmdline *cl,
3134 __rte_unused void *data)
3136 struct cmd_showport_reta *res = parsed_result;
3137 struct rte_eth_rss_reta_entry64 reta_conf[8];
3138 struct rte_eth_dev_info dev_info;
3139 uint16_t max_reta_size;
3142 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3146 max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3147 if (res->size == 0 || res->size > max_reta_size) {
3148 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3149 res->size, max_reta_size);
3153 memset(reta_conf, 0, sizeof(reta_conf));
3154 if (showport_parse_reta_config(reta_conf, res->size,
3155 res->list_of_items) < 0) {
3156 fprintf(stderr, "Invalid string: %s for reta masks\n",
3157 res->list_of_items);
3160 port_rss_reta_info(res->port_id, reta_conf, res->size);
3163 cmdline_parse_token_string_t cmd_showport_reta_show =
3164 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3165 cmdline_parse_token_string_t cmd_showport_reta_port =
3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3167 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3168 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3169 cmdline_parse_token_string_t cmd_showport_reta_rss =
3170 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3171 cmdline_parse_token_string_t cmd_showport_reta_reta =
3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3173 cmdline_parse_token_num_t cmd_showport_reta_size =
3174 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3175 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3176 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3177 list_of_items, NULL);
3179 cmdline_parse_inst_t cmd_showport_reta = {
3180 .f = cmd_showport_reta_parsed,
3182 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3184 (void *)&cmd_showport_reta_show,
3185 (void *)&cmd_showport_reta_port,
3186 (void *)&cmd_showport_reta_port_id,
3187 (void *)&cmd_showport_reta_rss,
3188 (void *)&cmd_showport_reta_reta,
3189 (void *)&cmd_showport_reta_size,
3190 (void *)&cmd_showport_reta_list_of_items,
3195 /* *** Show RSS hash configuration *** */
3196 struct cmd_showport_rss_hash {
3197 cmdline_fixed_string_t show;
3198 cmdline_fixed_string_t port;
3200 cmdline_fixed_string_t rss_hash;
3201 cmdline_fixed_string_t rss_type;
3202 cmdline_fixed_string_t key; /* optional argument */
3205 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3206 __rte_unused struct cmdline *cl,
3209 struct cmd_showport_rss_hash *res = parsed_result;
3211 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3214 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3215 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3216 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3217 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3218 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3219 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3221 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3222 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3224 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3225 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3227 cmdline_parse_inst_t cmd_showport_rss_hash = {
3228 .f = cmd_showport_rss_hash_parsed,
3230 .help_str = "show port <port_id> rss-hash",
3232 (void *)&cmd_showport_rss_hash_show,
3233 (void *)&cmd_showport_rss_hash_port,
3234 (void *)&cmd_showport_rss_hash_port_id,
3235 (void *)&cmd_showport_rss_hash_rss_hash,
3240 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3241 .f = cmd_showport_rss_hash_parsed,
3243 .help_str = "show port <port_id> rss-hash key",
3245 (void *)&cmd_showport_rss_hash_show,
3246 (void *)&cmd_showport_rss_hash_port,
3247 (void *)&cmd_showport_rss_hash_port_id,
3248 (void *)&cmd_showport_rss_hash_rss_hash,
3249 (void *)&cmd_showport_rss_hash_rss_key,
3254 /* *** Configure DCB *** */
3255 struct cmd_config_dcb {
3256 cmdline_fixed_string_t port;
3257 cmdline_fixed_string_t config;
3259 cmdline_fixed_string_t dcb;
3260 cmdline_fixed_string_t vt;
3261 cmdline_fixed_string_t vt_en;
3263 cmdline_fixed_string_t pfc;
3264 cmdline_fixed_string_t pfc_en;
3268 cmd_config_dcb_parsed(void *parsed_result,
3269 __rte_unused struct cmdline *cl,
3270 __rte_unused void *data)
3272 struct cmd_config_dcb *res = parsed_result;
3273 struct rte_eth_dcb_info dcb_info;
3274 portid_t port_id = res->port_id;
3275 struct rte_port *port;
3279 port = &ports[port_id];
3280 /** Check if the port is not started **/
3281 if (port->port_status != RTE_PORT_STOPPED) {
3282 fprintf(stderr, "Please stop port %d first\n", port_id);
3286 if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3288 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3292 if (nb_fwd_lcores < res->num_tcs) {
3294 "nb_cores shouldn't be less than number of TCs.\n");
3298 /* Check whether the port supports the report of DCB info. */
3299 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3300 if (ret == -ENOTSUP) {
3301 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3305 if (!strncmp(res->pfc_en, "on", 2))
3310 /* DCB in VT mode */
3311 if (!strncmp(res->vt_en, "on", 2))
3312 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3313 (enum rte_eth_nb_tcs)res->num_tcs,
3316 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3317 (enum rte_eth_nb_tcs)res->num_tcs,
3320 fprintf(stderr, "Cannot initialize network ports.\n");
3326 cmd_reconfig_device_queue(port_id, 1, 1);
3329 cmdline_parse_token_string_t cmd_config_dcb_port =
3330 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3331 cmdline_parse_token_string_t cmd_config_dcb_config =
3332 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3333 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3334 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3335 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3336 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3337 cmdline_parse_token_string_t cmd_config_dcb_vt =
3338 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3339 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3340 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3341 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3342 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3343 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3344 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3345 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3346 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3348 cmdline_parse_inst_t cmd_config_dcb = {
3349 .f = cmd_config_dcb_parsed,
3351 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3353 (void *)&cmd_config_dcb_port,
3354 (void *)&cmd_config_dcb_config,
3355 (void *)&cmd_config_dcb_port_id,
3356 (void *)&cmd_config_dcb_dcb,
3357 (void *)&cmd_config_dcb_vt,
3358 (void *)&cmd_config_dcb_vt_en,
3359 (void *)&cmd_config_dcb_num_tcs,
3360 (void *)&cmd_config_dcb_pfc,
3361 (void *)&cmd_config_dcb_pfc_en,
3366 /* *** configure number of packets per burst *** */
3367 struct cmd_config_burst {
3368 cmdline_fixed_string_t port;
3369 cmdline_fixed_string_t keyword;
3370 cmdline_fixed_string_t all;
3371 cmdline_fixed_string_t name;
3376 cmd_config_burst_parsed(void *parsed_result,
3377 __rte_unused struct cmdline *cl,
3378 __rte_unused void *data)
3380 struct cmd_config_burst *res = parsed_result;
3381 struct rte_eth_dev_info dev_info;
3382 uint16_t rec_nb_pkts;
3385 if (!all_ports_stopped()) {
3386 fprintf(stderr, "Please stop all ports first\n");
3390 if (!strcmp(res->name, "burst")) {
3391 if (res->value == 0) {
3392 /* If user gives a value of zero, query the PMD for
3393 * its recommended Rx burst size. Testpmd uses a single
3394 * size for all ports, so assume all ports are the same
3395 * NIC model and use the values from Port 0.
3397 ret = eth_dev_info_get_print_err(0, &dev_info);
3401 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3403 if (rec_nb_pkts == 0) {
3404 printf("PMD does not recommend a burst size.\n"
3405 "User provided value must be between"
3406 " 1 and %d\n", MAX_PKT_BURST);
3408 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3409 printf("PMD recommended burst size of %d"
3410 " exceeds maximum value of %d\n",
3411 rec_nb_pkts, MAX_PKT_BURST);
3414 printf("Using PMD-provided burst value of %d\n",
3416 nb_pkt_per_burst = rec_nb_pkts;
3417 } else if (res->value > MAX_PKT_BURST) {
3418 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3422 nb_pkt_per_burst = res->value;
3424 fprintf(stderr, "Unknown parameter\n");
3430 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3433 cmdline_parse_token_string_t cmd_config_burst_port =
3434 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3435 cmdline_parse_token_string_t cmd_config_burst_keyword =
3436 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3437 cmdline_parse_token_string_t cmd_config_burst_all =
3438 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3439 cmdline_parse_token_string_t cmd_config_burst_name =
3440 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3441 cmdline_parse_token_num_t cmd_config_burst_value =
3442 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3444 cmdline_parse_inst_t cmd_config_burst = {
3445 .f = cmd_config_burst_parsed,
3447 .help_str = "port config all burst <value>",
3449 (void *)&cmd_config_burst_port,
3450 (void *)&cmd_config_burst_keyword,
3451 (void *)&cmd_config_burst_all,
3452 (void *)&cmd_config_burst_name,
3453 (void *)&cmd_config_burst_value,
3458 /* *** configure rx/tx queues *** */
3459 struct cmd_config_thresh {
3460 cmdline_fixed_string_t port;
3461 cmdline_fixed_string_t keyword;
3462 cmdline_fixed_string_t all;
3463 cmdline_fixed_string_t name;
3468 cmd_config_thresh_parsed(void *parsed_result,
3469 __rte_unused struct cmdline *cl,
3470 __rte_unused void *data)
3472 struct cmd_config_thresh *res = parsed_result;
3474 if (!all_ports_stopped()) {
3475 fprintf(stderr, "Please stop all ports first\n");
3479 if (!strcmp(res->name, "txpt"))
3480 tx_pthresh = res->value;
3481 else if(!strcmp(res->name, "txht"))
3482 tx_hthresh = res->value;
3483 else if(!strcmp(res->name, "txwt"))
3484 tx_wthresh = res->value;
3485 else if(!strcmp(res->name, "rxpt"))
3486 rx_pthresh = res->value;
3487 else if(!strcmp(res->name, "rxht"))
3488 rx_hthresh = res->value;
3489 else if(!strcmp(res->name, "rxwt"))
3490 rx_wthresh = res->value;
3492 fprintf(stderr, "Unknown parameter\n");
3498 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3501 cmdline_parse_token_string_t cmd_config_thresh_port =
3502 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3503 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3504 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3505 cmdline_parse_token_string_t cmd_config_thresh_all =
3506 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3507 cmdline_parse_token_string_t cmd_config_thresh_name =
3508 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3509 "txpt#txht#txwt#rxpt#rxht#rxwt");
3510 cmdline_parse_token_num_t cmd_config_thresh_value =
3511 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3513 cmdline_parse_inst_t cmd_config_thresh = {
3514 .f = cmd_config_thresh_parsed,
3516 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3518 (void *)&cmd_config_thresh_port,
3519 (void *)&cmd_config_thresh_keyword,
3520 (void *)&cmd_config_thresh_all,
3521 (void *)&cmd_config_thresh_name,
3522 (void *)&cmd_config_thresh_value,
3527 /* *** configure free/rs threshold *** */
3528 struct cmd_config_threshold {
3529 cmdline_fixed_string_t port;
3530 cmdline_fixed_string_t keyword;
3531 cmdline_fixed_string_t all;
3532 cmdline_fixed_string_t name;
3537 cmd_config_threshold_parsed(void *parsed_result,
3538 __rte_unused struct cmdline *cl,
3539 __rte_unused void *data)
3541 struct cmd_config_threshold *res = parsed_result;
3543 if (!all_ports_stopped()) {
3544 fprintf(stderr, "Please stop all ports first\n");
3548 if (!strcmp(res->name, "txfreet"))
3549 tx_free_thresh = res->value;
3550 else if (!strcmp(res->name, "txrst"))
3551 tx_rs_thresh = res->value;
3552 else if (!strcmp(res->name, "rxfreet"))
3553 rx_free_thresh = res->value;
3555 fprintf(stderr, "Unknown parameter\n");
3561 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3564 cmdline_parse_token_string_t cmd_config_threshold_port =
3565 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3566 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3567 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3569 cmdline_parse_token_string_t cmd_config_threshold_all =
3570 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3571 cmdline_parse_token_string_t cmd_config_threshold_name =
3572 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3573 "txfreet#txrst#rxfreet");
3574 cmdline_parse_token_num_t cmd_config_threshold_value =
3575 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3577 cmdline_parse_inst_t cmd_config_threshold = {
3578 .f = cmd_config_threshold_parsed,
3580 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3582 (void *)&cmd_config_threshold_port,
3583 (void *)&cmd_config_threshold_keyword,
3584 (void *)&cmd_config_threshold_all,
3585 (void *)&cmd_config_threshold_name,
3586 (void *)&cmd_config_threshold_value,
3592 struct cmd_stop_result {
3593 cmdline_fixed_string_t stop;
3596 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3597 __rte_unused struct cmdline *cl,
3598 __rte_unused void *data)
3600 stop_packet_forwarding();
3603 cmdline_parse_token_string_t cmd_stop_stop =
3604 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3606 cmdline_parse_inst_t cmd_stop = {
3607 .f = cmd_stop_parsed,
3609 .help_str = "stop: Stop packet forwarding",
3611 (void *)&cmd_stop_stop,
3616 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3619 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3620 unsigned int *parsed_items, int check_unique_values)
3622 unsigned int nb_item;
3630 * First parse all items in the list and store their value.
3635 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3637 if ((c >= '0') && (c <= '9')) {
3638 value = (unsigned int) (value * 10 + (c - '0'));
3643 fprintf(stderr, "character %c is not a decimal digit\n", c);
3647 fprintf(stderr, "No valid value before comma\n");
3650 if (nb_item < max_items) {
3651 parsed_items[nb_item] = value;
3657 if (nb_item >= max_items) {
3658 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3659 item_name, nb_item + 1, max_items);
3662 parsed_items[nb_item++] = value;
3663 if (! check_unique_values)
3667 * Then, check that all values in the list are different.
3668 * No optimization here...
3670 for (i = 0; i < nb_item; i++) {
3671 for (j = i + 1; j < nb_item; j++) {
3672 if (parsed_items[j] == parsed_items[i]) {
3674 "duplicated %s %u at index %u and %u\n",
3675 item_name, parsed_items[i], i, j);
3683 struct cmd_set_list_result {
3684 cmdline_fixed_string_t cmd_keyword;
3685 cmdline_fixed_string_t list_name;
3686 cmdline_fixed_string_t list_of_items;
3689 static void cmd_set_list_parsed(void *parsed_result,
3690 __rte_unused struct cmdline *cl,
3691 __rte_unused void *data)
3693 struct cmd_set_list_result *res;
3695 unsigned int lcorelist[RTE_MAX_LCORE];
3696 unsigned int portlist[RTE_MAX_ETHPORTS];
3698 unsigned int nb_item;
3700 if (test_done == 0) {
3701 fprintf(stderr, "Please stop forwarding first\n");
3705 res = parsed_result;
3706 if (!strcmp(res->list_name, "corelist")) {
3707 nb_item = parse_item_list(res->list_of_items, "core",
3709 parsed_items.lcorelist, 1);
3711 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3716 if (!strcmp(res->list_name, "portlist")) {
3717 nb_item = parse_item_list(res->list_of_items, "port",
3719 parsed_items.portlist, 1);
3721 set_fwd_ports_list(parsed_items.portlist, nb_item);
3727 cmdline_parse_token_string_t cmd_set_list_keyword =
3728 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3730 cmdline_parse_token_string_t cmd_set_list_name =
3731 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3732 "corelist#portlist");
3733 cmdline_parse_token_string_t cmd_set_list_of_items =
3734 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3737 cmdline_parse_inst_t cmd_set_fwd_list = {
3738 .f = cmd_set_list_parsed,
3740 .help_str = "set corelist|portlist <list0[,list1]*>",
3742 (void *)&cmd_set_list_keyword,
3743 (void *)&cmd_set_list_name,
3744 (void *)&cmd_set_list_of_items,
3749 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3751 struct cmd_setmask_result {
3752 cmdline_fixed_string_t set;
3753 cmdline_fixed_string_t mask;
3757 static void cmd_set_mask_parsed(void *parsed_result,
3758 __rte_unused struct cmdline *cl,
3759 __rte_unused void *data)
3761 struct cmd_setmask_result *res = parsed_result;
3763 if (test_done == 0) {
3764 fprintf(stderr, "Please stop forwarding first\n");
3767 if (!strcmp(res->mask, "coremask")) {
3768 set_fwd_lcores_mask(res->hexavalue);
3770 } else if (!strcmp(res->mask, "portmask")) {
3771 set_fwd_ports_mask(res->hexavalue);
3776 cmdline_parse_token_string_t cmd_setmask_set =
3777 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3778 cmdline_parse_token_string_t cmd_setmask_mask =
3779 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3780 "coremask#portmask");
3781 cmdline_parse_token_num_t cmd_setmask_value =
3782 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3784 cmdline_parse_inst_t cmd_set_fwd_mask = {
3785 .f = cmd_set_mask_parsed,
3787 .help_str = "set coremask|portmask <hexadecimal value>",
3789 (void *)&cmd_setmask_set,
3790 (void *)&cmd_setmask_mask,
3791 (void *)&cmd_setmask_value,
3797 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3799 struct cmd_set_result {
3800 cmdline_fixed_string_t set;
3801 cmdline_fixed_string_t what;
3805 static void cmd_set_parsed(void *parsed_result,
3806 __rte_unused struct cmdline *cl,
3807 __rte_unused void *data)
3809 struct cmd_set_result *res = parsed_result;
3810 if (!strcmp(res->what, "nbport")) {
3811 set_fwd_ports_number(res->value);
3813 } else if (!strcmp(res->what, "nbcore")) {
3814 set_fwd_lcores_number(res->value);
3816 } else if (!strcmp(res->what, "burst"))
3817 set_nb_pkt_per_burst(res->value);
3818 else if (!strcmp(res->what, "verbose"))
3819 set_verbose_level(res->value);
3822 cmdline_parse_token_string_t cmd_set_set =
3823 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3824 cmdline_parse_token_string_t cmd_set_what =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3826 "nbport#nbcore#burst#verbose");
3827 cmdline_parse_token_num_t cmd_set_value =
3828 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3830 cmdline_parse_inst_t cmd_set_numbers = {
3831 .f = cmd_set_parsed,
3833 .help_str = "set nbport|nbcore|burst|verbose <value>",
3835 (void *)&cmd_set_set,
3836 (void *)&cmd_set_what,
3837 (void *)&cmd_set_value,
3842 /* *** SET LOG LEVEL CONFIGURATION *** */
3844 struct cmd_set_log_result {
3845 cmdline_fixed_string_t set;
3846 cmdline_fixed_string_t log;
3847 cmdline_fixed_string_t type;
3852 cmd_set_log_parsed(void *parsed_result,
3853 __rte_unused struct cmdline *cl,
3854 __rte_unused void *data)
3856 struct cmd_set_log_result *res;
3859 res = parsed_result;
3860 if (!strcmp(res->type, "global"))
3861 rte_log_set_global_level(res->level);
3863 ret = rte_log_set_level_regexp(res->type, res->level);
3865 fprintf(stderr, "Unable to set log level\n");
3869 cmdline_parse_token_string_t cmd_set_log_set =
3870 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3871 cmdline_parse_token_string_t cmd_set_log_log =
3872 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3873 cmdline_parse_token_string_t cmd_set_log_type =
3874 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3875 cmdline_parse_token_num_t cmd_set_log_level =
3876 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3878 cmdline_parse_inst_t cmd_set_log = {
3879 .f = cmd_set_log_parsed,
3881 .help_str = "set log global|<type> <level>",
3883 (void *)&cmd_set_log_set,
3884 (void *)&cmd_set_log_log,
3885 (void *)&cmd_set_log_type,
3886 (void *)&cmd_set_log_level,
3891 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3893 struct cmd_set_rxoffs_result {
3894 cmdline_fixed_string_t cmd_keyword;
3895 cmdline_fixed_string_t rxoffs;
3896 cmdline_fixed_string_t seg_offsets;
3900 cmd_set_rxoffs_parsed(void *parsed_result,
3901 __rte_unused struct cmdline *cl,
3902 __rte_unused void *data)
3904 struct cmd_set_rxoffs_result *res;
3905 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3906 unsigned int nb_segs;
3908 res = parsed_result;
3909 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3910 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3912 set_rx_pkt_offsets(seg_offsets, nb_segs);
3913 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3916 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3917 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3918 cmd_keyword, "set");
3919 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3920 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3922 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3923 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3926 cmdline_parse_inst_t cmd_set_rxoffs = {
3927 .f = cmd_set_rxoffs_parsed,
3929 .help_str = "set rxoffs <len0[,len1]*>",
3931 (void *)&cmd_set_rxoffs_keyword,
3932 (void *)&cmd_set_rxoffs_name,
3933 (void *)&cmd_set_rxoffs_offsets,
3938 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3940 struct cmd_set_rxpkts_result {
3941 cmdline_fixed_string_t cmd_keyword;
3942 cmdline_fixed_string_t rxpkts;
3943 cmdline_fixed_string_t seg_lengths;
3947 cmd_set_rxpkts_parsed(void *parsed_result,
3948 __rte_unused struct cmdline *cl,
3949 __rte_unused void *data)
3951 struct cmd_set_rxpkts_result *res;
3952 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3953 unsigned int nb_segs;
3955 res = parsed_result;
3956 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3957 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3959 set_rx_pkt_segments(seg_lengths, nb_segs);
3960 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3963 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3964 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3965 cmd_keyword, "set");
3966 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3967 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3969 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3970 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3973 cmdline_parse_inst_t cmd_set_rxpkts = {
3974 .f = cmd_set_rxpkts_parsed,
3976 .help_str = "set rxpkts <len0[,len1]*>",
3978 (void *)&cmd_set_rxpkts_keyword,
3979 (void *)&cmd_set_rxpkts_name,
3980 (void *)&cmd_set_rxpkts_lengths,
3985 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3987 struct cmd_set_txpkts_result {
3988 cmdline_fixed_string_t cmd_keyword;
3989 cmdline_fixed_string_t txpkts;
3990 cmdline_fixed_string_t seg_lengths;
3994 cmd_set_txpkts_parsed(void *parsed_result,
3995 __rte_unused struct cmdline *cl,
3996 __rte_unused void *data)
3998 struct cmd_set_txpkts_result *res;
3999 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4000 unsigned int nb_segs;
4002 res = parsed_result;
4003 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4004 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4006 set_tx_pkt_segments(seg_lengths, nb_segs);
4009 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4010 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4011 cmd_keyword, "set");
4012 cmdline_parse_token_string_t cmd_set_txpkts_name =
4013 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4015 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4016 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4019 cmdline_parse_inst_t cmd_set_txpkts = {
4020 .f = cmd_set_txpkts_parsed,
4022 .help_str = "set txpkts <len0[,len1]*>",
4024 (void *)&cmd_set_txpkts_keyword,
4025 (void *)&cmd_set_txpkts_name,
4026 (void *)&cmd_set_txpkts_lengths,
4031 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4033 struct cmd_set_txsplit_result {
4034 cmdline_fixed_string_t cmd_keyword;
4035 cmdline_fixed_string_t txsplit;
4036 cmdline_fixed_string_t mode;
4040 cmd_set_txsplit_parsed(void *parsed_result,
4041 __rte_unused struct cmdline *cl,
4042 __rte_unused void *data)
4044 struct cmd_set_txsplit_result *res;
4046 res = parsed_result;
4047 set_tx_pkt_split(res->mode);
4050 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4052 cmd_keyword, "set");
4053 cmdline_parse_token_string_t cmd_set_txsplit_name =
4054 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4055 txsplit, "txsplit");
4056 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4057 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4060 cmdline_parse_inst_t cmd_set_txsplit = {
4061 .f = cmd_set_txsplit_parsed,
4063 .help_str = "set txsplit on|off|rand",
4065 (void *)&cmd_set_txsplit_keyword,
4066 (void *)&cmd_set_txsplit_name,
4067 (void *)&cmd_set_txsplit_mode,
4072 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4074 struct cmd_set_txtimes_result {
4075 cmdline_fixed_string_t cmd_keyword;
4076 cmdline_fixed_string_t txtimes;
4077 cmdline_fixed_string_t tx_times;
4081 cmd_set_txtimes_parsed(void *parsed_result,
4082 __rte_unused struct cmdline *cl,
4083 __rte_unused void *data)
4085 struct cmd_set_txtimes_result *res;
4086 unsigned int tx_times[2] = {0, 0};
4087 unsigned int n_times;
4089 res = parsed_result;
4090 n_times = parse_item_list(res->tx_times, "tx times",
4093 set_tx_pkt_times(tx_times);
4096 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4097 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4098 cmd_keyword, "set");
4099 cmdline_parse_token_string_t cmd_set_txtimes_name =
4100 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4101 txtimes, "txtimes");
4102 cmdline_parse_token_string_t cmd_set_txtimes_value =
4103 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4106 cmdline_parse_inst_t cmd_set_txtimes = {
4107 .f = cmd_set_txtimes_parsed,
4109 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4111 (void *)&cmd_set_txtimes_keyword,
4112 (void *)&cmd_set_txtimes_name,
4113 (void *)&cmd_set_txtimes_value,
4118 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4119 struct cmd_rx_vlan_filter_all_result {
4120 cmdline_fixed_string_t rx_vlan;
4121 cmdline_fixed_string_t what;
4122 cmdline_fixed_string_t all;
4127 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4128 __rte_unused struct cmdline *cl,
4129 __rte_unused void *data)
4131 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4133 if (!strcmp(res->what, "add"))
4134 rx_vlan_all_filter_set(res->port_id, 1);
4136 rx_vlan_all_filter_set(res->port_id, 0);
4139 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4140 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4141 rx_vlan, "rx_vlan");
4142 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4143 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4145 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4146 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4148 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4149 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4150 port_id, RTE_UINT16);
4152 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4153 .f = cmd_rx_vlan_filter_all_parsed,
4155 .help_str = "rx_vlan add|rm all <port_id>: "
4156 "Add/Remove all identifiers to/from the set of VLAN "
4157 "identifiers filtered by a port",
4159 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4160 (void *)&cmd_rx_vlan_filter_all_what,
4161 (void *)&cmd_rx_vlan_filter_all_all,
4162 (void *)&cmd_rx_vlan_filter_all_portid,
4167 /* *** VLAN OFFLOAD SET ON A PORT *** */
4168 struct cmd_vlan_offload_result {
4169 cmdline_fixed_string_t vlan;
4170 cmdline_fixed_string_t set;
4171 cmdline_fixed_string_t vlan_type;
4172 cmdline_fixed_string_t what;
4173 cmdline_fixed_string_t on;
4174 cmdline_fixed_string_t port_id;
4178 cmd_vlan_offload_parsed(void *parsed_result,
4179 __rte_unused struct cmdline *cl,
4180 __rte_unused void *data)
4183 struct cmd_vlan_offload_result *res = parsed_result;
4186 portid_t port_id = 0;
4190 len = strnlen(str, STR_TOKEN_SIZE);
4192 /* Get port_id first */
4200 tmp = strtoul(str, NULL, 0);
4201 /* If port_id greater that what portid_t can represent, return */
4202 if(tmp >= RTE_MAX_ETHPORTS)
4204 port_id = (portid_t)tmp;
4206 if (!strcmp(res->on, "on"))
4211 if (!strcmp(res->what, "strip"))
4212 rx_vlan_strip_set(port_id, on);
4213 else if(!strcmp(res->what, "stripq")){
4214 uint16_t queue_id = 0;
4216 /* No queue_id, return */
4218 fprintf(stderr, "must specify (port,queue_id)\n");
4221 tmp = strtoul(str + i + 1, NULL, 0);
4222 /* If queue_id greater that what 16-bits can represent, return */
4226 queue_id = (uint16_t)tmp;
4227 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4229 else if (!strcmp(res->what, "filter"))
4230 rx_vlan_filter_set(port_id, on);
4231 else if (!strcmp(res->what, "qinq_strip"))
4232 rx_vlan_qinq_strip_set(port_id, on);
4234 vlan_extend_set(port_id, on);
4239 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4240 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4242 cmdline_parse_token_string_t cmd_vlan_offload_set =
4243 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4245 cmdline_parse_token_string_t cmd_vlan_offload_what =
4246 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4247 what, "strip#filter#qinq_strip#extend#stripq");
4248 cmdline_parse_token_string_t cmd_vlan_offload_on =
4249 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4251 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4252 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4255 cmdline_parse_inst_t cmd_vlan_offload = {
4256 .f = cmd_vlan_offload_parsed,
4258 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4259 "<port_id[,queue_id]>: "
4260 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4262 (void *)&cmd_vlan_offload_vlan,
4263 (void *)&cmd_vlan_offload_set,
4264 (void *)&cmd_vlan_offload_what,
4265 (void *)&cmd_vlan_offload_on,
4266 (void *)&cmd_vlan_offload_portid,
4271 /* *** VLAN TPID SET ON A PORT *** */
4272 struct cmd_vlan_tpid_result {
4273 cmdline_fixed_string_t vlan;
4274 cmdline_fixed_string_t set;
4275 cmdline_fixed_string_t vlan_type;
4276 cmdline_fixed_string_t what;
4282 cmd_vlan_tpid_parsed(void *parsed_result,
4283 __rte_unused struct cmdline *cl,
4284 __rte_unused void *data)
4286 struct cmd_vlan_tpid_result *res = parsed_result;
4287 enum rte_vlan_type vlan_type;
4289 if (!strcmp(res->vlan_type, "inner"))
4290 vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4291 else if (!strcmp(res->vlan_type, "outer"))
4292 vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4294 fprintf(stderr, "Unknown vlan type\n");
4297 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4300 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4301 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4303 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4304 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4306 cmdline_parse_token_string_t cmd_vlan_type =
4307 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4308 vlan_type, "inner#outer");
4309 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4310 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4312 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4313 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4315 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4316 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4317 port_id, RTE_UINT16);
4319 cmdline_parse_inst_t cmd_vlan_tpid = {
4320 .f = cmd_vlan_tpid_parsed,
4322 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4323 "Set the VLAN Ether type",
4325 (void *)&cmd_vlan_tpid_vlan,
4326 (void *)&cmd_vlan_tpid_set,
4327 (void *)&cmd_vlan_type,
4328 (void *)&cmd_vlan_tpid_what,
4329 (void *)&cmd_vlan_tpid_tpid,
4330 (void *)&cmd_vlan_tpid_portid,
4335 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4336 struct cmd_rx_vlan_filter_result {
4337 cmdline_fixed_string_t rx_vlan;
4338 cmdline_fixed_string_t what;
4344 cmd_rx_vlan_filter_parsed(void *parsed_result,
4345 __rte_unused struct cmdline *cl,
4346 __rte_unused void *data)
4348 struct cmd_rx_vlan_filter_result *res = parsed_result;
4350 if (!strcmp(res->what, "add"))
4351 rx_vft_set(res->port_id, res->vlan_id, 1);
4353 rx_vft_set(res->port_id, res->vlan_id, 0);
4356 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4357 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4358 rx_vlan, "rx_vlan");
4359 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4360 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4362 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4363 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4364 vlan_id, RTE_UINT16);
4365 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4366 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4367 port_id, RTE_UINT16);
4369 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4370 .f = cmd_rx_vlan_filter_parsed,
4372 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4373 "Add/Remove a VLAN identifier to/from the set of VLAN "
4374 "identifiers filtered by a port",
4376 (void *)&cmd_rx_vlan_filter_rx_vlan,
4377 (void *)&cmd_rx_vlan_filter_what,
4378 (void *)&cmd_rx_vlan_filter_vlanid,
4379 (void *)&cmd_rx_vlan_filter_portid,
4384 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4385 struct cmd_tx_vlan_set_result {
4386 cmdline_fixed_string_t tx_vlan;
4387 cmdline_fixed_string_t set;
4393 cmd_tx_vlan_set_parsed(void *parsed_result,
4394 __rte_unused struct cmdline *cl,
4395 __rte_unused void *data)
4397 struct cmd_tx_vlan_set_result *res = parsed_result;
4399 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4402 if (!port_is_stopped(res->port_id)) {
4403 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4407 tx_vlan_set(res->port_id, res->vlan_id);
4409 cmd_reconfig_device_queue(res->port_id, 1, 1);
4412 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4413 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4414 tx_vlan, "tx_vlan");
4415 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4416 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4418 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4419 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4420 port_id, RTE_UINT16);
4421 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4422 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4423 vlan_id, RTE_UINT16);
4425 cmdline_parse_inst_t cmd_tx_vlan_set = {
4426 .f = cmd_tx_vlan_set_parsed,
4428 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4429 "Enable hardware insertion of a single VLAN header "
4430 "with a given TAG Identifier in packets sent on a port",
4432 (void *)&cmd_tx_vlan_set_tx_vlan,
4433 (void *)&cmd_tx_vlan_set_set,
4434 (void *)&cmd_tx_vlan_set_portid,
4435 (void *)&cmd_tx_vlan_set_vlanid,
4440 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4441 struct cmd_tx_vlan_set_qinq_result {
4442 cmdline_fixed_string_t tx_vlan;
4443 cmdline_fixed_string_t set;
4446 uint16_t vlan_id_outer;
4450 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4451 __rte_unused struct cmdline *cl,
4452 __rte_unused void *data)
4454 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4456 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4459 if (!port_is_stopped(res->port_id)) {
4460 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4464 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4466 cmd_reconfig_device_queue(res->port_id, 1, 1);
4469 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4470 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4471 tx_vlan, "tx_vlan");
4472 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4473 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4475 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4476 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4477 port_id, RTE_UINT16);
4478 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4479 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4480 vlan_id, RTE_UINT16);
4481 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4482 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4483 vlan_id_outer, RTE_UINT16);
4485 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4486 .f = cmd_tx_vlan_set_qinq_parsed,
4488 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4489 "Enable hardware insertion of double VLAN header "
4490 "with given TAG Identifiers in packets sent on a port",
4492 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4493 (void *)&cmd_tx_vlan_set_qinq_set,
4494 (void *)&cmd_tx_vlan_set_qinq_portid,
4495 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4496 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4501 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4502 struct cmd_tx_vlan_set_pvid_result {
4503 cmdline_fixed_string_t tx_vlan;
4504 cmdline_fixed_string_t set;
4505 cmdline_fixed_string_t pvid;
4508 cmdline_fixed_string_t mode;
4512 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4513 __rte_unused struct cmdline *cl,
4514 __rte_unused void *data)
4516 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4518 if (strcmp(res->mode, "on") == 0)
4519 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4521 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4524 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4525 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4526 tx_vlan, "tx_vlan");
4527 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4528 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4530 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4531 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4533 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4534 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4535 port_id, RTE_UINT16);
4536 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4537 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4538 vlan_id, RTE_UINT16);
4539 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4540 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4543 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4544 .f = cmd_tx_vlan_set_pvid_parsed,
4546 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4548 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4549 (void *)&cmd_tx_vlan_set_pvid_set,
4550 (void *)&cmd_tx_vlan_set_pvid_pvid,
4551 (void *)&cmd_tx_vlan_set_pvid_port_id,
4552 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4553 (void *)&cmd_tx_vlan_set_pvid_mode,
4558 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4559 struct cmd_tx_vlan_reset_result {
4560 cmdline_fixed_string_t tx_vlan;
4561 cmdline_fixed_string_t reset;
4566 cmd_tx_vlan_reset_parsed(void *parsed_result,
4567 __rte_unused struct cmdline *cl,
4568 __rte_unused void *data)
4570 struct cmd_tx_vlan_reset_result *res = parsed_result;
4572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4575 if (!port_is_stopped(res->port_id)) {
4576 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4580 tx_vlan_reset(res->port_id);
4582 cmd_reconfig_device_queue(res->port_id, 1, 1);
4585 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4586 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4587 tx_vlan, "tx_vlan");
4588 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4589 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4591 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4592 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4593 port_id, RTE_UINT16);
4595 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4596 .f = cmd_tx_vlan_reset_parsed,
4598 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4599 "VLAN header in packets sent on a port",
4601 (void *)&cmd_tx_vlan_reset_tx_vlan,
4602 (void *)&cmd_tx_vlan_reset_reset,
4603 (void *)&cmd_tx_vlan_reset_portid,
4609 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4610 struct cmd_csum_result {
4611 cmdline_fixed_string_t csum;
4612 cmdline_fixed_string_t mode;
4613 cmdline_fixed_string_t proto;
4614 cmdline_fixed_string_t hwsw;
4619 csum_show(int port_id)
4621 struct rte_eth_dev_info dev_info;
4622 uint64_t tx_offloads;
4625 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4626 printf("Parse tunnel is %s\n",
4627 (ports[port_id].parse_tunnel) ? "on" : "off");
4628 printf("IP checksum offload is %s\n",
4629 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4630 printf("UDP checksum offload is %s\n",
4631 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4632 printf("TCP checksum offload is %s\n",
4633 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4634 printf("SCTP checksum offload is %s\n",
4635 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4636 printf("Outer-Ip checksum offload is %s\n",
4637 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4638 printf("Outer-Udp checksum offload is %s\n",
4639 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4641 /* display warnings if configuration is not supported by the NIC */
4642 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4646 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4647 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4649 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4652 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4653 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4655 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4658 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4659 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4661 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4664 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4665 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4667 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4670 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4671 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4673 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4676 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4677 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4680 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4686 cmd_config_queue_tx_offloads(struct rte_port *port)
4690 /* Apply queue tx offloads configuration */
4691 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4692 port->tx_conf[k].offloads =
4693 port->dev_conf.txmode.offloads;
4697 cmd_csum_parsed(void *parsed_result,
4698 __rte_unused struct cmdline *cl,
4699 __rte_unused void *data)
4701 struct cmd_csum_result *res = parsed_result;
4703 uint64_t csum_offloads = 0;
4704 struct rte_eth_dev_info dev_info;
4707 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4708 fprintf(stderr, "invalid port %d\n", res->port_id);
4711 if (!port_is_stopped(res->port_id)) {
4712 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4716 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4720 if (!strcmp(res->mode, "set")) {
4722 if (!strcmp(res->hwsw, "hw"))
4725 if (!strcmp(res->proto, "ip")) {
4726 if (hw == 0 || (dev_info.tx_offload_capa &
4727 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4728 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4731 "IP checksum offload is not supported by port %u\n",
4734 } else if (!strcmp(res->proto, "udp")) {
4735 if (hw == 0 || (dev_info.tx_offload_capa &
4736 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4737 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4740 "UDP checksum offload is not supported by port %u\n",
4743 } else if (!strcmp(res->proto, "tcp")) {
4744 if (hw == 0 || (dev_info.tx_offload_capa &
4745 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4746 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4749 "TCP checksum offload is not supported by port %u\n",
4752 } else if (!strcmp(res->proto, "sctp")) {
4753 if (hw == 0 || (dev_info.tx_offload_capa &
4754 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4755 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4758 "SCTP checksum offload is not supported by port %u\n",
4761 } else if (!strcmp(res->proto, "outer-ip")) {
4762 if (hw == 0 || (dev_info.tx_offload_capa &
4763 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4765 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4768 "Outer IP checksum offload is not supported by port %u\n",
4771 } else if (!strcmp(res->proto, "outer-udp")) {
4772 if (hw == 0 || (dev_info.tx_offload_capa &
4773 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4775 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4778 "Outer UDP checksum offload is not supported by port %u\n",
4784 ports[res->port_id].dev_conf.txmode.offloads |=
4787 ports[res->port_id].dev_conf.txmode.offloads &=
4790 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4792 csum_show(res->port_id);
4794 cmd_reconfig_device_queue(res->port_id, 1, 1);
4797 cmdline_parse_token_string_t cmd_csum_csum =
4798 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4800 cmdline_parse_token_string_t cmd_csum_mode =
4801 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4803 cmdline_parse_token_string_t cmd_csum_proto =
4804 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4805 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4806 cmdline_parse_token_string_t cmd_csum_hwsw =
4807 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4809 cmdline_parse_token_num_t cmd_csum_portid =
4810 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4811 port_id, RTE_UINT16);
4813 cmdline_parse_inst_t cmd_csum_set = {
4814 .f = cmd_csum_parsed,
4816 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4817 "Enable/Disable hardware calculation of L3/L4 checksum when "
4818 "using csum forward engine",
4820 (void *)&cmd_csum_csum,
4821 (void *)&cmd_csum_mode,
4822 (void *)&cmd_csum_proto,
4823 (void *)&cmd_csum_hwsw,
4824 (void *)&cmd_csum_portid,
4829 cmdline_parse_token_string_t cmd_csum_mode_show =
4830 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4833 cmdline_parse_inst_t cmd_csum_show = {
4834 .f = cmd_csum_parsed,
4836 .help_str = "csum show <port_id>: Show checksum offload configuration",
4838 (void *)&cmd_csum_csum,
4839 (void *)&cmd_csum_mode_show,
4840 (void *)&cmd_csum_portid,
4845 /* Enable/disable tunnel parsing */
4846 struct cmd_csum_tunnel_result {
4847 cmdline_fixed_string_t csum;
4848 cmdline_fixed_string_t parse;
4849 cmdline_fixed_string_t onoff;
4854 cmd_csum_tunnel_parsed(void *parsed_result,
4855 __rte_unused struct cmdline *cl,
4856 __rte_unused void *data)
4858 struct cmd_csum_tunnel_result *res = parsed_result;
4860 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4863 if (!strcmp(res->onoff, "on"))
4864 ports[res->port_id].parse_tunnel = 1;
4866 ports[res->port_id].parse_tunnel = 0;
4868 csum_show(res->port_id);
4871 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4872 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4874 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4875 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4876 parse, "parse-tunnel");
4877 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4878 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4880 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4881 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4882 port_id, RTE_UINT16);
4884 cmdline_parse_inst_t cmd_csum_tunnel = {
4885 .f = cmd_csum_tunnel_parsed,
4887 .help_str = "csum parse-tunnel on|off <port_id>: "
4888 "Enable/Disable parsing of tunnels for csum engine",
4890 (void *)&cmd_csum_tunnel_csum,
4891 (void *)&cmd_csum_tunnel_parse,
4892 (void *)&cmd_csum_tunnel_onoff,
4893 (void *)&cmd_csum_tunnel_portid,
4898 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4899 struct cmd_tso_set_result {
4900 cmdline_fixed_string_t tso;
4901 cmdline_fixed_string_t mode;
4907 cmd_tso_set_parsed(void *parsed_result,
4908 __rte_unused struct cmdline *cl,
4909 __rte_unused void *data)
4911 struct cmd_tso_set_result *res = parsed_result;
4912 struct rte_eth_dev_info dev_info;
4915 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4917 if (!port_is_stopped(res->port_id)) {
4918 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4922 if (!strcmp(res->mode, "set"))
4923 ports[res->port_id].tso_segsz = res->tso_segsz;
4925 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4929 if ((ports[res->port_id].tso_segsz != 0) &&
4930 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4931 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4936 if (ports[res->port_id].tso_segsz == 0) {
4937 ports[res->port_id].dev_conf.txmode.offloads &=
4938 ~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4939 printf("TSO for non-tunneled packets is disabled\n");
4941 ports[res->port_id].dev_conf.txmode.offloads |=
4942 RTE_ETH_TX_OFFLOAD_TCP_TSO;
4943 printf("TSO segment size for non-tunneled packets is %d\n",
4944 ports[res->port_id].tso_segsz);
4946 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4948 /* display warnings if configuration is not supported by the NIC */
4949 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4953 if ((ports[res->port_id].tso_segsz != 0) &&
4954 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4956 "Warning: TSO enabled but not supported by port %d\n",
4960 cmd_reconfig_device_queue(res->port_id, 1, 1);
4963 cmdline_parse_token_string_t cmd_tso_set_tso =
4964 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4966 cmdline_parse_token_string_t cmd_tso_set_mode =
4967 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4969 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4970 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4971 tso_segsz, RTE_UINT16);
4972 cmdline_parse_token_num_t cmd_tso_set_portid =
4973 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4974 port_id, RTE_UINT16);
4976 cmdline_parse_inst_t cmd_tso_set = {
4977 .f = cmd_tso_set_parsed,
4979 .help_str = "tso set <tso_segsz> <port_id>: "
4980 "Set TSO segment size of non-tunneled packets for csum engine "
4983 (void *)&cmd_tso_set_tso,
4984 (void *)&cmd_tso_set_mode,
4985 (void *)&cmd_tso_set_tso_segsz,
4986 (void *)&cmd_tso_set_portid,
4991 cmdline_parse_token_string_t cmd_tso_show_mode =
4992 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4996 cmdline_parse_inst_t cmd_tso_show = {
4997 .f = cmd_tso_set_parsed,
4999 .help_str = "tso show <port_id>: "
5000 "Show TSO segment size of non-tunneled packets for csum engine",
5002 (void *)&cmd_tso_set_tso,
5003 (void *)&cmd_tso_show_mode,
5004 (void *)&cmd_tso_set_portid,
5009 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5010 struct cmd_tunnel_tso_set_result {
5011 cmdline_fixed_string_t tso;
5012 cmdline_fixed_string_t mode;
5017 static struct rte_eth_dev_info
5018 check_tunnel_tso_nic_support(portid_t port_id)
5020 struct rte_eth_dev_info dev_info;
5022 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5025 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5027 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5029 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5031 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5033 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5035 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5037 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5039 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5041 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5043 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5045 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5047 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5053 cmd_tunnel_tso_set_parsed(void *parsed_result,
5054 __rte_unused struct cmdline *cl,
5055 __rte_unused void *data)
5057 struct cmd_tunnel_tso_set_result *res = parsed_result;
5058 struct rte_eth_dev_info dev_info;
5060 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5062 if (!port_is_stopped(res->port_id)) {
5063 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5067 if (!strcmp(res->mode, "set"))
5068 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5070 dev_info = check_tunnel_tso_nic_support(res->port_id);
5071 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5072 ports[res->port_id].dev_conf.txmode.offloads &=
5073 ~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5074 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5075 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5076 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5077 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5078 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5079 printf("TSO for tunneled packets is disabled\n");
5081 uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5082 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5083 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5084 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5085 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5086 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5088 ports[res->port_id].dev_conf.txmode.offloads |=
5089 (tso_offloads & dev_info.tx_offload_capa);
5090 printf("TSO segment size for tunneled packets is %d\n",
5091 ports[res->port_id].tunnel_tso_segsz);
5093 /* Below conditions are needed to make it work:
5094 * (1) tunnel TSO is supported by the NIC;
5095 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5097 * (3) for tunneled pkts with outer L3 of IPv4,
5098 * "csum set outer-ip" must be set to hw, because after tso,
5099 * total_len of outer IP header is changed, and the checksum
5100 * of outer IP header calculated by sw should be wrong; that
5101 * is not necessary for IPv6 tunneled pkts because there's no
5102 * checksum in IP header anymore.
5105 if (!ports[res->port_id].parse_tunnel)
5107 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5108 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5109 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5111 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5114 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5115 cmd_reconfig_device_queue(res->port_id, 1, 1);
5118 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5119 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5121 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5122 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5124 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5125 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5126 tso_segsz, RTE_UINT16);
5127 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5128 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5129 port_id, RTE_UINT16);
5131 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5132 .f = cmd_tunnel_tso_set_parsed,
5134 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5135 "Set TSO segment size of tunneled packets for csum engine "
5138 (void *)&cmd_tunnel_tso_set_tso,
5139 (void *)&cmd_tunnel_tso_set_mode,
5140 (void *)&cmd_tunnel_tso_set_tso_segsz,
5141 (void *)&cmd_tunnel_tso_set_portid,
5146 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5147 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5151 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5152 .f = cmd_tunnel_tso_set_parsed,
5154 .help_str = "tunnel_tso show <port_id> "
5155 "Show TSO segment size of tunneled packets for csum engine",
5157 (void *)&cmd_tunnel_tso_set_tso,
5158 (void *)&cmd_tunnel_tso_show_mode,
5159 (void *)&cmd_tunnel_tso_set_portid,
5165 /* *** SET GRO FOR A PORT *** */
5166 struct cmd_gro_enable_result {
5167 cmdline_fixed_string_t cmd_set;
5168 cmdline_fixed_string_t cmd_port;
5169 cmdline_fixed_string_t cmd_keyword;
5170 cmdline_fixed_string_t cmd_onoff;
5175 cmd_gro_enable_parsed(void *parsed_result,
5176 __rte_unused struct cmdline *cl,
5177 __rte_unused void *data)
5179 struct cmd_gro_enable_result *res;
5181 res = parsed_result;
5182 if (!strcmp(res->cmd_keyword, "gro"))
5183 setup_gro(res->cmd_onoff, res->cmd_pid);
5186 cmdline_parse_token_string_t cmd_gro_enable_set =
5187 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5189 cmdline_parse_token_string_t cmd_gro_enable_port =
5190 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5191 cmd_keyword, "port");
5192 cmdline_parse_token_num_t cmd_gro_enable_pid =
5193 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5194 cmd_pid, RTE_UINT16);
5195 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5196 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5197 cmd_keyword, "gro");
5198 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5199 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5200 cmd_onoff, "on#off");
5202 cmdline_parse_inst_t cmd_gro_enable = {
5203 .f = cmd_gro_enable_parsed,
5205 .help_str = "set port <port_id> gro on|off",
5207 (void *)&cmd_gro_enable_set,
5208 (void *)&cmd_gro_enable_port,
5209 (void *)&cmd_gro_enable_pid,
5210 (void *)&cmd_gro_enable_keyword,
5211 (void *)&cmd_gro_enable_onoff,
5216 /* *** DISPLAY GRO CONFIGURATION *** */
5217 struct cmd_gro_show_result {
5218 cmdline_fixed_string_t cmd_show;
5219 cmdline_fixed_string_t cmd_port;
5220 cmdline_fixed_string_t cmd_keyword;
5225 cmd_gro_show_parsed(void *parsed_result,
5226 __rte_unused struct cmdline *cl,
5227 __rte_unused void *data)
5229 struct cmd_gro_show_result *res;
5231 res = parsed_result;
5232 if (!strcmp(res->cmd_keyword, "gro"))
5233 show_gro(res->cmd_pid);
5236 cmdline_parse_token_string_t cmd_gro_show_show =
5237 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5239 cmdline_parse_token_string_t cmd_gro_show_port =
5240 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5242 cmdline_parse_token_num_t cmd_gro_show_pid =
5243 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5244 cmd_pid, RTE_UINT16);
5245 cmdline_parse_token_string_t cmd_gro_show_keyword =
5246 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5247 cmd_keyword, "gro");
5249 cmdline_parse_inst_t cmd_gro_show = {
5250 .f = cmd_gro_show_parsed,
5252 .help_str = "show port <port_id> gro",
5254 (void *)&cmd_gro_show_show,
5255 (void *)&cmd_gro_show_port,
5256 (void *)&cmd_gro_show_pid,
5257 (void *)&cmd_gro_show_keyword,
5262 /* *** SET FLUSH CYCLES FOR GRO *** */
5263 struct cmd_gro_flush_result {
5264 cmdline_fixed_string_t cmd_set;
5265 cmdline_fixed_string_t cmd_keyword;
5266 cmdline_fixed_string_t cmd_flush;
5271 cmd_gro_flush_parsed(void *parsed_result,
5272 __rte_unused struct cmdline *cl,
5273 __rte_unused void *data)
5275 struct cmd_gro_flush_result *res;
5277 res = parsed_result;
5278 if ((!strcmp(res->cmd_keyword, "gro")) &&
5279 (!strcmp(res->cmd_flush, "flush")))
5280 setup_gro_flush_cycles(res->cmd_cycles);
5283 cmdline_parse_token_string_t cmd_gro_flush_set =
5284 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5286 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5287 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5288 cmd_keyword, "gro");
5289 cmdline_parse_token_string_t cmd_gro_flush_flush =
5290 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5291 cmd_flush, "flush");
5292 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5293 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5294 cmd_cycles, RTE_UINT8);
5296 cmdline_parse_inst_t cmd_gro_flush = {
5297 .f = cmd_gro_flush_parsed,
5299 .help_str = "set gro flush <cycles>",
5301 (void *)&cmd_gro_flush_set,
5302 (void *)&cmd_gro_flush_keyword,
5303 (void *)&cmd_gro_flush_flush,
5304 (void *)&cmd_gro_flush_cycles,
5308 #endif /* RTE_LIB_GRO */
5311 /* *** ENABLE/DISABLE GSO *** */
5312 struct cmd_gso_enable_result {
5313 cmdline_fixed_string_t cmd_set;
5314 cmdline_fixed_string_t cmd_port;
5315 cmdline_fixed_string_t cmd_keyword;
5316 cmdline_fixed_string_t cmd_mode;
5321 cmd_gso_enable_parsed(void *parsed_result,
5322 __rte_unused struct cmdline *cl,
5323 __rte_unused void *data)
5325 struct cmd_gso_enable_result *res;
5327 res = parsed_result;
5328 if (!strcmp(res->cmd_keyword, "gso"))
5329 setup_gso(res->cmd_mode, res->cmd_pid);
5332 cmdline_parse_token_string_t cmd_gso_enable_set =
5333 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5335 cmdline_parse_token_string_t cmd_gso_enable_port =
5336 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5338 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5339 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5340 cmd_keyword, "gso");
5341 cmdline_parse_token_string_t cmd_gso_enable_mode =
5342 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5343 cmd_mode, "on#off");
5344 cmdline_parse_token_num_t cmd_gso_enable_pid =
5345 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5346 cmd_pid, RTE_UINT16);
5348 cmdline_parse_inst_t cmd_gso_enable = {
5349 .f = cmd_gso_enable_parsed,
5351 .help_str = "set port <port_id> gso on|off",
5353 (void *)&cmd_gso_enable_set,
5354 (void *)&cmd_gso_enable_port,
5355 (void *)&cmd_gso_enable_pid,
5356 (void *)&cmd_gso_enable_keyword,
5357 (void *)&cmd_gso_enable_mode,
5362 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5363 struct cmd_gso_size_result {
5364 cmdline_fixed_string_t cmd_set;
5365 cmdline_fixed_string_t cmd_keyword;
5366 cmdline_fixed_string_t cmd_segsz;
5371 cmd_gso_size_parsed(void *parsed_result,
5372 __rte_unused struct cmdline *cl,
5373 __rte_unused void *data)
5375 struct cmd_gso_size_result *res = parsed_result;
5377 if (test_done == 0) {
5379 "Before setting GSO segsz, please first stop forwarding\n");
5383 if (!strcmp(res->cmd_keyword, "gso") &&
5384 !strcmp(res->cmd_segsz, "segsz")) {
5385 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5387 "gso_size should be larger than %zu. Please input a legal value\n",
5388 RTE_GSO_SEG_SIZE_MIN);
5390 gso_max_segment_size = res->cmd_size;
5394 cmdline_parse_token_string_t cmd_gso_size_set =
5395 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5397 cmdline_parse_token_string_t cmd_gso_size_keyword =
5398 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5399 cmd_keyword, "gso");
5400 cmdline_parse_token_string_t cmd_gso_size_segsz =
5401 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5402 cmd_segsz, "segsz");
5403 cmdline_parse_token_num_t cmd_gso_size_size =
5404 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5405 cmd_size, RTE_UINT16);
5407 cmdline_parse_inst_t cmd_gso_size = {
5408 .f = cmd_gso_size_parsed,
5410 .help_str = "set gso segsz <length>",
5412 (void *)&cmd_gso_size_set,
5413 (void *)&cmd_gso_size_keyword,
5414 (void *)&cmd_gso_size_segsz,
5415 (void *)&cmd_gso_size_size,
5420 /* *** SHOW GSO CONFIGURATION *** */
5421 struct cmd_gso_show_result {
5422 cmdline_fixed_string_t cmd_show;
5423 cmdline_fixed_string_t cmd_port;
5424 cmdline_fixed_string_t cmd_keyword;
5429 cmd_gso_show_parsed(void *parsed_result,
5430 __rte_unused struct cmdline *cl,
5431 __rte_unused void *data)
5433 struct cmd_gso_show_result *res = parsed_result;
5435 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5436 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5439 if (!strcmp(res->cmd_keyword, "gso")) {
5440 if (gso_ports[res->cmd_pid].enable) {
5441 printf("Max GSO'd packet size: %uB\n"
5442 "Supported GSO types: TCP/IPv4, "
5443 "UDP/IPv4, VxLAN with inner "
5444 "TCP/IPv4 packet, GRE with inner "
5445 "TCP/IPv4 packet\n",
5446 gso_max_segment_size);
5448 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5452 cmdline_parse_token_string_t cmd_gso_show_show =
5453 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5455 cmdline_parse_token_string_t cmd_gso_show_port =
5456 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5458 cmdline_parse_token_string_t cmd_gso_show_keyword =
5459 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5460 cmd_keyword, "gso");
5461 cmdline_parse_token_num_t cmd_gso_show_pid =
5462 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5463 cmd_pid, RTE_UINT16);
5465 cmdline_parse_inst_t cmd_gso_show = {
5466 .f = cmd_gso_show_parsed,
5468 .help_str = "show port <port_id> gso",
5470 (void *)&cmd_gso_show_show,
5471 (void *)&cmd_gso_show_port,
5472 (void *)&cmd_gso_show_pid,
5473 (void *)&cmd_gso_show_keyword,
5477 #endif /* RTE_LIB_GSO */
5479 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5480 struct cmd_set_flush_rx {
5481 cmdline_fixed_string_t set;
5482 cmdline_fixed_string_t flush_rx;
5483 cmdline_fixed_string_t mode;
5487 cmd_set_flush_rx_parsed(void *parsed_result,
5488 __rte_unused struct cmdline *cl,
5489 __rte_unused void *data)
5491 struct cmd_set_flush_rx *res = parsed_result;
5493 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5494 printf("multi-process doesn't support to flush Rx queues.\n");
5498 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5501 cmdline_parse_token_string_t cmd_setflushrx_set =
5502 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5504 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5505 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5506 flush_rx, "flush_rx");
5507 cmdline_parse_token_string_t cmd_setflushrx_mode =
5508 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5512 cmdline_parse_inst_t cmd_set_flush_rx = {
5513 .f = cmd_set_flush_rx_parsed,
5514 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5517 (void *)&cmd_setflushrx_set,
5518 (void *)&cmd_setflushrx_flush_rx,
5519 (void *)&cmd_setflushrx_mode,
5524 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5525 struct cmd_set_link_check {
5526 cmdline_fixed_string_t set;
5527 cmdline_fixed_string_t link_check;
5528 cmdline_fixed_string_t mode;
5532 cmd_set_link_check_parsed(void *parsed_result,
5533 __rte_unused struct cmdline *cl,
5534 __rte_unused void *data)
5536 struct cmd_set_link_check *res = parsed_result;
5537 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5540 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5541 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5543 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5544 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5545 link_check, "link_check");
5546 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5547 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5551 cmdline_parse_inst_t cmd_set_link_check = {
5552 .f = cmd_set_link_check_parsed,
5553 .help_str = "set link_check on|off: Enable/Disable link status check "
5554 "when starting/stopping a port",
5557 (void *)&cmd_setlinkcheck_set,
5558 (void *)&cmd_setlinkcheck_link_check,
5559 (void *)&cmd_setlinkcheck_mode,
5564 /* *** SET NIC BYPASS MODE *** */
5565 struct cmd_set_bypass_mode_result {
5566 cmdline_fixed_string_t set;
5567 cmdline_fixed_string_t bypass;
5568 cmdline_fixed_string_t mode;
5569 cmdline_fixed_string_t value;
5574 cmd_set_bypass_mode_parsed(void *parsed_result,
5575 __rte_unused struct cmdline *cl,
5576 __rte_unused void *data)
5578 struct cmd_set_bypass_mode_result *res = parsed_result;
5579 portid_t port_id = res->port_id;
5580 int32_t rc = -EINVAL;
5582 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5583 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5585 if (!strcmp(res->value, "bypass"))
5586 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5587 else if (!strcmp(res->value, "isolate"))
5588 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5590 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5592 /* Set the bypass mode for the relevant port. */
5593 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5596 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5600 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5601 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5603 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5606 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5607 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5609 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5610 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5611 value, "normal#bypass#isolate");
5612 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5613 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5614 port_id, RTE_UINT16);
5616 cmdline_parse_inst_t cmd_set_bypass_mode = {
5617 .f = cmd_set_bypass_mode_parsed,
5618 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5619 "Set the NIC bypass mode for port_id",
5622 (void *)&cmd_setbypass_mode_set,
5623 (void *)&cmd_setbypass_mode_bypass,
5624 (void *)&cmd_setbypass_mode_mode,
5625 (void *)&cmd_setbypass_mode_value,
5626 (void *)&cmd_setbypass_mode_port,
5631 /* *** SET NIC BYPASS EVENT *** */
5632 struct cmd_set_bypass_event_result {
5633 cmdline_fixed_string_t set;
5634 cmdline_fixed_string_t bypass;
5635 cmdline_fixed_string_t event;
5636 cmdline_fixed_string_t event_value;
5637 cmdline_fixed_string_t mode;
5638 cmdline_fixed_string_t mode_value;
5643 cmd_set_bypass_event_parsed(void *parsed_result,
5644 __rte_unused struct cmdline *cl,
5645 __rte_unused void *data)
5647 int32_t rc = -EINVAL;
5648 struct cmd_set_bypass_event_result *res = parsed_result;
5649 portid_t port_id = res->port_id;
5651 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5652 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5653 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5655 if (!strcmp(res->event_value, "timeout"))
5656 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5657 else if (!strcmp(res->event_value, "os_on"))
5658 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5659 else if (!strcmp(res->event_value, "os_off"))
5660 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5661 else if (!strcmp(res->event_value, "power_on"))
5662 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5663 else if (!strcmp(res->event_value, "power_off"))
5664 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5666 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5668 if (!strcmp(res->mode_value, "bypass"))
5669 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5670 else if (!strcmp(res->mode_value, "isolate"))
5671 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5673 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5675 /* Set the watchdog timeout. */
5676 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5679 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5680 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5685 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5686 bypass_timeout, port_id, rc);
5690 /* Set the bypass event to transition to bypass mode. */
5691 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5696 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5700 cmdline_parse_token_string_t cmd_setbypass_event_set =
5701 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5703 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5706 cmdline_parse_token_string_t cmd_setbypass_event_event =
5707 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5709 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5710 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5711 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5712 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5713 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5715 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5716 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5717 mode_value, "normal#bypass#isolate");
5718 cmdline_parse_token_num_t cmd_setbypass_event_port =
5719 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5720 port_id, RTE_UINT16);
5722 cmdline_parse_inst_t cmd_set_bypass_event = {
5723 .f = cmd_set_bypass_event_parsed,
5724 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5725 "power_off mode normal|bypass|isolate <port_id>: "
5726 "Set the NIC bypass event mode for port_id",
5729 (void *)&cmd_setbypass_event_set,
5730 (void *)&cmd_setbypass_event_bypass,
5731 (void *)&cmd_setbypass_event_event,
5732 (void *)&cmd_setbypass_event_event_value,
5733 (void *)&cmd_setbypass_event_mode,
5734 (void *)&cmd_setbypass_event_mode_value,
5735 (void *)&cmd_setbypass_event_port,
5741 /* *** SET NIC BYPASS TIMEOUT *** */
5742 struct cmd_set_bypass_timeout_result {
5743 cmdline_fixed_string_t set;
5744 cmdline_fixed_string_t bypass;
5745 cmdline_fixed_string_t timeout;
5746 cmdline_fixed_string_t value;
5750 cmd_set_bypass_timeout_parsed(void *parsed_result,
5751 __rte_unused struct cmdline *cl,
5752 __rte_unused void *data)
5754 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5756 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5757 if (!strcmp(res->value, "1.5"))
5758 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5759 else if (!strcmp(res->value, "2"))
5760 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5761 else if (!strcmp(res->value, "3"))
5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5763 else if (!strcmp(res->value, "4"))
5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5765 else if (!strcmp(res->value, "8"))
5766 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5767 else if (!strcmp(res->value, "16"))
5768 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5769 else if (!strcmp(res->value, "32"))
5770 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5772 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5776 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5777 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5779 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5782 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5783 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5784 timeout, "timeout");
5785 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5786 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5787 value, "0#1.5#2#3#4#8#16#32");
5789 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5790 .f = cmd_set_bypass_timeout_parsed,
5791 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5792 "Set the NIC bypass watchdog timeout in seconds",
5795 (void *)&cmd_setbypass_timeout_set,
5796 (void *)&cmd_setbypass_timeout_bypass,
5797 (void *)&cmd_setbypass_timeout_timeout,
5798 (void *)&cmd_setbypass_timeout_value,
5803 /* *** SHOW NIC BYPASS MODE *** */
5804 struct cmd_show_bypass_config_result {
5805 cmdline_fixed_string_t show;
5806 cmdline_fixed_string_t bypass;
5807 cmdline_fixed_string_t config;
5812 cmd_show_bypass_config_parsed(void *parsed_result,
5813 __rte_unused struct cmdline *cl,
5814 __rte_unused void *data)
5816 struct cmd_show_bypass_config_result *res = parsed_result;
5817 portid_t port_id = res->port_id;
5819 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5820 uint32_t event_mode;
5821 uint32_t bypass_mode;
5822 uint32_t timeout = bypass_timeout;
5825 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5826 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5827 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5828 {"UNKNOWN", "normal", "bypass", "isolate"};
5829 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5837 /* Display the bypass mode.*/
5838 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5839 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5844 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5845 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5847 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5850 /* Display the bypass timeout.*/
5851 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5852 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5854 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5856 /* Display the bypass events and associated modes. */
5857 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5859 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5861 "\tFailed to get bypass mode for event = %s\n",
5864 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5865 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5867 printf("\tbypass event: %-16s = %s\n", events[i],
5874 "\tFailed to get bypass configuration for port = %d\n",
5878 cmdline_parse_token_string_t cmd_showbypass_config_show =
5879 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5881 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5882 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5884 cmdline_parse_token_string_t cmd_showbypass_config_config =
5885 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5887 cmdline_parse_token_num_t cmd_showbypass_config_port =
5888 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5889 port_id, RTE_UINT16);
5891 cmdline_parse_inst_t cmd_show_bypass_config = {
5892 .f = cmd_show_bypass_config_parsed,
5893 .help_str = "show bypass config <port_id>: "
5894 "Show the NIC bypass config for port_id",
5897 (void *)&cmd_showbypass_config_show,
5898 (void *)&cmd_showbypass_config_bypass,
5899 (void *)&cmd_showbypass_config_config,
5900 (void *)&cmd_showbypass_config_port,
5906 /* *** SET BONDING MODE *** */
5907 struct cmd_set_bonding_mode_result {
5908 cmdline_fixed_string_t set;
5909 cmdline_fixed_string_t bonding;
5910 cmdline_fixed_string_t mode;
5915 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5916 __rte_unused struct cmdline *cl,
5917 __rte_unused void *data)
5919 struct cmd_set_bonding_mode_result *res = parsed_result;
5920 portid_t port_id = res->port_id;
5921 struct rte_port *port = &ports[port_id];
5924 * Bonding mode changed means resources of device changed, like whether
5925 * started rte timer or not. Device should be restarted when resources
5926 * of device changed.
5928 if (port->port_status != RTE_PORT_STOPPED) {
5930 "\t Error: Can't set bonding mode when port %d is not stopped\n",
5935 /* Set the bonding mode for the relevant port. */
5936 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5937 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5941 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5942 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5944 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5945 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5946 bonding, "bonding");
5947 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5948 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5950 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5951 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5953 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5954 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5955 port_id, RTE_UINT16);
5957 cmdline_parse_inst_t cmd_set_bonding_mode = {
5958 .f = cmd_set_bonding_mode_parsed,
5959 .help_str = "set bonding mode <mode_value> <port_id>: "
5960 "Set the bonding mode for port_id",
5963 (void *) &cmd_setbonding_mode_set,
5964 (void *) &cmd_setbonding_mode_bonding,
5965 (void *) &cmd_setbonding_mode_mode,
5966 (void *) &cmd_setbonding_mode_value,
5967 (void *) &cmd_setbonding_mode_port,
5972 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5973 struct cmd_set_bonding_lacp_dedicated_queues_result {
5974 cmdline_fixed_string_t set;
5975 cmdline_fixed_string_t bonding;
5976 cmdline_fixed_string_t lacp;
5977 cmdline_fixed_string_t dedicated_queues;
5979 cmdline_fixed_string_t mode;
5982 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5983 __rte_unused struct cmdline *cl,
5984 __rte_unused void *data)
5986 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5987 portid_t port_id = res->port_id;
5988 struct rte_port *port;
5990 port = &ports[port_id];
5992 /** Check if the port is not started **/
5993 if (port->port_status != RTE_PORT_STOPPED) {
5994 fprintf(stderr, "Please stop port %d first\n", port_id);
5998 if (!strcmp(res->mode, "enable")) {
5999 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
6000 printf("Dedicate queues for LACP control packets"
6003 printf("Enabling dedicate queues for LACP control "
6004 "packets on port %d failed\n", port_id);
6005 } else if (!strcmp(res->mode, "disable")) {
6006 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
6007 printf("Dedicated queues for LACP control packets "
6010 printf("Disabling dedicated queues for LACP control "
6011 "traffic on port %d failed\n", port_id);
6015 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6018 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6019 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6020 bonding, "bonding");
6021 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6022 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6024 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6025 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6026 dedicated_queues, "dedicated_queues");
6027 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6028 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6029 port_id, RTE_UINT16);
6030 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6031 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6032 mode, "enable#disable");
6034 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6035 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6036 .help_str = "set bonding lacp dedicated_queues <port_id> "
6038 "Enable/disable dedicated queues for LACP control traffic for port_id",
6041 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6042 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6043 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6044 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6045 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6046 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6051 /* *** SET BALANCE XMIT POLICY *** */
6052 struct cmd_set_bonding_balance_xmit_policy_result {
6053 cmdline_fixed_string_t set;
6054 cmdline_fixed_string_t bonding;
6055 cmdline_fixed_string_t balance_xmit_policy;
6057 cmdline_fixed_string_t policy;
6060 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6061 __rte_unused struct cmdline *cl,
6062 __rte_unused void *data)
6064 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6065 portid_t port_id = res->port_id;
6068 if (!strcmp(res->policy, "l2")) {
6069 policy = BALANCE_XMIT_POLICY_LAYER2;
6070 } else if (!strcmp(res->policy, "l23")) {
6071 policy = BALANCE_XMIT_POLICY_LAYER23;
6072 } else if (!strcmp(res->policy, "l34")) {
6073 policy = BALANCE_XMIT_POLICY_LAYER34;
6075 fprintf(stderr, "\t Invalid xmit policy selection");
6079 /* Set the bonding mode for the relevant port. */
6080 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6082 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6087 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6088 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6090 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6091 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6092 bonding, "bonding");
6093 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6094 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6095 balance_xmit_policy, "balance_xmit_policy");
6096 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6097 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6098 port_id, RTE_UINT16);
6099 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6100 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6101 policy, "l2#l23#l34");
6103 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6104 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6105 .help_str = "set bonding balance_xmit_policy <port_id> "
6107 "Set the bonding balance_xmit_policy for port_id",
6110 (void *)&cmd_setbonding_balance_xmit_policy_set,
6111 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6112 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6113 (void *)&cmd_setbonding_balance_xmit_policy_port,
6114 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6119 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6120 struct cmd_show_bonding_lacp_info_result {
6121 cmdline_fixed_string_t show;
6122 cmdline_fixed_string_t bonding;
6123 cmdline_fixed_string_t lacp;
6124 cmdline_fixed_string_t info;
6128 static void port_param_show(struct port_params *params)
6130 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6132 printf("\t\tsystem priority: %u\n", params->system_priority);
6133 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6134 printf("\t\tsystem mac address: %s\n", buf);
6135 printf("\t\tport key: %u\n", params->key);
6136 printf("\t\tport priority: %u\n", params->port_priority);
6137 printf("\t\tport number: %u\n", params->port_number);
6140 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6142 char a_state[256] = { 0 };
6143 char p_state[256] = { 0 };
6148 static const char * const state[] = {
6158 static const char * const selection[] = {
6164 for (i = 0; i < RTE_DIM(state); i++) {
6165 if ((info->actor_state >> i) & 1)
6166 a_len += snprintf(&a_state[a_len],
6167 RTE_DIM(a_state) - a_len, "%s ",
6170 if ((info->partner_state >> i) & 1)
6171 p_len += snprintf(&p_state[p_len],
6172 RTE_DIM(p_state) - p_len, "%s ",
6175 printf("\tAggregator port id: %u\n", info->agg_port_id);
6176 printf("\tselection: %s\n", selection[info->selected]);
6177 printf("\tActor detail info:\n");
6178 port_param_show(&info->actor);
6179 printf("\t\tport state: %s\n", a_state);
6180 printf("\tPartner detail info:\n");
6181 port_param_show(&info->partner);
6182 printf("\t\tport state: %s\n", p_state);
6186 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6188 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6189 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6190 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6191 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6192 printf("\taggregate wait timeout: %u ms\n",
6193 conf->aggregate_wait_timeout_ms);
6194 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6195 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6196 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6197 switch (conf->agg_selection) {
6199 printf("\taggregation mode: bandwidth\n");
6202 printf("\taggregation mode: stable\n");
6205 printf("\taggregation mode: count\n");
6208 printf("\taggregation mode: invalid\n");
6215 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6216 __rte_unused struct cmdline *cl,
6217 __rte_unused void *data)
6219 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6220 struct rte_eth_bond_8023ad_slave_info slave_info;
6221 struct rte_eth_bond_8023ad_conf port_conf;
6222 portid_t slaves[RTE_MAX_ETHPORTS];
6223 portid_t port_id = res->port_id;
6224 int num_active_slaves;
6229 bonding_mode = rte_eth_bond_mode_get(port_id);
6230 if (bonding_mode != BONDING_MODE_8023AD) {
6231 fprintf(stderr, "\tBonding mode is not mode 4\n");
6235 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6237 if (num_active_slaves < 0) {
6238 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6242 if (num_active_slaves == 0)
6243 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6246 printf("\tIEEE802.3 port: %u\n", port_id);
6247 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6249 fprintf(stderr, "\tGet bonded device %u info failed\n",
6253 lacp_conf_show(&port_conf);
6255 for (i = 0; i < num_active_slaves; i++) {
6256 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6259 fprintf(stderr, "\tGet slave device %u info failed\n",
6263 printf("\tSlave Port: %u\n", slaves[i]);
6264 lacp_slave_info_show(&slave_info);
6268 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6269 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6271 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6272 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6273 bonding, "bonding");
6274 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6275 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6277 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6278 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6280 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6281 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6282 port_id, RTE_UINT16);
6284 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6285 .f = cmd_show_bonding_lacp_info_parsed,
6286 .help_str = "show bonding lacp info <port_id> : "
6287 "Show bonding IEEE802.3 information for port_id",
6290 (void *)&cmd_show_bonding_lacp_info_show,
6291 (void *)&cmd_show_bonding_lacp_info_bonding,
6292 (void *)&cmd_show_bonding_lacp_info_lacp,
6293 (void *)&cmd_show_bonding_lacp_info_info,
6294 (void *)&cmd_show_bonding_lacp_info_port_id,
6299 /* *** SHOW NIC BONDING CONFIGURATION *** */
6300 struct cmd_show_bonding_config_result {
6301 cmdline_fixed_string_t show;
6302 cmdline_fixed_string_t bonding;
6303 cmdline_fixed_string_t config;
6307 static void cmd_show_bonding_config_parsed(void *parsed_result,
6308 __rte_unused struct cmdline *cl,
6309 __rte_unused void *data)
6311 struct cmd_show_bonding_config_result *res = parsed_result;
6312 int bonding_mode, agg_mode;
6313 portid_t slaves[RTE_MAX_ETHPORTS];
6314 int num_slaves, num_active_slaves;
6317 portid_t port_id = res->port_id;
6319 /* Display the bonding mode.*/
6320 bonding_mode = rte_eth_bond_mode_get(port_id);
6321 if (bonding_mode < 0) {
6322 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6326 printf("\tBonding mode: %d\n", bonding_mode);
6328 if (bonding_mode == BONDING_MODE_BALANCE ||
6329 bonding_mode == BONDING_MODE_8023AD) {
6330 int balance_xmit_policy;
6332 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6333 if (balance_xmit_policy < 0) {
6335 "\tFailed to get balance xmit policy for port = %d\n",
6339 printf("\tBalance Xmit Policy: ");
6341 switch (balance_xmit_policy) {
6342 case BALANCE_XMIT_POLICY_LAYER2:
6343 printf("BALANCE_XMIT_POLICY_LAYER2");
6345 case BALANCE_XMIT_POLICY_LAYER23:
6346 printf("BALANCE_XMIT_POLICY_LAYER23");
6348 case BALANCE_XMIT_POLICY_LAYER34:
6349 printf("BALANCE_XMIT_POLICY_LAYER34");
6356 if (bonding_mode == BONDING_MODE_8023AD) {
6357 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6358 printf("\tIEEE802.3AD Aggregator Mode: ");
6361 printf("bandwidth");
6373 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6375 if (num_slaves < 0) {
6376 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6380 if (num_slaves > 0) {
6381 printf("\tSlaves (%d): [", num_slaves);
6382 for (i = 0; i < num_slaves - 1; i++)
6383 printf("%d ", slaves[i]);
6385 printf("%d]\n", slaves[num_slaves - 1]);
6387 printf("\tSlaves: []\n");
6391 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6394 if (num_active_slaves < 0) {
6396 "\tFailed to get active slave list for port = %d\n",
6400 if (num_active_slaves > 0) {
6401 printf("\tActive Slaves (%d): [", num_active_slaves);
6402 for (i = 0; i < num_active_slaves - 1; i++)
6403 printf("%d ", slaves[i]);
6405 printf("%d]\n", slaves[num_active_slaves - 1]);
6408 printf("\tActive Slaves: []\n");
6412 primary_id = rte_eth_bond_primary_get(port_id);
6413 if (primary_id < 0) {
6414 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6418 printf("\tPrimary: [%d]\n", primary_id);
6422 cmdline_parse_token_string_t cmd_showbonding_config_show =
6423 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6425 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6426 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6427 bonding, "bonding");
6428 cmdline_parse_token_string_t cmd_showbonding_config_config =
6429 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6431 cmdline_parse_token_num_t cmd_showbonding_config_port =
6432 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6433 port_id, RTE_UINT16);
6435 cmdline_parse_inst_t cmd_show_bonding_config = {
6436 .f = cmd_show_bonding_config_parsed,
6437 .help_str = "show bonding config <port_id>: "
6438 "Show the bonding config for port_id",
6441 (void *)&cmd_showbonding_config_show,
6442 (void *)&cmd_showbonding_config_bonding,
6443 (void *)&cmd_showbonding_config_config,
6444 (void *)&cmd_showbonding_config_port,
6449 /* *** SET BONDING PRIMARY *** */
6450 struct cmd_set_bonding_primary_result {
6451 cmdline_fixed_string_t set;
6452 cmdline_fixed_string_t bonding;
6453 cmdline_fixed_string_t primary;
6458 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6459 __rte_unused struct cmdline *cl,
6460 __rte_unused void *data)
6462 struct cmd_set_bonding_primary_result *res = parsed_result;
6463 portid_t master_port_id = res->port_id;
6464 portid_t slave_port_id = res->slave_id;
6466 /* Set the primary slave for a bonded device. */
6467 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6468 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6475 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6476 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6478 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6480 bonding, "bonding");
6481 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6483 primary, "primary");
6484 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6485 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6486 slave_id, RTE_UINT16);
6487 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6488 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6489 port_id, RTE_UINT16);
6491 cmdline_parse_inst_t cmd_set_bonding_primary = {
6492 .f = cmd_set_bonding_primary_parsed,
6493 .help_str = "set bonding primary <slave_id> <port_id>: "
6494 "Set the primary slave for port_id",
6497 (void *)&cmd_setbonding_primary_set,
6498 (void *)&cmd_setbonding_primary_bonding,
6499 (void *)&cmd_setbonding_primary_primary,
6500 (void *)&cmd_setbonding_primary_slave,
6501 (void *)&cmd_setbonding_primary_port,
6506 /* *** ADD SLAVE *** */
6507 struct cmd_add_bonding_slave_result {
6508 cmdline_fixed_string_t add;
6509 cmdline_fixed_string_t bonding;
6510 cmdline_fixed_string_t slave;
6515 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6516 __rte_unused struct cmdline *cl,
6517 __rte_unused void *data)
6519 struct cmd_add_bonding_slave_result *res = parsed_result;
6520 portid_t master_port_id = res->port_id;
6521 portid_t slave_port_id = res->slave_id;
6523 /* add the slave for a bonded device. */
6524 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6526 "\t Failed to add slave %d to master port = %d.\n",
6527 slave_port_id, master_port_id);
6531 set_port_slave_flag(slave_port_id);
6534 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6535 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6537 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6538 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6539 bonding, "bonding");
6540 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6541 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6543 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6544 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6545 slave_id, RTE_UINT16);
6546 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6547 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6548 port_id, RTE_UINT16);
6550 cmdline_parse_inst_t cmd_add_bonding_slave = {
6551 .f = cmd_add_bonding_slave_parsed,
6552 .help_str = "add bonding slave <slave_id> <port_id>: "
6553 "Add a slave device to a bonded device",
6556 (void *)&cmd_addbonding_slave_add,
6557 (void *)&cmd_addbonding_slave_bonding,
6558 (void *)&cmd_addbonding_slave_slave,
6559 (void *)&cmd_addbonding_slave_slaveid,
6560 (void *)&cmd_addbonding_slave_port,
6565 /* *** REMOVE SLAVE *** */
6566 struct cmd_remove_bonding_slave_result {
6567 cmdline_fixed_string_t remove;
6568 cmdline_fixed_string_t bonding;
6569 cmdline_fixed_string_t slave;
6574 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6575 __rte_unused struct cmdline *cl,
6576 __rte_unused void *data)
6578 struct cmd_remove_bonding_slave_result *res = parsed_result;
6579 portid_t master_port_id = res->port_id;
6580 portid_t slave_port_id = res->slave_id;
6582 /* remove the slave from a bonded device. */
6583 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6585 "\t Failed to remove slave %d from master port = %d.\n",
6586 slave_port_id, master_port_id);
6590 clear_port_slave_flag(slave_port_id);
6593 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6594 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6596 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6597 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6598 bonding, "bonding");
6599 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6600 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6602 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6603 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6604 slave_id, RTE_UINT16);
6605 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6606 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6607 port_id, RTE_UINT16);
6609 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6610 .f = cmd_remove_bonding_slave_parsed,
6611 .help_str = "remove bonding slave <slave_id> <port_id>: "
6612 "Remove a slave device from a bonded device",
6615 (void *)&cmd_removebonding_slave_remove,
6616 (void *)&cmd_removebonding_slave_bonding,
6617 (void *)&cmd_removebonding_slave_slave,
6618 (void *)&cmd_removebonding_slave_slaveid,
6619 (void *)&cmd_removebonding_slave_port,
6624 /* *** CREATE BONDED DEVICE *** */
6625 struct cmd_create_bonded_device_result {
6626 cmdline_fixed_string_t create;
6627 cmdline_fixed_string_t bonded;
6628 cmdline_fixed_string_t device;
6633 static int bond_dev_num = 0;
6635 static void cmd_create_bonded_device_parsed(void *parsed_result,
6636 __rte_unused struct cmdline *cl,
6637 __rte_unused void *data)
6639 struct cmd_create_bonded_device_result *res = parsed_result;
6640 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6644 if (test_done == 0) {
6645 fprintf(stderr, "Please stop forwarding first\n");
6649 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6652 /* Create a new bonded device. */
6653 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6655 fprintf(stderr, "\t Failed to create bonded device.\n");
6658 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6661 /* Update number of ports */
6662 nb_ports = rte_eth_dev_count_avail();
6663 reconfig(port_id, res->socket);
6664 ret = rte_eth_promiscuous_enable(port_id);
6667 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6668 port_id, rte_strerror(-ret));
6670 ports[port_id].need_setup = 0;
6671 ports[port_id].port_status = RTE_PORT_STOPPED;
6676 cmdline_parse_token_string_t cmd_createbonded_device_create =
6677 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6679 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6680 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6682 cmdline_parse_token_string_t cmd_createbonded_device_device =
6683 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6685 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6686 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6688 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6689 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6692 cmdline_parse_inst_t cmd_create_bonded_device = {
6693 .f = cmd_create_bonded_device_parsed,
6694 .help_str = "create bonded device <mode> <socket>: "
6695 "Create a new bonded device with specific bonding mode and socket",
6698 (void *)&cmd_createbonded_device_create,
6699 (void *)&cmd_createbonded_device_bonded,
6700 (void *)&cmd_createbonded_device_device,
6701 (void *)&cmd_createbonded_device_mode,
6702 (void *)&cmd_createbonded_device_socket,
6707 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6708 struct cmd_set_bond_mac_addr_result {
6709 cmdline_fixed_string_t set;
6710 cmdline_fixed_string_t bonding;
6711 cmdline_fixed_string_t mac_addr;
6713 struct rte_ether_addr address;
6716 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6717 __rte_unused struct cmdline *cl,
6718 __rte_unused void *data)
6720 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6723 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6726 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6728 /* check the return value and print it if is < 0 */
6730 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6734 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6735 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6736 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6737 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6739 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6740 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6742 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6743 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6744 port_num, RTE_UINT16);
6745 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6746 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6748 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6749 .f = cmd_set_bond_mac_addr_parsed,
6751 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6753 (void *)&cmd_set_bond_mac_addr_set,
6754 (void *)&cmd_set_bond_mac_addr_bonding,
6755 (void *)&cmd_set_bond_mac_addr_mac,
6756 (void *)&cmd_set_bond_mac_addr_portnum,
6757 (void *)&cmd_set_bond_mac_addr_addr,
6763 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6764 struct cmd_set_bond_mon_period_result {
6765 cmdline_fixed_string_t set;
6766 cmdline_fixed_string_t bonding;
6767 cmdline_fixed_string_t mon_period;
6772 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6773 __rte_unused struct cmdline *cl,
6774 __rte_unused void *data)
6776 struct cmd_set_bond_mon_period_result *res = parsed_result;
6779 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6781 /* check the return value and print it if is < 0 */
6783 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6787 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6788 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6790 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6791 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6792 bonding, "bonding");
6793 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6794 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6795 mon_period, "mon_period");
6796 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6797 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6798 port_num, RTE_UINT16);
6799 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6800 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6801 period_ms, RTE_UINT32);
6803 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6804 .f = cmd_set_bond_mon_period_parsed,
6806 .help_str = "set bonding mon_period <port_id> <period_ms>",
6808 (void *)&cmd_set_bond_mon_period_set,
6809 (void *)&cmd_set_bond_mon_period_bonding,
6810 (void *)&cmd_set_bond_mon_period_mon_period,
6811 (void *)&cmd_set_bond_mon_period_portnum,
6812 (void *)&cmd_set_bond_mon_period_period_ms,
6819 struct cmd_set_bonding_agg_mode_policy_result {
6820 cmdline_fixed_string_t set;
6821 cmdline_fixed_string_t bonding;
6822 cmdline_fixed_string_t agg_mode;
6824 cmdline_fixed_string_t policy;
6829 cmd_set_bonding_agg_mode(void *parsed_result,
6830 __rte_unused struct cmdline *cl,
6831 __rte_unused void *data)
6833 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6834 uint8_t policy = AGG_BANDWIDTH;
6836 if (!strcmp(res->policy, "bandwidth"))
6837 policy = AGG_BANDWIDTH;
6838 else if (!strcmp(res->policy, "stable"))
6839 policy = AGG_STABLE;
6840 else if (!strcmp(res->policy, "count"))
6843 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6847 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6848 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6850 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6851 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6852 bonding, "bonding");
6854 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6855 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6856 agg_mode, "agg_mode");
6858 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6859 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6860 port_num, RTE_UINT16);
6862 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6863 TOKEN_STRING_INITIALIZER(
6864 struct cmd_set_bonding_balance_xmit_policy_result,
6865 policy, "stable#bandwidth#count");
6867 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6868 .f = cmd_set_bonding_agg_mode,
6870 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6872 (void *)&cmd_set_bonding_agg_mode_set,
6873 (void *)&cmd_set_bonding_agg_mode_bonding,
6874 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6875 (void *)&cmd_set_bonding_agg_mode_portnum,
6876 (void *)&cmd_set_bonding_agg_mode_policy_string,
6882 #endif /* RTE_NET_BOND */
6884 /* *** SET FORWARDING MODE *** */
6885 struct cmd_set_fwd_mode_result {
6886 cmdline_fixed_string_t set;
6887 cmdline_fixed_string_t fwd;
6888 cmdline_fixed_string_t mode;
6891 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6892 __rte_unused struct cmdline *cl,
6893 __rte_unused void *data)
6895 struct cmd_set_fwd_mode_result *res = parsed_result;
6898 set_pkt_forwarding_mode(res->mode);
6901 cmdline_parse_token_string_t cmd_setfwd_set =
6902 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6903 cmdline_parse_token_string_t cmd_setfwd_fwd =
6904 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6905 cmdline_parse_token_string_t cmd_setfwd_mode =
6906 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6907 "" /* defined at init */);
6909 cmdline_parse_inst_t cmd_set_fwd_mode = {
6910 .f = cmd_set_fwd_mode_parsed,
6912 .help_str = NULL, /* defined at init */
6914 (void *)&cmd_setfwd_set,
6915 (void *)&cmd_setfwd_fwd,
6916 (void *)&cmd_setfwd_mode,
6921 static void cmd_set_fwd_mode_init(void)
6924 static char token[128];
6925 static char help[256];
6926 cmdline_parse_token_string_t *token_struct;
6928 modes = list_pkt_forwarding_modes();
6929 snprintf(help, sizeof(help), "set fwd %s: "
6930 "Set packet forwarding mode", modes);
6931 cmd_set_fwd_mode.help_str = help;
6933 /* string token separator is # */
6934 for (c = token; *modes != '\0'; modes++)
6939 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6940 token_struct->string_data.str = token;
6943 /* *** SET RETRY FORWARDING MODE *** */
6944 struct cmd_set_fwd_retry_mode_result {
6945 cmdline_fixed_string_t set;
6946 cmdline_fixed_string_t fwd;
6947 cmdline_fixed_string_t mode;
6948 cmdline_fixed_string_t retry;
6951 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6952 __rte_unused struct cmdline *cl,
6953 __rte_unused void *data)
6955 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6958 set_pkt_forwarding_mode(res->mode);
6961 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6962 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6964 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6965 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6967 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6968 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6970 "" /* defined at init */);
6971 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6972 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6975 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6976 .f = cmd_set_fwd_retry_mode_parsed,
6978 .help_str = NULL, /* defined at init */
6980 (void *)&cmd_setfwd_retry_set,
6981 (void *)&cmd_setfwd_retry_fwd,
6982 (void *)&cmd_setfwd_retry_mode,
6983 (void *)&cmd_setfwd_retry_retry,
6988 static void cmd_set_fwd_retry_mode_init(void)
6991 static char token[128];
6992 static char help[256];
6993 cmdline_parse_token_string_t *token_struct;
6995 modes = list_pkt_forwarding_retry_modes();
6996 snprintf(help, sizeof(help), "set fwd %s retry: "
6997 "Set packet forwarding mode with retry", modes);
6998 cmd_set_fwd_retry_mode.help_str = help;
7000 /* string token separator is # */
7001 for (c = token; *modes != '\0'; modes++)
7006 token_struct = (cmdline_parse_token_string_t *)
7007 cmd_set_fwd_retry_mode.tokens[2];
7008 token_struct->string_data.str = token;
7011 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
7012 struct cmd_set_burst_tx_retry_result {
7013 cmdline_fixed_string_t set;
7014 cmdline_fixed_string_t burst;
7015 cmdline_fixed_string_t tx;
7016 cmdline_fixed_string_t delay;
7018 cmdline_fixed_string_t retry;
7022 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7023 __rte_unused struct cmdline *cl,
7024 __rte_unused void *data)
7026 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7028 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7029 && !strcmp(res->tx, "tx")) {
7030 if (!strcmp(res->delay, "delay"))
7031 burst_tx_delay_time = res->time;
7032 if (!strcmp(res->retry, "retry"))
7033 burst_tx_retry_num = res->retry_num;
7038 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7039 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7040 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7041 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7043 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7044 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7045 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7046 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7047 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7048 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7050 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7051 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7052 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7053 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7056 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7057 .f = cmd_set_burst_tx_retry_parsed,
7058 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7060 (void *)&cmd_set_burst_tx_retry_set,
7061 (void *)&cmd_set_burst_tx_retry_burst,
7062 (void *)&cmd_set_burst_tx_retry_tx,
7063 (void *)&cmd_set_burst_tx_retry_delay,
7064 (void *)&cmd_set_burst_tx_retry_time,
7065 (void *)&cmd_set_burst_tx_retry_retry,
7066 (void *)&cmd_set_burst_tx_retry_retry_num,
7071 /* *** SET PROMISC MODE *** */
7072 struct cmd_set_promisc_mode_result {
7073 cmdline_fixed_string_t set;
7074 cmdline_fixed_string_t promisc;
7075 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7076 uint16_t port_num; /* valid if "allports" argument == 0 */
7077 cmdline_fixed_string_t mode;
7080 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7081 __rte_unused struct cmdline *cl,
7084 struct cmd_set_promisc_mode_result *res = parsed_result;
7088 if (!strcmp(res->mode, "on"))
7095 RTE_ETH_FOREACH_DEV(i)
7096 eth_set_promisc_mode(i, enable);
7098 eth_set_promisc_mode(res->port_num, enable);
7102 cmdline_parse_token_string_t cmd_setpromisc_set =
7103 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7104 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7105 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7107 cmdline_parse_token_string_t cmd_setpromisc_portall =
7108 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7110 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7111 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7113 cmdline_parse_token_string_t cmd_setpromisc_mode =
7114 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7117 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7118 .f = cmd_set_promisc_mode_parsed,
7120 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7122 (void *)&cmd_setpromisc_set,
7123 (void *)&cmd_setpromisc_promisc,
7124 (void *)&cmd_setpromisc_portall,
7125 (void *)&cmd_setpromisc_mode,
7130 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7131 .f = cmd_set_promisc_mode_parsed,
7133 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7135 (void *)&cmd_setpromisc_set,
7136 (void *)&cmd_setpromisc_promisc,
7137 (void *)&cmd_setpromisc_portnum,
7138 (void *)&cmd_setpromisc_mode,
7143 /* *** SET ALLMULTI MODE *** */
7144 struct cmd_set_allmulti_mode_result {
7145 cmdline_fixed_string_t set;
7146 cmdline_fixed_string_t allmulti;
7147 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7148 uint16_t port_num; /* valid if "allports" argument == 0 */
7149 cmdline_fixed_string_t mode;
7152 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7153 __rte_unused struct cmdline *cl,
7156 struct cmd_set_allmulti_mode_result *res = parsed_result;
7160 if (!strcmp(res->mode, "on"))
7167 RTE_ETH_FOREACH_DEV(i) {
7168 eth_set_allmulticast_mode(i, enable);
7172 eth_set_allmulticast_mode(res->port_num, enable);
7176 cmdline_parse_token_string_t cmd_setallmulti_set =
7177 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7178 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7179 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7181 cmdline_parse_token_string_t cmd_setallmulti_portall =
7182 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7184 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7185 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7187 cmdline_parse_token_string_t cmd_setallmulti_mode =
7188 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7191 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7192 .f = cmd_set_allmulti_mode_parsed,
7194 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7196 (void *)&cmd_setallmulti_set,
7197 (void *)&cmd_setallmulti_allmulti,
7198 (void *)&cmd_setallmulti_portall,
7199 (void *)&cmd_setallmulti_mode,
7204 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7205 .f = cmd_set_allmulti_mode_parsed,
7207 .help_str = "set allmulti <port_id> on|off: "
7208 "Set allmulti mode on port_id",
7210 (void *)&cmd_setallmulti_set,
7211 (void *)&cmd_setallmulti_allmulti,
7212 (void *)&cmd_setallmulti_portnum,
7213 (void *)&cmd_setallmulti_mode,
7218 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7219 struct cmd_link_flow_ctrl_show {
7220 cmdline_fixed_string_t show;
7221 cmdline_fixed_string_t port;
7223 cmdline_fixed_string_t flow_ctrl;
7226 cmdline_parse_token_string_t cmd_lfc_show_show =
7227 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7229 cmdline_parse_token_string_t cmd_lfc_show_port =
7230 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7232 cmdline_parse_token_num_t cmd_lfc_show_portid =
7233 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7234 port_id, RTE_UINT16);
7235 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7236 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7237 flow_ctrl, "flow_ctrl");
7240 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7241 __rte_unused struct cmdline *cl,
7242 __rte_unused void *data)
7244 struct cmd_link_flow_ctrl_show *res = parsed_result;
7245 static const char *info_border = "*********************";
7246 struct rte_eth_fc_conf fc_conf;
7247 bool rx_fc_en = false;
7248 bool tx_fc_en = false;
7251 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7254 "Failed to get current flow ctrl information: err = %d\n",
7259 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7261 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7264 printf("\n%s Flow control infos for port %-2d %s\n",
7265 info_border, res->port_id, info_border);
7266 printf("FC mode:\n");
7267 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7268 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7269 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7270 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7271 printf("High waterline: 0x%x\n", fc_conf.high_water);
7272 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7273 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7274 printf("Forward MAC control frames: %s\n",
7275 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7276 printf("\n%s************** End ***********%s\n",
7277 info_border, info_border);
7280 cmdline_parse_inst_t cmd_link_flow_control_show = {
7281 .f = cmd_link_flow_ctrl_show_parsed,
7283 .help_str = "show port <port_id> flow_ctrl",
7285 (void *)&cmd_lfc_show_show,
7286 (void *)&cmd_lfc_show_port,
7287 (void *)&cmd_lfc_show_portid,
7288 (void *)&cmd_lfc_show_flow_ctrl,
7293 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7294 struct cmd_link_flow_ctrl_set_result {
7295 cmdline_fixed_string_t set;
7296 cmdline_fixed_string_t flow_ctrl;
7297 cmdline_fixed_string_t rx;
7298 cmdline_fixed_string_t rx_lfc_mode;
7299 cmdline_fixed_string_t tx;
7300 cmdline_fixed_string_t tx_lfc_mode;
7301 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7302 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7303 cmdline_fixed_string_t autoneg_str;
7304 cmdline_fixed_string_t autoneg;
7305 cmdline_fixed_string_t hw_str;
7306 uint32_t high_water;
7307 cmdline_fixed_string_t lw_str;
7309 cmdline_fixed_string_t pt_str;
7310 uint16_t pause_time;
7311 cmdline_fixed_string_t xon_str;
7316 cmdline_parse_token_string_t cmd_lfc_set_set =
7317 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7319 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7320 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7321 flow_ctrl, "flow_ctrl");
7322 cmdline_parse_token_string_t cmd_lfc_set_rx =
7323 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7325 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7326 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7327 rx_lfc_mode, "on#off");
7328 cmdline_parse_token_string_t cmd_lfc_set_tx =
7329 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7331 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7332 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7333 tx_lfc_mode, "on#off");
7334 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7335 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7336 hw_str, "high_water");
7337 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7338 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7339 high_water, RTE_UINT32);
7340 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7341 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7342 lw_str, "low_water");
7343 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7344 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7345 low_water, RTE_UINT32);
7346 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7347 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7348 pt_str, "pause_time");
7349 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7350 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7351 pause_time, RTE_UINT16);
7352 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7353 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7354 xon_str, "send_xon");
7355 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7356 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7357 send_xon, RTE_UINT16);
7358 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7359 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7360 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7361 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7362 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7363 mac_ctrl_frame_fwd_mode, "on#off");
7364 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7365 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7366 autoneg_str, "autoneg");
7367 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7368 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7370 cmdline_parse_token_num_t cmd_lfc_set_portid =
7371 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7372 port_id, RTE_UINT16);
7374 /* forward declaration */
7376 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7379 cmdline_parse_inst_t cmd_link_flow_control_set = {
7380 .f = cmd_link_flow_ctrl_set_parsed,
7382 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7383 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7384 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7386 (void *)&cmd_lfc_set_set,
7387 (void *)&cmd_lfc_set_flow_ctrl,
7388 (void *)&cmd_lfc_set_rx,
7389 (void *)&cmd_lfc_set_rx_mode,
7390 (void *)&cmd_lfc_set_tx,
7391 (void *)&cmd_lfc_set_tx_mode,
7392 (void *)&cmd_lfc_set_high_water,
7393 (void *)&cmd_lfc_set_low_water,
7394 (void *)&cmd_lfc_set_pause_time,
7395 (void *)&cmd_lfc_set_send_xon,
7396 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7397 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7398 (void *)&cmd_lfc_set_autoneg_str,
7399 (void *)&cmd_lfc_set_autoneg,
7400 (void *)&cmd_lfc_set_portid,
7405 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7406 .f = cmd_link_flow_ctrl_set_parsed,
7407 .data = (void *)&cmd_link_flow_control_set_rx,
7408 .help_str = "set flow_ctrl rx on|off <port_id>: "
7409 "Change rx flow control parameter",
7411 (void *)&cmd_lfc_set_set,
7412 (void *)&cmd_lfc_set_flow_ctrl,
7413 (void *)&cmd_lfc_set_rx,
7414 (void *)&cmd_lfc_set_rx_mode,
7415 (void *)&cmd_lfc_set_portid,
7420 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7421 .f = cmd_link_flow_ctrl_set_parsed,
7422 .data = (void *)&cmd_link_flow_control_set_tx,
7423 .help_str = "set flow_ctrl tx on|off <port_id>: "
7424 "Change tx flow control parameter",
7426 (void *)&cmd_lfc_set_set,
7427 (void *)&cmd_lfc_set_flow_ctrl,
7428 (void *)&cmd_lfc_set_tx,
7429 (void *)&cmd_lfc_set_tx_mode,
7430 (void *)&cmd_lfc_set_portid,
7435 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7436 .f = cmd_link_flow_ctrl_set_parsed,
7437 .data = (void *)&cmd_link_flow_control_set_hw,
7438 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7439 "Change high water flow control parameter",
7441 (void *)&cmd_lfc_set_set,
7442 (void *)&cmd_lfc_set_flow_ctrl,
7443 (void *)&cmd_lfc_set_high_water_str,
7444 (void *)&cmd_lfc_set_high_water,
7445 (void *)&cmd_lfc_set_portid,
7450 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7451 .f = cmd_link_flow_ctrl_set_parsed,
7452 .data = (void *)&cmd_link_flow_control_set_lw,
7453 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7454 "Change low water flow control parameter",
7456 (void *)&cmd_lfc_set_set,
7457 (void *)&cmd_lfc_set_flow_ctrl,
7458 (void *)&cmd_lfc_set_low_water_str,
7459 (void *)&cmd_lfc_set_low_water,
7460 (void *)&cmd_lfc_set_portid,
7465 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7466 .f = cmd_link_flow_ctrl_set_parsed,
7467 .data = (void *)&cmd_link_flow_control_set_pt,
7468 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7469 "Change pause time flow control parameter",
7471 (void *)&cmd_lfc_set_set,
7472 (void *)&cmd_lfc_set_flow_ctrl,
7473 (void *)&cmd_lfc_set_pause_time_str,
7474 (void *)&cmd_lfc_set_pause_time,
7475 (void *)&cmd_lfc_set_portid,
7480 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7481 .f = cmd_link_flow_ctrl_set_parsed,
7482 .data = (void *)&cmd_link_flow_control_set_xon,
7483 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7484 "Change send_xon flow control parameter",
7486 (void *)&cmd_lfc_set_set,
7487 (void *)&cmd_lfc_set_flow_ctrl,
7488 (void *)&cmd_lfc_set_send_xon_str,
7489 (void *)&cmd_lfc_set_send_xon,
7490 (void *)&cmd_lfc_set_portid,
7495 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7496 .f = cmd_link_flow_ctrl_set_parsed,
7497 .data = (void *)&cmd_link_flow_control_set_macfwd,
7498 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7499 "Change mac ctrl fwd flow control parameter",
7501 (void *)&cmd_lfc_set_set,
7502 (void *)&cmd_lfc_set_flow_ctrl,
7503 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7504 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7505 (void *)&cmd_lfc_set_portid,
7510 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7511 .f = cmd_link_flow_ctrl_set_parsed,
7512 .data = (void *)&cmd_link_flow_control_set_autoneg,
7513 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7514 "Change autoneg flow control parameter",
7516 (void *)&cmd_lfc_set_set,
7517 (void *)&cmd_lfc_set_flow_ctrl,
7518 (void *)&cmd_lfc_set_autoneg_str,
7519 (void *)&cmd_lfc_set_autoneg,
7520 (void *)&cmd_lfc_set_portid,
7526 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7527 __rte_unused struct cmdline *cl,
7530 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7531 cmdline_parse_inst_t *cmd = data;
7532 struct rte_eth_fc_conf fc_conf;
7538 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7539 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7540 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7541 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7543 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7544 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7547 /* Partial command line, retrieve current configuration */
7549 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7552 "cannot get current flow ctrl parameters, return code = %d\n",
7557 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7558 (fc_conf.mode == RTE_ETH_FC_FULL))
7560 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7561 (fc_conf.mode == RTE_ETH_FC_FULL))
7565 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7566 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7568 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7569 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7571 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7573 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7574 fc_conf.high_water = res->high_water;
7576 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7577 fc_conf.low_water = res->low_water;
7579 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7580 fc_conf.pause_time = res->pause_time;
7582 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7583 fc_conf.send_xon = res->send_xon;
7585 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7586 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7587 fc_conf.mac_ctrl_frame_fwd = 1;
7589 fc_conf.mac_ctrl_frame_fwd = 0;
7592 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7593 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7595 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7598 "bad flow control parameter, return code = %d\n",
7602 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7603 struct cmd_priority_flow_ctrl_set_result {
7604 cmdline_fixed_string_t set;
7605 cmdline_fixed_string_t pfc_ctrl;
7606 cmdline_fixed_string_t rx;
7607 cmdline_fixed_string_t rx_pfc_mode;
7608 cmdline_fixed_string_t tx;
7609 cmdline_fixed_string_t tx_pfc_mode;
7610 uint32_t high_water;
7612 uint16_t pause_time;
7618 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7619 __rte_unused struct cmdline *cl,
7620 __rte_unused void *data)
7622 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7623 struct rte_eth_pfc_conf pfc_conf;
7624 int rx_fc_enable, tx_fc_enable;
7628 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7629 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7630 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7631 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7633 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7634 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7637 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7638 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7639 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7640 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7641 pfc_conf.fc.high_water = res->high_water;
7642 pfc_conf.fc.low_water = res->low_water;
7643 pfc_conf.fc.pause_time = res->pause_time;
7644 pfc_conf.priority = res->priority;
7646 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7649 "bad priority flow control parameter, return code = %d\n",
7653 cmdline_parse_token_string_t cmd_pfc_set_set =
7654 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7656 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7657 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7658 pfc_ctrl, "pfc_ctrl");
7659 cmdline_parse_token_string_t cmd_pfc_set_rx =
7660 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7662 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7663 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7664 rx_pfc_mode, "on#off");
7665 cmdline_parse_token_string_t cmd_pfc_set_tx =
7666 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7668 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7669 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7670 tx_pfc_mode, "on#off");
7671 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7672 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7673 high_water, RTE_UINT32);
7674 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7675 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7676 low_water, RTE_UINT32);
7677 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7678 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7679 pause_time, RTE_UINT16);
7680 cmdline_parse_token_num_t cmd_pfc_set_priority =
7681 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7682 priority, RTE_UINT8);
7683 cmdline_parse_token_num_t cmd_pfc_set_portid =
7684 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7685 port_id, RTE_UINT16);
7687 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7688 .f = cmd_priority_flow_ctrl_set_parsed,
7690 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7691 "<pause_time> <priority> <port_id>: "
7692 "Configure the Ethernet priority flow control",
7694 (void *)&cmd_pfc_set_set,
7695 (void *)&cmd_pfc_set_flow_ctrl,
7696 (void *)&cmd_pfc_set_rx,
7697 (void *)&cmd_pfc_set_rx_mode,
7698 (void *)&cmd_pfc_set_tx,
7699 (void *)&cmd_pfc_set_tx_mode,
7700 (void *)&cmd_pfc_set_high_water,
7701 (void *)&cmd_pfc_set_low_water,
7702 (void *)&cmd_pfc_set_pause_time,
7703 (void *)&cmd_pfc_set_priority,
7704 (void *)&cmd_pfc_set_portid,
7709 struct cmd_queue_priority_flow_ctrl_set_result {
7710 cmdline_fixed_string_t set;
7711 cmdline_fixed_string_t pfc_queue_ctrl;
7713 cmdline_fixed_string_t rx;
7714 cmdline_fixed_string_t rx_pfc_mode;
7717 cmdline_fixed_string_t tx;
7718 cmdline_fixed_string_t tx_pfc_mode;
7721 uint16_t pause_time;
7725 cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7726 __rte_unused struct cmdline *cl,
7727 __rte_unused void *data)
7729 struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7730 struct rte_eth_pfc_queue_conf pfc_queue_conf;
7731 int rx_fc_enable, tx_fc_enable;
7735 * Rx on/off, flow control is enabled/disabled on RX side. This can
7736 * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7737 * side. Tx on/off, flow control is enabled/disabled on TX side. This
7738 * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7741 static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7742 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7743 {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7746 memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7747 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7748 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7749 pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7750 pfc_queue_conf.rx_pause.tc = res->tx_tc;
7751 pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7752 pfc_queue_conf.tx_pause.tc = res->rx_tc;
7753 pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7754 pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7756 ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7760 "bad queue priority flow control parameter, rc = %d\n",
7765 cmdline_parse_token_string_t cmd_q_pfc_set_set =
7766 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7768 cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7769 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7770 pfc_queue_ctrl, "pfc_queue_ctrl");
7771 cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7772 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7773 port_id, RTE_UINT16);
7774 cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7775 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7777 cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7778 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7779 rx_pfc_mode, "on#off");
7780 cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7781 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7782 tx_qid, RTE_UINT16);
7783 cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7784 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7786 cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7787 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7789 cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7790 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7791 tx_pfc_mode, "on#off");
7792 cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7793 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7794 rx_qid, RTE_UINT16);
7795 cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7796 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7798 cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7799 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7800 pause_time, RTE_UINT16);
7802 cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7803 .f = cmd_queue_priority_flow_ctrl_set_parsed,
7805 .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7806 "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7807 "Configure the Ethernet queue priority flow control",
7809 (void *)&cmd_q_pfc_set_set,
7810 (void *)&cmd_q_pfc_set_flow_ctrl,
7811 (void *)&cmd_q_pfc_set_portid,
7812 (void *)&cmd_q_pfc_set_rx,
7813 (void *)&cmd_q_pfc_set_rx_mode,
7814 (void *)&cmd_q_pfc_set_tx_qid,
7815 (void *)&cmd_q_pfc_set_tx_tc,
7816 (void *)&cmd_q_pfc_set_tx,
7817 (void *)&cmd_q_pfc_set_tx_mode,
7818 (void *)&cmd_q_pfc_set_rx_qid,
7819 (void *)&cmd_q_pfc_set_rx_tc,
7820 (void *)&cmd_q_pfc_set_pause_time,
7825 /* *** RESET CONFIGURATION *** */
7826 struct cmd_reset_result {
7827 cmdline_fixed_string_t reset;
7828 cmdline_fixed_string_t def;
7831 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7833 __rte_unused void *data)
7835 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7836 set_def_fwd_config();
7839 cmdline_parse_token_string_t cmd_reset_set =
7840 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7841 cmdline_parse_token_string_t cmd_reset_def =
7842 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7845 cmdline_parse_inst_t cmd_reset = {
7846 .f = cmd_reset_parsed,
7848 .help_str = "set default: Reset default forwarding configuration",
7850 (void *)&cmd_reset_set,
7851 (void *)&cmd_reset_def,
7856 /* *** START FORWARDING *** */
7857 struct cmd_start_result {
7858 cmdline_fixed_string_t start;
7861 cmdline_parse_token_string_t cmd_start_start =
7862 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7864 static void cmd_start_parsed(__rte_unused void *parsed_result,
7865 __rte_unused struct cmdline *cl,
7866 __rte_unused void *data)
7868 start_packet_forwarding(0);
7871 cmdline_parse_inst_t cmd_start = {
7872 .f = cmd_start_parsed,
7874 .help_str = "start: Start packet forwarding",
7876 (void *)&cmd_start_start,
7881 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7882 struct cmd_start_tx_first_result {
7883 cmdline_fixed_string_t start;
7884 cmdline_fixed_string_t tx_first;
7888 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7889 __rte_unused struct cmdline *cl,
7890 __rte_unused void *data)
7892 start_packet_forwarding(1);
7895 cmdline_parse_token_string_t cmd_start_tx_first_start =
7896 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7898 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7899 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7900 tx_first, "tx_first");
7902 cmdline_parse_inst_t cmd_start_tx_first = {
7903 .f = cmd_start_tx_first_parsed,
7905 .help_str = "start tx_first: Start packet forwarding, "
7906 "after sending 1 burst of packets",
7908 (void *)&cmd_start_tx_first_start,
7909 (void *)&cmd_start_tx_first_tx_first,
7914 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7915 struct cmd_start_tx_first_n_result {
7916 cmdline_fixed_string_t start;
7917 cmdline_fixed_string_t tx_first;
7922 cmd_start_tx_first_n_parsed(void *parsed_result,
7923 __rte_unused struct cmdline *cl,
7924 __rte_unused void *data)
7926 struct cmd_start_tx_first_n_result *res = parsed_result;
7928 start_packet_forwarding(res->tx_num);
7931 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7932 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7934 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7935 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7936 tx_first, "tx_first");
7937 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7938 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7939 tx_num, RTE_UINT32);
7941 cmdline_parse_inst_t cmd_start_tx_first_n = {
7942 .f = cmd_start_tx_first_n_parsed,
7944 .help_str = "start tx_first <num>: "
7945 "packet forwarding, after sending <num> bursts of packets",
7947 (void *)&cmd_start_tx_first_n_start,
7948 (void *)&cmd_start_tx_first_n_tx_first,
7949 (void *)&cmd_start_tx_first_n_tx_num,
7954 /* *** SET LINK UP *** */
7955 struct cmd_set_link_up_result {
7956 cmdline_fixed_string_t set;
7957 cmdline_fixed_string_t link_up;
7958 cmdline_fixed_string_t port;
7962 cmdline_parse_token_string_t cmd_set_link_up_set =
7963 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7964 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7965 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7967 cmdline_parse_token_string_t cmd_set_link_up_port =
7968 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7969 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7970 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7973 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7974 __rte_unused struct cmdline *cl,
7975 __rte_unused void *data)
7977 struct cmd_set_link_up_result *res = parsed_result;
7978 dev_set_link_up(res->port_id);
7981 cmdline_parse_inst_t cmd_set_link_up = {
7982 .f = cmd_set_link_up_parsed,
7984 .help_str = "set link-up port <port id>",
7986 (void *)&cmd_set_link_up_set,
7987 (void *)&cmd_set_link_up_link_up,
7988 (void *)&cmd_set_link_up_port,
7989 (void *)&cmd_set_link_up_port_id,
7994 /* *** SET LINK DOWN *** */
7995 struct cmd_set_link_down_result {
7996 cmdline_fixed_string_t set;
7997 cmdline_fixed_string_t link_down;
7998 cmdline_fixed_string_t port;
8002 cmdline_parse_token_string_t cmd_set_link_down_set =
8003 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
8004 cmdline_parse_token_string_t cmd_set_link_down_link_down =
8005 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
8007 cmdline_parse_token_string_t cmd_set_link_down_port =
8008 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
8009 cmdline_parse_token_num_t cmd_set_link_down_port_id =
8010 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
8013 static void cmd_set_link_down_parsed(
8014 __rte_unused void *parsed_result,
8015 __rte_unused struct cmdline *cl,
8016 __rte_unused void *data)
8018 struct cmd_set_link_down_result *res = parsed_result;
8019 dev_set_link_down(res->port_id);
8022 cmdline_parse_inst_t cmd_set_link_down = {
8023 .f = cmd_set_link_down_parsed,
8025 .help_str = "set link-down port <port id>",
8027 (void *)&cmd_set_link_down_set,
8028 (void *)&cmd_set_link_down_link_down,
8029 (void *)&cmd_set_link_down_port,
8030 (void *)&cmd_set_link_down_port_id,
8035 /* *** SHOW CFG *** */
8036 struct cmd_showcfg_result {
8037 cmdline_fixed_string_t show;
8038 cmdline_fixed_string_t cfg;
8039 cmdline_fixed_string_t what;
8042 static void cmd_showcfg_parsed(void *parsed_result,
8043 __rte_unused struct cmdline *cl,
8044 __rte_unused void *data)
8046 struct cmd_showcfg_result *res = parsed_result;
8047 if (!strcmp(res->what, "rxtx"))
8048 rxtx_config_display();
8049 else if (!strcmp(res->what, "cores"))
8050 fwd_lcores_config_display();
8051 else if (!strcmp(res->what, "fwd"))
8052 pkt_fwd_config_display(&cur_fwd_config);
8053 else if (!strcmp(res->what, "rxoffs"))
8054 show_rx_pkt_offsets();
8055 else if (!strcmp(res->what, "rxpkts"))
8056 show_rx_pkt_segments();
8057 else if (!strcmp(res->what, "txpkts"))
8058 show_tx_pkt_segments();
8059 else if (!strcmp(res->what, "txtimes"))
8060 show_tx_pkt_times();
8063 cmdline_parse_token_string_t cmd_showcfg_show =
8064 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
8065 cmdline_parse_token_string_t cmd_showcfg_port =
8066 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
8067 cmdline_parse_token_string_t cmd_showcfg_what =
8068 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
8069 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
8071 cmdline_parse_inst_t cmd_showcfg = {
8072 .f = cmd_showcfg_parsed,
8074 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
8076 (void *)&cmd_showcfg_show,
8077 (void *)&cmd_showcfg_port,
8078 (void *)&cmd_showcfg_what,
8083 /* *** SHOW ALL PORT INFO *** */
8084 struct cmd_showportall_result {
8085 cmdline_fixed_string_t show;
8086 cmdline_fixed_string_t port;
8087 cmdline_fixed_string_t what;
8088 cmdline_fixed_string_t all;
8091 static void cmd_showportall_parsed(void *parsed_result,
8092 __rte_unused struct cmdline *cl,
8093 __rte_unused void *data)
8097 struct cmd_showportall_result *res = parsed_result;
8098 if (!strcmp(res->show, "clear")) {
8099 if (!strcmp(res->what, "stats"))
8100 RTE_ETH_FOREACH_DEV(i)
8102 else if (!strcmp(res->what, "xstats"))
8103 RTE_ETH_FOREACH_DEV(i)
8104 nic_xstats_clear(i);
8105 } else if (!strcmp(res->what, "info"))
8106 RTE_ETH_FOREACH_DEV(i)
8107 port_infos_display(i);
8108 else if (!strcmp(res->what, "summary")) {
8109 port_summary_header_display();
8110 RTE_ETH_FOREACH_DEV(i)
8111 port_summary_display(i);
8113 else if (!strcmp(res->what, "stats"))
8114 RTE_ETH_FOREACH_DEV(i)
8115 nic_stats_display(i);
8116 else if (!strcmp(res->what, "xstats"))
8117 RTE_ETH_FOREACH_DEV(i)
8118 nic_xstats_display(i);
8119 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8120 else if (!strcmp(res->what, "fdir"))
8121 RTE_ETH_FOREACH_DEV(i)
8124 else if (!strcmp(res->what, "dcb_tc"))
8125 RTE_ETH_FOREACH_DEV(i)
8126 port_dcb_info_display(i);
8129 cmdline_parse_token_string_t cmd_showportall_show =
8130 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
8132 cmdline_parse_token_string_t cmd_showportall_port =
8133 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8134 cmdline_parse_token_string_t cmd_showportall_what =
8135 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8136 "info#summary#stats#xstats#fdir#dcb_tc");
8137 cmdline_parse_token_string_t cmd_showportall_all =
8138 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8139 cmdline_parse_inst_t cmd_showportall = {
8140 .f = cmd_showportall_parsed,
8142 .help_str = "show|clear port "
8143 "info|summary|stats|xstats|fdir|dcb_tc all",
8145 (void *)&cmd_showportall_show,
8146 (void *)&cmd_showportall_port,
8147 (void *)&cmd_showportall_what,
8148 (void *)&cmd_showportall_all,
8153 /* *** SHOW PORT INFO *** */
8154 struct cmd_showport_result {
8155 cmdline_fixed_string_t show;
8156 cmdline_fixed_string_t port;
8157 cmdline_fixed_string_t what;
8161 static void cmd_showport_parsed(void *parsed_result,
8162 __rte_unused struct cmdline *cl,
8163 __rte_unused void *data)
8165 struct cmd_showport_result *res = parsed_result;
8166 if (!strcmp(res->show, "clear")) {
8167 if (!strcmp(res->what, "stats"))
8168 nic_stats_clear(res->portnum);
8169 else if (!strcmp(res->what, "xstats"))
8170 nic_xstats_clear(res->portnum);
8171 } else if (!strcmp(res->what, "info"))
8172 port_infos_display(res->portnum);
8173 else if (!strcmp(res->what, "summary")) {
8174 port_summary_header_display();
8175 port_summary_display(res->portnum);
8177 else if (!strcmp(res->what, "stats"))
8178 nic_stats_display(res->portnum);
8179 else if (!strcmp(res->what, "xstats"))
8180 nic_xstats_display(res->portnum);
8181 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8182 else if (!strcmp(res->what, "fdir"))
8183 fdir_get_infos(res->portnum);
8185 else if (!strcmp(res->what, "dcb_tc"))
8186 port_dcb_info_display(res->portnum);
8189 cmdline_parse_token_string_t cmd_showport_show =
8190 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8192 cmdline_parse_token_string_t cmd_showport_port =
8193 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8194 cmdline_parse_token_string_t cmd_showport_what =
8195 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8196 "info#summary#stats#xstats#fdir#dcb_tc");
8197 cmdline_parse_token_num_t cmd_showport_portnum =
8198 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8200 cmdline_parse_inst_t cmd_showport = {
8201 .f = cmd_showport_parsed,
8203 .help_str = "show|clear port "
8204 "info|summary|stats|xstats|fdir|dcb_tc "
8207 (void *)&cmd_showport_show,
8208 (void *)&cmd_showport_port,
8209 (void *)&cmd_showport_what,
8210 (void *)&cmd_showport_portnum,
8215 /* *** show port representors information *** */
8216 struct cmd_representor_info_result {
8217 cmdline_fixed_string_t cmd_show;
8218 cmdline_fixed_string_t cmd_port;
8219 cmdline_fixed_string_t cmd_info;
8220 cmdline_fixed_string_t cmd_keyword;
8225 cmd_representor_info_parsed(void *parsed_result,
8226 __rte_unused struct cmdline *cl,
8227 __rte_unused void *data)
8229 struct cmd_representor_info_result *res = parsed_result;
8230 struct rte_eth_representor_info *info;
8231 struct rte_eth_representor_range *range;
8232 uint32_t range_diff;
8237 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8238 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8242 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8245 "Failed to get the number of representor info ranges for port %hu: %s\n",
8246 res->cmd_pid, rte_strerror(-ret));
8251 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8254 "Failed to allocate memory for representor info for port %hu\n",
8258 info->nb_ranges_alloc = num;
8260 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8263 "Failed to get the representor info for port %hu: %s\n",
8264 res->cmd_pid, rte_strerror(-ret));
8269 printf("Port controller: %hu\n", info->controller);
8270 printf("Port PF: %hu\n", info->pf);
8272 printf("Ranges: %u\n", info->nb_ranges);
8273 for (i = 0; i < info->nb_ranges; i++) {
8274 range = &info->ranges[i];
8275 range_diff = range->id_end - range->id_base;
8277 printf("%u. ", i + 1);
8278 printf("'%s' ", range->name);
8280 printf("[%u-%u]: ", range->id_base, range->id_end);
8282 printf("[%u]: ", range->id_base);
8284 printf("Controller %d, PF %d", range->controller, range->pf);
8286 switch (range->type) {
8287 case RTE_ETH_REPRESENTOR_NONE:
8290 case RTE_ETH_REPRESENTOR_VF:
8292 printf(", VF %d..%d\n", range->vf,
8293 range->vf + range_diff);
8295 printf(", VF %d\n", range->vf);
8297 case RTE_ETH_REPRESENTOR_SF:
8298 printf(", SF %d\n", range->sf);
8300 case RTE_ETH_REPRESENTOR_PF:
8302 printf("..%d\n", range->pf + range_diff);
8307 printf(", UNKNOWN TYPE %d\n", range->type);
8315 cmdline_parse_token_string_t cmd_representor_info_show =
8316 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8318 cmdline_parse_token_string_t cmd_representor_info_port =
8319 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8321 cmdline_parse_token_string_t cmd_representor_info_info =
8322 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8324 cmdline_parse_token_num_t cmd_representor_info_pid =
8325 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8326 cmd_pid, RTE_UINT16);
8327 cmdline_parse_token_string_t cmd_representor_info_keyword =
8328 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8329 cmd_keyword, "representor");
8331 cmdline_parse_inst_t cmd_representor_info = {
8332 .f = cmd_representor_info_parsed,
8334 .help_str = "show port info <port_id> representor",
8336 (void *)&cmd_representor_info_show,
8337 (void *)&cmd_representor_info_port,
8338 (void *)&cmd_representor_info_info,
8339 (void *)&cmd_representor_info_pid,
8340 (void *)&cmd_representor_info_keyword,
8346 /* *** SHOW DEVICE INFO *** */
8347 struct cmd_showdevice_result {
8348 cmdline_fixed_string_t show;
8349 cmdline_fixed_string_t device;
8350 cmdline_fixed_string_t what;
8351 cmdline_fixed_string_t identifier;
8354 static void cmd_showdevice_parsed(void *parsed_result,
8355 __rte_unused struct cmdline *cl,
8356 __rte_unused void *data)
8358 struct cmd_showdevice_result *res = parsed_result;
8359 if (!strcmp(res->what, "info")) {
8360 if (!strcmp(res->identifier, "all"))
8361 device_infos_display(NULL);
8363 device_infos_display(res->identifier);
8367 cmdline_parse_token_string_t cmd_showdevice_show =
8368 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8370 cmdline_parse_token_string_t cmd_showdevice_device =
8371 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8372 cmdline_parse_token_string_t cmd_showdevice_what =
8373 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8375 cmdline_parse_token_string_t cmd_showdevice_identifier =
8376 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8379 cmdline_parse_inst_t cmd_showdevice = {
8380 .f = cmd_showdevice_parsed,
8382 .help_str = "show device info <identifier>|all",
8384 (void *)&cmd_showdevice_show,
8385 (void *)&cmd_showdevice_device,
8386 (void *)&cmd_showdevice_what,
8387 (void *)&cmd_showdevice_identifier,
8392 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8393 struct cmd_showeeprom_result {
8394 cmdline_fixed_string_t show;
8395 cmdline_fixed_string_t port;
8397 cmdline_fixed_string_t type;
8400 static void cmd_showeeprom_parsed(void *parsed_result,
8401 __rte_unused struct cmdline *cl,
8402 __rte_unused void *data)
8404 struct cmd_showeeprom_result *res = parsed_result;
8406 if (!strcmp(res->type, "eeprom"))
8407 port_eeprom_display(res->portnum);
8408 else if (!strcmp(res->type, "module_eeprom"))
8409 port_module_eeprom_display(res->portnum);
8411 fprintf(stderr, "Unknown argument\n");
8414 cmdline_parse_token_string_t cmd_showeeprom_show =
8415 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8416 cmdline_parse_token_string_t cmd_showeeprom_port =
8417 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8418 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8419 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8421 cmdline_parse_token_string_t cmd_showeeprom_type =
8422 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8424 cmdline_parse_inst_t cmd_showeeprom = {
8425 .f = cmd_showeeprom_parsed,
8427 .help_str = "show port <port_id> module_eeprom|eeprom",
8429 (void *)&cmd_showeeprom_show,
8430 (void *)&cmd_showeeprom_port,
8431 (void *)&cmd_showeeprom_portnum,
8432 (void *)&cmd_showeeprom_type,
8437 /* *** SHOW QUEUE INFO *** */
8438 struct cmd_showqueue_result {
8439 cmdline_fixed_string_t show;
8440 cmdline_fixed_string_t type;
8441 cmdline_fixed_string_t what;
8447 cmd_showqueue_parsed(void *parsed_result,
8448 __rte_unused struct cmdline *cl,
8449 __rte_unused void *data)
8451 struct cmd_showqueue_result *res = parsed_result;
8453 if (!strcmp(res->type, "rxq"))
8454 rx_queue_infos_display(res->portnum, res->queuenum);
8455 else if (!strcmp(res->type, "txq"))
8456 tx_queue_infos_display(res->portnum, res->queuenum);
8459 cmdline_parse_token_string_t cmd_showqueue_show =
8460 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8461 cmdline_parse_token_string_t cmd_showqueue_type =
8462 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8463 cmdline_parse_token_string_t cmd_showqueue_what =
8464 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8465 cmdline_parse_token_num_t cmd_showqueue_portnum =
8466 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8468 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8469 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8472 cmdline_parse_inst_t cmd_showqueue = {
8473 .f = cmd_showqueue_parsed,
8475 .help_str = "show rxq|txq info <port_id> <queue_id>",
8477 (void *)&cmd_showqueue_show,
8478 (void *)&cmd_showqueue_type,
8479 (void *)&cmd_showqueue_what,
8480 (void *)&cmd_showqueue_portnum,
8481 (void *)&cmd_showqueue_queuenum,
8486 /* show/clear fwd engine statistics */
8488 cmdline_fixed_string_t action;
8489 cmdline_fixed_string_t fwd;
8490 cmdline_fixed_string_t stats;
8491 cmdline_fixed_string_t all;
8494 cmdline_parse_token_string_t cmd_fwd_action =
8495 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8496 cmdline_parse_token_string_t cmd_fwd_fwd =
8497 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8498 cmdline_parse_token_string_t cmd_fwd_stats =
8499 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8500 cmdline_parse_token_string_t cmd_fwd_all =
8501 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8504 cmd_showfwdall_parsed(void *parsed_result,
8505 __rte_unused struct cmdline *cl,
8506 __rte_unused void *data)
8508 struct fwd_result *res = parsed_result;
8510 if (!strcmp(res->action, "show"))
8511 fwd_stats_display();
8516 static cmdline_parse_inst_t cmd_showfwdall = {
8517 .f = cmd_showfwdall_parsed,
8519 .help_str = "show|clear fwd stats all",
8521 (void *)&cmd_fwd_action,
8522 (void *)&cmd_fwd_fwd,
8523 (void *)&cmd_fwd_stats,
8524 (void *)&cmd_fwd_all,
8529 /* *** READ PORT REGISTER *** */
8530 struct cmd_read_reg_result {
8531 cmdline_fixed_string_t read;
8532 cmdline_fixed_string_t reg;
8538 cmd_read_reg_parsed(void *parsed_result,
8539 __rte_unused struct cmdline *cl,
8540 __rte_unused void *data)
8542 struct cmd_read_reg_result *res = parsed_result;
8543 port_reg_display(res->port_id, res->reg_off);
8546 cmdline_parse_token_string_t cmd_read_reg_read =
8547 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8548 cmdline_parse_token_string_t cmd_read_reg_reg =
8549 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8550 cmdline_parse_token_num_t cmd_read_reg_port_id =
8551 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8552 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8553 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8555 cmdline_parse_inst_t cmd_read_reg = {
8556 .f = cmd_read_reg_parsed,
8558 .help_str = "read reg <port_id> <reg_off>",
8560 (void *)&cmd_read_reg_read,
8561 (void *)&cmd_read_reg_reg,
8562 (void *)&cmd_read_reg_port_id,
8563 (void *)&cmd_read_reg_reg_off,
8568 /* *** READ PORT REGISTER BIT FIELD *** */
8569 struct cmd_read_reg_bit_field_result {
8570 cmdline_fixed_string_t read;
8571 cmdline_fixed_string_t regfield;
8579 cmd_read_reg_bit_field_parsed(void *parsed_result,
8580 __rte_unused struct cmdline *cl,
8581 __rte_unused void *data)
8583 struct cmd_read_reg_bit_field_result *res = parsed_result;
8584 port_reg_bit_field_display(res->port_id, res->reg_off,
8585 res->bit1_pos, res->bit2_pos);
8588 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8589 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8591 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8592 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8593 regfield, "regfield");
8594 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8595 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8597 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8598 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8600 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8601 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8603 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8604 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8607 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8608 .f = cmd_read_reg_bit_field_parsed,
8610 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8611 "Read register bit field between bit_x and bit_y included",
8613 (void *)&cmd_read_reg_bit_field_read,
8614 (void *)&cmd_read_reg_bit_field_regfield,
8615 (void *)&cmd_read_reg_bit_field_port_id,
8616 (void *)&cmd_read_reg_bit_field_reg_off,
8617 (void *)&cmd_read_reg_bit_field_bit1_pos,
8618 (void *)&cmd_read_reg_bit_field_bit2_pos,
8623 /* *** READ PORT REGISTER BIT *** */
8624 struct cmd_read_reg_bit_result {
8625 cmdline_fixed_string_t read;
8626 cmdline_fixed_string_t regbit;
8633 cmd_read_reg_bit_parsed(void *parsed_result,
8634 __rte_unused struct cmdline *cl,
8635 __rte_unused void *data)
8637 struct cmd_read_reg_bit_result *res = parsed_result;
8638 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8641 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8642 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8643 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8644 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8646 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8647 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8649 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8650 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8652 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8653 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8656 cmdline_parse_inst_t cmd_read_reg_bit = {
8657 .f = cmd_read_reg_bit_parsed,
8659 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8661 (void *)&cmd_read_reg_bit_read,
8662 (void *)&cmd_read_reg_bit_regbit,
8663 (void *)&cmd_read_reg_bit_port_id,
8664 (void *)&cmd_read_reg_bit_reg_off,
8665 (void *)&cmd_read_reg_bit_bit_pos,
8670 /* *** WRITE PORT REGISTER *** */
8671 struct cmd_write_reg_result {
8672 cmdline_fixed_string_t write;
8673 cmdline_fixed_string_t reg;
8680 cmd_write_reg_parsed(void *parsed_result,
8681 __rte_unused struct cmdline *cl,
8682 __rte_unused void *data)
8684 struct cmd_write_reg_result *res = parsed_result;
8685 port_reg_set(res->port_id, res->reg_off, res->value);
8688 cmdline_parse_token_string_t cmd_write_reg_write =
8689 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8690 cmdline_parse_token_string_t cmd_write_reg_reg =
8691 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8692 cmdline_parse_token_num_t cmd_write_reg_port_id =
8693 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8694 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8695 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8696 cmdline_parse_token_num_t cmd_write_reg_value =
8697 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8699 cmdline_parse_inst_t cmd_write_reg = {
8700 .f = cmd_write_reg_parsed,
8702 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8704 (void *)&cmd_write_reg_write,
8705 (void *)&cmd_write_reg_reg,
8706 (void *)&cmd_write_reg_port_id,
8707 (void *)&cmd_write_reg_reg_off,
8708 (void *)&cmd_write_reg_value,
8713 /* *** WRITE PORT REGISTER BIT FIELD *** */
8714 struct cmd_write_reg_bit_field_result {
8715 cmdline_fixed_string_t write;
8716 cmdline_fixed_string_t regfield;
8725 cmd_write_reg_bit_field_parsed(void *parsed_result,
8726 __rte_unused struct cmdline *cl,
8727 __rte_unused void *data)
8729 struct cmd_write_reg_bit_field_result *res = parsed_result;
8730 port_reg_bit_field_set(res->port_id, res->reg_off,
8731 res->bit1_pos, res->bit2_pos, res->value);
8734 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8735 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8737 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8738 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8739 regfield, "regfield");
8740 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8741 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8743 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8744 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8746 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8747 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8749 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8750 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8752 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8753 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8756 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8757 .f = cmd_write_reg_bit_field_parsed,
8759 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8761 "Set register bit field between bit_x and bit_y included",
8763 (void *)&cmd_write_reg_bit_field_write,
8764 (void *)&cmd_write_reg_bit_field_regfield,
8765 (void *)&cmd_write_reg_bit_field_port_id,
8766 (void *)&cmd_write_reg_bit_field_reg_off,
8767 (void *)&cmd_write_reg_bit_field_bit1_pos,
8768 (void *)&cmd_write_reg_bit_field_bit2_pos,
8769 (void *)&cmd_write_reg_bit_field_value,
8774 /* *** WRITE PORT REGISTER BIT *** */
8775 struct cmd_write_reg_bit_result {
8776 cmdline_fixed_string_t write;
8777 cmdline_fixed_string_t regbit;
8785 cmd_write_reg_bit_parsed(void *parsed_result,
8786 __rte_unused struct cmdline *cl,
8787 __rte_unused void *data)
8789 struct cmd_write_reg_bit_result *res = parsed_result;
8790 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8793 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8794 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8796 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8797 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8799 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8800 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8802 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8803 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8805 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8806 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8808 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8809 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8812 cmdline_parse_inst_t cmd_write_reg_bit = {
8813 .f = cmd_write_reg_bit_parsed,
8815 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8818 (void *)&cmd_write_reg_bit_write,
8819 (void *)&cmd_write_reg_bit_regbit,
8820 (void *)&cmd_write_reg_bit_port_id,
8821 (void *)&cmd_write_reg_bit_reg_off,
8822 (void *)&cmd_write_reg_bit_bit_pos,
8823 (void *)&cmd_write_reg_bit_value,
8828 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8829 struct cmd_read_rxd_txd_result {
8830 cmdline_fixed_string_t read;
8831 cmdline_fixed_string_t rxd_txd;
8838 cmd_read_rxd_txd_parsed(void *parsed_result,
8839 __rte_unused struct cmdline *cl,
8840 __rte_unused void *data)
8842 struct cmd_read_rxd_txd_result *res = parsed_result;
8844 if (!strcmp(res->rxd_txd, "rxd"))
8845 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8846 else if (!strcmp(res->rxd_txd, "txd"))
8847 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8850 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8851 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8852 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8853 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8855 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8856 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8858 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8859 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8861 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8862 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8865 cmdline_parse_inst_t cmd_read_rxd_txd = {
8866 .f = cmd_read_rxd_txd_parsed,
8868 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8870 (void *)&cmd_read_rxd_txd_read,
8871 (void *)&cmd_read_rxd_txd_rxd_txd,
8872 (void *)&cmd_read_rxd_txd_port_id,
8873 (void *)&cmd_read_rxd_txd_queue_id,
8874 (void *)&cmd_read_rxd_txd_desc_id,
8880 struct cmd_quit_result {
8881 cmdline_fixed_string_t quit;
8884 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8886 __rte_unused void *data)
8891 cmdline_parse_token_string_t cmd_quit_quit =
8892 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8894 cmdline_parse_inst_t cmd_quit = {
8895 .f = cmd_quit_parsed,
8897 .help_str = "quit: Exit application",
8899 (void *)&cmd_quit_quit,
8904 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8905 struct cmd_mac_addr_result {
8906 cmdline_fixed_string_t mac_addr_cmd;
8907 cmdline_fixed_string_t what;
8909 struct rte_ether_addr address;
8912 static void cmd_mac_addr_parsed(void *parsed_result,
8913 __rte_unused struct cmdline *cl,
8914 __rte_unused void *data)
8916 struct cmd_mac_addr_result *res = parsed_result;
8919 if (strcmp(res->what, "add") == 0)
8920 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8921 else if (strcmp(res->what, "set") == 0)
8922 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8925 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8927 /* check the return value and print it if is < 0 */
8929 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8933 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8934 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8936 cmdline_parse_token_string_t cmd_mac_addr_what =
8937 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8939 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8940 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8942 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8943 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8945 cmdline_parse_inst_t cmd_mac_addr = {
8946 .f = cmd_mac_addr_parsed,
8948 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8949 "Add/Remove/Set MAC address on port_id",
8951 (void *)&cmd_mac_addr_cmd,
8952 (void *)&cmd_mac_addr_what,
8953 (void *)&cmd_mac_addr_portnum,
8954 (void *)&cmd_mac_addr_addr,
8959 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8960 struct cmd_eth_peer_result {
8961 cmdline_fixed_string_t set;
8962 cmdline_fixed_string_t eth_peer;
8964 cmdline_fixed_string_t peer_addr;
8967 static void cmd_set_eth_peer_parsed(void *parsed_result,
8968 __rte_unused struct cmdline *cl,
8969 __rte_unused void *data)
8971 struct cmd_eth_peer_result *res = parsed_result;
8973 if (test_done == 0) {
8974 fprintf(stderr, "Please stop forwarding first\n");
8977 if (!strcmp(res->eth_peer, "eth-peer")) {
8978 set_fwd_eth_peer(res->port_id, res->peer_addr);
8982 cmdline_parse_token_string_t cmd_eth_peer_set =
8983 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8984 cmdline_parse_token_string_t cmd_eth_peer =
8985 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8986 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8987 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8989 cmdline_parse_token_string_t cmd_eth_peer_addr =
8990 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8992 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8993 .f = cmd_set_eth_peer_parsed,
8995 .help_str = "set eth-peer <port_id> <peer_mac>",
8997 (void *)&cmd_eth_peer_set,
8998 (void *)&cmd_eth_peer,
8999 (void *)&cmd_eth_peer_port_id,
9000 (void *)&cmd_eth_peer_addr,
9005 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
9006 struct cmd_set_qmap_result {
9007 cmdline_fixed_string_t set;
9008 cmdline_fixed_string_t qmap;
9009 cmdline_fixed_string_t what;
9016 cmd_set_qmap_parsed(void *parsed_result,
9017 __rte_unused struct cmdline *cl,
9018 __rte_unused void *data)
9020 struct cmd_set_qmap_result *res = parsed_result;
9021 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
9023 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
9026 cmdline_parse_token_string_t cmd_setqmap_set =
9027 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9029 cmdline_parse_token_string_t cmd_setqmap_qmap =
9030 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9032 cmdline_parse_token_string_t cmd_setqmap_what =
9033 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9035 cmdline_parse_token_num_t cmd_setqmap_portid =
9036 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9037 port_id, RTE_UINT16);
9038 cmdline_parse_token_num_t cmd_setqmap_queueid =
9039 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9040 queue_id, RTE_UINT16);
9041 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
9042 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9043 map_value, RTE_UINT8);
9045 cmdline_parse_inst_t cmd_set_qmap = {
9046 .f = cmd_set_qmap_parsed,
9048 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
9049 "Set statistics mapping value on tx|rx queue_id of port_id",
9051 (void *)&cmd_setqmap_set,
9052 (void *)&cmd_setqmap_qmap,
9053 (void *)&cmd_setqmap_what,
9054 (void *)&cmd_setqmap_portid,
9055 (void *)&cmd_setqmap_queueid,
9056 (void *)&cmd_setqmap_mapvalue,
9061 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
9062 struct cmd_set_xstats_hide_zero_result {
9063 cmdline_fixed_string_t keyword;
9064 cmdline_fixed_string_t name;
9065 cmdline_fixed_string_t on_off;
9069 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
9070 __rte_unused struct cmdline *cl,
9071 __rte_unused void *data)
9073 struct cmd_set_xstats_hide_zero_result *res;
9074 uint16_t on_off = 0;
9076 res = parsed_result;
9077 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9078 set_xstats_hide_zero(on_off);
9081 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
9082 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9084 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
9085 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9086 name, "xstats-hide-zero");
9087 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
9088 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9091 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
9092 .f = cmd_set_xstats_hide_zero_parsed,
9094 .help_str = "set xstats-hide-zero on|off",
9096 (void *)&cmd_set_xstats_hide_zero_keyword,
9097 (void *)&cmd_set_xstats_hide_zero_name,
9098 (void *)&cmd_set_xstats_hide_zero_on_off,
9103 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
9104 struct cmd_set_record_core_cycles_result {
9105 cmdline_fixed_string_t keyword;
9106 cmdline_fixed_string_t name;
9107 cmdline_fixed_string_t on_off;
9111 cmd_set_record_core_cycles_parsed(void *parsed_result,
9112 __rte_unused struct cmdline *cl,
9113 __rte_unused void *data)
9115 struct cmd_set_record_core_cycles_result *res;
9116 uint16_t on_off = 0;
9118 res = parsed_result;
9119 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9120 set_record_core_cycles(on_off);
9123 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
9124 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9126 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
9127 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9128 name, "record-core-cycles");
9129 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
9130 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9133 cmdline_parse_inst_t cmd_set_record_core_cycles = {
9134 .f = cmd_set_record_core_cycles_parsed,
9136 .help_str = "set record-core-cycles on|off",
9138 (void *)&cmd_set_record_core_cycles_keyword,
9139 (void *)&cmd_set_record_core_cycles_name,
9140 (void *)&cmd_set_record_core_cycles_on_off,
9145 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9146 struct cmd_set_record_burst_stats_result {
9147 cmdline_fixed_string_t keyword;
9148 cmdline_fixed_string_t name;
9149 cmdline_fixed_string_t on_off;
9153 cmd_set_record_burst_stats_parsed(void *parsed_result,
9154 __rte_unused struct cmdline *cl,
9155 __rte_unused void *data)
9157 struct cmd_set_record_burst_stats_result *res;
9158 uint16_t on_off = 0;
9160 res = parsed_result;
9161 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9162 set_record_burst_stats(on_off);
9165 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9166 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9168 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9169 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9170 name, "record-burst-stats");
9171 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9172 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9175 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9176 .f = cmd_set_record_burst_stats_parsed,
9178 .help_str = "set record-burst-stats on|off",
9180 (void *)&cmd_set_record_burst_stats_keyword,
9181 (void *)&cmd_set_record_burst_stats_name,
9182 (void *)&cmd_set_record_burst_stats_on_off,
9187 /* *** CONFIGURE UNICAST HASH TABLE *** */
9188 struct cmd_set_uc_hash_table {
9189 cmdline_fixed_string_t set;
9190 cmdline_fixed_string_t port;
9192 cmdline_fixed_string_t what;
9193 struct rte_ether_addr address;
9194 cmdline_fixed_string_t mode;
9198 cmd_set_uc_hash_parsed(void *parsed_result,
9199 __rte_unused struct cmdline *cl,
9200 __rte_unused void *data)
9203 struct cmd_set_uc_hash_table *res = parsed_result;
9205 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9207 if (strcmp(res->what, "uta") == 0)
9208 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9209 &res->address,(uint8_t)is_on);
9212 "bad unicast hash table parameter, return code = %d\n",
9217 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9218 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9220 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9221 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9223 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9224 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9225 port_id, RTE_UINT16);
9226 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9227 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9229 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9230 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9232 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9233 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9236 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9237 .f = cmd_set_uc_hash_parsed,
9239 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9241 (void *)&cmd_set_uc_hash_set,
9242 (void *)&cmd_set_uc_hash_port,
9243 (void *)&cmd_set_uc_hash_portid,
9244 (void *)&cmd_set_uc_hash_what,
9245 (void *)&cmd_set_uc_hash_mac,
9246 (void *)&cmd_set_uc_hash_mode,
9251 struct cmd_set_uc_all_hash_table {
9252 cmdline_fixed_string_t set;
9253 cmdline_fixed_string_t port;
9255 cmdline_fixed_string_t what;
9256 cmdline_fixed_string_t value;
9257 cmdline_fixed_string_t mode;
9261 cmd_set_uc_all_hash_parsed(void *parsed_result,
9262 __rte_unused struct cmdline *cl,
9263 __rte_unused void *data)
9266 struct cmd_set_uc_all_hash_table *res = parsed_result;
9268 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9270 if ((strcmp(res->what, "uta") == 0) &&
9271 (strcmp(res->value, "all") == 0))
9272 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9275 "bad unicast hash table parameter, return code = %d\n",
9279 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9280 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9282 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9283 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9285 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9286 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9287 port_id, RTE_UINT16);
9288 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9289 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9291 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9292 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9294 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9295 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9298 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9299 .f = cmd_set_uc_all_hash_parsed,
9301 .help_str = "set port <port_id> uta all on|off",
9303 (void *)&cmd_set_uc_all_hash_set,
9304 (void *)&cmd_set_uc_all_hash_port,
9305 (void *)&cmd_set_uc_all_hash_portid,
9306 (void *)&cmd_set_uc_all_hash_what,
9307 (void *)&cmd_set_uc_all_hash_value,
9308 (void *)&cmd_set_uc_all_hash_mode,
9313 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9314 struct cmd_set_vf_traffic {
9315 cmdline_fixed_string_t set;
9316 cmdline_fixed_string_t port;
9318 cmdline_fixed_string_t vf;
9320 cmdline_fixed_string_t what;
9321 cmdline_fixed_string_t mode;
9325 cmd_set_vf_traffic_parsed(void *parsed_result,
9326 __rte_unused struct cmdline *cl,
9327 __rte_unused void *data)
9329 struct cmd_set_vf_traffic *res = parsed_result;
9330 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9331 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9333 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9336 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9337 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9339 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9340 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9342 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9343 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9344 port_id, RTE_UINT16);
9345 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9346 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9348 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9349 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9351 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9352 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9354 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9355 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9358 cmdline_parse_inst_t cmd_set_vf_traffic = {
9359 .f = cmd_set_vf_traffic_parsed,
9361 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9363 (void *)&cmd_setvf_traffic_set,
9364 (void *)&cmd_setvf_traffic_port,
9365 (void *)&cmd_setvf_traffic_portid,
9366 (void *)&cmd_setvf_traffic_vf,
9367 (void *)&cmd_setvf_traffic_vfid,
9368 (void *)&cmd_setvf_traffic_what,
9369 (void *)&cmd_setvf_traffic_mode,
9374 /* *** CONFIGURE VF RECEIVE MODE *** */
9375 struct cmd_set_vf_rxmode {
9376 cmdline_fixed_string_t set;
9377 cmdline_fixed_string_t port;
9379 cmdline_fixed_string_t vf;
9381 cmdline_fixed_string_t what;
9382 cmdline_fixed_string_t mode;
9383 cmdline_fixed_string_t on;
9387 cmd_set_vf_rxmode_parsed(void *parsed_result,
9388 __rte_unused struct cmdline *cl,
9389 __rte_unused void *data)
9392 uint16_t vf_rxmode = 0;
9393 struct cmd_set_vf_rxmode *res = parsed_result;
9395 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9396 if (!strcmp(res->what,"rxmode")) {
9397 if (!strcmp(res->mode, "AUPE"))
9398 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9399 else if (!strcmp(res->mode, "ROPE"))
9400 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9401 else if (!strcmp(res->mode, "BAM"))
9402 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9403 else if (!strncmp(res->mode, "MPE",3))
9404 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9407 RTE_SET_USED(is_on);
9408 RTE_SET_USED(vf_rxmode);
9410 #ifdef RTE_NET_IXGBE
9411 if (ret == -ENOTSUP)
9412 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9413 vf_rxmode, (uint8_t)is_on);
9416 if (ret == -ENOTSUP)
9417 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9418 vf_rxmode, (uint8_t)is_on);
9422 "bad VF receive mode parameter, return code = %d\n",
9426 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9427 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9429 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9430 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9432 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9433 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9434 port_id, RTE_UINT16);
9435 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9436 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9438 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9439 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9441 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9442 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9444 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9445 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9446 mode, "AUPE#ROPE#BAM#MPE");
9447 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9448 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9451 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9452 .f = cmd_set_vf_rxmode_parsed,
9454 .help_str = "set port <port_id> vf <vf_id> rxmode "
9455 "AUPE|ROPE|BAM|MPE on|off",
9457 (void *)&cmd_set_vf_rxmode_set,
9458 (void *)&cmd_set_vf_rxmode_port,
9459 (void *)&cmd_set_vf_rxmode_portid,
9460 (void *)&cmd_set_vf_rxmode_vf,
9461 (void *)&cmd_set_vf_rxmode_vfid,
9462 (void *)&cmd_set_vf_rxmode_what,
9463 (void *)&cmd_set_vf_rxmode_mode,
9464 (void *)&cmd_set_vf_rxmode_on,
9469 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9470 struct cmd_vf_mac_addr_result {
9471 cmdline_fixed_string_t mac_addr_cmd;
9472 cmdline_fixed_string_t what;
9473 cmdline_fixed_string_t port;
9475 cmdline_fixed_string_t vf;
9477 struct rte_ether_addr address;
9480 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9481 __rte_unused struct cmdline *cl,
9482 __rte_unused void *data)
9484 struct cmd_vf_mac_addr_result *res = parsed_result;
9487 if (strcmp(res->what, "add") != 0)
9491 if (ret == -ENOTSUP)
9492 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9496 if (ret == -ENOTSUP)
9497 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9502 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9506 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9507 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9508 mac_addr_cmd,"mac_addr");
9509 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9510 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9512 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9513 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9515 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9516 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9517 port_num, RTE_UINT16);
9518 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9519 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9521 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9522 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9524 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9525 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9528 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9529 .f = cmd_vf_mac_addr_parsed,
9531 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9532 "Add MAC address filtering for a VF on port_id",
9534 (void *)&cmd_vf_mac_addr_cmd,
9535 (void *)&cmd_vf_mac_addr_what,
9536 (void *)&cmd_vf_mac_addr_port,
9537 (void *)&cmd_vf_mac_addr_portnum,
9538 (void *)&cmd_vf_mac_addr_vf,
9539 (void *)&cmd_vf_mac_addr_vfnum,
9540 (void *)&cmd_vf_mac_addr_addr,
9545 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9546 struct cmd_vf_rx_vlan_filter {
9547 cmdline_fixed_string_t rx_vlan;
9548 cmdline_fixed_string_t what;
9550 cmdline_fixed_string_t port;
9552 cmdline_fixed_string_t vf;
9557 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9558 __rte_unused struct cmdline *cl,
9559 __rte_unused void *data)
9561 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9564 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9566 #ifdef RTE_NET_IXGBE
9567 if (ret == -ENOTSUP)
9568 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9569 res->vlan_id, res->vf_mask, is_add);
9572 if (ret == -ENOTSUP)
9573 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9574 res->vlan_id, res->vf_mask, is_add);
9577 if (ret == -ENOTSUP)
9578 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9579 res->vlan_id, res->vf_mask, is_add);
9586 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9587 res->vlan_id, res->vf_mask);
9590 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9593 fprintf(stderr, "function not implemented or supported\n");
9596 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9600 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9601 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9602 rx_vlan, "rx_vlan");
9603 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9604 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9606 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9607 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9608 vlan_id, RTE_UINT16);
9609 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9610 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9612 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9613 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9614 port_id, RTE_UINT16);
9615 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9616 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9618 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9619 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9620 vf_mask, RTE_UINT64);
9622 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9623 .f = cmd_vf_rx_vlan_filter_parsed,
9625 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9626 "(vf_mask = hexadecimal VF mask)",
9628 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9629 (void *)&cmd_vf_rx_vlan_filter_what,
9630 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9631 (void *)&cmd_vf_rx_vlan_filter_port,
9632 (void *)&cmd_vf_rx_vlan_filter_portid,
9633 (void *)&cmd_vf_rx_vlan_filter_vf,
9634 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9639 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9640 struct cmd_queue_rate_limit_result {
9641 cmdline_fixed_string_t set;
9642 cmdline_fixed_string_t port;
9644 cmdline_fixed_string_t queue;
9646 cmdline_fixed_string_t rate;
9650 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9651 __rte_unused struct cmdline *cl,
9652 __rte_unused void *data)
9654 struct cmd_queue_rate_limit_result *res = parsed_result;
9657 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9658 && (strcmp(res->queue, "queue") == 0)
9659 && (strcmp(res->rate, "rate") == 0))
9660 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9663 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9668 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9669 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9671 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9672 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9674 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9675 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9676 port_num, RTE_UINT16);
9677 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9678 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9680 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9681 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9682 queue_num, RTE_UINT8);
9683 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9684 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9686 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9687 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9688 rate_num, RTE_UINT16);
9690 cmdline_parse_inst_t cmd_queue_rate_limit = {
9691 .f = cmd_queue_rate_limit_parsed,
9693 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9694 "Set rate limit for a queue on port_id",
9696 (void *)&cmd_queue_rate_limit_set,
9697 (void *)&cmd_queue_rate_limit_port,
9698 (void *)&cmd_queue_rate_limit_portnum,
9699 (void *)&cmd_queue_rate_limit_queue,
9700 (void *)&cmd_queue_rate_limit_queuenum,
9701 (void *)&cmd_queue_rate_limit_rate,
9702 (void *)&cmd_queue_rate_limit_ratenum,
9707 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9708 struct cmd_vf_rate_limit_result {
9709 cmdline_fixed_string_t set;
9710 cmdline_fixed_string_t port;
9712 cmdline_fixed_string_t vf;
9714 cmdline_fixed_string_t rate;
9716 cmdline_fixed_string_t q_msk;
9720 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9721 __rte_unused struct cmdline *cl,
9722 __rte_unused void *data)
9724 struct cmd_vf_rate_limit_result *res = parsed_result;
9727 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9728 && (strcmp(res->vf, "vf") == 0)
9729 && (strcmp(res->rate, "rate") == 0)
9730 && (strcmp(res->q_msk, "queue_mask") == 0))
9731 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9732 res->rate_num, res->q_msk_val);
9734 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9739 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9740 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9742 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9743 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9745 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9746 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9747 port_num, RTE_UINT16);
9748 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9749 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9751 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9752 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9754 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9755 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9757 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9758 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9759 rate_num, RTE_UINT16);
9760 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9761 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9762 q_msk, "queue_mask");
9763 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9764 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9765 q_msk_val, RTE_UINT64);
9767 cmdline_parse_inst_t cmd_vf_rate_limit = {
9768 .f = cmd_vf_rate_limit_parsed,
9770 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9771 "queue_mask <queue_mask_value>: "
9772 "Set rate limit for queues of VF on port_id",
9774 (void *)&cmd_vf_rate_limit_set,
9775 (void *)&cmd_vf_rate_limit_port,
9776 (void *)&cmd_vf_rate_limit_portnum,
9777 (void *)&cmd_vf_rate_limit_vf,
9778 (void *)&cmd_vf_rate_limit_vfnum,
9779 (void *)&cmd_vf_rate_limit_rate,
9780 (void *)&cmd_vf_rate_limit_ratenum,
9781 (void *)&cmd_vf_rate_limit_q_msk,
9782 (void *)&cmd_vf_rate_limit_q_msk_val,
9787 /* *** CONFIGURE TUNNEL UDP PORT *** */
9788 struct cmd_tunnel_udp_config {
9789 cmdline_fixed_string_t rx_vxlan_port;
9790 cmdline_fixed_string_t what;
9796 cmd_tunnel_udp_config_parsed(void *parsed_result,
9797 __rte_unused struct cmdline *cl,
9798 __rte_unused void *data)
9800 struct cmd_tunnel_udp_config *res = parsed_result;
9801 struct rte_eth_udp_tunnel tunnel_udp;
9804 tunnel_udp.udp_port = res->udp_port;
9805 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9807 if (!strcmp(res->what, "add"))
9808 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9811 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9815 fprintf(stderr, "udp tunneling add error: (%s)\n",
9819 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9820 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9821 rx_vxlan_port, "rx_vxlan_port");
9822 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9823 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9825 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9826 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9827 udp_port, RTE_UINT16);
9828 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9829 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9830 port_id, RTE_UINT16);
9832 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9833 .f = cmd_tunnel_udp_config_parsed,
9835 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9836 "Add/Remove a tunneling UDP port filter",
9838 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9839 (void *)&cmd_tunnel_udp_config_what,
9840 (void *)&cmd_tunnel_udp_config_udp_port,
9841 (void *)&cmd_tunnel_udp_config_port_id,
9846 struct cmd_config_tunnel_udp_port {
9847 cmdline_fixed_string_t port;
9848 cmdline_fixed_string_t config;
9850 cmdline_fixed_string_t udp_tunnel_port;
9851 cmdline_fixed_string_t action;
9852 cmdline_fixed_string_t tunnel_type;
9857 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9858 __rte_unused struct cmdline *cl,
9859 __rte_unused void *data)
9861 struct cmd_config_tunnel_udp_port *res = parsed_result;
9862 struct rte_eth_udp_tunnel tunnel_udp;
9865 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9868 tunnel_udp.udp_port = res->udp_port;
9870 if (!strcmp(res->tunnel_type, "vxlan")) {
9871 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9872 } else if (!strcmp(res->tunnel_type, "geneve")) {
9873 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9874 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9875 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9876 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9877 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9879 fprintf(stderr, "Invalid tunnel type\n");
9883 if (!strcmp(res->action, "add"))
9884 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9887 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9891 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9895 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9896 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9898 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9899 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9901 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9902 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9904 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9905 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9908 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9909 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9911 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9912 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9913 "vxlan#geneve#vxlan-gpe#ecpri");
9914 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9915 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9918 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9919 .f = cmd_cfg_tunnel_udp_port_parsed,
9921 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9922 "geneve|vxlan-gpe|ecpri <udp_port>",
9924 (void *)&cmd_config_tunnel_udp_port_port,
9925 (void *)&cmd_config_tunnel_udp_port_config,
9926 (void *)&cmd_config_tunnel_udp_port_port_id,
9927 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9928 (void *)&cmd_config_tunnel_udp_port_action,
9929 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9930 (void *)&cmd_config_tunnel_udp_port_value,
9935 /* ******************************************************************************** */
9937 struct cmd_dump_result {
9938 cmdline_fixed_string_t dump;
9942 dump_struct_sizes(void)
9944 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9945 DUMP_SIZE(struct rte_mbuf);
9946 DUMP_SIZE(struct rte_mempool);
9947 DUMP_SIZE(struct rte_ring);
9952 /* Dump the socket memory statistics on console */
9954 dump_socket_mem(FILE *f)
9956 struct rte_malloc_socket_stats socket_stats;
9961 unsigned int n_alloc = 0;
9962 unsigned int n_free = 0;
9963 static size_t last_allocs;
9964 static size_t last_total;
9967 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9968 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9969 !socket_stats.heap_totalsz_bytes)
9971 total += socket_stats.heap_totalsz_bytes;
9972 alloc += socket_stats.heap_allocsz_bytes;
9973 free += socket_stats.heap_freesz_bytes;
9974 n_alloc += socket_stats.alloc_count;
9975 n_free += socket_stats.free_count;
9977 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9979 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9980 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9981 (double)socket_stats.heap_allocsz_bytes * 100 /
9982 (double)socket_stats.heap_totalsz_bytes,
9983 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9984 socket_stats.alloc_count,
9985 socket_stats.free_count);
9988 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9989 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9990 total ? ((double)alloc * 100 / (double)total) : 0,
9991 (double)free / (1024 * 1024),
9994 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9995 ((double)total - (double)last_total) / (1024 * 1024),
9996 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9997 last_allocs = alloc;
10001 static void cmd_dump_parsed(void *parsed_result,
10002 __rte_unused struct cmdline *cl,
10003 __rte_unused void *data)
10005 struct cmd_dump_result *res = parsed_result;
10007 if (!strcmp(res->dump, "dump_physmem"))
10008 rte_dump_physmem_layout(stdout);
10009 else if (!strcmp(res->dump, "dump_socket_mem"))
10010 dump_socket_mem(stdout);
10011 else if (!strcmp(res->dump, "dump_memzone"))
10012 rte_memzone_dump(stdout);
10013 else if (!strcmp(res->dump, "dump_struct_sizes"))
10014 dump_struct_sizes();
10015 else if (!strcmp(res->dump, "dump_ring"))
10016 rte_ring_list_dump(stdout);
10017 else if (!strcmp(res->dump, "dump_mempool"))
10018 rte_mempool_list_dump(stdout);
10019 else if (!strcmp(res->dump, "dump_devargs"))
10020 rte_devargs_dump(stdout);
10021 else if (!strcmp(res->dump, "dump_log_types"))
10022 rte_log_dump(stdout);
10025 cmdline_parse_token_string_t cmd_dump_dump =
10026 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
10030 "dump_struct_sizes#"
10036 cmdline_parse_inst_t cmd_dump = {
10037 .f = cmd_dump_parsed, /* function to call */
10038 .data = NULL, /* 2nd arg of func */
10039 .help_str = "Dump status",
10040 .tokens = { /* token list, NULL terminated */
10041 (void *)&cmd_dump_dump,
10046 /* ******************************************************************************** */
10048 struct cmd_dump_one_result {
10049 cmdline_fixed_string_t dump;
10050 cmdline_fixed_string_t name;
10053 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
10054 __rte_unused void *data)
10056 struct cmd_dump_one_result *res = parsed_result;
10058 if (!strcmp(res->dump, "dump_ring")) {
10059 struct rte_ring *r;
10060 r = rte_ring_lookup(res->name);
10062 cmdline_printf(cl, "Cannot find ring\n");
10065 rte_ring_dump(stdout, r);
10066 } else if (!strcmp(res->dump, "dump_mempool")) {
10067 struct rte_mempool *mp;
10068 mp = rte_mempool_lookup(res->name);
10070 cmdline_printf(cl, "Cannot find mempool\n");
10073 rte_mempool_dump(stdout, mp);
10077 cmdline_parse_token_string_t cmd_dump_one_dump =
10078 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
10079 "dump_ring#dump_mempool");
10081 cmdline_parse_token_string_t cmd_dump_one_name =
10082 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
10084 cmdline_parse_inst_t cmd_dump_one = {
10085 .f = cmd_dump_one_parsed, /* function to call */
10086 .data = NULL, /* 2nd arg of func */
10087 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
10088 .tokens = { /* token list, NULL terminated */
10089 (void *)&cmd_dump_one_dump,
10090 (void *)&cmd_dump_one_name,
10095 /* *** queue region set *** */
10096 struct cmd_queue_region_result {
10097 cmdline_fixed_string_t set;
10098 cmdline_fixed_string_t port;
10100 cmdline_fixed_string_t cmd;
10101 cmdline_fixed_string_t region;
10103 cmdline_fixed_string_t queue_start_index;
10105 cmdline_fixed_string_t queue_num;
10106 uint8_t queue_num_value;
10110 cmd_queue_region_parsed(void *parsed_result,
10111 __rte_unused struct cmdline *cl,
10112 __rte_unused void *data)
10114 struct cmd_queue_region_result *res = parsed_result;
10115 int ret = -ENOTSUP;
10116 #ifdef RTE_NET_I40E
10117 struct rte_pmd_i40e_queue_region_conf region_conf;
10118 enum rte_pmd_i40e_queue_region_op op_type;
10121 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10124 #ifdef RTE_NET_I40E
10125 memset(®ion_conf, 0, sizeof(region_conf));
10126 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10127 region_conf.region_id = res->region_id;
10128 region_conf.queue_num = res->queue_num_value;
10129 region_conf.queue_start_index = res->queue_id;
10131 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10132 op_type, ®ion_conf);
10139 fprintf(stderr, "function not implemented or supported\n");
10142 fprintf(stderr, "queue region config error: (%s)\n",
10147 cmdline_parse_token_string_t cmd_queue_region_set =
10148 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10150 cmdline_parse_token_string_t cmd_queue_region_port =
10151 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10152 cmdline_parse_token_num_t cmd_queue_region_port_id =
10153 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10154 port_id, RTE_UINT16);
10155 cmdline_parse_token_string_t cmd_queue_region_cmd =
10156 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10157 cmd, "queue-region");
10158 cmdline_parse_token_string_t cmd_queue_region_id =
10159 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10160 region, "region_id");
10161 cmdline_parse_token_num_t cmd_queue_region_index =
10162 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10163 region_id, RTE_UINT8);
10164 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10165 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10166 queue_start_index, "queue_start_index");
10167 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10168 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10169 queue_id, RTE_UINT8);
10170 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10171 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10172 queue_num, "queue_num");
10173 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10174 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10175 queue_num_value, RTE_UINT8);
10177 cmdline_parse_inst_t cmd_queue_region = {
10178 .f = cmd_queue_region_parsed,
10180 .help_str = "set port <port_id> queue-region region_id <value> "
10181 "queue_start_index <value> queue_num <value>: Set a queue region",
10183 (void *)&cmd_queue_region_set,
10184 (void *)&cmd_queue_region_port,
10185 (void *)&cmd_queue_region_port_id,
10186 (void *)&cmd_queue_region_cmd,
10187 (void *)&cmd_queue_region_id,
10188 (void *)&cmd_queue_region_index,
10189 (void *)&cmd_queue_region_queue_start_index,
10190 (void *)&cmd_queue_region_queue_id,
10191 (void *)&cmd_queue_region_queue_num,
10192 (void *)&cmd_queue_region_queue_num_value,
10197 /* *** queue region and flowtype set *** */
10198 struct cmd_region_flowtype_result {
10199 cmdline_fixed_string_t set;
10200 cmdline_fixed_string_t port;
10202 cmdline_fixed_string_t cmd;
10203 cmdline_fixed_string_t region;
10205 cmdline_fixed_string_t flowtype;
10206 uint8_t flowtype_id;
10210 cmd_region_flowtype_parsed(void *parsed_result,
10211 __rte_unused struct cmdline *cl,
10212 __rte_unused void *data)
10214 struct cmd_region_flowtype_result *res = parsed_result;
10215 int ret = -ENOTSUP;
10216 #ifdef RTE_NET_I40E
10217 struct rte_pmd_i40e_queue_region_conf region_conf;
10218 enum rte_pmd_i40e_queue_region_op op_type;
10221 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10224 #ifdef RTE_NET_I40E
10225 memset(®ion_conf, 0, sizeof(region_conf));
10227 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10228 region_conf.region_id = res->region_id;
10229 region_conf.hw_flowtype = res->flowtype_id;
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, "region flowtype config error: (%s)\n",
10247 cmdline_parse_token_string_t cmd_region_flowtype_set =
10248 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10250 cmdline_parse_token_string_t cmd_region_flowtype_port =
10251 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10253 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10254 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10255 port_id, RTE_UINT16);
10256 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10257 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10258 cmd, "queue-region");
10259 cmdline_parse_token_string_t cmd_region_flowtype_index =
10260 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10261 region, "region_id");
10262 cmdline_parse_token_num_t cmd_region_flowtype_id =
10263 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10264 region_id, RTE_UINT8);
10265 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10266 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10267 flowtype, "flowtype");
10268 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10269 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10270 flowtype_id, RTE_UINT8);
10271 cmdline_parse_inst_t cmd_region_flowtype = {
10272 .f = cmd_region_flowtype_parsed,
10274 .help_str = "set port <port_id> queue-region region_id <value> "
10275 "flowtype <value>: Set a flowtype region index",
10277 (void *)&cmd_region_flowtype_set,
10278 (void *)&cmd_region_flowtype_port,
10279 (void *)&cmd_region_flowtype_port_index,
10280 (void *)&cmd_region_flowtype_cmd,
10281 (void *)&cmd_region_flowtype_index,
10282 (void *)&cmd_region_flowtype_id,
10283 (void *)&cmd_region_flowtype_flow_index,
10284 (void *)&cmd_region_flowtype_flow_id,
10289 /* *** User Priority (UP) to queue region (region_id) set *** */
10290 struct cmd_user_priority_region_result {
10291 cmdline_fixed_string_t set;
10292 cmdline_fixed_string_t port;
10294 cmdline_fixed_string_t cmd;
10295 cmdline_fixed_string_t user_priority;
10296 uint8_t user_priority_id;
10297 cmdline_fixed_string_t region;
10302 cmd_user_priority_region_parsed(void *parsed_result,
10303 __rte_unused struct cmdline *cl,
10304 __rte_unused void *data)
10306 struct cmd_user_priority_region_result *res = parsed_result;
10307 int ret = -ENOTSUP;
10308 #ifdef RTE_NET_I40E
10309 struct rte_pmd_i40e_queue_region_conf region_conf;
10310 enum rte_pmd_i40e_queue_region_op op_type;
10313 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10316 #ifdef RTE_NET_I40E
10317 memset(®ion_conf, 0, sizeof(region_conf));
10318 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10319 region_conf.user_priority = res->user_priority_id;
10320 region_conf.region_id = res->region_id;
10322 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10323 op_type, ®ion_conf);
10330 fprintf(stderr, "function not implemented or supported\n");
10333 fprintf(stderr, "user_priority region config error: (%s)\n",
10338 cmdline_parse_token_string_t cmd_user_priority_region_set =
10339 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10341 cmdline_parse_token_string_t cmd_user_priority_region_port =
10342 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10344 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10345 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10346 port_id, RTE_UINT16);
10347 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10348 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10349 cmd, "queue-region");
10350 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10351 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10352 user_priority, "UP");
10353 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10354 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10355 user_priority_id, RTE_UINT8);
10356 cmdline_parse_token_string_t cmd_user_priority_region_region =
10357 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10358 region, "region_id");
10359 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10360 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10361 region_id, RTE_UINT8);
10363 cmdline_parse_inst_t cmd_user_priority_region = {
10364 .f = cmd_user_priority_region_parsed,
10366 .help_str = "set port <port_id> queue-region UP <value> "
10367 "region_id <value>: Set the mapping of User Priority (UP) "
10368 "to queue region (region_id) ",
10370 (void *)&cmd_user_priority_region_set,
10371 (void *)&cmd_user_priority_region_port,
10372 (void *)&cmd_user_priority_region_port_index,
10373 (void *)&cmd_user_priority_region_cmd,
10374 (void *)&cmd_user_priority_region_UP,
10375 (void *)&cmd_user_priority_region_UP_id,
10376 (void *)&cmd_user_priority_region_region,
10377 (void *)&cmd_user_priority_region_region_id,
10382 /* *** flush all queue region related configuration *** */
10383 struct cmd_flush_queue_region_result {
10384 cmdline_fixed_string_t set;
10385 cmdline_fixed_string_t port;
10387 cmdline_fixed_string_t cmd;
10388 cmdline_fixed_string_t flush;
10389 cmdline_fixed_string_t what;
10393 cmd_flush_queue_region_parsed(void *parsed_result,
10394 __rte_unused struct cmdline *cl,
10395 __rte_unused void *data)
10397 struct cmd_flush_queue_region_result *res = parsed_result;
10398 int ret = -ENOTSUP;
10399 #ifdef RTE_NET_I40E
10400 struct rte_pmd_i40e_queue_region_conf region_conf;
10401 enum rte_pmd_i40e_queue_region_op op_type;
10404 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10407 #ifdef RTE_NET_I40E
10408 memset(®ion_conf, 0, sizeof(region_conf));
10410 if (strcmp(res->what, "on") == 0)
10411 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10413 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10415 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10416 op_type, ®ion_conf);
10423 fprintf(stderr, "function not implemented or supported\n");
10426 fprintf(stderr, "queue region config flush error: (%s)\n",
10431 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10432 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10434 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10435 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10437 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10438 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10439 port_id, RTE_UINT16);
10440 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10441 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10442 cmd, "queue-region");
10443 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10444 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10446 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10447 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10450 cmdline_parse_inst_t cmd_flush_queue_region = {
10451 .f = cmd_flush_queue_region_parsed,
10453 .help_str = "set port <port_id> queue-region flush on|off"
10454 ": flush all queue region related configuration",
10456 (void *)&cmd_flush_queue_region_set,
10457 (void *)&cmd_flush_queue_region_port,
10458 (void *)&cmd_flush_queue_region_port_index,
10459 (void *)&cmd_flush_queue_region_cmd,
10460 (void *)&cmd_flush_queue_region_flush,
10461 (void *)&cmd_flush_queue_region_what,
10466 /* *** get all queue region related configuration info *** */
10467 struct cmd_show_queue_region_info {
10468 cmdline_fixed_string_t show;
10469 cmdline_fixed_string_t port;
10471 cmdline_fixed_string_t cmd;
10475 cmd_show_queue_region_info_parsed(void *parsed_result,
10476 __rte_unused struct cmdline *cl,
10477 __rte_unused void *data)
10479 struct cmd_show_queue_region_info *res = parsed_result;
10480 int ret = -ENOTSUP;
10481 #ifdef RTE_NET_I40E
10482 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10483 enum rte_pmd_i40e_queue_region_op op_type;
10486 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10489 #ifdef RTE_NET_I40E
10490 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10492 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10494 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10495 op_type, &rte_pmd_regions);
10497 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10504 fprintf(stderr, "function not implemented or supported\n");
10507 fprintf(stderr, "queue region config info show error: (%s)\n",
10512 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10513 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10515 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10516 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10518 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10519 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10520 port_id, RTE_UINT16);
10521 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10522 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10523 cmd, "queue-region");
10525 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10526 .f = cmd_show_queue_region_info_parsed,
10528 .help_str = "show port <port_id> queue-region"
10529 ": show all queue region related configuration info",
10531 (void *)&cmd_show_queue_region_info_get,
10532 (void *)&cmd_show_queue_region_info_port,
10533 (void *)&cmd_show_queue_region_info_port_index,
10534 (void *)&cmd_show_queue_region_info_cmd,
10539 /* *** Filters Control *** */
10541 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10543 if ((ip_addr).family == AF_INET) \
10544 (ip) = (ip_addr).addr.ipv4.s_addr; \
10546 fprintf(stderr, "invalid parameter.\n"); \
10551 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10553 if ((ip_addr).family == AF_INET6) \
10554 rte_memcpy(&(ip), \
10555 &((ip_addr).addr.ipv6), \
10556 sizeof(struct in6_addr)); \
10558 fprintf(stderr, "invalid parameter.\n"); \
10563 #ifdef RTE_NET_I40E
10566 str2flowtype(char *string)
10569 static const struct {
10572 } flowtype_str[] = {
10573 {"raw", RTE_ETH_FLOW_RAW},
10574 {"ipv4", RTE_ETH_FLOW_IPV4},
10575 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10576 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10577 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10578 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10579 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10580 {"ipv6", RTE_ETH_FLOW_IPV6},
10581 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10582 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10583 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10584 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10585 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10586 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10587 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10588 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10589 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10590 {"gtpu", RTE_ETH_FLOW_GTPU},
10593 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10594 if (!strcmp(flowtype_str[i].str, string))
10595 return flowtype_str[i].type;
10598 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10599 return (uint16_t)atoi(string);
10601 return RTE_ETH_FLOW_UNKNOWN;
10604 /* *** deal with flow director filter *** */
10605 struct cmd_flow_director_result {
10606 cmdline_fixed_string_t flow_director_filter;
10608 cmdline_fixed_string_t mode;
10609 cmdline_fixed_string_t mode_value;
10610 cmdline_fixed_string_t ops;
10611 cmdline_fixed_string_t flow;
10612 cmdline_fixed_string_t flow_type;
10613 cmdline_fixed_string_t drop;
10614 cmdline_fixed_string_t queue;
10616 cmdline_fixed_string_t fd_id;
10617 uint32_t fd_id_value;
10618 cmdline_fixed_string_t packet;
10623 cmd_flow_director_filter_parsed(void *parsed_result,
10624 __rte_unused struct cmdline *cl,
10625 __rte_unused void *data)
10627 struct cmd_flow_director_result *res = parsed_result;
10629 struct rte_pmd_i40e_flow_type_mapping
10630 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10631 struct rte_pmd_i40e_pkt_template_conf conf;
10632 uint16_t flow_type = str2flowtype(res->flow_type);
10633 uint16_t i, port = res->port_id;
10636 memset(&conf, 0, sizeof(conf));
10638 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10639 fprintf(stderr, "Invalid flow type specified.\n");
10642 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10646 if (mapping[flow_type].pctype == 0ULL) {
10647 fprintf(stderr, "Invalid flow type specified.\n");
10650 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10651 if (mapping[flow_type].pctype & (1ULL << i)) {
10652 conf.input.pctype = i;
10657 conf.input.packet = open_file(res->filepath,
10658 &conf.input.length);
10659 if (!conf.input.packet)
10661 if (!strcmp(res->drop, "drop"))
10662 conf.action.behavior =
10663 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10665 conf.action.behavior =
10666 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10667 conf.action.report_status =
10668 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10669 conf.action.rx_queue = res->queue_id;
10670 conf.soft_id = res->fd_id_value;
10671 add = strcmp(res->ops, "del") ? 1 : 0;
10672 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10676 fprintf(stderr, "flow director config error: (%s)\n",
10678 close_file(conf.input.packet);
10681 cmdline_parse_token_string_t cmd_flow_director_filter =
10682 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10683 flow_director_filter, "flow_director_filter");
10684 cmdline_parse_token_num_t cmd_flow_director_port_id =
10685 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10686 port_id, RTE_UINT16);
10687 cmdline_parse_token_string_t cmd_flow_director_ops =
10688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10689 ops, "add#del#update");
10690 cmdline_parse_token_string_t cmd_flow_director_flow =
10691 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10693 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10696 cmdline_parse_token_string_t cmd_flow_director_drop =
10697 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10699 cmdline_parse_token_string_t cmd_flow_director_queue =
10700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10702 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10703 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10704 queue_id, RTE_UINT16);
10705 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10706 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10708 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10709 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10710 fd_id_value, RTE_UINT32);
10712 cmdline_parse_token_string_t cmd_flow_director_mode =
10713 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10715 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10716 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10717 mode_value, "raw");
10718 cmdline_parse_token_string_t cmd_flow_director_packet =
10719 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10721 cmdline_parse_token_string_t cmd_flow_director_filepath =
10722 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10725 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10726 .f = cmd_flow_director_filter_parsed,
10728 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10729 "director entry on NIC",
10731 (void *)&cmd_flow_director_filter,
10732 (void *)&cmd_flow_director_port_id,
10733 (void *)&cmd_flow_director_mode,
10734 (void *)&cmd_flow_director_mode_raw,
10735 (void *)&cmd_flow_director_ops,
10736 (void *)&cmd_flow_director_flow,
10737 (void *)&cmd_flow_director_flow_type,
10738 (void *)&cmd_flow_director_drop,
10739 (void *)&cmd_flow_director_queue,
10740 (void *)&cmd_flow_director_queue_id,
10741 (void *)&cmd_flow_director_fd_id,
10742 (void *)&cmd_flow_director_fd_id_value,
10743 (void *)&cmd_flow_director_packet,
10744 (void *)&cmd_flow_director_filepath,
10749 #endif /* RTE_NET_I40E */
10751 /* *** deal with flow director mask *** */
10752 struct cmd_flow_director_mask_result {
10753 cmdline_fixed_string_t flow_director_mask;
10755 cmdline_fixed_string_t mode;
10756 cmdline_fixed_string_t mode_value;
10757 cmdline_fixed_string_t vlan;
10758 uint16_t vlan_mask;
10759 cmdline_fixed_string_t src_mask;
10760 cmdline_ipaddr_t ipv4_src;
10761 cmdline_ipaddr_t ipv6_src;
10763 cmdline_fixed_string_t dst_mask;
10764 cmdline_ipaddr_t ipv4_dst;
10765 cmdline_ipaddr_t ipv6_dst;
10767 cmdline_fixed_string_t mac;
10768 uint8_t mac_addr_byte_mask;
10769 cmdline_fixed_string_t tunnel_id;
10770 uint32_t tunnel_id_mask;
10771 cmdline_fixed_string_t tunnel_type;
10772 uint8_t tunnel_type_mask;
10776 cmd_flow_director_mask_parsed(void *parsed_result,
10777 __rte_unused struct cmdline *cl,
10778 __rte_unused void *data)
10780 struct cmd_flow_director_mask_result *res = parsed_result;
10781 struct rte_eth_fdir_masks *mask;
10782 struct rte_port *port;
10784 port = &ports[res->port_id];
10785 /** Check if the port is not started **/
10786 if (port->port_status != RTE_PORT_STOPPED) {
10787 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10791 mask = &port->dev_conf.fdir_conf.mask;
10793 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10794 if (strcmp(res->mode_value, "MAC-VLAN")) {
10795 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10799 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10800 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10801 if (strcmp(res->mode_value, "Tunnel")) {
10802 fprintf(stderr, "Please set mode to Tunnel.\n");
10806 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10807 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10808 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10809 mask->tunnel_type_mask = res->tunnel_type_mask;
10811 if (strcmp(res->mode_value, "IP")) {
10812 fprintf(stderr, "Please set mode to IP.\n");
10816 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10817 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10818 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10819 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10820 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10821 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10822 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10825 cmd_reconfig_device_queue(res->port_id, 1, 1);
10828 cmdline_parse_token_string_t cmd_flow_director_mask =
10829 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10830 flow_director_mask, "flow_director_mask");
10831 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10832 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10833 port_id, RTE_UINT16);
10834 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10835 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10837 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10838 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10839 vlan_mask, RTE_UINT16);
10840 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10841 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10842 src_mask, "src_mask");
10843 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10844 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10846 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10847 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10849 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10850 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10851 port_src, RTE_UINT16);
10852 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10854 dst_mask, "dst_mask");
10855 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10856 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10858 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10859 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10861 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10862 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10863 port_dst, RTE_UINT16);
10865 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10866 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10868 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10871 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10873 mode_value, "MAC-VLAN");
10874 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10876 mode_value, "Tunnel");
10877 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10878 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10880 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10881 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10882 mac_addr_byte_mask, RTE_UINT8);
10883 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10884 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10885 tunnel_type, "tunnel-type");
10886 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10887 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10888 tunnel_type_mask, RTE_UINT8);
10889 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10890 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10891 tunnel_id, "tunnel-id");
10892 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10893 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10894 tunnel_id_mask, RTE_UINT32);
10896 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10897 .f = cmd_flow_director_mask_parsed,
10899 .help_str = "flow_director_mask ... : "
10900 "Set IP mode flow director's mask on NIC",
10902 (void *)&cmd_flow_director_mask,
10903 (void *)&cmd_flow_director_mask_port_id,
10904 (void *)&cmd_flow_director_mask_mode,
10905 (void *)&cmd_flow_director_mask_mode_ip,
10906 (void *)&cmd_flow_director_mask_vlan,
10907 (void *)&cmd_flow_director_mask_vlan_value,
10908 (void *)&cmd_flow_director_mask_src,
10909 (void *)&cmd_flow_director_mask_ipv4_src,
10910 (void *)&cmd_flow_director_mask_ipv6_src,
10911 (void *)&cmd_flow_director_mask_port_src,
10912 (void *)&cmd_flow_director_mask_dst,
10913 (void *)&cmd_flow_director_mask_ipv4_dst,
10914 (void *)&cmd_flow_director_mask_ipv6_dst,
10915 (void *)&cmd_flow_director_mask_port_dst,
10920 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10921 .f = cmd_flow_director_mask_parsed,
10923 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10924 "flow director's mask on NIC",
10926 (void *)&cmd_flow_director_mask,
10927 (void *)&cmd_flow_director_mask_port_id,
10928 (void *)&cmd_flow_director_mask_mode,
10929 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10930 (void *)&cmd_flow_director_mask_vlan,
10931 (void *)&cmd_flow_director_mask_vlan_value,
10936 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10937 .f = cmd_flow_director_mask_parsed,
10939 .help_str = "flow_director_mask ... : Set tunnel mode "
10940 "flow director's mask on NIC",
10942 (void *)&cmd_flow_director_mask,
10943 (void *)&cmd_flow_director_mask_port_id,
10944 (void *)&cmd_flow_director_mask_mode,
10945 (void *)&cmd_flow_director_mask_mode_tunnel,
10946 (void *)&cmd_flow_director_mask_vlan,
10947 (void *)&cmd_flow_director_mask_vlan_value,
10948 (void *)&cmd_flow_director_mask_mac,
10949 (void *)&cmd_flow_director_mask_mac_value,
10950 (void *)&cmd_flow_director_mask_tunnel_type,
10951 (void *)&cmd_flow_director_mask_tunnel_type_value,
10952 (void *)&cmd_flow_director_mask_tunnel_id,
10953 (void *)&cmd_flow_director_mask_tunnel_id_value,
10958 /* *** deal with flow director flexible payload configuration *** */
10959 struct cmd_flow_director_flexpayload_result {
10960 cmdline_fixed_string_t flow_director_flexpayload;
10962 cmdline_fixed_string_t payload_layer;
10963 cmdline_fixed_string_t payload_cfg;
10967 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10970 const char *p, *p0 = q_arg;
10972 unsigned long int_fld;
10973 char *str_fld[max_num];
10978 p = strchr(p0, '(');
10982 p0 = strchr(p, ')');
10987 if (size >= sizeof(s))
10990 snprintf(s, sizeof(s), "%.*s", size, p);
10991 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10992 if (ret < 0 || ret > max_num)
10994 for (i = 0; i < ret; i++) {
10996 int_fld = strtoul(str_fld[i], &end, 0);
10997 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10999 offsets[i] = (uint16_t)int_fld;
11005 cmd_flow_director_flxpld_parsed(void *parsed_result,
11006 __rte_unused struct cmdline *cl,
11007 __rte_unused void *data)
11009 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11010 struct rte_eth_flex_payload_cfg flex_cfg;
11011 struct rte_port *port;
11014 port = &ports[res->port_id];
11015 /** Check if the port is not started **/
11016 if (port->port_status != RTE_PORT_STOPPED) {
11017 fprintf(stderr, "Please stop port %d first\n", res->port_id);
11021 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11023 if (!strcmp(res->payload_layer, "raw"))
11024 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11025 else if (!strcmp(res->payload_layer, "l2"))
11026 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11027 else if (!strcmp(res->payload_layer, "l3"))
11028 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11029 else if (!strcmp(res->payload_layer, "l4"))
11030 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11032 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11033 RTE_ETH_FDIR_MAX_FLEXLEN);
11035 fprintf(stderr, "error: Cannot parse flex payload input.\n");
11039 fdir_set_flex_payload(res->port_id, &flex_cfg);
11040 cmd_reconfig_device_queue(res->port_id, 1, 1);
11043 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11044 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11045 flow_director_flexpayload,
11046 "flow_director_flex_payload");
11047 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11048 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11049 port_id, RTE_UINT16);
11050 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11051 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11052 payload_layer, "raw#l2#l3#l4");
11053 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11054 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11055 payload_cfg, NULL);
11057 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11058 .f = cmd_flow_director_flxpld_parsed,
11060 .help_str = "flow_director_flexpayload ... : "
11061 "Set flow director's flex payload on NIC",
11063 (void *)&cmd_flow_director_flexpayload,
11064 (void *)&cmd_flow_director_flexpayload_port_id,
11065 (void *)&cmd_flow_director_flexpayload_payload_layer,
11066 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11071 /* Generic flow interface command. */
11072 extern cmdline_parse_inst_t cmd_flow;
11074 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11075 struct cmd_mcast_addr_result {
11076 cmdline_fixed_string_t mcast_addr_cmd;
11077 cmdline_fixed_string_t what;
11079 struct rte_ether_addr mc_addr;
11082 static void cmd_mcast_addr_parsed(void *parsed_result,
11083 __rte_unused struct cmdline *cl,
11084 __rte_unused void *data)
11086 struct cmd_mcast_addr_result *res = parsed_result;
11088 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11090 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
11091 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
11094 if (strcmp(res->what, "add") == 0)
11095 mcast_addr_add(res->port_num, &res->mc_addr);
11097 mcast_addr_remove(res->port_num, &res->mc_addr);
11100 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11101 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11102 mcast_addr_cmd, "mcast_addr");
11103 cmdline_parse_token_string_t cmd_mcast_addr_what =
11104 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11106 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11107 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
11109 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11110 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11112 cmdline_parse_inst_t cmd_mcast_addr = {
11113 .f = cmd_mcast_addr_parsed,
11115 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11116 "Add/Remove multicast MAC address on port_id",
11118 (void *)&cmd_mcast_addr_cmd,
11119 (void *)&cmd_mcast_addr_what,
11120 (void *)&cmd_mcast_addr_portnum,
11121 (void *)&cmd_mcast_addr_addr,
11126 /* vf vlan anti spoof configuration */
11128 /* Common result structure for vf vlan anti spoof */
11129 struct cmd_vf_vlan_anti_spoof_result {
11130 cmdline_fixed_string_t set;
11131 cmdline_fixed_string_t vf;
11132 cmdline_fixed_string_t vlan;
11133 cmdline_fixed_string_t antispoof;
11136 cmdline_fixed_string_t on_off;
11139 /* Common CLI fields for vf vlan anti spoof enable disable */
11140 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11141 TOKEN_STRING_INITIALIZER
11142 (struct cmd_vf_vlan_anti_spoof_result,
11144 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11145 TOKEN_STRING_INITIALIZER
11146 (struct cmd_vf_vlan_anti_spoof_result,
11148 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11149 TOKEN_STRING_INITIALIZER
11150 (struct cmd_vf_vlan_anti_spoof_result,
11152 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11153 TOKEN_STRING_INITIALIZER
11154 (struct cmd_vf_vlan_anti_spoof_result,
11155 antispoof, "antispoof");
11156 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11157 TOKEN_NUM_INITIALIZER
11158 (struct cmd_vf_vlan_anti_spoof_result,
11159 port_id, RTE_UINT16);
11160 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11161 TOKEN_NUM_INITIALIZER
11162 (struct cmd_vf_vlan_anti_spoof_result,
11163 vf_id, RTE_UINT32);
11164 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11165 TOKEN_STRING_INITIALIZER
11166 (struct cmd_vf_vlan_anti_spoof_result,
11170 cmd_set_vf_vlan_anti_spoof_parsed(
11171 void *parsed_result,
11172 __rte_unused struct cmdline *cl,
11173 __rte_unused void *data)
11175 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11176 int ret = -ENOTSUP;
11178 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11180 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11183 #ifdef RTE_NET_IXGBE
11184 if (ret == -ENOTSUP)
11185 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11186 res->vf_id, is_on);
11188 #ifdef RTE_NET_I40E
11189 if (ret == -ENOTSUP)
11190 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11191 res->vf_id, is_on);
11193 #ifdef RTE_NET_BNXT
11194 if (ret == -ENOTSUP)
11195 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11196 res->vf_id, is_on);
11203 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11206 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11209 fprintf(stderr, "function not implemented\n");
11212 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11216 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11217 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11219 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11221 (void *)&cmd_vf_vlan_anti_spoof_set,
11222 (void *)&cmd_vf_vlan_anti_spoof_vf,
11223 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11224 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11225 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11226 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11227 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11232 /* vf mac anti spoof configuration */
11234 /* Common result structure for vf mac anti spoof */
11235 struct cmd_vf_mac_anti_spoof_result {
11236 cmdline_fixed_string_t set;
11237 cmdline_fixed_string_t vf;
11238 cmdline_fixed_string_t mac;
11239 cmdline_fixed_string_t antispoof;
11242 cmdline_fixed_string_t on_off;
11245 /* Common CLI fields for vf mac anti spoof enable disable */
11246 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11247 TOKEN_STRING_INITIALIZER
11248 (struct cmd_vf_mac_anti_spoof_result,
11250 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11251 TOKEN_STRING_INITIALIZER
11252 (struct cmd_vf_mac_anti_spoof_result,
11254 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11255 TOKEN_STRING_INITIALIZER
11256 (struct cmd_vf_mac_anti_spoof_result,
11258 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11259 TOKEN_STRING_INITIALIZER
11260 (struct cmd_vf_mac_anti_spoof_result,
11261 antispoof, "antispoof");
11262 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11263 TOKEN_NUM_INITIALIZER
11264 (struct cmd_vf_mac_anti_spoof_result,
11265 port_id, RTE_UINT16);
11266 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11267 TOKEN_NUM_INITIALIZER
11268 (struct cmd_vf_mac_anti_spoof_result,
11269 vf_id, RTE_UINT32);
11270 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11271 TOKEN_STRING_INITIALIZER
11272 (struct cmd_vf_mac_anti_spoof_result,
11276 cmd_set_vf_mac_anti_spoof_parsed(
11277 void *parsed_result,
11278 __rte_unused struct cmdline *cl,
11279 __rte_unused void *data)
11281 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11282 int ret = -ENOTSUP;
11284 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11286 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11289 #ifdef RTE_NET_IXGBE
11290 if (ret == -ENOTSUP)
11291 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11292 res->vf_id, is_on);
11294 #ifdef RTE_NET_I40E
11295 if (ret == -ENOTSUP)
11296 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11297 res->vf_id, is_on);
11299 #ifdef RTE_NET_BNXT
11300 if (ret == -ENOTSUP)
11301 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11302 res->vf_id, is_on);
11309 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11310 res->vf_id, is_on);
11313 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11316 fprintf(stderr, "function not implemented\n");
11319 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11323 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11324 .f = cmd_set_vf_mac_anti_spoof_parsed,
11326 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11328 (void *)&cmd_vf_mac_anti_spoof_set,
11329 (void *)&cmd_vf_mac_anti_spoof_vf,
11330 (void *)&cmd_vf_mac_anti_spoof_mac,
11331 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11332 (void *)&cmd_vf_mac_anti_spoof_port_id,
11333 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11334 (void *)&cmd_vf_mac_anti_spoof_on_off,
11339 /* vf vlan strip queue configuration */
11341 /* Common result structure for vf mac anti spoof */
11342 struct cmd_vf_vlan_stripq_result {
11343 cmdline_fixed_string_t set;
11344 cmdline_fixed_string_t vf;
11345 cmdline_fixed_string_t vlan;
11346 cmdline_fixed_string_t stripq;
11349 cmdline_fixed_string_t on_off;
11352 /* Common CLI fields for vf vlan strip enable disable */
11353 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11354 TOKEN_STRING_INITIALIZER
11355 (struct cmd_vf_vlan_stripq_result,
11357 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11358 TOKEN_STRING_INITIALIZER
11359 (struct cmd_vf_vlan_stripq_result,
11361 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11362 TOKEN_STRING_INITIALIZER
11363 (struct cmd_vf_vlan_stripq_result,
11365 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11366 TOKEN_STRING_INITIALIZER
11367 (struct cmd_vf_vlan_stripq_result,
11369 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11370 TOKEN_NUM_INITIALIZER
11371 (struct cmd_vf_vlan_stripq_result,
11372 port_id, RTE_UINT16);
11373 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11374 TOKEN_NUM_INITIALIZER
11375 (struct cmd_vf_vlan_stripq_result,
11376 vf_id, RTE_UINT16);
11377 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11378 TOKEN_STRING_INITIALIZER
11379 (struct cmd_vf_vlan_stripq_result,
11383 cmd_set_vf_vlan_stripq_parsed(
11384 void *parsed_result,
11385 __rte_unused struct cmdline *cl,
11386 __rte_unused void *data)
11388 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11389 int ret = -ENOTSUP;
11391 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11393 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11396 #ifdef RTE_NET_IXGBE
11397 if (ret == -ENOTSUP)
11398 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11399 res->vf_id, is_on);
11401 #ifdef RTE_NET_I40E
11402 if (ret == -ENOTSUP)
11403 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11404 res->vf_id, is_on);
11406 #ifdef RTE_NET_BNXT
11407 if (ret == -ENOTSUP)
11408 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11409 res->vf_id, is_on);
11416 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11417 res->vf_id, is_on);
11420 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11423 fprintf(stderr, "function not implemented\n");
11426 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11430 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11431 .f = cmd_set_vf_vlan_stripq_parsed,
11433 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11435 (void *)&cmd_vf_vlan_stripq_set,
11436 (void *)&cmd_vf_vlan_stripq_vf,
11437 (void *)&cmd_vf_vlan_stripq_vlan,
11438 (void *)&cmd_vf_vlan_stripq_stripq,
11439 (void *)&cmd_vf_vlan_stripq_port_id,
11440 (void *)&cmd_vf_vlan_stripq_vf_id,
11441 (void *)&cmd_vf_vlan_stripq_on_off,
11446 /* vf vlan insert configuration */
11448 /* Common result structure for vf vlan insert */
11449 struct cmd_vf_vlan_insert_result {
11450 cmdline_fixed_string_t set;
11451 cmdline_fixed_string_t vf;
11452 cmdline_fixed_string_t vlan;
11453 cmdline_fixed_string_t insert;
11459 /* Common CLI fields for vf vlan insert enable disable */
11460 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11461 TOKEN_STRING_INITIALIZER
11462 (struct cmd_vf_vlan_insert_result,
11464 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11465 TOKEN_STRING_INITIALIZER
11466 (struct cmd_vf_vlan_insert_result,
11468 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11469 TOKEN_STRING_INITIALIZER
11470 (struct cmd_vf_vlan_insert_result,
11472 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11473 TOKEN_STRING_INITIALIZER
11474 (struct cmd_vf_vlan_insert_result,
11476 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11477 TOKEN_NUM_INITIALIZER
11478 (struct cmd_vf_vlan_insert_result,
11479 port_id, RTE_UINT16);
11480 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11481 TOKEN_NUM_INITIALIZER
11482 (struct cmd_vf_vlan_insert_result,
11483 vf_id, RTE_UINT16);
11484 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11485 TOKEN_NUM_INITIALIZER
11486 (struct cmd_vf_vlan_insert_result,
11487 vlan_id, RTE_UINT16);
11490 cmd_set_vf_vlan_insert_parsed(
11491 void *parsed_result,
11492 __rte_unused struct cmdline *cl,
11493 __rte_unused void *data)
11495 struct cmd_vf_vlan_insert_result *res = parsed_result;
11496 int ret = -ENOTSUP;
11498 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11501 #ifdef RTE_NET_IXGBE
11502 if (ret == -ENOTSUP)
11503 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11506 #ifdef RTE_NET_I40E
11507 if (ret == -ENOTSUP)
11508 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11511 #ifdef RTE_NET_BNXT
11512 if (ret == -ENOTSUP)
11513 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11521 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11522 res->vf_id, res->vlan_id);
11525 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11528 fprintf(stderr, "function not implemented\n");
11531 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11535 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11536 .f = cmd_set_vf_vlan_insert_parsed,
11538 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11540 (void *)&cmd_vf_vlan_insert_set,
11541 (void *)&cmd_vf_vlan_insert_vf,
11542 (void *)&cmd_vf_vlan_insert_vlan,
11543 (void *)&cmd_vf_vlan_insert_insert,
11544 (void *)&cmd_vf_vlan_insert_port_id,
11545 (void *)&cmd_vf_vlan_insert_vf_id,
11546 (void *)&cmd_vf_vlan_insert_vlan_id,
11551 /* tx loopback configuration */
11553 /* Common result structure for tx loopback */
11554 struct cmd_tx_loopback_result {
11555 cmdline_fixed_string_t set;
11556 cmdline_fixed_string_t tx;
11557 cmdline_fixed_string_t loopback;
11559 cmdline_fixed_string_t on_off;
11562 /* Common CLI fields for tx loopback enable disable */
11563 cmdline_parse_token_string_t cmd_tx_loopback_set =
11564 TOKEN_STRING_INITIALIZER
11565 (struct cmd_tx_loopback_result,
11567 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11568 TOKEN_STRING_INITIALIZER
11569 (struct cmd_tx_loopback_result,
11571 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11572 TOKEN_STRING_INITIALIZER
11573 (struct cmd_tx_loopback_result,
11574 loopback, "loopback");
11575 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11576 TOKEN_NUM_INITIALIZER
11577 (struct cmd_tx_loopback_result,
11578 port_id, RTE_UINT16);
11579 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11580 TOKEN_STRING_INITIALIZER
11581 (struct cmd_tx_loopback_result,
11585 cmd_set_tx_loopback_parsed(
11586 void *parsed_result,
11587 __rte_unused struct cmdline *cl,
11588 __rte_unused void *data)
11590 struct cmd_tx_loopback_result *res = parsed_result;
11591 int ret = -ENOTSUP;
11593 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11595 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11598 #ifdef RTE_NET_IXGBE
11599 if (ret == -ENOTSUP)
11600 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11602 #ifdef RTE_NET_I40E
11603 if (ret == -ENOTSUP)
11604 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11606 #ifdef RTE_NET_BNXT
11607 if (ret == -ENOTSUP)
11608 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11610 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11611 if (ret == -ENOTSUP)
11612 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11619 fprintf(stderr, "invalid is_on %d\n", is_on);
11622 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11625 fprintf(stderr, "function not implemented\n");
11628 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11632 cmdline_parse_inst_t cmd_set_tx_loopback = {
11633 .f = cmd_set_tx_loopback_parsed,
11635 .help_str = "set tx loopback <port_id> on|off",
11637 (void *)&cmd_tx_loopback_set,
11638 (void *)&cmd_tx_loopback_tx,
11639 (void *)&cmd_tx_loopback_loopback,
11640 (void *)&cmd_tx_loopback_port_id,
11641 (void *)&cmd_tx_loopback_on_off,
11646 /* all queues drop enable configuration */
11648 /* Common result structure for all queues drop enable */
11649 struct cmd_all_queues_drop_en_result {
11650 cmdline_fixed_string_t set;
11651 cmdline_fixed_string_t all;
11652 cmdline_fixed_string_t queues;
11653 cmdline_fixed_string_t drop;
11655 cmdline_fixed_string_t on_off;
11658 /* Common CLI fields for tx loopback enable disable */
11659 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11660 TOKEN_STRING_INITIALIZER
11661 (struct cmd_all_queues_drop_en_result,
11663 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11664 TOKEN_STRING_INITIALIZER
11665 (struct cmd_all_queues_drop_en_result,
11667 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11668 TOKEN_STRING_INITIALIZER
11669 (struct cmd_all_queues_drop_en_result,
11671 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11672 TOKEN_STRING_INITIALIZER
11673 (struct cmd_all_queues_drop_en_result,
11675 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11676 TOKEN_NUM_INITIALIZER
11677 (struct cmd_all_queues_drop_en_result,
11678 port_id, RTE_UINT16);
11679 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11680 TOKEN_STRING_INITIALIZER
11681 (struct cmd_all_queues_drop_en_result,
11685 cmd_set_all_queues_drop_en_parsed(
11686 void *parsed_result,
11687 __rte_unused struct cmdline *cl,
11688 __rte_unused void *data)
11690 struct cmd_all_queues_drop_en_result *res = parsed_result;
11691 int ret = -ENOTSUP;
11692 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11694 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11697 #ifdef RTE_NET_IXGBE
11698 if (ret == -ENOTSUP)
11699 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11701 #ifdef RTE_NET_BNXT
11702 if (ret == -ENOTSUP)
11703 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11709 fprintf(stderr, "invalid is_on %d\n", is_on);
11712 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11715 fprintf(stderr, "function not implemented\n");
11718 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11722 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11723 .f = cmd_set_all_queues_drop_en_parsed,
11725 .help_str = "set all queues drop <port_id> on|off",
11727 (void *)&cmd_all_queues_drop_en_set,
11728 (void *)&cmd_all_queues_drop_en_all,
11729 (void *)&cmd_all_queues_drop_en_queues,
11730 (void *)&cmd_all_queues_drop_en_drop,
11731 (void *)&cmd_all_queues_drop_en_port_id,
11732 (void *)&cmd_all_queues_drop_en_on_off,
11737 /* vf split drop enable configuration */
11739 /* Common result structure for vf split drop enable */
11740 struct cmd_vf_split_drop_en_result {
11741 cmdline_fixed_string_t set;
11742 cmdline_fixed_string_t vf;
11743 cmdline_fixed_string_t split;
11744 cmdline_fixed_string_t drop;
11747 cmdline_fixed_string_t on_off;
11750 /* Common CLI fields for vf split drop enable disable */
11751 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11752 TOKEN_STRING_INITIALIZER
11753 (struct cmd_vf_split_drop_en_result,
11755 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11756 TOKEN_STRING_INITIALIZER
11757 (struct cmd_vf_split_drop_en_result,
11759 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11760 TOKEN_STRING_INITIALIZER
11761 (struct cmd_vf_split_drop_en_result,
11763 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11764 TOKEN_STRING_INITIALIZER
11765 (struct cmd_vf_split_drop_en_result,
11767 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11768 TOKEN_NUM_INITIALIZER
11769 (struct cmd_vf_split_drop_en_result,
11770 port_id, RTE_UINT16);
11771 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11772 TOKEN_NUM_INITIALIZER
11773 (struct cmd_vf_split_drop_en_result,
11774 vf_id, RTE_UINT16);
11775 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11776 TOKEN_STRING_INITIALIZER
11777 (struct cmd_vf_split_drop_en_result,
11781 cmd_set_vf_split_drop_en_parsed(
11782 void *parsed_result,
11783 __rte_unused struct cmdline *cl,
11784 __rte_unused void *data)
11786 struct cmd_vf_split_drop_en_result *res = parsed_result;
11787 int ret = -ENOTSUP;
11788 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11793 #ifdef RTE_NET_IXGBE
11794 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11801 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11802 res->vf_id, is_on);
11805 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11808 fprintf(stderr, "not supported on port %d\n", res->port_id);
11811 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11815 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11816 .f = cmd_set_vf_split_drop_en_parsed,
11818 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11820 (void *)&cmd_vf_split_drop_en_set,
11821 (void *)&cmd_vf_split_drop_en_vf,
11822 (void *)&cmd_vf_split_drop_en_split,
11823 (void *)&cmd_vf_split_drop_en_drop,
11824 (void *)&cmd_vf_split_drop_en_port_id,
11825 (void *)&cmd_vf_split_drop_en_vf_id,
11826 (void *)&cmd_vf_split_drop_en_on_off,
11831 /* vf mac address configuration */
11833 /* Common result structure for vf mac address */
11834 struct cmd_set_vf_mac_addr_result {
11835 cmdline_fixed_string_t set;
11836 cmdline_fixed_string_t vf;
11837 cmdline_fixed_string_t mac;
11838 cmdline_fixed_string_t addr;
11841 struct rte_ether_addr mac_addr;
11845 /* Common CLI fields for vf split drop enable disable */
11846 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11847 TOKEN_STRING_INITIALIZER
11848 (struct cmd_set_vf_mac_addr_result,
11850 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11851 TOKEN_STRING_INITIALIZER
11852 (struct cmd_set_vf_mac_addr_result,
11854 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11855 TOKEN_STRING_INITIALIZER
11856 (struct cmd_set_vf_mac_addr_result,
11858 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11859 TOKEN_STRING_INITIALIZER
11860 (struct cmd_set_vf_mac_addr_result,
11862 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11863 TOKEN_NUM_INITIALIZER
11864 (struct cmd_set_vf_mac_addr_result,
11865 port_id, RTE_UINT16);
11866 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11867 TOKEN_NUM_INITIALIZER
11868 (struct cmd_set_vf_mac_addr_result,
11869 vf_id, RTE_UINT16);
11870 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11871 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11875 cmd_set_vf_mac_addr_parsed(
11876 void *parsed_result,
11877 __rte_unused struct cmdline *cl,
11878 __rte_unused void *data)
11880 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11881 int ret = -ENOTSUP;
11883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11886 #ifdef RTE_NET_IXGBE
11887 if (ret == -ENOTSUP)
11888 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11891 #ifdef RTE_NET_I40E
11892 if (ret == -ENOTSUP)
11893 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11896 #ifdef RTE_NET_BNXT
11897 if (ret == -ENOTSUP)
11898 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11906 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11909 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11912 fprintf(stderr, "function not implemented\n");
11915 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11919 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11920 .f = cmd_set_vf_mac_addr_parsed,
11922 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11924 (void *)&cmd_set_vf_mac_addr_set,
11925 (void *)&cmd_set_vf_mac_addr_vf,
11926 (void *)&cmd_set_vf_mac_addr_mac,
11927 (void *)&cmd_set_vf_mac_addr_addr,
11928 (void *)&cmd_set_vf_mac_addr_port_id,
11929 (void *)&cmd_set_vf_mac_addr_vf_id,
11930 (void *)&cmd_set_vf_mac_addr_mac_addr,
11935 /* MACsec configuration */
11937 /* Common result structure for MACsec offload enable */
11938 struct cmd_macsec_offload_on_result {
11939 cmdline_fixed_string_t set;
11940 cmdline_fixed_string_t macsec;
11941 cmdline_fixed_string_t offload;
11943 cmdline_fixed_string_t on;
11944 cmdline_fixed_string_t encrypt;
11945 cmdline_fixed_string_t en_on_off;
11946 cmdline_fixed_string_t replay_protect;
11947 cmdline_fixed_string_t rp_on_off;
11950 /* Common CLI fields for MACsec offload disable */
11951 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11952 TOKEN_STRING_INITIALIZER
11953 (struct cmd_macsec_offload_on_result,
11955 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11956 TOKEN_STRING_INITIALIZER
11957 (struct cmd_macsec_offload_on_result,
11959 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11960 TOKEN_STRING_INITIALIZER
11961 (struct cmd_macsec_offload_on_result,
11962 offload, "offload");
11963 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11964 TOKEN_NUM_INITIALIZER
11965 (struct cmd_macsec_offload_on_result,
11966 port_id, RTE_UINT16);
11967 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11968 TOKEN_STRING_INITIALIZER
11969 (struct cmd_macsec_offload_on_result,
11971 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11972 TOKEN_STRING_INITIALIZER
11973 (struct cmd_macsec_offload_on_result,
11974 encrypt, "encrypt");
11975 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11976 TOKEN_STRING_INITIALIZER
11977 (struct cmd_macsec_offload_on_result,
11978 en_on_off, "on#off");
11979 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11980 TOKEN_STRING_INITIALIZER
11981 (struct cmd_macsec_offload_on_result,
11982 replay_protect, "replay-protect");
11983 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11984 TOKEN_STRING_INITIALIZER
11985 (struct cmd_macsec_offload_on_result,
11986 rp_on_off, "on#off");
11989 cmd_set_macsec_offload_on_parsed(
11990 void *parsed_result,
11991 __rte_unused struct cmdline *cl,
11992 __rte_unused void *data)
11994 struct cmd_macsec_offload_on_result *res = parsed_result;
11995 int ret = -ENOTSUP;
11996 portid_t port_id = res->port_id;
11997 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11998 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11999 struct rte_eth_dev_info dev_info;
12001 if (port_id_is_invalid(port_id, ENABLED_WARN))
12003 if (!port_is_stopped(port_id)) {
12004 fprintf(stderr, "Please stop port %d first\n", port_id);
12008 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12012 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12013 #ifdef RTE_NET_IXGBE
12014 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12022 ports[port_id].dev_conf.txmode.offloads |=
12023 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12024 cmd_reconfig_device_queue(port_id, 1, 1);
12027 fprintf(stderr, "invalid port_id %d\n", port_id);
12030 fprintf(stderr, "not supported on port %d\n", port_id);
12033 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12037 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12038 .f = cmd_set_macsec_offload_on_parsed,
12040 .help_str = "set macsec offload <port_id> on "
12041 "encrypt on|off replay-protect on|off",
12043 (void *)&cmd_macsec_offload_on_set,
12044 (void *)&cmd_macsec_offload_on_macsec,
12045 (void *)&cmd_macsec_offload_on_offload,
12046 (void *)&cmd_macsec_offload_on_port_id,
12047 (void *)&cmd_macsec_offload_on_on,
12048 (void *)&cmd_macsec_offload_on_encrypt,
12049 (void *)&cmd_macsec_offload_on_en_on_off,
12050 (void *)&cmd_macsec_offload_on_replay_protect,
12051 (void *)&cmd_macsec_offload_on_rp_on_off,
12056 /* Common result structure for MACsec offload disable */
12057 struct cmd_macsec_offload_off_result {
12058 cmdline_fixed_string_t set;
12059 cmdline_fixed_string_t macsec;
12060 cmdline_fixed_string_t offload;
12062 cmdline_fixed_string_t off;
12065 /* Common CLI fields for MACsec offload disable */
12066 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12067 TOKEN_STRING_INITIALIZER
12068 (struct cmd_macsec_offload_off_result,
12070 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12071 TOKEN_STRING_INITIALIZER
12072 (struct cmd_macsec_offload_off_result,
12074 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12075 TOKEN_STRING_INITIALIZER
12076 (struct cmd_macsec_offload_off_result,
12077 offload, "offload");
12078 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12079 TOKEN_NUM_INITIALIZER
12080 (struct cmd_macsec_offload_off_result,
12081 port_id, RTE_UINT16);
12082 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12083 TOKEN_STRING_INITIALIZER
12084 (struct cmd_macsec_offload_off_result,
12088 cmd_set_macsec_offload_off_parsed(
12089 void *parsed_result,
12090 __rte_unused struct cmdline *cl,
12091 __rte_unused void *data)
12093 struct cmd_macsec_offload_off_result *res = parsed_result;
12094 int ret = -ENOTSUP;
12095 struct rte_eth_dev_info dev_info;
12096 portid_t port_id = res->port_id;
12098 if (port_id_is_invalid(port_id, ENABLED_WARN))
12100 if (!port_is_stopped(port_id)) {
12101 fprintf(stderr, "Please stop port %d first\n", port_id);
12105 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12109 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12110 #ifdef RTE_NET_IXGBE
12111 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12116 ports[port_id].dev_conf.txmode.offloads &=
12117 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12118 cmd_reconfig_device_queue(port_id, 1, 1);
12121 fprintf(stderr, "invalid port_id %d\n", port_id);
12124 fprintf(stderr, "not supported on port %d\n", port_id);
12127 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12131 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12132 .f = cmd_set_macsec_offload_off_parsed,
12134 .help_str = "set macsec offload <port_id> off",
12136 (void *)&cmd_macsec_offload_off_set,
12137 (void *)&cmd_macsec_offload_off_macsec,
12138 (void *)&cmd_macsec_offload_off_offload,
12139 (void *)&cmd_macsec_offload_off_port_id,
12140 (void *)&cmd_macsec_offload_off_off,
12145 /* Common result structure for MACsec secure connection configure */
12146 struct cmd_macsec_sc_result {
12147 cmdline_fixed_string_t set;
12148 cmdline_fixed_string_t macsec;
12149 cmdline_fixed_string_t sc;
12150 cmdline_fixed_string_t tx_rx;
12152 struct rte_ether_addr mac;
12156 /* Common CLI fields for MACsec secure connection configure */
12157 cmdline_parse_token_string_t cmd_macsec_sc_set =
12158 TOKEN_STRING_INITIALIZER
12159 (struct cmd_macsec_sc_result,
12161 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12162 TOKEN_STRING_INITIALIZER
12163 (struct cmd_macsec_sc_result,
12165 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12166 TOKEN_STRING_INITIALIZER
12167 (struct cmd_macsec_sc_result,
12169 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12170 TOKEN_STRING_INITIALIZER
12171 (struct cmd_macsec_sc_result,
12173 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12174 TOKEN_NUM_INITIALIZER
12175 (struct cmd_macsec_sc_result,
12176 port_id, RTE_UINT16);
12177 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12178 TOKEN_ETHERADDR_INITIALIZER
12179 (struct cmd_macsec_sc_result,
12181 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12182 TOKEN_NUM_INITIALIZER
12183 (struct cmd_macsec_sc_result,
12187 cmd_set_macsec_sc_parsed(
12188 void *parsed_result,
12189 __rte_unused struct cmdline *cl,
12190 __rte_unused void *data)
12192 struct cmd_macsec_sc_result *res = parsed_result;
12193 int ret = -ENOTSUP;
12194 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12196 #ifdef RTE_NET_IXGBE
12198 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12199 res->mac.addr_bytes) :
12200 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12201 res->mac.addr_bytes, res->pi);
12203 RTE_SET_USED(is_tx);
12209 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12212 fprintf(stderr, "not supported on port %d\n", res->port_id);
12215 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12219 cmdline_parse_inst_t cmd_set_macsec_sc = {
12220 .f = cmd_set_macsec_sc_parsed,
12222 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12224 (void *)&cmd_macsec_sc_set,
12225 (void *)&cmd_macsec_sc_macsec,
12226 (void *)&cmd_macsec_sc_sc,
12227 (void *)&cmd_macsec_sc_tx_rx,
12228 (void *)&cmd_macsec_sc_port_id,
12229 (void *)&cmd_macsec_sc_mac,
12230 (void *)&cmd_macsec_sc_pi,
12235 /* Common result structure for MACsec secure connection configure */
12236 struct cmd_macsec_sa_result {
12237 cmdline_fixed_string_t set;
12238 cmdline_fixed_string_t macsec;
12239 cmdline_fixed_string_t sa;
12240 cmdline_fixed_string_t tx_rx;
12245 cmdline_fixed_string_t key;
12248 /* Common CLI fields for MACsec secure connection configure */
12249 cmdline_parse_token_string_t cmd_macsec_sa_set =
12250 TOKEN_STRING_INITIALIZER
12251 (struct cmd_macsec_sa_result,
12253 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12254 TOKEN_STRING_INITIALIZER
12255 (struct cmd_macsec_sa_result,
12257 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12258 TOKEN_STRING_INITIALIZER
12259 (struct cmd_macsec_sa_result,
12261 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12262 TOKEN_STRING_INITIALIZER
12263 (struct cmd_macsec_sa_result,
12265 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12266 TOKEN_NUM_INITIALIZER
12267 (struct cmd_macsec_sa_result,
12268 port_id, RTE_UINT16);
12269 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12270 TOKEN_NUM_INITIALIZER
12271 (struct cmd_macsec_sa_result,
12273 cmdline_parse_token_num_t cmd_macsec_sa_an =
12274 TOKEN_NUM_INITIALIZER
12275 (struct cmd_macsec_sa_result,
12277 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12278 TOKEN_NUM_INITIALIZER
12279 (struct cmd_macsec_sa_result,
12281 cmdline_parse_token_string_t cmd_macsec_sa_key =
12282 TOKEN_STRING_INITIALIZER
12283 (struct cmd_macsec_sa_result,
12287 cmd_set_macsec_sa_parsed(
12288 void *parsed_result,
12289 __rte_unused struct cmdline *cl,
12290 __rte_unused void *data)
12292 struct cmd_macsec_sa_result *res = parsed_result;
12293 int ret = -ENOTSUP;
12294 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12295 uint8_t key[16] = { 0 };
12301 key_len = strlen(res->key) / 2;
12305 for (i = 0; i < key_len; i++) {
12306 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12309 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12312 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12315 #ifdef RTE_NET_IXGBE
12317 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12318 res->idx, res->an, res->pn, key) :
12319 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12320 res->idx, res->an, res->pn, key);
12322 RTE_SET_USED(is_tx);
12329 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12332 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12335 fprintf(stderr, "not supported on port %d\n", res->port_id);
12338 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12342 cmdline_parse_inst_t cmd_set_macsec_sa = {
12343 .f = cmd_set_macsec_sa_parsed,
12345 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12347 (void *)&cmd_macsec_sa_set,
12348 (void *)&cmd_macsec_sa_macsec,
12349 (void *)&cmd_macsec_sa_sa,
12350 (void *)&cmd_macsec_sa_tx_rx,
12351 (void *)&cmd_macsec_sa_port_id,
12352 (void *)&cmd_macsec_sa_idx,
12353 (void *)&cmd_macsec_sa_an,
12354 (void *)&cmd_macsec_sa_pn,
12355 (void *)&cmd_macsec_sa_key,
12360 /* VF unicast promiscuous mode configuration */
12362 /* Common result structure for VF unicast promiscuous mode */
12363 struct cmd_vf_promisc_result {
12364 cmdline_fixed_string_t set;
12365 cmdline_fixed_string_t vf;
12366 cmdline_fixed_string_t promisc;
12369 cmdline_fixed_string_t on_off;
12372 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12373 cmdline_parse_token_string_t cmd_vf_promisc_set =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_vf_promisc_result,
12377 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_vf_promisc_result,
12381 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12382 TOKEN_STRING_INITIALIZER
12383 (struct cmd_vf_promisc_result,
12384 promisc, "promisc");
12385 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12386 TOKEN_NUM_INITIALIZER
12387 (struct cmd_vf_promisc_result,
12388 port_id, RTE_UINT16);
12389 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12390 TOKEN_NUM_INITIALIZER
12391 (struct cmd_vf_promisc_result,
12392 vf_id, RTE_UINT32);
12393 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12394 TOKEN_STRING_INITIALIZER
12395 (struct cmd_vf_promisc_result,
12399 cmd_set_vf_promisc_parsed(
12400 void *parsed_result,
12401 __rte_unused struct cmdline *cl,
12402 __rte_unused void *data)
12404 struct cmd_vf_promisc_result *res = parsed_result;
12405 int ret = -ENOTSUP;
12407 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12412 #ifdef RTE_NET_I40E
12413 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12414 res->vf_id, is_on);
12421 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12424 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12427 fprintf(stderr, "function not implemented\n");
12430 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12434 cmdline_parse_inst_t cmd_set_vf_promisc = {
12435 .f = cmd_set_vf_promisc_parsed,
12437 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12438 "Set unicast promiscuous mode for a VF from the PF",
12440 (void *)&cmd_vf_promisc_set,
12441 (void *)&cmd_vf_promisc_vf,
12442 (void *)&cmd_vf_promisc_promisc,
12443 (void *)&cmd_vf_promisc_port_id,
12444 (void *)&cmd_vf_promisc_vf_id,
12445 (void *)&cmd_vf_promisc_on_off,
12450 /* VF multicast promiscuous mode configuration */
12452 /* Common result structure for VF multicast promiscuous mode */
12453 struct cmd_vf_allmulti_result {
12454 cmdline_fixed_string_t set;
12455 cmdline_fixed_string_t vf;
12456 cmdline_fixed_string_t allmulti;
12459 cmdline_fixed_string_t on_off;
12462 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12463 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12464 TOKEN_STRING_INITIALIZER
12465 (struct cmd_vf_allmulti_result,
12467 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12468 TOKEN_STRING_INITIALIZER
12469 (struct cmd_vf_allmulti_result,
12471 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12472 TOKEN_STRING_INITIALIZER
12473 (struct cmd_vf_allmulti_result,
12474 allmulti, "allmulti");
12475 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12476 TOKEN_NUM_INITIALIZER
12477 (struct cmd_vf_allmulti_result,
12478 port_id, RTE_UINT16);
12479 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12480 TOKEN_NUM_INITIALIZER
12481 (struct cmd_vf_allmulti_result,
12482 vf_id, RTE_UINT32);
12483 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12484 TOKEN_STRING_INITIALIZER
12485 (struct cmd_vf_allmulti_result,
12489 cmd_set_vf_allmulti_parsed(
12490 void *parsed_result,
12491 __rte_unused struct cmdline *cl,
12492 __rte_unused void *data)
12494 struct cmd_vf_allmulti_result *res = parsed_result;
12495 int ret = -ENOTSUP;
12497 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12499 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12502 #ifdef RTE_NET_I40E
12503 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12504 res->vf_id, is_on);
12511 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
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_allmulti = {
12525 .f = cmd_set_vf_allmulti_parsed,
12527 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12528 "Set multicast promiscuous mode for a VF from the PF",
12530 (void *)&cmd_vf_allmulti_set,
12531 (void *)&cmd_vf_allmulti_vf,
12532 (void *)&cmd_vf_allmulti_allmulti,
12533 (void *)&cmd_vf_allmulti_port_id,
12534 (void *)&cmd_vf_allmulti_vf_id,
12535 (void *)&cmd_vf_allmulti_on_off,
12540 /* vf broadcast mode configuration */
12542 /* Common result structure for vf broadcast */
12543 struct cmd_set_vf_broadcast_result {
12544 cmdline_fixed_string_t set;
12545 cmdline_fixed_string_t vf;
12546 cmdline_fixed_string_t broadcast;
12549 cmdline_fixed_string_t on_off;
12552 /* Common CLI fields for vf broadcast enable disable */
12553 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12554 TOKEN_STRING_INITIALIZER
12555 (struct cmd_set_vf_broadcast_result,
12557 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12558 TOKEN_STRING_INITIALIZER
12559 (struct cmd_set_vf_broadcast_result,
12561 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12562 TOKEN_STRING_INITIALIZER
12563 (struct cmd_set_vf_broadcast_result,
12564 broadcast, "broadcast");
12565 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12566 TOKEN_NUM_INITIALIZER
12567 (struct cmd_set_vf_broadcast_result,
12568 port_id, RTE_UINT16);
12569 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12570 TOKEN_NUM_INITIALIZER
12571 (struct cmd_set_vf_broadcast_result,
12572 vf_id, RTE_UINT16);
12573 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12574 TOKEN_STRING_INITIALIZER
12575 (struct cmd_set_vf_broadcast_result,
12579 cmd_set_vf_broadcast_parsed(
12580 void *parsed_result,
12581 __rte_unused struct cmdline *cl,
12582 __rte_unused void *data)
12584 struct cmd_set_vf_broadcast_result *res = parsed_result;
12585 int ret = -ENOTSUP;
12587 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12589 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12592 #ifdef RTE_NET_I40E
12593 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12594 res->vf_id, is_on);
12601 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12602 res->vf_id, is_on);
12605 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12608 fprintf(stderr, "function not implemented\n");
12611 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12615 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12616 .f = cmd_set_vf_broadcast_parsed,
12618 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12620 (void *)&cmd_set_vf_broadcast_set,
12621 (void *)&cmd_set_vf_broadcast_vf,
12622 (void *)&cmd_set_vf_broadcast_broadcast,
12623 (void *)&cmd_set_vf_broadcast_port_id,
12624 (void *)&cmd_set_vf_broadcast_vf_id,
12625 (void *)&cmd_set_vf_broadcast_on_off,
12630 /* vf vlan tag configuration */
12632 /* Common result structure for vf vlan tag */
12633 struct cmd_set_vf_vlan_tag_result {
12634 cmdline_fixed_string_t set;
12635 cmdline_fixed_string_t vf;
12636 cmdline_fixed_string_t vlan;
12637 cmdline_fixed_string_t tag;
12640 cmdline_fixed_string_t on_off;
12643 /* Common CLI fields for vf vlan tag enable disable */
12644 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12645 TOKEN_STRING_INITIALIZER
12646 (struct cmd_set_vf_vlan_tag_result,
12648 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12649 TOKEN_STRING_INITIALIZER
12650 (struct cmd_set_vf_vlan_tag_result,
12652 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12653 TOKEN_STRING_INITIALIZER
12654 (struct cmd_set_vf_vlan_tag_result,
12656 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12657 TOKEN_STRING_INITIALIZER
12658 (struct cmd_set_vf_vlan_tag_result,
12660 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12661 TOKEN_NUM_INITIALIZER
12662 (struct cmd_set_vf_vlan_tag_result,
12663 port_id, RTE_UINT16);
12664 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12665 TOKEN_NUM_INITIALIZER
12666 (struct cmd_set_vf_vlan_tag_result,
12667 vf_id, RTE_UINT16);
12668 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12669 TOKEN_STRING_INITIALIZER
12670 (struct cmd_set_vf_vlan_tag_result,
12674 cmd_set_vf_vlan_tag_parsed(
12675 void *parsed_result,
12676 __rte_unused struct cmdline *cl,
12677 __rte_unused void *data)
12679 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12680 int ret = -ENOTSUP;
12682 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12687 #ifdef RTE_NET_I40E
12688 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12689 res->vf_id, is_on);
12696 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12697 res->vf_id, is_on);
12700 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12703 fprintf(stderr, "function not implemented\n");
12706 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12710 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12711 .f = cmd_set_vf_vlan_tag_parsed,
12713 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12715 (void *)&cmd_set_vf_vlan_tag_set,
12716 (void *)&cmd_set_vf_vlan_tag_vf,
12717 (void *)&cmd_set_vf_vlan_tag_vlan,
12718 (void *)&cmd_set_vf_vlan_tag_tag,
12719 (void *)&cmd_set_vf_vlan_tag_port_id,
12720 (void *)&cmd_set_vf_vlan_tag_vf_id,
12721 (void *)&cmd_set_vf_vlan_tag_on_off,
12726 /* Common definition of VF and TC TX bandwidth configuration */
12727 struct cmd_vf_tc_bw_result {
12728 cmdline_fixed_string_t set;
12729 cmdline_fixed_string_t vf;
12730 cmdline_fixed_string_t tc;
12731 cmdline_fixed_string_t tx;
12732 cmdline_fixed_string_t min_bw;
12733 cmdline_fixed_string_t max_bw;
12734 cmdline_fixed_string_t strict_link_prio;
12739 cmdline_fixed_string_t bw_list;
12743 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12744 TOKEN_STRING_INITIALIZER
12745 (struct cmd_vf_tc_bw_result,
12747 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12748 TOKEN_STRING_INITIALIZER
12749 (struct cmd_vf_tc_bw_result,
12751 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12752 TOKEN_STRING_INITIALIZER
12753 (struct cmd_vf_tc_bw_result,
12755 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12756 TOKEN_STRING_INITIALIZER
12757 (struct cmd_vf_tc_bw_result,
12759 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12760 TOKEN_STRING_INITIALIZER
12761 (struct cmd_vf_tc_bw_result,
12762 strict_link_prio, "strict-link-priority");
12763 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12764 TOKEN_STRING_INITIALIZER
12765 (struct cmd_vf_tc_bw_result,
12766 min_bw, "min-bandwidth");
12767 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12768 TOKEN_STRING_INITIALIZER
12769 (struct cmd_vf_tc_bw_result,
12770 max_bw, "max-bandwidth");
12771 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12772 TOKEN_NUM_INITIALIZER
12773 (struct cmd_vf_tc_bw_result,
12774 port_id, RTE_UINT16);
12775 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12776 TOKEN_NUM_INITIALIZER
12777 (struct cmd_vf_tc_bw_result,
12778 vf_id, RTE_UINT16);
12779 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12780 TOKEN_NUM_INITIALIZER
12781 (struct cmd_vf_tc_bw_result,
12783 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12784 TOKEN_NUM_INITIALIZER
12785 (struct cmd_vf_tc_bw_result,
12787 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12788 TOKEN_STRING_INITIALIZER
12789 (struct cmd_vf_tc_bw_result,
12791 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12792 TOKEN_NUM_INITIALIZER
12793 (struct cmd_vf_tc_bw_result,
12794 tc_map, RTE_UINT8);
12796 /* VF max bandwidth setting */
12798 cmd_vf_max_bw_parsed(
12799 void *parsed_result,
12800 __rte_unused struct cmdline *cl,
12801 __rte_unused void *data)
12803 struct cmd_vf_tc_bw_result *res = parsed_result;
12804 int ret = -ENOTSUP;
12806 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12809 #ifdef RTE_NET_I40E
12810 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12811 res->vf_id, res->bw);
12818 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12819 res->vf_id, res->bw);
12822 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12825 fprintf(stderr, "function not implemented\n");
12828 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12832 cmdline_parse_inst_t cmd_vf_max_bw = {
12833 .f = cmd_vf_max_bw_parsed,
12835 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12837 (void *)&cmd_vf_tc_bw_set,
12838 (void *)&cmd_vf_tc_bw_vf,
12839 (void *)&cmd_vf_tc_bw_tx,
12840 (void *)&cmd_vf_tc_bw_max_bw,
12841 (void *)&cmd_vf_tc_bw_port_id,
12842 (void *)&cmd_vf_tc_bw_vf_id,
12843 (void *)&cmd_vf_tc_bw_bw,
12849 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12854 const char *p, *p0 = str;
12861 p = strchr(p0, '(');
12864 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12868 p0 = strchr(p, ')');
12871 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12875 if (size >= sizeof(s)) {
12877 "The string size exceeds the internal buffer size\n");
12880 snprintf(s, sizeof(s), "%.*s", size, p);
12881 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12883 fprintf(stderr, "Failed to get the bandwidth list.\n");
12887 for (i = 0; i < ret; i++)
12888 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12893 /* TC min bandwidth setting */
12895 cmd_vf_tc_min_bw_parsed(
12896 void *parsed_result,
12897 __rte_unused struct cmdline *cl,
12898 __rte_unused void *data)
12900 struct cmd_vf_tc_bw_result *res = parsed_result;
12903 int ret = -ENOTSUP;
12905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12908 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12912 #ifdef RTE_NET_I40E
12913 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12921 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12924 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12927 fprintf(stderr, "function not implemented\n");
12930 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12934 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12935 .f = cmd_vf_tc_min_bw_parsed,
12937 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12938 " <bw1, bw2, ...>",
12940 (void *)&cmd_vf_tc_bw_set,
12941 (void *)&cmd_vf_tc_bw_vf,
12942 (void *)&cmd_vf_tc_bw_tc,
12943 (void *)&cmd_vf_tc_bw_tx,
12944 (void *)&cmd_vf_tc_bw_min_bw,
12945 (void *)&cmd_vf_tc_bw_port_id,
12946 (void *)&cmd_vf_tc_bw_vf_id,
12947 (void *)&cmd_vf_tc_bw_bw_list,
12953 cmd_tc_min_bw_parsed(
12954 void *parsed_result,
12955 __rte_unused struct cmdline *cl,
12956 __rte_unused void *data)
12958 struct cmd_vf_tc_bw_result *res = parsed_result;
12959 struct rte_port *port;
12962 int ret = -ENOTSUP;
12964 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12967 port = &ports[res->port_id];
12968 /** Check if the port is not started **/
12969 if (port->port_status != RTE_PORT_STOPPED) {
12970 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12974 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12978 #ifdef RTE_NET_IXGBE
12979 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12986 fprintf(stderr, "invalid bandwidth\n");
12989 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12992 fprintf(stderr, "function not implemented\n");
12995 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12999 cmdline_parse_inst_t cmd_tc_min_bw = {
13000 .f = cmd_tc_min_bw_parsed,
13002 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13004 (void *)&cmd_vf_tc_bw_set,
13005 (void *)&cmd_vf_tc_bw_tc,
13006 (void *)&cmd_vf_tc_bw_tx,
13007 (void *)&cmd_vf_tc_bw_min_bw,
13008 (void *)&cmd_vf_tc_bw_port_id,
13009 (void *)&cmd_vf_tc_bw_bw_list,
13014 /* TC max bandwidth setting */
13016 cmd_vf_tc_max_bw_parsed(
13017 void *parsed_result,
13018 __rte_unused struct cmdline *cl,
13019 __rte_unused void *data)
13021 struct cmd_vf_tc_bw_result *res = parsed_result;
13022 int ret = -ENOTSUP;
13024 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13027 #ifdef RTE_NET_I40E
13028 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13029 res->tc_no, res->bw);
13037 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
13038 res->vf_id, res->tc_no, res->bw);
13041 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13044 fprintf(stderr, "function not implemented\n");
13047 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13051 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13052 .f = cmd_vf_tc_max_bw_parsed,
13054 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13057 (void *)&cmd_vf_tc_bw_set,
13058 (void *)&cmd_vf_tc_bw_vf,
13059 (void *)&cmd_vf_tc_bw_tc,
13060 (void *)&cmd_vf_tc_bw_tx,
13061 (void *)&cmd_vf_tc_bw_max_bw,
13062 (void *)&cmd_vf_tc_bw_port_id,
13063 (void *)&cmd_vf_tc_bw_vf_id,
13064 (void *)&cmd_vf_tc_bw_tc_no,
13065 (void *)&cmd_vf_tc_bw_bw,
13070 /** Set VXLAN encapsulation details */
13071 struct cmd_set_vxlan_result {
13072 cmdline_fixed_string_t set;
13073 cmdline_fixed_string_t vxlan;
13074 cmdline_fixed_string_t pos_token;
13075 cmdline_fixed_string_t ip_version;
13076 uint32_t vlan_present:1;
13080 cmdline_ipaddr_t ip_src;
13081 cmdline_ipaddr_t ip_dst;
13085 struct rte_ether_addr eth_src;
13086 struct rte_ether_addr eth_dst;
13089 cmdline_parse_token_string_t cmd_set_vxlan_set =
13090 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
13091 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
13092 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
13093 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
13094 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13096 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
13097 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13098 "vxlan-with-vlan");
13099 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
13100 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13102 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
13103 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
13105 cmdline_parse_token_string_t cmd_set_vxlan_vni =
13106 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13108 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
13109 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
13110 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
13111 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13113 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
13114 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
13115 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
13116 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13118 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
13119 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
13120 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13121 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13123 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13124 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
13125 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13126 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13128 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13129 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
13130 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13131 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13133 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13134 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13135 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13136 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13138 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13139 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13140 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13141 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13143 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13144 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13145 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13146 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13148 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13149 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13150 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13151 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13153 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13154 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13156 static void cmd_set_vxlan_parsed(void *parsed_result,
13157 __rte_unused struct cmdline *cl,
13158 __rte_unused void *data)
13160 struct cmd_set_vxlan_result *res = parsed_result;
13165 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13168 vxlan_encap_conf.select_tos_ttl = 0;
13169 if (strcmp(res->vxlan, "vxlan") == 0)
13170 vxlan_encap_conf.select_vlan = 0;
13171 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13172 vxlan_encap_conf.select_vlan = 1;
13173 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13174 vxlan_encap_conf.select_vlan = 0;
13175 vxlan_encap_conf.select_tos_ttl = 1;
13177 if (strcmp(res->ip_version, "ipv4") == 0)
13178 vxlan_encap_conf.select_ipv4 = 1;
13179 else if (strcmp(res->ip_version, "ipv6") == 0)
13180 vxlan_encap_conf.select_ipv4 = 0;
13183 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13184 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13185 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13186 vxlan_encap_conf.ip_tos = res->tos;
13187 vxlan_encap_conf.ip_ttl = res->ttl;
13188 if (vxlan_encap_conf.select_ipv4) {
13189 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13190 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13192 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13193 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13195 if (vxlan_encap_conf.select_vlan)
13196 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13197 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13198 RTE_ETHER_ADDR_LEN);
13199 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13200 RTE_ETHER_ADDR_LEN);
13203 cmdline_parse_inst_t cmd_set_vxlan = {
13204 .f = cmd_set_vxlan_parsed,
13206 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13207 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13208 " eth-src <eth-src> eth-dst <eth-dst>",
13210 (void *)&cmd_set_vxlan_set,
13211 (void *)&cmd_set_vxlan_vxlan,
13212 (void *)&cmd_set_vxlan_ip_version,
13213 (void *)&cmd_set_vxlan_ip_version_value,
13214 (void *)&cmd_set_vxlan_vni,
13215 (void *)&cmd_set_vxlan_vni_value,
13216 (void *)&cmd_set_vxlan_udp_src,
13217 (void *)&cmd_set_vxlan_udp_src_value,
13218 (void *)&cmd_set_vxlan_udp_dst,
13219 (void *)&cmd_set_vxlan_udp_dst_value,
13220 (void *)&cmd_set_vxlan_ip_src,
13221 (void *)&cmd_set_vxlan_ip_src_value,
13222 (void *)&cmd_set_vxlan_ip_dst,
13223 (void *)&cmd_set_vxlan_ip_dst_value,
13224 (void *)&cmd_set_vxlan_eth_src,
13225 (void *)&cmd_set_vxlan_eth_src_value,
13226 (void *)&cmd_set_vxlan_eth_dst,
13227 (void *)&cmd_set_vxlan_eth_dst_value,
13232 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13233 .f = cmd_set_vxlan_parsed,
13235 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13236 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13237 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13238 " eth-dst <eth-dst>",
13240 (void *)&cmd_set_vxlan_set,
13241 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13242 (void *)&cmd_set_vxlan_ip_version,
13243 (void *)&cmd_set_vxlan_ip_version_value,
13244 (void *)&cmd_set_vxlan_vni,
13245 (void *)&cmd_set_vxlan_vni_value,
13246 (void *)&cmd_set_vxlan_udp_src,
13247 (void *)&cmd_set_vxlan_udp_src_value,
13248 (void *)&cmd_set_vxlan_udp_dst,
13249 (void *)&cmd_set_vxlan_udp_dst_value,
13250 (void *)&cmd_set_vxlan_ip_tos,
13251 (void *)&cmd_set_vxlan_ip_tos_value,
13252 (void *)&cmd_set_vxlan_ip_ttl,
13253 (void *)&cmd_set_vxlan_ip_ttl_value,
13254 (void *)&cmd_set_vxlan_ip_src,
13255 (void *)&cmd_set_vxlan_ip_src_value,
13256 (void *)&cmd_set_vxlan_ip_dst,
13257 (void *)&cmd_set_vxlan_ip_dst_value,
13258 (void *)&cmd_set_vxlan_eth_src,
13259 (void *)&cmd_set_vxlan_eth_src_value,
13260 (void *)&cmd_set_vxlan_eth_dst,
13261 (void *)&cmd_set_vxlan_eth_dst_value,
13266 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13267 .f = cmd_set_vxlan_parsed,
13269 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13270 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13271 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13274 (void *)&cmd_set_vxlan_set,
13275 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13276 (void *)&cmd_set_vxlan_ip_version,
13277 (void *)&cmd_set_vxlan_ip_version_value,
13278 (void *)&cmd_set_vxlan_vni,
13279 (void *)&cmd_set_vxlan_vni_value,
13280 (void *)&cmd_set_vxlan_udp_src,
13281 (void *)&cmd_set_vxlan_udp_src_value,
13282 (void *)&cmd_set_vxlan_udp_dst,
13283 (void *)&cmd_set_vxlan_udp_dst_value,
13284 (void *)&cmd_set_vxlan_ip_src,
13285 (void *)&cmd_set_vxlan_ip_src_value,
13286 (void *)&cmd_set_vxlan_ip_dst,
13287 (void *)&cmd_set_vxlan_ip_dst_value,
13288 (void *)&cmd_set_vxlan_vlan,
13289 (void *)&cmd_set_vxlan_vlan_value,
13290 (void *)&cmd_set_vxlan_eth_src,
13291 (void *)&cmd_set_vxlan_eth_src_value,
13292 (void *)&cmd_set_vxlan_eth_dst,
13293 (void *)&cmd_set_vxlan_eth_dst_value,
13298 /** Set NVGRE encapsulation details */
13299 struct cmd_set_nvgre_result {
13300 cmdline_fixed_string_t set;
13301 cmdline_fixed_string_t nvgre;
13302 cmdline_fixed_string_t pos_token;
13303 cmdline_fixed_string_t ip_version;
13305 cmdline_ipaddr_t ip_src;
13306 cmdline_ipaddr_t ip_dst;
13308 struct rte_ether_addr eth_src;
13309 struct rte_ether_addr eth_dst;
13312 cmdline_parse_token_string_t cmd_set_nvgre_set =
13313 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13314 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13315 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13316 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13317 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13318 "nvgre-with-vlan");
13319 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13320 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13322 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13323 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13325 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13326 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13328 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13329 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13330 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13331 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13333 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13334 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13335 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13336 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13338 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13339 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13340 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13341 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13343 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13344 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13345 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13346 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13348 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13349 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13350 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13351 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13353 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13354 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13356 static void cmd_set_nvgre_parsed(void *parsed_result,
13357 __rte_unused struct cmdline *cl,
13358 __rte_unused void *data)
13360 struct cmd_set_nvgre_result *res = parsed_result;
13362 uint32_t nvgre_tni;
13365 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13368 if (strcmp(res->nvgre, "nvgre") == 0)
13369 nvgre_encap_conf.select_vlan = 0;
13370 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13371 nvgre_encap_conf.select_vlan = 1;
13372 if (strcmp(res->ip_version, "ipv4") == 0)
13373 nvgre_encap_conf.select_ipv4 = 1;
13374 else if (strcmp(res->ip_version, "ipv6") == 0)
13375 nvgre_encap_conf.select_ipv4 = 0;
13378 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13379 if (nvgre_encap_conf.select_ipv4) {
13380 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13381 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13383 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13384 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13386 if (nvgre_encap_conf.select_vlan)
13387 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13388 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13389 RTE_ETHER_ADDR_LEN);
13390 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13391 RTE_ETHER_ADDR_LEN);
13394 cmdline_parse_inst_t cmd_set_nvgre = {
13395 .f = cmd_set_nvgre_parsed,
13397 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13398 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13399 " eth-dst <eth-dst>",
13401 (void *)&cmd_set_nvgre_set,
13402 (void *)&cmd_set_nvgre_nvgre,
13403 (void *)&cmd_set_nvgre_ip_version,
13404 (void *)&cmd_set_nvgre_ip_version_value,
13405 (void *)&cmd_set_nvgre_tni,
13406 (void *)&cmd_set_nvgre_tni_value,
13407 (void *)&cmd_set_nvgre_ip_src,
13408 (void *)&cmd_set_nvgre_ip_src_value,
13409 (void *)&cmd_set_nvgre_ip_dst,
13410 (void *)&cmd_set_nvgre_ip_dst_value,
13411 (void *)&cmd_set_nvgre_eth_src,
13412 (void *)&cmd_set_nvgre_eth_src_value,
13413 (void *)&cmd_set_nvgre_eth_dst,
13414 (void *)&cmd_set_nvgre_eth_dst_value,
13419 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13420 .f = cmd_set_nvgre_parsed,
13422 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13423 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13424 " eth-src <eth-src> eth-dst <eth-dst>",
13426 (void *)&cmd_set_nvgre_set,
13427 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13428 (void *)&cmd_set_nvgre_ip_version,
13429 (void *)&cmd_set_nvgre_ip_version_value,
13430 (void *)&cmd_set_nvgre_tni,
13431 (void *)&cmd_set_nvgre_tni_value,
13432 (void *)&cmd_set_nvgre_ip_src,
13433 (void *)&cmd_set_nvgre_ip_src_value,
13434 (void *)&cmd_set_nvgre_ip_dst,
13435 (void *)&cmd_set_nvgre_ip_dst_value,
13436 (void *)&cmd_set_nvgre_vlan,
13437 (void *)&cmd_set_nvgre_vlan_value,
13438 (void *)&cmd_set_nvgre_eth_src,
13439 (void *)&cmd_set_nvgre_eth_src_value,
13440 (void *)&cmd_set_nvgre_eth_dst,
13441 (void *)&cmd_set_nvgre_eth_dst_value,
13446 /** Set L2 encapsulation details */
13447 struct cmd_set_l2_encap_result {
13448 cmdline_fixed_string_t set;
13449 cmdline_fixed_string_t l2_encap;
13450 cmdline_fixed_string_t pos_token;
13451 cmdline_fixed_string_t ip_version;
13452 uint32_t vlan_present:1;
13454 struct rte_ether_addr eth_src;
13455 struct rte_ether_addr eth_dst;
13458 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13459 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13460 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13461 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13462 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13463 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13464 "l2_encap-with-vlan");
13465 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13466 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13468 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13469 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13471 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13472 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13474 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13475 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13476 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13477 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13479 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13480 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13481 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13482 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13484 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13485 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13487 static void cmd_set_l2_encap_parsed(void *parsed_result,
13488 __rte_unused struct cmdline *cl,
13489 __rte_unused void *data)
13491 struct cmd_set_l2_encap_result *res = parsed_result;
13493 if (strcmp(res->l2_encap, "l2_encap") == 0)
13494 l2_encap_conf.select_vlan = 0;
13495 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13496 l2_encap_conf.select_vlan = 1;
13497 if (strcmp(res->ip_version, "ipv4") == 0)
13498 l2_encap_conf.select_ipv4 = 1;
13499 else if (strcmp(res->ip_version, "ipv6") == 0)
13500 l2_encap_conf.select_ipv4 = 0;
13503 if (l2_encap_conf.select_vlan)
13504 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13505 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13506 RTE_ETHER_ADDR_LEN);
13507 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13508 RTE_ETHER_ADDR_LEN);
13511 cmdline_parse_inst_t cmd_set_l2_encap = {
13512 .f = cmd_set_l2_encap_parsed,
13514 .help_str = "set l2_encap ip-version ipv4|ipv6"
13515 " eth-src <eth-src> eth-dst <eth-dst>",
13517 (void *)&cmd_set_l2_encap_set,
13518 (void *)&cmd_set_l2_encap_l2_encap,
13519 (void *)&cmd_set_l2_encap_ip_version,
13520 (void *)&cmd_set_l2_encap_ip_version_value,
13521 (void *)&cmd_set_l2_encap_eth_src,
13522 (void *)&cmd_set_l2_encap_eth_src_value,
13523 (void *)&cmd_set_l2_encap_eth_dst,
13524 (void *)&cmd_set_l2_encap_eth_dst_value,
13529 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13530 .f = cmd_set_l2_encap_parsed,
13532 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13533 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13535 (void *)&cmd_set_l2_encap_set,
13536 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13537 (void *)&cmd_set_l2_encap_ip_version,
13538 (void *)&cmd_set_l2_encap_ip_version_value,
13539 (void *)&cmd_set_l2_encap_vlan,
13540 (void *)&cmd_set_l2_encap_vlan_value,
13541 (void *)&cmd_set_l2_encap_eth_src,
13542 (void *)&cmd_set_l2_encap_eth_src_value,
13543 (void *)&cmd_set_l2_encap_eth_dst,
13544 (void *)&cmd_set_l2_encap_eth_dst_value,
13549 /** Set L2 decapsulation details */
13550 struct cmd_set_l2_decap_result {
13551 cmdline_fixed_string_t set;
13552 cmdline_fixed_string_t l2_decap;
13553 cmdline_fixed_string_t pos_token;
13554 uint32_t vlan_present:1;
13557 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13558 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13559 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13560 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13562 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13563 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13564 "l2_decap-with-vlan");
13566 static void cmd_set_l2_decap_parsed(void *parsed_result,
13567 __rte_unused struct cmdline *cl,
13568 __rte_unused void *data)
13570 struct cmd_set_l2_decap_result *res = parsed_result;
13572 if (strcmp(res->l2_decap, "l2_decap") == 0)
13573 l2_decap_conf.select_vlan = 0;
13574 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13575 l2_decap_conf.select_vlan = 1;
13578 cmdline_parse_inst_t cmd_set_l2_decap = {
13579 .f = cmd_set_l2_decap_parsed,
13581 .help_str = "set l2_decap",
13583 (void *)&cmd_set_l2_decap_set,
13584 (void *)&cmd_set_l2_decap_l2_decap,
13589 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13590 .f = cmd_set_l2_decap_parsed,
13592 .help_str = "set l2_decap-with-vlan",
13594 (void *)&cmd_set_l2_decap_set,
13595 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13600 /** Set MPLSoGRE encapsulation details */
13601 struct cmd_set_mplsogre_encap_result {
13602 cmdline_fixed_string_t set;
13603 cmdline_fixed_string_t mplsogre;
13604 cmdline_fixed_string_t pos_token;
13605 cmdline_fixed_string_t ip_version;
13606 uint32_t vlan_present:1;
13608 cmdline_ipaddr_t ip_src;
13609 cmdline_ipaddr_t ip_dst;
13611 struct rte_ether_addr eth_src;
13612 struct rte_ether_addr eth_dst;
13615 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13616 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13618 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13619 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13621 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13622 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13623 mplsogre, "mplsogre_encap-with-vlan");
13624 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13625 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13626 pos_token, "ip-version");
13627 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13628 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13629 ip_version, "ipv4#ipv6");
13630 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13631 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13632 pos_token, "label");
13633 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13634 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13636 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13637 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13638 pos_token, "ip-src");
13639 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13640 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13641 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13642 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13643 pos_token, "ip-dst");
13644 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13645 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13646 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13647 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13648 pos_token, "vlan-tci");
13649 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13650 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13652 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13653 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13654 pos_token, "eth-src");
13655 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13656 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13658 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13659 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13660 pos_token, "eth-dst");
13661 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13662 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13665 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13666 __rte_unused struct cmdline *cl,
13667 __rte_unused void *data)
13669 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13671 uint32_t mplsogre_label;
13674 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13677 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13678 mplsogre_encap_conf.select_vlan = 0;
13679 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13680 mplsogre_encap_conf.select_vlan = 1;
13681 if (strcmp(res->ip_version, "ipv4") == 0)
13682 mplsogre_encap_conf.select_ipv4 = 1;
13683 else if (strcmp(res->ip_version, "ipv6") == 0)
13684 mplsogre_encap_conf.select_ipv4 = 0;
13687 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13688 if (mplsogre_encap_conf.select_ipv4) {
13689 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13690 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13692 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13693 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13695 if (mplsogre_encap_conf.select_vlan)
13696 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13697 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13698 RTE_ETHER_ADDR_LEN);
13699 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13700 RTE_ETHER_ADDR_LEN);
13703 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13704 .f = cmd_set_mplsogre_encap_parsed,
13706 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13707 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13708 " eth-dst <eth-dst>",
13710 (void *)&cmd_set_mplsogre_encap_set,
13711 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13712 (void *)&cmd_set_mplsogre_encap_ip_version,
13713 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13714 (void *)&cmd_set_mplsogre_encap_label,
13715 (void *)&cmd_set_mplsogre_encap_label_value,
13716 (void *)&cmd_set_mplsogre_encap_ip_src,
13717 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13718 (void *)&cmd_set_mplsogre_encap_ip_dst,
13719 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13720 (void *)&cmd_set_mplsogre_encap_eth_src,
13721 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13722 (void *)&cmd_set_mplsogre_encap_eth_dst,
13723 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13728 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13729 .f = cmd_set_mplsogre_encap_parsed,
13731 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13732 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13733 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13735 (void *)&cmd_set_mplsogre_encap_set,
13736 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13737 (void *)&cmd_set_mplsogre_encap_ip_version,
13738 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13739 (void *)&cmd_set_mplsogre_encap_label,
13740 (void *)&cmd_set_mplsogre_encap_label_value,
13741 (void *)&cmd_set_mplsogre_encap_ip_src,
13742 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13743 (void *)&cmd_set_mplsogre_encap_ip_dst,
13744 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13745 (void *)&cmd_set_mplsogre_encap_vlan,
13746 (void *)&cmd_set_mplsogre_encap_vlan_value,
13747 (void *)&cmd_set_mplsogre_encap_eth_src,
13748 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13749 (void *)&cmd_set_mplsogre_encap_eth_dst,
13750 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13755 /** Set MPLSoGRE decapsulation details */
13756 struct cmd_set_mplsogre_decap_result {
13757 cmdline_fixed_string_t set;
13758 cmdline_fixed_string_t mplsogre;
13759 cmdline_fixed_string_t pos_token;
13760 cmdline_fixed_string_t ip_version;
13761 uint32_t vlan_present:1;
13764 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13765 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13767 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13768 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13770 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13771 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13772 mplsogre, "mplsogre_decap-with-vlan");
13773 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13774 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13775 pos_token, "ip-version");
13776 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13777 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13778 ip_version, "ipv4#ipv6");
13780 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13781 __rte_unused struct cmdline *cl,
13782 __rte_unused void *data)
13784 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13786 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13787 mplsogre_decap_conf.select_vlan = 0;
13788 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13789 mplsogre_decap_conf.select_vlan = 1;
13790 if (strcmp(res->ip_version, "ipv4") == 0)
13791 mplsogre_decap_conf.select_ipv4 = 1;
13792 else if (strcmp(res->ip_version, "ipv6") == 0)
13793 mplsogre_decap_conf.select_ipv4 = 0;
13796 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13797 .f = cmd_set_mplsogre_decap_parsed,
13799 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13801 (void *)&cmd_set_mplsogre_decap_set,
13802 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13803 (void *)&cmd_set_mplsogre_decap_ip_version,
13804 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13809 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13810 .f = cmd_set_mplsogre_decap_parsed,
13812 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13814 (void *)&cmd_set_mplsogre_decap_set,
13815 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13816 (void *)&cmd_set_mplsogre_decap_ip_version,
13817 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13822 /** Set MPLSoUDP encapsulation details */
13823 struct cmd_set_mplsoudp_encap_result {
13824 cmdline_fixed_string_t set;
13825 cmdline_fixed_string_t mplsoudp;
13826 cmdline_fixed_string_t pos_token;
13827 cmdline_fixed_string_t ip_version;
13828 uint32_t vlan_present:1;
13832 cmdline_ipaddr_t ip_src;
13833 cmdline_ipaddr_t ip_dst;
13835 struct rte_ether_addr eth_src;
13836 struct rte_ether_addr eth_dst;
13839 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13840 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13842 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13843 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13845 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13846 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13847 mplsoudp, "mplsoudp_encap-with-vlan");
13848 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13849 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13850 pos_token, "ip-version");
13851 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13852 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13853 ip_version, "ipv4#ipv6");
13854 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13855 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13856 pos_token, "label");
13857 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13858 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13860 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13861 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13862 pos_token, "udp-src");
13863 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13864 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13866 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13867 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13868 pos_token, "udp-dst");
13869 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13870 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13872 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13873 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13874 pos_token, "ip-src");
13875 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13876 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13877 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13878 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13879 pos_token, "ip-dst");
13880 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13881 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13882 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13883 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13884 pos_token, "vlan-tci");
13885 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13886 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13888 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13889 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13890 pos_token, "eth-src");
13891 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13892 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13894 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13895 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13896 pos_token, "eth-dst");
13897 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13898 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13901 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13902 __rte_unused struct cmdline *cl,
13903 __rte_unused void *data)
13905 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13907 uint32_t mplsoudp_label;
13910 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13913 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13914 mplsoudp_encap_conf.select_vlan = 0;
13915 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13916 mplsoudp_encap_conf.select_vlan = 1;
13917 if (strcmp(res->ip_version, "ipv4") == 0)
13918 mplsoudp_encap_conf.select_ipv4 = 1;
13919 else if (strcmp(res->ip_version, "ipv6") == 0)
13920 mplsoudp_encap_conf.select_ipv4 = 0;
13923 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13924 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13925 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13926 if (mplsoudp_encap_conf.select_ipv4) {
13927 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13928 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13930 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13931 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13933 if (mplsoudp_encap_conf.select_vlan)
13934 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13935 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13936 RTE_ETHER_ADDR_LEN);
13937 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13938 RTE_ETHER_ADDR_LEN);
13941 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13942 .f = cmd_set_mplsoudp_encap_parsed,
13944 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13945 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13946 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13948 (void *)&cmd_set_mplsoudp_encap_set,
13949 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13950 (void *)&cmd_set_mplsoudp_encap_ip_version,
13951 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13952 (void *)&cmd_set_mplsoudp_encap_label,
13953 (void *)&cmd_set_mplsoudp_encap_label_value,
13954 (void *)&cmd_set_mplsoudp_encap_udp_src,
13955 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13956 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13957 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13958 (void *)&cmd_set_mplsoudp_encap_ip_src,
13959 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13960 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13961 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13962 (void *)&cmd_set_mplsoudp_encap_eth_src,
13963 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13964 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13965 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13970 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13971 .f = cmd_set_mplsoudp_encap_parsed,
13973 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13974 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13975 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13976 " eth-src <eth-src> eth-dst <eth-dst>",
13978 (void *)&cmd_set_mplsoudp_encap_set,
13979 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13980 (void *)&cmd_set_mplsoudp_encap_ip_version,
13981 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13982 (void *)&cmd_set_mplsoudp_encap_label,
13983 (void *)&cmd_set_mplsoudp_encap_label_value,
13984 (void *)&cmd_set_mplsoudp_encap_udp_src,
13985 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13986 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13987 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13988 (void *)&cmd_set_mplsoudp_encap_ip_src,
13989 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13990 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13991 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13992 (void *)&cmd_set_mplsoudp_encap_vlan,
13993 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13994 (void *)&cmd_set_mplsoudp_encap_eth_src,
13995 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13996 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13997 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14002 /** Set MPLSoUDP decapsulation details */
14003 struct cmd_set_mplsoudp_decap_result {
14004 cmdline_fixed_string_t set;
14005 cmdline_fixed_string_t mplsoudp;
14006 cmdline_fixed_string_t pos_token;
14007 cmdline_fixed_string_t ip_version;
14008 uint32_t vlan_present:1;
14011 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
14012 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
14014 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
14015 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
14017 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
14018 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14019 mplsoudp, "mplsoudp_decap-with-vlan");
14020 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
14021 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14022 pos_token, "ip-version");
14023 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
14024 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14025 ip_version, "ipv4#ipv6");
14027 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
14028 __rte_unused struct cmdline *cl,
14029 __rte_unused void *data)
14031 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
14033 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
14034 mplsoudp_decap_conf.select_vlan = 0;
14035 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
14036 mplsoudp_decap_conf.select_vlan = 1;
14037 if (strcmp(res->ip_version, "ipv4") == 0)
14038 mplsoudp_decap_conf.select_ipv4 = 1;
14039 else if (strcmp(res->ip_version, "ipv6") == 0)
14040 mplsoudp_decap_conf.select_ipv4 = 0;
14043 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
14044 .f = cmd_set_mplsoudp_decap_parsed,
14046 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
14048 (void *)&cmd_set_mplsoudp_decap_set,
14049 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
14050 (void *)&cmd_set_mplsoudp_decap_ip_version,
14051 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14056 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
14057 .f = cmd_set_mplsoudp_decap_parsed,
14059 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
14061 (void *)&cmd_set_mplsoudp_decap_set,
14062 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
14063 (void *)&cmd_set_mplsoudp_decap_ip_version,
14064 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14069 /** Set connection tracking object common details */
14070 struct cmd_set_conntrack_common_result {
14071 cmdline_fixed_string_t set;
14072 cmdline_fixed_string_t conntrack;
14073 cmdline_fixed_string_t common;
14074 cmdline_fixed_string_t peer;
14075 cmdline_fixed_string_t is_orig;
14076 cmdline_fixed_string_t enable;
14077 cmdline_fixed_string_t live;
14078 cmdline_fixed_string_t sack;
14079 cmdline_fixed_string_t cack;
14080 cmdline_fixed_string_t last_dir;
14081 cmdline_fixed_string_t liberal;
14082 cmdline_fixed_string_t state;
14083 cmdline_fixed_string_t max_ack_win;
14084 cmdline_fixed_string_t retrans;
14085 cmdline_fixed_string_t last_win;
14086 cmdline_fixed_string_t last_seq;
14087 cmdline_fixed_string_t last_ack;
14088 cmdline_fixed_string_t last_end;
14089 cmdline_fixed_string_t last_index;
14092 uint16_t peer_port;
14093 uint32_t is_original;
14108 cmdline_parse_token_string_t cmd_set_conntrack_set =
14109 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14111 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
14112 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14113 conntrack, "conntrack");
14114 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
14115 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14117 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
14118 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14120 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
14121 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14122 peer_port, RTE_UINT16);
14123 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
14124 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14125 is_orig, "is_orig");
14126 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
14127 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14128 is_original, RTE_UINT32);
14129 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
14130 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14132 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14133 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14135 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14136 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14138 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14139 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14140 is_live, RTE_UINT32);
14141 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14142 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14144 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14145 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14146 s_ack, RTE_UINT32);
14147 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14148 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14150 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14151 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14152 c_ack, RTE_UINT32);
14153 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14154 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14155 last_dir, "last_dir");
14156 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14157 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14159 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14160 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14161 liberal, "liberal");
14162 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14163 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14165 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14166 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14168 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14169 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14171 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14172 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14173 max_ack_win, "max_ack_win");
14174 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14175 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14176 factor, RTE_UINT8);
14177 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14178 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14180 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14181 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14182 re_num, RTE_UINT8);
14183 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14184 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14185 last_win, "last_win");
14186 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14187 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14189 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14190 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14191 last_seq, "last_seq");
14192 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14193 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14195 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14196 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14197 last_ack, "last_ack");
14198 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14199 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14201 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14202 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14203 last_end, "last_end");
14204 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14205 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14207 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14208 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14209 last_index, "last_index");
14210 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14211 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14214 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14215 __rte_unused struct cmdline *cl,
14216 __rte_unused void *data)
14218 struct cmd_set_conntrack_common_result *res = parsed_result;
14220 /* No need to swap to big endian. */
14221 conntrack_context.peer_port = res->peer_port;
14222 conntrack_context.is_original_dir = res->is_original;
14223 conntrack_context.enable = res->en;
14224 conntrack_context.live_connection = res->is_live;
14225 conntrack_context.selective_ack = res->s_ack;
14226 conntrack_context.challenge_ack_passed = res->c_ack;
14227 conntrack_context.last_direction = res->ld;
14228 conntrack_context.liberal_mode = res->lb;
14229 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14230 conntrack_context.max_ack_window = res->factor;
14231 conntrack_context.retransmission_limit = res->re_num;
14232 conntrack_context.last_window = res->lw;
14233 conntrack_context.last_index =
14234 (enum rte_flow_conntrack_tcp_last_index)res->li;
14235 conntrack_context.last_seq = res->ls;
14236 conntrack_context.last_ack = res->la;
14237 conntrack_context.last_end = res->le;
14240 cmdline_parse_inst_t cmd_set_conntrack_common = {
14241 .f = cmd_set_conntrack_common_parsed,
14243 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14244 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14245 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14246 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14247 " last_index <flag>",
14249 (void *)&cmd_set_conntrack_set,
14250 (void *)&cmd_set_conntrack_conntrack,
14251 (void *)&cmd_set_conntrack_common_com,
14252 (void *)&cmd_set_conntrack_common_peer,
14253 (void *)&cmd_set_conntrack_common_peer_value,
14254 (void *)&cmd_set_conntrack_common_is_orig,
14255 (void *)&cmd_set_conntrack_common_is_orig_value,
14256 (void *)&cmd_set_conntrack_common_enable,
14257 (void *)&cmd_set_conntrack_common_enable_value,
14258 (void *)&cmd_set_conntrack_common_live,
14259 (void *)&cmd_set_conntrack_common_live_value,
14260 (void *)&cmd_set_conntrack_common_sack,
14261 (void *)&cmd_set_conntrack_common_sack_value,
14262 (void *)&cmd_set_conntrack_common_cack,
14263 (void *)&cmd_set_conntrack_common_cack_value,
14264 (void *)&cmd_set_conntrack_common_last_dir,
14265 (void *)&cmd_set_conntrack_common_last_dir_value,
14266 (void *)&cmd_set_conntrack_common_liberal,
14267 (void *)&cmd_set_conntrack_common_liberal_value,
14268 (void *)&cmd_set_conntrack_common_state,
14269 (void *)&cmd_set_conntrack_common_state_value,
14270 (void *)&cmd_set_conntrack_common_max_ackwin,
14271 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14272 (void *)&cmd_set_conntrack_common_retrans,
14273 (void *)&cmd_set_conntrack_common_retrans_value,
14274 (void *)&cmd_set_conntrack_common_last_win,
14275 (void *)&cmd_set_conntrack_common_last_win_value,
14276 (void *)&cmd_set_conntrack_common_last_seq,
14277 (void *)&cmd_set_conntrack_common_last_seq_value,
14278 (void *)&cmd_set_conntrack_common_last_ack,
14279 (void *)&cmd_set_conntrack_common_last_ack_value,
14280 (void *)&cmd_set_conntrack_common_last_end,
14281 (void *)&cmd_set_conntrack_common_last_end_value,
14282 (void *)&cmd_set_conntrack_common_last_index,
14283 (void *)&cmd_set_conntrack_common_last_index_value,
14288 /** Set connection tracking object both directions' details */
14289 struct cmd_set_conntrack_dir_result {
14290 cmdline_fixed_string_t set;
14291 cmdline_fixed_string_t conntrack;
14292 cmdline_fixed_string_t dir;
14293 cmdline_fixed_string_t scale;
14294 cmdline_fixed_string_t fin;
14295 cmdline_fixed_string_t ack_seen;
14296 cmdline_fixed_string_t unack;
14297 cmdline_fixed_string_t sent_end;
14298 cmdline_fixed_string_t reply_end;
14299 cmdline_fixed_string_t max_win;
14300 cmdline_fixed_string_t max_ack;
14311 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14312 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14314 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14315 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14316 conntrack, "conntrack");
14317 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14318 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14320 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14321 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14323 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14324 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14325 factor, RTE_UINT32);
14326 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14327 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14329 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14330 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14332 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14333 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14334 ack_seen, "acked");
14335 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14336 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14338 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14339 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14340 unack, "unack_data");
14341 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14342 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14344 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14345 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14346 sent_end, "sent_end");
14347 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14348 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14350 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14351 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14352 reply_end, "reply_end");
14353 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14354 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14356 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14357 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14358 max_win, "max_win");
14359 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14360 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14362 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14363 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14364 max_ack, "max_ack");
14365 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14366 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14369 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14370 __rte_unused struct cmdline *cl,
14371 __rte_unused void *data)
14373 struct cmd_set_conntrack_dir_result *res = parsed_result;
14374 struct rte_flow_tcp_dir_param *dir = NULL;
14376 if (strcmp(res->dir, "orig") == 0)
14377 dir = &conntrack_context.original_dir;
14378 else if (strcmp(res->dir, "rply") == 0)
14379 dir = &conntrack_context.reply_dir;
14382 dir->scale = res->factor;
14383 dir->close_initiated = res->f;
14384 dir->last_ack_seen = res->as;
14385 dir->data_unacked = res->un;
14386 dir->sent_end = res->se;
14387 dir->reply_end = res->re;
14388 dir->max_ack = res->ma;
14389 dir->max_win = res->mw;
14392 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14393 .f = cmd_set_conntrack_dir_parsed,
14395 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14396 " acked <seen> unack_data <unack> sent_end <sent>"
14397 " reply_end <reply> max_win <win> max_ack <ack>",
14399 (void *)&cmd_set_conntrack_set,
14400 (void *)&cmd_set_conntrack_conntrack,
14401 (void *)&cmd_set_conntrack_dir_dir,
14402 (void *)&cmd_set_conntrack_dir_scale,
14403 (void *)&cmd_set_conntrack_dir_scale_value,
14404 (void *)&cmd_set_conntrack_dir_fin,
14405 (void *)&cmd_set_conntrack_dir_fin_value,
14406 (void *)&cmd_set_conntrack_dir_ack,
14407 (void *)&cmd_set_conntrack_dir_ack_value,
14408 (void *)&cmd_set_conntrack_dir_unack_data,
14409 (void *)&cmd_set_conntrack_dir_unack_data_value,
14410 (void *)&cmd_set_conntrack_dir_sent_end,
14411 (void *)&cmd_set_conntrack_dir_sent_end_value,
14412 (void *)&cmd_set_conntrack_dir_reply_end,
14413 (void *)&cmd_set_conntrack_dir_reply_end_value,
14414 (void *)&cmd_set_conntrack_dir_max_win,
14415 (void *)&cmd_set_conntrack_dir_max_win_value,
14416 (void *)&cmd_set_conntrack_dir_max_ack,
14417 (void *)&cmd_set_conntrack_dir_max_ack_value,
14422 /* Strict link priority scheduling mode setting */
14424 cmd_strict_link_prio_parsed(
14425 void *parsed_result,
14426 __rte_unused struct cmdline *cl,
14427 __rte_unused void *data)
14429 struct cmd_vf_tc_bw_result *res = parsed_result;
14430 int ret = -ENOTSUP;
14432 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14435 #ifdef RTE_NET_I40E
14436 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14443 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14446 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14449 fprintf(stderr, "function not implemented\n");
14452 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14456 cmdline_parse_inst_t cmd_strict_link_prio = {
14457 .f = cmd_strict_link_prio_parsed,
14459 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14461 (void *)&cmd_vf_tc_bw_set,
14462 (void *)&cmd_vf_tc_bw_tx,
14463 (void *)&cmd_vf_tc_bw_strict_link_prio,
14464 (void *)&cmd_vf_tc_bw_port_id,
14465 (void *)&cmd_vf_tc_bw_tc_map,
14470 /* Load dynamic device personalization*/
14471 struct cmd_ddp_add_result {
14472 cmdline_fixed_string_t ddp;
14473 cmdline_fixed_string_t add;
14478 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14479 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14480 cmdline_parse_token_string_t cmd_ddp_add_add =
14481 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14482 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14483 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14485 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14486 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14489 cmd_ddp_add_parsed(
14490 void *parsed_result,
14491 __rte_unused struct cmdline *cl,
14492 __rte_unused void *data)
14494 struct cmd_ddp_add_result *res = parsed_result;
14500 int ret = -ENOTSUP;
14502 if (!all_ports_stopped()) {
14503 fprintf(stderr, "Please stop all ports first\n");
14507 filepath = strdup(res->filepath);
14508 if (filepath == NULL) {
14509 fprintf(stderr, "Failed to allocate memory\n");
14512 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14514 buff = open_file(file_fld[0], &size);
14516 free((void *)filepath);
14520 #ifdef RTE_NET_I40E
14521 if (ret == -ENOTSUP)
14522 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14524 RTE_PMD_I40E_PKG_OP_WR_ADD);
14527 if (ret == -EEXIST)
14528 fprintf(stderr, "Profile has already existed.\n");
14530 fprintf(stderr, "Failed to load profile.\n");
14531 else if (file_num == 2)
14532 save_file(file_fld[1], buff, size);
14535 free((void *)filepath);
14538 cmdline_parse_inst_t cmd_ddp_add = {
14539 .f = cmd_ddp_add_parsed,
14541 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14543 (void *)&cmd_ddp_add_ddp,
14544 (void *)&cmd_ddp_add_add,
14545 (void *)&cmd_ddp_add_port_id,
14546 (void *)&cmd_ddp_add_filepath,
14551 /* Delete dynamic device personalization*/
14552 struct cmd_ddp_del_result {
14553 cmdline_fixed_string_t ddp;
14554 cmdline_fixed_string_t del;
14559 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14560 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14561 cmdline_parse_token_string_t cmd_ddp_del_del =
14562 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14563 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14564 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14565 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14566 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14569 cmd_ddp_del_parsed(
14570 void *parsed_result,
14571 __rte_unused struct cmdline *cl,
14572 __rte_unused void *data)
14574 struct cmd_ddp_del_result *res = parsed_result;
14577 int ret = -ENOTSUP;
14579 if (!all_ports_stopped()) {
14580 fprintf(stderr, "Please stop all ports first\n");
14584 buff = open_file(res->filepath, &size);
14588 #ifdef RTE_NET_I40E
14589 if (ret == -ENOTSUP)
14590 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14592 RTE_PMD_I40E_PKG_OP_WR_DEL);
14595 if (ret == -EACCES)
14596 fprintf(stderr, "Profile does not exist.\n");
14598 fprintf(stderr, "Failed to delete profile.\n");
14603 cmdline_parse_inst_t cmd_ddp_del = {
14604 .f = cmd_ddp_del_parsed,
14606 .help_str = "ddp del <port_id> <backup_profile_path>",
14608 (void *)&cmd_ddp_del_ddp,
14609 (void *)&cmd_ddp_del_del,
14610 (void *)&cmd_ddp_del_port_id,
14611 (void *)&cmd_ddp_del_filepath,
14616 /* Get dynamic device personalization profile info */
14617 struct cmd_ddp_info_result {
14618 cmdline_fixed_string_t ddp;
14619 cmdline_fixed_string_t get;
14620 cmdline_fixed_string_t info;
14624 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14625 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14626 cmdline_parse_token_string_t cmd_ddp_info_get =
14627 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14628 cmdline_parse_token_string_t cmd_ddp_info_info =
14629 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14630 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14631 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14634 cmd_ddp_info_parsed(
14635 void *parsed_result,
14636 __rte_unused struct cmdline *cl,
14637 __rte_unused void *data)
14639 struct cmd_ddp_info_result *res = parsed_result;
14642 int ret = -ENOTSUP;
14643 #ifdef RTE_NET_I40E
14646 uint32_t buff_size = 0;
14647 struct rte_pmd_i40e_profile_info info;
14648 uint32_t dev_num = 0;
14649 struct rte_pmd_i40e_ddp_device_id *devs;
14650 uint32_t proto_num = 0;
14651 struct rte_pmd_i40e_proto_info *proto = NULL;
14652 uint32_t pctype_num = 0;
14653 struct rte_pmd_i40e_ptype_info *pctype;
14654 uint32_t ptype_num = 0;
14655 struct rte_pmd_i40e_ptype_info *ptype;
14660 pkg = open_file(res->filepath, &pkg_size);
14664 #ifdef RTE_NET_I40E
14665 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14666 (uint8_t *)&info, sizeof(info),
14667 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14669 printf("Global Track id: 0x%x\n", info.track_id);
14670 printf("Global Version: %d.%d.%d.%d\n",
14671 info.version.major,
14672 info.version.minor,
14673 info.version.update,
14674 info.version.draft);
14675 printf("Global Package name: %s\n\n", info.name);
14678 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14679 (uint8_t *)&info, sizeof(info),
14680 RTE_PMD_I40E_PKG_INFO_HEADER);
14682 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14683 printf("i40e Profile Version: %d.%d.%d.%d\n",
14684 info.version.major,
14685 info.version.minor,
14686 info.version.update,
14687 info.version.draft);
14688 printf("i40e Profile name: %s\n\n", info.name);
14691 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14692 (uint8_t *)&buff_size, sizeof(buff_size),
14693 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14694 if (!ret && buff_size) {
14695 buff = (uint8_t *)malloc(buff_size);
14697 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14699 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14701 printf("Package Notes:\n%s\n\n", buff);
14706 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14707 (uint8_t *)&dev_num, sizeof(dev_num),
14708 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14709 if (!ret && dev_num) {
14710 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14711 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14713 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14714 (uint8_t *)devs, buff_size,
14715 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14717 printf("List of supported devices:\n");
14718 for (i = 0; i < dev_num; i++) {
14719 printf(" %04X:%04X %04X:%04X\n",
14720 devs[i].vendor_dev_id >> 16,
14721 devs[i].vendor_dev_id & 0xFFFF,
14722 devs[i].sub_vendor_dev_id >> 16,
14723 devs[i].sub_vendor_dev_id & 0xFFFF);
14731 /* get information about protocols and packet types */
14732 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14733 (uint8_t *)&proto_num, sizeof(proto_num),
14734 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14735 if (ret || !proto_num)
14736 goto no_print_return;
14738 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14739 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14741 goto no_print_return;
14743 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14745 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14747 printf("List of used protocols:\n");
14748 for (i = 0; i < proto_num; i++)
14749 printf(" %2u: %s\n", proto[i].proto_id,
14753 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14754 (uint8_t *)&pctype_num, sizeof(pctype_num),
14755 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14756 if (ret || !pctype_num)
14757 goto no_print_pctypes;
14759 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14760 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14762 goto no_print_pctypes;
14764 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14766 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14769 goto no_print_pctypes;
14772 printf("List of defined packet classification types:\n");
14773 for (i = 0; i < pctype_num; i++) {
14774 printf(" %2u:", pctype[i].ptype_id);
14775 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14776 proto_id = pctype[i].protocols[j];
14777 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14778 for (n = 0; n < proto_num; n++) {
14779 if (proto[n].proto_id == proto_id) {
14780 printf(" %s", proto[n].name);
14793 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14795 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14796 if (ret || !ptype_num)
14797 goto no_print_return;
14799 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14800 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14802 goto no_print_return;
14804 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14806 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14809 goto no_print_return;
14811 printf("List of defined packet types:\n");
14812 for (i = 0; i < ptype_num; i++) {
14813 printf(" %2u:", ptype[i].ptype_id);
14814 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14815 proto_id = ptype[i].protocols[j];
14816 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14817 for (n = 0; n < proto_num; n++) {
14818 if (proto[n].proto_id == proto_id) {
14819 printf(" %s", proto[n].name);
14834 if (ret == -ENOTSUP)
14835 fprintf(stderr, "Function not supported in PMD\n");
14839 cmdline_parse_inst_t cmd_ddp_get_info = {
14840 .f = cmd_ddp_info_parsed,
14842 .help_str = "ddp get info <profile_path>",
14844 (void *)&cmd_ddp_info_ddp,
14845 (void *)&cmd_ddp_info_get,
14846 (void *)&cmd_ddp_info_info,
14847 (void *)&cmd_ddp_info_filepath,
14852 /* Get dynamic device personalization profile info list*/
14853 #define PROFILE_INFO_SIZE 48
14854 #define MAX_PROFILE_NUM 16
14856 struct cmd_ddp_get_list_result {
14857 cmdline_fixed_string_t ddp;
14858 cmdline_fixed_string_t get;
14859 cmdline_fixed_string_t list;
14863 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14864 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14865 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14866 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14867 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14868 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14869 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14870 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14874 cmd_ddp_get_list_parsed(
14875 __rte_unused void *parsed_result,
14876 __rte_unused struct cmdline *cl,
14877 __rte_unused void *data)
14879 #ifdef RTE_NET_I40E
14880 struct cmd_ddp_get_list_result *res = parsed_result;
14881 struct rte_pmd_i40e_profile_list *p_list;
14882 struct rte_pmd_i40e_profile_info *p_info;
14887 int ret = -ENOTSUP;
14889 #ifdef RTE_NET_I40E
14890 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14891 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14893 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14897 if (ret == -ENOTSUP)
14898 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14899 (uint8_t *)p_list, size);
14902 p_num = p_list->p_count;
14903 printf("Profile number is: %d\n\n", p_num);
14905 for (i = 0; i < p_num; i++) {
14906 p_info = &p_list->p_info[i];
14907 printf("Profile %d:\n", i);
14908 printf("Track id: 0x%x\n", p_info->track_id);
14909 printf("Version: %d.%d.%d.%d\n",
14910 p_info->version.major,
14911 p_info->version.minor,
14912 p_info->version.update,
14913 p_info->version.draft);
14914 printf("Profile name: %s\n\n", p_info->name);
14922 fprintf(stderr, "Failed to get ddp list\n");
14925 cmdline_parse_inst_t cmd_ddp_get_list = {
14926 .f = cmd_ddp_get_list_parsed,
14928 .help_str = "ddp get list <port_id>",
14930 (void *)&cmd_ddp_get_list_ddp,
14931 (void *)&cmd_ddp_get_list_get,
14932 (void *)&cmd_ddp_get_list_list,
14933 (void *)&cmd_ddp_get_list_port_id,
14938 /* Configure input set */
14939 struct cmd_cfg_input_set_result {
14940 cmdline_fixed_string_t port;
14941 cmdline_fixed_string_t cfg;
14943 cmdline_fixed_string_t pctype;
14945 cmdline_fixed_string_t inset_type;
14946 cmdline_fixed_string_t opt;
14947 cmdline_fixed_string_t field;
14952 cmd_cfg_input_set_parsed(
14953 __rte_unused void *parsed_result,
14954 __rte_unused struct cmdline *cl,
14955 __rte_unused void *data)
14957 #ifdef RTE_NET_I40E
14958 struct cmd_cfg_input_set_result *res = parsed_result;
14959 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14960 struct rte_pmd_i40e_inset inset;
14962 int ret = -ENOTSUP;
14964 if (!all_ports_stopped()) {
14965 fprintf(stderr, "Please stop all ports first\n");
14969 #ifdef RTE_NET_I40E
14970 if (!strcmp(res->inset_type, "hash_inset"))
14971 inset_type = INSET_HASH;
14972 else if (!strcmp(res->inset_type, "fdir_inset"))
14973 inset_type = INSET_FDIR;
14974 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14975 inset_type = INSET_FDIR_FLX;
14976 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14977 &inset, inset_type);
14979 fprintf(stderr, "Failed to get input set.\n");
14983 if (!strcmp(res->opt, "get")) {
14984 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14987 printf("Field index %d is enabled.\n", res->field_idx);
14989 printf("Field index %d is disabled.\n", res->field_idx);
14991 } else if (!strcmp(res->opt, "set"))
14992 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14994 else if (!strcmp(res->opt, "clear"))
14995 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14998 fprintf(stderr, "Failed to configure input set field.\n");
15002 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15003 &inset, inset_type);
15005 fprintf(stderr, "Failed to set input set.\n");
15010 if (ret == -ENOTSUP)
15011 fprintf(stderr, "Function not supported\n");
15014 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15015 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15017 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15018 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15020 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15021 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15022 port_id, RTE_UINT16);
15023 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15024 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15026 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15027 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15028 pctype_id, RTE_UINT8);
15029 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15030 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15032 "hash_inset#fdir_inset#fdir_flx_inset");
15033 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15034 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15035 opt, "get#set#clear");
15036 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15037 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15039 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15040 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15041 field_idx, RTE_UINT8);
15043 cmdline_parse_inst_t cmd_cfg_input_set = {
15044 .f = cmd_cfg_input_set_parsed,
15046 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15047 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15049 (void *)&cmd_cfg_input_set_port,
15050 (void *)&cmd_cfg_input_set_cfg,
15051 (void *)&cmd_cfg_input_set_port_id,
15052 (void *)&cmd_cfg_input_set_pctype,
15053 (void *)&cmd_cfg_input_set_pctype_id,
15054 (void *)&cmd_cfg_input_set_inset_type,
15055 (void *)&cmd_cfg_input_set_opt,
15056 (void *)&cmd_cfg_input_set_field,
15057 (void *)&cmd_cfg_input_set_field_idx,
15062 /* Clear input set */
15063 struct cmd_clear_input_set_result {
15064 cmdline_fixed_string_t port;
15065 cmdline_fixed_string_t cfg;
15067 cmdline_fixed_string_t pctype;
15069 cmdline_fixed_string_t inset_type;
15070 cmdline_fixed_string_t clear;
15071 cmdline_fixed_string_t all;
15075 cmd_clear_input_set_parsed(
15076 __rte_unused void *parsed_result,
15077 __rte_unused struct cmdline *cl,
15078 __rte_unused void *data)
15080 #ifdef RTE_NET_I40E
15081 struct cmd_clear_input_set_result *res = parsed_result;
15082 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15083 struct rte_pmd_i40e_inset inset;
15085 int ret = -ENOTSUP;
15087 if (!all_ports_stopped()) {
15088 fprintf(stderr, "Please stop all ports first\n");
15092 #ifdef RTE_NET_I40E
15093 if (!strcmp(res->inset_type, "hash_inset"))
15094 inset_type = INSET_HASH;
15095 else if (!strcmp(res->inset_type, "fdir_inset"))
15096 inset_type = INSET_FDIR;
15097 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15098 inset_type = INSET_FDIR_FLX;
15100 memset(&inset, 0, sizeof(inset));
15102 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15103 &inset, inset_type);
15105 fprintf(stderr, "Failed to clear input set.\n");
15111 if (ret == -ENOTSUP)
15112 fprintf(stderr, "Function not supported\n");
15115 cmdline_parse_token_string_t cmd_clear_input_set_port =
15116 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15118 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15119 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15121 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15122 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15123 port_id, RTE_UINT16);
15124 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15125 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15127 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15128 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15129 pctype_id, RTE_UINT8);
15130 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15131 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15133 "hash_inset#fdir_inset#fdir_flx_inset");
15134 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15135 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15137 cmdline_parse_token_string_t cmd_clear_input_set_all =
15138 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15141 cmdline_parse_inst_t cmd_clear_input_set = {
15142 .f = cmd_clear_input_set_parsed,
15144 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15145 "fdir_inset|fdir_flx_inset clear all",
15147 (void *)&cmd_clear_input_set_port,
15148 (void *)&cmd_clear_input_set_cfg,
15149 (void *)&cmd_clear_input_set_port_id,
15150 (void *)&cmd_clear_input_set_pctype,
15151 (void *)&cmd_clear_input_set_pctype_id,
15152 (void *)&cmd_clear_input_set_inset_type,
15153 (void *)&cmd_clear_input_set_clear,
15154 (void *)&cmd_clear_input_set_all,
15159 /* show vf stats */
15161 /* Common result structure for show vf stats */
15162 struct cmd_show_vf_stats_result {
15163 cmdline_fixed_string_t show;
15164 cmdline_fixed_string_t vf;
15165 cmdline_fixed_string_t stats;
15170 /* Common CLI fields show vf stats*/
15171 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15172 TOKEN_STRING_INITIALIZER
15173 (struct cmd_show_vf_stats_result,
15175 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15176 TOKEN_STRING_INITIALIZER
15177 (struct cmd_show_vf_stats_result,
15179 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15180 TOKEN_STRING_INITIALIZER
15181 (struct cmd_show_vf_stats_result,
15183 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15184 TOKEN_NUM_INITIALIZER
15185 (struct cmd_show_vf_stats_result,
15186 port_id, RTE_UINT16);
15187 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15188 TOKEN_NUM_INITIALIZER
15189 (struct cmd_show_vf_stats_result,
15190 vf_id, RTE_UINT16);
15193 cmd_show_vf_stats_parsed(
15194 void *parsed_result,
15195 __rte_unused struct cmdline *cl,
15196 __rte_unused void *data)
15198 struct cmd_show_vf_stats_result *res = parsed_result;
15199 struct rte_eth_stats stats;
15200 int ret = -ENOTSUP;
15201 static const char *nic_stats_border = "########################";
15203 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15206 memset(&stats, 0, sizeof(stats));
15208 #ifdef RTE_NET_I40E
15209 if (ret == -ENOTSUP)
15210 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15214 #ifdef RTE_NET_BNXT
15215 if (ret == -ENOTSUP)
15216 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15225 fprintf(stderr, "invalid vf_id %d\n", res->vf_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));
15237 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15238 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15240 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15242 stats.ipackets, stats.imissed, stats.ibytes);
15243 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15244 printf(" RX-nombuf: %-10"PRIu64"\n",
15246 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15248 stats.opackets, stats.oerrors, stats.obytes);
15250 printf(" %s############################%s\n",
15251 nic_stats_border, nic_stats_border);
15254 cmdline_parse_inst_t cmd_show_vf_stats = {
15255 .f = cmd_show_vf_stats_parsed,
15257 .help_str = "show vf stats <port_id> <vf_id>",
15259 (void *)&cmd_show_vf_stats_show,
15260 (void *)&cmd_show_vf_stats_vf,
15261 (void *)&cmd_show_vf_stats_stats,
15262 (void *)&cmd_show_vf_stats_port_id,
15263 (void *)&cmd_show_vf_stats_vf_id,
15268 /* clear vf stats */
15270 /* Common result structure for clear vf stats */
15271 struct cmd_clear_vf_stats_result {
15272 cmdline_fixed_string_t clear;
15273 cmdline_fixed_string_t vf;
15274 cmdline_fixed_string_t stats;
15279 /* Common CLI fields clear vf stats*/
15280 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15281 TOKEN_STRING_INITIALIZER
15282 (struct cmd_clear_vf_stats_result,
15284 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15285 TOKEN_STRING_INITIALIZER
15286 (struct cmd_clear_vf_stats_result,
15288 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15289 TOKEN_STRING_INITIALIZER
15290 (struct cmd_clear_vf_stats_result,
15292 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15293 TOKEN_NUM_INITIALIZER
15294 (struct cmd_clear_vf_stats_result,
15295 port_id, RTE_UINT16);
15296 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15297 TOKEN_NUM_INITIALIZER
15298 (struct cmd_clear_vf_stats_result,
15299 vf_id, RTE_UINT16);
15302 cmd_clear_vf_stats_parsed(
15303 void *parsed_result,
15304 __rte_unused struct cmdline *cl,
15305 __rte_unused void *data)
15307 struct cmd_clear_vf_stats_result *res = parsed_result;
15308 int ret = -ENOTSUP;
15310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15313 #ifdef RTE_NET_I40E
15314 if (ret == -ENOTSUP)
15315 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15318 #ifdef RTE_NET_BNXT
15319 if (ret == -ENOTSUP)
15320 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15328 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15331 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15334 fprintf(stderr, "function not implemented\n");
15337 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15341 cmdline_parse_inst_t cmd_clear_vf_stats = {
15342 .f = cmd_clear_vf_stats_parsed,
15344 .help_str = "clear vf stats <port_id> <vf_id>",
15346 (void *)&cmd_clear_vf_stats_clear,
15347 (void *)&cmd_clear_vf_stats_vf,
15348 (void *)&cmd_clear_vf_stats_stats,
15349 (void *)&cmd_clear_vf_stats_port_id,
15350 (void *)&cmd_clear_vf_stats_vf_id,
15355 /* port config pctype mapping reset */
15357 /* Common result structure for port config pctype mapping reset */
15358 struct cmd_pctype_mapping_reset_result {
15359 cmdline_fixed_string_t port;
15360 cmdline_fixed_string_t config;
15362 cmdline_fixed_string_t pctype;
15363 cmdline_fixed_string_t mapping;
15364 cmdline_fixed_string_t reset;
15367 /* Common CLI fields for port config pctype mapping reset*/
15368 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15369 TOKEN_STRING_INITIALIZER
15370 (struct cmd_pctype_mapping_reset_result,
15372 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15373 TOKEN_STRING_INITIALIZER
15374 (struct cmd_pctype_mapping_reset_result,
15376 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15377 TOKEN_NUM_INITIALIZER
15378 (struct cmd_pctype_mapping_reset_result,
15379 port_id, RTE_UINT16);
15380 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15381 TOKEN_STRING_INITIALIZER
15382 (struct cmd_pctype_mapping_reset_result,
15384 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15385 TOKEN_STRING_INITIALIZER
15386 (struct cmd_pctype_mapping_reset_result,
15387 mapping, "mapping");
15388 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15389 TOKEN_STRING_INITIALIZER
15390 (struct cmd_pctype_mapping_reset_result,
15394 cmd_pctype_mapping_reset_parsed(
15395 void *parsed_result,
15396 __rte_unused struct cmdline *cl,
15397 __rte_unused void *data)
15399 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15400 int ret = -ENOTSUP;
15402 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15405 #ifdef RTE_NET_I40E
15406 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15413 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15416 fprintf(stderr, "function not implemented\n");
15419 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15423 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15424 .f = cmd_pctype_mapping_reset_parsed,
15426 .help_str = "port config <port_id> pctype mapping reset",
15428 (void *)&cmd_pctype_mapping_reset_port,
15429 (void *)&cmd_pctype_mapping_reset_config,
15430 (void *)&cmd_pctype_mapping_reset_port_id,
15431 (void *)&cmd_pctype_mapping_reset_pctype,
15432 (void *)&cmd_pctype_mapping_reset_mapping,
15433 (void *)&cmd_pctype_mapping_reset_reset,
15438 /* show port pctype mapping */
15440 /* Common result structure for show port pctype mapping */
15441 struct cmd_pctype_mapping_get_result {
15442 cmdline_fixed_string_t show;
15443 cmdline_fixed_string_t port;
15445 cmdline_fixed_string_t pctype;
15446 cmdline_fixed_string_t mapping;
15449 /* Common CLI fields for pctype mapping get */
15450 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15451 TOKEN_STRING_INITIALIZER
15452 (struct cmd_pctype_mapping_get_result,
15454 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15455 TOKEN_STRING_INITIALIZER
15456 (struct cmd_pctype_mapping_get_result,
15458 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15459 TOKEN_NUM_INITIALIZER
15460 (struct cmd_pctype_mapping_get_result,
15461 port_id, RTE_UINT16);
15462 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15463 TOKEN_STRING_INITIALIZER
15464 (struct cmd_pctype_mapping_get_result,
15466 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15467 TOKEN_STRING_INITIALIZER
15468 (struct cmd_pctype_mapping_get_result,
15469 mapping, "mapping");
15472 cmd_pctype_mapping_get_parsed(
15473 void *parsed_result,
15474 __rte_unused struct cmdline *cl,
15475 __rte_unused void *data)
15477 struct cmd_pctype_mapping_get_result *res = parsed_result;
15478 int ret = -ENOTSUP;
15479 #ifdef RTE_NET_I40E
15480 struct rte_pmd_i40e_flow_type_mapping
15481 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15482 int i, j, first_pctype;
15485 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15488 #ifdef RTE_NET_I40E
15489 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15496 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15499 fprintf(stderr, "function not implemented\n");
15502 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15506 #ifdef RTE_NET_I40E
15507 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15508 if (mapping[i].pctype != 0ULL) {
15511 printf("pctype: ");
15512 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15513 if (mapping[i].pctype & (1ULL << j)) {
15514 printf(first_pctype ?
15515 "%02d" : ",%02d", j);
15519 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15525 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15526 .f = cmd_pctype_mapping_get_parsed,
15528 .help_str = "show port <port_id> pctype mapping",
15530 (void *)&cmd_pctype_mapping_get_show,
15531 (void *)&cmd_pctype_mapping_get_port,
15532 (void *)&cmd_pctype_mapping_get_port_id,
15533 (void *)&cmd_pctype_mapping_get_pctype,
15534 (void *)&cmd_pctype_mapping_get_mapping,
15539 /* port config pctype mapping update */
15541 /* Common result structure for port config pctype mapping update */
15542 struct cmd_pctype_mapping_update_result {
15543 cmdline_fixed_string_t port;
15544 cmdline_fixed_string_t config;
15546 cmdline_fixed_string_t pctype;
15547 cmdline_fixed_string_t mapping;
15548 cmdline_fixed_string_t update;
15549 cmdline_fixed_string_t pctype_list;
15550 uint16_t flow_type;
15553 /* Common CLI fields for pctype mapping update*/
15554 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15555 TOKEN_STRING_INITIALIZER
15556 (struct cmd_pctype_mapping_update_result,
15558 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15559 TOKEN_STRING_INITIALIZER
15560 (struct cmd_pctype_mapping_update_result,
15562 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15563 TOKEN_NUM_INITIALIZER
15564 (struct cmd_pctype_mapping_update_result,
15565 port_id, RTE_UINT16);
15566 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15567 TOKEN_STRING_INITIALIZER
15568 (struct cmd_pctype_mapping_update_result,
15570 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15571 TOKEN_STRING_INITIALIZER
15572 (struct cmd_pctype_mapping_update_result,
15573 mapping, "mapping");
15574 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15575 TOKEN_STRING_INITIALIZER
15576 (struct cmd_pctype_mapping_update_result,
15578 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15579 TOKEN_STRING_INITIALIZER
15580 (struct cmd_pctype_mapping_update_result,
15581 pctype_list, NULL);
15582 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15583 TOKEN_NUM_INITIALIZER
15584 (struct cmd_pctype_mapping_update_result,
15585 flow_type, RTE_UINT16);
15588 cmd_pctype_mapping_update_parsed(
15589 void *parsed_result,
15590 __rte_unused struct cmdline *cl,
15591 __rte_unused void *data)
15593 struct cmd_pctype_mapping_update_result *res = parsed_result;
15594 int ret = -ENOTSUP;
15595 #ifdef RTE_NET_I40E
15596 struct rte_pmd_i40e_flow_type_mapping mapping;
15598 unsigned int nb_item;
15599 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15602 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15605 #ifdef RTE_NET_I40E
15606 nb_item = parse_item_list(res->pctype_list, "pctypes",
15607 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15608 mapping.flow_type = res->flow_type;
15609 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15610 mapping.pctype |= (1ULL << pctype_list[i]);
15611 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15621 fprintf(stderr, "invalid pctype or flow type\n");
15624 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15627 fprintf(stderr, "function not implemented\n");
15630 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15634 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15635 .f = cmd_pctype_mapping_update_parsed,
15637 .help_str = "port config <port_id> pctype mapping update"
15638 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15640 (void *)&cmd_pctype_mapping_update_port,
15641 (void *)&cmd_pctype_mapping_update_config,
15642 (void *)&cmd_pctype_mapping_update_port_id,
15643 (void *)&cmd_pctype_mapping_update_pctype,
15644 (void *)&cmd_pctype_mapping_update_mapping,
15645 (void *)&cmd_pctype_mapping_update_update,
15646 (void *)&cmd_pctype_mapping_update_pc_type,
15647 (void *)&cmd_pctype_mapping_update_flow_type,
15652 /* ptype mapping get */
15654 /* Common result structure for ptype mapping get */
15655 struct cmd_ptype_mapping_get_result {
15656 cmdline_fixed_string_t ptype;
15657 cmdline_fixed_string_t mapping;
15658 cmdline_fixed_string_t get;
15660 uint8_t valid_only;
15663 /* Common CLI fields for ptype mapping get */
15664 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15665 TOKEN_STRING_INITIALIZER
15666 (struct cmd_ptype_mapping_get_result,
15668 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15669 TOKEN_STRING_INITIALIZER
15670 (struct cmd_ptype_mapping_get_result,
15671 mapping, "mapping");
15672 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15673 TOKEN_STRING_INITIALIZER
15674 (struct cmd_ptype_mapping_get_result,
15676 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15677 TOKEN_NUM_INITIALIZER
15678 (struct cmd_ptype_mapping_get_result,
15679 port_id, RTE_UINT16);
15680 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15681 TOKEN_NUM_INITIALIZER
15682 (struct cmd_ptype_mapping_get_result,
15683 valid_only, RTE_UINT8);
15686 cmd_ptype_mapping_get_parsed(
15687 void *parsed_result,
15688 __rte_unused struct cmdline *cl,
15689 __rte_unused void *data)
15691 struct cmd_ptype_mapping_get_result *res = parsed_result;
15692 int ret = -ENOTSUP;
15693 #ifdef RTE_NET_I40E
15694 int max_ptype_num = 256;
15695 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15700 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15703 #ifdef RTE_NET_I40E
15704 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15715 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15718 fprintf(stderr, "function not implemented\n");
15721 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15724 #ifdef RTE_NET_I40E
15726 for (i = 0; i < count; i++)
15727 printf("%3d\t0x%08x\n",
15728 mapping[i].hw_ptype, mapping[i].sw_ptype);
15733 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15734 .f = cmd_ptype_mapping_get_parsed,
15736 .help_str = "ptype mapping get <port_id> <valid_only>",
15738 (void *)&cmd_ptype_mapping_get_ptype,
15739 (void *)&cmd_ptype_mapping_get_mapping,
15740 (void *)&cmd_ptype_mapping_get_get,
15741 (void *)&cmd_ptype_mapping_get_port_id,
15742 (void *)&cmd_ptype_mapping_get_valid_only,
15747 /* ptype mapping replace */
15749 /* Common result structure for ptype mapping replace */
15750 struct cmd_ptype_mapping_replace_result {
15751 cmdline_fixed_string_t ptype;
15752 cmdline_fixed_string_t mapping;
15753 cmdline_fixed_string_t replace;
15760 /* Common CLI fields for ptype mapping replace */
15761 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15762 TOKEN_STRING_INITIALIZER
15763 (struct cmd_ptype_mapping_replace_result,
15765 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15766 TOKEN_STRING_INITIALIZER
15767 (struct cmd_ptype_mapping_replace_result,
15768 mapping, "mapping");
15769 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15770 TOKEN_STRING_INITIALIZER
15771 (struct cmd_ptype_mapping_replace_result,
15772 replace, "replace");
15773 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15774 TOKEN_NUM_INITIALIZER
15775 (struct cmd_ptype_mapping_replace_result,
15776 port_id, RTE_UINT16);
15777 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15778 TOKEN_NUM_INITIALIZER
15779 (struct cmd_ptype_mapping_replace_result,
15780 target, RTE_UINT32);
15781 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15782 TOKEN_NUM_INITIALIZER
15783 (struct cmd_ptype_mapping_replace_result,
15785 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15786 TOKEN_NUM_INITIALIZER
15787 (struct cmd_ptype_mapping_replace_result,
15788 pkt_type, RTE_UINT32);
15791 cmd_ptype_mapping_replace_parsed(
15792 void *parsed_result,
15793 __rte_unused struct cmdline *cl,
15794 __rte_unused void *data)
15796 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15797 int ret = -ENOTSUP;
15799 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15802 #ifdef RTE_NET_I40E
15803 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15813 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15814 res->target, res->pkt_type);
15817 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15820 fprintf(stderr, "function not implemented\n");
15823 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15827 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15828 .f = cmd_ptype_mapping_replace_parsed,
15831 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15833 (void *)&cmd_ptype_mapping_replace_ptype,
15834 (void *)&cmd_ptype_mapping_replace_mapping,
15835 (void *)&cmd_ptype_mapping_replace_replace,
15836 (void *)&cmd_ptype_mapping_replace_port_id,
15837 (void *)&cmd_ptype_mapping_replace_target,
15838 (void *)&cmd_ptype_mapping_replace_mask,
15839 (void *)&cmd_ptype_mapping_replace_pkt_type,
15844 /* ptype mapping reset */
15846 /* Common result structure for ptype mapping reset */
15847 struct cmd_ptype_mapping_reset_result {
15848 cmdline_fixed_string_t ptype;
15849 cmdline_fixed_string_t mapping;
15850 cmdline_fixed_string_t reset;
15854 /* Common CLI fields for ptype mapping reset*/
15855 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15856 TOKEN_STRING_INITIALIZER
15857 (struct cmd_ptype_mapping_reset_result,
15859 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15860 TOKEN_STRING_INITIALIZER
15861 (struct cmd_ptype_mapping_reset_result,
15862 mapping, "mapping");
15863 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15864 TOKEN_STRING_INITIALIZER
15865 (struct cmd_ptype_mapping_reset_result,
15867 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15868 TOKEN_NUM_INITIALIZER
15869 (struct cmd_ptype_mapping_reset_result,
15870 port_id, RTE_UINT16);
15873 cmd_ptype_mapping_reset_parsed(
15874 void *parsed_result,
15875 __rte_unused struct cmdline *cl,
15876 __rte_unused void *data)
15878 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15879 int ret = -ENOTSUP;
15881 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15884 #ifdef RTE_NET_I40E
15885 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15892 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15895 fprintf(stderr, "function not implemented\n");
15898 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15902 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15903 .f = cmd_ptype_mapping_reset_parsed,
15905 .help_str = "ptype mapping reset <port_id>",
15907 (void *)&cmd_ptype_mapping_reset_ptype,
15908 (void *)&cmd_ptype_mapping_reset_mapping,
15909 (void *)&cmd_ptype_mapping_reset_reset,
15910 (void *)&cmd_ptype_mapping_reset_port_id,
15915 /* ptype mapping update */
15917 /* Common result structure for ptype mapping update */
15918 struct cmd_ptype_mapping_update_result {
15919 cmdline_fixed_string_t ptype;
15920 cmdline_fixed_string_t mapping;
15921 cmdline_fixed_string_t reset;
15927 /* Common CLI fields for ptype mapping update*/
15928 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15929 TOKEN_STRING_INITIALIZER
15930 (struct cmd_ptype_mapping_update_result,
15932 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15933 TOKEN_STRING_INITIALIZER
15934 (struct cmd_ptype_mapping_update_result,
15935 mapping, "mapping");
15936 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15937 TOKEN_STRING_INITIALIZER
15938 (struct cmd_ptype_mapping_update_result,
15940 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15941 TOKEN_NUM_INITIALIZER
15942 (struct cmd_ptype_mapping_update_result,
15943 port_id, RTE_UINT16);
15944 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15945 TOKEN_NUM_INITIALIZER
15946 (struct cmd_ptype_mapping_update_result,
15947 hw_ptype, RTE_UINT8);
15948 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15949 TOKEN_NUM_INITIALIZER
15950 (struct cmd_ptype_mapping_update_result,
15951 sw_ptype, RTE_UINT32);
15954 cmd_ptype_mapping_update_parsed(
15955 void *parsed_result,
15956 __rte_unused struct cmdline *cl,
15957 __rte_unused void *data)
15959 struct cmd_ptype_mapping_update_result *res = parsed_result;
15960 int ret = -ENOTSUP;
15961 #ifdef RTE_NET_I40E
15962 struct rte_pmd_i40e_ptype_mapping mapping;
15964 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15967 #ifdef RTE_NET_I40E
15968 mapping.hw_ptype = res->hw_ptype;
15969 mapping.sw_ptype = res->sw_ptype;
15970 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15980 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15983 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15986 fprintf(stderr, "function not implemented\n");
15989 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15993 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15994 .f = cmd_ptype_mapping_update_parsed,
15996 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15998 (void *)&cmd_ptype_mapping_update_ptype,
15999 (void *)&cmd_ptype_mapping_update_mapping,
16000 (void *)&cmd_ptype_mapping_update_update,
16001 (void *)&cmd_ptype_mapping_update_port_id,
16002 (void *)&cmd_ptype_mapping_update_hw_ptype,
16003 (void *)&cmd_ptype_mapping_update_sw_ptype,
16008 /* Common result structure for file commands */
16009 struct cmd_cmdfile_result {
16010 cmdline_fixed_string_t load;
16011 cmdline_fixed_string_t filename;
16014 /* Common CLI fields for file commands */
16015 cmdline_parse_token_string_t cmd_load_cmdfile =
16016 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16017 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16018 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16021 cmd_load_from_file_parsed(
16022 void *parsed_result,
16023 __rte_unused struct cmdline *cl,
16024 __rte_unused void *data)
16026 struct cmd_cmdfile_result *res = parsed_result;
16028 cmdline_read_from_file(res->filename);
16031 cmdline_parse_inst_t cmd_load_from_file = {
16032 .f = cmd_load_from_file_parsed,
16034 .help_str = "load <filename>",
16036 (void *)&cmd_load_cmdfile,
16037 (void *)&cmd_load_cmdfile_filename,
16042 /* Get Rx offloads capabilities */
16043 struct cmd_rx_offload_get_capa_result {
16044 cmdline_fixed_string_t show;
16045 cmdline_fixed_string_t port;
16047 cmdline_fixed_string_t rx_offload;
16048 cmdline_fixed_string_t capabilities;
16051 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16052 TOKEN_STRING_INITIALIZER
16053 (struct cmd_rx_offload_get_capa_result,
16055 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16056 TOKEN_STRING_INITIALIZER
16057 (struct cmd_rx_offload_get_capa_result,
16059 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16060 TOKEN_NUM_INITIALIZER
16061 (struct cmd_rx_offload_get_capa_result,
16062 port_id, RTE_UINT16);
16063 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16064 TOKEN_STRING_INITIALIZER
16065 (struct cmd_rx_offload_get_capa_result,
16066 rx_offload, "rx_offload");
16067 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16068 TOKEN_STRING_INITIALIZER
16069 (struct cmd_rx_offload_get_capa_result,
16070 capabilities, "capabilities");
16073 print_rx_offloads(uint64_t offloads)
16075 uint64_t single_offload;
16083 begin = __builtin_ctzll(offloads);
16084 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16086 single_offload = 1ULL << begin;
16087 for (bit = begin; bit < end; bit++) {
16088 if (offloads & single_offload)
16090 rte_eth_dev_rx_offload_name(single_offload));
16091 single_offload <<= 1;
16096 cmd_rx_offload_get_capa_parsed(
16097 void *parsed_result,
16098 __rte_unused struct cmdline *cl,
16099 __rte_unused void *data)
16101 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16102 struct rte_eth_dev_info dev_info;
16103 portid_t port_id = res->port_id;
16104 uint64_t queue_offloads;
16105 uint64_t port_offloads;
16108 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16112 queue_offloads = dev_info.rx_queue_offload_capa;
16113 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16115 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16116 printf(" Per Queue :");
16117 print_rx_offloads(queue_offloads);
16120 printf(" Per Port :");
16121 print_rx_offloads(port_offloads);
16125 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16126 .f = cmd_rx_offload_get_capa_parsed,
16128 .help_str = "show port <port_id> rx_offload capabilities",
16130 (void *)&cmd_rx_offload_get_capa_show,
16131 (void *)&cmd_rx_offload_get_capa_port,
16132 (void *)&cmd_rx_offload_get_capa_port_id,
16133 (void *)&cmd_rx_offload_get_capa_rx_offload,
16134 (void *)&cmd_rx_offload_get_capa_capabilities,
16139 /* Get Rx offloads configuration */
16140 struct cmd_rx_offload_get_configuration_result {
16141 cmdline_fixed_string_t show;
16142 cmdline_fixed_string_t port;
16144 cmdline_fixed_string_t rx_offload;
16145 cmdline_fixed_string_t configuration;
16148 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16149 TOKEN_STRING_INITIALIZER
16150 (struct cmd_rx_offload_get_configuration_result,
16152 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16153 TOKEN_STRING_INITIALIZER
16154 (struct cmd_rx_offload_get_configuration_result,
16156 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16157 TOKEN_NUM_INITIALIZER
16158 (struct cmd_rx_offload_get_configuration_result,
16159 port_id, RTE_UINT16);
16160 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16161 TOKEN_STRING_INITIALIZER
16162 (struct cmd_rx_offload_get_configuration_result,
16163 rx_offload, "rx_offload");
16164 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16165 TOKEN_STRING_INITIALIZER
16166 (struct cmd_rx_offload_get_configuration_result,
16167 configuration, "configuration");
16170 cmd_rx_offload_get_configuration_parsed(
16171 void *parsed_result,
16172 __rte_unused struct cmdline *cl,
16173 __rte_unused void *data)
16175 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16176 struct rte_eth_dev_info dev_info;
16177 portid_t port_id = res->port_id;
16178 struct rte_port *port = &ports[port_id];
16179 struct rte_eth_conf dev_conf;
16180 uint64_t port_offloads;
16181 uint64_t queue_offloads;
16182 uint16_t nb_rx_queues;
16186 printf("Rx Offloading Configuration of port %d :\n", port_id);
16188 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16192 port_offloads = dev_conf.rxmode.offloads;
16194 print_rx_offloads(port_offloads);
16197 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16201 nb_rx_queues = dev_info.nb_rx_queues;
16202 for (q = 0; q < nb_rx_queues; q++) {
16203 queue_offloads = port->rx_conf[q].offloads;
16204 printf(" Queue[%2d] :", q);
16205 print_rx_offloads(queue_offloads);
16211 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16212 .f = cmd_rx_offload_get_configuration_parsed,
16214 .help_str = "show port <port_id> rx_offload configuration",
16216 (void *)&cmd_rx_offload_get_configuration_show,
16217 (void *)&cmd_rx_offload_get_configuration_port,
16218 (void *)&cmd_rx_offload_get_configuration_port_id,
16219 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16220 (void *)&cmd_rx_offload_get_configuration_configuration,
16225 /* Enable/Disable a per port offloading */
16226 struct cmd_config_per_port_rx_offload_result {
16227 cmdline_fixed_string_t port;
16228 cmdline_fixed_string_t config;
16230 cmdline_fixed_string_t rx_offload;
16231 cmdline_fixed_string_t offload;
16232 cmdline_fixed_string_t on_off;
16235 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16236 TOKEN_STRING_INITIALIZER
16237 (struct cmd_config_per_port_rx_offload_result,
16239 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16240 TOKEN_STRING_INITIALIZER
16241 (struct cmd_config_per_port_rx_offload_result,
16243 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16244 TOKEN_NUM_INITIALIZER
16245 (struct cmd_config_per_port_rx_offload_result,
16246 port_id, RTE_UINT16);
16247 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16248 TOKEN_STRING_INITIALIZER
16249 (struct cmd_config_per_port_rx_offload_result,
16250 rx_offload, "rx_offload");
16251 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16252 TOKEN_STRING_INITIALIZER
16253 (struct cmd_config_per_port_rx_offload_result,
16254 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16255 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16256 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16257 "scatter#buffer_split#timestamp#security#"
16258 "keep_crc#rss_hash");
16259 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16260 TOKEN_STRING_INITIALIZER
16261 (struct cmd_config_per_port_rx_offload_result,
16265 search_rx_offload(const char *name)
16267 uint64_t single_offload;
16268 const char *single_name;
16272 single_offload = 1;
16273 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16274 single_name = rte_eth_dev_rx_offload_name(single_offload);
16275 if (!strcasecmp(single_name, name)) {
16279 single_offload <<= 1;
16283 return single_offload;
16289 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16290 __rte_unused struct cmdline *cl,
16291 __rte_unused void *data)
16293 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16294 portid_t port_id = res->port_id;
16295 struct rte_eth_dev_info dev_info;
16296 struct rte_port *port = &ports[port_id];
16297 uint64_t single_offload;
16298 uint16_t nb_rx_queues;
16302 if (port->port_status != RTE_PORT_STOPPED) {
16304 "Error: Can't config offload when Port %d is not stopped\n",
16309 single_offload = search_rx_offload(res->offload);
16310 if (single_offload == 0) {
16311 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16315 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16319 nb_rx_queues = dev_info.nb_rx_queues;
16320 if (!strcmp(res->on_off, "on")) {
16321 port->dev_conf.rxmode.offloads |= single_offload;
16322 for (q = 0; q < nb_rx_queues; q++)
16323 port->rx_conf[q].offloads |= single_offload;
16325 port->dev_conf.rxmode.offloads &= ~single_offload;
16326 for (q = 0; q < nb_rx_queues; q++)
16327 port->rx_conf[q].offloads &= ~single_offload;
16330 cmd_reconfig_device_queue(port_id, 1, 1);
16333 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16334 .f = cmd_config_per_port_rx_offload_parsed,
16336 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16337 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16338 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16339 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16340 "keep_crc|rss_hash on|off",
16342 (void *)&cmd_config_per_port_rx_offload_result_port,
16343 (void *)&cmd_config_per_port_rx_offload_result_config,
16344 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16345 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16346 (void *)&cmd_config_per_port_rx_offload_result_offload,
16347 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16352 /* Enable/Disable a per queue offloading */
16353 struct cmd_config_per_queue_rx_offload_result {
16354 cmdline_fixed_string_t port;
16356 cmdline_fixed_string_t rxq;
16358 cmdline_fixed_string_t rx_offload;
16359 cmdline_fixed_string_t offload;
16360 cmdline_fixed_string_t on_off;
16363 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16364 TOKEN_STRING_INITIALIZER
16365 (struct cmd_config_per_queue_rx_offload_result,
16367 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16368 TOKEN_NUM_INITIALIZER
16369 (struct cmd_config_per_queue_rx_offload_result,
16370 port_id, RTE_UINT16);
16371 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16372 TOKEN_STRING_INITIALIZER
16373 (struct cmd_config_per_queue_rx_offload_result,
16375 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16376 TOKEN_NUM_INITIALIZER
16377 (struct cmd_config_per_queue_rx_offload_result,
16378 queue_id, RTE_UINT16);
16379 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16380 TOKEN_STRING_INITIALIZER
16381 (struct cmd_config_per_queue_rx_offload_result,
16382 rx_offload, "rx_offload");
16383 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16384 TOKEN_STRING_INITIALIZER
16385 (struct cmd_config_per_queue_rx_offload_result,
16386 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16387 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16388 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16389 "scatter#buffer_split#timestamp#security#keep_crc");
16390 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16391 TOKEN_STRING_INITIALIZER
16392 (struct cmd_config_per_queue_rx_offload_result,
16396 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16397 __rte_unused struct cmdline *cl,
16398 __rte_unused void *data)
16400 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16401 struct rte_eth_dev_info dev_info;
16402 portid_t port_id = res->port_id;
16403 uint16_t queue_id = res->queue_id;
16404 struct rte_port *port = &ports[port_id];
16405 uint64_t single_offload;
16408 if (port->port_status != RTE_PORT_STOPPED) {
16410 "Error: Can't config offload when Port %d is not stopped\n",
16415 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16419 if (queue_id >= dev_info.nb_rx_queues) {
16421 "Error: input queue_id should be 0 ... %d\n",
16422 dev_info.nb_rx_queues - 1);
16426 single_offload = search_rx_offload(res->offload);
16427 if (single_offload == 0) {
16428 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16432 if (!strcmp(res->on_off, "on"))
16433 port->rx_conf[queue_id].offloads |= single_offload;
16435 port->rx_conf[queue_id].offloads &= ~single_offload;
16437 cmd_reconfig_device_queue(port_id, 1, 1);
16440 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16441 .f = cmd_config_per_queue_rx_offload_parsed,
16443 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16444 "vlan_strip|ipv4_cksum|"
16445 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16446 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16447 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16450 (void *)&cmd_config_per_queue_rx_offload_result_port,
16451 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16452 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16453 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16454 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16455 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16456 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16461 /* Get Tx offloads capabilities */
16462 struct cmd_tx_offload_get_capa_result {
16463 cmdline_fixed_string_t show;
16464 cmdline_fixed_string_t port;
16466 cmdline_fixed_string_t tx_offload;
16467 cmdline_fixed_string_t capabilities;
16470 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16471 TOKEN_STRING_INITIALIZER
16472 (struct cmd_tx_offload_get_capa_result,
16474 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16475 TOKEN_STRING_INITIALIZER
16476 (struct cmd_tx_offload_get_capa_result,
16478 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16479 TOKEN_NUM_INITIALIZER
16480 (struct cmd_tx_offload_get_capa_result,
16481 port_id, RTE_UINT16);
16482 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16483 TOKEN_STRING_INITIALIZER
16484 (struct cmd_tx_offload_get_capa_result,
16485 tx_offload, "tx_offload");
16486 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16487 TOKEN_STRING_INITIALIZER
16488 (struct cmd_tx_offload_get_capa_result,
16489 capabilities, "capabilities");
16492 print_tx_offloads(uint64_t offloads)
16494 uint64_t single_offload;
16502 begin = __builtin_ctzll(offloads);
16503 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16505 single_offload = 1ULL << begin;
16506 for (bit = begin; bit < end; bit++) {
16507 if (offloads & single_offload)
16509 rte_eth_dev_tx_offload_name(single_offload));
16510 single_offload <<= 1;
16515 cmd_tx_offload_get_capa_parsed(
16516 void *parsed_result,
16517 __rte_unused struct cmdline *cl,
16518 __rte_unused void *data)
16520 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16521 struct rte_eth_dev_info dev_info;
16522 portid_t port_id = res->port_id;
16523 uint64_t queue_offloads;
16524 uint64_t port_offloads;
16527 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16531 queue_offloads = dev_info.tx_queue_offload_capa;
16532 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16534 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16535 printf(" Per Queue :");
16536 print_tx_offloads(queue_offloads);
16539 printf(" Per Port :");
16540 print_tx_offloads(port_offloads);
16544 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16545 .f = cmd_tx_offload_get_capa_parsed,
16547 .help_str = "show port <port_id> tx_offload capabilities",
16549 (void *)&cmd_tx_offload_get_capa_show,
16550 (void *)&cmd_tx_offload_get_capa_port,
16551 (void *)&cmd_tx_offload_get_capa_port_id,
16552 (void *)&cmd_tx_offload_get_capa_tx_offload,
16553 (void *)&cmd_tx_offload_get_capa_capabilities,
16558 /* Get Tx offloads configuration */
16559 struct cmd_tx_offload_get_configuration_result {
16560 cmdline_fixed_string_t show;
16561 cmdline_fixed_string_t port;
16563 cmdline_fixed_string_t tx_offload;
16564 cmdline_fixed_string_t configuration;
16567 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16568 TOKEN_STRING_INITIALIZER
16569 (struct cmd_tx_offload_get_configuration_result,
16571 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16572 TOKEN_STRING_INITIALIZER
16573 (struct cmd_tx_offload_get_configuration_result,
16575 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16576 TOKEN_NUM_INITIALIZER
16577 (struct cmd_tx_offload_get_configuration_result,
16578 port_id, RTE_UINT16);
16579 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16580 TOKEN_STRING_INITIALIZER
16581 (struct cmd_tx_offload_get_configuration_result,
16582 tx_offload, "tx_offload");
16583 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16584 TOKEN_STRING_INITIALIZER
16585 (struct cmd_tx_offload_get_configuration_result,
16586 configuration, "configuration");
16589 cmd_tx_offload_get_configuration_parsed(
16590 void *parsed_result,
16591 __rte_unused struct cmdline *cl,
16592 __rte_unused void *data)
16594 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16595 struct rte_eth_dev_info dev_info;
16596 portid_t port_id = res->port_id;
16597 struct rte_port *port = &ports[port_id];
16598 struct rte_eth_conf dev_conf;
16599 uint64_t port_offloads;
16600 uint64_t queue_offloads;
16601 uint16_t nb_tx_queues;
16605 printf("Tx Offloading Configuration of port %d :\n", port_id);
16607 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16611 port_offloads = dev_conf.txmode.offloads;
16613 print_tx_offloads(port_offloads);
16616 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16620 nb_tx_queues = dev_info.nb_tx_queues;
16621 for (q = 0; q < nb_tx_queues; q++) {
16622 queue_offloads = port->tx_conf[q].offloads;
16623 printf(" Queue[%2d] :", q);
16624 print_tx_offloads(queue_offloads);
16630 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16631 .f = cmd_tx_offload_get_configuration_parsed,
16633 .help_str = "show port <port_id> tx_offload configuration",
16635 (void *)&cmd_tx_offload_get_configuration_show,
16636 (void *)&cmd_tx_offload_get_configuration_port,
16637 (void *)&cmd_tx_offload_get_configuration_port_id,
16638 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16639 (void *)&cmd_tx_offload_get_configuration_configuration,
16644 /* Enable/Disable a per port offloading */
16645 struct cmd_config_per_port_tx_offload_result {
16646 cmdline_fixed_string_t port;
16647 cmdline_fixed_string_t config;
16649 cmdline_fixed_string_t tx_offload;
16650 cmdline_fixed_string_t offload;
16651 cmdline_fixed_string_t on_off;
16654 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16655 TOKEN_STRING_INITIALIZER
16656 (struct cmd_config_per_port_tx_offload_result,
16658 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16659 TOKEN_STRING_INITIALIZER
16660 (struct cmd_config_per_port_tx_offload_result,
16662 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16663 TOKEN_NUM_INITIALIZER
16664 (struct cmd_config_per_port_tx_offload_result,
16665 port_id, RTE_UINT16);
16666 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16667 TOKEN_STRING_INITIALIZER
16668 (struct cmd_config_per_port_tx_offload_result,
16669 tx_offload, "tx_offload");
16670 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16671 TOKEN_STRING_INITIALIZER
16672 (struct cmd_config_per_port_tx_offload_result,
16673 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16674 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16675 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16676 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16677 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16678 "send_on_timestamp");
16679 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16680 TOKEN_STRING_INITIALIZER
16681 (struct cmd_config_per_port_tx_offload_result,
16685 search_tx_offload(const char *name)
16687 uint64_t single_offload;
16688 const char *single_name;
16692 single_offload = 1;
16693 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16694 single_name = rte_eth_dev_tx_offload_name(single_offload);
16695 if (single_name == NULL)
16697 if (!strcasecmp(single_name, name)) {
16700 } else if (!strcasecmp(single_name, "UNKNOWN"))
16702 single_offload <<= 1;
16706 return single_offload;
16712 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16713 __rte_unused struct cmdline *cl,
16714 __rte_unused void *data)
16716 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16717 portid_t port_id = res->port_id;
16718 struct rte_eth_dev_info dev_info;
16719 struct rte_port *port = &ports[port_id];
16720 uint64_t single_offload;
16721 uint16_t nb_tx_queues;
16725 if (port->port_status != RTE_PORT_STOPPED) {
16727 "Error: Can't config offload when Port %d is not stopped\n",
16732 single_offload = search_tx_offload(res->offload);
16733 if (single_offload == 0) {
16734 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16738 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16742 nb_tx_queues = dev_info.nb_tx_queues;
16743 if (!strcmp(res->on_off, "on")) {
16744 port->dev_conf.txmode.offloads |= single_offload;
16745 for (q = 0; q < nb_tx_queues; q++)
16746 port->tx_conf[q].offloads |= single_offload;
16748 port->dev_conf.txmode.offloads &= ~single_offload;
16749 for (q = 0; q < nb_tx_queues; q++)
16750 port->tx_conf[q].offloads &= ~single_offload;
16753 cmd_reconfig_device_queue(port_id, 1, 1);
16756 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16757 .f = cmd_config_per_port_tx_offload_parsed,
16759 .help_str = "port config <port_id> tx_offload "
16760 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16761 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16762 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16763 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16764 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16765 "send_on_timestamp on|off",
16767 (void *)&cmd_config_per_port_tx_offload_result_port,
16768 (void *)&cmd_config_per_port_tx_offload_result_config,
16769 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16770 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16771 (void *)&cmd_config_per_port_tx_offload_result_offload,
16772 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16777 /* Enable/Disable a per queue offloading */
16778 struct cmd_config_per_queue_tx_offload_result {
16779 cmdline_fixed_string_t port;
16781 cmdline_fixed_string_t txq;
16783 cmdline_fixed_string_t tx_offload;
16784 cmdline_fixed_string_t offload;
16785 cmdline_fixed_string_t on_off;
16788 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16789 TOKEN_STRING_INITIALIZER
16790 (struct cmd_config_per_queue_tx_offload_result,
16792 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16793 TOKEN_NUM_INITIALIZER
16794 (struct cmd_config_per_queue_tx_offload_result,
16795 port_id, RTE_UINT16);
16796 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16797 TOKEN_STRING_INITIALIZER
16798 (struct cmd_config_per_queue_tx_offload_result,
16800 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16801 TOKEN_NUM_INITIALIZER
16802 (struct cmd_config_per_queue_tx_offload_result,
16803 queue_id, RTE_UINT16);
16804 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16805 TOKEN_STRING_INITIALIZER
16806 (struct cmd_config_per_queue_tx_offload_result,
16807 tx_offload, "tx_offload");
16808 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16809 TOKEN_STRING_INITIALIZER
16810 (struct cmd_config_per_queue_tx_offload_result,
16811 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16812 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16813 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16814 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16815 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16816 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16817 TOKEN_STRING_INITIALIZER
16818 (struct cmd_config_per_queue_tx_offload_result,
16822 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16823 __rte_unused struct cmdline *cl,
16824 __rte_unused void *data)
16826 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16827 struct rte_eth_dev_info dev_info;
16828 portid_t port_id = res->port_id;
16829 uint16_t queue_id = res->queue_id;
16830 struct rte_port *port = &ports[port_id];
16831 uint64_t single_offload;
16834 if (port->port_status != RTE_PORT_STOPPED) {
16836 "Error: Can't config offload when Port %d is not stopped\n",
16841 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16845 if (queue_id >= dev_info.nb_tx_queues) {
16847 "Error: input queue_id should be 0 ... %d\n",
16848 dev_info.nb_tx_queues - 1);
16852 single_offload = search_tx_offload(res->offload);
16853 if (single_offload == 0) {
16854 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16858 if (!strcmp(res->on_off, "on"))
16859 port->tx_conf[queue_id].offloads |= single_offload;
16861 port->tx_conf[queue_id].offloads &= ~single_offload;
16863 cmd_reconfig_device_queue(port_id, 1, 1);
16866 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16867 .f = cmd_config_per_queue_tx_offload_parsed,
16869 .help_str = "port <port_id> txq <queue_id> tx_offload "
16870 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16871 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16872 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16873 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16874 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16877 (void *)&cmd_config_per_queue_tx_offload_result_port,
16878 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16879 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16880 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16881 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16882 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16883 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16888 /* *** configure tx_metadata for specific port *** */
16889 struct cmd_config_tx_metadata_specific_result {
16890 cmdline_fixed_string_t port;
16891 cmdline_fixed_string_t keyword;
16893 cmdline_fixed_string_t item;
16898 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16899 __rte_unused struct cmdline *cl,
16900 __rte_unused void *data)
16902 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16906 ports[res->port_id].tx_metadata = res->value;
16907 /* Add/remove callback to insert valid metadata in every Tx packet. */
16908 if (ports[res->port_id].tx_metadata)
16909 add_tx_md_callback(res->port_id);
16911 remove_tx_md_callback(res->port_id);
16912 rte_flow_dynf_metadata_register();
16915 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16916 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16918 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16919 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16920 keyword, "config");
16921 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16922 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16923 port_id, RTE_UINT16);
16924 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16925 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16926 item, "tx_metadata");
16927 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16928 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16929 value, RTE_UINT32);
16931 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16932 .f = cmd_config_tx_metadata_specific_parsed,
16934 .help_str = "port config <port_id> tx_metadata <value>",
16936 (void *)&cmd_config_tx_metadata_specific_port,
16937 (void *)&cmd_config_tx_metadata_specific_keyword,
16938 (void *)&cmd_config_tx_metadata_specific_id,
16939 (void *)&cmd_config_tx_metadata_specific_item,
16940 (void *)&cmd_config_tx_metadata_specific_value,
16945 /* *** set dynf *** */
16946 struct cmd_config_tx_dynf_specific_result {
16947 cmdline_fixed_string_t port;
16948 cmdline_fixed_string_t keyword;
16950 cmdline_fixed_string_t item;
16951 cmdline_fixed_string_t name;
16952 cmdline_fixed_string_t value;
16956 cmd_config_dynf_specific_parsed(void *parsed_result,
16957 __rte_unused struct cmdline *cl,
16958 __rte_unused void *data)
16960 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16961 struct rte_mbuf_dynflag desc_flag;
16963 uint64_t old_port_flags;
16965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16967 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16969 if (strlcpy(desc_flag.name, res->name,
16970 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16971 fprintf(stderr, "Flag name too long\n");
16974 desc_flag.flags = 0;
16975 flag = rte_mbuf_dynflag_register(&desc_flag);
16977 fprintf(stderr, "Can't register flag\n");
16980 strcpy(dynf_names[flag], desc_flag.name);
16982 old_port_flags = ports[res->port_id].mbuf_dynf;
16983 if (!strcmp(res->value, "set")) {
16984 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16985 if (old_port_flags == 0)
16986 add_tx_dynf_callback(res->port_id);
16988 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16989 if (ports[res->port_id].mbuf_dynf == 0)
16990 remove_tx_dynf_callback(res->port_id);
16994 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16995 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16997 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16998 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16999 keyword, "config");
17000 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17001 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17002 port_id, RTE_UINT16);
17003 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17004 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17006 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17007 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17009 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17010 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17011 value, "set#clear");
17013 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17014 .f = cmd_config_dynf_specific_parsed,
17016 .help_str = "port config <port id> dynf <name> set|clear",
17018 (void *)&cmd_config_tx_dynf_specific_port,
17019 (void *)&cmd_config_tx_dynf_specific_keyword,
17020 (void *)&cmd_config_tx_dynf_specific_port_id,
17021 (void *)&cmd_config_tx_dynf_specific_item,
17022 (void *)&cmd_config_tx_dynf_specific_name,
17023 (void *)&cmd_config_tx_dynf_specific_value,
17028 /* *** display tx_metadata per port configuration *** */
17029 struct cmd_show_tx_metadata_result {
17030 cmdline_fixed_string_t cmd_show;
17031 cmdline_fixed_string_t cmd_port;
17032 cmdline_fixed_string_t cmd_keyword;
17037 cmd_show_tx_metadata_parsed(void *parsed_result,
17038 __rte_unused struct cmdline *cl,
17039 __rte_unused void *data)
17041 struct cmd_show_tx_metadata_result *res = parsed_result;
17043 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17044 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17047 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17048 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17049 ports[res->cmd_pid].tx_metadata);
17053 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17054 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17056 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17057 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17059 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17060 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17061 cmd_pid, RTE_UINT16);
17062 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17063 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17064 cmd_keyword, "tx_metadata");
17066 cmdline_parse_inst_t cmd_show_tx_metadata = {
17067 .f = cmd_show_tx_metadata_parsed,
17069 .help_str = "show port <port_id> tx_metadata",
17071 (void *)&cmd_show_tx_metadata_show,
17072 (void *)&cmd_show_tx_metadata_port,
17073 (void *)&cmd_show_tx_metadata_pid,
17074 (void *)&cmd_show_tx_metadata_keyword,
17079 /* *** show fec capability per port configuration *** */
17080 struct cmd_show_fec_capability_result {
17081 cmdline_fixed_string_t cmd_show;
17082 cmdline_fixed_string_t cmd_port;
17083 cmdline_fixed_string_t cmd_fec;
17084 cmdline_fixed_string_t cmd_keyword;
17089 cmd_show_fec_capability_parsed(void *parsed_result,
17090 __rte_unused struct cmdline *cl,
17091 __rte_unused void *data)
17093 struct cmd_show_fec_capability_result *res = parsed_result;
17094 struct rte_eth_fec_capa *speed_fec_capa;
17098 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17099 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17103 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
17104 if (ret == -ENOTSUP) {
17105 fprintf(stderr, "Function not implemented\n");
17107 } else if (ret < 0) {
17108 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
17112 num = (unsigned int)ret;
17113 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
17114 if (speed_fec_capa == NULL) {
17115 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
17119 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17121 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17125 show_fec_capability(num, speed_fec_capa);
17127 free(speed_fec_capa);
17130 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17131 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17133 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17134 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17136 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17137 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17138 cmd_pid, RTE_UINT16);
17139 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17140 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17142 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17143 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17144 cmd_keyword, "capabilities");
17146 cmdline_parse_inst_t cmd_show_capability = {
17147 .f = cmd_show_fec_capability_parsed,
17149 .help_str = "show port <port_id> fec capabilities",
17151 (void *)&cmd_show_fec_capability_show,
17152 (void *)&cmd_show_fec_capability_port,
17153 (void *)&cmd_show_fec_capability_pid,
17154 (void *)&cmd_show_fec_capability_fec,
17155 (void *)&cmd_show_fec_capability_keyword,
17160 /* *** show fec mode per port configuration *** */
17161 struct cmd_show_fec_metadata_result {
17162 cmdline_fixed_string_t cmd_show;
17163 cmdline_fixed_string_t cmd_port;
17164 cmdline_fixed_string_t cmd_keyword;
17169 cmd_show_fec_mode_parsed(void *parsed_result,
17170 __rte_unused struct cmdline *cl,
17171 __rte_unused void *data)
17173 #define FEC_NAME_SIZE 16
17174 struct cmd_show_fec_metadata_result *res = parsed_result;
17176 char buf[FEC_NAME_SIZE];
17179 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17180 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17183 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17184 if (ret == -ENOTSUP) {
17185 fprintf(stderr, "Function not implemented\n");
17187 } else if (ret < 0) {
17188 fprintf(stderr, "Get FEC mode failed\n");
17193 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17194 strlcpy(buf, "off", sizeof(buf));
17196 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17197 strlcpy(buf, "auto", sizeof(buf));
17199 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17200 strlcpy(buf, "baser", sizeof(buf));
17202 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17203 strlcpy(buf, "rs", sizeof(buf));
17209 printf("%s\n", buf);
17212 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17213 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17215 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17216 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17218 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17219 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17220 cmd_pid, RTE_UINT16);
17221 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17222 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17223 cmd_keyword, "fec_mode");
17225 cmdline_parse_inst_t cmd_show_fec_mode = {
17226 .f = cmd_show_fec_mode_parsed,
17228 .help_str = "show port <port_id> fec_mode",
17230 (void *)&cmd_show_fec_mode_show,
17231 (void *)&cmd_show_fec_mode_port,
17232 (void *)&cmd_show_fec_mode_pid,
17233 (void *)&cmd_show_fec_mode_keyword,
17238 /* *** set fec mode per port configuration *** */
17239 struct cmd_set_port_fec_mode {
17240 cmdline_fixed_string_t set;
17241 cmdline_fixed_string_t port;
17243 cmdline_fixed_string_t fec_mode;
17244 cmdline_fixed_string_t fec_value;
17247 /* Common CLI fields for set fec mode */
17248 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17249 TOKEN_STRING_INITIALIZER
17250 (struct cmd_set_port_fec_mode,
17252 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17253 TOKEN_STRING_INITIALIZER
17254 (struct cmd_set_port_fec_mode,
17256 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17257 TOKEN_NUM_INITIALIZER
17258 (struct cmd_set_port_fec_mode,
17259 port_id, RTE_UINT16);
17260 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17261 TOKEN_STRING_INITIALIZER
17262 (struct cmd_set_port_fec_mode,
17263 fec_mode, "fec_mode");
17264 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17265 TOKEN_STRING_INITIALIZER
17266 (struct cmd_set_port_fec_mode,
17270 cmd_set_port_fec_mode_parsed(
17271 void *parsed_result,
17272 __rte_unused struct cmdline *cl,
17273 __rte_unused void *data)
17275 struct cmd_set_port_fec_mode *res = parsed_result;
17276 uint16_t port_id = res->port_id;
17280 ret = parse_fec_mode(res->fec_value, &fec_capa);
17282 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17283 res->fec_value, port_id);
17287 ret = rte_eth_fec_set(port_id, fec_capa);
17288 if (ret == -ENOTSUP) {
17289 fprintf(stderr, "Function not implemented\n");
17291 } else if (ret < 0) {
17292 fprintf(stderr, "Set FEC mode failed\n");
17297 cmdline_parse_inst_t cmd_set_fec_mode = {
17298 .f = cmd_set_port_fec_mode_parsed,
17300 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17302 (void *)&cmd_set_port_fec_mode_set,
17303 (void *)&cmd_set_port_fec_mode_port,
17304 (void *)&cmd_set_port_fec_mode_port_id,
17305 (void *)&cmd_set_port_fec_mode_str,
17306 (void *)&cmd_set_port_fec_mode_value,
17311 /* show port supported ptypes */
17313 /* Common result structure for show port ptypes */
17314 struct cmd_show_port_supported_ptypes_result {
17315 cmdline_fixed_string_t show;
17316 cmdline_fixed_string_t port;
17318 cmdline_fixed_string_t ptypes;
17321 /* Common CLI fields for show port ptypes */
17322 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17323 TOKEN_STRING_INITIALIZER
17324 (struct cmd_show_port_supported_ptypes_result,
17326 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17327 TOKEN_STRING_INITIALIZER
17328 (struct cmd_show_port_supported_ptypes_result,
17330 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17331 TOKEN_NUM_INITIALIZER
17332 (struct cmd_show_port_supported_ptypes_result,
17333 port_id, RTE_UINT16);
17334 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17335 TOKEN_STRING_INITIALIZER
17336 (struct cmd_show_port_supported_ptypes_result,
17340 cmd_show_port_supported_ptypes_parsed(
17341 void *parsed_result,
17342 __rte_unused struct cmdline *cl,
17343 __rte_unused void *data)
17345 #define RSVD_PTYPE_MASK 0xf0000000
17346 #define MAX_PTYPES_PER_LAYER 16
17347 #define LTYPE_NAMESIZE 32
17348 #define PTYPE_NAMESIZE 256
17349 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17350 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17351 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17352 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17353 uint16_t port_id = res->port_id;
17356 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17360 while (ptype_mask != RSVD_PTYPE_MASK) {
17362 switch (ptype_mask) {
17363 case RTE_PTYPE_L2_MASK:
17364 strlcpy(ltype, "L2", sizeof(ltype));
17366 case RTE_PTYPE_L3_MASK:
17367 strlcpy(ltype, "L3", sizeof(ltype));
17369 case RTE_PTYPE_L4_MASK:
17370 strlcpy(ltype, "L4", sizeof(ltype));
17372 case RTE_PTYPE_TUNNEL_MASK:
17373 strlcpy(ltype, "Tunnel", sizeof(ltype));
17375 case RTE_PTYPE_INNER_L2_MASK:
17376 strlcpy(ltype, "Inner L2", sizeof(ltype));
17378 case RTE_PTYPE_INNER_L3_MASK:
17379 strlcpy(ltype, "Inner L3", sizeof(ltype));
17381 case RTE_PTYPE_INNER_L4_MASK:
17382 strlcpy(ltype, "Inner L4", sizeof(ltype));
17388 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17389 ptype_mask, ptypes,
17390 MAX_PTYPES_PER_LAYER);
17393 printf("Supported %s ptypes:\n", ltype);
17395 printf("%s ptypes unsupported\n", ltype);
17397 for (i = 0; i < ret; ++i) {
17398 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17399 printf("%s\n", buf);
17406 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17407 .f = cmd_show_port_supported_ptypes_parsed,
17409 .help_str = "show port <port_id> ptypes",
17411 (void *)&cmd_show_port_supported_ptypes_show,
17412 (void *)&cmd_show_port_supported_ptypes_port,
17413 (void *)&cmd_show_port_supported_ptypes_port_id,
17414 (void *)&cmd_show_port_supported_ptypes_ptypes,
17419 /* *** display rx/tx descriptor status *** */
17420 struct cmd_show_rx_tx_desc_status_result {
17421 cmdline_fixed_string_t cmd_show;
17422 cmdline_fixed_string_t cmd_port;
17423 cmdline_fixed_string_t cmd_keyword;
17424 cmdline_fixed_string_t cmd_desc;
17425 cmdline_fixed_string_t cmd_status;
17432 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17433 __rte_unused struct cmdline *cl,
17434 __rte_unused void *data)
17436 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17439 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17440 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17444 if (!strcmp(res->cmd_keyword, "rxq")) {
17445 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17449 "Invalid input: queue id = %d, desc id = %d\n",
17450 res->cmd_qid, res->cmd_did);
17453 if (rc == RTE_ETH_RX_DESC_AVAIL)
17454 printf("Desc status = AVAILABLE\n");
17455 else if (rc == RTE_ETH_RX_DESC_DONE)
17456 printf("Desc status = DONE\n");
17458 printf("Desc status = UNAVAILABLE\n");
17459 } else if (!strcmp(res->cmd_keyword, "txq")) {
17460 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17464 "Invalid input: queue id = %d, desc id = %d\n",
17465 res->cmd_qid, res->cmd_did);
17468 if (rc == RTE_ETH_TX_DESC_FULL)
17469 printf("Desc status = FULL\n");
17470 else if (rc == RTE_ETH_TX_DESC_DONE)
17471 printf("Desc status = DONE\n");
17473 printf("Desc status = UNAVAILABLE\n");
17477 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17478 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17480 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17481 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17483 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17484 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17485 cmd_pid, RTE_UINT16);
17486 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17487 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17488 cmd_keyword, "rxq#txq");
17489 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17490 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17491 cmd_qid, RTE_UINT16);
17492 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17493 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17495 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17496 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17497 cmd_did, RTE_UINT16);
17498 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17499 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17500 cmd_status, "status");
17501 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17502 .f = cmd_show_rx_tx_desc_status_parsed,
17504 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17507 (void *)&cmd_show_rx_tx_desc_status_show,
17508 (void *)&cmd_show_rx_tx_desc_status_port,
17509 (void *)&cmd_show_rx_tx_desc_status_pid,
17510 (void *)&cmd_show_rx_tx_desc_status_keyword,
17511 (void *)&cmd_show_rx_tx_desc_status_qid,
17512 (void *)&cmd_show_rx_tx_desc_status_desc,
17513 (void *)&cmd_show_rx_tx_desc_status_did,
17514 (void *)&cmd_show_rx_tx_desc_status_status,
17519 /* *** display rx queue desc used count *** */
17520 struct cmd_show_rx_queue_desc_used_count_result {
17521 cmdline_fixed_string_t cmd_show;
17522 cmdline_fixed_string_t cmd_port;
17523 cmdline_fixed_string_t cmd_rxq;
17524 cmdline_fixed_string_t cmd_desc;
17525 cmdline_fixed_string_t cmd_used;
17526 cmdline_fixed_string_t cmd_count;
17532 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17533 __rte_unused struct cmdline *cl,
17534 __rte_unused void *data)
17536 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17539 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17540 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17544 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17546 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17549 printf("Used desc count = %d\n", rc);
17552 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17553 TOKEN_STRING_INITIALIZER
17554 (struct cmd_show_rx_queue_desc_used_count_result,
17556 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17557 TOKEN_STRING_INITIALIZER
17558 (struct cmd_show_rx_queue_desc_used_count_result,
17560 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17561 TOKEN_NUM_INITIALIZER
17562 (struct cmd_show_rx_queue_desc_used_count_result,
17563 cmd_pid, RTE_UINT16);
17564 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17565 TOKEN_STRING_INITIALIZER
17566 (struct cmd_show_rx_queue_desc_used_count_result,
17568 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17569 TOKEN_NUM_INITIALIZER
17570 (struct cmd_show_rx_queue_desc_used_count_result,
17571 cmd_qid, RTE_UINT16);
17572 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17573 TOKEN_STRING_INITIALIZER
17574 (struct cmd_show_rx_queue_desc_used_count_result,
17575 cmd_count, "desc");
17576 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17577 TOKEN_STRING_INITIALIZER
17578 (struct cmd_show_rx_queue_desc_used_count_result,
17579 cmd_count, "used");
17580 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17581 TOKEN_STRING_INITIALIZER
17582 (struct cmd_show_rx_queue_desc_used_count_result,
17583 cmd_count, "count");
17584 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17585 .f = cmd_show_rx_queue_desc_used_count_parsed,
17587 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17589 (void *)&cmd_show_rx_queue_desc_used_count_show,
17590 (void *)&cmd_show_rx_queue_desc_used_count_port,
17591 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17592 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17593 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17594 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17595 (void *)&cmd_show_rx_queue_desc_used_count_used,
17596 (void *)&cmd_show_rx_queue_desc_used_count_count,
17601 /* Common result structure for set port ptypes */
17602 struct cmd_set_port_ptypes_result {
17603 cmdline_fixed_string_t set;
17604 cmdline_fixed_string_t port;
17606 cmdline_fixed_string_t ptype_mask;
17610 /* Common CLI fields for set port ptypes */
17611 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17612 TOKEN_STRING_INITIALIZER
17613 (struct cmd_set_port_ptypes_result,
17615 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17616 TOKEN_STRING_INITIALIZER
17617 (struct cmd_set_port_ptypes_result,
17619 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17620 TOKEN_NUM_INITIALIZER
17621 (struct cmd_set_port_ptypes_result,
17622 port_id, RTE_UINT16);
17623 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17624 TOKEN_STRING_INITIALIZER
17625 (struct cmd_set_port_ptypes_result,
17626 ptype_mask, "ptype_mask");
17627 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17628 TOKEN_NUM_INITIALIZER
17629 (struct cmd_set_port_ptypes_result,
17633 cmd_set_port_ptypes_parsed(
17634 void *parsed_result,
17635 __rte_unused struct cmdline *cl,
17636 __rte_unused void *data)
17638 struct cmd_set_port_ptypes_result *res = parsed_result;
17639 #define PTYPE_NAMESIZE 256
17640 char ptype_name[PTYPE_NAMESIZE];
17641 uint16_t port_id = res->port_id;
17642 uint32_t ptype_mask = res->mask;
17645 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17648 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17653 uint32_t ptypes[ret];
17655 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17657 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17662 printf("Successfully set following ptypes for Port %d\n", port_id);
17663 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17664 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17665 printf("%s\n", ptype_name);
17668 clear_ptypes = false;
17671 cmdline_parse_inst_t cmd_set_port_ptypes = {
17672 .f = cmd_set_port_ptypes_parsed,
17674 .help_str = "set port <port_id> ptype_mask <mask>",
17676 (void *)&cmd_set_port_ptypes_set,
17677 (void *)&cmd_set_port_ptypes_port,
17678 (void *)&cmd_set_port_ptypes_port_id,
17679 (void *)&cmd_set_port_ptypes_mask_str,
17680 (void *)&cmd_set_port_ptypes_mask_u32,
17685 /* *** display mac addresses added to a port *** */
17686 struct cmd_showport_macs_result {
17687 cmdline_fixed_string_t cmd_show;
17688 cmdline_fixed_string_t cmd_port;
17689 cmdline_fixed_string_t cmd_keyword;
17694 cmd_showport_macs_parsed(void *parsed_result,
17695 __rte_unused struct cmdline *cl,
17696 __rte_unused void *data)
17698 struct cmd_showport_macs_result *res = parsed_result;
17700 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17703 if (!strcmp(res->cmd_keyword, "macs"))
17704 show_macs(res->cmd_pid);
17705 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17706 show_mcast_macs(res->cmd_pid);
17709 cmdline_parse_token_string_t cmd_showport_macs_show =
17710 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17712 cmdline_parse_token_string_t cmd_showport_macs_port =
17713 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17715 cmdline_parse_token_num_t cmd_showport_macs_pid =
17716 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17717 cmd_pid, RTE_UINT16);
17718 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17719 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17720 cmd_keyword, "macs#mcast_macs");
17722 cmdline_parse_inst_t cmd_showport_macs = {
17723 .f = cmd_showport_macs_parsed,
17725 .help_str = "show port <port_id> macs|mcast_macs",
17727 (void *)&cmd_showport_macs_show,
17728 (void *)&cmd_showport_macs_port,
17729 (void *)&cmd_showport_macs_pid,
17730 (void *)&cmd_showport_macs_keyword,
17735 /* *** show flow transfer proxy port ID for the given port *** */
17736 struct cmd_show_port_flow_transfer_proxy_result {
17737 cmdline_fixed_string_t show;
17738 cmdline_fixed_string_t port;
17740 cmdline_fixed_string_t flow;
17741 cmdline_fixed_string_t transfer;
17742 cmdline_fixed_string_t proxy;
17745 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17746 TOKEN_STRING_INITIALIZER
17747 (struct cmd_show_port_flow_transfer_proxy_result,
17749 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17750 TOKEN_STRING_INITIALIZER
17751 (struct cmd_show_port_flow_transfer_proxy_result,
17753 cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17754 TOKEN_NUM_INITIALIZER
17755 (struct cmd_show_port_flow_transfer_proxy_result,
17756 port_id, RTE_UINT16);
17757 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17758 TOKEN_STRING_INITIALIZER
17759 (struct cmd_show_port_flow_transfer_proxy_result,
17761 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17762 TOKEN_STRING_INITIALIZER
17763 (struct cmd_show_port_flow_transfer_proxy_result,
17764 transfer, "transfer");
17765 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17766 TOKEN_STRING_INITIALIZER
17767 (struct cmd_show_port_flow_transfer_proxy_result,
17771 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17772 __rte_unused struct cmdline *cl,
17773 __rte_unused void *data)
17775 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17776 portid_t proxy_port_id;
17781 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17783 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17784 rte_strerror(-ret));
17788 printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17791 cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17792 .f = cmd_show_port_flow_transfer_proxy_parsed,
17794 .help_str = "show port <port_id> flow transfer proxy",
17796 (void *)&cmd_show_port_flow_transfer_proxy_show,
17797 (void *)&cmd_show_port_flow_transfer_proxy_port,
17798 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
17799 (void *)&cmd_show_port_flow_transfer_proxy_flow,
17800 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
17801 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
17806 /* ******************************************************************************** */
17808 /* list of instructions */
17809 cmdline_parse_ctx_t main_ctx[] = {
17810 (cmdline_parse_inst_t *)&cmd_help_brief,
17811 (cmdline_parse_inst_t *)&cmd_help_long,
17812 (cmdline_parse_inst_t *)&cmd_quit,
17813 (cmdline_parse_inst_t *)&cmd_load_from_file,
17814 (cmdline_parse_inst_t *)&cmd_showport,
17815 (cmdline_parse_inst_t *)&cmd_showqueue,
17816 (cmdline_parse_inst_t *)&cmd_showeeprom,
17817 (cmdline_parse_inst_t *)&cmd_showportall,
17818 (cmdline_parse_inst_t *)&cmd_representor_info,
17819 (cmdline_parse_inst_t *)&cmd_showdevice,
17820 (cmdline_parse_inst_t *)&cmd_showcfg,
17821 (cmdline_parse_inst_t *)&cmd_showfwdall,
17822 (cmdline_parse_inst_t *)&cmd_start,
17823 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17824 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17825 (cmdline_parse_inst_t *)&cmd_set_link_up,
17826 (cmdline_parse_inst_t *)&cmd_set_link_down,
17827 (cmdline_parse_inst_t *)&cmd_reset,
17828 (cmdline_parse_inst_t *)&cmd_set_numbers,
17829 (cmdline_parse_inst_t *)&cmd_set_log,
17830 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17831 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17832 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17833 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17834 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17835 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17836 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17837 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17838 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17839 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17840 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17841 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17842 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17843 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17844 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17845 (cmdline_parse_inst_t *)&cmd_set_link_check,
17846 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17847 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17848 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17849 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17850 #ifdef RTE_NET_BOND
17851 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17852 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17853 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17854 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17855 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17856 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17857 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17858 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17859 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17860 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17861 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17862 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17864 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17865 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17866 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17867 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17868 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17869 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17870 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17871 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17872 (cmdline_parse_inst_t *)&cmd_csum_set,
17873 (cmdline_parse_inst_t *)&cmd_csum_show,
17874 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17875 (cmdline_parse_inst_t *)&cmd_tso_set,
17876 (cmdline_parse_inst_t *)&cmd_tso_show,
17877 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17878 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17880 (cmdline_parse_inst_t *)&cmd_gro_enable,
17881 (cmdline_parse_inst_t *)&cmd_gro_flush,
17882 (cmdline_parse_inst_t *)&cmd_gro_show,
17885 (cmdline_parse_inst_t *)&cmd_gso_enable,
17886 (cmdline_parse_inst_t *)&cmd_gso_size,
17887 (cmdline_parse_inst_t *)&cmd_gso_show,
17889 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17890 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17891 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17892 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17893 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17894 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17895 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17896 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17897 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17898 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17899 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17900 (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
17901 (cmdline_parse_inst_t *)&cmd_config_dcb,
17902 (cmdline_parse_inst_t *)&cmd_read_reg,
17903 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17904 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17905 (cmdline_parse_inst_t *)&cmd_write_reg,
17906 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17907 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17908 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17909 (cmdline_parse_inst_t *)&cmd_stop,
17910 (cmdline_parse_inst_t *)&cmd_mac_addr,
17911 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17912 (cmdline_parse_inst_t *)&cmd_set_qmap,
17913 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17914 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17915 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17916 (cmdline_parse_inst_t *)&cmd_operate_port,
17917 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17918 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17919 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17920 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17921 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17922 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17923 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17924 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17925 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17926 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17927 (cmdline_parse_inst_t *)&cmd_config_mtu,
17928 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17929 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17930 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17931 (cmdline_parse_inst_t *)&cmd_config_rss,
17932 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17933 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17934 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17935 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17936 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17937 (cmdline_parse_inst_t *)&cmd_showport_reta,
17938 (cmdline_parse_inst_t *)&cmd_showport_macs,
17939 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17940 (cmdline_parse_inst_t *)&cmd_config_burst,
17941 (cmdline_parse_inst_t *)&cmd_config_thresh,
17942 (cmdline_parse_inst_t *)&cmd_config_threshold,
17943 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17944 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17945 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17946 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17947 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17948 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17949 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17950 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17951 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17952 (cmdline_parse_inst_t *)&cmd_dump,
17953 (cmdline_parse_inst_t *)&cmd_dump_one,
17954 #ifdef RTE_NET_I40E
17955 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17957 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17958 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17959 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17960 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17961 (cmdline_parse_inst_t *)&cmd_flow,
17962 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17963 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17964 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17965 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17966 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17967 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17968 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17969 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17970 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17971 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17972 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17973 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17974 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17975 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17976 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17977 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17978 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17979 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17980 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17981 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17982 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17983 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17984 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17985 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17986 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17987 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17988 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17989 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17990 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17991 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17992 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17993 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17994 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17995 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17996 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17997 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17998 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17999 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18000 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18001 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18002 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18003 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18004 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18005 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18006 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18007 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18008 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18009 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18010 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18011 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18012 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18013 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18014 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18015 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18016 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18017 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18018 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
18019 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
18020 (cmdline_parse_inst_t *)&cmd_ddp_add,
18021 (cmdline_parse_inst_t *)&cmd_ddp_del,
18022 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18023 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18024 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18025 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18026 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18027 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18028 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18029 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18030 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18031 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18032 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18033 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18035 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18036 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18037 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18038 (cmdline_parse_inst_t *)&cmd_queue_region,
18039 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18040 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18041 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18042 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18043 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18044 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18045 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18046 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18047 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18048 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18049 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18050 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18051 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18052 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18053 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18054 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18055 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18056 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18057 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18058 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18059 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18060 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18061 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18062 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18063 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18064 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18065 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18066 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18067 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18068 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18069 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18070 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18071 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18072 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18073 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18074 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18076 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18077 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18079 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18080 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18081 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18082 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
18083 (cmdline_parse_inst_t *)&cmd_set_raw,
18084 (cmdline_parse_inst_t *)&cmd_show_set_raw,
18085 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18086 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18087 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
18088 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
18089 (cmdline_parse_inst_t *)&cmd_show_capability,
18090 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
18091 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
18095 /* read cmdline commands from file */
18097 cmdline_read_from_file(const char *filename)
18099 struct cmdline *cl;
18101 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18104 "Failed to create file based cmdline context: %s\n",
18109 cmdline_interact(cl);
18114 printf("Read CLI commands from %s\n", filename);
18117 /* prompt function, called from main on MAIN lcore */
18122 /* initialize non-constant commands */
18123 cmd_set_fwd_mode_init();
18124 cmd_set_fwd_retry_mode_init();
18126 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18127 if (testpmd_cl == NULL)
18130 ret = atexit(prompt_exit);
18132 fprintf(stderr, "Cannot set exit function for cmdline\n");
18134 cmdline_interact(testpmd_cl);
18136 cmdline_stdin_exit(testpmd_cl);
18142 if (testpmd_cl != NULL) {
18143 cmdline_quit(testpmd_cl);
18144 cmdline_stdin_exit(testpmd_cl);
18149 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18151 if (id == (portid_t)RTE_PORT_ALL) {
18154 RTE_ETH_FOREACH_DEV(pid) {
18155 /* check if need_reconfig has been set to 1 */
18156 if (ports[pid].need_reconfig == 0)
18157 ports[pid].need_reconfig = dev;
18158 /* check if need_reconfig_queues has been set to 1 */
18159 if (ports[pid].need_reconfig_queues == 0)
18160 ports[pid].need_reconfig_queues = queue;
18162 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18163 /* check if need_reconfig has been set to 1 */
18164 if (ports[id].need_reconfig == 0)
18165 ports[id].need_reconfig = dev;
18166 /* check if need_reconfig_queues has been set to 1 */
18167 if (ports[id].need_reconfig_queues == 0)
18168 ports[id].need_reconfig_queues = queue;