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|none|level-default|"
802 "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 if (res->value < RTE_ETHER_MIN_LEN) {
2054 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2057 port_mtu_set(res->port_id, res->value);
2060 cmdline_parse_token_string_t cmd_config_mtu_port =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2063 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2066 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2069 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2070 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2072 cmdline_parse_token_num_t cmd_config_mtu_value =
2073 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2076 cmdline_parse_inst_t cmd_config_mtu = {
2077 .f = cmd_config_mtu_parsed,
2079 .help_str = "port config mtu <port_id> <value>",
2081 (void *)&cmd_config_mtu_port,
2082 (void *)&cmd_config_mtu_keyword,
2083 (void *)&cmd_config_mtu_mtu,
2084 (void *)&cmd_config_mtu_port_id,
2085 (void *)&cmd_config_mtu_value,
2090 /* *** configure rx mode *** */
2091 struct cmd_config_rx_mode_flag {
2092 cmdline_fixed_string_t port;
2093 cmdline_fixed_string_t keyword;
2094 cmdline_fixed_string_t all;
2095 cmdline_fixed_string_t name;
2096 cmdline_fixed_string_t value;
2100 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2101 __rte_unused struct cmdline *cl,
2102 __rte_unused void *data)
2104 struct cmd_config_rx_mode_flag *res = parsed_result;
2106 if (!all_ports_stopped()) {
2107 fprintf(stderr, "Please stop all ports first\n");
2111 if (!strcmp(res->name, "drop-en")) {
2112 if (!strcmp(res->value, "on"))
2114 else if (!strcmp(res->value, "off"))
2117 fprintf(stderr, "Unknown parameter\n");
2121 fprintf(stderr, "Unknown parameter\n");
2127 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2130 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2131 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2132 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2133 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2135 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2137 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2138 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2140 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2141 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2144 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2145 .f = cmd_config_rx_mode_flag_parsed,
2147 .help_str = "port config all drop-en on|off",
2149 (void *)&cmd_config_rx_mode_flag_port,
2150 (void *)&cmd_config_rx_mode_flag_keyword,
2151 (void *)&cmd_config_rx_mode_flag_all,
2152 (void *)&cmd_config_rx_mode_flag_name,
2153 (void *)&cmd_config_rx_mode_flag_value,
2158 /* *** configure rss *** */
2159 struct cmd_config_rss {
2160 cmdline_fixed_string_t port;
2161 cmdline_fixed_string_t keyword;
2162 cmdline_fixed_string_t all;
2163 cmdline_fixed_string_t name;
2164 cmdline_fixed_string_t value;
2168 cmd_config_rss_parsed(void *parsed_result,
2169 __rte_unused struct cmdline *cl,
2170 __rte_unused void *data)
2172 struct cmd_config_rss *res = parsed_result;
2173 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2174 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2175 int use_default = 0;
2176 int all_updated = 1;
2181 if (!strcmp(res->value, "all"))
2182 rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2183 RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2184 RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2185 RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2187 else if (!strcmp(res->value, "eth"))
2188 rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2189 else if (!strcmp(res->value, "vlan"))
2190 rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2191 else if (!strcmp(res->value, "ip"))
2192 rss_conf.rss_hf = RTE_ETH_RSS_IP;
2193 else if (!strcmp(res->value, "udp"))
2194 rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2195 else if (!strcmp(res->value, "tcp"))
2196 rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2197 else if (!strcmp(res->value, "sctp"))
2198 rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2199 else if (!strcmp(res->value, "ether"))
2200 rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2201 else if (!strcmp(res->value, "port"))
2202 rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2203 else if (!strcmp(res->value, "vxlan"))
2204 rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2205 else if (!strcmp(res->value, "geneve"))
2206 rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2207 else if (!strcmp(res->value, "nvgre"))
2208 rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2209 else if (!strcmp(res->value, "l3-pre32"))
2210 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2211 else if (!strcmp(res->value, "l3-pre40"))
2212 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2213 else if (!strcmp(res->value, "l3-pre48"))
2214 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2215 else if (!strcmp(res->value, "l3-pre56"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2217 else if (!strcmp(res->value, "l3-pre64"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2219 else if (!strcmp(res->value, "l3-pre96"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2221 else if (!strcmp(res->value, "l3-src-only"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2223 else if (!strcmp(res->value, "l3-dst-only"))
2224 rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2225 else if (!strcmp(res->value, "l4-src-only"))
2226 rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2227 else if (!strcmp(res->value, "l4-dst-only"))
2228 rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2229 else if (!strcmp(res->value, "l2-src-only"))
2230 rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2231 else if (!strcmp(res->value, "l2-dst-only"))
2232 rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2233 else if (!strcmp(res->value, "l2tpv3"))
2234 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2235 else if (!strcmp(res->value, "esp"))
2236 rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2237 else if (!strcmp(res->value, "ah"))
2238 rss_conf.rss_hf = RTE_ETH_RSS_AH;
2239 else if (!strcmp(res->value, "pfcp"))
2240 rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2241 else if (!strcmp(res->value, "pppoe"))
2242 rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2243 else if (!strcmp(res->value, "gtpu"))
2244 rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2245 else if (!strcmp(res->value, "ecpri"))
2246 rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2247 else if (!strcmp(res->value, "mpls"))
2248 rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2249 else if (!strcmp(res->value, "ipv4-chksum"))
2250 rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2251 else if (!strcmp(res->value, "none"))
2252 rss_conf.rss_hf = 0;
2253 else if (!strcmp(res->value, "level-default")) {
2254 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2255 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2256 } else if (!strcmp(res->value, "level-outer")) {
2257 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2258 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2259 } else if (!strcmp(res->value, "level-inner")) {
2260 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2261 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2262 } else if (!strcmp(res->value, "default"))
2264 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2265 atoi(res->value) < 64)
2266 rss_conf.rss_hf = 1ULL << atoi(res->value);
2268 fprintf(stderr, "Unknown parameter\n");
2271 rss_conf.rss_key = NULL;
2272 /* Update global configuration for RSS types. */
2273 RTE_ETH_FOREACH_DEV(i) {
2274 struct rte_eth_rss_conf local_rss_conf;
2276 ret = eth_dev_info_get_print_err(i, &dev_info);
2281 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2283 local_rss_conf = rss_conf;
2284 local_rss_conf.rss_hf = rss_conf.rss_hf &
2285 dev_info.flow_type_rss_offloads;
2286 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2287 printf("Port %u modified RSS hash function based on hardware support,"
2288 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2289 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2291 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2295 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2296 i, -diag, strerror(-diag));
2299 if (all_updated && !use_default) {
2300 rss_hf = rss_conf.rss_hf;
2301 printf("rss_hf %#"PRIx64"\n", rss_hf);
2305 cmdline_parse_token_string_t cmd_config_rss_port =
2306 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2307 cmdline_parse_token_string_t cmd_config_rss_keyword =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2309 cmdline_parse_token_string_t cmd_config_rss_all =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2311 cmdline_parse_token_string_t cmd_config_rss_name =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2313 cmdline_parse_token_string_t cmd_config_rss_value =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2316 cmdline_parse_inst_t cmd_config_rss = {
2317 .f = cmd_config_rss_parsed,
2319 .help_str = "port config all rss "
2320 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2321 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2322 "level-outer|level-inner|ipv4-chksum|<flowtype_id>",
2324 (void *)&cmd_config_rss_port,
2325 (void *)&cmd_config_rss_keyword,
2326 (void *)&cmd_config_rss_all,
2327 (void *)&cmd_config_rss_name,
2328 (void *)&cmd_config_rss_value,
2333 /* *** configure rss hash key *** */
2334 struct cmd_config_rss_hash_key {
2335 cmdline_fixed_string_t port;
2336 cmdline_fixed_string_t config;
2338 cmdline_fixed_string_t rss_hash_key;
2339 cmdline_fixed_string_t rss_type;
2340 cmdline_fixed_string_t key;
2344 hexa_digit_to_value(char hexa_digit)
2346 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2347 return (uint8_t) (hexa_digit - '0');
2348 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2349 return (uint8_t) ((hexa_digit - 'a') + 10);
2350 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2351 return (uint8_t) ((hexa_digit - 'A') + 10);
2352 /* Invalid hexa digit */
2357 parse_and_check_key_hexa_digit(char *key, int idx)
2361 hexa_v = hexa_digit_to_value(key[idx]);
2364 "invalid key: character %c at position %d is not a valid hexa digit\n",
2370 cmd_config_rss_hash_key_parsed(void *parsed_result,
2371 __rte_unused struct cmdline *cl,
2372 __rte_unused void *data)
2374 struct cmd_config_rss_hash_key *res = parsed_result;
2375 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2379 struct rte_eth_dev_info dev_info;
2380 uint8_t hash_key_size;
2384 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2388 if (dev_info.hash_key_size > 0 &&
2389 dev_info.hash_key_size <= sizeof(hash_key))
2390 hash_key_size = dev_info.hash_key_size;
2393 "dev_info did not provide a valid hash key size\n");
2396 /* Check the length of the RSS hash key */
2397 key_len = strlen(res->key);
2398 if (key_len != (hash_key_size * 2)) {
2400 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2401 (int)key_len, hash_key_size * 2);
2404 /* Translate RSS hash key into binary representation */
2405 for (i = 0; i < hash_key_size; i++) {
2406 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2409 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2412 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2414 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2418 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2420 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2421 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2423 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2424 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2426 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2427 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2428 rss_hash_key, "rss-hash-key");
2429 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2430 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2431 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2432 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2433 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2434 "ipv6-tcp-ex#ipv6-udp-ex#"
2435 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2436 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2437 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2438 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2439 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2441 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2442 .f = cmd_config_rss_hash_key_parsed,
2444 .help_str = "port config <port_id> rss-hash-key "
2445 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2446 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2447 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2448 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2449 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2450 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2451 "<string of hex digits (variable length, NIC dependent)>",
2453 (void *)&cmd_config_rss_hash_key_port,
2454 (void *)&cmd_config_rss_hash_key_config,
2455 (void *)&cmd_config_rss_hash_key_port_id,
2456 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2457 (void *)&cmd_config_rss_hash_key_rss_type,
2458 (void *)&cmd_config_rss_hash_key_value,
2463 /* *** cleanup txq mbufs *** */
2464 struct cmd_cleanup_txq_mbufs_result {
2465 cmdline_fixed_string_t port;
2466 cmdline_fixed_string_t keyword;
2467 cmdline_fixed_string_t name;
2474 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2475 __rte_unused struct cmdline *cl,
2476 __rte_unused void *data)
2478 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2479 uint16_t port_id = res->port_id;
2480 uint16_t queue_id = res->queue_id;
2481 uint32_t free_cnt = res->free_cnt;
2482 struct rte_eth_txq_info qinfo;
2485 if (test_done == 0) {
2486 fprintf(stderr, "Please stop forwarding first\n");
2490 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2491 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2496 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2497 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2501 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2504 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2505 port_id, queue_id, strerror(-ret), ret);
2509 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2510 port_id, queue_id, ret);
2513 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2514 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2516 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2517 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2519 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2520 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2522 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2523 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2525 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2526 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2528 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2529 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2532 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2533 .f = cmd_cleanup_txq_mbufs_parsed,
2535 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2537 (void *)&cmd_cleanup_txq_mbufs_port,
2538 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2539 (void *)&cmd_cleanup_txq_mbufs_port_id,
2540 (void *)&cmd_cleanup_txq_mbufs_txq,
2541 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2542 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2547 /* *** configure port rxq/txq ring size *** */
2548 struct cmd_config_rxtx_ring_size {
2549 cmdline_fixed_string_t port;
2550 cmdline_fixed_string_t config;
2552 cmdline_fixed_string_t rxtxq;
2554 cmdline_fixed_string_t rsize;
2559 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2560 __rte_unused struct cmdline *cl,
2561 __rte_unused void *data)
2563 struct cmd_config_rxtx_ring_size *res = parsed_result;
2564 struct rte_port *port;
2567 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2570 if (res->portid == (portid_t)RTE_PORT_ALL) {
2571 fprintf(stderr, "Invalid port id\n");
2575 port = &ports[res->portid];
2577 if (!strcmp(res->rxtxq, "rxq"))
2579 else if (!strcmp(res->rxtxq, "txq"))
2582 fprintf(stderr, "Unknown parameter\n");
2586 if (isrx && rx_queue_id_is_invalid(res->qid))
2588 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2591 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2593 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2599 port->nb_rx_desc[res->qid] = res->size;
2601 port->nb_tx_desc[res->qid] = res->size;
2603 cmd_reconfig_device_queue(res->portid, 0, 1);
2606 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2607 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2609 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2610 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2612 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2613 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2614 portid, RTE_UINT16);
2615 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2616 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2618 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2619 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2621 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2622 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2623 rsize, "ring_size");
2624 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2625 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2628 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2629 .f = cmd_config_rxtx_ring_size_parsed,
2631 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2633 (void *)&cmd_config_rxtx_ring_size_port,
2634 (void *)&cmd_config_rxtx_ring_size_config,
2635 (void *)&cmd_config_rxtx_ring_size_portid,
2636 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2637 (void *)&cmd_config_rxtx_ring_size_qid,
2638 (void *)&cmd_config_rxtx_ring_size_rsize,
2639 (void *)&cmd_config_rxtx_ring_size_size,
2644 /* *** configure port rxq/txq start/stop *** */
2645 struct cmd_config_rxtx_queue {
2646 cmdline_fixed_string_t port;
2648 cmdline_fixed_string_t rxtxq;
2650 cmdline_fixed_string_t opname;
2654 cmd_config_rxtx_queue_parsed(void *parsed_result,
2655 __rte_unused struct cmdline *cl,
2656 __rte_unused void *data)
2658 struct cmd_config_rxtx_queue *res = parsed_result;
2663 if (test_done == 0) {
2664 fprintf(stderr, "Please stop forwarding first\n");
2668 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2671 if (port_is_started(res->portid) != 1) {
2672 fprintf(stderr, "Please start port %u first\n", res->portid);
2676 if (!strcmp(res->rxtxq, "rxq"))
2678 else if (!strcmp(res->rxtxq, "txq"))
2681 fprintf(stderr, "Unknown parameter\n");
2685 if (isrx && rx_queue_id_is_invalid(res->qid))
2687 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2690 if (!strcmp(res->opname, "start"))
2692 else if (!strcmp(res->opname, "stop"))
2695 fprintf(stderr, "Unknown parameter\n");
2699 if (isstart && isrx)
2700 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2701 else if (!isstart && isrx)
2702 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2703 else if (isstart && !isrx)
2704 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2706 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2708 if (ret == -ENOTSUP)
2709 fprintf(stderr, "Function not supported in PMD\n");
2712 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2713 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2714 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2715 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2716 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2717 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2718 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2719 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2720 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2721 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2724 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2725 .f = cmd_config_rxtx_queue_parsed,
2727 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2729 (void *)&cmd_config_rxtx_queue_port,
2730 (void *)&cmd_config_rxtx_queue_portid,
2731 (void *)&cmd_config_rxtx_queue_rxtxq,
2732 (void *)&cmd_config_rxtx_queue_qid,
2733 (void *)&cmd_config_rxtx_queue_opname,
2738 /* *** configure port rxq/txq deferred start on/off *** */
2739 struct cmd_config_deferred_start_rxtx_queue {
2740 cmdline_fixed_string_t port;
2742 cmdline_fixed_string_t rxtxq;
2744 cmdline_fixed_string_t opname;
2745 cmdline_fixed_string_t state;
2749 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2750 __rte_unused struct cmdline *cl,
2751 __rte_unused void *data)
2753 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2754 struct rte_port *port;
2757 uint8_t needreconfig = 0;
2759 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2762 if (port_is_started(res->port_id) != 0) {
2763 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2767 port = &ports[res->port_id];
2769 isrx = !strcmp(res->rxtxq, "rxq");
2771 if (isrx && rx_queue_id_is_invalid(res->qid))
2773 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2776 ison = !strcmp(res->state, "on");
2778 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2779 port->rx_conf[res->qid].rx_deferred_start = ison;
2781 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2782 port->tx_conf[res->qid].tx_deferred_start = ison;
2787 cmd_reconfig_device_queue(res->port_id, 0, 1);
2790 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2791 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2793 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2794 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2795 port_id, RTE_UINT16);
2796 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2797 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2799 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2800 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2802 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2803 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2804 opname, "deferred_start");
2805 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2806 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2809 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2810 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2812 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2814 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2815 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2816 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2817 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2818 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2819 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2824 /* *** configure port rxq/txq setup *** */
2825 struct cmd_setup_rxtx_queue {
2826 cmdline_fixed_string_t port;
2828 cmdline_fixed_string_t rxtxq;
2830 cmdline_fixed_string_t setup;
2833 /* Common CLI fields for queue setup */
2834 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2835 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2836 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2837 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2838 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2839 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2840 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2841 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2842 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2843 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2846 cmd_setup_rxtx_queue_parsed(
2847 void *parsed_result,
2848 __rte_unused struct cmdline *cl,
2849 __rte_unused void *data)
2851 struct cmd_setup_rxtx_queue *res = parsed_result;
2852 struct rte_port *port;
2853 struct rte_mempool *mp;
2854 unsigned int socket_id;
2858 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2861 if (res->portid == (portid_t)RTE_PORT_ALL) {
2862 fprintf(stderr, "Invalid port id\n");
2866 if (!strcmp(res->rxtxq, "rxq"))
2868 else if (!strcmp(res->rxtxq, "txq"))
2871 fprintf(stderr, "Unknown parameter\n");
2875 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2876 fprintf(stderr, "Invalid rx queue\n");
2878 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2879 fprintf(stderr, "Invalid tx queue\n");
2883 port = &ports[res->portid];
2885 socket_id = rxring_numa[res->portid];
2886 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2887 socket_id = port->socket_id;
2889 mp = mbuf_pool_find(socket_id, 0);
2892 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2893 rxring_numa[res->portid]);
2896 ret = rx_queue_setup(res->portid,
2898 port->nb_rx_desc[res->qid],
2900 &port->rx_conf[res->qid],
2903 fprintf(stderr, "Failed to setup RX queue\n");
2905 socket_id = txring_numa[res->portid];
2906 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2907 socket_id = port->socket_id;
2909 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2911 "Failed to setup TX queue: not enough descriptors\n");
2914 ret = rte_eth_tx_queue_setup(res->portid,
2916 port->nb_tx_desc[res->qid],
2918 &port->tx_conf[res->qid]);
2920 fprintf(stderr, "Failed to setup TX queue\n");
2924 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2925 .f = cmd_setup_rxtx_queue_parsed,
2927 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2929 (void *)&cmd_setup_rxtx_queue_port,
2930 (void *)&cmd_setup_rxtx_queue_portid,
2931 (void *)&cmd_setup_rxtx_queue_rxtxq,
2932 (void *)&cmd_setup_rxtx_queue_qid,
2933 (void *)&cmd_setup_rxtx_queue_setup,
2939 /* *** Configure RSS RETA *** */
2940 struct cmd_config_rss_reta {
2941 cmdline_fixed_string_t port;
2942 cmdline_fixed_string_t keyword;
2944 cmdline_fixed_string_t name;
2945 cmdline_fixed_string_t list_name;
2946 cmdline_fixed_string_t list_of_items;
2950 parse_reta_config(const char *str,
2951 struct rte_eth_rss_reta_entry64 *reta_conf,
2952 uint16_t nb_entries)
2956 uint16_t hash_index, idx, shift;
2959 const char *p, *p0 = str;
2966 unsigned long int_fld[_NUM_FLD];
2967 char *str_fld[_NUM_FLD];
2969 while ((p = strchr(p0,'(')) != NULL) {
2971 if((p0 = strchr(p,')')) == NULL)
2975 if(size >= sizeof(s))
2978 snprintf(s, sizeof(s), "%.*s", size, p);
2979 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2981 for (i = 0; i < _NUM_FLD; i++) {
2983 int_fld[i] = strtoul(str_fld[i], &end, 0);
2984 if (errno != 0 || end == str_fld[i] ||
2989 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2990 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2992 if (hash_index >= nb_entries) {
2993 fprintf(stderr, "Invalid RETA hash index=%d\n",
2998 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
2999 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3000 reta_conf[idx].mask |= (1ULL << shift);
3001 reta_conf[idx].reta[shift] = nb_queue;
3008 cmd_set_rss_reta_parsed(void *parsed_result,
3009 __rte_unused struct cmdline *cl,
3010 __rte_unused void *data)
3013 struct rte_eth_dev_info dev_info;
3014 struct rte_eth_rss_reta_entry64 reta_conf[8];
3015 struct cmd_config_rss_reta *res = parsed_result;
3017 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3021 if (dev_info.reta_size == 0) {
3023 "Redirection table size is 0 which is invalid for RSS\n");
3026 printf("The reta size of port %d is %u\n",
3027 res->port_id, dev_info.reta_size);
3028 if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3030 "Currently do not support more than %u entries of redirection table\n",
3031 RTE_ETH_RSS_RETA_SIZE_512);
3035 memset(reta_conf, 0, sizeof(reta_conf));
3036 if (!strcmp(res->list_name, "reta")) {
3037 if (parse_reta_config(res->list_of_items, reta_conf,
3038 dev_info.reta_size)) {
3040 "Invalid RSS Redirection Table config entered\n");
3043 ret = rte_eth_dev_rss_reta_update(res->port_id,
3044 reta_conf, dev_info.reta_size);
3047 "Bad redirection table parameter, return code = %d\n",
3052 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3054 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3056 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3057 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3058 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3060 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3062 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3065 cmdline_parse_inst_t cmd_config_rss_reta = {
3066 .f = cmd_set_rss_reta_parsed,
3068 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3070 (void *)&cmd_config_rss_reta_port,
3071 (void *)&cmd_config_rss_reta_keyword,
3072 (void *)&cmd_config_rss_reta_port_id,
3073 (void *)&cmd_config_rss_reta_name,
3074 (void *)&cmd_config_rss_reta_list_name,
3075 (void *)&cmd_config_rss_reta_list_of_items,
3080 /* *** SHOW PORT RETA INFO *** */
3081 struct cmd_showport_reta {
3082 cmdline_fixed_string_t show;
3083 cmdline_fixed_string_t port;
3085 cmdline_fixed_string_t rss;
3086 cmdline_fixed_string_t reta;
3088 cmdline_fixed_string_t list_of_items;
3092 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3093 uint16_t nb_entries,
3097 const char *p, *p0 = str;
3102 uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3103 RTE_ETH_RETA_GROUP_SIZE;
3106 p = strchr(p0, '(');
3110 p0 = strchr(p, ')');
3114 if (size >= sizeof(s)) {
3116 "The string size exceeds the internal buffer size\n");
3119 snprintf(s, sizeof(s), "%.*s", size, p);
3120 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3121 if (ret <= 0 || ret != num) {
3123 "The bits of masks do not match the number of reta entries: %u\n",
3127 for (i = 0; i < ret; i++)
3128 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3134 cmd_showport_reta_parsed(void *parsed_result,
3135 __rte_unused struct cmdline *cl,
3136 __rte_unused void *data)
3138 struct cmd_showport_reta *res = parsed_result;
3139 struct rte_eth_rss_reta_entry64 reta_conf[8];
3140 struct rte_eth_dev_info dev_info;
3141 uint16_t max_reta_size;
3144 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3148 max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3149 if (res->size == 0 || res->size > max_reta_size) {
3150 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3151 res->size, max_reta_size);
3155 memset(reta_conf, 0, sizeof(reta_conf));
3156 if (showport_parse_reta_config(reta_conf, res->size,
3157 res->list_of_items) < 0) {
3158 fprintf(stderr, "Invalid string: %s for reta masks\n",
3159 res->list_of_items);
3162 port_rss_reta_info(res->port_id, reta_conf, res->size);
3165 cmdline_parse_token_string_t cmd_showport_reta_show =
3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3167 cmdline_parse_token_string_t cmd_showport_reta_port =
3168 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3169 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3170 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3171 cmdline_parse_token_string_t cmd_showport_reta_rss =
3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3173 cmdline_parse_token_string_t cmd_showport_reta_reta =
3174 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3175 cmdline_parse_token_num_t cmd_showport_reta_size =
3176 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3177 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3178 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3179 list_of_items, NULL);
3181 cmdline_parse_inst_t cmd_showport_reta = {
3182 .f = cmd_showport_reta_parsed,
3184 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3186 (void *)&cmd_showport_reta_show,
3187 (void *)&cmd_showport_reta_port,
3188 (void *)&cmd_showport_reta_port_id,
3189 (void *)&cmd_showport_reta_rss,
3190 (void *)&cmd_showport_reta_reta,
3191 (void *)&cmd_showport_reta_size,
3192 (void *)&cmd_showport_reta_list_of_items,
3197 /* *** Show RSS hash configuration *** */
3198 struct cmd_showport_rss_hash {
3199 cmdline_fixed_string_t show;
3200 cmdline_fixed_string_t port;
3202 cmdline_fixed_string_t rss_hash;
3203 cmdline_fixed_string_t rss_type;
3204 cmdline_fixed_string_t key; /* optional argument */
3207 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3208 __rte_unused struct cmdline *cl,
3211 struct cmd_showport_rss_hash *res = parsed_result;
3213 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3216 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3217 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3218 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3219 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3220 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3221 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3223 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3224 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3226 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3227 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3229 cmdline_parse_inst_t cmd_showport_rss_hash = {
3230 .f = cmd_showport_rss_hash_parsed,
3232 .help_str = "show port <port_id> rss-hash",
3234 (void *)&cmd_showport_rss_hash_show,
3235 (void *)&cmd_showport_rss_hash_port,
3236 (void *)&cmd_showport_rss_hash_port_id,
3237 (void *)&cmd_showport_rss_hash_rss_hash,
3242 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3243 .f = cmd_showport_rss_hash_parsed,
3245 .help_str = "show port <port_id> rss-hash key",
3247 (void *)&cmd_showport_rss_hash_show,
3248 (void *)&cmd_showport_rss_hash_port,
3249 (void *)&cmd_showport_rss_hash_port_id,
3250 (void *)&cmd_showport_rss_hash_rss_hash,
3251 (void *)&cmd_showport_rss_hash_rss_key,
3256 /* *** Configure DCB *** */
3257 struct cmd_config_dcb {
3258 cmdline_fixed_string_t port;
3259 cmdline_fixed_string_t config;
3261 cmdline_fixed_string_t dcb;
3262 cmdline_fixed_string_t vt;
3263 cmdline_fixed_string_t vt_en;
3265 cmdline_fixed_string_t pfc;
3266 cmdline_fixed_string_t pfc_en;
3270 cmd_config_dcb_parsed(void *parsed_result,
3271 __rte_unused struct cmdline *cl,
3272 __rte_unused void *data)
3274 struct cmd_config_dcb *res = parsed_result;
3275 struct rte_eth_dcb_info dcb_info;
3276 portid_t port_id = res->port_id;
3277 struct rte_port *port;
3281 port = &ports[port_id];
3282 /** Check if the port is not started **/
3283 if (port->port_status != RTE_PORT_STOPPED) {
3284 fprintf(stderr, "Please stop port %d first\n", port_id);
3288 if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3290 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3294 if (nb_fwd_lcores < res->num_tcs) {
3296 "nb_cores shouldn't be less than number of TCs.\n");
3300 /* Check whether the port supports the report of DCB info. */
3301 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3302 if (ret == -ENOTSUP) {
3303 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3307 if (!strncmp(res->pfc_en, "on", 2))
3312 /* DCB in VT mode */
3313 if (!strncmp(res->vt_en, "on", 2))
3314 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3315 (enum rte_eth_nb_tcs)res->num_tcs,
3318 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3319 (enum rte_eth_nb_tcs)res->num_tcs,
3322 fprintf(stderr, "Cannot initialize network ports.\n");
3328 cmd_reconfig_device_queue(port_id, 1, 1);
3331 cmdline_parse_token_string_t cmd_config_dcb_port =
3332 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3333 cmdline_parse_token_string_t cmd_config_dcb_config =
3334 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3335 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3336 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3337 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3338 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3339 cmdline_parse_token_string_t cmd_config_dcb_vt =
3340 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3341 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3342 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3343 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3344 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3345 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3346 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3347 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3348 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3350 cmdline_parse_inst_t cmd_config_dcb = {
3351 .f = cmd_config_dcb_parsed,
3353 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3355 (void *)&cmd_config_dcb_port,
3356 (void *)&cmd_config_dcb_config,
3357 (void *)&cmd_config_dcb_port_id,
3358 (void *)&cmd_config_dcb_dcb,
3359 (void *)&cmd_config_dcb_vt,
3360 (void *)&cmd_config_dcb_vt_en,
3361 (void *)&cmd_config_dcb_num_tcs,
3362 (void *)&cmd_config_dcb_pfc,
3363 (void *)&cmd_config_dcb_pfc_en,
3368 /* *** configure number of packets per burst *** */
3369 struct cmd_config_burst {
3370 cmdline_fixed_string_t port;
3371 cmdline_fixed_string_t keyword;
3372 cmdline_fixed_string_t all;
3373 cmdline_fixed_string_t name;
3378 cmd_config_burst_parsed(void *parsed_result,
3379 __rte_unused struct cmdline *cl,
3380 __rte_unused void *data)
3382 struct cmd_config_burst *res = parsed_result;
3383 struct rte_eth_dev_info dev_info;
3384 uint16_t rec_nb_pkts;
3387 if (!all_ports_stopped()) {
3388 fprintf(stderr, "Please stop all ports first\n");
3392 if (!strcmp(res->name, "burst")) {
3393 if (res->value == 0) {
3394 /* If user gives a value of zero, query the PMD for
3395 * its recommended Rx burst size. Testpmd uses a single
3396 * size for all ports, so assume all ports are the same
3397 * NIC model and use the values from Port 0.
3399 ret = eth_dev_info_get_print_err(0, &dev_info);
3403 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3405 if (rec_nb_pkts == 0) {
3406 printf("PMD does not recommend a burst size.\n"
3407 "User provided value must be between"
3408 " 1 and %d\n", MAX_PKT_BURST);
3410 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3411 printf("PMD recommended burst size of %d"
3412 " exceeds maximum value of %d\n",
3413 rec_nb_pkts, MAX_PKT_BURST);
3416 printf("Using PMD-provided burst value of %d\n",
3418 nb_pkt_per_burst = rec_nb_pkts;
3419 } else if (res->value > MAX_PKT_BURST) {
3420 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3424 nb_pkt_per_burst = res->value;
3426 fprintf(stderr, "Unknown parameter\n");
3432 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3435 cmdline_parse_token_string_t cmd_config_burst_port =
3436 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3437 cmdline_parse_token_string_t cmd_config_burst_keyword =
3438 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3439 cmdline_parse_token_string_t cmd_config_burst_all =
3440 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3441 cmdline_parse_token_string_t cmd_config_burst_name =
3442 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3443 cmdline_parse_token_num_t cmd_config_burst_value =
3444 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3446 cmdline_parse_inst_t cmd_config_burst = {
3447 .f = cmd_config_burst_parsed,
3449 .help_str = "port config all burst <value>",
3451 (void *)&cmd_config_burst_port,
3452 (void *)&cmd_config_burst_keyword,
3453 (void *)&cmd_config_burst_all,
3454 (void *)&cmd_config_burst_name,
3455 (void *)&cmd_config_burst_value,
3460 /* *** configure rx/tx queues *** */
3461 struct cmd_config_thresh {
3462 cmdline_fixed_string_t port;
3463 cmdline_fixed_string_t keyword;
3464 cmdline_fixed_string_t all;
3465 cmdline_fixed_string_t name;
3470 cmd_config_thresh_parsed(void *parsed_result,
3471 __rte_unused struct cmdline *cl,
3472 __rte_unused void *data)
3474 struct cmd_config_thresh *res = parsed_result;
3476 if (!all_ports_stopped()) {
3477 fprintf(stderr, "Please stop all ports first\n");
3481 if (!strcmp(res->name, "txpt"))
3482 tx_pthresh = res->value;
3483 else if(!strcmp(res->name, "txht"))
3484 tx_hthresh = res->value;
3485 else if(!strcmp(res->name, "txwt"))
3486 tx_wthresh = res->value;
3487 else if(!strcmp(res->name, "rxpt"))
3488 rx_pthresh = res->value;
3489 else if(!strcmp(res->name, "rxht"))
3490 rx_hthresh = res->value;
3491 else if(!strcmp(res->name, "rxwt"))
3492 rx_wthresh = res->value;
3494 fprintf(stderr, "Unknown parameter\n");
3500 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3503 cmdline_parse_token_string_t cmd_config_thresh_port =
3504 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3505 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3506 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3507 cmdline_parse_token_string_t cmd_config_thresh_all =
3508 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3509 cmdline_parse_token_string_t cmd_config_thresh_name =
3510 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3511 "txpt#txht#txwt#rxpt#rxht#rxwt");
3512 cmdline_parse_token_num_t cmd_config_thresh_value =
3513 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3515 cmdline_parse_inst_t cmd_config_thresh = {
3516 .f = cmd_config_thresh_parsed,
3518 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3520 (void *)&cmd_config_thresh_port,
3521 (void *)&cmd_config_thresh_keyword,
3522 (void *)&cmd_config_thresh_all,
3523 (void *)&cmd_config_thresh_name,
3524 (void *)&cmd_config_thresh_value,
3529 /* *** configure free/rs threshold *** */
3530 struct cmd_config_threshold {
3531 cmdline_fixed_string_t port;
3532 cmdline_fixed_string_t keyword;
3533 cmdline_fixed_string_t all;
3534 cmdline_fixed_string_t name;
3539 cmd_config_threshold_parsed(void *parsed_result,
3540 __rte_unused struct cmdline *cl,
3541 __rte_unused void *data)
3543 struct cmd_config_threshold *res = parsed_result;
3545 if (!all_ports_stopped()) {
3546 fprintf(stderr, "Please stop all ports first\n");
3550 if (!strcmp(res->name, "txfreet"))
3551 tx_free_thresh = res->value;
3552 else if (!strcmp(res->name, "txrst"))
3553 tx_rs_thresh = res->value;
3554 else if (!strcmp(res->name, "rxfreet"))
3555 rx_free_thresh = res->value;
3557 fprintf(stderr, "Unknown parameter\n");
3563 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3566 cmdline_parse_token_string_t cmd_config_threshold_port =
3567 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3568 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3569 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3571 cmdline_parse_token_string_t cmd_config_threshold_all =
3572 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3573 cmdline_parse_token_string_t cmd_config_threshold_name =
3574 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3575 "txfreet#txrst#rxfreet");
3576 cmdline_parse_token_num_t cmd_config_threshold_value =
3577 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3579 cmdline_parse_inst_t cmd_config_threshold = {
3580 .f = cmd_config_threshold_parsed,
3582 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3584 (void *)&cmd_config_threshold_port,
3585 (void *)&cmd_config_threshold_keyword,
3586 (void *)&cmd_config_threshold_all,
3587 (void *)&cmd_config_threshold_name,
3588 (void *)&cmd_config_threshold_value,
3594 struct cmd_stop_result {
3595 cmdline_fixed_string_t stop;
3598 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3599 __rte_unused struct cmdline *cl,
3600 __rte_unused void *data)
3602 stop_packet_forwarding();
3605 cmdline_parse_token_string_t cmd_stop_stop =
3606 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3608 cmdline_parse_inst_t cmd_stop = {
3609 .f = cmd_stop_parsed,
3611 .help_str = "stop: Stop packet forwarding",
3613 (void *)&cmd_stop_stop,
3618 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3621 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3622 unsigned int *parsed_items, int check_unique_values)
3624 unsigned int nb_item;
3632 * First parse all items in the list and store their value.
3637 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3639 if ((c >= '0') && (c <= '9')) {
3640 value = (unsigned int) (value * 10 + (c - '0'));
3645 fprintf(stderr, "character %c is not a decimal digit\n", c);
3649 fprintf(stderr, "No valid value before comma\n");
3652 if (nb_item < max_items) {
3653 parsed_items[nb_item] = value;
3659 if (nb_item >= max_items) {
3660 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3661 item_name, nb_item + 1, max_items);
3664 parsed_items[nb_item++] = value;
3665 if (! check_unique_values)
3669 * Then, check that all values in the list are different.
3670 * No optimization here...
3672 for (i = 0; i < nb_item; i++) {
3673 for (j = i + 1; j < nb_item; j++) {
3674 if (parsed_items[j] == parsed_items[i]) {
3676 "duplicated %s %u at index %u and %u\n",
3677 item_name, parsed_items[i], i, j);
3685 struct cmd_set_list_result {
3686 cmdline_fixed_string_t cmd_keyword;
3687 cmdline_fixed_string_t list_name;
3688 cmdline_fixed_string_t list_of_items;
3691 static void cmd_set_list_parsed(void *parsed_result,
3692 __rte_unused struct cmdline *cl,
3693 __rte_unused void *data)
3695 struct cmd_set_list_result *res;
3697 unsigned int lcorelist[RTE_MAX_LCORE];
3698 unsigned int portlist[RTE_MAX_ETHPORTS];
3700 unsigned int nb_item;
3702 if (test_done == 0) {
3703 fprintf(stderr, "Please stop forwarding first\n");
3707 res = parsed_result;
3708 if (!strcmp(res->list_name, "corelist")) {
3709 nb_item = parse_item_list(res->list_of_items, "core",
3711 parsed_items.lcorelist, 1);
3713 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3718 if (!strcmp(res->list_name, "portlist")) {
3719 nb_item = parse_item_list(res->list_of_items, "port",
3721 parsed_items.portlist, 1);
3723 set_fwd_ports_list(parsed_items.portlist, nb_item);
3729 cmdline_parse_token_string_t cmd_set_list_keyword =
3730 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3732 cmdline_parse_token_string_t cmd_set_list_name =
3733 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3734 "corelist#portlist");
3735 cmdline_parse_token_string_t cmd_set_list_of_items =
3736 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3739 cmdline_parse_inst_t cmd_set_fwd_list = {
3740 .f = cmd_set_list_parsed,
3742 .help_str = "set corelist|portlist <list0[,list1]*>",
3744 (void *)&cmd_set_list_keyword,
3745 (void *)&cmd_set_list_name,
3746 (void *)&cmd_set_list_of_items,
3751 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3753 struct cmd_setmask_result {
3754 cmdline_fixed_string_t set;
3755 cmdline_fixed_string_t mask;
3759 static void cmd_set_mask_parsed(void *parsed_result,
3760 __rte_unused struct cmdline *cl,
3761 __rte_unused void *data)
3763 struct cmd_setmask_result *res = parsed_result;
3765 if (test_done == 0) {
3766 fprintf(stderr, "Please stop forwarding first\n");
3769 if (!strcmp(res->mask, "coremask")) {
3770 set_fwd_lcores_mask(res->hexavalue);
3772 } else if (!strcmp(res->mask, "portmask")) {
3773 set_fwd_ports_mask(res->hexavalue);
3778 cmdline_parse_token_string_t cmd_setmask_set =
3779 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3780 cmdline_parse_token_string_t cmd_setmask_mask =
3781 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3782 "coremask#portmask");
3783 cmdline_parse_token_num_t cmd_setmask_value =
3784 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3786 cmdline_parse_inst_t cmd_set_fwd_mask = {
3787 .f = cmd_set_mask_parsed,
3789 .help_str = "set coremask|portmask <hexadecimal value>",
3791 (void *)&cmd_setmask_set,
3792 (void *)&cmd_setmask_mask,
3793 (void *)&cmd_setmask_value,
3799 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3801 struct cmd_set_result {
3802 cmdline_fixed_string_t set;
3803 cmdline_fixed_string_t what;
3807 static void cmd_set_parsed(void *parsed_result,
3808 __rte_unused struct cmdline *cl,
3809 __rte_unused void *data)
3811 struct cmd_set_result *res = parsed_result;
3812 if (!strcmp(res->what, "nbport")) {
3813 set_fwd_ports_number(res->value);
3815 } else if (!strcmp(res->what, "nbcore")) {
3816 set_fwd_lcores_number(res->value);
3818 } else if (!strcmp(res->what, "burst"))
3819 set_nb_pkt_per_burst(res->value);
3820 else if (!strcmp(res->what, "verbose"))
3821 set_verbose_level(res->value);
3824 cmdline_parse_token_string_t cmd_set_set =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3826 cmdline_parse_token_string_t cmd_set_what =
3827 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3828 "nbport#nbcore#burst#verbose");
3829 cmdline_parse_token_num_t cmd_set_value =
3830 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3832 cmdline_parse_inst_t cmd_set_numbers = {
3833 .f = cmd_set_parsed,
3835 .help_str = "set nbport|nbcore|burst|verbose <value>",
3837 (void *)&cmd_set_set,
3838 (void *)&cmd_set_what,
3839 (void *)&cmd_set_value,
3844 /* *** SET LOG LEVEL CONFIGURATION *** */
3846 struct cmd_set_log_result {
3847 cmdline_fixed_string_t set;
3848 cmdline_fixed_string_t log;
3849 cmdline_fixed_string_t type;
3854 cmd_set_log_parsed(void *parsed_result,
3855 __rte_unused struct cmdline *cl,
3856 __rte_unused void *data)
3858 struct cmd_set_log_result *res;
3861 res = parsed_result;
3862 if (!strcmp(res->type, "global"))
3863 rte_log_set_global_level(res->level);
3865 ret = rte_log_set_level_regexp(res->type, res->level);
3867 fprintf(stderr, "Unable to set log level\n");
3871 cmdline_parse_token_string_t cmd_set_log_set =
3872 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3873 cmdline_parse_token_string_t cmd_set_log_log =
3874 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3875 cmdline_parse_token_string_t cmd_set_log_type =
3876 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3877 cmdline_parse_token_num_t cmd_set_log_level =
3878 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3880 cmdline_parse_inst_t cmd_set_log = {
3881 .f = cmd_set_log_parsed,
3883 .help_str = "set log global|<type> <level>",
3885 (void *)&cmd_set_log_set,
3886 (void *)&cmd_set_log_log,
3887 (void *)&cmd_set_log_type,
3888 (void *)&cmd_set_log_level,
3893 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3895 struct cmd_set_rxoffs_result {
3896 cmdline_fixed_string_t cmd_keyword;
3897 cmdline_fixed_string_t rxoffs;
3898 cmdline_fixed_string_t seg_offsets;
3902 cmd_set_rxoffs_parsed(void *parsed_result,
3903 __rte_unused struct cmdline *cl,
3904 __rte_unused void *data)
3906 struct cmd_set_rxoffs_result *res;
3907 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3908 unsigned int nb_segs;
3910 res = parsed_result;
3911 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3912 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3914 set_rx_pkt_offsets(seg_offsets, nb_segs);
3915 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3918 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3919 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3920 cmd_keyword, "set");
3921 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3922 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3924 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3925 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3928 cmdline_parse_inst_t cmd_set_rxoffs = {
3929 .f = cmd_set_rxoffs_parsed,
3931 .help_str = "set rxoffs <len0[,len1]*>",
3933 (void *)&cmd_set_rxoffs_keyword,
3934 (void *)&cmd_set_rxoffs_name,
3935 (void *)&cmd_set_rxoffs_offsets,
3940 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3942 struct cmd_set_rxpkts_result {
3943 cmdline_fixed_string_t cmd_keyword;
3944 cmdline_fixed_string_t rxpkts;
3945 cmdline_fixed_string_t seg_lengths;
3949 cmd_set_rxpkts_parsed(void *parsed_result,
3950 __rte_unused struct cmdline *cl,
3951 __rte_unused void *data)
3953 struct cmd_set_rxpkts_result *res;
3954 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3955 unsigned int nb_segs;
3957 res = parsed_result;
3958 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3959 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3961 set_rx_pkt_segments(seg_lengths, nb_segs);
3962 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3965 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3966 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3967 cmd_keyword, "set");
3968 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3969 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3971 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3975 cmdline_parse_inst_t cmd_set_rxpkts = {
3976 .f = cmd_set_rxpkts_parsed,
3978 .help_str = "set rxpkts <len0[,len1]*>",
3980 (void *)&cmd_set_rxpkts_keyword,
3981 (void *)&cmd_set_rxpkts_name,
3982 (void *)&cmd_set_rxpkts_lengths,
3987 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3989 struct cmd_set_txpkts_result {
3990 cmdline_fixed_string_t cmd_keyword;
3991 cmdline_fixed_string_t txpkts;
3992 cmdline_fixed_string_t seg_lengths;
3996 cmd_set_txpkts_parsed(void *parsed_result,
3997 __rte_unused struct cmdline *cl,
3998 __rte_unused void *data)
4000 struct cmd_set_txpkts_result *res;
4001 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4002 unsigned int nb_segs;
4004 res = parsed_result;
4005 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4006 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4008 set_tx_pkt_segments(seg_lengths, nb_segs);
4011 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4012 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4013 cmd_keyword, "set");
4014 cmdline_parse_token_string_t cmd_set_txpkts_name =
4015 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4017 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4018 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4021 cmdline_parse_inst_t cmd_set_txpkts = {
4022 .f = cmd_set_txpkts_parsed,
4024 .help_str = "set txpkts <len0[,len1]*>",
4026 (void *)&cmd_set_txpkts_keyword,
4027 (void *)&cmd_set_txpkts_name,
4028 (void *)&cmd_set_txpkts_lengths,
4033 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4035 struct cmd_set_txsplit_result {
4036 cmdline_fixed_string_t cmd_keyword;
4037 cmdline_fixed_string_t txsplit;
4038 cmdline_fixed_string_t mode;
4042 cmd_set_txsplit_parsed(void *parsed_result,
4043 __rte_unused struct cmdline *cl,
4044 __rte_unused void *data)
4046 struct cmd_set_txsplit_result *res;
4048 res = parsed_result;
4049 set_tx_pkt_split(res->mode);
4052 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4053 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4054 cmd_keyword, "set");
4055 cmdline_parse_token_string_t cmd_set_txsplit_name =
4056 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4057 txsplit, "txsplit");
4058 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4059 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4062 cmdline_parse_inst_t cmd_set_txsplit = {
4063 .f = cmd_set_txsplit_parsed,
4065 .help_str = "set txsplit on|off|rand",
4067 (void *)&cmd_set_txsplit_keyword,
4068 (void *)&cmd_set_txsplit_name,
4069 (void *)&cmd_set_txsplit_mode,
4074 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4076 struct cmd_set_txtimes_result {
4077 cmdline_fixed_string_t cmd_keyword;
4078 cmdline_fixed_string_t txtimes;
4079 cmdline_fixed_string_t tx_times;
4083 cmd_set_txtimes_parsed(void *parsed_result,
4084 __rte_unused struct cmdline *cl,
4085 __rte_unused void *data)
4087 struct cmd_set_txtimes_result *res;
4088 unsigned int tx_times[2] = {0, 0};
4089 unsigned int n_times;
4091 res = parsed_result;
4092 n_times = parse_item_list(res->tx_times, "tx times",
4095 set_tx_pkt_times(tx_times);
4098 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4099 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4100 cmd_keyword, "set");
4101 cmdline_parse_token_string_t cmd_set_txtimes_name =
4102 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4103 txtimes, "txtimes");
4104 cmdline_parse_token_string_t cmd_set_txtimes_value =
4105 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4108 cmdline_parse_inst_t cmd_set_txtimes = {
4109 .f = cmd_set_txtimes_parsed,
4111 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4113 (void *)&cmd_set_txtimes_keyword,
4114 (void *)&cmd_set_txtimes_name,
4115 (void *)&cmd_set_txtimes_value,
4120 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4121 struct cmd_rx_vlan_filter_all_result {
4122 cmdline_fixed_string_t rx_vlan;
4123 cmdline_fixed_string_t what;
4124 cmdline_fixed_string_t all;
4129 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4130 __rte_unused struct cmdline *cl,
4131 __rte_unused void *data)
4133 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4135 if (!strcmp(res->what, "add"))
4136 rx_vlan_all_filter_set(res->port_id, 1);
4138 rx_vlan_all_filter_set(res->port_id, 0);
4141 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4142 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4143 rx_vlan, "rx_vlan");
4144 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4145 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4147 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4148 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4150 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4151 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4152 port_id, RTE_UINT16);
4154 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4155 .f = cmd_rx_vlan_filter_all_parsed,
4157 .help_str = "rx_vlan add|rm all <port_id>: "
4158 "Add/Remove all identifiers to/from the set of VLAN "
4159 "identifiers filtered by a port",
4161 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4162 (void *)&cmd_rx_vlan_filter_all_what,
4163 (void *)&cmd_rx_vlan_filter_all_all,
4164 (void *)&cmd_rx_vlan_filter_all_portid,
4169 /* *** VLAN OFFLOAD SET ON A PORT *** */
4170 struct cmd_vlan_offload_result {
4171 cmdline_fixed_string_t vlan;
4172 cmdline_fixed_string_t set;
4173 cmdline_fixed_string_t vlan_type;
4174 cmdline_fixed_string_t what;
4175 cmdline_fixed_string_t on;
4176 cmdline_fixed_string_t port_id;
4180 cmd_vlan_offload_parsed(void *parsed_result,
4181 __rte_unused struct cmdline *cl,
4182 __rte_unused void *data)
4185 struct cmd_vlan_offload_result *res = parsed_result;
4188 portid_t port_id = 0;
4192 len = strnlen(str, STR_TOKEN_SIZE);
4194 /* Get port_id first */
4202 tmp = strtoul(str, NULL, 0);
4203 /* If port_id greater that what portid_t can represent, return */
4204 if(tmp >= RTE_MAX_ETHPORTS)
4206 port_id = (portid_t)tmp;
4208 if (!strcmp(res->on, "on"))
4213 if (!strcmp(res->what, "strip"))
4214 rx_vlan_strip_set(port_id, on);
4215 else if(!strcmp(res->what, "stripq")){
4216 uint16_t queue_id = 0;
4218 /* No queue_id, return */
4220 fprintf(stderr, "must specify (port,queue_id)\n");
4223 tmp = strtoul(str + i + 1, NULL, 0);
4224 /* If queue_id greater that what 16-bits can represent, return */
4228 queue_id = (uint16_t)tmp;
4229 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4231 else if (!strcmp(res->what, "filter"))
4232 rx_vlan_filter_set(port_id, on);
4233 else if (!strcmp(res->what, "qinq_strip"))
4234 rx_vlan_qinq_strip_set(port_id, on);
4236 vlan_extend_set(port_id, on);
4241 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4242 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4244 cmdline_parse_token_string_t cmd_vlan_offload_set =
4245 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4247 cmdline_parse_token_string_t cmd_vlan_offload_what =
4248 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4249 what, "strip#filter#qinq_strip#extend#stripq");
4250 cmdline_parse_token_string_t cmd_vlan_offload_on =
4251 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4253 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4254 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4257 cmdline_parse_inst_t cmd_vlan_offload = {
4258 .f = cmd_vlan_offload_parsed,
4260 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4261 "<port_id[,queue_id]>: "
4262 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4264 (void *)&cmd_vlan_offload_vlan,
4265 (void *)&cmd_vlan_offload_set,
4266 (void *)&cmd_vlan_offload_what,
4267 (void *)&cmd_vlan_offload_on,
4268 (void *)&cmd_vlan_offload_portid,
4273 /* *** VLAN TPID SET ON A PORT *** */
4274 struct cmd_vlan_tpid_result {
4275 cmdline_fixed_string_t vlan;
4276 cmdline_fixed_string_t set;
4277 cmdline_fixed_string_t vlan_type;
4278 cmdline_fixed_string_t what;
4284 cmd_vlan_tpid_parsed(void *parsed_result,
4285 __rte_unused struct cmdline *cl,
4286 __rte_unused void *data)
4288 struct cmd_vlan_tpid_result *res = parsed_result;
4289 enum rte_vlan_type vlan_type;
4291 if (!strcmp(res->vlan_type, "inner"))
4292 vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4293 else if (!strcmp(res->vlan_type, "outer"))
4294 vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4296 fprintf(stderr, "Unknown vlan type\n");
4299 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4302 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4303 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4305 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4306 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4308 cmdline_parse_token_string_t cmd_vlan_type =
4309 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4310 vlan_type, "inner#outer");
4311 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4312 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4314 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4315 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4317 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4318 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4319 port_id, RTE_UINT16);
4321 cmdline_parse_inst_t cmd_vlan_tpid = {
4322 .f = cmd_vlan_tpid_parsed,
4324 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4325 "Set the VLAN Ether type",
4327 (void *)&cmd_vlan_tpid_vlan,
4328 (void *)&cmd_vlan_tpid_set,
4329 (void *)&cmd_vlan_type,
4330 (void *)&cmd_vlan_tpid_what,
4331 (void *)&cmd_vlan_tpid_tpid,
4332 (void *)&cmd_vlan_tpid_portid,
4337 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4338 struct cmd_rx_vlan_filter_result {
4339 cmdline_fixed_string_t rx_vlan;
4340 cmdline_fixed_string_t what;
4346 cmd_rx_vlan_filter_parsed(void *parsed_result,
4347 __rte_unused struct cmdline *cl,
4348 __rte_unused void *data)
4350 struct cmd_rx_vlan_filter_result *res = parsed_result;
4352 if (!strcmp(res->what, "add"))
4353 rx_vft_set(res->port_id, res->vlan_id, 1);
4355 rx_vft_set(res->port_id, res->vlan_id, 0);
4358 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4359 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4360 rx_vlan, "rx_vlan");
4361 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4362 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4364 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4365 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4366 vlan_id, RTE_UINT16);
4367 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4368 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4369 port_id, RTE_UINT16);
4371 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4372 .f = cmd_rx_vlan_filter_parsed,
4374 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4375 "Add/Remove a VLAN identifier to/from the set of VLAN "
4376 "identifiers filtered by a port",
4378 (void *)&cmd_rx_vlan_filter_rx_vlan,
4379 (void *)&cmd_rx_vlan_filter_what,
4380 (void *)&cmd_rx_vlan_filter_vlanid,
4381 (void *)&cmd_rx_vlan_filter_portid,
4386 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4387 struct cmd_tx_vlan_set_result {
4388 cmdline_fixed_string_t tx_vlan;
4389 cmdline_fixed_string_t set;
4395 cmd_tx_vlan_set_parsed(void *parsed_result,
4396 __rte_unused struct cmdline *cl,
4397 __rte_unused void *data)
4399 struct cmd_tx_vlan_set_result *res = parsed_result;
4401 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4404 if (!port_is_stopped(res->port_id)) {
4405 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4409 tx_vlan_set(res->port_id, res->vlan_id);
4411 cmd_reconfig_device_queue(res->port_id, 1, 1);
4414 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4415 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4416 tx_vlan, "tx_vlan");
4417 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4418 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4420 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4421 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4422 port_id, RTE_UINT16);
4423 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4424 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4425 vlan_id, RTE_UINT16);
4427 cmdline_parse_inst_t cmd_tx_vlan_set = {
4428 .f = cmd_tx_vlan_set_parsed,
4430 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4431 "Enable hardware insertion of a single VLAN header "
4432 "with a given TAG Identifier in packets sent on a port",
4434 (void *)&cmd_tx_vlan_set_tx_vlan,
4435 (void *)&cmd_tx_vlan_set_set,
4436 (void *)&cmd_tx_vlan_set_portid,
4437 (void *)&cmd_tx_vlan_set_vlanid,
4442 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4443 struct cmd_tx_vlan_set_qinq_result {
4444 cmdline_fixed_string_t tx_vlan;
4445 cmdline_fixed_string_t set;
4448 uint16_t vlan_id_outer;
4452 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4453 __rte_unused struct cmdline *cl,
4454 __rte_unused void *data)
4456 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4458 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4461 if (!port_is_stopped(res->port_id)) {
4462 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4466 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4468 cmd_reconfig_device_queue(res->port_id, 1, 1);
4471 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4472 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4473 tx_vlan, "tx_vlan");
4474 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4475 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4477 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4478 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4479 port_id, RTE_UINT16);
4480 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4481 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4482 vlan_id, RTE_UINT16);
4483 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4484 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4485 vlan_id_outer, RTE_UINT16);
4487 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4488 .f = cmd_tx_vlan_set_qinq_parsed,
4490 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4491 "Enable hardware insertion of double VLAN header "
4492 "with given TAG Identifiers in packets sent on a port",
4494 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4495 (void *)&cmd_tx_vlan_set_qinq_set,
4496 (void *)&cmd_tx_vlan_set_qinq_portid,
4497 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4498 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4503 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4504 struct cmd_tx_vlan_set_pvid_result {
4505 cmdline_fixed_string_t tx_vlan;
4506 cmdline_fixed_string_t set;
4507 cmdline_fixed_string_t pvid;
4510 cmdline_fixed_string_t mode;
4514 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4515 __rte_unused struct cmdline *cl,
4516 __rte_unused void *data)
4518 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4520 if (strcmp(res->mode, "on") == 0)
4521 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4523 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4526 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4527 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4528 tx_vlan, "tx_vlan");
4529 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4530 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4532 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4533 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4535 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4536 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4537 port_id, RTE_UINT16);
4538 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4539 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4540 vlan_id, RTE_UINT16);
4541 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4542 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4545 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4546 .f = cmd_tx_vlan_set_pvid_parsed,
4548 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4550 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4551 (void *)&cmd_tx_vlan_set_pvid_set,
4552 (void *)&cmd_tx_vlan_set_pvid_pvid,
4553 (void *)&cmd_tx_vlan_set_pvid_port_id,
4554 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4555 (void *)&cmd_tx_vlan_set_pvid_mode,
4560 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4561 struct cmd_tx_vlan_reset_result {
4562 cmdline_fixed_string_t tx_vlan;
4563 cmdline_fixed_string_t reset;
4568 cmd_tx_vlan_reset_parsed(void *parsed_result,
4569 __rte_unused struct cmdline *cl,
4570 __rte_unused void *data)
4572 struct cmd_tx_vlan_reset_result *res = parsed_result;
4574 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4577 if (!port_is_stopped(res->port_id)) {
4578 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4582 tx_vlan_reset(res->port_id);
4584 cmd_reconfig_device_queue(res->port_id, 1, 1);
4587 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4588 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4589 tx_vlan, "tx_vlan");
4590 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4591 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4593 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4594 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4595 port_id, RTE_UINT16);
4597 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4598 .f = cmd_tx_vlan_reset_parsed,
4600 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4601 "VLAN header in packets sent on a port",
4603 (void *)&cmd_tx_vlan_reset_tx_vlan,
4604 (void *)&cmd_tx_vlan_reset_reset,
4605 (void *)&cmd_tx_vlan_reset_portid,
4611 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4612 struct cmd_csum_result {
4613 cmdline_fixed_string_t csum;
4614 cmdline_fixed_string_t mode;
4615 cmdline_fixed_string_t proto;
4616 cmdline_fixed_string_t hwsw;
4621 csum_show(int port_id)
4623 struct rte_eth_dev_info dev_info;
4624 uint64_t tx_offloads;
4627 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4628 printf("Parse tunnel is %s\n",
4629 (ports[port_id].parse_tunnel) ? "on" : "off");
4630 printf("IP checksum offload is %s\n",
4631 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4632 printf("UDP checksum offload is %s\n",
4633 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4634 printf("TCP checksum offload is %s\n",
4635 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4636 printf("SCTP checksum offload is %s\n",
4637 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4638 printf("Outer-Ip checksum offload is %s\n",
4639 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4640 printf("Outer-Udp checksum offload is %s\n",
4641 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4643 /* display warnings if configuration is not supported by the NIC */
4644 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4648 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4649 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4651 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4654 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4655 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4657 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4660 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4661 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4663 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4666 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4667 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4669 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4672 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4673 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4675 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4678 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4679 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4682 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4688 cmd_config_queue_tx_offloads(struct rte_port *port)
4692 /* Apply queue tx offloads configuration */
4693 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4694 port->tx_conf[k].offloads =
4695 port->dev_conf.txmode.offloads;
4699 cmd_csum_parsed(void *parsed_result,
4700 __rte_unused struct cmdline *cl,
4701 __rte_unused void *data)
4703 struct cmd_csum_result *res = parsed_result;
4705 uint64_t csum_offloads = 0;
4706 struct rte_eth_dev_info dev_info;
4709 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4710 fprintf(stderr, "invalid port %d\n", res->port_id);
4713 if (!port_is_stopped(res->port_id)) {
4714 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4718 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4722 if (!strcmp(res->mode, "set")) {
4724 if (!strcmp(res->hwsw, "hw"))
4727 if (!strcmp(res->proto, "ip")) {
4728 if (hw == 0 || (dev_info.tx_offload_capa &
4729 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4730 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4733 "IP checksum offload is not supported by port %u\n",
4736 } else if (!strcmp(res->proto, "udp")) {
4737 if (hw == 0 || (dev_info.tx_offload_capa &
4738 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4739 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4742 "UDP checksum offload is not supported by port %u\n",
4745 } else if (!strcmp(res->proto, "tcp")) {
4746 if (hw == 0 || (dev_info.tx_offload_capa &
4747 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4748 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4751 "TCP checksum offload is not supported by port %u\n",
4754 } else if (!strcmp(res->proto, "sctp")) {
4755 if (hw == 0 || (dev_info.tx_offload_capa &
4756 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4757 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4760 "SCTP checksum offload is not supported by port %u\n",
4763 } else if (!strcmp(res->proto, "outer-ip")) {
4764 if (hw == 0 || (dev_info.tx_offload_capa &
4765 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4767 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4770 "Outer IP checksum offload is not supported by port %u\n",
4773 } else if (!strcmp(res->proto, "outer-udp")) {
4774 if (hw == 0 || (dev_info.tx_offload_capa &
4775 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4777 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4780 "Outer UDP checksum offload is not supported by port %u\n",
4786 ports[res->port_id].dev_conf.txmode.offloads |=
4789 ports[res->port_id].dev_conf.txmode.offloads &=
4792 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4794 csum_show(res->port_id);
4796 cmd_reconfig_device_queue(res->port_id, 1, 1);
4799 cmdline_parse_token_string_t cmd_csum_csum =
4800 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4802 cmdline_parse_token_string_t cmd_csum_mode =
4803 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4805 cmdline_parse_token_string_t cmd_csum_proto =
4806 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4807 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4808 cmdline_parse_token_string_t cmd_csum_hwsw =
4809 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4811 cmdline_parse_token_num_t cmd_csum_portid =
4812 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4813 port_id, RTE_UINT16);
4815 cmdline_parse_inst_t cmd_csum_set = {
4816 .f = cmd_csum_parsed,
4818 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4819 "Enable/Disable hardware calculation of L3/L4 checksum when "
4820 "using csum forward engine",
4822 (void *)&cmd_csum_csum,
4823 (void *)&cmd_csum_mode,
4824 (void *)&cmd_csum_proto,
4825 (void *)&cmd_csum_hwsw,
4826 (void *)&cmd_csum_portid,
4831 cmdline_parse_token_string_t cmd_csum_mode_show =
4832 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4835 cmdline_parse_inst_t cmd_csum_show = {
4836 .f = cmd_csum_parsed,
4838 .help_str = "csum show <port_id>: Show checksum offload configuration",
4840 (void *)&cmd_csum_csum,
4841 (void *)&cmd_csum_mode_show,
4842 (void *)&cmd_csum_portid,
4847 /* Enable/disable tunnel parsing */
4848 struct cmd_csum_tunnel_result {
4849 cmdline_fixed_string_t csum;
4850 cmdline_fixed_string_t parse;
4851 cmdline_fixed_string_t onoff;
4856 cmd_csum_tunnel_parsed(void *parsed_result,
4857 __rte_unused struct cmdline *cl,
4858 __rte_unused void *data)
4860 struct cmd_csum_tunnel_result *res = parsed_result;
4862 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4865 if (!strcmp(res->onoff, "on"))
4866 ports[res->port_id].parse_tunnel = 1;
4868 ports[res->port_id].parse_tunnel = 0;
4870 csum_show(res->port_id);
4873 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4874 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4876 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4877 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4878 parse, "parse-tunnel");
4879 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4880 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4882 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4883 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4884 port_id, RTE_UINT16);
4886 cmdline_parse_inst_t cmd_csum_tunnel = {
4887 .f = cmd_csum_tunnel_parsed,
4889 .help_str = "csum parse-tunnel on|off <port_id>: "
4890 "Enable/Disable parsing of tunnels for csum engine",
4892 (void *)&cmd_csum_tunnel_csum,
4893 (void *)&cmd_csum_tunnel_parse,
4894 (void *)&cmd_csum_tunnel_onoff,
4895 (void *)&cmd_csum_tunnel_portid,
4900 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4901 struct cmd_tso_set_result {
4902 cmdline_fixed_string_t tso;
4903 cmdline_fixed_string_t mode;
4909 cmd_tso_set_parsed(void *parsed_result,
4910 __rte_unused struct cmdline *cl,
4911 __rte_unused void *data)
4913 struct cmd_tso_set_result *res = parsed_result;
4914 struct rte_eth_dev_info dev_info;
4917 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4919 if (!port_is_stopped(res->port_id)) {
4920 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4924 if (!strcmp(res->mode, "set"))
4925 ports[res->port_id].tso_segsz = res->tso_segsz;
4927 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4931 if ((ports[res->port_id].tso_segsz != 0) &&
4932 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4933 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4938 if (ports[res->port_id].tso_segsz == 0) {
4939 ports[res->port_id].dev_conf.txmode.offloads &=
4940 ~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4941 printf("TSO for non-tunneled packets is disabled\n");
4943 ports[res->port_id].dev_conf.txmode.offloads |=
4944 RTE_ETH_TX_OFFLOAD_TCP_TSO;
4945 printf("TSO segment size for non-tunneled packets is %d\n",
4946 ports[res->port_id].tso_segsz);
4948 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4950 /* display warnings if configuration is not supported by the NIC */
4951 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4955 if ((ports[res->port_id].tso_segsz != 0) &&
4956 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4958 "Warning: TSO enabled but not supported by port %d\n",
4962 cmd_reconfig_device_queue(res->port_id, 1, 1);
4965 cmdline_parse_token_string_t cmd_tso_set_tso =
4966 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4968 cmdline_parse_token_string_t cmd_tso_set_mode =
4969 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4971 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4972 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4973 tso_segsz, RTE_UINT16);
4974 cmdline_parse_token_num_t cmd_tso_set_portid =
4975 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4976 port_id, RTE_UINT16);
4978 cmdline_parse_inst_t cmd_tso_set = {
4979 .f = cmd_tso_set_parsed,
4981 .help_str = "tso set <tso_segsz> <port_id>: "
4982 "Set TSO segment size of non-tunneled packets for csum engine "
4985 (void *)&cmd_tso_set_tso,
4986 (void *)&cmd_tso_set_mode,
4987 (void *)&cmd_tso_set_tso_segsz,
4988 (void *)&cmd_tso_set_portid,
4993 cmdline_parse_token_string_t cmd_tso_show_mode =
4994 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4998 cmdline_parse_inst_t cmd_tso_show = {
4999 .f = cmd_tso_set_parsed,
5001 .help_str = "tso show <port_id>: "
5002 "Show TSO segment size of non-tunneled packets for csum engine",
5004 (void *)&cmd_tso_set_tso,
5005 (void *)&cmd_tso_show_mode,
5006 (void *)&cmd_tso_set_portid,
5011 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5012 struct cmd_tunnel_tso_set_result {
5013 cmdline_fixed_string_t tso;
5014 cmdline_fixed_string_t mode;
5019 static struct rte_eth_dev_info
5020 check_tunnel_tso_nic_support(portid_t port_id)
5022 struct rte_eth_dev_info dev_info;
5024 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5027 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5029 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5031 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5033 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5035 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5037 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5039 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5041 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5043 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5045 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5047 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5049 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5055 cmd_tunnel_tso_set_parsed(void *parsed_result,
5056 __rte_unused struct cmdline *cl,
5057 __rte_unused void *data)
5059 struct cmd_tunnel_tso_set_result *res = parsed_result;
5060 struct rte_eth_dev_info dev_info;
5062 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5064 if (!port_is_stopped(res->port_id)) {
5065 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5069 if (!strcmp(res->mode, "set"))
5070 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5072 dev_info = check_tunnel_tso_nic_support(res->port_id);
5073 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5074 ports[res->port_id].dev_conf.txmode.offloads &=
5075 ~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5076 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5077 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5078 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5079 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5080 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5081 printf("TSO for tunneled packets is disabled\n");
5083 uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5084 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5085 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5086 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5087 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5088 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5090 ports[res->port_id].dev_conf.txmode.offloads |=
5091 (tso_offloads & dev_info.tx_offload_capa);
5092 printf("TSO segment size for tunneled packets is %d\n",
5093 ports[res->port_id].tunnel_tso_segsz);
5095 /* Below conditions are needed to make it work:
5096 * (1) tunnel TSO is supported by the NIC;
5097 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5099 * (3) for tunneled pkts with outer L3 of IPv4,
5100 * "csum set outer-ip" must be set to hw, because after tso,
5101 * total_len of outer IP header is changed, and the checksum
5102 * of outer IP header calculated by sw should be wrong; that
5103 * is not necessary for IPv6 tunneled pkts because there's no
5104 * checksum in IP header anymore.
5107 if (!ports[res->port_id].parse_tunnel)
5109 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5110 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5111 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5113 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5116 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5117 cmd_reconfig_device_queue(res->port_id, 1, 1);
5120 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5121 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5123 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5124 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5126 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5127 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5128 tso_segsz, RTE_UINT16);
5129 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5130 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5131 port_id, RTE_UINT16);
5133 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5134 .f = cmd_tunnel_tso_set_parsed,
5136 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5137 "Set TSO segment size of tunneled packets for csum engine "
5140 (void *)&cmd_tunnel_tso_set_tso,
5141 (void *)&cmd_tunnel_tso_set_mode,
5142 (void *)&cmd_tunnel_tso_set_tso_segsz,
5143 (void *)&cmd_tunnel_tso_set_portid,
5148 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5149 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5153 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5154 .f = cmd_tunnel_tso_set_parsed,
5156 .help_str = "tunnel_tso show <port_id> "
5157 "Show TSO segment size of tunneled packets for csum engine",
5159 (void *)&cmd_tunnel_tso_set_tso,
5160 (void *)&cmd_tunnel_tso_show_mode,
5161 (void *)&cmd_tunnel_tso_set_portid,
5167 /* *** SET GRO FOR A PORT *** */
5168 struct cmd_gro_enable_result {
5169 cmdline_fixed_string_t cmd_set;
5170 cmdline_fixed_string_t cmd_port;
5171 cmdline_fixed_string_t cmd_keyword;
5172 cmdline_fixed_string_t cmd_onoff;
5177 cmd_gro_enable_parsed(void *parsed_result,
5178 __rte_unused struct cmdline *cl,
5179 __rte_unused void *data)
5181 struct cmd_gro_enable_result *res;
5183 res = parsed_result;
5184 if (!strcmp(res->cmd_keyword, "gro"))
5185 setup_gro(res->cmd_onoff, res->cmd_pid);
5188 cmdline_parse_token_string_t cmd_gro_enable_set =
5189 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5191 cmdline_parse_token_string_t cmd_gro_enable_port =
5192 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5193 cmd_keyword, "port");
5194 cmdline_parse_token_num_t cmd_gro_enable_pid =
5195 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5196 cmd_pid, RTE_UINT16);
5197 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5198 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5199 cmd_keyword, "gro");
5200 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5201 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5202 cmd_onoff, "on#off");
5204 cmdline_parse_inst_t cmd_gro_enable = {
5205 .f = cmd_gro_enable_parsed,
5207 .help_str = "set port <port_id> gro on|off",
5209 (void *)&cmd_gro_enable_set,
5210 (void *)&cmd_gro_enable_port,
5211 (void *)&cmd_gro_enable_pid,
5212 (void *)&cmd_gro_enable_keyword,
5213 (void *)&cmd_gro_enable_onoff,
5218 /* *** DISPLAY GRO CONFIGURATION *** */
5219 struct cmd_gro_show_result {
5220 cmdline_fixed_string_t cmd_show;
5221 cmdline_fixed_string_t cmd_port;
5222 cmdline_fixed_string_t cmd_keyword;
5227 cmd_gro_show_parsed(void *parsed_result,
5228 __rte_unused struct cmdline *cl,
5229 __rte_unused void *data)
5231 struct cmd_gro_show_result *res;
5233 res = parsed_result;
5234 if (!strcmp(res->cmd_keyword, "gro"))
5235 show_gro(res->cmd_pid);
5238 cmdline_parse_token_string_t cmd_gro_show_show =
5239 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5241 cmdline_parse_token_string_t cmd_gro_show_port =
5242 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5244 cmdline_parse_token_num_t cmd_gro_show_pid =
5245 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5246 cmd_pid, RTE_UINT16);
5247 cmdline_parse_token_string_t cmd_gro_show_keyword =
5248 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5249 cmd_keyword, "gro");
5251 cmdline_parse_inst_t cmd_gro_show = {
5252 .f = cmd_gro_show_parsed,
5254 .help_str = "show port <port_id> gro",
5256 (void *)&cmd_gro_show_show,
5257 (void *)&cmd_gro_show_port,
5258 (void *)&cmd_gro_show_pid,
5259 (void *)&cmd_gro_show_keyword,
5264 /* *** SET FLUSH CYCLES FOR GRO *** */
5265 struct cmd_gro_flush_result {
5266 cmdline_fixed_string_t cmd_set;
5267 cmdline_fixed_string_t cmd_keyword;
5268 cmdline_fixed_string_t cmd_flush;
5273 cmd_gro_flush_parsed(void *parsed_result,
5274 __rte_unused struct cmdline *cl,
5275 __rte_unused void *data)
5277 struct cmd_gro_flush_result *res;
5279 res = parsed_result;
5280 if ((!strcmp(res->cmd_keyword, "gro")) &&
5281 (!strcmp(res->cmd_flush, "flush")))
5282 setup_gro_flush_cycles(res->cmd_cycles);
5285 cmdline_parse_token_string_t cmd_gro_flush_set =
5286 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5288 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5289 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5290 cmd_keyword, "gro");
5291 cmdline_parse_token_string_t cmd_gro_flush_flush =
5292 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5293 cmd_flush, "flush");
5294 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5295 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5296 cmd_cycles, RTE_UINT8);
5298 cmdline_parse_inst_t cmd_gro_flush = {
5299 .f = cmd_gro_flush_parsed,
5301 .help_str = "set gro flush <cycles>",
5303 (void *)&cmd_gro_flush_set,
5304 (void *)&cmd_gro_flush_keyword,
5305 (void *)&cmd_gro_flush_flush,
5306 (void *)&cmd_gro_flush_cycles,
5310 #endif /* RTE_LIB_GRO */
5313 /* *** ENABLE/DISABLE GSO *** */
5314 struct cmd_gso_enable_result {
5315 cmdline_fixed_string_t cmd_set;
5316 cmdline_fixed_string_t cmd_port;
5317 cmdline_fixed_string_t cmd_keyword;
5318 cmdline_fixed_string_t cmd_mode;
5323 cmd_gso_enable_parsed(void *parsed_result,
5324 __rte_unused struct cmdline *cl,
5325 __rte_unused void *data)
5327 struct cmd_gso_enable_result *res;
5329 res = parsed_result;
5330 if (!strcmp(res->cmd_keyword, "gso"))
5331 setup_gso(res->cmd_mode, res->cmd_pid);
5334 cmdline_parse_token_string_t cmd_gso_enable_set =
5335 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5337 cmdline_parse_token_string_t cmd_gso_enable_port =
5338 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5340 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5341 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5342 cmd_keyword, "gso");
5343 cmdline_parse_token_string_t cmd_gso_enable_mode =
5344 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5345 cmd_mode, "on#off");
5346 cmdline_parse_token_num_t cmd_gso_enable_pid =
5347 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5348 cmd_pid, RTE_UINT16);
5350 cmdline_parse_inst_t cmd_gso_enable = {
5351 .f = cmd_gso_enable_parsed,
5353 .help_str = "set port <port_id> gso on|off",
5355 (void *)&cmd_gso_enable_set,
5356 (void *)&cmd_gso_enable_port,
5357 (void *)&cmd_gso_enable_pid,
5358 (void *)&cmd_gso_enable_keyword,
5359 (void *)&cmd_gso_enable_mode,
5364 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5365 struct cmd_gso_size_result {
5366 cmdline_fixed_string_t cmd_set;
5367 cmdline_fixed_string_t cmd_keyword;
5368 cmdline_fixed_string_t cmd_segsz;
5373 cmd_gso_size_parsed(void *parsed_result,
5374 __rte_unused struct cmdline *cl,
5375 __rte_unused void *data)
5377 struct cmd_gso_size_result *res = parsed_result;
5379 if (test_done == 0) {
5381 "Before setting GSO segsz, please first stop forwarding\n");
5385 if (!strcmp(res->cmd_keyword, "gso") &&
5386 !strcmp(res->cmd_segsz, "segsz")) {
5387 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5389 "gso_size should be larger than %zu. Please input a legal value\n",
5390 RTE_GSO_SEG_SIZE_MIN);
5392 gso_max_segment_size = res->cmd_size;
5396 cmdline_parse_token_string_t cmd_gso_size_set =
5397 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5399 cmdline_parse_token_string_t cmd_gso_size_keyword =
5400 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5401 cmd_keyword, "gso");
5402 cmdline_parse_token_string_t cmd_gso_size_segsz =
5403 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5404 cmd_segsz, "segsz");
5405 cmdline_parse_token_num_t cmd_gso_size_size =
5406 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5407 cmd_size, RTE_UINT16);
5409 cmdline_parse_inst_t cmd_gso_size = {
5410 .f = cmd_gso_size_parsed,
5412 .help_str = "set gso segsz <length>",
5414 (void *)&cmd_gso_size_set,
5415 (void *)&cmd_gso_size_keyword,
5416 (void *)&cmd_gso_size_segsz,
5417 (void *)&cmd_gso_size_size,
5422 /* *** SHOW GSO CONFIGURATION *** */
5423 struct cmd_gso_show_result {
5424 cmdline_fixed_string_t cmd_show;
5425 cmdline_fixed_string_t cmd_port;
5426 cmdline_fixed_string_t cmd_keyword;
5431 cmd_gso_show_parsed(void *parsed_result,
5432 __rte_unused struct cmdline *cl,
5433 __rte_unused void *data)
5435 struct cmd_gso_show_result *res = parsed_result;
5437 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5438 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5441 if (!strcmp(res->cmd_keyword, "gso")) {
5442 if (gso_ports[res->cmd_pid].enable) {
5443 printf("Max GSO'd packet size: %uB\n"
5444 "Supported GSO types: TCP/IPv4, "
5445 "UDP/IPv4, VxLAN with inner "
5446 "TCP/IPv4 packet, GRE with inner "
5447 "TCP/IPv4 packet\n",
5448 gso_max_segment_size);
5450 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5454 cmdline_parse_token_string_t cmd_gso_show_show =
5455 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5457 cmdline_parse_token_string_t cmd_gso_show_port =
5458 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5460 cmdline_parse_token_string_t cmd_gso_show_keyword =
5461 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5462 cmd_keyword, "gso");
5463 cmdline_parse_token_num_t cmd_gso_show_pid =
5464 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5465 cmd_pid, RTE_UINT16);
5467 cmdline_parse_inst_t cmd_gso_show = {
5468 .f = cmd_gso_show_parsed,
5470 .help_str = "show port <port_id> gso",
5472 (void *)&cmd_gso_show_show,
5473 (void *)&cmd_gso_show_port,
5474 (void *)&cmd_gso_show_pid,
5475 (void *)&cmd_gso_show_keyword,
5479 #endif /* RTE_LIB_GSO */
5481 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5482 struct cmd_set_flush_rx {
5483 cmdline_fixed_string_t set;
5484 cmdline_fixed_string_t flush_rx;
5485 cmdline_fixed_string_t mode;
5489 cmd_set_flush_rx_parsed(void *parsed_result,
5490 __rte_unused struct cmdline *cl,
5491 __rte_unused void *data)
5493 struct cmd_set_flush_rx *res = parsed_result;
5495 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5496 printf("multi-process doesn't support to flush Rx queues.\n");
5500 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5503 cmdline_parse_token_string_t cmd_setflushrx_set =
5504 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5506 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5507 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5508 flush_rx, "flush_rx");
5509 cmdline_parse_token_string_t cmd_setflushrx_mode =
5510 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5514 cmdline_parse_inst_t cmd_set_flush_rx = {
5515 .f = cmd_set_flush_rx_parsed,
5516 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5519 (void *)&cmd_setflushrx_set,
5520 (void *)&cmd_setflushrx_flush_rx,
5521 (void *)&cmd_setflushrx_mode,
5526 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5527 struct cmd_set_link_check {
5528 cmdline_fixed_string_t set;
5529 cmdline_fixed_string_t link_check;
5530 cmdline_fixed_string_t mode;
5534 cmd_set_link_check_parsed(void *parsed_result,
5535 __rte_unused struct cmdline *cl,
5536 __rte_unused void *data)
5538 struct cmd_set_link_check *res = parsed_result;
5539 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5542 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5545 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5547 link_check, "link_check");
5548 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5553 cmdline_parse_inst_t cmd_set_link_check = {
5554 .f = cmd_set_link_check_parsed,
5555 .help_str = "set link_check on|off: Enable/Disable link status check "
5556 "when starting/stopping a port",
5559 (void *)&cmd_setlinkcheck_set,
5560 (void *)&cmd_setlinkcheck_link_check,
5561 (void *)&cmd_setlinkcheck_mode,
5566 /* *** SET NIC BYPASS MODE *** */
5567 struct cmd_set_bypass_mode_result {
5568 cmdline_fixed_string_t set;
5569 cmdline_fixed_string_t bypass;
5570 cmdline_fixed_string_t mode;
5571 cmdline_fixed_string_t value;
5576 cmd_set_bypass_mode_parsed(void *parsed_result,
5577 __rte_unused struct cmdline *cl,
5578 __rte_unused void *data)
5580 struct cmd_set_bypass_mode_result *res = parsed_result;
5581 portid_t port_id = res->port_id;
5582 int32_t rc = -EINVAL;
5584 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5585 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5587 if (!strcmp(res->value, "bypass"))
5588 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5589 else if (!strcmp(res->value, "isolate"))
5590 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5592 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5594 /* Set the bypass mode for the relevant port. */
5595 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5598 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5602 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5603 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5605 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5606 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5608 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5609 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5611 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5612 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5613 value, "normal#bypass#isolate");
5614 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5615 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5616 port_id, RTE_UINT16);
5618 cmdline_parse_inst_t cmd_set_bypass_mode = {
5619 .f = cmd_set_bypass_mode_parsed,
5620 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5621 "Set the NIC bypass mode for port_id",
5624 (void *)&cmd_setbypass_mode_set,
5625 (void *)&cmd_setbypass_mode_bypass,
5626 (void *)&cmd_setbypass_mode_mode,
5627 (void *)&cmd_setbypass_mode_value,
5628 (void *)&cmd_setbypass_mode_port,
5633 /* *** SET NIC BYPASS EVENT *** */
5634 struct cmd_set_bypass_event_result {
5635 cmdline_fixed_string_t set;
5636 cmdline_fixed_string_t bypass;
5637 cmdline_fixed_string_t event;
5638 cmdline_fixed_string_t event_value;
5639 cmdline_fixed_string_t mode;
5640 cmdline_fixed_string_t mode_value;
5645 cmd_set_bypass_event_parsed(void *parsed_result,
5646 __rte_unused struct cmdline *cl,
5647 __rte_unused void *data)
5649 int32_t rc = -EINVAL;
5650 struct cmd_set_bypass_event_result *res = parsed_result;
5651 portid_t port_id = res->port_id;
5653 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5654 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5655 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5657 if (!strcmp(res->event_value, "timeout"))
5658 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5659 else if (!strcmp(res->event_value, "os_on"))
5660 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5661 else if (!strcmp(res->event_value, "os_off"))
5662 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5663 else if (!strcmp(res->event_value, "power_on"))
5664 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5665 else if (!strcmp(res->event_value, "power_off"))
5666 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5668 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5670 if (!strcmp(res->mode_value, "bypass"))
5671 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5672 else if (!strcmp(res->mode_value, "isolate"))
5673 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5675 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5677 /* Set the watchdog timeout. */
5678 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5681 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5682 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5687 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5688 bypass_timeout, port_id, rc);
5692 /* Set the bypass event to transition to bypass mode. */
5693 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5698 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5702 cmdline_parse_token_string_t cmd_setbypass_event_set =
5703 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5705 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5706 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5708 cmdline_parse_token_string_t cmd_setbypass_event_event =
5709 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5711 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5712 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5713 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5714 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5715 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5717 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5718 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5719 mode_value, "normal#bypass#isolate");
5720 cmdline_parse_token_num_t cmd_setbypass_event_port =
5721 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5722 port_id, RTE_UINT16);
5724 cmdline_parse_inst_t cmd_set_bypass_event = {
5725 .f = cmd_set_bypass_event_parsed,
5726 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5727 "power_off mode normal|bypass|isolate <port_id>: "
5728 "Set the NIC bypass event mode for port_id",
5731 (void *)&cmd_setbypass_event_set,
5732 (void *)&cmd_setbypass_event_bypass,
5733 (void *)&cmd_setbypass_event_event,
5734 (void *)&cmd_setbypass_event_event_value,
5735 (void *)&cmd_setbypass_event_mode,
5736 (void *)&cmd_setbypass_event_mode_value,
5737 (void *)&cmd_setbypass_event_port,
5743 /* *** SET NIC BYPASS TIMEOUT *** */
5744 struct cmd_set_bypass_timeout_result {
5745 cmdline_fixed_string_t set;
5746 cmdline_fixed_string_t bypass;
5747 cmdline_fixed_string_t timeout;
5748 cmdline_fixed_string_t value;
5752 cmd_set_bypass_timeout_parsed(void *parsed_result,
5753 __rte_unused struct cmdline *cl,
5754 __rte_unused void *data)
5756 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5758 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5759 if (!strcmp(res->value, "1.5"))
5760 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5761 else if (!strcmp(res->value, "2"))
5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5763 else if (!strcmp(res->value, "3"))
5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5765 else if (!strcmp(res->value, "4"))
5766 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5767 else if (!strcmp(res->value, "8"))
5768 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5769 else if (!strcmp(res->value, "16"))
5770 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5771 else if (!strcmp(res->value, "32"))
5772 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5774 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5778 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5779 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5781 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5784 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5785 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5786 timeout, "timeout");
5787 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5788 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5789 value, "0#1.5#2#3#4#8#16#32");
5791 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5792 .f = cmd_set_bypass_timeout_parsed,
5793 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5794 "Set the NIC bypass watchdog timeout in seconds",
5797 (void *)&cmd_setbypass_timeout_set,
5798 (void *)&cmd_setbypass_timeout_bypass,
5799 (void *)&cmd_setbypass_timeout_timeout,
5800 (void *)&cmd_setbypass_timeout_value,
5805 /* *** SHOW NIC BYPASS MODE *** */
5806 struct cmd_show_bypass_config_result {
5807 cmdline_fixed_string_t show;
5808 cmdline_fixed_string_t bypass;
5809 cmdline_fixed_string_t config;
5814 cmd_show_bypass_config_parsed(void *parsed_result,
5815 __rte_unused struct cmdline *cl,
5816 __rte_unused void *data)
5818 struct cmd_show_bypass_config_result *res = parsed_result;
5819 portid_t port_id = res->port_id;
5821 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5822 uint32_t event_mode;
5823 uint32_t bypass_mode;
5824 uint32_t timeout = bypass_timeout;
5827 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5828 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5829 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5830 {"UNKNOWN", "normal", "bypass", "isolate"};
5831 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5839 /* Display the bypass mode.*/
5840 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5841 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5846 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5847 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5849 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5852 /* Display the bypass timeout.*/
5853 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5854 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5856 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5858 /* Display the bypass events and associated modes. */
5859 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5861 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5863 "\tFailed to get bypass mode for event = %s\n",
5866 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5867 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5869 printf("\tbypass event: %-16s = %s\n", events[i],
5876 "\tFailed to get bypass configuration for port = %d\n",
5880 cmdline_parse_token_string_t cmd_showbypass_config_show =
5881 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5883 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5884 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5886 cmdline_parse_token_string_t cmd_showbypass_config_config =
5887 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5889 cmdline_parse_token_num_t cmd_showbypass_config_port =
5890 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5891 port_id, RTE_UINT16);
5893 cmdline_parse_inst_t cmd_show_bypass_config = {
5894 .f = cmd_show_bypass_config_parsed,
5895 .help_str = "show bypass config <port_id>: "
5896 "Show the NIC bypass config for port_id",
5899 (void *)&cmd_showbypass_config_show,
5900 (void *)&cmd_showbypass_config_bypass,
5901 (void *)&cmd_showbypass_config_config,
5902 (void *)&cmd_showbypass_config_port,
5908 /* *** SET BONDING MODE *** */
5909 struct cmd_set_bonding_mode_result {
5910 cmdline_fixed_string_t set;
5911 cmdline_fixed_string_t bonding;
5912 cmdline_fixed_string_t mode;
5917 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5918 __rte_unused struct cmdline *cl,
5919 __rte_unused void *data)
5921 struct cmd_set_bonding_mode_result *res = parsed_result;
5922 portid_t port_id = res->port_id;
5923 struct rte_port *port = &ports[port_id];
5926 * Bonding mode changed means resources of device changed, like whether
5927 * started rte timer or not. Device should be restarted when resources
5928 * of device changed.
5930 if (port->port_status != RTE_PORT_STOPPED) {
5932 "\t Error: Can't set bonding mode when port %d is not stopped\n",
5937 /* Set the bonding mode for the relevant port. */
5938 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5939 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5943 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5944 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5946 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5947 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5948 bonding, "bonding");
5949 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5950 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5952 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5953 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5955 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5956 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5957 port_id, RTE_UINT16);
5959 cmdline_parse_inst_t cmd_set_bonding_mode = {
5960 .f = cmd_set_bonding_mode_parsed,
5961 .help_str = "set bonding mode <mode_value> <port_id>: "
5962 "Set the bonding mode for port_id",
5965 (void *) &cmd_setbonding_mode_set,
5966 (void *) &cmd_setbonding_mode_bonding,
5967 (void *) &cmd_setbonding_mode_mode,
5968 (void *) &cmd_setbonding_mode_value,
5969 (void *) &cmd_setbonding_mode_port,
5974 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5975 struct cmd_set_bonding_lacp_dedicated_queues_result {
5976 cmdline_fixed_string_t set;
5977 cmdline_fixed_string_t bonding;
5978 cmdline_fixed_string_t lacp;
5979 cmdline_fixed_string_t dedicated_queues;
5981 cmdline_fixed_string_t mode;
5984 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5985 __rte_unused struct cmdline *cl,
5986 __rte_unused void *data)
5988 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5989 portid_t port_id = res->port_id;
5990 struct rte_port *port;
5992 port = &ports[port_id];
5994 /** Check if the port is not started **/
5995 if (port->port_status != RTE_PORT_STOPPED) {
5996 fprintf(stderr, "Please stop port %d first\n", port_id);
6000 if (!strcmp(res->mode, "enable")) {
6001 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
6002 printf("Dedicate queues for LACP control packets"
6005 printf("Enabling dedicate queues for LACP control "
6006 "packets on port %d failed\n", port_id);
6007 } else if (!strcmp(res->mode, "disable")) {
6008 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
6009 printf("Dedicated queues for LACP control packets "
6012 printf("Disabling dedicated queues for LACP control "
6013 "traffic on port %d failed\n", port_id);
6017 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6018 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6020 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6021 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6022 bonding, "bonding");
6023 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6024 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6026 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6027 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6028 dedicated_queues, "dedicated_queues");
6029 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6030 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6031 port_id, RTE_UINT16);
6032 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6033 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6034 mode, "enable#disable");
6036 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6037 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6038 .help_str = "set bonding lacp dedicated_queues <port_id> "
6040 "Enable/disable dedicated queues for LACP control traffic for port_id",
6043 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6044 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6045 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6046 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6047 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6048 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6053 /* *** SET BALANCE XMIT POLICY *** */
6054 struct cmd_set_bonding_balance_xmit_policy_result {
6055 cmdline_fixed_string_t set;
6056 cmdline_fixed_string_t bonding;
6057 cmdline_fixed_string_t balance_xmit_policy;
6059 cmdline_fixed_string_t policy;
6062 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6063 __rte_unused struct cmdline *cl,
6064 __rte_unused void *data)
6066 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6067 portid_t port_id = res->port_id;
6070 if (!strcmp(res->policy, "l2")) {
6071 policy = BALANCE_XMIT_POLICY_LAYER2;
6072 } else if (!strcmp(res->policy, "l23")) {
6073 policy = BALANCE_XMIT_POLICY_LAYER23;
6074 } else if (!strcmp(res->policy, "l34")) {
6075 policy = BALANCE_XMIT_POLICY_LAYER34;
6077 fprintf(stderr, "\t Invalid xmit policy selection");
6081 /* Set the bonding mode for the relevant port. */
6082 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6084 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6089 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6090 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6092 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6093 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6094 bonding, "bonding");
6095 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6096 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6097 balance_xmit_policy, "balance_xmit_policy");
6098 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6099 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6100 port_id, RTE_UINT16);
6101 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6102 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6103 policy, "l2#l23#l34");
6105 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6106 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6107 .help_str = "set bonding balance_xmit_policy <port_id> "
6109 "Set the bonding balance_xmit_policy for port_id",
6112 (void *)&cmd_setbonding_balance_xmit_policy_set,
6113 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6114 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6115 (void *)&cmd_setbonding_balance_xmit_policy_port,
6116 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6121 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6122 struct cmd_show_bonding_lacp_info_result {
6123 cmdline_fixed_string_t show;
6124 cmdline_fixed_string_t bonding;
6125 cmdline_fixed_string_t lacp;
6126 cmdline_fixed_string_t info;
6130 static void port_param_show(struct port_params *params)
6132 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6134 printf("\t\tsystem priority: %u\n", params->system_priority);
6135 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6136 printf("\t\tsystem mac address: %s\n", buf);
6137 printf("\t\tport key: %u\n", params->key);
6138 printf("\t\tport priority: %u\n", params->port_priority);
6139 printf("\t\tport number: %u\n", params->port_number);
6142 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6144 char a_state[256] = { 0 };
6145 char p_state[256] = { 0 };
6150 static const char * const state[] = {
6160 static const char * const selection[] = {
6166 for (i = 0; i < RTE_DIM(state); i++) {
6167 if ((info->actor_state >> i) & 1)
6168 a_len += snprintf(&a_state[a_len],
6169 RTE_DIM(a_state) - a_len, "%s ",
6172 if ((info->partner_state >> i) & 1)
6173 p_len += snprintf(&p_state[p_len],
6174 RTE_DIM(p_state) - p_len, "%s ",
6177 printf("\tAggregator port id: %u\n", info->agg_port_id);
6178 printf("\tselection: %s\n", selection[info->selected]);
6179 printf("\tActor detail info:\n");
6180 port_param_show(&info->actor);
6181 printf("\t\tport state: %s\n", a_state);
6182 printf("\tPartner detail info:\n");
6183 port_param_show(&info->partner);
6184 printf("\t\tport state: %s\n", p_state);
6188 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6190 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6191 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6192 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6193 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6194 printf("\taggregate wait timeout: %u ms\n",
6195 conf->aggregate_wait_timeout_ms);
6196 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6197 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6198 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6199 switch (conf->agg_selection) {
6201 printf("\taggregation mode: bandwidth\n");
6204 printf("\taggregation mode: stable\n");
6207 printf("\taggregation mode: count\n");
6210 printf("\taggregation mode: invalid\n");
6217 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6218 __rte_unused struct cmdline *cl,
6219 __rte_unused void *data)
6221 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6222 struct rte_eth_bond_8023ad_slave_info slave_info;
6223 struct rte_eth_bond_8023ad_conf port_conf;
6224 portid_t slaves[RTE_MAX_ETHPORTS];
6225 portid_t port_id = res->port_id;
6226 int num_active_slaves;
6231 bonding_mode = rte_eth_bond_mode_get(port_id);
6232 if (bonding_mode != BONDING_MODE_8023AD) {
6233 fprintf(stderr, "\tBonding mode is not mode 4\n");
6237 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6239 if (num_active_slaves < 0) {
6240 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6244 if (num_active_slaves == 0)
6245 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6248 printf("\tIEEE802.3 port: %u\n", port_id);
6249 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6251 fprintf(stderr, "\tGet bonded device %u info failed\n",
6255 lacp_conf_show(&port_conf);
6257 for (i = 0; i < num_active_slaves; i++) {
6258 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6261 fprintf(stderr, "\tGet slave device %u info failed\n",
6265 printf("\tSlave Port: %u\n", slaves[i]);
6266 lacp_slave_info_show(&slave_info);
6270 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6271 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6273 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6274 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6275 bonding, "bonding");
6276 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6277 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6279 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6280 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6282 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6283 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6284 port_id, RTE_UINT16);
6286 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6287 .f = cmd_show_bonding_lacp_info_parsed,
6288 .help_str = "show bonding lacp info <port_id> : "
6289 "Show bonding IEEE802.3 information for port_id",
6292 (void *)&cmd_show_bonding_lacp_info_show,
6293 (void *)&cmd_show_bonding_lacp_info_bonding,
6294 (void *)&cmd_show_bonding_lacp_info_lacp,
6295 (void *)&cmd_show_bonding_lacp_info_info,
6296 (void *)&cmd_show_bonding_lacp_info_port_id,
6301 /* *** SHOW NIC BONDING CONFIGURATION *** */
6302 struct cmd_show_bonding_config_result {
6303 cmdline_fixed_string_t show;
6304 cmdline_fixed_string_t bonding;
6305 cmdline_fixed_string_t config;
6309 static void cmd_show_bonding_config_parsed(void *parsed_result,
6310 __rte_unused struct cmdline *cl,
6311 __rte_unused void *data)
6313 struct cmd_show_bonding_config_result *res = parsed_result;
6314 int bonding_mode, agg_mode;
6315 portid_t slaves[RTE_MAX_ETHPORTS];
6316 int num_slaves, num_active_slaves;
6319 portid_t port_id = res->port_id;
6321 /* Display the bonding mode.*/
6322 bonding_mode = rte_eth_bond_mode_get(port_id);
6323 if (bonding_mode < 0) {
6324 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6328 printf("\tBonding mode: %d\n", bonding_mode);
6330 if (bonding_mode == BONDING_MODE_BALANCE ||
6331 bonding_mode == BONDING_MODE_8023AD) {
6332 int balance_xmit_policy;
6334 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6335 if (balance_xmit_policy < 0) {
6337 "\tFailed to get balance xmit policy for port = %d\n",
6341 printf("\tBalance Xmit Policy: ");
6343 switch (balance_xmit_policy) {
6344 case BALANCE_XMIT_POLICY_LAYER2:
6345 printf("BALANCE_XMIT_POLICY_LAYER2");
6347 case BALANCE_XMIT_POLICY_LAYER23:
6348 printf("BALANCE_XMIT_POLICY_LAYER23");
6350 case BALANCE_XMIT_POLICY_LAYER34:
6351 printf("BALANCE_XMIT_POLICY_LAYER34");
6358 if (bonding_mode == BONDING_MODE_8023AD) {
6359 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6360 printf("\tIEEE802.3AD Aggregator Mode: ");
6363 printf("bandwidth");
6375 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6377 if (num_slaves < 0) {
6378 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6382 if (num_slaves > 0) {
6383 printf("\tSlaves (%d): [", num_slaves);
6384 for (i = 0; i < num_slaves - 1; i++)
6385 printf("%d ", slaves[i]);
6387 printf("%d]\n", slaves[num_slaves - 1]);
6389 printf("\tSlaves: []\n");
6393 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6396 if (num_active_slaves < 0) {
6398 "\tFailed to get active slave list for port = %d\n",
6402 if (num_active_slaves > 0) {
6403 printf("\tActive Slaves (%d): [", num_active_slaves);
6404 for (i = 0; i < num_active_slaves - 1; i++)
6405 printf("%d ", slaves[i]);
6407 printf("%d]\n", slaves[num_active_slaves - 1]);
6410 printf("\tActive Slaves: []\n");
6414 primary_id = rte_eth_bond_primary_get(port_id);
6415 if (primary_id < 0) {
6416 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6420 printf("\tPrimary: [%d]\n", primary_id);
6424 cmdline_parse_token_string_t cmd_showbonding_config_show =
6425 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6427 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6428 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6429 bonding, "bonding");
6430 cmdline_parse_token_string_t cmd_showbonding_config_config =
6431 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6433 cmdline_parse_token_num_t cmd_showbonding_config_port =
6434 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6435 port_id, RTE_UINT16);
6437 cmdline_parse_inst_t cmd_show_bonding_config = {
6438 .f = cmd_show_bonding_config_parsed,
6439 .help_str = "show bonding config <port_id>: "
6440 "Show the bonding config for port_id",
6443 (void *)&cmd_showbonding_config_show,
6444 (void *)&cmd_showbonding_config_bonding,
6445 (void *)&cmd_showbonding_config_config,
6446 (void *)&cmd_showbonding_config_port,
6451 /* *** SET BONDING PRIMARY *** */
6452 struct cmd_set_bonding_primary_result {
6453 cmdline_fixed_string_t set;
6454 cmdline_fixed_string_t bonding;
6455 cmdline_fixed_string_t primary;
6460 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6461 __rte_unused struct cmdline *cl,
6462 __rte_unused void *data)
6464 struct cmd_set_bonding_primary_result *res = parsed_result;
6465 portid_t master_port_id = res->port_id;
6466 portid_t slave_port_id = res->slave_id;
6468 /* Set the primary slave for a bonded device. */
6469 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6470 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6477 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6480 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6481 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6482 bonding, "bonding");
6483 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6485 primary, "primary");
6486 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6487 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6488 slave_id, RTE_UINT16);
6489 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6490 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6491 port_id, RTE_UINT16);
6493 cmdline_parse_inst_t cmd_set_bonding_primary = {
6494 .f = cmd_set_bonding_primary_parsed,
6495 .help_str = "set bonding primary <slave_id> <port_id>: "
6496 "Set the primary slave for port_id",
6499 (void *)&cmd_setbonding_primary_set,
6500 (void *)&cmd_setbonding_primary_bonding,
6501 (void *)&cmd_setbonding_primary_primary,
6502 (void *)&cmd_setbonding_primary_slave,
6503 (void *)&cmd_setbonding_primary_port,
6508 /* *** ADD SLAVE *** */
6509 struct cmd_add_bonding_slave_result {
6510 cmdline_fixed_string_t add;
6511 cmdline_fixed_string_t bonding;
6512 cmdline_fixed_string_t slave;
6517 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6518 __rte_unused struct cmdline *cl,
6519 __rte_unused void *data)
6521 struct cmd_add_bonding_slave_result *res = parsed_result;
6522 portid_t master_port_id = res->port_id;
6523 portid_t slave_port_id = res->slave_id;
6525 /* add the slave for a bonded device. */
6526 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6528 "\t Failed to add slave %d to master port = %d.\n",
6529 slave_port_id, master_port_id);
6533 set_port_slave_flag(slave_port_id);
6536 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6537 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6539 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6540 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6541 bonding, "bonding");
6542 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6543 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6545 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6546 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6547 slave_id, RTE_UINT16);
6548 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6549 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6550 port_id, RTE_UINT16);
6552 cmdline_parse_inst_t cmd_add_bonding_slave = {
6553 .f = cmd_add_bonding_slave_parsed,
6554 .help_str = "add bonding slave <slave_id> <port_id>: "
6555 "Add a slave device to a bonded device",
6558 (void *)&cmd_addbonding_slave_add,
6559 (void *)&cmd_addbonding_slave_bonding,
6560 (void *)&cmd_addbonding_slave_slave,
6561 (void *)&cmd_addbonding_slave_slaveid,
6562 (void *)&cmd_addbonding_slave_port,
6567 /* *** REMOVE SLAVE *** */
6568 struct cmd_remove_bonding_slave_result {
6569 cmdline_fixed_string_t remove;
6570 cmdline_fixed_string_t bonding;
6571 cmdline_fixed_string_t slave;
6576 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6577 __rte_unused struct cmdline *cl,
6578 __rte_unused void *data)
6580 struct cmd_remove_bonding_slave_result *res = parsed_result;
6581 portid_t master_port_id = res->port_id;
6582 portid_t slave_port_id = res->slave_id;
6584 /* remove the slave from a bonded device. */
6585 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6587 "\t Failed to remove slave %d from master port = %d.\n",
6588 slave_port_id, master_port_id);
6592 clear_port_slave_flag(slave_port_id);
6595 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6596 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6598 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6599 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6600 bonding, "bonding");
6601 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6602 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6604 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6605 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6606 slave_id, RTE_UINT16);
6607 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6608 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6609 port_id, RTE_UINT16);
6611 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6612 .f = cmd_remove_bonding_slave_parsed,
6613 .help_str = "remove bonding slave <slave_id> <port_id>: "
6614 "Remove a slave device from a bonded device",
6617 (void *)&cmd_removebonding_slave_remove,
6618 (void *)&cmd_removebonding_slave_bonding,
6619 (void *)&cmd_removebonding_slave_slave,
6620 (void *)&cmd_removebonding_slave_slaveid,
6621 (void *)&cmd_removebonding_slave_port,
6626 /* *** CREATE BONDED DEVICE *** */
6627 struct cmd_create_bonded_device_result {
6628 cmdline_fixed_string_t create;
6629 cmdline_fixed_string_t bonded;
6630 cmdline_fixed_string_t device;
6635 static int bond_dev_num = 0;
6637 static void cmd_create_bonded_device_parsed(void *parsed_result,
6638 __rte_unused struct cmdline *cl,
6639 __rte_unused void *data)
6641 struct cmd_create_bonded_device_result *res = parsed_result;
6642 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6646 if (test_done == 0) {
6647 fprintf(stderr, "Please stop forwarding first\n");
6651 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6654 /* Create a new bonded device. */
6655 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6657 fprintf(stderr, "\t Failed to create bonded device.\n");
6660 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6663 /* Update number of ports */
6664 nb_ports = rte_eth_dev_count_avail();
6665 reconfig(port_id, res->socket);
6666 ret = rte_eth_promiscuous_enable(port_id);
6669 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6670 port_id, rte_strerror(-ret));
6672 ports[port_id].need_setup = 0;
6673 ports[port_id].port_status = RTE_PORT_STOPPED;
6678 cmdline_parse_token_string_t cmd_createbonded_device_create =
6679 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6681 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6682 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6684 cmdline_parse_token_string_t cmd_createbonded_device_device =
6685 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6687 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6688 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6690 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6691 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6694 cmdline_parse_inst_t cmd_create_bonded_device = {
6695 .f = cmd_create_bonded_device_parsed,
6696 .help_str = "create bonded device <mode> <socket>: "
6697 "Create a new bonded device with specific bonding mode and socket",
6700 (void *)&cmd_createbonded_device_create,
6701 (void *)&cmd_createbonded_device_bonded,
6702 (void *)&cmd_createbonded_device_device,
6703 (void *)&cmd_createbonded_device_mode,
6704 (void *)&cmd_createbonded_device_socket,
6709 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6710 struct cmd_set_bond_mac_addr_result {
6711 cmdline_fixed_string_t set;
6712 cmdline_fixed_string_t bonding;
6713 cmdline_fixed_string_t mac_addr;
6715 struct rte_ether_addr address;
6718 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6719 __rte_unused struct cmdline *cl,
6720 __rte_unused void *data)
6722 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6725 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6728 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6730 /* check the return value and print it if is < 0 */
6732 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6736 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6737 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6738 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6739 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6741 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6742 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6744 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6745 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6746 port_num, RTE_UINT16);
6747 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6748 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6750 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6751 .f = cmd_set_bond_mac_addr_parsed,
6753 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6755 (void *)&cmd_set_bond_mac_addr_set,
6756 (void *)&cmd_set_bond_mac_addr_bonding,
6757 (void *)&cmd_set_bond_mac_addr_mac,
6758 (void *)&cmd_set_bond_mac_addr_portnum,
6759 (void *)&cmd_set_bond_mac_addr_addr,
6765 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6766 struct cmd_set_bond_mon_period_result {
6767 cmdline_fixed_string_t set;
6768 cmdline_fixed_string_t bonding;
6769 cmdline_fixed_string_t mon_period;
6774 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6775 __rte_unused struct cmdline *cl,
6776 __rte_unused void *data)
6778 struct cmd_set_bond_mon_period_result *res = parsed_result;
6781 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6783 /* check the return value and print it if is < 0 */
6785 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6789 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6790 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6792 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6793 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6794 bonding, "bonding");
6795 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6796 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6797 mon_period, "mon_period");
6798 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6799 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6800 port_num, RTE_UINT16);
6801 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6802 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6803 period_ms, RTE_UINT32);
6805 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6806 .f = cmd_set_bond_mon_period_parsed,
6808 .help_str = "set bonding mon_period <port_id> <period_ms>",
6810 (void *)&cmd_set_bond_mon_period_set,
6811 (void *)&cmd_set_bond_mon_period_bonding,
6812 (void *)&cmd_set_bond_mon_period_mon_period,
6813 (void *)&cmd_set_bond_mon_period_portnum,
6814 (void *)&cmd_set_bond_mon_period_period_ms,
6821 struct cmd_set_bonding_agg_mode_policy_result {
6822 cmdline_fixed_string_t set;
6823 cmdline_fixed_string_t bonding;
6824 cmdline_fixed_string_t agg_mode;
6826 cmdline_fixed_string_t policy;
6831 cmd_set_bonding_agg_mode(void *parsed_result,
6832 __rte_unused struct cmdline *cl,
6833 __rte_unused void *data)
6835 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6836 uint8_t policy = AGG_BANDWIDTH;
6838 if (!strcmp(res->policy, "bandwidth"))
6839 policy = AGG_BANDWIDTH;
6840 else if (!strcmp(res->policy, "stable"))
6841 policy = AGG_STABLE;
6842 else if (!strcmp(res->policy, "count"))
6845 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6849 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6852 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6854 bonding, "bonding");
6856 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6857 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6858 agg_mode, "agg_mode");
6860 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6861 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6862 port_num, RTE_UINT16);
6864 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6865 TOKEN_STRING_INITIALIZER(
6866 struct cmd_set_bonding_balance_xmit_policy_result,
6867 policy, "stable#bandwidth#count");
6869 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6870 .f = cmd_set_bonding_agg_mode,
6872 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6874 (void *)&cmd_set_bonding_agg_mode_set,
6875 (void *)&cmd_set_bonding_agg_mode_bonding,
6876 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6877 (void *)&cmd_set_bonding_agg_mode_portnum,
6878 (void *)&cmd_set_bonding_agg_mode_policy_string,
6884 #endif /* RTE_NET_BOND */
6886 /* *** SET FORWARDING MODE *** */
6887 struct cmd_set_fwd_mode_result {
6888 cmdline_fixed_string_t set;
6889 cmdline_fixed_string_t fwd;
6890 cmdline_fixed_string_t mode;
6893 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6894 __rte_unused struct cmdline *cl,
6895 __rte_unused void *data)
6897 struct cmd_set_fwd_mode_result *res = parsed_result;
6900 set_pkt_forwarding_mode(res->mode);
6903 cmdline_parse_token_string_t cmd_setfwd_set =
6904 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6905 cmdline_parse_token_string_t cmd_setfwd_fwd =
6906 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6907 cmdline_parse_token_string_t cmd_setfwd_mode =
6908 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6909 "" /* defined at init */);
6911 cmdline_parse_inst_t cmd_set_fwd_mode = {
6912 .f = cmd_set_fwd_mode_parsed,
6914 .help_str = NULL, /* defined at init */
6916 (void *)&cmd_setfwd_set,
6917 (void *)&cmd_setfwd_fwd,
6918 (void *)&cmd_setfwd_mode,
6923 static void cmd_set_fwd_mode_init(void)
6926 static char token[128];
6927 static char help[256];
6928 cmdline_parse_token_string_t *token_struct;
6930 modes = list_pkt_forwarding_modes();
6931 snprintf(help, sizeof(help), "set fwd %s: "
6932 "Set packet forwarding mode", modes);
6933 cmd_set_fwd_mode.help_str = help;
6935 /* string token separator is # */
6936 for (c = token; *modes != '\0'; modes++)
6941 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6942 token_struct->string_data.str = token;
6945 /* *** SET RETRY FORWARDING MODE *** */
6946 struct cmd_set_fwd_retry_mode_result {
6947 cmdline_fixed_string_t set;
6948 cmdline_fixed_string_t fwd;
6949 cmdline_fixed_string_t mode;
6950 cmdline_fixed_string_t retry;
6953 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6954 __rte_unused struct cmdline *cl,
6955 __rte_unused void *data)
6957 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6960 set_pkt_forwarding_mode(res->mode);
6963 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6964 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6966 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6967 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6969 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6970 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6972 "" /* defined at init */);
6973 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6974 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6977 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6978 .f = cmd_set_fwd_retry_mode_parsed,
6980 .help_str = NULL, /* defined at init */
6982 (void *)&cmd_setfwd_retry_set,
6983 (void *)&cmd_setfwd_retry_fwd,
6984 (void *)&cmd_setfwd_retry_mode,
6985 (void *)&cmd_setfwd_retry_retry,
6990 static void cmd_set_fwd_retry_mode_init(void)
6993 static char token[128];
6994 static char help[256];
6995 cmdline_parse_token_string_t *token_struct;
6997 modes = list_pkt_forwarding_retry_modes();
6998 snprintf(help, sizeof(help), "set fwd %s retry: "
6999 "Set packet forwarding mode with retry", modes);
7000 cmd_set_fwd_retry_mode.help_str = help;
7002 /* string token separator is # */
7003 for (c = token; *modes != '\0'; modes++)
7008 token_struct = (cmdline_parse_token_string_t *)
7009 cmd_set_fwd_retry_mode.tokens[2];
7010 token_struct->string_data.str = token;
7013 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
7014 struct cmd_set_burst_tx_retry_result {
7015 cmdline_fixed_string_t set;
7016 cmdline_fixed_string_t burst;
7017 cmdline_fixed_string_t tx;
7018 cmdline_fixed_string_t delay;
7020 cmdline_fixed_string_t retry;
7024 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7025 __rte_unused struct cmdline *cl,
7026 __rte_unused void *data)
7028 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7030 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7031 && !strcmp(res->tx, "tx")) {
7032 if (!strcmp(res->delay, "delay"))
7033 burst_tx_delay_time = res->time;
7034 if (!strcmp(res->retry, "retry"))
7035 burst_tx_retry_num = res->retry_num;
7040 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7041 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7042 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7043 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7045 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7046 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7047 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7048 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7049 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7050 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7052 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7053 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7054 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7055 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7058 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7059 .f = cmd_set_burst_tx_retry_parsed,
7060 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7062 (void *)&cmd_set_burst_tx_retry_set,
7063 (void *)&cmd_set_burst_tx_retry_burst,
7064 (void *)&cmd_set_burst_tx_retry_tx,
7065 (void *)&cmd_set_burst_tx_retry_delay,
7066 (void *)&cmd_set_burst_tx_retry_time,
7067 (void *)&cmd_set_burst_tx_retry_retry,
7068 (void *)&cmd_set_burst_tx_retry_retry_num,
7073 /* *** SET PROMISC MODE *** */
7074 struct cmd_set_promisc_mode_result {
7075 cmdline_fixed_string_t set;
7076 cmdline_fixed_string_t promisc;
7077 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7078 uint16_t port_num; /* valid if "allports" argument == 0 */
7079 cmdline_fixed_string_t mode;
7082 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7083 __rte_unused struct cmdline *cl,
7086 struct cmd_set_promisc_mode_result *res = parsed_result;
7090 if (!strcmp(res->mode, "on"))
7097 RTE_ETH_FOREACH_DEV(i)
7098 eth_set_promisc_mode(i, enable);
7100 eth_set_promisc_mode(res->port_num, enable);
7104 cmdline_parse_token_string_t cmd_setpromisc_set =
7105 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7106 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7107 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7109 cmdline_parse_token_string_t cmd_setpromisc_portall =
7110 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7112 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7113 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7115 cmdline_parse_token_string_t cmd_setpromisc_mode =
7116 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7119 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7120 .f = cmd_set_promisc_mode_parsed,
7122 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7124 (void *)&cmd_setpromisc_set,
7125 (void *)&cmd_setpromisc_promisc,
7126 (void *)&cmd_setpromisc_portall,
7127 (void *)&cmd_setpromisc_mode,
7132 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7133 .f = cmd_set_promisc_mode_parsed,
7135 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7137 (void *)&cmd_setpromisc_set,
7138 (void *)&cmd_setpromisc_promisc,
7139 (void *)&cmd_setpromisc_portnum,
7140 (void *)&cmd_setpromisc_mode,
7145 /* *** SET ALLMULTI MODE *** */
7146 struct cmd_set_allmulti_mode_result {
7147 cmdline_fixed_string_t set;
7148 cmdline_fixed_string_t allmulti;
7149 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7150 uint16_t port_num; /* valid if "allports" argument == 0 */
7151 cmdline_fixed_string_t mode;
7154 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7155 __rte_unused struct cmdline *cl,
7158 struct cmd_set_allmulti_mode_result *res = parsed_result;
7162 if (!strcmp(res->mode, "on"))
7169 RTE_ETH_FOREACH_DEV(i) {
7170 eth_set_allmulticast_mode(i, enable);
7174 eth_set_allmulticast_mode(res->port_num, enable);
7178 cmdline_parse_token_string_t cmd_setallmulti_set =
7179 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7180 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7181 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7183 cmdline_parse_token_string_t cmd_setallmulti_portall =
7184 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7186 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7187 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7189 cmdline_parse_token_string_t cmd_setallmulti_mode =
7190 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7193 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7194 .f = cmd_set_allmulti_mode_parsed,
7196 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7198 (void *)&cmd_setallmulti_set,
7199 (void *)&cmd_setallmulti_allmulti,
7200 (void *)&cmd_setallmulti_portall,
7201 (void *)&cmd_setallmulti_mode,
7206 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7207 .f = cmd_set_allmulti_mode_parsed,
7209 .help_str = "set allmulti <port_id> on|off: "
7210 "Set allmulti mode on port_id",
7212 (void *)&cmd_setallmulti_set,
7213 (void *)&cmd_setallmulti_allmulti,
7214 (void *)&cmd_setallmulti_portnum,
7215 (void *)&cmd_setallmulti_mode,
7220 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7221 struct cmd_link_flow_ctrl_show {
7222 cmdline_fixed_string_t show;
7223 cmdline_fixed_string_t port;
7225 cmdline_fixed_string_t flow_ctrl;
7228 cmdline_parse_token_string_t cmd_lfc_show_show =
7229 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7231 cmdline_parse_token_string_t cmd_lfc_show_port =
7232 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7234 cmdline_parse_token_num_t cmd_lfc_show_portid =
7235 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7236 port_id, RTE_UINT16);
7237 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7238 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7239 flow_ctrl, "flow_ctrl");
7242 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7243 __rte_unused struct cmdline *cl,
7244 __rte_unused void *data)
7246 struct cmd_link_flow_ctrl_show *res = parsed_result;
7247 static const char *info_border = "*********************";
7248 struct rte_eth_fc_conf fc_conf;
7249 bool rx_fc_en = false;
7250 bool tx_fc_en = false;
7253 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7256 "Failed to get current flow ctrl information: err = %d\n",
7261 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7263 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7266 printf("\n%s Flow control infos for port %-2d %s\n",
7267 info_border, res->port_id, info_border);
7268 printf("FC mode:\n");
7269 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7270 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7271 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7272 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7273 printf("High waterline: 0x%x\n", fc_conf.high_water);
7274 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7275 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7276 printf("Forward MAC control frames: %s\n",
7277 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7278 printf("\n%s************** End ***********%s\n",
7279 info_border, info_border);
7282 cmdline_parse_inst_t cmd_link_flow_control_show = {
7283 .f = cmd_link_flow_ctrl_show_parsed,
7285 .help_str = "show port <port_id> flow_ctrl",
7287 (void *)&cmd_lfc_show_show,
7288 (void *)&cmd_lfc_show_port,
7289 (void *)&cmd_lfc_show_portid,
7290 (void *)&cmd_lfc_show_flow_ctrl,
7295 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7296 struct cmd_link_flow_ctrl_set_result {
7297 cmdline_fixed_string_t set;
7298 cmdline_fixed_string_t flow_ctrl;
7299 cmdline_fixed_string_t rx;
7300 cmdline_fixed_string_t rx_lfc_mode;
7301 cmdline_fixed_string_t tx;
7302 cmdline_fixed_string_t tx_lfc_mode;
7303 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7304 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7305 cmdline_fixed_string_t autoneg_str;
7306 cmdline_fixed_string_t autoneg;
7307 cmdline_fixed_string_t hw_str;
7308 uint32_t high_water;
7309 cmdline_fixed_string_t lw_str;
7311 cmdline_fixed_string_t pt_str;
7312 uint16_t pause_time;
7313 cmdline_fixed_string_t xon_str;
7318 cmdline_parse_token_string_t cmd_lfc_set_set =
7319 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7321 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7322 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7323 flow_ctrl, "flow_ctrl");
7324 cmdline_parse_token_string_t cmd_lfc_set_rx =
7325 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7327 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7328 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7329 rx_lfc_mode, "on#off");
7330 cmdline_parse_token_string_t cmd_lfc_set_tx =
7331 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7333 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7334 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7335 tx_lfc_mode, "on#off");
7336 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7337 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7338 hw_str, "high_water");
7339 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7340 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7341 high_water, RTE_UINT32);
7342 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7343 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7344 lw_str, "low_water");
7345 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7346 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7347 low_water, RTE_UINT32);
7348 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7349 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7350 pt_str, "pause_time");
7351 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7352 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7353 pause_time, RTE_UINT16);
7354 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7355 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7356 xon_str, "send_xon");
7357 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7358 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7359 send_xon, RTE_UINT16);
7360 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7361 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7362 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7363 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7364 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7365 mac_ctrl_frame_fwd_mode, "on#off");
7366 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7367 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7368 autoneg_str, "autoneg");
7369 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7370 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7372 cmdline_parse_token_num_t cmd_lfc_set_portid =
7373 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7374 port_id, RTE_UINT16);
7376 /* forward declaration */
7378 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7381 cmdline_parse_inst_t cmd_link_flow_control_set = {
7382 .f = cmd_link_flow_ctrl_set_parsed,
7384 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7385 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7386 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7388 (void *)&cmd_lfc_set_set,
7389 (void *)&cmd_lfc_set_flow_ctrl,
7390 (void *)&cmd_lfc_set_rx,
7391 (void *)&cmd_lfc_set_rx_mode,
7392 (void *)&cmd_lfc_set_tx,
7393 (void *)&cmd_lfc_set_tx_mode,
7394 (void *)&cmd_lfc_set_high_water,
7395 (void *)&cmd_lfc_set_low_water,
7396 (void *)&cmd_lfc_set_pause_time,
7397 (void *)&cmd_lfc_set_send_xon,
7398 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7399 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7400 (void *)&cmd_lfc_set_autoneg_str,
7401 (void *)&cmd_lfc_set_autoneg,
7402 (void *)&cmd_lfc_set_portid,
7407 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7408 .f = cmd_link_flow_ctrl_set_parsed,
7409 .data = (void *)&cmd_link_flow_control_set_rx,
7410 .help_str = "set flow_ctrl rx on|off <port_id>: "
7411 "Change rx flow control parameter",
7413 (void *)&cmd_lfc_set_set,
7414 (void *)&cmd_lfc_set_flow_ctrl,
7415 (void *)&cmd_lfc_set_rx,
7416 (void *)&cmd_lfc_set_rx_mode,
7417 (void *)&cmd_lfc_set_portid,
7422 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7423 .f = cmd_link_flow_ctrl_set_parsed,
7424 .data = (void *)&cmd_link_flow_control_set_tx,
7425 .help_str = "set flow_ctrl tx on|off <port_id>: "
7426 "Change tx flow control parameter",
7428 (void *)&cmd_lfc_set_set,
7429 (void *)&cmd_lfc_set_flow_ctrl,
7430 (void *)&cmd_lfc_set_tx,
7431 (void *)&cmd_lfc_set_tx_mode,
7432 (void *)&cmd_lfc_set_portid,
7437 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7438 .f = cmd_link_flow_ctrl_set_parsed,
7439 .data = (void *)&cmd_link_flow_control_set_hw,
7440 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7441 "Change high water flow control parameter",
7443 (void *)&cmd_lfc_set_set,
7444 (void *)&cmd_lfc_set_flow_ctrl,
7445 (void *)&cmd_lfc_set_high_water_str,
7446 (void *)&cmd_lfc_set_high_water,
7447 (void *)&cmd_lfc_set_portid,
7452 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7453 .f = cmd_link_flow_ctrl_set_parsed,
7454 .data = (void *)&cmd_link_flow_control_set_lw,
7455 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7456 "Change low water flow control parameter",
7458 (void *)&cmd_lfc_set_set,
7459 (void *)&cmd_lfc_set_flow_ctrl,
7460 (void *)&cmd_lfc_set_low_water_str,
7461 (void *)&cmd_lfc_set_low_water,
7462 (void *)&cmd_lfc_set_portid,
7467 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7468 .f = cmd_link_flow_ctrl_set_parsed,
7469 .data = (void *)&cmd_link_flow_control_set_pt,
7470 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7471 "Change pause time flow control parameter",
7473 (void *)&cmd_lfc_set_set,
7474 (void *)&cmd_lfc_set_flow_ctrl,
7475 (void *)&cmd_lfc_set_pause_time_str,
7476 (void *)&cmd_lfc_set_pause_time,
7477 (void *)&cmd_lfc_set_portid,
7482 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7483 .f = cmd_link_flow_ctrl_set_parsed,
7484 .data = (void *)&cmd_link_flow_control_set_xon,
7485 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7486 "Change send_xon flow control parameter",
7488 (void *)&cmd_lfc_set_set,
7489 (void *)&cmd_lfc_set_flow_ctrl,
7490 (void *)&cmd_lfc_set_send_xon_str,
7491 (void *)&cmd_lfc_set_send_xon,
7492 (void *)&cmd_lfc_set_portid,
7497 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7498 .f = cmd_link_flow_ctrl_set_parsed,
7499 .data = (void *)&cmd_link_flow_control_set_macfwd,
7500 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7501 "Change mac ctrl fwd flow control parameter",
7503 (void *)&cmd_lfc_set_set,
7504 (void *)&cmd_lfc_set_flow_ctrl,
7505 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7506 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7507 (void *)&cmd_lfc_set_portid,
7512 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7513 .f = cmd_link_flow_ctrl_set_parsed,
7514 .data = (void *)&cmd_link_flow_control_set_autoneg,
7515 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7516 "Change autoneg flow control parameter",
7518 (void *)&cmd_lfc_set_set,
7519 (void *)&cmd_lfc_set_flow_ctrl,
7520 (void *)&cmd_lfc_set_autoneg_str,
7521 (void *)&cmd_lfc_set_autoneg,
7522 (void *)&cmd_lfc_set_portid,
7528 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7529 __rte_unused struct cmdline *cl,
7532 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7533 cmdline_parse_inst_t *cmd = data;
7534 struct rte_eth_fc_conf fc_conf;
7540 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7541 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7542 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7543 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7545 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7546 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7549 /* Partial command line, retrieve current configuration */
7551 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7554 "cannot get current flow ctrl parameters, return code = %d\n",
7559 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7560 (fc_conf.mode == RTE_ETH_FC_FULL))
7562 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7563 (fc_conf.mode == RTE_ETH_FC_FULL))
7567 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7568 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7570 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7571 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7573 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7575 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7576 fc_conf.high_water = res->high_water;
7578 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7579 fc_conf.low_water = res->low_water;
7581 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7582 fc_conf.pause_time = res->pause_time;
7584 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7585 fc_conf.send_xon = res->send_xon;
7587 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7588 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7589 fc_conf.mac_ctrl_frame_fwd = 1;
7591 fc_conf.mac_ctrl_frame_fwd = 0;
7594 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7595 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7597 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7600 "bad flow control parameter, return code = %d\n",
7604 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7605 struct cmd_priority_flow_ctrl_set_result {
7606 cmdline_fixed_string_t set;
7607 cmdline_fixed_string_t pfc_ctrl;
7608 cmdline_fixed_string_t rx;
7609 cmdline_fixed_string_t rx_pfc_mode;
7610 cmdline_fixed_string_t tx;
7611 cmdline_fixed_string_t tx_pfc_mode;
7612 uint32_t high_water;
7614 uint16_t pause_time;
7620 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7621 __rte_unused struct cmdline *cl,
7622 __rte_unused void *data)
7624 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7625 struct rte_eth_pfc_conf pfc_conf;
7626 int rx_fc_enable, tx_fc_enable;
7630 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7631 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7632 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7633 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7635 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7636 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7639 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7640 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7641 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7642 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7643 pfc_conf.fc.high_water = res->high_water;
7644 pfc_conf.fc.low_water = res->low_water;
7645 pfc_conf.fc.pause_time = res->pause_time;
7646 pfc_conf.priority = res->priority;
7648 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7651 "bad priority flow control parameter, return code = %d\n",
7655 cmdline_parse_token_string_t cmd_pfc_set_set =
7656 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7658 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7659 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7660 pfc_ctrl, "pfc_ctrl");
7661 cmdline_parse_token_string_t cmd_pfc_set_rx =
7662 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7664 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7665 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7666 rx_pfc_mode, "on#off");
7667 cmdline_parse_token_string_t cmd_pfc_set_tx =
7668 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7670 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7671 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7672 tx_pfc_mode, "on#off");
7673 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7674 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7675 high_water, RTE_UINT32);
7676 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7677 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7678 low_water, RTE_UINT32);
7679 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7680 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7681 pause_time, RTE_UINT16);
7682 cmdline_parse_token_num_t cmd_pfc_set_priority =
7683 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7684 priority, RTE_UINT8);
7685 cmdline_parse_token_num_t cmd_pfc_set_portid =
7686 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7687 port_id, RTE_UINT16);
7689 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7690 .f = cmd_priority_flow_ctrl_set_parsed,
7692 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7693 "<pause_time> <priority> <port_id>: "
7694 "Configure the Ethernet priority flow control",
7696 (void *)&cmd_pfc_set_set,
7697 (void *)&cmd_pfc_set_flow_ctrl,
7698 (void *)&cmd_pfc_set_rx,
7699 (void *)&cmd_pfc_set_rx_mode,
7700 (void *)&cmd_pfc_set_tx,
7701 (void *)&cmd_pfc_set_tx_mode,
7702 (void *)&cmd_pfc_set_high_water,
7703 (void *)&cmd_pfc_set_low_water,
7704 (void *)&cmd_pfc_set_pause_time,
7705 (void *)&cmd_pfc_set_priority,
7706 (void *)&cmd_pfc_set_portid,
7711 struct cmd_queue_priority_flow_ctrl_set_result {
7712 cmdline_fixed_string_t set;
7713 cmdline_fixed_string_t pfc_queue_ctrl;
7715 cmdline_fixed_string_t rx;
7716 cmdline_fixed_string_t rx_pfc_mode;
7719 cmdline_fixed_string_t tx;
7720 cmdline_fixed_string_t tx_pfc_mode;
7723 uint16_t pause_time;
7727 cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7728 __rte_unused struct cmdline *cl,
7729 __rte_unused void *data)
7731 struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7732 struct rte_eth_pfc_queue_conf pfc_queue_conf;
7733 int rx_fc_enable, tx_fc_enable;
7737 * Rx on/off, flow control is enabled/disabled on RX side. This can
7738 * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7739 * side. Tx on/off, flow control is enabled/disabled on TX side. This
7740 * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7743 static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7744 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7745 {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7748 memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7749 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7750 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7751 pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7752 pfc_queue_conf.rx_pause.tc = res->tx_tc;
7753 pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7754 pfc_queue_conf.tx_pause.tc = res->rx_tc;
7755 pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7756 pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7758 ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7762 "bad queue priority flow control parameter, rc = %d\n",
7767 cmdline_parse_token_string_t cmd_q_pfc_set_set =
7768 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7770 cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7771 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7772 pfc_queue_ctrl, "pfc_queue_ctrl");
7773 cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7774 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7775 port_id, RTE_UINT16);
7776 cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7777 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7779 cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7780 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7781 rx_pfc_mode, "on#off");
7782 cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7783 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7784 tx_qid, RTE_UINT16);
7785 cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7786 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7788 cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7789 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7791 cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7792 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7793 tx_pfc_mode, "on#off");
7794 cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7795 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7796 rx_qid, RTE_UINT16);
7797 cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7798 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7800 cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7801 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7802 pause_time, RTE_UINT16);
7804 cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7805 .f = cmd_queue_priority_flow_ctrl_set_parsed,
7807 .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7808 "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7809 "Configure the Ethernet queue priority flow control",
7811 (void *)&cmd_q_pfc_set_set,
7812 (void *)&cmd_q_pfc_set_flow_ctrl,
7813 (void *)&cmd_q_pfc_set_portid,
7814 (void *)&cmd_q_pfc_set_rx,
7815 (void *)&cmd_q_pfc_set_rx_mode,
7816 (void *)&cmd_q_pfc_set_tx_qid,
7817 (void *)&cmd_q_pfc_set_tx_tc,
7818 (void *)&cmd_q_pfc_set_tx,
7819 (void *)&cmd_q_pfc_set_tx_mode,
7820 (void *)&cmd_q_pfc_set_rx_qid,
7821 (void *)&cmd_q_pfc_set_rx_tc,
7822 (void *)&cmd_q_pfc_set_pause_time,
7827 /* *** RESET CONFIGURATION *** */
7828 struct cmd_reset_result {
7829 cmdline_fixed_string_t reset;
7830 cmdline_fixed_string_t def;
7833 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7835 __rte_unused void *data)
7837 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7838 set_def_fwd_config();
7841 cmdline_parse_token_string_t cmd_reset_set =
7842 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7843 cmdline_parse_token_string_t cmd_reset_def =
7844 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7847 cmdline_parse_inst_t cmd_reset = {
7848 .f = cmd_reset_parsed,
7850 .help_str = "set default: Reset default forwarding configuration",
7852 (void *)&cmd_reset_set,
7853 (void *)&cmd_reset_def,
7858 /* *** START FORWARDING *** */
7859 struct cmd_start_result {
7860 cmdline_fixed_string_t start;
7863 cmdline_parse_token_string_t cmd_start_start =
7864 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7866 static void cmd_start_parsed(__rte_unused void *parsed_result,
7867 __rte_unused struct cmdline *cl,
7868 __rte_unused void *data)
7870 start_packet_forwarding(0);
7873 cmdline_parse_inst_t cmd_start = {
7874 .f = cmd_start_parsed,
7876 .help_str = "start: Start packet forwarding",
7878 (void *)&cmd_start_start,
7883 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7884 struct cmd_start_tx_first_result {
7885 cmdline_fixed_string_t start;
7886 cmdline_fixed_string_t tx_first;
7890 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7891 __rte_unused struct cmdline *cl,
7892 __rte_unused void *data)
7894 start_packet_forwarding(1);
7897 cmdline_parse_token_string_t cmd_start_tx_first_start =
7898 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7900 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7901 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7902 tx_first, "tx_first");
7904 cmdline_parse_inst_t cmd_start_tx_first = {
7905 .f = cmd_start_tx_first_parsed,
7907 .help_str = "start tx_first: Start packet forwarding, "
7908 "after sending 1 burst of packets",
7910 (void *)&cmd_start_tx_first_start,
7911 (void *)&cmd_start_tx_first_tx_first,
7916 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7917 struct cmd_start_tx_first_n_result {
7918 cmdline_fixed_string_t start;
7919 cmdline_fixed_string_t tx_first;
7924 cmd_start_tx_first_n_parsed(void *parsed_result,
7925 __rte_unused struct cmdline *cl,
7926 __rte_unused void *data)
7928 struct cmd_start_tx_first_n_result *res = parsed_result;
7930 start_packet_forwarding(res->tx_num);
7933 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7934 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7936 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7937 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7938 tx_first, "tx_first");
7939 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7940 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7941 tx_num, RTE_UINT32);
7943 cmdline_parse_inst_t cmd_start_tx_first_n = {
7944 .f = cmd_start_tx_first_n_parsed,
7946 .help_str = "start tx_first <num>: "
7947 "packet forwarding, after sending <num> bursts of packets",
7949 (void *)&cmd_start_tx_first_n_start,
7950 (void *)&cmd_start_tx_first_n_tx_first,
7951 (void *)&cmd_start_tx_first_n_tx_num,
7956 /* *** SET LINK UP *** */
7957 struct cmd_set_link_up_result {
7958 cmdline_fixed_string_t set;
7959 cmdline_fixed_string_t link_up;
7960 cmdline_fixed_string_t port;
7964 cmdline_parse_token_string_t cmd_set_link_up_set =
7965 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7966 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7967 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7969 cmdline_parse_token_string_t cmd_set_link_up_port =
7970 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7971 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7972 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7975 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7976 __rte_unused struct cmdline *cl,
7977 __rte_unused void *data)
7979 struct cmd_set_link_up_result *res = parsed_result;
7980 dev_set_link_up(res->port_id);
7983 cmdline_parse_inst_t cmd_set_link_up = {
7984 .f = cmd_set_link_up_parsed,
7986 .help_str = "set link-up port <port id>",
7988 (void *)&cmd_set_link_up_set,
7989 (void *)&cmd_set_link_up_link_up,
7990 (void *)&cmd_set_link_up_port,
7991 (void *)&cmd_set_link_up_port_id,
7996 /* *** SET LINK DOWN *** */
7997 struct cmd_set_link_down_result {
7998 cmdline_fixed_string_t set;
7999 cmdline_fixed_string_t link_down;
8000 cmdline_fixed_string_t port;
8004 cmdline_parse_token_string_t cmd_set_link_down_set =
8005 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
8006 cmdline_parse_token_string_t cmd_set_link_down_link_down =
8007 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
8009 cmdline_parse_token_string_t cmd_set_link_down_port =
8010 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
8011 cmdline_parse_token_num_t cmd_set_link_down_port_id =
8012 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
8015 static void cmd_set_link_down_parsed(
8016 __rte_unused void *parsed_result,
8017 __rte_unused struct cmdline *cl,
8018 __rte_unused void *data)
8020 struct cmd_set_link_down_result *res = parsed_result;
8021 dev_set_link_down(res->port_id);
8024 cmdline_parse_inst_t cmd_set_link_down = {
8025 .f = cmd_set_link_down_parsed,
8027 .help_str = "set link-down port <port id>",
8029 (void *)&cmd_set_link_down_set,
8030 (void *)&cmd_set_link_down_link_down,
8031 (void *)&cmd_set_link_down_port,
8032 (void *)&cmd_set_link_down_port_id,
8037 /* *** SHOW CFG *** */
8038 struct cmd_showcfg_result {
8039 cmdline_fixed_string_t show;
8040 cmdline_fixed_string_t cfg;
8041 cmdline_fixed_string_t what;
8044 static void cmd_showcfg_parsed(void *parsed_result,
8045 __rte_unused struct cmdline *cl,
8046 __rte_unused void *data)
8048 struct cmd_showcfg_result *res = parsed_result;
8049 if (!strcmp(res->what, "rxtx"))
8050 rxtx_config_display();
8051 else if (!strcmp(res->what, "cores"))
8052 fwd_lcores_config_display();
8053 else if (!strcmp(res->what, "fwd"))
8054 pkt_fwd_config_display(&cur_fwd_config);
8055 else if (!strcmp(res->what, "rxoffs"))
8056 show_rx_pkt_offsets();
8057 else if (!strcmp(res->what, "rxpkts"))
8058 show_rx_pkt_segments();
8059 else if (!strcmp(res->what, "txpkts"))
8060 show_tx_pkt_segments();
8061 else if (!strcmp(res->what, "txtimes"))
8062 show_tx_pkt_times();
8065 cmdline_parse_token_string_t cmd_showcfg_show =
8066 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
8067 cmdline_parse_token_string_t cmd_showcfg_port =
8068 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
8069 cmdline_parse_token_string_t cmd_showcfg_what =
8070 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
8071 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
8073 cmdline_parse_inst_t cmd_showcfg = {
8074 .f = cmd_showcfg_parsed,
8076 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
8078 (void *)&cmd_showcfg_show,
8079 (void *)&cmd_showcfg_port,
8080 (void *)&cmd_showcfg_what,
8085 /* *** SHOW ALL PORT INFO *** */
8086 struct cmd_showportall_result {
8087 cmdline_fixed_string_t show;
8088 cmdline_fixed_string_t port;
8089 cmdline_fixed_string_t what;
8090 cmdline_fixed_string_t all;
8093 static void cmd_showportall_parsed(void *parsed_result,
8094 __rte_unused struct cmdline *cl,
8095 __rte_unused void *data)
8099 struct cmd_showportall_result *res = parsed_result;
8100 if (!strcmp(res->show, "clear")) {
8101 if (!strcmp(res->what, "stats"))
8102 RTE_ETH_FOREACH_DEV(i)
8104 else if (!strcmp(res->what, "xstats"))
8105 RTE_ETH_FOREACH_DEV(i)
8106 nic_xstats_clear(i);
8107 } else if (!strcmp(res->what, "info"))
8108 RTE_ETH_FOREACH_DEV(i)
8109 port_infos_display(i);
8110 else if (!strcmp(res->what, "summary")) {
8111 port_summary_header_display();
8112 RTE_ETH_FOREACH_DEV(i)
8113 port_summary_display(i);
8115 else if (!strcmp(res->what, "stats"))
8116 RTE_ETH_FOREACH_DEV(i)
8117 nic_stats_display(i);
8118 else if (!strcmp(res->what, "xstats"))
8119 RTE_ETH_FOREACH_DEV(i)
8120 nic_xstats_display(i);
8121 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8122 else if (!strcmp(res->what, "fdir"))
8123 RTE_ETH_FOREACH_DEV(i)
8126 else if (!strcmp(res->what, "dcb_tc"))
8127 RTE_ETH_FOREACH_DEV(i)
8128 port_dcb_info_display(i);
8131 cmdline_parse_token_string_t cmd_showportall_show =
8132 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
8134 cmdline_parse_token_string_t cmd_showportall_port =
8135 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8136 cmdline_parse_token_string_t cmd_showportall_what =
8137 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8138 "info#summary#stats#xstats#fdir#dcb_tc");
8139 cmdline_parse_token_string_t cmd_showportall_all =
8140 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8141 cmdline_parse_inst_t cmd_showportall = {
8142 .f = cmd_showportall_parsed,
8144 .help_str = "show|clear port "
8145 "info|summary|stats|xstats|fdir|dcb_tc all",
8147 (void *)&cmd_showportall_show,
8148 (void *)&cmd_showportall_port,
8149 (void *)&cmd_showportall_what,
8150 (void *)&cmd_showportall_all,
8155 /* *** SHOW PORT INFO *** */
8156 struct cmd_showport_result {
8157 cmdline_fixed_string_t show;
8158 cmdline_fixed_string_t port;
8159 cmdline_fixed_string_t what;
8163 static void cmd_showport_parsed(void *parsed_result,
8164 __rte_unused struct cmdline *cl,
8165 __rte_unused void *data)
8167 struct cmd_showport_result *res = parsed_result;
8168 if (!strcmp(res->show, "clear")) {
8169 if (!strcmp(res->what, "stats"))
8170 nic_stats_clear(res->portnum);
8171 else if (!strcmp(res->what, "xstats"))
8172 nic_xstats_clear(res->portnum);
8173 } else if (!strcmp(res->what, "info"))
8174 port_infos_display(res->portnum);
8175 else if (!strcmp(res->what, "summary")) {
8176 port_summary_header_display();
8177 port_summary_display(res->portnum);
8179 else if (!strcmp(res->what, "stats"))
8180 nic_stats_display(res->portnum);
8181 else if (!strcmp(res->what, "xstats"))
8182 nic_xstats_display(res->portnum);
8183 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8184 else if (!strcmp(res->what, "fdir"))
8185 fdir_get_infos(res->portnum);
8187 else if (!strcmp(res->what, "dcb_tc"))
8188 port_dcb_info_display(res->portnum);
8191 cmdline_parse_token_string_t cmd_showport_show =
8192 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8194 cmdline_parse_token_string_t cmd_showport_port =
8195 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8196 cmdline_parse_token_string_t cmd_showport_what =
8197 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8198 "info#summary#stats#xstats#fdir#dcb_tc");
8199 cmdline_parse_token_num_t cmd_showport_portnum =
8200 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8202 cmdline_parse_inst_t cmd_showport = {
8203 .f = cmd_showport_parsed,
8205 .help_str = "show|clear port "
8206 "info|summary|stats|xstats|fdir|dcb_tc "
8209 (void *)&cmd_showport_show,
8210 (void *)&cmd_showport_port,
8211 (void *)&cmd_showport_what,
8212 (void *)&cmd_showport_portnum,
8217 /* *** show port representors information *** */
8218 struct cmd_representor_info_result {
8219 cmdline_fixed_string_t cmd_show;
8220 cmdline_fixed_string_t cmd_port;
8221 cmdline_fixed_string_t cmd_info;
8222 cmdline_fixed_string_t cmd_keyword;
8227 cmd_representor_info_parsed(void *parsed_result,
8228 __rte_unused struct cmdline *cl,
8229 __rte_unused void *data)
8231 struct cmd_representor_info_result *res = parsed_result;
8232 struct rte_eth_representor_info *info;
8233 struct rte_eth_representor_range *range;
8234 uint32_t range_diff;
8239 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8240 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8244 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8247 "Failed to get the number of representor info ranges for port %hu: %s\n",
8248 res->cmd_pid, rte_strerror(-ret));
8253 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8256 "Failed to allocate memory for representor info for port %hu\n",
8260 info->nb_ranges_alloc = num;
8262 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8265 "Failed to get the representor info for port %hu: %s\n",
8266 res->cmd_pid, rte_strerror(-ret));
8271 printf("Port controller: %hu\n", info->controller);
8272 printf("Port PF: %hu\n", info->pf);
8274 printf("Ranges: %u\n", info->nb_ranges);
8275 for (i = 0; i < info->nb_ranges; i++) {
8276 range = &info->ranges[i];
8277 range_diff = range->id_end - range->id_base;
8279 printf("%u. ", i + 1);
8280 printf("'%s' ", range->name);
8282 printf("[%u-%u]: ", range->id_base, range->id_end);
8284 printf("[%u]: ", range->id_base);
8286 printf("Controller %d, PF %d", range->controller, range->pf);
8288 switch (range->type) {
8289 case RTE_ETH_REPRESENTOR_NONE:
8292 case RTE_ETH_REPRESENTOR_VF:
8294 printf(", VF %d..%d\n", range->vf,
8295 range->vf + range_diff);
8297 printf(", VF %d\n", range->vf);
8299 case RTE_ETH_REPRESENTOR_SF:
8300 printf(", SF %d\n", range->sf);
8302 case RTE_ETH_REPRESENTOR_PF:
8304 printf("..%d\n", range->pf + range_diff);
8309 printf(", UNKNOWN TYPE %d\n", range->type);
8317 cmdline_parse_token_string_t cmd_representor_info_show =
8318 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8320 cmdline_parse_token_string_t cmd_representor_info_port =
8321 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8323 cmdline_parse_token_string_t cmd_representor_info_info =
8324 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8326 cmdline_parse_token_num_t cmd_representor_info_pid =
8327 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8328 cmd_pid, RTE_UINT16);
8329 cmdline_parse_token_string_t cmd_representor_info_keyword =
8330 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8331 cmd_keyword, "representor");
8333 cmdline_parse_inst_t cmd_representor_info = {
8334 .f = cmd_representor_info_parsed,
8336 .help_str = "show port info <port_id> representor",
8338 (void *)&cmd_representor_info_show,
8339 (void *)&cmd_representor_info_port,
8340 (void *)&cmd_representor_info_info,
8341 (void *)&cmd_representor_info_pid,
8342 (void *)&cmd_representor_info_keyword,
8348 /* *** SHOW DEVICE INFO *** */
8349 struct cmd_showdevice_result {
8350 cmdline_fixed_string_t show;
8351 cmdline_fixed_string_t device;
8352 cmdline_fixed_string_t what;
8353 cmdline_fixed_string_t identifier;
8356 static void cmd_showdevice_parsed(void *parsed_result,
8357 __rte_unused struct cmdline *cl,
8358 __rte_unused void *data)
8360 struct cmd_showdevice_result *res = parsed_result;
8361 if (!strcmp(res->what, "info")) {
8362 if (!strcmp(res->identifier, "all"))
8363 device_infos_display(NULL);
8365 device_infos_display(res->identifier);
8369 cmdline_parse_token_string_t cmd_showdevice_show =
8370 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8372 cmdline_parse_token_string_t cmd_showdevice_device =
8373 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8374 cmdline_parse_token_string_t cmd_showdevice_what =
8375 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8377 cmdline_parse_token_string_t cmd_showdevice_identifier =
8378 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8381 cmdline_parse_inst_t cmd_showdevice = {
8382 .f = cmd_showdevice_parsed,
8384 .help_str = "show device info <identifier>|all",
8386 (void *)&cmd_showdevice_show,
8387 (void *)&cmd_showdevice_device,
8388 (void *)&cmd_showdevice_what,
8389 (void *)&cmd_showdevice_identifier,
8394 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8395 struct cmd_showeeprom_result {
8396 cmdline_fixed_string_t show;
8397 cmdline_fixed_string_t port;
8399 cmdline_fixed_string_t type;
8402 static void cmd_showeeprom_parsed(void *parsed_result,
8403 __rte_unused struct cmdline *cl,
8404 __rte_unused void *data)
8406 struct cmd_showeeprom_result *res = parsed_result;
8408 if (!strcmp(res->type, "eeprom"))
8409 port_eeprom_display(res->portnum);
8410 else if (!strcmp(res->type, "module_eeprom"))
8411 port_module_eeprom_display(res->portnum);
8413 fprintf(stderr, "Unknown argument\n");
8416 cmdline_parse_token_string_t cmd_showeeprom_show =
8417 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8418 cmdline_parse_token_string_t cmd_showeeprom_port =
8419 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8420 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8421 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8423 cmdline_parse_token_string_t cmd_showeeprom_type =
8424 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8426 cmdline_parse_inst_t cmd_showeeprom = {
8427 .f = cmd_showeeprom_parsed,
8429 .help_str = "show port <port_id> module_eeprom|eeprom",
8431 (void *)&cmd_showeeprom_show,
8432 (void *)&cmd_showeeprom_port,
8433 (void *)&cmd_showeeprom_portnum,
8434 (void *)&cmd_showeeprom_type,
8439 /* *** SHOW QUEUE INFO *** */
8440 struct cmd_showqueue_result {
8441 cmdline_fixed_string_t show;
8442 cmdline_fixed_string_t type;
8443 cmdline_fixed_string_t what;
8449 cmd_showqueue_parsed(void *parsed_result,
8450 __rte_unused struct cmdline *cl,
8451 __rte_unused void *data)
8453 struct cmd_showqueue_result *res = parsed_result;
8455 if (!strcmp(res->type, "rxq"))
8456 rx_queue_infos_display(res->portnum, res->queuenum);
8457 else if (!strcmp(res->type, "txq"))
8458 tx_queue_infos_display(res->portnum, res->queuenum);
8461 cmdline_parse_token_string_t cmd_showqueue_show =
8462 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8463 cmdline_parse_token_string_t cmd_showqueue_type =
8464 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8465 cmdline_parse_token_string_t cmd_showqueue_what =
8466 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8467 cmdline_parse_token_num_t cmd_showqueue_portnum =
8468 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8470 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8471 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8474 cmdline_parse_inst_t cmd_showqueue = {
8475 .f = cmd_showqueue_parsed,
8477 .help_str = "show rxq|txq info <port_id> <queue_id>",
8479 (void *)&cmd_showqueue_show,
8480 (void *)&cmd_showqueue_type,
8481 (void *)&cmd_showqueue_what,
8482 (void *)&cmd_showqueue_portnum,
8483 (void *)&cmd_showqueue_queuenum,
8488 /* show/clear fwd engine statistics */
8490 cmdline_fixed_string_t action;
8491 cmdline_fixed_string_t fwd;
8492 cmdline_fixed_string_t stats;
8493 cmdline_fixed_string_t all;
8496 cmdline_parse_token_string_t cmd_fwd_action =
8497 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8498 cmdline_parse_token_string_t cmd_fwd_fwd =
8499 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8500 cmdline_parse_token_string_t cmd_fwd_stats =
8501 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8502 cmdline_parse_token_string_t cmd_fwd_all =
8503 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8506 cmd_showfwdall_parsed(void *parsed_result,
8507 __rte_unused struct cmdline *cl,
8508 __rte_unused void *data)
8510 struct fwd_result *res = parsed_result;
8512 if (!strcmp(res->action, "show"))
8513 fwd_stats_display();
8518 static cmdline_parse_inst_t cmd_showfwdall = {
8519 .f = cmd_showfwdall_parsed,
8521 .help_str = "show|clear fwd stats all",
8523 (void *)&cmd_fwd_action,
8524 (void *)&cmd_fwd_fwd,
8525 (void *)&cmd_fwd_stats,
8526 (void *)&cmd_fwd_all,
8531 /* *** READ PORT REGISTER *** */
8532 struct cmd_read_reg_result {
8533 cmdline_fixed_string_t read;
8534 cmdline_fixed_string_t reg;
8540 cmd_read_reg_parsed(void *parsed_result,
8541 __rte_unused struct cmdline *cl,
8542 __rte_unused void *data)
8544 struct cmd_read_reg_result *res = parsed_result;
8545 port_reg_display(res->port_id, res->reg_off);
8548 cmdline_parse_token_string_t cmd_read_reg_read =
8549 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8550 cmdline_parse_token_string_t cmd_read_reg_reg =
8551 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8552 cmdline_parse_token_num_t cmd_read_reg_port_id =
8553 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8554 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8555 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8557 cmdline_parse_inst_t cmd_read_reg = {
8558 .f = cmd_read_reg_parsed,
8560 .help_str = "read reg <port_id> <reg_off>",
8562 (void *)&cmd_read_reg_read,
8563 (void *)&cmd_read_reg_reg,
8564 (void *)&cmd_read_reg_port_id,
8565 (void *)&cmd_read_reg_reg_off,
8570 /* *** READ PORT REGISTER BIT FIELD *** */
8571 struct cmd_read_reg_bit_field_result {
8572 cmdline_fixed_string_t read;
8573 cmdline_fixed_string_t regfield;
8581 cmd_read_reg_bit_field_parsed(void *parsed_result,
8582 __rte_unused struct cmdline *cl,
8583 __rte_unused void *data)
8585 struct cmd_read_reg_bit_field_result *res = parsed_result;
8586 port_reg_bit_field_display(res->port_id, res->reg_off,
8587 res->bit1_pos, res->bit2_pos);
8590 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8591 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8593 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8594 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8595 regfield, "regfield");
8596 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8597 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8599 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8600 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8602 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8603 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8605 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8606 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8609 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8610 .f = cmd_read_reg_bit_field_parsed,
8612 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8613 "Read register bit field between bit_x and bit_y included",
8615 (void *)&cmd_read_reg_bit_field_read,
8616 (void *)&cmd_read_reg_bit_field_regfield,
8617 (void *)&cmd_read_reg_bit_field_port_id,
8618 (void *)&cmd_read_reg_bit_field_reg_off,
8619 (void *)&cmd_read_reg_bit_field_bit1_pos,
8620 (void *)&cmd_read_reg_bit_field_bit2_pos,
8625 /* *** READ PORT REGISTER BIT *** */
8626 struct cmd_read_reg_bit_result {
8627 cmdline_fixed_string_t read;
8628 cmdline_fixed_string_t regbit;
8635 cmd_read_reg_bit_parsed(void *parsed_result,
8636 __rte_unused struct cmdline *cl,
8637 __rte_unused void *data)
8639 struct cmd_read_reg_bit_result *res = parsed_result;
8640 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8643 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8644 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8645 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8646 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8648 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8649 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8651 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8652 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8654 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8655 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8658 cmdline_parse_inst_t cmd_read_reg_bit = {
8659 .f = cmd_read_reg_bit_parsed,
8661 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8663 (void *)&cmd_read_reg_bit_read,
8664 (void *)&cmd_read_reg_bit_regbit,
8665 (void *)&cmd_read_reg_bit_port_id,
8666 (void *)&cmd_read_reg_bit_reg_off,
8667 (void *)&cmd_read_reg_bit_bit_pos,
8672 /* *** WRITE PORT REGISTER *** */
8673 struct cmd_write_reg_result {
8674 cmdline_fixed_string_t write;
8675 cmdline_fixed_string_t reg;
8682 cmd_write_reg_parsed(void *parsed_result,
8683 __rte_unused struct cmdline *cl,
8684 __rte_unused void *data)
8686 struct cmd_write_reg_result *res = parsed_result;
8687 port_reg_set(res->port_id, res->reg_off, res->value);
8690 cmdline_parse_token_string_t cmd_write_reg_write =
8691 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8692 cmdline_parse_token_string_t cmd_write_reg_reg =
8693 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8694 cmdline_parse_token_num_t cmd_write_reg_port_id =
8695 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8696 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8697 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8698 cmdline_parse_token_num_t cmd_write_reg_value =
8699 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8701 cmdline_parse_inst_t cmd_write_reg = {
8702 .f = cmd_write_reg_parsed,
8704 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8706 (void *)&cmd_write_reg_write,
8707 (void *)&cmd_write_reg_reg,
8708 (void *)&cmd_write_reg_port_id,
8709 (void *)&cmd_write_reg_reg_off,
8710 (void *)&cmd_write_reg_value,
8715 /* *** WRITE PORT REGISTER BIT FIELD *** */
8716 struct cmd_write_reg_bit_field_result {
8717 cmdline_fixed_string_t write;
8718 cmdline_fixed_string_t regfield;
8727 cmd_write_reg_bit_field_parsed(void *parsed_result,
8728 __rte_unused struct cmdline *cl,
8729 __rte_unused void *data)
8731 struct cmd_write_reg_bit_field_result *res = parsed_result;
8732 port_reg_bit_field_set(res->port_id, res->reg_off,
8733 res->bit1_pos, res->bit2_pos, res->value);
8736 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8737 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8739 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8740 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8741 regfield, "regfield");
8742 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8743 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8745 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8746 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8748 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8749 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8751 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8752 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8754 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8755 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8758 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8759 .f = cmd_write_reg_bit_field_parsed,
8761 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8763 "Set register bit field between bit_x and bit_y included",
8765 (void *)&cmd_write_reg_bit_field_write,
8766 (void *)&cmd_write_reg_bit_field_regfield,
8767 (void *)&cmd_write_reg_bit_field_port_id,
8768 (void *)&cmd_write_reg_bit_field_reg_off,
8769 (void *)&cmd_write_reg_bit_field_bit1_pos,
8770 (void *)&cmd_write_reg_bit_field_bit2_pos,
8771 (void *)&cmd_write_reg_bit_field_value,
8776 /* *** WRITE PORT REGISTER BIT *** */
8777 struct cmd_write_reg_bit_result {
8778 cmdline_fixed_string_t write;
8779 cmdline_fixed_string_t regbit;
8787 cmd_write_reg_bit_parsed(void *parsed_result,
8788 __rte_unused struct cmdline *cl,
8789 __rte_unused void *data)
8791 struct cmd_write_reg_bit_result *res = parsed_result;
8792 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8795 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8796 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8798 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8799 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8801 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8802 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8804 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8805 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8807 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8808 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8810 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8811 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8814 cmdline_parse_inst_t cmd_write_reg_bit = {
8815 .f = cmd_write_reg_bit_parsed,
8817 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8820 (void *)&cmd_write_reg_bit_write,
8821 (void *)&cmd_write_reg_bit_regbit,
8822 (void *)&cmd_write_reg_bit_port_id,
8823 (void *)&cmd_write_reg_bit_reg_off,
8824 (void *)&cmd_write_reg_bit_bit_pos,
8825 (void *)&cmd_write_reg_bit_value,
8830 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8831 struct cmd_read_rxd_txd_result {
8832 cmdline_fixed_string_t read;
8833 cmdline_fixed_string_t rxd_txd;
8840 cmd_read_rxd_txd_parsed(void *parsed_result,
8841 __rte_unused struct cmdline *cl,
8842 __rte_unused void *data)
8844 struct cmd_read_rxd_txd_result *res = parsed_result;
8846 if (!strcmp(res->rxd_txd, "rxd"))
8847 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8848 else if (!strcmp(res->rxd_txd, "txd"))
8849 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8852 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8853 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8854 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8855 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8857 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8858 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8860 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8861 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8863 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8864 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8867 cmdline_parse_inst_t cmd_read_rxd_txd = {
8868 .f = cmd_read_rxd_txd_parsed,
8870 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8872 (void *)&cmd_read_rxd_txd_read,
8873 (void *)&cmd_read_rxd_txd_rxd_txd,
8874 (void *)&cmd_read_rxd_txd_port_id,
8875 (void *)&cmd_read_rxd_txd_queue_id,
8876 (void *)&cmd_read_rxd_txd_desc_id,
8882 struct cmd_quit_result {
8883 cmdline_fixed_string_t quit;
8886 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8888 __rte_unused void *data)
8893 cmdline_parse_token_string_t cmd_quit_quit =
8894 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8896 cmdline_parse_inst_t cmd_quit = {
8897 .f = cmd_quit_parsed,
8899 .help_str = "quit: Exit application",
8901 (void *)&cmd_quit_quit,
8906 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8907 struct cmd_mac_addr_result {
8908 cmdline_fixed_string_t mac_addr_cmd;
8909 cmdline_fixed_string_t what;
8911 struct rte_ether_addr address;
8914 static void cmd_mac_addr_parsed(void *parsed_result,
8915 __rte_unused struct cmdline *cl,
8916 __rte_unused void *data)
8918 struct cmd_mac_addr_result *res = parsed_result;
8921 if (strcmp(res->what, "add") == 0)
8922 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8923 else if (strcmp(res->what, "set") == 0)
8924 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8927 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8929 /* check the return value and print it if is < 0 */
8931 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8935 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8936 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8938 cmdline_parse_token_string_t cmd_mac_addr_what =
8939 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8941 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8942 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8944 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8945 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8947 cmdline_parse_inst_t cmd_mac_addr = {
8948 .f = cmd_mac_addr_parsed,
8950 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8951 "Add/Remove/Set MAC address on port_id",
8953 (void *)&cmd_mac_addr_cmd,
8954 (void *)&cmd_mac_addr_what,
8955 (void *)&cmd_mac_addr_portnum,
8956 (void *)&cmd_mac_addr_addr,
8961 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8962 struct cmd_eth_peer_result {
8963 cmdline_fixed_string_t set;
8964 cmdline_fixed_string_t eth_peer;
8966 cmdline_fixed_string_t peer_addr;
8969 static void cmd_set_eth_peer_parsed(void *parsed_result,
8970 __rte_unused struct cmdline *cl,
8971 __rte_unused void *data)
8973 struct cmd_eth_peer_result *res = parsed_result;
8975 if (test_done == 0) {
8976 fprintf(stderr, "Please stop forwarding first\n");
8979 if (!strcmp(res->eth_peer, "eth-peer")) {
8980 set_fwd_eth_peer(res->port_id, res->peer_addr);
8984 cmdline_parse_token_string_t cmd_eth_peer_set =
8985 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8986 cmdline_parse_token_string_t cmd_eth_peer =
8987 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8988 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8989 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8991 cmdline_parse_token_string_t cmd_eth_peer_addr =
8992 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8994 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8995 .f = cmd_set_eth_peer_parsed,
8997 .help_str = "set eth-peer <port_id> <peer_mac>",
8999 (void *)&cmd_eth_peer_set,
9000 (void *)&cmd_eth_peer,
9001 (void *)&cmd_eth_peer_port_id,
9002 (void *)&cmd_eth_peer_addr,
9007 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
9008 struct cmd_set_qmap_result {
9009 cmdline_fixed_string_t set;
9010 cmdline_fixed_string_t qmap;
9011 cmdline_fixed_string_t what;
9018 cmd_set_qmap_parsed(void *parsed_result,
9019 __rte_unused struct cmdline *cl,
9020 __rte_unused void *data)
9022 struct cmd_set_qmap_result *res = parsed_result;
9023 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
9025 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
9028 cmdline_parse_token_string_t cmd_setqmap_set =
9029 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9031 cmdline_parse_token_string_t cmd_setqmap_qmap =
9032 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9034 cmdline_parse_token_string_t cmd_setqmap_what =
9035 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9037 cmdline_parse_token_num_t cmd_setqmap_portid =
9038 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9039 port_id, RTE_UINT16);
9040 cmdline_parse_token_num_t cmd_setqmap_queueid =
9041 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9042 queue_id, RTE_UINT16);
9043 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
9044 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9045 map_value, RTE_UINT8);
9047 cmdline_parse_inst_t cmd_set_qmap = {
9048 .f = cmd_set_qmap_parsed,
9050 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
9051 "Set statistics mapping value on tx|rx queue_id of port_id",
9053 (void *)&cmd_setqmap_set,
9054 (void *)&cmd_setqmap_qmap,
9055 (void *)&cmd_setqmap_what,
9056 (void *)&cmd_setqmap_portid,
9057 (void *)&cmd_setqmap_queueid,
9058 (void *)&cmd_setqmap_mapvalue,
9063 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
9064 struct cmd_set_xstats_hide_zero_result {
9065 cmdline_fixed_string_t keyword;
9066 cmdline_fixed_string_t name;
9067 cmdline_fixed_string_t on_off;
9071 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
9072 __rte_unused struct cmdline *cl,
9073 __rte_unused void *data)
9075 struct cmd_set_xstats_hide_zero_result *res;
9076 uint16_t on_off = 0;
9078 res = parsed_result;
9079 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9080 set_xstats_hide_zero(on_off);
9083 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
9084 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9086 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
9087 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9088 name, "xstats-hide-zero");
9089 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
9090 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9093 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
9094 .f = cmd_set_xstats_hide_zero_parsed,
9096 .help_str = "set xstats-hide-zero on|off",
9098 (void *)&cmd_set_xstats_hide_zero_keyword,
9099 (void *)&cmd_set_xstats_hide_zero_name,
9100 (void *)&cmd_set_xstats_hide_zero_on_off,
9105 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
9106 struct cmd_set_record_core_cycles_result {
9107 cmdline_fixed_string_t keyword;
9108 cmdline_fixed_string_t name;
9109 cmdline_fixed_string_t on_off;
9113 cmd_set_record_core_cycles_parsed(void *parsed_result,
9114 __rte_unused struct cmdline *cl,
9115 __rte_unused void *data)
9117 struct cmd_set_record_core_cycles_result *res;
9118 uint16_t on_off = 0;
9120 res = parsed_result;
9121 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9122 set_record_core_cycles(on_off);
9125 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
9126 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9128 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
9129 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9130 name, "record-core-cycles");
9131 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
9132 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9135 cmdline_parse_inst_t cmd_set_record_core_cycles = {
9136 .f = cmd_set_record_core_cycles_parsed,
9138 .help_str = "set record-core-cycles on|off",
9140 (void *)&cmd_set_record_core_cycles_keyword,
9141 (void *)&cmd_set_record_core_cycles_name,
9142 (void *)&cmd_set_record_core_cycles_on_off,
9147 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9148 struct cmd_set_record_burst_stats_result {
9149 cmdline_fixed_string_t keyword;
9150 cmdline_fixed_string_t name;
9151 cmdline_fixed_string_t on_off;
9155 cmd_set_record_burst_stats_parsed(void *parsed_result,
9156 __rte_unused struct cmdline *cl,
9157 __rte_unused void *data)
9159 struct cmd_set_record_burst_stats_result *res;
9160 uint16_t on_off = 0;
9162 res = parsed_result;
9163 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9164 set_record_burst_stats(on_off);
9167 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9168 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9170 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9171 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9172 name, "record-burst-stats");
9173 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9174 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9177 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9178 .f = cmd_set_record_burst_stats_parsed,
9180 .help_str = "set record-burst-stats on|off",
9182 (void *)&cmd_set_record_burst_stats_keyword,
9183 (void *)&cmd_set_record_burst_stats_name,
9184 (void *)&cmd_set_record_burst_stats_on_off,
9189 /* *** CONFIGURE UNICAST HASH TABLE *** */
9190 struct cmd_set_uc_hash_table {
9191 cmdline_fixed_string_t set;
9192 cmdline_fixed_string_t port;
9194 cmdline_fixed_string_t what;
9195 struct rte_ether_addr address;
9196 cmdline_fixed_string_t mode;
9200 cmd_set_uc_hash_parsed(void *parsed_result,
9201 __rte_unused struct cmdline *cl,
9202 __rte_unused void *data)
9205 struct cmd_set_uc_hash_table *res = parsed_result;
9207 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9209 if (strcmp(res->what, "uta") == 0)
9210 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9211 &res->address,(uint8_t)is_on);
9214 "bad unicast hash table parameter, return code = %d\n",
9219 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9220 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9222 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9223 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9225 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9226 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9227 port_id, RTE_UINT16);
9228 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9229 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9231 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9232 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9234 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9235 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9238 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9239 .f = cmd_set_uc_hash_parsed,
9241 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9243 (void *)&cmd_set_uc_hash_set,
9244 (void *)&cmd_set_uc_hash_port,
9245 (void *)&cmd_set_uc_hash_portid,
9246 (void *)&cmd_set_uc_hash_what,
9247 (void *)&cmd_set_uc_hash_mac,
9248 (void *)&cmd_set_uc_hash_mode,
9253 struct cmd_set_uc_all_hash_table {
9254 cmdline_fixed_string_t set;
9255 cmdline_fixed_string_t port;
9257 cmdline_fixed_string_t what;
9258 cmdline_fixed_string_t value;
9259 cmdline_fixed_string_t mode;
9263 cmd_set_uc_all_hash_parsed(void *parsed_result,
9264 __rte_unused struct cmdline *cl,
9265 __rte_unused void *data)
9268 struct cmd_set_uc_all_hash_table *res = parsed_result;
9270 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9272 if ((strcmp(res->what, "uta") == 0) &&
9273 (strcmp(res->value, "all") == 0))
9274 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9277 "bad unicast hash table parameter, return code = %d\n",
9281 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9282 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9284 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9285 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9287 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9288 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9289 port_id, RTE_UINT16);
9290 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9291 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9293 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9294 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9296 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9297 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9300 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9301 .f = cmd_set_uc_all_hash_parsed,
9303 .help_str = "set port <port_id> uta all on|off",
9305 (void *)&cmd_set_uc_all_hash_set,
9306 (void *)&cmd_set_uc_all_hash_port,
9307 (void *)&cmd_set_uc_all_hash_portid,
9308 (void *)&cmd_set_uc_all_hash_what,
9309 (void *)&cmd_set_uc_all_hash_value,
9310 (void *)&cmd_set_uc_all_hash_mode,
9315 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9316 struct cmd_set_vf_traffic {
9317 cmdline_fixed_string_t set;
9318 cmdline_fixed_string_t port;
9320 cmdline_fixed_string_t vf;
9322 cmdline_fixed_string_t what;
9323 cmdline_fixed_string_t mode;
9327 cmd_set_vf_traffic_parsed(void *parsed_result,
9328 __rte_unused struct cmdline *cl,
9329 __rte_unused void *data)
9331 struct cmd_set_vf_traffic *res = parsed_result;
9332 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9333 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9335 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9338 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9339 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9341 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9342 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9344 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9345 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9346 port_id, RTE_UINT16);
9347 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9348 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9350 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9351 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9353 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9354 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9356 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9357 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9360 cmdline_parse_inst_t cmd_set_vf_traffic = {
9361 .f = cmd_set_vf_traffic_parsed,
9363 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9365 (void *)&cmd_setvf_traffic_set,
9366 (void *)&cmd_setvf_traffic_port,
9367 (void *)&cmd_setvf_traffic_portid,
9368 (void *)&cmd_setvf_traffic_vf,
9369 (void *)&cmd_setvf_traffic_vfid,
9370 (void *)&cmd_setvf_traffic_what,
9371 (void *)&cmd_setvf_traffic_mode,
9376 /* *** CONFIGURE VF RECEIVE MODE *** */
9377 struct cmd_set_vf_rxmode {
9378 cmdline_fixed_string_t set;
9379 cmdline_fixed_string_t port;
9381 cmdline_fixed_string_t vf;
9383 cmdline_fixed_string_t what;
9384 cmdline_fixed_string_t mode;
9385 cmdline_fixed_string_t on;
9389 cmd_set_vf_rxmode_parsed(void *parsed_result,
9390 __rte_unused struct cmdline *cl,
9391 __rte_unused void *data)
9394 uint16_t vf_rxmode = 0;
9395 struct cmd_set_vf_rxmode *res = parsed_result;
9397 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9398 if (!strcmp(res->what,"rxmode")) {
9399 if (!strcmp(res->mode, "AUPE"))
9400 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9401 else if (!strcmp(res->mode, "ROPE"))
9402 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9403 else if (!strcmp(res->mode, "BAM"))
9404 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9405 else if (!strncmp(res->mode, "MPE",3))
9406 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9409 RTE_SET_USED(is_on);
9411 #ifdef RTE_NET_IXGBE
9412 if (ret == -ENOTSUP)
9413 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9414 vf_rxmode, (uint8_t)is_on);
9417 if (ret == -ENOTSUP)
9418 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9419 vf_rxmode, (uint8_t)is_on);
9423 "bad VF receive mode parameter, return code = %d\n",
9427 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9428 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9430 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9431 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9433 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9434 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9435 port_id, RTE_UINT16);
9436 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9437 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9439 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9440 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9442 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9443 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9445 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9446 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9447 mode, "AUPE#ROPE#BAM#MPE");
9448 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9449 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9452 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9453 .f = cmd_set_vf_rxmode_parsed,
9455 .help_str = "set port <port_id> vf <vf_id> rxmode "
9456 "AUPE|ROPE|BAM|MPE on|off",
9458 (void *)&cmd_set_vf_rxmode_set,
9459 (void *)&cmd_set_vf_rxmode_port,
9460 (void *)&cmd_set_vf_rxmode_portid,
9461 (void *)&cmd_set_vf_rxmode_vf,
9462 (void *)&cmd_set_vf_rxmode_vfid,
9463 (void *)&cmd_set_vf_rxmode_what,
9464 (void *)&cmd_set_vf_rxmode_mode,
9465 (void *)&cmd_set_vf_rxmode_on,
9470 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9471 struct cmd_vf_mac_addr_result {
9472 cmdline_fixed_string_t mac_addr_cmd;
9473 cmdline_fixed_string_t what;
9474 cmdline_fixed_string_t port;
9476 cmdline_fixed_string_t vf;
9478 struct rte_ether_addr address;
9481 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9482 __rte_unused struct cmdline *cl,
9483 __rte_unused void *data)
9485 struct cmd_vf_mac_addr_result *res = parsed_result;
9488 if (strcmp(res->what, "add") != 0)
9492 if (ret == -ENOTSUP)
9493 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9497 if (ret == -ENOTSUP)
9498 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9503 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9507 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9508 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9509 mac_addr_cmd,"mac_addr");
9510 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9511 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9513 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9514 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9516 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9517 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9518 port_num, RTE_UINT16);
9519 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9520 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9522 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9523 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9525 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9526 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9529 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9530 .f = cmd_vf_mac_addr_parsed,
9532 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9533 "Add MAC address filtering for a VF on port_id",
9535 (void *)&cmd_vf_mac_addr_cmd,
9536 (void *)&cmd_vf_mac_addr_what,
9537 (void *)&cmd_vf_mac_addr_port,
9538 (void *)&cmd_vf_mac_addr_portnum,
9539 (void *)&cmd_vf_mac_addr_vf,
9540 (void *)&cmd_vf_mac_addr_vfnum,
9541 (void *)&cmd_vf_mac_addr_addr,
9546 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9547 struct cmd_vf_rx_vlan_filter {
9548 cmdline_fixed_string_t rx_vlan;
9549 cmdline_fixed_string_t what;
9551 cmdline_fixed_string_t port;
9553 cmdline_fixed_string_t vf;
9558 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9559 __rte_unused struct cmdline *cl,
9560 __rte_unused void *data)
9562 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9565 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9567 #ifdef RTE_NET_IXGBE
9568 if (ret == -ENOTSUP)
9569 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9570 res->vlan_id, res->vf_mask, is_add);
9573 if (ret == -ENOTSUP)
9574 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9575 res->vlan_id, res->vf_mask, is_add);
9578 if (ret == -ENOTSUP)
9579 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9580 res->vlan_id, res->vf_mask, is_add);
9587 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9588 res->vlan_id, res->vf_mask);
9591 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9594 fprintf(stderr, "function not implemented or supported\n");
9597 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9601 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9602 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9603 rx_vlan, "rx_vlan");
9604 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9605 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9607 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9608 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9609 vlan_id, RTE_UINT16);
9610 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9611 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9613 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9614 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9615 port_id, RTE_UINT16);
9616 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9617 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9619 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9620 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9621 vf_mask, RTE_UINT64);
9623 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9624 .f = cmd_vf_rx_vlan_filter_parsed,
9626 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9627 "(vf_mask = hexadecimal VF mask)",
9629 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9630 (void *)&cmd_vf_rx_vlan_filter_what,
9631 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9632 (void *)&cmd_vf_rx_vlan_filter_port,
9633 (void *)&cmd_vf_rx_vlan_filter_portid,
9634 (void *)&cmd_vf_rx_vlan_filter_vf,
9635 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9640 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9641 struct cmd_queue_rate_limit_result {
9642 cmdline_fixed_string_t set;
9643 cmdline_fixed_string_t port;
9645 cmdline_fixed_string_t queue;
9647 cmdline_fixed_string_t rate;
9651 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9652 __rte_unused struct cmdline *cl,
9653 __rte_unused void *data)
9655 struct cmd_queue_rate_limit_result *res = parsed_result;
9658 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9659 && (strcmp(res->queue, "queue") == 0)
9660 && (strcmp(res->rate, "rate") == 0))
9661 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9664 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9669 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9670 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9672 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9673 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9675 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9676 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9677 port_num, RTE_UINT16);
9678 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9679 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9681 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9682 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9683 queue_num, RTE_UINT8);
9684 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9685 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9687 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9688 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9689 rate_num, RTE_UINT16);
9691 cmdline_parse_inst_t cmd_queue_rate_limit = {
9692 .f = cmd_queue_rate_limit_parsed,
9694 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9695 "Set rate limit for a queue on port_id",
9697 (void *)&cmd_queue_rate_limit_set,
9698 (void *)&cmd_queue_rate_limit_port,
9699 (void *)&cmd_queue_rate_limit_portnum,
9700 (void *)&cmd_queue_rate_limit_queue,
9701 (void *)&cmd_queue_rate_limit_queuenum,
9702 (void *)&cmd_queue_rate_limit_rate,
9703 (void *)&cmd_queue_rate_limit_ratenum,
9708 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9709 struct cmd_vf_rate_limit_result {
9710 cmdline_fixed_string_t set;
9711 cmdline_fixed_string_t port;
9713 cmdline_fixed_string_t vf;
9715 cmdline_fixed_string_t rate;
9717 cmdline_fixed_string_t q_msk;
9721 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9722 __rte_unused struct cmdline *cl,
9723 __rte_unused void *data)
9725 struct cmd_vf_rate_limit_result *res = parsed_result;
9728 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9729 && (strcmp(res->vf, "vf") == 0)
9730 && (strcmp(res->rate, "rate") == 0)
9731 && (strcmp(res->q_msk, "queue_mask") == 0))
9732 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9733 res->rate_num, res->q_msk_val);
9735 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9740 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9741 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9743 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9744 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9746 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9747 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9748 port_num, RTE_UINT16);
9749 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9750 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9752 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9753 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9755 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9756 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9758 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9759 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9760 rate_num, RTE_UINT16);
9761 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9762 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9763 q_msk, "queue_mask");
9764 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9765 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9766 q_msk_val, RTE_UINT64);
9768 cmdline_parse_inst_t cmd_vf_rate_limit = {
9769 .f = cmd_vf_rate_limit_parsed,
9771 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9772 "queue_mask <queue_mask_value>: "
9773 "Set rate limit for queues of VF on port_id",
9775 (void *)&cmd_vf_rate_limit_set,
9776 (void *)&cmd_vf_rate_limit_port,
9777 (void *)&cmd_vf_rate_limit_portnum,
9778 (void *)&cmd_vf_rate_limit_vf,
9779 (void *)&cmd_vf_rate_limit_vfnum,
9780 (void *)&cmd_vf_rate_limit_rate,
9781 (void *)&cmd_vf_rate_limit_ratenum,
9782 (void *)&cmd_vf_rate_limit_q_msk,
9783 (void *)&cmd_vf_rate_limit_q_msk_val,
9788 /* *** CONFIGURE TUNNEL UDP PORT *** */
9789 struct cmd_tunnel_udp_config {
9790 cmdline_fixed_string_t rx_vxlan_port;
9791 cmdline_fixed_string_t what;
9797 cmd_tunnel_udp_config_parsed(void *parsed_result,
9798 __rte_unused struct cmdline *cl,
9799 __rte_unused void *data)
9801 struct cmd_tunnel_udp_config *res = parsed_result;
9802 struct rte_eth_udp_tunnel tunnel_udp;
9805 tunnel_udp.udp_port = res->udp_port;
9806 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9808 if (!strcmp(res->what, "add"))
9809 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9812 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9816 fprintf(stderr, "udp tunneling add error: (%s)\n",
9820 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9821 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9822 rx_vxlan_port, "rx_vxlan_port");
9823 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9824 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9826 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9827 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9828 udp_port, RTE_UINT16);
9829 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9830 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9831 port_id, RTE_UINT16);
9833 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9834 .f = cmd_tunnel_udp_config_parsed,
9836 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9837 "Add/Remove a tunneling UDP port filter",
9839 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9840 (void *)&cmd_tunnel_udp_config_what,
9841 (void *)&cmd_tunnel_udp_config_udp_port,
9842 (void *)&cmd_tunnel_udp_config_port_id,
9847 struct cmd_config_tunnel_udp_port {
9848 cmdline_fixed_string_t port;
9849 cmdline_fixed_string_t config;
9851 cmdline_fixed_string_t udp_tunnel_port;
9852 cmdline_fixed_string_t action;
9853 cmdline_fixed_string_t tunnel_type;
9858 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9859 __rte_unused struct cmdline *cl,
9860 __rte_unused void *data)
9862 struct cmd_config_tunnel_udp_port *res = parsed_result;
9863 struct rte_eth_udp_tunnel tunnel_udp;
9866 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9869 tunnel_udp.udp_port = res->udp_port;
9871 if (!strcmp(res->tunnel_type, "vxlan")) {
9872 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9873 } else if (!strcmp(res->tunnel_type, "geneve")) {
9874 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9875 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9876 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9877 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9878 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9880 fprintf(stderr, "Invalid tunnel type\n");
9884 if (!strcmp(res->action, "add"))
9885 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9888 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9892 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9896 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9897 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9899 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9900 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9902 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9903 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9905 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9906 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9909 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9910 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9912 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9913 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9914 "vxlan#geneve#vxlan-gpe#ecpri");
9915 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9916 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9919 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9920 .f = cmd_cfg_tunnel_udp_port_parsed,
9922 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9923 "geneve|vxlan-gpe|ecpri <udp_port>",
9925 (void *)&cmd_config_tunnel_udp_port_port,
9926 (void *)&cmd_config_tunnel_udp_port_config,
9927 (void *)&cmd_config_tunnel_udp_port_port_id,
9928 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9929 (void *)&cmd_config_tunnel_udp_port_action,
9930 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9931 (void *)&cmd_config_tunnel_udp_port_value,
9936 /* ******************************************************************************** */
9938 struct cmd_dump_result {
9939 cmdline_fixed_string_t dump;
9943 dump_struct_sizes(void)
9945 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9946 DUMP_SIZE(struct rte_mbuf);
9947 DUMP_SIZE(struct rte_mempool);
9948 DUMP_SIZE(struct rte_ring);
9953 /* Dump the socket memory statistics on console */
9955 dump_socket_mem(FILE *f)
9957 struct rte_malloc_socket_stats socket_stats;
9962 unsigned int n_alloc = 0;
9963 unsigned int n_free = 0;
9964 static size_t last_allocs;
9965 static size_t last_total;
9968 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9969 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9970 !socket_stats.heap_totalsz_bytes)
9972 total += socket_stats.heap_totalsz_bytes;
9973 alloc += socket_stats.heap_allocsz_bytes;
9974 free += socket_stats.heap_freesz_bytes;
9975 n_alloc += socket_stats.alloc_count;
9976 n_free += socket_stats.free_count;
9978 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9980 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9981 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9982 (double)socket_stats.heap_allocsz_bytes * 100 /
9983 (double)socket_stats.heap_totalsz_bytes,
9984 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9985 socket_stats.alloc_count,
9986 socket_stats.free_count);
9989 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9990 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9991 total ? ((double)alloc * 100 / (double)total) : 0,
9992 (double)free / (1024 * 1024),
9995 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9996 ((double)total - (double)last_total) / (1024 * 1024),
9997 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9998 last_allocs = alloc;
10002 static void cmd_dump_parsed(void *parsed_result,
10003 __rte_unused struct cmdline *cl,
10004 __rte_unused void *data)
10006 struct cmd_dump_result *res = parsed_result;
10008 if (!strcmp(res->dump, "dump_physmem"))
10009 rte_dump_physmem_layout(stdout);
10010 else if (!strcmp(res->dump, "dump_socket_mem"))
10011 dump_socket_mem(stdout);
10012 else if (!strcmp(res->dump, "dump_memzone"))
10013 rte_memzone_dump(stdout);
10014 else if (!strcmp(res->dump, "dump_struct_sizes"))
10015 dump_struct_sizes();
10016 else if (!strcmp(res->dump, "dump_ring"))
10017 rte_ring_list_dump(stdout);
10018 else if (!strcmp(res->dump, "dump_mempool"))
10019 rte_mempool_list_dump(stdout);
10020 else if (!strcmp(res->dump, "dump_devargs"))
10021 rte_devargs_dump(stdout);
10022 else if (!strcmp(res->dump, "dump_log_types"))
10023 rte_log_dump(stdout);
10026 cmdline_parse_token_string_t cmd_dump_dump =
10027 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
10031 "dump_struct_sizes#"
10037 cmdline_parse_inst_t cmd_dump = {
10038 .f = cmd_dump_parsed, /* function to call */
10039 .data = NULL, /* 2nd arg of func */
10040 .help_str = "Dump status",
10041 .tokens = { /* token list, NULL terminated */
10042 (void *)&cmd_dump_dump,
10047 /* ******************************************************************************** */
10049 struct cmd_dump_one_result {
10050 cmdline_fixed_string_t dump;
10051 cmdline_fixed_string_t name;
10054 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
10055 __rte_unused void *data)
10057 struct cmd_dump_one_result *res = parsed_result;
10059 if (!strcmp(res->dump, "dump_ring")) {
10060 struct rte_ring *r;
10061 r = rte_ring_lookup(res->name);
10063 cmdline_printf(cl, "Cannot find ring\n");
10066 rte_ring_dump(stdout, r);
10067 } else if (!strcmp(res->dump, "dump_mempool")) {
10068 struct rte_mempool *mp;
10069 mp = rte_mempool_lookup(res->name);
10071 cmdline_printf(cl, "Cannot find mempool\n");
10074 rte_mempool_dump(stdout, mp);
10078 cmdline_parse_token_string_t cmd_dump_one_dump =
10079 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
10080 "dump_ring#dump_mempool");
10082 cmdline_parse_token_string_t cmd_dump_one_name =
10083 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
10085 cmdline_parse_inst_t cmd_dump_one = {
10086 .f = cmd_dump_one_parsed, /* function to call */
10087 .data = NULL, /* 2nd arg of func */
10088 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
10089 .tokens = { /* token list, NULL terminated */
10090 (void *)&cmd_dump_one_dump,
10091 (void *)&cmd_dump_one_name,
10096 /* *** queue region set *** */
10097 struct cmd_queue_region_result {
10098 cmdline_fixed_string_t set;
10099 cmdline_fixed_string_t port;
10101 cmdline_fixed_string_t cmd;
10102 cmdline_fixed_string_t region;
10104 cmdline_fixed_string_t queue_start_index;
10106 cmdline_fixed_string_t queue_num;
10107 uint8_t queue_num_value;
10111 cmd_queue_region_parsed(void *parsed_result,
10112 __rte_unused struct cmdline *cl,
10113 __rte_unused void *data)
10115 struct cmd_queue_region_result *res = parsed_result;
10116 int ret = -ENOTSUP;
10117 #ifdef RTE_NET_I40E
10118 struct rte_pmd_i40e_queue_region_conf region_conf;
10119 enum rte_pmd_i40e_queue_region_op op_type;
10122 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10125 #ifdef RTE_NET_I40E
10126 memset(®ion_conf, 0, sizeof(region_conf));
10127 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10128 region_conf.region_id = res->region_id;
10129 region_conf.queue_num = res->queue_num_value;
10130 region_conf.queue_start_index = res->queue_id;
10132 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10133 op_type, ®ion_conf);
10140 fprintf(stderr, "function not implemented or supported\n");
10143 fprintf(stderr, "queue region config error: (%s)\n",
10148 cmdline_parse_token_string_t cmd_queue_region_set =
10149 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10151 cmdline_parse_token_string_t cmd_queue_region_port =
10152 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10153 cmdline_parse_token_num_t cmd_queue_region_port_id =
10154 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10155 port_id, RTE_UINT16);
10156 cmdline_parse_token_string_t cmd_queue_region_cmd =
10157 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10158 cmd, "queue-region");
10159 cmdline_parse_token_string_t cmd_queue_region_id =
10160 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10161 region, "region_id");
10162 cmdline_parse_token_num_t cmd_queue_region_index =
10163 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10164 region_id, RTE_UINT8);
10165 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10166 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10167 queue_start_index, "queue_start_index");
10168 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10169 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10170 queue_id, RTE_UINT8);
10171 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10172 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10173 queue_num, "queue_num");
10174 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10175 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10176 queue_num_value, RTE_UINT8);
10178 cmdline_parse_inst_t cmd_queue_region = {
10179 .f = cmd_queue_region_parsed,
10181 .help_str = "set port <port_id> queue-region region_id <value> "
10182 "queue_start_index <value> queue_num <value>: Set a queue region",
10184 (void *)&cmd_queue_region_set,
10185 (void *)&cmd_queue_region_port,
10186 (void *)&cmd_queue_region_port_id,
10187 (void *)&cmd_queue_region_cmd,
10188 (void *)&cmd_queue_region_id,
10189 (void *)&cmd_queue_region_index,
10190 (void *)&cmd_queue_region_queue_start_index,
10191 (void *)&cmd_queue_region_queue_id,
10192 (void *)&cmd_queue_region_queue_num,
10193 (void *)&cmd_queue_region_queue_num_value,
10198 /* *** queue region and flowtype set *** */
10199 struct cmd_region_flowtype_result {
10200 cmdline_fixed_string_t set;
10201 cmdline_fixed_string_t port;
10203 cmdline_fixed_string_t cmd;
10204 cmdline_fixed_string_t region;
10206 cmdline_fixed_string_t flowtype;
10207 uint8_t flowtype_id;
10211 cmd_region_flowtype_parsed(void *parsed_result,
10212 __rte_unused struct cmdline *cl,
10213 __rte_unused void *data)
10215 struct cmd_region_flowtype_result *res = parsed_result;
10216 int ret = -ENOTSUP;
10217 #ifdef RTE_NET_I40E
10218 struct rte_pmd_i40e_queue_region_conf region_conf;
10219 enum rte_pmd_i40e_queue_region_op op_type;
10222 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10225 #ifdef RTE_NET_I40E
10226 memset(®ion_conf, 0, sizeof(region_conf));
10228 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10229 region_conf.region_id = res->region_id;
10230 region_conf.hw_flowtype = res->flowtype_id;
10232 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10233 op_type, ®ion_conf);
10240 fprintf(stderr, "function not implemented or supported\n");
10243 fprintf(stderr, "region flowtype config error: (%s)\n",
10248 cmdline_parse_token_string_t cmd_region_flowtype_set =
10249 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10251 cmdline_parse_token_string_t cmd_region_flowtype_port =
10252 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10254 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10255 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10256 port_id, RTE_UINT16);
10257 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10258 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10259 cmd, "queue-region");
10260 cmdline_parse_token_string_t cmd_region_flowtype_index =
10261 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10262 region, "region_id");
10263 cmdline_parse_token_num_t cmd_region_flowtype_id =
10264 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10265 region_id, RTE_UINT8);
10266 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10267 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10268 flowtype, "flowtype");
10269 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10270 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10271 flowtype_id, RTE_UINT8);
10272 cmdline_parse_inst_t cmd_region_flowtype = {
10273 .f = cmd_region_flowtype_parsed,
10275 .help_str = "set port <port_id> queue-region region_id <value> "
10276 "flowtype <value>: Set a flowtype region index",
10278 (void *)&cmd_region_flowtype_set,
10279 (void *)&cmd_region_flowtype_port,
10280 (void *)&cmd_region_flowtype_port_index,
10281 (void *)&cmd_region_flowtype_cmd,
10282 (void *)&cmd_region_flowtype_index,
10283 (void *)&cmd_region_flowtype_id,
10284 (void *)&cmd_region_flowtype_flow_index,
10285 (void *)&cmd_region_flowtype_flow_id,
10290 /* *** User Priority (UP) to queue region (region_id) set *** */
10291 struct cmd_user_priority_region_result {
10292 cmdline_fixed_string_t set;
10293 cmdline_fixed_string_t port;
10295 cmdline_fixed_string_t cmd;
10296 cmdline_fixed_string_t user_priority;
10297 uint8_t user_priority_id;
10298 cmdline_fixed_string_t region;
10303 cmd_user_priority_region_parsed(void *parsed_result,
10304 __rte_unused struct cmdline *cl,
10305 __rte_unused void *data)
10307 struct cmd_user_priority_region_result *res = parsed_result;
10308 int ret = -ENOTSUP;
10309 #ifdef RTE_NET_I40E
10310 struct rte_pmd_i40e_queue_region_conf region_conf;
10311 enum rte_pmd_i40e_queue_region_op op_type;
10314 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10317 #ifdef RTE_NET_I40E
10318 memset(®ion_conf, 0, sizeof(region_conf));
10319 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10320 region_conf.user_priority = res->user_priority_id;
10321 region_conf.region_id = res->region_id;
10323 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10324 op_type, ®ion_conf);
10331 fprintf(stderr, "function not implemented or supported\n");
10334 fprintf(stderr, "user_priority region config error: (%s)\n",
10339 cmdline_parse_token_string_t cmd_user_priority_region_set =
10340 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10342 cmdline_parse_token_string_t cmd_user_priority_region_port =
10343 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10345 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10346 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10347 port_id, RTE_UINT16);
10348 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10349 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10350 cmd, "queue-region");
10351 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10352 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10353 user_priority, "UP");
10354 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10355 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10356 user_priority_id, RTE_UINT8);
10357 cmdline_parse_token_string_t cmd_user_priority_region_region =
10358 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10359 region, "region_id");
10360 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10361 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10362 region_id, RTE_UINT8);
10364 cmdline_parse_inst_t cmd_user_priority_region = {
10365 .f = cmd_user_priority_region_parsed,
10367 .help_str = "set port <port_id> queue-region UP <value> "
10368 "region_id <value>: Set the mapping of User Priority (UP) "
10369 "to queue region (region_id) ",
10371 (void *)&cmd_user_priority_region_set,
10372 (void *)&cmd_user_priority_region_port,
10373 (void *)&cmd_user_priority_region_port_index,
10374 (void *)&cmd_user_priority_region_cmd,
10375 (void *)&cmd_user_priority_region_UP,
10376 (void *)&cmd_user_priority_region_UP_id,
10377 (void *)&cmd_user_priority_region_region,
10378 (void *)&cmd_user_priority_region_region_id,
10383 /* *** flush all queue region related configuration *** */
10384 struct cmd_flush_queue_region_result {
10385 cmdline_fixed_string_t set;
10386 cmdline_fixed_string_t port;
10388 cmdline_fixed_string_t cmd;
10389 cmdline_fixed_string_t flush;
10390 cmdline_fixed_string_t what;
10394 cmd_flush_queue_region_parsed(void *parsed_result,
10395 __rte_unused struct cmdline *cl,
10396 __rte_unused void *data)
10398 struct cmd_flush_queue_region_result *res = parsed_result;
10399 int ret = -ENOTSUP;
10400 #ifdef RTE_NET_I40E
10401 struct rte_pmd_i40e_queue_region_conf region_conf;
10402 enum rte_pmd_i40e_queue_region_op op_type;
10405 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10408 #ifdef RTE_NET_I40E
10409 memset(®ion_conf, 0, sizeof(region_conf));
10411 if (strcmp(res->what, "on") == 0)
10412 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10414 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10416 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10417 op_type, ®ion_conf);
10424 fprintf(stderr, "function not implemented or supported\n");
10427 fprintf(stderr, "queue region config flush error: (%s)\n",
10432 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10433 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10435 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10436 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10438 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10439 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10440 port_id, RTE_UINT16);
10441 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10442 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10443 cmd, "queue-region");
10444 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10445 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10447 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10448 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10451 cmdline_parse_inst_t cmd_flush_queue_region = {
10452 .f = cmd_flush_queue_region_parsed,
10454 .help_str = "set port <port_id> queue-region flush on|off"
10455 ": flush all queue region related configuration",
10457 (void *)&cmd_flush_queue_region_set,
10458 (void *)&cmd_flush_queue_region_port,
10459 (void *)&cmd_flush_queue_region_port_index,
10460 (void *)&cmd_flush_queue_region_cmd,
10461 (void *)&cmd_flush_queue_region_flush,
10462 (void *)&cmd_flush_queue_region_what,
10467 /* *** get all queue region related configuration info *** */
10468 struct cmd_show_queue_region_info {
10469 cmdline_fixed_string_t show;
10470 cmdline_fixed_string_t port;
10472 cmdline_fixed_string_t cmd;
10476 cmd_show_queue_region_info_parsed(void *parsed_result,
10477 __rte_unused struct cmdline *cl,
10478 __rte_unused void *data)
10480 struct cmd_show_queue_region_info *res = parsed_result;
10481 int ret = -ENOTSUP;
10482 #ifdef RTE_NET_I40E
10483 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10484 enum rte_pmd_i40e_queue_region_op op_type;
10487 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10490 #ifdef RTE_NET_I40E
10491 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10493 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10495 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10496 op_type, &rte_pmd_regions);
10498 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10505 fprintf(stderr, "function not implemented or supported\n");
10508 fprintf(stderr, "queue region config info show error: (%s)\n",
10513 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10514 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10516 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10517 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10519 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10520 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10521 port_id, RTE_UINT16);
10522 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10523 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10524 cmd, "queue-region");
10526 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10527 .f = cmd_show_queue_region_info_parsed,
10529 .help_str = "show port <port_id> queue-region"
10530 ": show all queue region related configuration info",
10532 (void *)&cmd_show_queue_region_info_get,
10533 (void *)&cmd_show_queue_region_info_port,
10534 (void *)&cmd_show_queue_region_info_port_index,
10535 (void *)&cmd_show_queue_region_info_cmd,
10540 /* *** Filters Control *** */
10542 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10544 if ((ip_addr).family == AF_INET) \
10545 (ip) = (ip_addr).addr.ipv4.s_addr; \
10547 fprintf(stderr, "invalid parameter.\n"); \
10552 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10554 if ((ip_addr).family == AF_INET6) \
10555 rte_memcpy(&(ip), \
10556 &((ip_addr).addr.ipv6), \
10557 sizeof(struct in6_addr)); \
10559 fprintf(stderr, "invalid parameter.\n"); \
10564 #ifdef RTE_NET_I40E
10567 str2flowtype(char *string)
10570 static const struct {
10573 } flowtype_str[] = {
10574 {"raw", RTE_ETH_FLOW_RAW},
10575 {"ipv4", RTE_ETH_FLOW_IPV4},
10576 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10577 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10578 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10579 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10580 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10581 {"ipv6", RTE_ETH_FLOW_IPV6},
10582 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10583 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10584 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10585 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10586 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10587 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10588 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10589 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10590 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10591 {"gtpu", RTE_ETH_FLOW_GTPU},
10594 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10595 if (!strcmp(flowtype_str[i].str, string))
10596 return flowtype_str[i].type;
10599 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10600 return (uint16_t)atoi(string);
10602 return RTE_ETH_FLOW_UNKNOWN;
10605 /* *** deal with flow director filter *** */
10606 struct cmd_flow_director_result {
10607 cmdline_fixed_string_t flow_director_filter;
10609 cmdline_fixed_string_t mode;
10610 cmdline_fixed_string_t mode_value;
10611 cmdline_fixed_string_t ops;
10612 cmdline_fixed_string_t flow;
10613 cmdline_fixed_string_t flow_type;
10614 cmdline_fixed_string_t drop;
10615 cmdline_fixed_string_t queue;
10617 cmdline_fixed_string_t fd_id;
10618 uint32_t fd_id_value;
10619 cmdline_fixed_string_t packet;
10624 cmd_flow_director_filter_parsed(void *parsed_result,
10625 __rte_unused struct cmdline *cl,
10626 __rte_unused void *data)
10628 struct cmd_flow_director_result *res = parsed_result;
10630 struct rte_pmd_i40e_flow_type_mapping
10631 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10632 struct rte_pmd_i40e_pkt_template_conf conf;
10633 uint16_t flow_type = str2flowtype(res->flow_type);
10634 uint16_t i, port = res->port_id;
10637 memset(&conf, 0, sizeof(conf));
10639 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10640 fprintf(stderr, "Invalid flow type specified.\n");
10643 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10647 if (mapping[flow_type].pctype == 0ULL) {
10648 fprintf(stderr, "Invalid flow type specified.\n");
10651 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10652 if (mapping[flow_type].pctype & (1ULL << i)) {
10653 conf.input.pctype = i;
10658 conf.input.packet = open_file(res->filepath,
10659 &conf.input.length);
10660 if (!conf.input.packet)
10662 if (!strcmp(res->drop, "drop"))
10663 conf.action.behavior =
10664 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10666 conf.action.behavior =
10667 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10668 conf.action.report_status =
10669 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10670 conf.action.rx_queue = res->queue_id;
10671 conf.soft_id = res->fd_id_value;
10672 add = strcmp(res->ops, "del") ? 1 : 0;
10673 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10677 fprintf(stderr, "flow director config error: (%s)\n",
10679 close_file(conf.input.packet);
10682 cmdline_parse_token_string_t cmd_flow_director_filter =
10683 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10684 flow_director_filter, "flow_director_filter");
10685 cmdline_parse_token_num_t cmd_flow_director_port_id =
10686 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10687 port_id, RTE_UINT16);
10688 cmdline_parse_token_string_t cmd_flow_director_ops =
10689 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10690 ops, "add#del#update");
10691 cmdline_parse_token_string_t cmd_flow_director_flow =
10692 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10694 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10697 cmdline_parse_token_string_t cmd_flow_director_drop =
10698 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10700 cmdline_parse_token_string_t cmd_flow_director_queue =
10701 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10703 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10704 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10705 queue_id, RTE_UINT16);
10706 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10707 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10709 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10710 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10711 fd_id_value, RTE_UINT32);
10713 cmdline_parse_token_string_t cmd_flow_director_mode =
10714 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10716 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10718 mode_value, "raw");
10719 cmdline_parse_token_string_t cmd_flow_director_packet =
10720 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10722 cmdline_parse_token_string_t cmd_flow_director_filepath =
10723 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10726 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10727 .f = cmd_flow_director_filter_parsed,
10729 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10730 "director entry on NIC",
10732 (void *)&cmd_flow_director_filter,
10733 (void *)&cmd_flow_director_port_id,
10734 (void *)&cmd_flow_director_mode,
10735 (void *)&cmd_flow_director_mode_raw,
10736 (void *)&cmd_flow_director_ops,
10737 (void *)&cmd_flow_director_flow,
10738 (void *)&cmd_flow_director_flow_type,
10739 (void *)&cmd_flow_director_drop,
10740 (void *)&cmd_flow_director_queue,
10741 (void *)&cmd_flow_director_queue_id,
10742 (void *)&cmd_flow_director_fd_id,
10743 (void *)&cmd_flow_director_fd_id_value,
10744 (void *)&cmd_flow_director_packet,
10745 (void *)&cmd_flow_director_filepath,
10750 #endif /* RTE_NET_I40E */
10752 /* *** deal with flow director mask *** */
10753 struct cmd_flow_director_mask_result {
10754 cmdline_fixed_string_t flow_director_mask;
10756 cmdline_fixed_string_t mode;
10757 cmdline_fixed_string_t mode_value;
10758 cmdline_fixed_string_t vlan;
10759 uint16_t vlan_mask;
10760 cmdline_fixed_string_t src_mask;
10761 cmdline_ipaddr_t ipv4_src;
10762 cmdline_ipaddr_t ipv6_src;
10764 cmdline_fixed_string_t dst_mask;
10765 cmdline_ipaddr_t ipv4_dst;
10766 cmdline_ipaddr_t ipv6_dst;
10768 cmdline_fixed_string_t mac;
10769 uint8_t mac_addr_byte_mask;
10770 cmdline_fixed_string_t tunnel_id;
10771 uint32_t tunnel_id_mask;
10772 cmdline_fixed_string_t tunnel_type;
10773 uint8_t tunnel_type_mask;
10777 cmd_flow_director_mask_parsed(void *parsed_result,
10778 __rte_unused struct cmdline *cl,
10779 __rte_unused void *data)
10781 struct cmd_flow_director_mask_result *res = parsed_result;
10782 struct rte_eth_fdir_masks *mask;
10783 struct rte_port *port;
10785 port = &ports[res->port_id];
10786 /** Check if the port is not started **/
10787 if (port->port_status != RTE_PORT_STOPPED) {
10788 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10792 mask = &port->dev_conf.fdir_conf.mask;
10794 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10795 if (strcmp(res->mode_value, "MAC-VLAN")) {
10796 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10800 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10801 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10802 if (strcmp(res->mode_value, "Tunnel")) {
10803 fprintf(stderr, "Please set mode to Tunnel.\n");
10807 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10808 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10809 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10810 mask->tunnel_type_mask = res->tunnel_type_mask;
10812 if (strcmp(res->mode_value, "IP")) {
10813 fprintf(stderr, "Please set mode to IP.\n");
10817 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10818 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10819 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10820 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10821 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10822 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10823 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10826 cmd_reconfig_device_queue(res->port_id, 1, 1);
10829 cmdline_parse_token_string_t cmd_flow_director_mask =
10830 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10831 flow_director_mask, "flow_director_mask");
10832 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10833 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10834 port_id, RTE_UINT16);
10835 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10836 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10838 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10839 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10840 vlan_mask, RTE_UINT16);
10841 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10842 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10843 src_mask, "src_mask");
10844 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10845 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10847 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10848 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10850 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10851 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10852 port_src, RTE_UINT16);
10853 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10854 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10855 dst_mask, "dst_mask");
10856 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10857 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10859 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10860 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10862 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10863 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10864 port_dst, RTE_UINT16);
10866 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10869 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10872 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10874 mode_value, "MAC-VLAN");
10875 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10877 mode_value, "Tunnel");
10878 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10881 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10882 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10883 mac_addr_byte_mask, RTE_UINT8);
10884 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10886 tunnel_type, "tunnel-type");
10887 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10888 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10889 tunnel_type_mask, RTE_UINT8);
10890 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10891 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10892 tunnel_id, "tunnel-id");
10893 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10894 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10895 tunnel_id_mask, RTE_UINT32);
10897 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10898 .f = cmd_flow_director_mask_parsed,
10900 .help_str = "flow_director_mask ... : "
10901 "Set IP mode flow director's mask on NIC",
10903 (void *)&cmd_flow_director_mask,
10904 (void *)&cmd_flow_director_mask_port_id,
10905 (void *)&cmd_flow_director_mask_mode,
10906 (void *)&cmd_flow_director_mask_mode_ip,
10907 (void *)&cmd_flow_director_mask_vlan,
10908 (void *)&cmd_flow_director_mask_vlan_value,
10909 (void *)&cmd_flow_director_mask_src,
10910 (void *)&cmd_flow_director_mask_ipv4_src,
10911 (void *)&cmd_flow_director_mask_ipv6_src,
10912 (void *)&cmd_flow_director_mask_port_src,
10913 (void *)&cmd_flow_director_mask_dst,
10914 (void *)&cmd_flow_director_mask_ipv4_dst,
10915 (void *)&cmd_flow_director_mask_ipv6_dst,
10916 (void *)&cmd_flow_director_mask_port_dst,
10921 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10922 .f = cmd_flow_director_mask_parsed,
10924 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10925 "flow director's mask on NIC",
10927 (void *)&cmd_flow_director_mask,
10928 (void *)&cmd_flow_director_mask_port_id,
10929 (void *)&cmd_flow_director_mask_mode,
10930 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10931 (void *)&cmd_flow_director_mask_vlan,
10932 (void *)&cmd_flow_director_mask_vlan_value,
10937 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10938 .f = cmd_flow_director_mask_parsed,
10940 .help_str = "flow_director_mask ... : Set tunnel mode "
10941 "flow director's mask on NIC",
10943 (void *)&cmd_flow_director_mask,
10944 (void *)&cmd_flow_director_mask_port_id,
10945 (void *)&cmd_flow_director_mask_mode,
10946 (void *)&cmd_flow_director_mask_mode_tunnel,
10947 (void *)&cmd_flow_director_mask_vlan,
10948 (void *)&cmd_flow_director_mask_vlan_value,
10949 (void *)&cmd_flow_director_mask_mac,
10950 (void *)&cmd_flow_director_mask_mac_value,
10951 (void *)&cmd_flow_director_mask_tunnel_type,
10952 (void *)&cmd_flow_director_mask_tunnel_type_value,
10953 (void *)&cmd_flow_director_mask_tunnel_id,
10954 (void *)&cmd_flow_director_mask_tunnel_id_value,
10959 /* *** deal with flow director flexible payload configuration *** */
10960 struct cmd_flow_director_flexpayload_result {
10961 cmdline_fixed_string_t flow_director_flexpayload;
10963 cmdline_fixed_string_t payload_layer;
10964 cmdline_fixed_string_t payload_cfg;
10968 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10971 const char *p, *p0 = q_arg;
10973 unsigned long int_fld;
10974 char *str_fld[max_num];
10979 p = strchr(p0, '(');
10983 p0 = strchr(p, ')');
10988 if (size >= sizeof(s))
10991 snprintf(s, sizeof(s), "%.*s", size, p);
10992 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10993 if (ret < 0 || ret > max_num)
10995 for (i = 0; i < ret; i++) {
10997 int_fld = strtoul(str_fld[i], &end, 0);
10998 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11000 offsets[i] = (uint16_t)int_fld;
11006 cmd_flow_director_flxpld_parsed(void *parsed_result,
11007 __rte_unused struct cmdline *cl,
11008 __rte_unused void *data)
11010 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11011 struct rte_eth_flex_payload_cfg flex_cfg;
11012 struct rte_port *port;
11015 port = &ports[res->port_id];
11016 /** Check if the port is not started **/
11017 if (port->port_status != RTE_PORT_STOPPED) {
11018 fprintf(stderr, "Please stop port %d first\n", res->port_id);
11022 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11024 if (!strcmp(res->payload_layer, "raw"))
11025 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11026 else if (!strcmp(res->payload_layer, "l2"))
11027 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11028 else if (!strcmp(res->payload_layer, "l3"))
11029 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11030 else if (!strcmp(res->payload_layer, "l4"))
11031 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11033 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11034 RTE_ETH_FDIR_MAX_FLEXLEN);
11036 fprintf(stderr, "error: Cannot parse flex payload input.\n");
11040 fdir_set_flex_payload(res->port_id, &flex_cfg);
11041 cmd_reconfig_device_queue(res->port_id, 1, 1);
11044 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11045 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11046 flow_director_flexpayload,
11047 "flow_director_flex_payload");
11048 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11049 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11050 port_id, RTE_UINT16);
11051 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11052 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11053 payload_layer, "raw#l2#l3#l4");
11054 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11055 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11056 payload_cfg, NULL);
11058 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11059 .f = cmd_flow_director_flxpld_parsed,
11061 .help_str = "flow_director_flexpayload ... : "
11062 "Set flow director's flex payload on NIC",
11064 (void *)&cmd_flow_director_flexpayload,
11065 (void *)&cmd_flow_director_flexpayload_port_id,
11066 (void *)&cmd_flow_director_flexpayload_payload_layer,
11067 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11072 /* Generic flow interface command. */
11073 extern cmdline_parse_inst_t cmd_flow;
11075 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11076 struct cmd_mcast_addr_result {
11077 cmdline_fixed_string_t mcast_addr_cmd;
11078 cmdline_fixed_string_t what;
11080 struct rte_ether_addr mc_addr;
11083 static void cmd_mcast_addr_parsed(void *parsed_result,
11084 __rte_unused struct cmdline *cl,
11085 __rte_unused void *data)
11087 struct cmd_mcast_addr_result *res = parsed_result;
11089 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11091 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
11092 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
11095 if (strcmp(res->what, "add") == 0)
11096 mcast_addr_add(res->port_num, &res->mc_addr);
11098 mcast_addr_remove(res->port_num, &res->mc_addr);
11101 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11102 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11103 mcast_addr_cmd, "mcast_addr");
11104 cmdline_parse_token_string_t cmd_mcast_addr_what =
11105 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11107 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11108 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
11110 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11111 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11113 cmdline_parse_inst_t cmd_mcast_addr = {
11114 .f = cmd_mcast_addr_parsed,
11116 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11117 "Add/Remove multicast MAC address on port_id",
11119 (void *)&cmd_mcast_addr_cmd,
11120 (void *)&cmd_mcast_addr_what,
11121 (void *)&cmd_mcast_addr_portnum,
11122 (void *)&cmd_mcast_addr_addr,
11127 /* vf vlan anti spoof configuration */
11129 /* Common result structure for vf vlan anti spoof */
11130 struct cmd_vf_vlan_anti_spoof_result {
11131 cmdline_fixed_string_t set;
11132 cmdline_fixed_string_t vf;
11133 cmdline_fixed_string_t vlan;
11134 cmdline_fixed_string_t antispoof;
11137 cmdline_fixed_string_t on_off;
11140 /* Common CLI fields for vf vlan anti spoof enable disable */
11141 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11142 TOKEN_STRING_INITIALIZER
11143 (struct cmd_vf_vlan_anti_spoof_result,
11145 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11146 TOKEN_STRING_INITIALIZER
11147 (struct cmd_vf_vlan_anti_spoof_result,
11149 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11150 TOKEN_STRING_INITIALIZER
11151 (struct cmd_vf_vlan_anti_spoof_result,
11153 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11154 TOKEN_STRING_INITIALIZER
11155 (struct cmd_vf_vlan_anti_spoof_result,
11156 antispoof, "antispoof");
11157 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11158 TOKEN_NUM_INITIALIZER
11159 (struct cmd_vf_vlan_anti_spoof_result,
11160 port_id, RTE_UINT16);
11161 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11162 TOKEN_NUM_INITIALIZER
11163 (struct cmd_vf_vlan_anti_spoof_result,
11164 vf_id, RTE_UINT32);
11165 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11166 TOKEN_STRING_INITIALIZER
11167 (struct cmd_vf_vlan_anti_spoof_result,
11171 cmd_set_vf_vlan_anti_spoof_parsed(
11172 void *parsed_result,
11173 __rte_unused struct cmdline *cl,
11174 __rte_unused void *data)
11176 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11177 int ret = -ENOTSUP;
11179 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11181 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11184 #ifdef RTE_NET_IXGBE
11185 if (ret == -ENOTSUP)
11186 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11187 res->vf_id, is_on);
11189 #ifdef RTE_NET_I40E
11190 if (ret == -ENOTSUP)
11191 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11192 res->vf_id, is_on);
11194 #ifdef RTE_NET_BNXT
11195 if (ret == -ENOTSUP)
11196 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11197 res->vf_id, is_on);
11204 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11207 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11210 fprintf(stderr, "function not implemented\n");
11213 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11217 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11218 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11220 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11222 (void *)&cmd_vf_vlan_anti_spoof_set,
11223 (void *)&cmd_vf_vlan_anti_spoof_vf,
11224 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11225 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11226 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11227 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11228 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11233 /* vf mac anti spoof configuration */
11235 /* Common result structure for vf mac anti spoof */
11236 struct cmd_vf_mac_anti_spoof_result {
11237 cmdline_fixed_string_t set;
11238 cmdline_fixed_string_t vf;
11239 cmdline_fixed_string_t mac;
11240 cmdline_fixed_string_t antispoof;
11243 cmdline_fixed_string_t on_off;
11246 /* Common CLI fields for vf mac anti spoof enable disable */
11247 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11248 TOKEN_STRING_INITIALIZER
11249 (struct cmd_vf_mac_anti_spoof_result,
11251 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11252 TOKEN_STRING_INITIALIZER
11253 (struct cmd_vf_mac_anti_spoof_result,
11255 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11256 TOKEN_STRING_INITIALIZER
11257 (struct cmd_vf_mac_anti_spoof_result,
11259 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11260 TOKEN_STRING_INITIALIZER
11261 (struct cmd_vf_mac_anti_spoof_result,
11262 antispoof, "antispoof");
11263 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11264 TOKEN_NUM_INITIALIZER
11265 (struct cmd_vf_mac_anti_spoof_result,
11266 port_id, RTE_UINT16);
11267 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11268 TOKEN_NUM_INITIALIZER
11269 (struct cmd_vf_mac_anti_spoof_result,
11270 vf_id, RTE_UINT32);
11271 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11272 TOKEN_STRING_INITIALIZER
11273 (struct cmd_vf_mac_anti_spoof_result,
11277 cmd_set_vf_mac_anti_spoof_parsed(
11278 void *parsed_result,
11279 __rte_unused struct cmdline *cl,
11280 __rte_unused void *data)
11282 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11283 int ret = -ENOTSUP;
11285 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11287 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11290 #ifdef RTE_NET_IXGBE
11291 if (ret == -ENOTSUP)
11292 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11293 res->vf_id, is_on);
11295 #ifdef RTE_NET_I40E
11296 if (ret == -ENOTSUP)
11297 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11298 res->vf_id, is_on);
11300 #ifdef RTE_NET_BNXT
11301 if (ret == -ENOTSUP)
11302 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11303 res->vf_id, is_on);
11310 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11311 res->vf_id, is_on);
11314 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11317 fprintf(stderr, "function not implemented\n");
11320 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11324 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11325 .f = cmd_set_vf_mac_anti_spoof_parsed,
11327 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11329 (void *)&cmd_vf_mac_anti_spoof_set,
11330 (void *)&cmd_vf_mac_anti_spoof_vf,
11331 (void *)&cmd_vf_mac_anti_spoof_mac,
11332 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11333 (void *)&cmd_vf_mac_anti_spoof_port_id,
11334 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11335 (void *)&cmd_vf_mac_anti_spoof_on_off,
11340 /* vf vlan strip queue configuration */
11342 /* Common result structure for vf mac anti spoof */
11343 struct cmd_vf_vlan_stripq_result {
11344 cmdline_fixed_string_t set;
11345 cmdline_fixed_string_t vf;
11346 cmdline_fixed_string_t vlan;
11347 cmdline_fixed_string_t stripq;
11350 cmdline_fixed_string_t on_off;
11353 /* Common CLI fields for vf vlan strip enable disable */
11354 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11355 TOKEN_STRING_INITIALIZER
11356 (struct cmd_vf_vlan_stripq_result,
11358 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11359 TOKEN_STRING_INITIALIZER
11360 (struct cmd_vf_vlan_stripq_result,
11362 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11363 TOKEN_STRING_INITIALIZER
11364 (struct cmd_vf_vlan_stripq_result,
11366 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11367 TOKEN_STRING_INITIALIZER
11368 (struct cmd_vf_vlan_stripq_result,
11370 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11371 TOKEN_NUM_INITIALIZER
11372 (struct cmd_vf_vlan_stripq_result,
11373 port_id, RTE_UINT16);
11374 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11375 TOKEN_NUM_INITIALIZER
11376 (struct cmd_vf_vlan_stripq_result,
11377 vf_id, RTE_UINT16);
11378 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11379 TOKEN_STRING_INITIALIZER
11380 (struct cmd_vf_vlan_stripq_result,
11384 cmd_set_vf_vlan_stripq_parsed(
11385 void *parsed_result,
11386 __rte_unused struct cmdline *cl,
11387 __rte_unused void *data)
11389 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11390 int ret = -ENOTSUP;
11392 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11397 #ifdef RTE_NET_IXGBE
11398 if (ret == -ENOTSUP)
11399 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11400 res->vf_id, is_on);
11402 #ifdef RTE_NET_I40E
11403 if (ret == -ENOTSUP)
11404 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11405 res->vf_id, is_on);
11407 #ifdef RTE_NET_BNXT
11408 if (ret == -ENOTSUP)
11409 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11410 res->vf_id, is_on);
11417 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11418 res->vf_id, is_on);
11421 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11424 fprintf(stderr, "function not implemented\n");
11427 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11431 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11432 .f = cmd_set_vf_vlan_stripq_parsed,
11434 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11436 (void *)&cmd_vf_vlan_stripq_set,
11437 (void *)&cmd_vf_vlan_stripq_vf,
11438 (void *)&cmd_vf_vlan_stripq_vlan,
11439 (void *)&cmd_vf_vlan_stripq_stripq,
11440 (void *)&cmd_vf_vlan_stripq_port_id,
11441 (void *)&cmd_vf_vlan_stripq_vf_id,
11442 (void *)&cmd_vf_vlan_stripq_on_off,
11447 /* vf vlan insert configuration */
11449 /* Common result structure for vf vlan insert */
11450 struct cmd_vf_vlan_insert_result {
11451 cmdline_fixed_string_t set;
11452 cmdline_fixed_string_t vf;
11453 cmdline_fixed_string_t vlan;
11454 cmdline_fixed_string_t insert;
11460 /* Common CLI fields for vf vlan insert enable disable */
11461 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11462 TOKEN_STRING_INITIALIZER
11463 (struct cmd_vf_vlan_insert_result,
11465 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11466 TOKEN_STRING_INITIALIZER
11467 (struct cmd_vf_vlan_insert_result,
11469 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11470 TOKEN_STRING_INITIALIZER
11471 (struct cmd_vf_vlan_insert_result,
11473 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11474 TOKEN_STRING_INITIALIZER
11475 (struct cmd_vf_vlan_insert_result,
11477 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11478 TOKEN_NUM_INITIALIZER
11479 (struct cmd_vf_vlan_insert_result,
11480 port_id, RTE_UINT16);
11481 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11482 TOKEN_NUM_INITIALIZER
11483 (struct cmd_vf_vlan_insert_result,
11484 vf_id, RTE_UINT16);
11485 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11486 TOKEN_NUM_INITIALIZER
11487 (struct cmd_vf_vlan_insert_result,
11488 vlan_id, RTE_UINT16);
11491 cmd_set_vf_vlan_insert_parsed(
11492 void *parsed_result,
11493 __rte_unused struct cmdline *cl,
11494 __rte_unused void *data)
11496 struct cmd_vf_vlan_insert_result *res = parsed_result;
11497 int ret = -ENOTSUP;
11499 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11502 #ifdef RTE_NET_IXGBE
11503 if (ret == -ENOTSUP)
11504 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11507 #ifdef RTE_NET_I40E
11508 if (ret == -ENOTSUP)
11509 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11512 #ifdef RTE_NET_BNXT
11513 if (ret == -ENOTSUP)
11514 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11522 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11523 res->vf_id, res->vlan_id);
11526 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11529 fprintf(stderr, "function not implemented\n");
11532 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11536 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11537 .f = cmd_set_vf_vlan_insert_parsed,
11539 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11541 (void *)&cmd_vf_vlan_insert_set,
11542 (void *)&cmd_vf_vlan_insert_vf,
11543 (void *)&cmd_vf_vlan_insert_vlan,
11544 (void *)&cmd_vf_vlan_insert_insert,
11545 (void *)&cmd_vf_vlan_insert_port_id,
11546 (void *)&cmd_vf_vlan_insert_vf_id,
11547 (void *)&cmd_vf_vlan_insert_vlan_id,
11552 /* tx loopback configuration */
11554 /* Common result structure for tx loopback */
11555 struct cmd_tx_loopback_result {
11556 cmdline_fixed_string_t set;
11557 cmdline_fixed_string_t tx;
11558 cmdline_fixed_string_t loopback;
11560 cmdline_fixed_string_t on_off;
11563 /* Common CLI fields for tx loopback enable disable */
11564 cmdline_parse_token_string_t cmd_tx_loopback_set =
11565 TOKEN_STRING_INITIALIZER
11566 (struct cmd_tx_loopback_result,
11568 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11569 TOKEN_STRING_INITIALIZER
11570 (struct cmd_tx_loopback_result,
11572 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11573 TOKEN_STRING_INITIALIZER
11574 (struct cmd_tx_loopback_result,
11575 loopback, "loopback");
11576 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11577 TOKEN_NUM_INITIALIZER
11578 (struct cmd_tx_loopback_result,
11579 port_id, RTE_UINT16);
11580 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11581 TOKEN_STRING_INITIALIZER
11582 (struct cmd_tx_loopback_result,
11586 cmd_set_tx_loopback_parsed(
11587 void *parsed_result,
11588 __rte_unused struct cmdline *cl,
11589 __rte_unused void *data)
11591 struct cmd_tx_loopback_result *res = parsed_result;
11592 int ret = -ENOTSUP;
11594 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11596 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11599 #ifdef RTE_NET_IXGBE
11600 if (ret == -ENOTSUP)
11601 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11603 #ifdef RTE_NET_I40E
11604 if (ret == -ENOTSUP)
11605 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11607 #ifdef RTE_NET_BNXT
11608 if (ret == -ENOTSUP)
11609 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11611 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11612 if (ret == -ENOTSUP)
11613 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11620 fprintf(stderr, "invalid is_on %d\n", is_on);
11623 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11626 fprintf(stderr, "function not implemented\n");
11629 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11633 cmdline_parse_inst_t cmd_set_tx_loopback = {
11634 .f = cmd_set_tx_loopback_parsed,
11636 .help_str = "set tx loopback <port_id> on|off",
11638 (void *)&cmd_tx_loopback_set,
11639 (void *)&cmd_tx_loopback_tx,
11640 (void *)&cmd_tx_loopback_loopback,
11641 (void *)&cmd_tx_loopback_port_id,
11642 (void *)&cmd_tx_loopback_on_off,
11647 /* all queues drop enable configuration */
11649 /* Common result structure for all queues drop enable */
11650 struct cmd_all_queues_drop_en_result {
11651 cmdline_fixed_string_t set;
11652 cmdline_fixed_string_t all;
11653 cmdline_fixed_string_t queues;
11654 cmdline_fixed_string_t drop;
11656 cmdline_fixed_string_t on_off;
11659 /* Common CLI fields for tx loopback enable disable */
11660 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11661 TOKEN_STRING_INITIALIZER
11662 (struct cmd_all_queues_drop_en_result,
11664 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11665 TOKEN_STRING_INITIALIZER
11666 (struct cmd_all_queues_drop_en_result,
11668 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11669 TOKEN_STRING_INITIALIZER
11670 (struct cmd_all_queues_drop_en_result,
11672 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11673 TOKEN_STRING_INITIALIZER
11674 (struct cmd_all_queues_drop_en_result,
11676 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11677 TOKEN_NUM_INITIALIZER
11678 (struct cmd_all_queues_drop_en_result,
11679 port_id, RTE_UINT16);
11680 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11681 TOKEN_STRING_INITIALIZER
11682 (struct cmd_all_queues_drop_en_result,
11686 cmd_set_all_queues_drop_en_parsed(
11687 void *parsed_result,
11688 __rte_unused struct cmdline *cl,
11689 __rte_unused void *data)
11691 struct cmd_all_queues_drop_en_result *res = parsed_result;
11692 int ret = -ENOTSUP;
11693 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11695 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11698 #ifdef RTE_NET_IXGBE
11699 if (ret == -ENOTSUP)
11700 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11702 #ifdef RTE_NET_BNXT
11703 if (ret == -ENOTSUP)
11704 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11710 fprintf(stderr, "invalid is_on %d\n", is_on);
11713 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11716 fprintf(stderr, "function not implemented\n");
11719 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11723 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11724 .f = cmd_set_all_queues_drop_en_parsed,
11726 .help_str = "set all queues drop <port_id> on|off",
11728 (void *)&cmd_all_queues_drop_en_set,
11729 (void *)&cmd_all_queues_drop_en_all,
11730 (void *)&cmd_all_queues_drop_en_queues,
11731 (void *)&cmd_all_queues_drop_en_drop,
11732 (void *)&cmd_all_queues_drop_en_port_id,
11733 (void *)&cmd_all_queues_drop_en_on_off,
11738 /* vf split drop enable configuration */
11740 /* Common result structure for vf split drop enable */
11741 struct cmd_vf_split_drop_en_result {
11742 cmdline_fixed_string_t set;
11743 cmdline_fixed_string_t vf;
11744 cmdline_fixed_string_t split;
11745 cmdline_fixed_string_t drop;
11748 cmdline_fixed_string_t on_off;
11751 /* Common CLI fields for vf split drop enable disable */
11752 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11753 TOKEN_STRING_INITIALIZER
11754 (struct cmd_vf_split_drop_en_result,
11756 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11757 TOKEN_STRING_INITIALIZER
11758 (struct cmd_vf_split_drop_en_result,
11760 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11761 TOKEN_STRING_INITIALIZER
11762 (struct cmd_vf_split_drop_en_result,
11764 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11765 TOKEN_STRING_INITIALIZER
11766 (struct cmd_vf_split_drop_en_result,
11768 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11769 TOKEN_NUM_INITIALIZER
11770 (struct cmd_vf_split_drop_en_result,
11771 port_id, RTE_UINT16);
11772 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11773 TOKEN_NUM_INITIALIZER
11774 (struct cmd_vf_split_drop_en_result,
11775 vf_id, RTE_UINT16);
11776 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11777 TOKEN_STRING_INITIALIZER
11778 (struct cmd_vf_split_drop_en_result,
11782 cmd_set_vf_split_drop_en_parsed(
11783 void *parsed_result,
11784 __rte_unused struct cmdline *cl,
11785 __rte_unused void *data)
11787 struct cmd_vf_split_drop_en_result *res = parsed_result;
11788 int ret = -ENOTSUP;
11789 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11791 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11794 #ifdef RTE_NET_IXGBE
11795 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11802 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11803 res->vf_id, is_on);
11806 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11809 fprintf(stderr, "not supported on port %d\n", res->port_id);
11812 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11816 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11817 .f = cmd_set_vf_split_drop_en_parsed,
11819 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11821 (void *)&cmd_vf_split_drop_en_set,
11822 (void *)&cmd_vf_split_drop_en_vf,
11823 (void *)&cmd_vf_split_drop_en_split,
11824 (void *)&cmd_vf_split_drop_en_drop,
11825 (void *)&cmd_vf_split_drop_en_port_id,
11826 (void *)&cmd_vf_split_drop_en_vf_id,
11827 (void *)&cmd_vf_split_drop_en_on_off,
11832 /* vf mac address configuration */
11834 /* Common result structure for vf mac address */
11835 struct cmd_set_vf_mac_addr_result {
11836 cmdline_fixed_string_t set;
11837 cmdline_fixed_string_t vf;
11838 cmdline_fixed_string_t mac;
11839 cmdline_fixed_string_t addr;
11842 struct rte_ether_addr mac_addr;
11846 /* Common CLI fields for vf split drop enable disable */
11847 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11848 TOKEN_STRING_INITIALIZER
11849 (struct cmd_set_vf_mac_addr_result,
11851 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11852 TOKEN_STRING_INITIALIZER
11853 (struct cmd_set_vf_mac_addr_result,
11855 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11856 TOKEN_STRING_INITIALIZER
11857 (struct cmd_set_vf_mac_addr_result,
11859 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11860 TOKEN_STRING_INITIALIZER
11861 (struct cmd_set_vf_mac_addr_result,
11863 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11864 TOKEN_NUM_INITIALIZER
11865 (struct cmd_set_vf_mac_addr_result,
11866 port_id, RTE_UINT16);
11867 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11868 TOKEN_NUM_INITIALIZER
11869 (struct cmd_set_vf_mac_addr_result,
11870 vf_id, RTE_UINT16);
11871 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11872 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11876 cmd_set_vf_mac_addr_parsed(
11877 void *parsed_result,
11878 __rte_unused struct cmdline *cl,
11879 __rte_unused void *data)
11881 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11882 int ret = -ENOTSUP;
11884 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11887 #ifdef RTE_NET_IXGBE
11888 if (ret == -ENOTSUP)
11889 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11892 #ifdef RTE_NET_I40E
11893 if (ret == -ENOTSUP)
11894 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11897 #ifdef RTE_NET_BNXT
11898 if (ret == -ENOTSUP)
11899 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11907 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11910 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11913 fprintf(stderr, "function not implemented\n");
11916 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11920 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11921 .f = cmd_set_vf_mac_addr_parsed,
11923 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11925 (void *)&cmd_set_vf_mac_addr_set,
11926 (void *)&cmd_set_vf_mac_addr_vf,
11927 (void *)&cmd_set_vf_mac_addr_mac,
11928 (void *)&cmd_set_vf_mac_addr_addr,
11929 (void *)&cmd_set_vf_mac_addr_port_id,
11930 (void *)&cmd_set_vf_mac_addr_vf_id,
11931 (void *)&cmd_set_vf_mac_addr_mac_addr,
11936 /* MACsec configuration */
11938 /* Common result structure for MACsec offload enable */
11939 struct cmd_macsec_offload_on_result {
11940 cmdline_fixed_string_t set;
11941 cmdline_fixed_string_t macsec;
11942 cmdline_fixed_string_t offload;
11944 cmdline_fixed_string_t on;
11945 cmdline_fixed_string_t encrypt;
11946 cmdline_fixed_string_t en_on_off;
11947 cmdline_fixed_string_t replay_protect;
11948 cmdline_fixed_string_t rp_on_off;
11951 /* Common CLI fields for MACsec offload disable */
11952 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11953 TOKEN_STRING_INITIALIZER
11954 (struct cmd_macsec_offload_on_result,
11956 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11957 TOKEN_STRING_INITIALIZER
11958 (struct cmd_macsec_offload_on_result,
11960 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11961 TOKEN_STRING_INITIALIZER
11962 (struct cmd_macsec_offload_on_result,
11963 offload, "offload");
11964 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11965 TOKEN_NUM_INITIALIZER
11966 (struct cmd_macsec_offload_on_result,
11967 port_id, RTE_UINT16);
11968 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11969 TOKEN_STRING_INITIALIZER
11970 (struct cmd_macsec_offload_on_result,
11972 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11973 TOKEN_STRING_INITIALIZER
11974 (struct cmd_macsec_offload_on_result,
11975 encrypt, "encrypt");
11976 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11977 TOKEN_STRING_INITIALIZER
11978 (struct cmd_macsec_offload_on_result,
11979 en_on_off, "on#off");
11980 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11981 TOKEN_STRING_INITIALIZER
11982 (struct cmd_macsec_offload_on_result,
11983 replay_protect, "replay-protect");
11984 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11985 TOKEN_STRING_INITIALIZER
11986 (struct cmd_macsec_offload_on_result,
11987 rp_on_off, "on#off");
11990 cmd_set_macsec_offload_on_parsed(
11991 void *parsed_result,
11992 __rte_unused struct cmdline *cl,
11993 __rte_unused void *data)
11995 struct cmd_macsec_offload_on_result *res = parsed_result;
11996 int ret = -ENOTSUP;
11997 portid_t port_id = res->port_id;
11998 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11999 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12000 struct rte_eth_dev_info dev_info;
12002 if (port_id_is_invalid(port_id, ENABLED_WARN))
12004 if (!port_is_stopped(port_id)) {
12005 fprintf(stderr, "Please stop port %d first\n", port_id);
12009 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12013 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12014 #ifdef RTE_NET_IXGBE
12015 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12023 ports[port_id].dev_conf.txmode.offloads |=
12024 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12025 cmd_reconfig_device_queue(port_id, 1, 1);
12028 fprintf(stderr, "invalid port_id %d\n", port_id);
12031 fprintf(stderr, "not supported on port %d\n", port_id);
12034 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12038 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12039 .f = cmd_set_macsec_offload_on_parsed,
12041 .help_str = "set macsec offload <port_id> on "
12042 "encrypt on|off replay-protect on|off",
12044 (void *)&cmd_macsec_offload_on_set,
12045 (void *)&cmd_macsec_offload_on_macsec,
12046 (void *)&cmd_macsec_offload_on_offload,
12047 (void *)&cmd_macsec_offload_on_port_id,
12048 (void *)&cmd_macsec_offload_on_on,
12049 (void *)&cmd_macsec_offload_on_encrypt,
12050 (void *)&cmd_macsec_offload_on_en_on_off,
12051 (void *)&cmd_macsec_offload_on_replay_protect,
12052 (void *)&cmd_macsec_offload_on_rp_on_off,
12057 /* Common result structure for MACsec offload disable */
12058 struct cmd_macsec_offload_off_result {
12059 cmdline_fixed_string_t set;
12060 cmdline_fixed_string_t macsec;
12061 cmdline_fixed_string_t offload;
12063 cmdline_fixed_string_t off;
12066 /* Common CLI fields for MACsec offload disable */
12067 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12068 TOKEN_STRING_INITIALIZER
12069 (struct cmd_macsec_offload_off_result,
12071 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12072 TOKEN_STRING_INITIALIZER
12073 (struct cmd_macsec_offload_off_result,
12075 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12076 TOKEN_STRING_INITIALIZER
12077 (struct cmd_macsec_offload_off_result,
12078 offload, "offload");
12079 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12080 TOKEN_NUM_INITIALIZER
12081 (struct cmd_macsec_offload_off_result,
12082 port_id, RTE_UINT16);
12083 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12084 TOKEN_STRING_INITIALIZER
12085 (struct cmd_macsec_offload_off_result,
12089 cmd_set_macsec_offload_off_parsed(
12090 void *parsed_result,
12091 __rte_unused struct cmdline *cl,
12092 __rte_unused void *data)
12094 struct cmd_macsec_offload_off_result *res = parsed_result;
12095 int ret = -ENOTSUP;
12096 struct rte_eth_dev_info dev_info;
12097 portid_t port_id = res->port_id;
12099 if (port_id_is_invalid(port_id, ENABLED_WARN))
12101 if (!port_is_stopped(port_id)) {
12102 fprintf(stderr, "Please stop port %d first\n", port_id);
12106 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12110 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12111 #ifdef RTE_NET_IXGBE
12112 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12117 ports[port_id].dev_conf.txmode.offloads &=
12118 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12119 cmd_reconfig_device_queue(port_id, 1, 1);
12122 fprintf(stderr, "invalid port_id %d\n", port_id);
12125 fprintf(stderr, "not supported on port %d\n", port_id);
12128 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12132 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12133 .f = cmd_set_macsec_offload_off_parsed,
12135 .help_str = "set macsec offload <port_id> off",
12137 (void *)&cmd_macsec_offload_off_set,
12138 (void *)&cmd_macsec_offload_off_macsec,
12139 (void *)&cmd_macsec_offload_off_offload,
12140 (void *)&cmd_macsec_offload_off_port_id,
12141 (void *)&cmd_macsec_offload_off_off,
12146 /* Common result structure for MACsec secure connection configure */
12147 struct cmd_macsec_sc_result {
12148 cmdline_fixed_string_t set;
12149 cmdline_fixed_string_t macsec;
12150 cmdline_fixed_string_t sc;
12151 cmdline_fixed_string_t tx_rx;
12153 struct rte_ether_addr mac;
12157 /* Common CLI fields for MACsec secure connection configure */
12158 cmdline_parse_token_string_t cmd_macsec_sc_set =
12159 TOKEN_STRING_INITIALIZER
12160 (struct cmd_macsec_sc_result,
12162 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12163 TOKEN_STRING_INITIALIZER
12164 (struct cmd_macsec_sc_result,
12166 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12167 TOKEN_STRING_INITIALIZER
12168 (struct cmd_macsec_sc_result,
12170 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12171 TOKEN_STRING_INITIALIZER
12172 (struct cmd_macsec_sc_result,
12174 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12175 TOKEN_NUM_INITIALIZER
12176 (struct cmd_macsec_sc_result,
12177 port_id, RTE_UINT16);
12178 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12179 TOKEN_ETHERADDR_INITIALIZER
12180 (struct cmd_macsec_sc_result,
12182 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12183 TOKEN_NUM_INITIALIZER
12184 (struct cmd_macsec_sc_result,
12188 cmd_set_macsec_sc_parsed(
12189 void *parsed_result,
12190 __rte_unused struct cmdline *cl,
12191 __rte_unused void *data)
12193 struct cmd_macsec_sc_result *res = parsed_result;
12194 int ret = -ENOTSUP;
12195 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12197 #ifdef RTE_NET_IXGBE
12199 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12200 res->mac.addr_bytes) :
12201 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12202 res->mac.addr_bytes, res->pi);
12204 RTE_SET_USED(is_tx);
12210 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12213 fprintf(stderr, "not supported on port %d\n", res->port_id);
12216 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12220 cmdline_parse_inst_t cmd_set_macsec_sc = {
12221 .f = cmd_set_macsec_sc_parsed,
12223 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12225 (void *)&cmd_macsec_sc_set,
12226 (void *)&cmd_macsec_sc_macsec,
12227 (void *)&cmd_macsec_sc_sc,
12228 (void *)&cmd_macsec_sc_tx_rx,
12229 (void *)&cmd_macsec_sc_port_id,
12230 (void *)&cmd_macsec_sc_mac,
12231 (void *)&cmd_macsec_sc_pi,
12236 /* Common result structure for MACsec secure connection configure */
12237 struct cmd_macsec_sa_result {
12238 cmdline_fixed_string_t set;
12239 cmdline_fixed_string_t macsec;
12240 cmdline_fixed_string_t sa;
12241 cmdline_fixed_string_t tx_rx;
12246 cmdline_fixed_string_t key;
12249 /* Common CLI fields for MACsec secure connection configure */
12250 cmdline_parse_token_string_t cmd_macsec_sa_set =
12251 TOKEN_STRING_INITIALIZER
12252 (struct cmd_macsec_sa_result,
12254 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12255 TOKEN_STRING_INITIALIZER
12256 (struct cmd_macsec_sa_result,
12258 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12259 TOKEN_STRING_INITIALIZER
12260 (struct cmd_macsec_sa_result,
12262 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12263 TOKEN_STRING_INITIALIZER
12264 (struct cmd_macsec_sa_result,
12266 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12267 TOKEN_NUM_INITIALIZER
12268 (struct cmd_macsec_sa_result,
12269 port_id, RTE_UINT16);
12270 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12271 TOKEN_NUM_INITIALIZER
12272 (struct cmd_macsec_sa_result,
12274 cmdline_parse_token_num_t cmd_macsec_sa_an =
12275 TOKEN_NUM_INITIALIZER
12276 (struct cmd_macsec_sa_result,
12278 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12279 TOKEN_NUM_INITIALIZER
12280 (struct cmd_macsec_sa_result,
12282 cmdline_parse_token_string_t cmd_macsec_sa_key =
12283 TOKEN_STRING_INITIALIZER
12284 (struct cmd_macsec_sa_result,
12288 cmd_set_macsec_sa_parsed(
12289 void *parsed_result,
12290 __rte_unused struct cmdline *cl,
12291 __rte_unused void *data)
12293 struct cmd_macsec_sa_result *res = parsed_result;
12294 int ret = -ENOTSUP;
12295 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12296 uint8_t key[16] = { 0 };
12302 key_len = strlen(res->key) / 2;
12306 for (i = 0; i < key_len; i++) {
12307 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12310 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12313 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12316 #ifdef RTE_NET_IXGBE
12318 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12319 res->idx, res->an, res->pn, key) :
12320 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12321 res->idx, res->an, res->pn, key);
12323 RTE_SET_USED(is_tx);
12330 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12333 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12336 fprintf(stderr, "not supported on port %d\n", res->port_id);
12339 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12343 cmdline_parse_inst_t cmd_set_macsec_sa = {
12344 .f = cmd_set_macsec_sa_parsed,
12346 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12348 (void *)&cmd_macsec_sa_set,
12349 (void *)&cmd_macsec_sa_macsec,
12350 (void *)&cmd_macsec_sa_sa,
12351 (void *)&cmd_macsec_sa_tx_rx,
12352 (void *)&cmd_macsec_sa_port_id,
12353 (void *)&cmd_macsec_sa_idx,
12354 (void *)&cmd_macsec_sa_an,
12355 (void *)&cmd_macsec_sa_pn,
12356 (void *)&cmd_macsec_sa_key,
12361 /* VF unicast promiscuous mode configuration */
12363 /* Common result structure for VF unicast promiscuous mode */
12364 struct cmd_vf_promisc_result {
12365 cmdline_fixed_string_t set;
12366 cmdline_fixed_string_t vf;
12367 cmdline_fixed_string_t promisc;
12370 cmdline_fixed_string_t on_off;
12373 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12374 cmdline_parse_token_string_t cmd_vf_promisc_set =
12375 TOKEN_STRING_INITIALIZER
12376 (struct cmd_vf_promisc_result,
12378 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12379 TOKEN_STRING_INITIALIZER
12380 (struct cmd_vf_promisc_result,
12382 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12383 TOKEN_STRING_INITIALIZER
12384 (struct cmd_vf_promisc_result,
12385 promisc, "promisc");
12386 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12387 TOKEN_NUM_INITIALIZER
12388 (struct cmd_vf_promisc_result,
12389 port_id, RTE_UINT16);
12390 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12391 TOKEN_NUM_INITIALIZER
12392 (struct cmd_vf_promisc_result,
12393 vf_id, RTE_UINT32);
12394 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12395 TOKEN_STRING_INITIALIZER
12396 (struct cmd_vf_promisc_result,
12400 cmd_set_vf_promisc_parsed(
12401 void *parsed_result,
12402 __rte_unused struct cmdline *cl,
12403 __rte_unused void *data)
12405 struct cmd_vf_promisc_result *res = parsed_result;
12406 int ret = -ENOTSUP;
12408 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12410 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12413 #ifdef RTE_NET_I40E
12414 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12415 res->vf_id, is_on);
12422 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12425 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12428 fprintf(stderr, "function not implemented\n");
12431 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12435 cmdline_parse_inst_t cmd_set_vf_promisc = {
12436 .f = cmd_set_vf_promisc_parsed,
12438 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12439 "Set unicast promiscuous mode for a VF from the PF",
12441 (void *)&cmd_vf_promisc_set,
12442 (void *)&cmd_vf_promisc_vf,
12443 (void *)&cmd_vf_promisc_promisc,
12444 (void *)&cmd_vf_promisc_port_id,
12445 (void *)&cmd_vf_promisc_vf_id,
12446 (void *)&cmd_vf_promisc_on_off,
12451 /* VF multicast promiscuous mode configuration */
12453 /* Common result structure for VF multicast promiscuous mode */
12454 struct cmd_vf_allmulti_result {
12455 cmdline_fixed_string_t set;
12456 cmdline_fixed_string_t vf;
12457 cmdline_fixed_string_t allmulti;
12460 cmdline_fixed_string_t on_off;
12463 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12464 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12465 TOKEN_STRING_INITIALIZER
12466 (struct cmd_vf_allmulti_result,
12468 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_vf_allmulti_result,
12472 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12473 TOKEN_STRING_INITIALIZER
12474 (struct cmd_vf_allmulti_result,
12475 allmulti, "allmulti");
12476 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12477 TOKEN_NUM_INITIALIZER
12478 (struct cmd_vf_allmulti_result,
12479 port_id, RTE_UINT16);
12480 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12481 TOKEN_NUM_INITIALIZER
12482 (struct cmd_vf_allmulti_result,
12483 vf_id, RTE_UINT32);
12484 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12485 TOKEN_STRING_INITIALIZER
12486 (struct cmd_vf_allmulti_result,
12490 cmd_set_vf_allmulti_parsed(
12491 void *parsed_result,
12492 __rte_unused struct cmdline *cl,
12493 __rte_unused void *data)
12495 struct cmd_vf_allmulti_result *res = parsed_result;
12496 int ret = -ENOTSUP;
12498 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12500 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12503 #ifdef RTE_NET_I40E
12504 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12505 res->vf_id, is_on);
12512 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12515 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12518 fprintf(stderr, "function not implemented\n");
12521 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12525 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12526 .f = cmd_set_vf_allmulti_parsed,
12528 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12529 "Set multicast promiscuous mode for a VF from the PF",
12531 (void *)&cmd_vf_allmulti_set,
12532 (void *)&cmd_vf_allmulti_vf,
12533 (void *)&cmd_vf_allmulti_allmulti,
12534 (void *)&cmd_vf_allmulti_port_id,
12535 (void *)&cmd_vf_allmulti_vf_id,
12536 (void *)&cmd_vf_allmulti_on_off,
12541 /* vf broadcast mode configuration */
12543 /* Common result structure for vf broadcast */
12544 struct cmd_set_vf_broadcast_result {
12545 cmdline_fixed_string_t set;
12546 cmdline_fixed_string_t vf;
12547 cmdline_fixed_string_t broadcast;
12550 cmdline_fixed_string_t on_off;
12553 /* Common CLI fields for vf broadcast enable disable */
12554 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12555 TOKEN_STRING_INITIALIZER
12556 (struct cmd_set_vf_broadcast_result,
12558 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12559 TOKEN_STRING_INITIALIZER
12560 (struct cmd_set_vf_broadcast_result,
12562 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12563 TOKEN_STRING_INITIALIZER
12564 (struct cmd_set_vf_broadcast_result,
12565 broadcast, "broadcast");
12566 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12567 TOKEN_NUM_INITIALIZER
12568 (struct cmd_set_vf_broadcast_result,
12569 port_id, RTE_UINT16);
12570 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12571 TOKEN_NUM_INITIALIZER
12572 (struct cmd_set_vf_broadcast_result,
12573 vf_id, RTE_UINT16);
12574 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12575 TOKEN_STRING_INITIALIZER
12576 (struct cmd_set_vf_broadcast_result,
12580 cmd_set_vf_broadcast_parsed(
12581 void *parsed_result,
12582 __rte_unused struct cmdline *cl,
12583 __rte_unused void *data)
12585 struct cmd_set_vf_broadcast_result *res = parsed_result;
12586 int ret = -ENOTSUP;
12588 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12590 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12593 #ifdef RTE_NET_I40E
12594 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12595 res->vf_id, is_on);
12602 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12603 res->vf_id, is_on);
12606 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12609 fprintf(stderr, "function not implemented\n");
12612 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12616 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12617 .f = cmd_set_vf_broadcast_parsed,
12619 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12621 (void *)&cmd_set_vf_broadcast_set,
12622 (void *)&cmd_set_vf_broadcast_vf,
12623 (void *)&cmd_set_vf_broadcast_broadcast,
12624 (void *)&cmd_set_vf_broadcast_port_id,
12625 (void *)&cmd_set_vf_broadcast_vf_id,
12626 (void *)&cmd_set_vf_broadcast_on_off,
12631 /* vf vlan tag configuration */
12633 /* Common result structure for vf vlan tag */
12634 struct cmd_set_vf_vlan_tag_result {
12635 cmdline_fixed_string_t set;
12636 cmdline_fixed_string_t vf;
12637 cmdline_fixed_string_t vlan;
12638 cmdline_fixed_string_t tag;
12641 cmdline_fixed_string_t on_off;
12644 /* Common CLI fields for vf vlan tag enable disable */
12645 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12646 TOKEN_STRING_INITIALIZER
12647 (struct cmd_set_vf_vlan_tag_result,
12649 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12650 TOKEN_STRING_INITIALIZER
12651 (struct cmd_set_vf_vlan_tag_result,
12653 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12654 TOKEN_STRING_INITIALIZER
12655 (struct cmd_set_vf_vlan_tag_result,
12657 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12658 TOKEN_STRING_INITIALIZER
12659 (struct cmd_set_vf_vlan_tag_result,
12661 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12662 TOKEN_NUM_INITIALIZER
12663 (struct cmd_set_vf_vlan_tag_result,
12664 port_id, RTE_UINT16);
12665 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12666 TOKEN_NUM_INITIALIZER
12667 (struct cmd_set_vf_vlan_tag_result,
12668 vf_id, RTE_UINT16);
12669 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12670 TOKEN_STRING_INITIALIZER
12671 (struct cmd_set_vf_vlan_tag_result,
12675 cmd_set_vf_vlan_tag_parsed(
12676 void *parsed_result,
12677 __rte_unused struct cmdline *cl,
12678 __rte_unused void *data)
12680 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12681 int ret = -ENOTSUP;
12683 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12685 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12688 #ifdef RTE_NET_I40E
12689 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12690 res->vf_id, is_on);
12697 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12698 res->vf_id, is_on);
12701 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12704 fprintf(stderr, "function not implemented\n");
12707 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12711 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12712 .f = cmd_set_vf_vlan_tag_parsed,
12714 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12716 (void *)&cmd_set_vf_vlan_tag_set,
12717 (void *)&cmd_set_vf_vlan_tag_vf,
12718 (void *)&cmd_set_vf_vlan_tag_vlan,
12719 (void *)&cmd_set_vf_vlan_tag_tag,
12720 (void *)&cmd_set_vf_vlan_tag_port_id,
12721 (void *)&cmd_set_vf_vlan_tag_vf_id,
12722 (void *)&cmd_set_vf_vlan_tag_on_off,
12727 /* Common definition of VF and TC TX bandwidth configuration */
12728 struct cmd_vf_tc_bw_result {
12729 cmdline_fixed_string_t set;
12730 cmdline_fixed_string_t vf;
12731 cmdline_fixed_string_t tc;
12732 cmdline_fixed_string_t tx;
12733 cmdline_fixed_string_t min_bw;
12734 cmdline_fixed_string_t max_bw;
12735 cmdline_fixed_string_t strict_link_prio;
12740 cmdline_fixed_string_t bw_list;
12744 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12745 TOKEN_STRING_INITIALIZER
12746 (struct cmd_vf_tc_bw_result,
12748 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12749 TOKEN_STRING_INITIALIZER
12750 (struct cmd_vf_tc_bw_result,
12752 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12753 TOKEN_STRING_INITIALIZER
12754 (struct cmd_vf_tc_bw_result,
12756 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12757 TOKEN_STRING_INITIALIZER
12758 (struct cmd_vf_tc_bw_result,
12760 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12761 TOKEN_STRING_INITIALIZER
12762 (struct cmd_vf_tc_bw_result,
12763 strict_link_prio, "strict-link-priority");
12764 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12765 TOKEN_STRING_INITIALIZER
12766 (struct cmd_vf_tc_bw_result,
12767 min_bw, "min-bandwidth");
12768 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12769 TOKEN_STRING_INITIALIZER
12770 (struct cmd_vf_tc_bw_result,
12771 max_bw, "max-bandwidth");
12772 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12773 TOKEN_NUM_INITIALIZER
12774 (struct cmd_vf_tc_bw_result,
12775 port_id, RTE_UINT16);
12776 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12777 TOKEN_NUM_INITIALIZER
12778 (struct cmd_vf_tc_bw_result,
12779 vf_id, RTE_UINT16);
12780 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12781 TOKEN_NUM_INITIALIZER
12782 (struct cmd_vf_tc_bw_result,
12784 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12785 TOKEN_NUM_INITIALIZER
12786 (struct cmd_vf_tc_bw_result,
12788 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12789 TOKEN_STRING_INITIALIZER
12790 (struct cmd_vf_tc_bw_result,
12792 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12793 TOKEN_NUM_INITIALIZER
12794 (struct cmd_vf_tc_bw_result,
12795 tc_map, RTE_UINT8);
12797 /* VF max bandwidth setting */
12799 cmd_vf_max_bw_parsed(
12800 void *parsed_result,
12801 __rte_unused struct cmdline *cl,
12802 __rte_unused void *data)
12804 struct cmd_vf_tc_bw_result *res = parsed_result;
12805 int ret = -ENOTSUP;
12807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12810 #ifdef RTE_NET_I40E
12811 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12812 res->vf_id, res->bw);
12819 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12820 res->vf_id, res->bw);
12823 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12826 fprintf(stderr, "function not implemented\n");
12829 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12833 cmdline_parse_inst_t cmd_vf_max_bw = {
12834 .f = cmd_vf_max_bw_parsed,
12836 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12838 (void *)&cmd_vf_tc_bw_set,
12839 (void *)&cmd_vf_tc_bw_vf,
12840 (void *)&cmd_vf_tc_bw_tx,
12841 (void *)&cmd_vf_tc_bw_max_bw,
12842 (void *)&cmd_vf_tc_bw_port_id,
12843 (void *)&cmd_vf_tc_bw_vf_id,
12844 (void *)&cmd_vf_tc_bw_bw,
12850 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12855 const char *p, *p0 = str;
12862 p = strchr(p0, '(');
12865 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12869 p0 = strchr(p, ')');
12872 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12876 if (size >= sizeof(s)) {
12878 "The string size exceeds the internal buffer size\n");
12881 snprintf(s, sizeof(s), "%.*s", size, p);
12882 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12884 fprintf(stderr, "Failed to get the bandwidth list.\n");
12888 for (i = 0; i < ret; i++)
12889 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12894 /* TC min bandwidth setting */
12896 cmd_vf_tc_min_bw_parsed(
12897 void *parsed_result,
12898 __rte_unused struct cmdline *cl,
12899 __rte_unused void *data)
12901 struct cmd_vf_tc_bw_result *res = parsed_result;
12904 int ret = -ENOTSUP;
12906 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12909 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12913 #ifdef RTE_NET_I40E
12914 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12922 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12925 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12928 fprintf(stderr, "function not implemented\n");
12931 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12935 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12936 .f = cmd_vf_tc_min_bw_parsed,
12938 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12939 " <bw1, bw2, ...>",
12941 (void *)&cmd_vf_tc_bw_set,
12942 (void *)&cmd_vf_tc_bw_vf,
12943 (void *)&cmd_vf_tc_bw_tc,
12944 (void *)&cmd_vf_tc_bw_tx,
12945 (void *)&cmd_vf_tc_bw_min_bw,
12946 (void *)&cmd_vf_tc_bw_port_id,
12947 (void *)&cmd_vf_tc_bw_vf_id,
12948 (void *)&cmd_vf_tc_bw_bw_list,
12954 cmd_tc_min_bw_parsed(
12955 void *parsed_result,
12956 __rte_unused struct cmdline *cl,
12957 __rte_unused void *data)
12959 struct cmd_vf_tc_bw_result *res = parsed_result;
12960 struct rte_port *port;
12963 int ret = -ENOTSUP;
12965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12968 port = &ports[res->port_id];
12969 /** Check if the port is not started **/
12970 if (port->port_status != RTE_PORT_STOPPED) {
12971 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12975 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12979 #ifdef RTE_NET_IXGBE
12980 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12987 fprintf(stderr, "invalid bandwidth\n");
12990 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12993 fprintf(stderr, "function not implemented\n");
12996 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13000 cmdline_parse_inst_t cmd_tc_min_bw = {
13001 .f = cmd_tc_min_bw_parsed,
13003 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13005 (void *)&cmd_vf_tc_bw_set,
13006 (void *)&cmd_vf_tc_bw_tc,
13007 (void *)&cmd_vf_tc_bw_tx,
13008 (void *)&cmd_vf_tc_bw_min_bw,
13009 (void *)&cmd_vf_tc_bw_port_id,
13010 (void *)&cmd_vf_tc_bw_bw_list,
13015 /* TC max bandwidth setting */
13017 cmd_vf_tc_max_bw_parsed(
13018 void *parsed_result,
13019 __rte_unused struct cmdline *cl,
13020 __rte_unused void *data)
13022 struct cmd_vf_tc_bw_result *res = parsed_result;
13023 int ret = -ENOTSUP;
13025 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13028 #ifdef RTE_NET_I40E
13029 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13030 res->tc_no, res->bw);
13038 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
13039 res->vf_id, res->tc_no, res->bw);
13042 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13045 fprintf(stderr, "function not implemented\n");
13048 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13052 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13053 .f = cmd_vf_tc_max_bw_parsed,
13055 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13058 (void *)&cmd_vf_tc_bw_set,
13059 (void *)&cmd_vf_tc_bw_vf,
13060 (void *)&cmd_vf_tc_bw_tc,
13061 (void *)&cmd_vf_tc_bw_tx,
13062 (void *)&cmd_vf_tc_bw_max_bw,
13063 (void *)&cmd_vf_tc_bw_port_id,
13064 (void *)&cmd_vf_tc_bw_vf_id,
13065 (void *)&cmd_vf_tc_bw_tc_no,
13066 (void *)&cmd_vf_tc_bw_bw,
13071 /** Set VXLAN encapsulation details */
13072 struct cmd_set_vxlan_result {
13073 cmdline_fixed_string_t set;
13074 cmdline_fixed_string_t vxlan;
13075 cmdline_fixed_string_t pos_token;
13076 cmdline_fixed_string_t ip_version;
13077 uint32_t vlan_present:1;
13081 cmdline_ipaddr_t ip_src;
13082 cmdline_ipaddr_t ip_dst;
13086 struct rte_ether_addr eth_src;
13087 struct rte_ether_addr eth_dst;
13090 cmdline_parse_token_string_t cmd_set_vxlan_set =
13091 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
13092 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
13093 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
13094 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
13095 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13097 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
13098 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13099 "vxlan-with-vlan");
13100 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
13101 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13103 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
13104 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
13106 cmdline_parse_token_string_t cmd_set_vxlan_vni =
13107 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13109 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
13110 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
13111 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
13112 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13114 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
13115 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
13116 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
13117 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13119 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
13120 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
13121 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13122 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13124 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13125 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
13126 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13127 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13129 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13130 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
13131 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13132 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13134 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13135 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13136 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13137 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13139 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13140 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13141 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13142 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13144 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13145 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13146 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13147 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13149 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13150 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13151 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13152 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13154 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13155 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13157 static void cmd_set_vxlan_parsed(void *parsed_result,
13158 __rte_unused struct cmdline *cl,
13159 __rte_unused void *data)
13161 struct cmd_set_vxlan_result *res = parsed_result;
13166 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13169 vxlan_encap_conf.select_tos_ttl = 0;
13170 if (strcmp(res->vxlan, "vxlan") == 0)
13171 vxlan_encap_conf.select_vlan = 0;
13172 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13173 vxlan_encap_conf.select_vlan = 1;
13174 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13175 vxlan_encap_conf.select_vlan = 0;
13176 vxlan_encap_conf.select_tos_ttl = 1;
13178 if (strcmp(res->ip_version, "ipv4") == 0)
13179 vxlan_encap_conf.select_ipv4 = 1;
13180 else if (strcmp(res->ip_version, "ipv6") == 0)
13181 vxlan_encap_conf.select_ipv4 = 0;
13184 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13185 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13186 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13187 vxlan_encap_conf.ip_tos = res->tos;
13188 vxlan_encap_conf.ip_ttl = res->ttl;
13189 if (vxlan_encap_conf.select_ipv4) {
13190 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13191 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13193 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13194 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13196 if (vxlan_encap_conf.select_vlan)
13197 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13198 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13199 RTE_ETHER_ADDR_LEN);
13200 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13201 RTE_ETHER_ADDR_LEN);
13204 cmdline_parse_inst_t cmd_set_vxlan = {
13205 .f = cmd_set_vxlan_parsed,
13207 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13208 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13209 " eth-src <eth-src> eth-dst <eth-dst>",
13211 (void *)&cmd_set_vxlan_set,
13212 (void *)&cmd_set_vxlan_vxlan,
13213 (void *)&cmd_set_vxlan_ip_version,
13214 (void *)&cmd_set_vxlan_ip_version_value,
13215 (void *)&cmd_set_vxlan_vni,
13216 (void *)&cmd_set_vxlan_vni_value,
13217 (void *)&cmd_set_vxlan_udp_src,
13218 (void *)&cmd_set_vxlan_udp_src_value,
13219 (void *)&cmd_set_vxlan_udp_dst,
13220 (void *)&cmd_set_vxlan_udp_dst_value,
13221 (void *)&cmd_set_vxlan_ip_src,
13222 (void *)&cmd_set_vxlan_ip_src_value,
13223 (void *)&cmd_set_vxlan_ip_dst,
13224 (void *)&cmd_set_vxlan_ip_dst_value,
13225 (void *)&cmd_set_vxlan_eth_src,
13226 (void *)&cmd_set_vxlan_eth_src_value,
13227 (void *)&cmd_set_vxlan_eth_dst,
13228 (void *)&cmd_set_vxlan_eth_dst_value,
13233 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13234 .f = cmd_set_vxlan_parsed,
13236 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13237 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13238 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13239 " eth-dst <eth-dst>",
13241 (void *)&cmd_set_vxlan_set,
13242 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13243 (void *)&cmd_set_vxlan_ip_version,
13244 (void *)&cmd_set_vxlan_ip_version_value,
13245 (void *)&cmd_set_vxlan_vni,
13246 (void *)&cmd_set_vxlan_vni_value,
13247 (void *)&cmd_set_vxlan_udp_src,
13248 (void *)&cmd_set_vxlan_udp_src_value,
13249 (void *)&cmd_set_vxlan_udp_dst,
13250 (void *)&cmd_set_vxlan_udp_dst_value,
13251 (void *)&cmd_set_vxlan_ip_tos,
13252 (void *)&cmd_set_vxlan_ip_tos_value,
13253 (void *)&cmd_set_vxlan_ip_ttl,
13254 (void *)&cmd_set_vxlan_ip_ttl_value,
13255 (void *)&cmd_set_vxlan_ip_src,
13256 (void *)&cmd_set_vxlan_ip_src_value,
13257 (void *)&cmd_set_vxlan_ip_dst,
13258 (void *)&cmd_set_vxlan_ip_dst_value,
13259 (void *)&cmd_set_vxlan_eth_src,
13260 (void *)&cmd_set_vxlan_eth_src_value,
13261 (void *)&cmd_set_vxlan_eth_dst,
13262 (void *)&cmd_set_vxlan_eth_dst_value,
13267 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13268 .f = cmd_set_vxlan_parsed,
13270 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13271 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13272 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13275 (void *)&cmd_set_vxlan_set,
13276 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13277 (void *)&cmd_set_vxlan_ip_version,
13278 (void *)&cmd_set_vxlan_ip_version_value,
13279 (void *)&cmd_set_vxlan_vni,
13280 (void *)&cmd_set_vxlan_vni_value,
13281 (void *)&cmd_set_vxlan_udp_src,
13282 (void *)&cmd_set_vxlan_udp_src_value,
13283 (void *)&cmd_set_vxlan_udp_dst,
13284 (void *)&cmd_set_vxlan_udp_dst_value,
13285 (void *)&cmd_set_vxlan_ip_src,
13286 (void *)&cmd_set_vxlan_ip_src_value,
13287 (void *)&cmd_set_vxlan_ip_dst,
13288 (void *)&cmd_set_vxlan_ip_dst_value,
13289 (void *)&cmd_set_vxlan_vlan,
13290 (void *)&cmd_set_vxlan_vlan_value,
13291 (void *)&cmd_set_vxlan_eth_src,
13292 (void *)&cmd_set_vxlan_eth_src_value,
13293 (void *)&cmd_set_vxlan_eth_dst,
13294 (void *)&cmd_set_vxlan_eth_dst_value,
13299 /** Set NVGRE encapsulation details */
13300 struct cmd_set_nvgre_result {
13301 cmdline_fixed_string_t set;
13302 cmdline_fixed_string_t nvgre;
13303 cmdline_fixed_string_t pos_token;
13304 cmdline_fixed_string_t ip_version;
13306 cmdline_ipaddr_t ip_src;
13307 cmdline_ipaddr_t ip_dst;
13309 struct rte_ether_addr eth_src;
13310 struct rte_ether_addr eth_dst;
13313 cmdline_parse_token_string_t cmd_set_nvgre_set =
13314 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13315 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13316 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13317 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13318 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13319 "nvgre-with-vlan");
13320 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13321 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13323 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13324 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13326 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13327 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13329 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13330 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13331 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13332 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13334 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13335 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13336 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13337 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13339 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13340 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13341 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13342 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13344 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13345 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13346 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13347 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13349 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13350 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13351 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13352 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13354 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13355 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13357 static void cmd_set_nvgre_parsed(void *parsed_result,
13358 __rte_unused struct cmdline *cl,
13359 __rte_unused void *data)
13361 struct cmd_set_nvgre_result *res = parsed_result;
13363 uint32_t nvgre_tni;
13366 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13369 if (strcmp(res->nvgre, "nvgre") == 0)
13370 nvgre_encap_conf.select_vlan = 0;
13371 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13372 nvgre_encap_conf.select_vlan = 1;
13373 if (strcmp(res->ip_version, "ipv4") == 0)
13374 nvgre_encap_conf.select_ipv4 = 1;
13375 else if (strcmp(res->ip_version, "ipv6") == 0)
13376 nvgre_encap_conf.select_ipv4 = 0;
13379 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13380 if (nvgre_encap_conf.select_ipv4) {
13381 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13382 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13384 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13385 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13387 if (nvgre_encap_conf.select_vlan)
13388 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13389 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13390 RTE_ETHER_ADDR_LEN);
13391 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13392 RTE_ETHER_ADDR_LEN);
13395 cmdline_parse_inst_t cmd_set_nvgre = {
13396 .f = cmd_set_nvgre_parsed,
13398 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13399 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13400 " eth-dst <eth-dst>",
13402 (void *)&cmd_set_nvgre_set,
13403 (void *)&cmd_set_nvgre_nvgre,
13404 (void *)&cmd_set_nvgre_ip_version,
13405 (void *)&cmd_set_nvgre_ip_version_value,
13406 (void *)&cmd_set_nvgre_tni,
13407 (void *)&cmd_set_nvgre_tni_value,
13408 (void *)&cmd_set_nvgre_ip_src,
13409 (void *)&cmd_set_nvgre_ip_src_value,
13410 (void *)&cmd_set_nvgre_ip_dst,
13411 (void *)&cmd_set_nvgre_ip_dst_value,
13412 (void *)&cmd_set_nvgre_eth_src,
13413 (void *)&cmd_set_nvgre_eth_src_value,
13414 (void *)&cmd_set_nvgre_eth_dst,
13415 (void *)&cmd_set_nvgre_eth_dst_value,
13420 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13421 .f = cmd_set_nvgre_parsed,
13423 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13424 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13425 " eth-src <eth-src> eth-dst <eth-dst>",
13427 (void *)&cmd_set_nvgre_set,
13428 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13429 (void *)&cmd_set_nvgre_ip_version,
13430 (void *)&cmd_set_nvgre_ip_version_value,
13431 (void *)&cmd_set_nvgre_tni,
13432 (void *)&cmd_set_nvgre_tni_value,
13433 (void *)&cmd_set_nvgre_ip_src,
13434 (void *)&cmd_set_nvgre_ip_src_value,
13435 (void *)&cmd_set_nvgre_ip_dst,
13436 (void *)&cmd_set_nvgre_ip_dst_value,
13437 (void *)&cmd_set_nvgre_vlan,
13438 (void *)&cmd_set_nvgre_vlan_value,
13439 (void *)&cmd_set_nvgre_eth_src,
13440 (void *)&cmd_set_nvgre_eth_src_value,
13441 (void *)&cmd_set_nvgre_eth_dst,
13442 (void *)&cmd_set_nvgre_eth_dst_value,
13447 /** Set L2 encapsulation details */
13448 struct cmd_set_l2_encap_result {
13449 cmdline_fixed_string_t set;
13450 cmdline_fixed_string_t l2_encap;
13451 cmdline_fixed_string_t pos_token;
13452 cmdline_fixed_string_t ip_version;
13453 uint32_t vlan_present:1;
13455 struct rte_ether_addr eth_src;
13456 struct rte_ether_addr eth_dst;
13459 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13460 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13461 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13462 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13463 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13464 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13465 "l2_encap-with-vlan");
13466 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13467 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13469 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13470 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13472 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13473 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13475 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13476 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13477 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13478 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13480 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13481 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13482 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13483 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13485 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13486 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13488 static void cmd_set_l2_encap_parsed(void *parsed_result,
13489 __rte_unused struct cmdline *cl,
13490 __rte_unused void *data)
13492 struct cmd_set_l2_encap_result *res = parsed_result;
13494 if (strcmp(res->l2_encap, "l2_encap") == 0)
13495 l2_encap_conf.select_vlan = 0;
13496 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13497 l2_encap_conf.select_vlan = 1;
13498 if (strcmp(res->ip_version, "ipv4") == 0)
13499 l2_encap_conf.select_ipv4 = 1;
13500 else if (strcmp(res->ip_version, "ipv6") == 0)
13501 l2_encap_conf.select_ipv4 = 0;
13504 if (l2_encap_conf.select_vlan)
13505 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13506 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13507 RTE_ETHER_ADDR_LEN);
13508 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13509 RTE_ETHER_ADDR_LEN);
13512 cmdline_parse_inst_t cmd_set_l2_encap = {
13513 .f = cmd_set_l2_encap_parsed,
13515 .help_str = "set l2_encap ip-version ipv4|ipv6"
13516 " eth-src <eth-src> eth-dst <eth-dst>",
13518 (void *)&cmd_set_l2_encap_set,
13519 (void *)&cmd_set_l2_encap_l2_encap,
13520 (void *)&cmd_set_l2_encap_ip_version,
13521 (void *)&cmd_set_l2_encap_ip_version_value,
13522 (void *)&cmd_set_l2_encap_eth_src,
13523 (void *)&cmd_set_l2_encap_eth_src_value,
13524 (void *)&cmd_set_l2_encap_eth_dst,
13525 (void *)&cmd_set_l2_encap_eth_dst_value,
13530 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13531 .f = cmd_set_l2_encap_parsed,
13533 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13534 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13536 (void *)&cmd_set_l2_encap_set,
13537 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13538 (void *)&cmd_set_l2_encap_ip_version,
13539 (void *)&cmd_set_l2_encap_ip_version_value,
13540 (void *)&cmd_set_l2_encap_vlan,
13541 (void *)&cmd_set_l2_encap_vlan_value,
13542 (void *)&cmd_set_l2_encap_eth_src,
13543 (void *)&cmd_set_l2_encap_eth_src_value,
13544 (void *)&cmd_set_l2_encap_eth_dst,
13545 (void *)&cmd_set_l2_encap_eth_dst_value,
13550 /** Set L2 decapsulation details */
13551 struct cmd_set_l2_decap_result {
13552 cmdline_fixed_string_t set;
13553 cmdline_fixed_string_t l2_decap;
13554 cmdline_fixed_string_t pos_token;
13555 uint32_t vlan_present:1;
13558 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13559 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13560 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13561 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13563 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13564 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13565 "l2_decap-with-vlan");
13567 static void cmd_set_l2_decap_parsed(void *parsed_result,
13568 __rte_unused struct cmdline *cl,
13569 __rte_unused void *data)
13571 struct cmd_set_l2_decap_result *res = parsed_result;
13573 if (strcmp(res->l2_decap, "l2_decap") == 0)
13574 l2_decap_conf.select_vlan = 0;
13575 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13576 l2_decap_conf.select_vlan = 1;
13579 cmdline_parse_inst_t cmd_set_l2_decap = {
13580 .f = cmd_set_l2_decap_parsed,
13582 .help_str = "set l2_decap",
13584 (void *)&cmd_set_l2_decap_set,
13585 (void *)&cmd_set_l2_decap_l2_decap,
13590 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13591 .f = cmd_set_l2_decap_parsed,
13593 .help_str = "set l2_decap-with-vlan",
13595 (void *)&cmd_set_l2_decap_set,
13596 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13601 /** Set MPLSoGRE encapsulation details */
13602 struct cmd_set_mplsogre_encap_result {
13603 cmdline_fixed_string_t set;
13604 cmdline_fixed_string_t mplsogre;
13605 cmdline_fixed_string_t pos_token;
13606 cmdline_fixed_string_t ip_version;
13607 uint32_t vlan_present:1;
13609 cmdline_ipaddr_t ip_src;
13610 cmdline_ipaddr_t ip_dst;
13612 struct rte_ether_addr eth_src;
13613 struct rte_ether_addr eth_dst;
13616 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13617 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13619 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13620 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13622 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13623 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13624 mplsogre, "mplsogre_encap-with-vlan");
13625 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13626 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13627 pos_token, "ip-version");
13628 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13629 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13630 ip_version, "ipv4#ipv6");
13631 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13632 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13633 pos_token, "label");
13634 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13635 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13637 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13638 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13639 pos_token, "ip-src");
13640 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13641 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13642 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13643 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13644 pos_token, "ip-dst");
13645 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13646 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13647 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13648 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13649 pos_token, "vlan-tci");
13650 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13651 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13653 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13654 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13655 pos_token, "eth-src");
13656 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13657 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13659 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13660 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13661 pos_token, "eth-dst");
13662 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13663 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13666 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13667 __rte_unused struct cmdline *cl,
13668 __rte_unused void *data)
13670 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13672 uint32_t mplsogre_label;
13675 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13678 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13679 mplsogre_encap_conf.select_vlan = 0;
13680 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13681 mplsogre_encap_conf.select_vlan = 1;
13682 if (strcmp(res->ip_version, "ipv4") == 0)
13683 mplsogre_encap_conf.select_ipv4 = 1;
13684 else if (strcmp(res->ip_version, "ipv6") == 0)
13685 mplsogre_encap_conf.select_ipv4 = 0;
13688 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13689 if (mplsogre_encap_conf.select_ipv4) {
13690 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13691 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13693 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13694 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13696 if (mplsogre_encap_conf.select_vlan)
13697 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13698 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13699 RTE_ETHER_ADDR_LEN);
13700 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13701 RTE_ETHER_ADDR_LEN);
13704 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13705 .f = cmd_set_mplsogre_encap_parsed,
13707 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13708 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13709 " eth-dst <eth-dst>",
13711 (void *)&cmd_set_mplsogre_encap_set,
13712 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13713 (void *)&cmd_set_mplsogre_encap_ip_version,
13714 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13715 (void *)&cmd_set_mplsogre_encap_label,
13716 (void *)&cmd_set_mplsogre_encap_label_value,
13717 (void *)&cmd_set_mplsogre_encap_ip_src,
13718 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13719 (void *)&cmd_set_mplsogre_encap_ip_dst,
13720 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13721 (void *)&cmd_set_mplsogre_encap_eth_src,
13722 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13723 (void *)&cmd_set_mplsogre_encap_eth_dst,
13724 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13729 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13730 .f = cmd_set_mplsogre_encap_parsed,
13732 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13733 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13734 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13736 (void *)&cmd_set_mplsogre_encap_set,
13737 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13738 (void *)&cmd_set_mplsogre_encap_ip_version,
13739 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13740 (void *)&cmd_set_mplsogre_encap_label,
13741 (void *)&cmd_set_mplsogre_encap_label_value,
13742 (void *)&cmd_set_mplsogre_encap_ip_src,
13743 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13744 (void *)&cmd_set_mplsogre_encap_ip_dst,
13745 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13746 (void *)&cmd_set_mplsogre_encap_vlan,
13747 (void *)&cmd_set_mplsogre_encap_vlan_value,
13748 (void *)&cmd_set_mplsogre_encap_eth_src,
13749 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13750 (void *)&cmd_set_mplsogre_encap_eth_dst,
13751 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13756 /** Set MPLSoGRE decapsulation details */
13757 struct cmd_set_mplsogre_decap_result {
13758 cmdline_fixed_string_t set;
13759 cmdline_fixed_string_t mplsogre;
13760 cmdline_fixed_string_t pos_token;
13761 cmdline_fixed_string_t ip_version;
13762 uint32_t vlan_present:1;
13765 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13766 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13768 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13769 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13771 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13772 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13773 mplsogre, "mplsogre_decap-with-vlan");
13774 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13775 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13776 pos_token, "ip-version");
13777 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13778 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13779 ip_version, "ipv4#ipv6");
13781 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13782 __rte_unused struct cmdline *cl,
13783 __rte_unused void *data)
13785 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13787 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13788 mplsogre_decap_conf.select_vlan = 0;
13789 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13790 mplsogre_decap_conf.select_vlan = 1;
13791 if (strcmp(res->ip_version, "ipv4") == 0)
13792 mplsogre_decap_conf.select_ipv4 = 1;
13793 else if (strcmp(res->ip_version, "ipv6") == 0)
13794 mplsogre_decap_conf.select_ipv4 = 0;
13797 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13798 .f = cmd_set_mplsogre_decap_parsed,
13800 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13802 (void *)&cmd_set_mplsogre_decap_set,
13803 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13804 (void *)&cmd_set_mplsogre_decap_ip_version,
13805 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13810 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13811 .f = cmd_set_mplsogre_decap_parsed,
13813 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13815 (void *)&cmd_set_mplsogre_decap_set,
13816 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13817 (void *)&cmd_set_mplsogre_decap_ip_version,
13818 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13823 /** Set MPLSoUDP encapsulation details */
13824 struct cmd_set_mplsoudp_encap_result {
13825 cmdline_fixed_string_t set;
13826 cmdline_fixed_string_t mplsoudp;
13827 cmdline_fixed_string_t pos_token;
13828 cmdline_fixed_string_t ip_version;
13829 uint32_t vlan_present:1;
13833 cmdline_ipaddr_t ip_src;
13834 cmdline_ipaddr_t ip_dst;
13836 struct rte_ether_addr eth_src;
13837 struct rte_ether_addr eth_dst;
13840 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13841 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13843 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13844 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13846 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13847 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13848 mplsoudp, "mplsoudp_encap-with-vlan");
13849 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13850 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13851 pos_token, "ip-version");
13852 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13853 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13854 ip_version, "ipv4#ipv6");
13855 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13856 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13857 pos_token, "label");
13858 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13859 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13861 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13862 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13863 pos_token, "udp-src");
13864 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13865 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13867 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13868 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13869 pos_token, "udp-dst");
13870 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13871 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13873 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13874 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13875 pos_token, "ip-src");
13876 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13877 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13878 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13879 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13880 pos_token, "ip-dst");
13881 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13882 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13883 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13884 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13885 pos_token, "vlan-tci");
13886 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13887 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13889 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13890 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13891 pos_token, "eth-src");
13892 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13893 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13895 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13896 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13897 pos_token, "eth-dst");
13898 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13899 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13902 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13903 __rte_unused struct cmdline *cl,
13904 __rte_unused void *data)
13906 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13908 uint32_t mplsoudp_label;
13911 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13914 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13915 mplsoudp_encap_conf.select_vlan = 0;
13916 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13917 mplsoudp_encap_conf.select_vlan = 1;
13918 if (strcmp(res->ip_version, "ipv4") == 0)
13919 mplsoudp_encap_conf.select_ipv4 = 1;
13920 else if (strcmp(res->ip_version, "ipv6") == 0)
13921 mplsoudp_encap_conf.select_ipv4 = 0;
13924 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13925 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13926 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13927 if (mplsoudp_encap_conf.select_ipv4) {
13928 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13929 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13931 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13932 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13934 if (mplsoudp_encap_conf.select_vlan)
13935 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13936 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13937 RTE_ETHER_ADDR_LEN);
13938 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13939 RTE_ETHER_ADDR_LEN);
13942 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13943 .f = cmd_set_mplsoudp_encap_parsed,
13945 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13946 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13947 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13949 (void *)&cmd_set_mplsoudp_encap_set,
13950 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13951 (void *)&cmd_set_mplsoudp_encap_ip_version,
13952 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13953 (void *)&cmd_set_mplsoudp_encap_label,
13954 (void *)&cmd_set_mplsoudp_encap_label_value,
13955 (void *)&cmd_set_mplsoudp_encap_udp_src,
13956 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13957 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13958 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13959 (void *)&cmd_set_mplsoudp_encap_ip_src,
13960 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13961 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13962 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13963 (void *)&cmd_set_mplsoudp_encap_eth_src,
13964 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13965 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13966 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13971 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13972 .f = cmd_set_mplsoudp_encap_parsed,
13974 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13975 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13976 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13977 " eth-src <eth-src> eth-dst <eth-dst>",
13979 (void *)&cmd_set_mplsoudp_encap_set,
13980 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13981 (void *)&cmd_set_mplsoudp_encap_ip_version,
13982 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13983 (void *)&cmd_set_mplsoudp_encap_label,
13984 (void *)&cmd_set_mplsoudp_encap_label_value,
13985 (void *)&cmd_set_mplsoudp_encap_udp_src,
13986 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13987 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13988 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13989 (void *)&cmd_set_mplsoudp_encap_ip_src,
13990 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13991 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13992 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13993 (void *)&cmd_set_mplsoudp_encap_vlan,
13994 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13995 (void *)&cmd_set_mplsoudp_encap_eth_src,
13996 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13997 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13998 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14003 /** Set MPLSoUDP decapsulation details */
14004 struct cmd_set_mplsoudp_decap_result {
14005 cmdline_fixed_string_t set;
14006 cmdline_fixed_string_t mplsoudp;
14007 cmdline_fixed_string_t pos_token;
14008 cmdline_fixed_string_t ip_version;
14009 uint32_t vlan_present:1;
14012 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
14013 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
14015 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
14016 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
14018 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
14019 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14020 mplsoudp, "mplsoudp_decap-with-vlan");
14021 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
14022 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14023 pos_token, "ip-version");
14024 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
14025 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14026 ip_version, "ipv4#ipv6");
14028 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
14029 __rte_unused struct cmdline *cl,
14030 __rte_unused void *data)
14032 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
14034 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
14035 mplsoudp_decap_conf.select_vlan = 0;
14036 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
14037 mplsoudp_decap_conf.select_vlan = 1;
14038 if (strcmp(res->ip_version, "ipv4") == 0)
14039 mplsoudp_decap_conf.select_ipv4 = 1;
14040 else if (strcmp(res->ip_version, "ipv6") == 0)
14041 mplsoudp_decap_conf.select_ipv4 = 0;
14044 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
14045 .f = cmd_set_mplsoudp_decap_parsed,
14047 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
14049 (void *)&cmd_set_mplsoudp_decap_set,
14050 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
14051 (void *)&cmd_set_mplsoudp_decap_ip_version,
14052 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14057 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
14058 .f = cmd_set_mplsoudp_decap_parsed,
14060 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
14062 (void *)&cmd_set_mplsoudp_decap_set,
14063 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
14064 (void *)&cmd_set_mplsoudp_decap_ip_version,
14065 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14070 /** Set connection tracking object common details */
14071 struct cmd_set_conntrack_common_result {
14072 cmdline_fixed_string_t set;
14073 cmdline_fixed_string_t conntrack;
14074 cmdline_fixed_string_t common;
14075 cmdline_fixed_string_t peer;
14076 cmdline_fixed_string_t is_orig;
14077 cmdline_fixed_string_t enable;
14078 cmdline_fixed_string_t live;
14079 cmdline_fixed_string_t sack;
14080 cmdline_fixed_string_t cack;
14081 cmdline_fixed_string_t last_dir;
14082 cmdline_fixed_string_t liberal;
14083 cmdline_fixed_string_t state;
14084 cmdline_fixed_string_t max_ack_win;
14085 cmdline_fixed_string_t retrans;
14086 cmdline_fixed_string_t last_win;
14087 cmdline_fixed_string_t last_seq;
14088 cmdline_fixed_string_t last_ack;
14089 cmdline_fixed_string_t last_end;
14090 cmdline_fixed_string_t last_index;
14093 uint16_t peer_port;
14094 uint32_t is_original;
14109 cmdline_parse_token_string_t cmd_set_conntrack_set =
14110 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14112 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
14113 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14114 conntrack, "conntrack");
14115 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
14116 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14118 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
14119 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14121 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
14122 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14123 peer_port, RTE_UINT16);
14124 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
14125 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14126 is_orig, "is_orig");
14127 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
14128 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14129 is_original, RTE_UINT32);
14130 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
14131 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14133 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14134 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14136 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14137 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14139 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14140 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14141 is_live, RTE_UINT32);
14142 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14143 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14145 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14146 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14147 s_ack, RTE_UINT32);
14148 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14149 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14151 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14152 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14153 c_ack, RTE_UINT32);
14154 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14155 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14156 last_dir, "last_dir");
14157 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14158 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14160 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14161 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14162 liberal, "liberal");
14163 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14164 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14166 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14167 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14169 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14170 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14172 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14173 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14174 max_ack_win, "max_ack_win");
14175 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14176 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14177 factor, RTE_UINT8);
14178 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14179 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14181 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14182 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14183 re_num, RTE_UINT8);
14184 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14185 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14186 last_win, "last_win");
14187 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14188 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14190 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14191 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14192 last_seq, "last_seq");
14193 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14194 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14196 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14197 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14198 last_ack, "last_ack");
14199 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14200 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14202 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14203 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14204 last_end, "last_end");
14205 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14206 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14208 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14209 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14210 last_index, "last_index");
14211 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14212 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14215 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14216 __rte_unused struct cmdline *cl,
14217 __rte_unused void *data)
14219 struct cmd_set_conntrack_common_result *res = parsed_result;
14221 /* No need to swap to big endian. */
14222 conntrack_context.peer_port = res->peer_port;
14223 conntrack_context.is_original_dir = res->is_original;
14224 conntrack_context.enable = res->en;
14225 conntrack_context.live_connection = res->is_live;
14226 conntrack_context.selective_ack = res->s_ack;
14227 conntrack_context.challenge_ack_passed = res->c_ack;
14228 conntrack_context.last_direction = res->ld;
14229 conntrack_context.liberal_mode = res->lb;
14230 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14231 conntrack_context.max_ack_window = res->factor;
14232 conntrack_context.retransmission_limit = res->re_num;
14233 conntrack_context.last_window = res->lw;
14234 conntrack_context.last_index =
14235 (enum rte_flow_conntrack_tcp_last_index)res->li;
14236 conntrack_context.last_seq = res->ls;
14237 conntrack_context.last_ack = res->la;
14238 conntrack_context.last_end = res->le;
14241 cmdline_parse_inst_t cmd_set_conntrack_common = {
14242 .f = cmd_set_conntrack_common_parsed,
14244 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14245 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14246 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14247 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14248 " last_index <flag>",
14250 (void *)&cmd_set_conntrack_set,
14251 (void *)&cmd_set_conntrack_conntrack,
14252 (void *)&cmd_set_conntrack_common_com,
14253 (void *)&cmd_set_conntrack_common_peer,
14254 (void *)&cmd_set_conntrack_common_peer_value,
14255 (void *)&cmd_set_conntrack_common_is_orig,
14256 (void *)&cmd_set_conntrack_common_is_orig_value,
14257 (void *)&cmd_set_conntrack_common_enable,
14258 (void *)&cmd_set_conntrack_common_enable_value,
14259 (void *)&cmd_set_conntrack_common_live,
14260 (void *)&cmd_set_conntrack_common_live_value,
14261 (void *)&cmd_set_conntrack_common_sack,
14262 (void *)&cmd_set_conntrack_common_sack_value,
14263 (void *)&cmd_set_conntrack_common_cack,
14264 (void *)&cmd_set_conntrack_common_cack_value,
14265 (void *)&cmd_set_conntrack_common_last_dir,
14266 (void *)&cmd_set_conntrack_common_last_dir_value,
14267 (void *)&cmd_set_conntrack_common_liberal,
14268 (void *)&cmd_set_conntrack_common_liberal_value,
14269 (void *)&cmd_set_conntrack_common_state,
14270 (void *)&cmd_set_conntrack_common_state_value,
14271 (void *)&cmd_set_conntrack_common_max_ackwin,
14272 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14273 (void *)&cmd_set_conntrack_common_retrans,
14274 (void *)&cmd_set_conntrack_common_retrans_value,
14275 (void *)&cmd_set_conntrack_common_last_win,
14276 (void *)&cmd_set_conntrack_common_last_win_value,
14277 (void *)&cmd_set_conntrack_common_last_seq,
14278 (void *)&cmd_set_conntrack_common_last_seq_value,
14279 (void *)&cmd_set_conntrack_common_last_ack,
14280 (void *)&cmd_set_conntrack_common_last_ack_value,
14281 (void *)&cmd_set_conntrack_common_last_end,
14282 (void *)&cmd_set_conntrack_common_last_end_value,
14283 (void *)&cmd_set_conntrack_common_last_index,
14284 (void *)&cmd_set_conntrack_common_last_index_value,
14289 /** Set connection tracking object both directions' details */
14290 struct cmd_set_conntrack_dir_result {
14291 cmdline_fixed_string_t set;
14292 cmdline_fixed_string_t conntrack;
14293 cmdline_fixed_string_t dir;
14294 cmdline_fixed_string_t scale;
14295 cmdline_fixed_string_t fin;
14296 cmdline_fixed_string_t ack_seen;
14297 cmdline_fixed_string_t unack;
14298 cmdline_fixed_string_t sent_end;
14299 cmdline_fixed_string_t reply_end;
14300 cmdline_fixed_string_t max_win;
14301 cmdline_fixed_string_t max_ack;
14312 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14313 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14315 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14316 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14317 conntrack, "conntrack");
14318 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14319 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14321 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14322 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14324 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14325 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14326 factor, RTE_UINT32);
14327 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14328 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14330 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14331 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14333 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14334 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14335 ack_seen, "acked");
14336 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14337 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14339 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14340 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14341 unack, "unack_data");
14342 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14343 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14345 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14346 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14347 sent_end, "sent_end");
14348 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14349 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14351 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14352 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14353 reply_end, "reply_end");
14354 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14355 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14357 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14358 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14359 max_win, "max_win");
14360 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14361 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14363 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14364 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14365 max_ack, "max_ack");
14366 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14367 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14370 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14371 __rte_unused struct cmdline *cl,
14372 __rte_unused void *data)
14374 struct cmd_set_conntrack_dir_result *res = parsed_result;
14375 struct rte_flow_tcp_dir_param *dir = NULL;
14377 if (strcmp(res->dir, "orig") == 0)
14378 dir = &conntrack_context.original_dir;
14379 else if (strcmp(res->dir, "rply") == 0)
14380 dir = &conntrack_context.reply_dir;
14383 dir->scale = res->factor;
14384 dir->close_initiated = res->f;
14385 dir->last_ack_seen = res->as;
14386 dir->data_unacked = res->un;
14387 dir->sent_end = res->se;
14388 dir->reply_end = res->re;
14389 dir->max_ack = res->ma;
14390 dir->max_win = res->mw;
14393 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14394 .f = cmd_set_conntrack_dir_parsed,
14396 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14397 " acked <seen> unack_data <unack> sent_end <sent>"
14398 " reply_end <reply> max_win <win> max_ack <ack>",
14400 (void *)&cmd_set_conntrack_set,
14401 (void *)&cmd_set_conntrack_conntrack,
14402 (void *)&cmd_set_conntrack_dir_dir,
14403 (void *)&cmd_set_conntrack_dir_scale,
14404 (void *)&cmd_set_conntrack_dir_scale_value,
14405 (void *)&cmd_set_conntrack_dir_fin,
14406 (void *)&cmd_set_conntrack_dir_fin_value,
14407 (void *)&cmd_set_conntrack_dir_ack,
14408 (void *)&cmd_set_conntrack_dir_ack_value,
14409 (void *)&cmd_set_conntrack_dir_unack_data,
14410 (void *)&cmd_set_conntrack_dir_unack_data_value,
14411 (void *)&cmd_set_conntrack_dir_sent_end,
14412 (void *)&cmd_set_conntrack_dir_sent_end_value,
14413 (void *)&cmd_set_conntrack_dir_reply_end,
14414 (void *)&cmd_set_conntrack_dir_reply_end_value,
14415 (void *)&cmd_set_conntrack_dir_max_win,
14416 (void *)&cmd_set_conntrack_dir_max_win_value,
14417 (void *)&cmd_set_conntrack_dir_max_ack,
14418 (void *)&cmd_set_conntrack_dir_max_ack_value,
14423 /* Strict link priority scheduling mode setting */
14425 cmd_strict_link_prio_parsed(
14426 void *parsed_result,
14427 __rte_unused struct cmdline *cl,
14428 __rte_unused void *data)
14430 struct cmd_vf_tc_bw_result *res = parsed_result;
14431 int ret = -ENOTSUP;
14433 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14436 #ifdef RTE_NET_I40E
14437 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14444 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14447 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14450 fprintf(stderr, "function not implemented\n");
14453 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14457 cmdline_parse_inst_t cmd_strict_link_prio = {
14458 .f = cmd_strict_link_prio_parsed,
14460 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14462 (void *)&cmd_vf_tc_bw_set,
14463 (void *)&cmd_vf_tc_bw_tx,
14464 (void *)&cmd_vf_tc_bw_strict_link_prio,
14465 (void *)&cmd_vf_tc_bw_port_id,
14466 (void *)&cmd_vf_tc_bw_tc_map,
14471 /* Load dynamic device personalization*/
14472 struct cmd_ddp_add_result {
14473 cmdline_fixed_string_t ddp;
14474 cmdline_fixed_string_t add;
14479 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14480 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14481 cmdline_parse_token_string_t cmd_ddp_add_add =
14482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14483 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14484 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14486 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14487 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14490 cmd_ddp_add_parsed(
14491 void *parsed_result,
14492 __rte_unused struct cmdline *cl,
14493 __rte_unused void *data)
14495 struct cmd_ddp_add_result *res = parsed_result;
14501 int ret = -ENOTSUP;
14503 if (!all_ports_stopped()) {
14504 fprintf(stderr, "Please stop all ports first\n");
14508 filepath = strdup(res->filepath);
14509 if (filepath == NULL) {
14510 fprintf(stderr, "Failed to allocate memory\n");
14513 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14515 buff = open_file(file_fld[0], &size);
14517 free((void *)filepath);
14521 #ifdef RTE_NET_I40E
14522 if (ret == -ENOTSUP)
14523 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14525 RTE_PMD_I40E_PKG_OP_WR_ADD);
14528 if (ret == -EEXIST)
14529 fprintf(stderr, "Profile has already existed.\n");
14531 fprintf(stderr, "Failed to load profile.\n");
14532 else if (file_num == 2)
14533 save_file(file_fld[1], buff, size);
14536 free((void *)filepath);
14539 cmdline_parse_inst_t cmd_ddp_add = {
14540 .f = cmd_ddp_add_parsed,
14542 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14544 (void *)&cmd_ddp_add_ddp,
14545 (void *)&cmd_ddp_add_add,
14546 (void *)&cmd_ddp_add_port_id,
14547 (void *)&cmd_ddp_add_filepath,
14552 /* Delete dynamic device personalization*/
14553 struct cmd_ddp_del_result {
14554 cmdline_fixed_string_t ddp;
14555 cmdline_fixed_string_t del;
14560 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14561 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14562 cmdline_parse_token_string_t cmd_ddp_del_del =
14563 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14564 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14565 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14566 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14567 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14570 cmd_ddp_del_parsed(
14571 void *parsed_result,
14572 __rte_unused struct cmdline *cl,
14573 __rte_unused void *data)
14575 struct cmd_ddp_del_result *res = parsed_result;
14578 int ret = -ENOTSUP;
14580 if (!all_ports_stopped()) {
14581 fprintf(stderr, "Please stop all ports first\n");
14585 buff = open_file(res->filepath, &size);
14589 #ifdef RTE_NET_I40E
14590 if (ret == -ENOTSUP)
14591 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14593 RTE_PMD_I40E_PKG_OP_WR_DEL);
14596 if (ret == -EACCES)
14597 fprintf(stderr, "Profile does not exist.\n");
14599 fprintf(stderr, "Failed to delete profile.\n");
14604 cmdline_parse_inst_t cmd_ddp_del = {
14605 .f = cmd_ddp_del_parsed,
14607 .help_str = "ddp del <port_id> <backup_profile_path>",
14609 (void *)&cmd_ddp_del_ddp,
14610 (void *)&cmd_ddp_del_del,
14611 (void *)&cmd_ddp_del_port_id,
14612 (void *)&cmd_ddp_del_filepath,
14617 /* Get dynamic device personalization profile info */
14618 struct cmd_ddp_info_result {
14619 cmdline_fixed_string_t ddp;
14620 cmdline_fixed_string_t get;
14621 cmdline_fixed_string_t info;
14625 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14626 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14627 cmdline_parse_token_string_t cmd_ddp_info_get =
14628 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14629 cmdline_parse_token_string_t cmd_ddp_info_info =
14630 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14631 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14632 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14635 cmd_ddp_info_parsed(
14636 void *parsed_result,
14637 __rte_unused struct cmdline *cl,
14638 __rte_unused void *data)
14640 struct cmd_ddp_info_result *res = parsed_result;
14643 int ret = -ENOTSUP;
14644 #ifdef RTE_NET_I40E
14647 uint32_t buff_size = 0;
14648 struct rte_pmd_i40e_profile_info info;
14649 uint32_t dev_num = 0;
14650 struct rte_pmd_i40e_ddp_device_id *devs;
14651 uint32_t proto_num = 0;
14652 struct rte_pmd_i40e_proto_info *proto = NULL;
14653 uint32_t pctype_num = 0;
14654 struct rte_pmd_i40e_ptype_info *pctype;
14655 uint32_t ptype_num = 0;
14656 struct rte_pmd_i40e_ptype_info *ptype;
14661 pkg = open_file(res->filepath, &pkg_size);
14665 #ifdef RTE_NET_I40E
14666 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14667 (uint8_t *)&info, sizeof(info),
14668 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14670 printf("Global Track id: 0x%x\n", info.track_id);
14671 printf("Global Version: %d.%d.%d.%d\n",
14672 info.version.major,
14673 info.version.minor,
14674 info.version.update,
14675 info.version.draft);
14676 printf("Global Package name: %s\n\n", info.name);
14679 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14680 (uint8_t *)&info, sizeof(info),
14681 RTE_PMD_I40E_PKG_INFO_HEADER);
14683 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14684 printf("i40e Profile Version: %d.%d.%d.%d\n",
14685 info.version.major,
14686 info.version.minor,
14687 info.version.update,
14688 info.version.draft);
14689 printf("i40e Profile name: %s\n\n", info.name);
14692 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14693 (uint8_t *)&buff_size, sizeof(buff_size),
14694 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14695 if (!ret && buff_size) {
14696 buff = (uint8_t *)malloc(buff_size);
14698 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14700 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14702 printf("Package Notes:\n%s\n\n", buff);
14707 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14708 (uint8_t *)&dev_num, sizeof(dev_num),
14709 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14710 if (!ret && dev_num) {
14711 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14712 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14714 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14715 (uint8_t *)devs, buff_size,
14716 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14718 printf("List of supported devices:\n");
14719 for (i = 0; i < dev_num; i++) {
14720 printf(" %04X:%04X %04X:%04X\n",
14721 devs[i].vendor_dev_id >> 16,
14722 devs[i].vendor_dev_id & 0xFFFF,
14723 devs[i].sub_vendor_dev_id >> 16,
14724 devs[i].sub_vendor_dev_id & 0xFFFF);
14732 /* get information about protocols and packet types */
14733 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14734 (uint8_t *)&proto_num, sizeof(proto_num),
14735 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14736 if (ret || !proto_num)
14737 goto no_print_return;
14739 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14740 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14742 goto no_print_return;
14744 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14746 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14748 printf("List of used protocols:\n");
14749 for (i = 0; i < proto_num; i++)
14750 printf(" %2u: %s\n", proto[i].proto_id,
14754 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14755 (uint8_t *)&pctype_num, sizeof(pctype_num),
14756 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14757 if (ret || !pctype_num)
14758 goto no_print_pctypes;
14760 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14761 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14763 goto no_print_pctypes;
14765 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14767 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14770 goto no_print_pctypes;
14773 printf("List of defined packet classification types:\n");
14774 for (i = 0; i < pctype_num; i++) {
14775 printf(" %2u:", pctype[i].ptype_id);
14776 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14777 proto_id = pctype[i].protocols[j];
14778 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14779 for (n = 0; n < proto_num; n++) {
14780 if (proto[n].proto_id == proto_id) {
14781 printf(" %s", proto[n].name);
14794 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14796 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14797 if (ret || !ptype_num)
14798 goto no_print_return;
14800 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14801 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14803 goto no_print_return;
14805 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14807 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14810 goto no_print_return;
14812 printf("List of defined packet types:\n");
14813 for (i = 0; i < ptype_num; i++) {
14814 printf(" %2u:", ptype[i].ptype_id);
14815 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14816 proto_id = ptype[i].protocols[j];
14817 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14818 for (n = 0; n < proto_num; n++) {
14819 if (proto[n].proto_id == proto_id) {
14820 printf(" %s", proto[n].name);
14836 if (ret == -ENOTSUP)
14837 fprintf(stderr, "Function not supported in PMD\n");
14841 cmdline_parse_inst_t cmd_ddp_get_info = {
14842 .f = cmd_ddp_info_parsed,
14844 .help_str = "ddp get info <profile_path>",
14846 (void *)&cmd_ddp_info_ddp,
14847 (void *)&cmd_ddp_info_get,
14848 (void *)&cmd_ddp_info_info,
14849 (void *)&cmd_ddp_info_filepath,
14854 /* Get dynamic device personalization profile info list*/
14855 #define PROFILE_INFO_SIZE 48
14856 #define MAX_PROFILE_NUM 16
14858 struct cmd_ddp_get_list_result {
14859 cmdline_fixed_string_t ddp;
14860 cmdline_fixed_string_t get;
14861 cmdline_fixed_string_t list;
14865 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14866 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14867 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14868 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14869 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14870 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14871 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14872 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14876 cmd_ddp_get_list_parsed(
14877 __rte_unused void *parsed_result,
14878 __rte_unused struct cmdline *cl,
14879 __rte_unused void *data)
14881 #ifdef RTE_NET_I40E
14882 struct cmd_ddp_get_list_result *res = parsed_result;
14883 struct rte_pmd_i40e_profile_list *p_list;
14884 struct rte_pmd_i40e_profile_info *p_info;
14889 int ret = -ENOTSUP;
14891 #ifdef RTE_NET_I40E
14892 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14893 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14895 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14899 if (ret == -ENOTSUP)
14900 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14901 (uint8_t *)p_list, size);
14904 p_num = p_list->p_count;
14905 printf("Profile number is: %d\n\n", p_num);
14907 for (i = 0; i < p_num; i++) {
14908 p_info = &p_list->p_info[i];
14909 printf("Profile %d:\n", i);
14910 printf("Track id: 0x%x\n", p_info->track_id);
14911 printf("Version: %d.%d.%d.%d\n",
14912 p_info->version.major,
14913 p_info->version.minor,
14914 p_info->version.update,
14915 p_info->version.draft);
14916 printf("Profile name: %s\n\n", p_info->name);
14924 fprintf(stderr, "Failed to get ddp list\n");
14927 cmdline_parse_inst_t cmd_ddp_get_list = {
14928 .f = cmd_ddp_get_list_parsed,
14930 .help_str = "ddp get list <port_id>",
14932 (void *)&cmd_ddp_get_list_ddp,
14933 (void *)&cmd_ddp_get_list_get,
14934 (void *)&cmd_ddp_get_list_list,
14935 (void *)&cmd_ddp_get_list_port_id,
14940 /* Configure input set */
14941 struct cmd_cfg_input_set_result {
14942 cmdline_fixed_string_t port;
14943 cmdline_fixed_string_t cfg;
14945 cmdline_fixed_string_t pctype;
14947 cmdline_fixed_string_t inset_type;
14948 cmdline_fixed_string_t opt;
14949 cmdline_fixed_string_t field;
14954 cmd_cfg_input_set_parsed(
14955 __rte_unused void *parsed_result,
14956 __rte_unused struct cmdline *cl,
14957 __rte_unused void *data)
14959 #ifdef RTE_NET_I40E
14960 struct cmd_cfg_input_set_result *res = parsed_result;
14961 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14962 struct rte_pmd_i40e_inset inset;
14964 int ret = -ENOTSUP;
14966 if (!all_ports_stopped()) {
14967 fprintf(stderr, "Please stop all ports first\n");
14971 #ifdef RTE_NET_I40E
14972 if (!strcmp(res->inset_type, "hash_inset"))
14973 inset_type = INSET_HASH;
14974 else if (!strcmp(res->inset_type, "fdir_inset"))
14975 inset_type = INSET_FDIR;
14976 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14977 inset_type = INSET_FDIR_FLX;
14978 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14979 &inset, inset_type);
14981 fprintf(stderr, "Failed to get input set.\n");
14985 if (!strcmp(res->opt, "get")) {
14986 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14989 printf("Field index %d is enabled.\n", res->field_idx);
14991 printf("Field index %d is disabled.\n", res->field_idx);
14993 } else if (!strcmp(res->opt, "set"))
14994 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14996 else if (!strcmp(res->opt, "clear"))
14997 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15000 fprintf(stderr, "Failed to configure input set field.\n");
15004 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15005 &inset, inset_type);
15007 fprintf(stderr, "Failed to set input set.\n");
15012 if (ret == -ENOTSUP)
15013 fprintf(stderr, "Function not supported\n");
15016 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15017 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15019 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15020 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15022 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15023 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15024 port_id, RTE_UINT16);
15025 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15026 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15028 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15029 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15030 pctype_id, RTE_UINT8);
15031 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15032 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15034 "hash_inset#fdir_inset#fdir_flx_inset");
15035 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15036 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15037 opt, "get#set#clear");
15038 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15039 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15041 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15042 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15043 field_idx, RTE_UINT8);
15045 cmdline_parse_inst_t cmd_cfg_input_set = {
15046 .f = cmd_cfg_input_set_parsed,
15048 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15049 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15051 (void *)&cmd_cfg_input_set_port,
15052 (void *)&cmd_cfg_input_set_cfg,
15053 (void *)&cmd_cfg_input_set_port_id,
15054 (void *)&cmd_cfg_input_set_pctype,
15055 (void *)&cmd_cfg_input_set_pctype_id,
15056 (void *)&cmd_cfg_input_set_inset_type,
15057 (void *)&cmd_cfg_input_set_opt,
15058 (void *)&cmd_cfg_input_set_field,
15059 (void *)&cmd_cfg_input_set_field_idx,
15064 /* Clear input set */
15065 struct cmd_clear_input_set_result {
15066 cmdline_fixed_string_t port;
15067 cmdline_fixed_string_t cfg;
15069 cmdline_fixed_string_t pctype;
15071 cmdline_fixed_string_t inset_type;
15072 cmdline_fixed_string_t clear;
15073 cmdline_fixed_string_t all;
15077 cmd_clear_input_set_parsed(
15078 __rte_unused void *parsed_result,
15079 __rte_unused struct cmdline *cl,
15080 __rte_unused void *data)
15082 #ifdef RTE_NET_I40E
15083 struct cmd_clear_input_set_result *res = parsed_result;
15084 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15085 struct rte_pmd_i40e_inset inset;
15087 int ret = -ENOTSUP;
15089 if (!all_ports_stopped()) {
15090 fprintf(stderr, "Please stop all ports first\n");
15094 #ifdef RTE_NET_I40E
15095 if (!strcmp(res->inset_type, "hash_inset"))
15096 inset_type = INSET_HASH;
15097 else if (!strcmp(res->inset_type, "fdir_inset"))
15098 inset_type = INSET_FDIR;
15099 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15100 inset_type = INSET_FDIR_FLX;
15102 memset(&inset, 0, sizeof(inset));
15104 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15105 &inset, inset_type);
15107 fprintf(stderr, "Failed to clear input set.\n");
15113 if (ret == -ENOTSUP)
15114 fprintf(stderr, "Function not supported\n");
15117 cmdline_parse_token_string_t cmd_clear_input_set_port =
15118 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15120 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15121 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15123 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15124 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15125 port_id, RTE_UINT16);
15126 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15127 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15129 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15130 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15131 pctype_id, RTE_UINT8);
15132 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15133 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15135 "hash_inset#fdir_inset#fdir_flx_inset");
15136 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15137 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15139 cmdline_parse_token_string_t cmd_clear_input_set_all =
15140 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15143 cmdline_parse_inst_t cmd_clear_input_set = {
15144 .f = cmd_clear_input_set_parsed,
15146 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15147 "fdir_inset|fdir_flx_inset clear all",
15149 (void *)&cmd_clear_input_set_port,
15150 (void *)&cmd_clear_input_set_cfg,
15151 (void *)&cmd_clear_input_set_port_id,
15152 (void *)&cmd_clear_input_set_pctype,
15153 (void *)&cmd_clear_input_set_pctype_id,
15154 (void *)&cmd_clear_input_set_inset_type,
15155 (void *)&cmd_clear_input_set_clear,
15156 (void *)&cmd_clear_input_set_all,
15161 /* show vf stats */
15163 /* Common result structure for show vf stats */
15164 struct cmd_show_vf_stats_result {
15165 cmdline_fixed_string_t show;
15166 cmdline_fixed_string_t vf;
15167 cmdline_fixed_string_t stats;
15172 /* Common CLI fields show vf stats*/
15173 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15174 TOKEN_STRING_INITIALIZER
15175 (struct cmd_show_vf_stats_result,
15177 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15178 TOKEN_STRING_INITIALIZER
15179 (struct cmd_show_vf_stats_result,
15181 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15182 TOKEN_STRING_INITIALIZER
15183 (struct cmd_show_vf_stats_result,
15185 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15186 TOKEN_NUM_INITIALIZER
15187 (struct cmd_show_vf_stats_result,
15188 port_id, RTE_UINT16);
15189 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15190 TOKEN_NUM_INITIALIZER
15191 (struct cmd_show_vf_stats_result,
15192 vf_id, RTE_UINT16);
15195 cmd_show_vf_stats_parsed(
15196 void *parsed_result,
15197 __rte_unused struct cmdline *cl,
15198 __rte_unused void *data)
15200 struct cmd_show_vf_stats_result *res = parsed_result;
15201 struct rte_eth_stats stats;
15202 int ret = -ENOTSUP;
15203 static const char *nic_stats_border = "########################";
15205 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15208 memset(&stats, 0, sizeof(stats));
15210 #ifdef RTE_NET_I40E
15211 if (ret == -ENOTSUP)
15212 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15216 #ifdef RTE_NET_BNXT
15217 if (ret == -ENOTSUP)
15218 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15227 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15230 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15233 fprintf(stderr, "function not implemented\n");
15236 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15239 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15240 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15242 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15244 stats.ipackets, stats.imissed, stats.ibytes);
15245 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15246 printf(" RX-nombuf: %-10"PRIu64"\n",
15248 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15250 stats.opackets, stats.oerrors, stats.obytes);
15252 printf(" %s############################%s\n",
15253 nic_stats_border, nic_stats_border);
15256 cmdline_parse_inst_t cmd_show_vf_stats = {
15257 .f = cmd_show_vf_stats_parsed,
15259 .help_str = "show vf stats <port_id> <vf_id>",
15261 (void *)&cmd_show_vf_stats_show,
15262 (void *)&cmd_show_vf_stats_vf,
15263 (void *)&cmd_show_vf_stats_stats,
15264 (void *)&cmd_show_vf_stats_port_id,
15265 (void *)&cmd_show_vf_stats_vf_id,
15270 /* clear vf stats */
15272 /* Common result structure for clear vf stats */
15273 struct cmd_clear_vf_stats_result {
15274 cmdline_fixed_string_t clear;
15275 cmdline_fixed_string_t vf;
15276 cmdline_fixed_string_t stats;
15281 /* Common CLI fields clear vf stats*/
15282 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15283 TOKEN_STRING_INITIALIZER
15284 (struct cmd_clear_vf_stats_result,
15286 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15287 TOKEN_STRING_INITIALIZER
15288 (struct cmd_clear_vf_stats_result,
15290 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15291 TOKEN_STRING_INITIALIZER
15292 (struct cmd_clear_vf_stats_result,
15294 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15295 TOKEN_NUM_INITIALIZER
15296 (struct cmd_clear_vf_stats_result,
15297 port_id, RTE_UINT16);
15298 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15299 TOKEN_NUM_INITIALIZER
15300 (struct cmd_clear_vf_stats_result,
15301 vf_id, RTE_UINT16);
15304 cmd_clear_vf_stats_parsed(
15305 void *parsed_result,
15306 __rte_unused struct cmdline *cl,
15307 __rte_unused void *data)
15309 struct cmd_clear_vf_stats_result *res = parsed_result;
15310 int ret = -ENOTSUP;
15312 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15315 #ifdef RTE_NET_I40E
15316 if (ret == -ENOTSUP)
15317 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15320 #ifdef RTE_NET_BNXT
15321 if (ret == -ENOTSUP)
15322 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15330 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15333 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15336 fprintf(stderr, "function not implemented\n");
15339 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15343 cmdline_parse_inst_t cmd_clear_vf_stats = {
15344 .f = cmd_clear_vf_stats_parsed,
15346 .help_str = "clear vf stats <port_id> <vf_id>",
15348 (void *)&cmd_clear_vf_stats_clear,
15349 (void *)&cmd_clear_vf_stats_vf,
15350 (void *)&cmd_clear_vf_stats_stats,
15351 (void *)&cmd_clear_vf_stats_port_id,
15352 (void *)&cmd_clear_vf_stats_vf_id,
15357 /* port config pctype mapping reset */
15359 /* Common result structure for port config pctype mapping reset */
15360 struct cmd_pctype_mapping_reset_result {
15361 cmdline_fixed_string_t port;
15362 cmdline_fixed_string_t config;
15364 cmdline_fixed_string_t pctype;
15365 cmdline_fixed_string_t mapping;
15366 cmdline_fixed_string_t reset;
15369 /* Common CLI fields for port config pctype mapping reset*/
15370 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15371 TOKEN_STRING_INITIALIZER
15372 (struct cmd_pctype_mapping_reset_result,
15374 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15375 TOKEN_STRING_INITIALIZER
15376 (struct cmd_pctype_mapping_reset_result,
15378 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15379 TOKEN_NUM_INITIALIZER
15380 (struct cmd_pctype_mapping_reset_result,
15381 port_id, RTE_UINT16);
15382 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15383 TOKEN_STRING_INITIALIZER
15384 (struct cmd_pctype_mapping_reset_result,
15386 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15387 TOKEN_STRING_INITIALIZER
15388 (struct cmd_pctype_mapping_reset_result,
15389 mapping, "mapping");
15390 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15391 TOKEN_STRING_INITIALIZER
15392 (struct cmd_pctype_mapping_reset_result,
15396 cmd_pctype_mapping_reset_parsed(
15397 void *parsed_result,
15398 __rte_unused struct cmdline *cl,
15399 __rte_unused void *data)
15401 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15402 int ret = -ENOTSUP;
15404 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15407 #ifdef RTE_NET_I40E
15408 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15415 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15418 fprintf(stderr, "function not implemented\n");
15421 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15425 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15426 .f = cmd_pctype_mapping_reset_parsed,
15428 .help_str = "port config <port_id> pctype mapping reset",
15430 (void *)&cmd_pctype_mapping_reset_port,
15431 (void *)&cmd_pctype_mapping_reset_config,
15432 (void *)&cmd_pctype_mapping_reset_port_id,
15433 (void *)&cmd_pctype_mapping_reset_pctype,
15434 (void *)&cmd_pctype_mapping_reset_mapping,
15435 (void *)&cmd_pctype_mapping_reset_reset,
15440 /* show port pctype mapping */
15442 /* Common result structure for show port pctype mapping */
15443 struct cmd_pctype_mapping_get_result {
15444 cmdline_fixed_string_t show;
15445 cmdline_fixed_string_t port;
15447 cmdline_fixed_string_t pctype;
15448 cmdline_fixed_string_t mapping;
15451 /* Common CLI fields for pctype mapping get */
15452 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15453 TOKEN_STRING_INITIALIZER
15454 (struct cmd_pctype_mapping_get_result,
15456 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15457 TOKEN_STRING_INITIALIZER
15458 (struct cmd_pctype_mapping_get_result,
15460 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15461 TOKEN_NUM_INITIALIZER
15462 (struct cmd_pctype_mapping_get_result,
15463 port_id, RTE_UINT16);
15464 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15465 TOKEN_STRING_INITIALIZER
15466 (struct cmd_pctype_mapping_get_result,
15468 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15469 TOKEN_STRING_INITIALIZER
15470 (struct cmd_pctype_mapping_get_result,
15471 mapping, "mapping");
15474 cmd_pctype_mapping_get_parsed(
15475 void *parsed_result,
15476 __rte_unused struct cmdline *cl,
15477 __rte_unused void *data)
15479 struct cmd_pctype_mapping_get_result *res = parsed_result;
15480 int ret = -ENOTSUP;
15481 #ifdef RTE_NET_I40E
15482 struct rte_pmd_i40e_flow_type_mapping
15483 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15484 int i, j, first_pctype;
15487 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15490 #ifdef RTE_NET_I40E
15491 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15498 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15501 fprintf(stderr, "function not implemented\n");
15504 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15508 #ifdef RTE_NET_I40E
15509 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15510 if (mapping[i].pctype != 0ULL) {
15513 printf("pctype: ");
15514 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15515 if (mapping[i].pctype & (1ULL << j)) {
15516 printf(first_pctype ?
15517 "%02d" : ",%02d", j);
15521 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15527 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15528 .f = cmd_pctype_mapping_get_parsed,
15530 .help_str = "show port <port_id> pctype mapping",
15532 (void *)&cmd_pctype_mapping_get_show,
15533 (void *)&cmd_pctype_mapping_get_port,
15534 (void *)&cmd_pctype_mapping_get_port_id,
15535 (void *)&cmd_pctype_mapping_get_pctype,
15536 (void *)&cmd_pctype_mapping_get_mapping,
15541 /* port config pctype mapping update */
15543 /* Common result structure for port config pctype mapping update */
15544 struct cmd_pctype_mapping_update_result {
15545 cmdline_fixed_string_t port;
15546 cmdline_fixed_string_t config;
15548 cmdline_fixed_string_t pctype;
15549 cmdline_fixed_string_t mapping;
15550 cmdline_fixed_string_t update;
15551 cmdline_fixed_string_t pctype_list;
15552 uint16_t flow_type;
15555 /* Common CLI fields for pctype mapping update*/
15556 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15557 TOKEN_STRING_INITIALIZER
15558 (struct cmd_pctype_mapping_update_result,
15560 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15561 TOKEN_STRING_INITIALIZER
15562 (struct cmd_pctype_mapping_update_result,
15564 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15565 TOKEN_NUM_INITIALIZER
15566 (struct cmd_pctype_mapping_update_result,
15567 port_id, RTE_UINT16);
15568 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15569 TOKEN_STRING_INITIALIZER
15570 (struct cmd_pctype_mapping_update_result,
15572 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15573 TOKEN_STRING_INITIALIZER
15574 (struct cmd_pctype_mapping_update_result,
15575 mapping, "mapping");
15576 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15577 TOKEN_STRING_INITIALIZER
15578 (struct cmd_pctype_mapping_update_result,
15580 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15581 TOKEN_STRING_INITIALIZER
15582 (struct cmd_pctype_mapping_update_result,
15583 pctype_list, NULL);
15584 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15585 TOKEN_NUM_INITIALIZER
15586 (struct cmd_pctype_mapping_update_result,
15587 flow_type, RTE_UINT16);
15590 cmd_pctype_mapping_update_parsed(
15591 void *parsed_result,
15592 __rte_unused struct cmdline *cl,
15593 __rte_unused void *data)
15595 struct cmd_pctype_mapping_update_result *res = parsed_result;
15596 int ret = -ENOTSUP;
15597 #ifdef RTE_NET_I40E
15598 struct rte_pmd_i40e_flow_type_mapping mapping;
15600 unsigned int nb_item;
15601 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15607 #ifdef RTE_NET_I40E
15608 nb_item = parse_item_list(res->pctype_list, "pctypes",
15609 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15610 mapping.flow_type = res->flow_type;
15611 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15612 mapping.pctype |= (1ULL << pctype_list[i]);
15613 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15623 fprintf(stderr, "invalid pctype or flow type\n");
15626 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15629 fprintf(stderr, "function not implemented\n");
15632 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15636 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15637 .f = cmd_pctype_mapping_update_parsed,
15639 .help_str = "port config <port_id> pctype mapping update"
15640 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15642 (void *)&cmd_pctype_mapping_update_port,
15643 (void *)&cmd_pctype_mapping_update_config,
15644 (void *)&cmd_pctype_mapping_update_port_id,
15645 (void *)&cmd_pctype_mapping_update_pctype,
15646 (void *)&cmd_pctype_mapping_update_mapping,
15647 (void *)&cmd_pctype_mapping_update_update,
15648 (void *)&cmd_pctype_mapping_update_pc_type,
15649 (void *)&cmd_pctype_mapping_update_flow_type,
15654 /* ptype mapping get */
15656 /* Common result structure for ptype mapping get */
15657 struct cmd_ptype_mapping_get_result {
15658 cmdline_fixed_string_t ptype;
15659 cmdline_fixed_string_t mapping;
15660 cmdline_fixed_string_t get;
15662 uint8_t valid_only;
15665 /* Common CLI fields for ptype mapping get */
15666 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15667 TOKEN_STRING_INITIALIZER
15668 (struct cmd_ptype_mapping_get_result,
15670 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15671 TOKEN_STRING_INITIALIZER
15672 (struct cmd_ptype_mapping_get_result,
15673 mapping, "mapping");
15674 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15675 TOKEN_STRING_INITIALIZER
15676 (struct cmd_ptype_mapping_get_result,
15678 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15679 TOKEN_NUM_INITIALIZER
15680 (struct cmd_ptype_mapping_get_result,
15681 port_id, RTE_UINT16);
15682 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15683 TOKEN_NUM_INITIALIZER
15684 (struct cmd_ptype_mapping_get_result,
15685 valid_only, RTE_UINT8);
15688 cmd_ptype_mapping_get_parsed(
15689 void *parsed_result,
15690 __rte_unused struct cmdline *cl,
15691 __rte_unused void *data)
15693 struct cmd_ptype_mapping_get_result *res = parsed_result;
15694 int ret = -ENOTSUP;
15695 #ifdef RTE_NET_I40E
15696 int max_ptype_num = 256;
15697 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15702 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15705 #ifdef RTE_NET_I40E
15706 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15717 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15720 fprintf(stderr, "function not implemented\n");
15723 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15726 #ifdef RTE_NET_I40E
15728 for (i = 0; i < count; i++)
15729 printf("%3d\t0x%08x\n",
15730 mapping[i].hw_ptype, mapping[i].sw_ptype);
15735 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15736 .f = cmd_ptype_mapping_get_parsed,
15738 .help_str = "ptype mapping get <port_id> <valid_only>",
15740 (void *)&cmd_ptype_mapping_get_ptype,
15741 (void *)&cmd_ptype_mapping_get_mapping,
15742 (void *)&cmd_ptype_mapping_get_get,
15743 (void *)&cmd_ptype_mapping_get_port_id,
15744 (void *)&cmd_ptype_mapping_get_valid_only,
15749 /* ptype mapping replace */
15751 /* Common result structure for ptype mapping replace */
15752 struct cmd_ptype_mapping_replace_result {
15753 cmdline_fixed_string_t ptype;
15754 cmdline_fixed_string_t mapping;
15755 cmdline_fixed_string_t replace;
15762 /* Common CLI fields for ptype mapping replace */
15763 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15764 TOKEN_STRING_INITIALIZER
15765 (struct cmd_ptype_mapping_replace_result,
15767 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15768 TOKEN_STRING_INITIALIZER
15769 (struct cmd_ptype_mapping_replace_result,
15770 mapping, "mapping");
15771 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15772 TOKEN_STRING_INITIALIZER
15773 (struct cmd_ptype_mapping_replace_result,
15774 replace, "replace");
15775 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15776 TOKEN_NUM_INITIALIZER
15777 (struct cmd_ptype_mapping_replace_result,
15778 port_id, RTE_UINT16);
15779 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15780 TOKEN_NUM_INITIALIZER
15781 (struct cmd_ptype_mapping_replace_result,
15782 target, RTE_UINT32);
15783 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15784 TOKEN_NUM_INITIALIZER
15785 (struct cmd_ptype_mapping_replace_result,
15787 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15788 TOKEN_NUM_INITIALIZER
15789 (struct cmd_ptype_mapping_replace_result,
15790 pkt_type, RTE_UINT32);
15793 cmd_ptype_mapping_replace_parsed(
15794 void *parsed_result,
15795 __rte_unused struct cmdline *cl,
15796 __rte_unused void *data)
15798 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15799 int ret = -ENOTSUP;
15801 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15804 #ifdef RTE_NET_I40E
15805 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15815 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15816 res->target, res->pkt_type);
15819 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15822 fprintf(stderr, "function not implemented\n");
15825 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15829 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15830 .f = cmd_ptype_mapping_replace_parsed,
15833 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15835 (void *)&cmd_ptype_mapping_replace_ptype,
15836 (void *)&cmd_ptype_mapping_replace_mapping,
15837 (void *)&cmd_ptype_mapping_replace_replace,
15838 (void *)&cmd_ptype_mapping_replace_port_id,
15839 (void *)&cmd_ptype_mapping_replace_target,
15840 (void *)&cmd_ptype_mapping_replace_mask,
15841 (void *)&cmd_ptype_mapping_replace_pkt_type,
15846 /* ptype mapping reset */
15848 /* Common result structure for ptype mapping reset */
15849 struct cmd_ptype_mapping_reset_result {
15850 cmdline_fixed_string_t ptype;
15851 cmdline_fixed_string_t mapping;
15852 cmdline_fixed_string_t reset;
15856 /* Common CLI fields for ptype mapping reset*/
15857 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15858 TOKEN_STRING_INITIALIZER
15859 (struct cmd_ptype_mapping_reset_result,
15861 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15862 TOKEN_STRING_INITIALIZER
15863 (struct cmd_ptype_mapping_reset_result,
15864 mapping, "mapping");
15865 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15866 TOKEN_STRING_INITIALIZER
15867 (struct cmd_ptype_mapping_reset_result,
15869 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15870 TOKEN_NUM_INITIALIZER
15871 (struct cmd_ptype_mapping_reset_result,
15872 port_id, RTE_UINT16);
15875 cmd_ptype_mapping_reset_parsed(
15876 void *parsed_result,
15877 __rte_unused struct cmdline *cl,
15878 __rte_unused void *data)
15880 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15881 int ret = -ENOTSUP;
15883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15886 #ifdef RTE_NET_I40E
15887 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15894 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15897 fprintf(stderr, "function not implemented\n");
15900 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15904 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15905 .f = cmd_ptype_mapping_reset_parsed,
15907 .help_str = "ptype mapping reset <port_id>",
15909 (void *)&cmd_ptype_mapping_reset_ptype,
15910 (void *)&cmd_ptype_mapping_reset_mapping,
15911 (void *)&cmd_ptype_mapping_reset_reset,
15912 (void *)&cmd_ptype_mapping_reset_port_id,
15917 /* ptype mapping update */
15919 /* Common result structure for ptype mapping update */
15920 struct cmd_ptype_mapping_update_result {
15921 cmdline_fixed_string_t ptype;
15922 cmdline_fixed_string_t mapping;
15923 cmdline_fixed_string_t reset;
15929 /* Common CLI fields for ptype mapping update*/
15930 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15931 TOKEN_STRING_INITIALIZER
15932 (struct cmd_ptype_mapping_update_result,
15934 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15935 TOKEN_STRING_INITIALIZER
15936 (struct cmd_ptype_mapping_update_result,
15937 mapping, "mapping");
15938 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15939 TOKEN_STRING_INITIALIZER
15940 (struct cmd_ptype_mapping_update_result,
15942 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15943 TOKEN_NUM_INITIALIZER
15944 (struct cmd_ptype_mapping_update_result,
15945 port_id, RTE_UINT16);
15946 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15947 TOKEN_NUM_INITIALIZER
15948 (struct cmd_ptype_mapping_update_result,
15949 hw_ptype, RTE_UINT8);
15950 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15951 TOKEN_NUM_INITIALIZER
15952 (struct cmd_ptype_mapping_update_result,
15953 sw_ptype, RTE_UINT32);
15956 cmd_ptype_mapping_update_parsed(
15957 void *parsed_result,
15958 __rte_unused struct cmdline *cl,
15959 __rte_unused void *data)
15961 struct cmd_ptype_mapping_update_result *res = parsed_result;
15962 int ret = -ENOTSUP;
15963 #ifdef RTE_NET_I40E
15964 struct rte_pmd_i40e_ptype_mapping mapping;
15966 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15969 #ifdef RTE_NET_I40E
15970 mapping.hw_ptype = res->hw_ptype;
15971 mapping.sw_ptype = res->sw_ptype;
15972 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15982 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15985 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15988 fprintf(stderr, "function not implemented\n");
15991 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15995 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15996 .f = cmd_ptype_mapping_update_parsed,
15998 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16000 (void *)&cmd_ptype_mapping_update_ptype,
16001 (void *)&cmd_ptype_mapping_update_mapping,
16002 (void *)&cmd_ptype_mapping_update_update,
16003 (void *)&cmd_ptype_mapping_update_port_id,
16004 (void *)&cmd_ptype_mapping_update_hw_ptype,
16005 (void *)&cmd_ptype_mapping_update_sw_ptype,
16010 /* Common result structure for file commands */
16011 struct cmd_cmdfile_result {
16012 cmdline_fixed_string_t load;
16013 cmdline_fixed_string_t filename;
16016 /* Common CLI fields for file commands */
16017 cmdline_parse_token_string_t cmd_load_cmdfile =
16018 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16019 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16020 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16023 cmd_load_from_file_parsed(
16024 void *parsed_result,
16025 __rte_unused struct cmdline *cl,
16026 __rte_unused void *data)
16028 struct cmd_cmdfile_result *res = parsed_result;
16030 cmdline_read_from_file(res->filename);
16033 cmdline_parse_inst_t cmd_load_from_file = {
16034 .f = cmd_load_from_file_parsed,
16036 .help_str = "load <filename>",
16038 (void *)&cmd_load_cmdfile,
16039 (void *)&cmd_load_cmdfile_filename,
16044 /* Get Rx offloads capabilities */
16045 struct cmd_rx_offload_get_capa_result {
16046 cmdline_fixed_string_t show;
16047 cmdline_fixed_string_t port;
16049 cmdline_fixed_string_t rx_offload;
16050 cmdline_fixed_string_t capabilities;
16053 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16054 TOKEN_STRING_INITIALIZER
16055 (struct cmd_rx_offload_get_capa_result,
16057 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16058 TOKEN_STRING_INITIALIZER
16059 (struct cmd_rx_offload_get_capa_result,
16061 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16062 TOKEN_NUM_INITIALIZER
16063 (struct cmd_rx_offload_get_capa_result,
16064 port_id, RTE_UINT16);
16065 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16066 TOKEN_STRING_INITIALIZER
16067 (struct cmd_rx_offload_get_capa_result,
16068 rx_offload, "rx_offload");
16069 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16070 TOKEN_STRING_INITIALIZER
16071 (struct cmd_rx_offload_get_capa_result,
16072 capabilities, "capabilities");
16075 print_rx_offloads(uint64_t offloads)
16077 uint64_t single_offload;
16085 begin = __builtin_ctzll(offloads);
16086 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16088 single_offload = 1ULL << begin;
16089 for (bit = begin; bit < end; bit++) {
16090 if (offloads & single_offload)
16092 rte_eth_dev_rx_offload_name(single_offload));
16093 single_offload <<= 1;
16098 cmd_rx_offload_get_capa_parsed(
16099 void *parsed_result,
16100 __rte_unused struct cmdline *cl,
16101 __rte_unused void *data)
16103 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16104 struct rte_eth_dev_info dev_info;
16105 portid_t port_id = res->port_id;
16106 uint64_t queue_offloads;
16107 uint64_t port_offloads;
16110 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16114 queue_offloads = dev_info.rx_queue_offload_capa;
16115 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16117 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16118 printf(" Per Queue :");
16119 print_rx_offloads(queue_offloads);
16122 printf(" Per Port :");
16123 print_rx_offloads(port_offloads);
16127 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16128 .f = cmd_rx_offload_get_capa_parsed,
16130 .help_str = "show port <port_id> rx_offload capabilities",
16132 (void *)&cmd_rx_offload_get_capa_show,
16133 (void *)&cmd_rx_offload_get_capa_port,
16134 (void *)&cmd_rx_offload_get_capa_port_id,
16135 (void *)&cmd_rx_offload_get_capa_rx_offload,
16136 (void *)&cmd_rx_offload_get_capa_capabilities,
16141 /* Get Rx offloads configuration */
16142 struct cmd_rx_offload_get_configuration_result {
16143 cmdline_fixed_string_t show;
16144 cmdline_fixed_string_t port;
16146 cmdline_fixed_string_t rx_offload;
16147 cmdline_fixed_string_t configuration;
16150 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16151 TOKEN_STRING_INITIALIZER
16152 (struct cmd_rx_offload_get_configuration_result,
16154 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16155 TOKEN_STRING_INITIALIZER
16156 (struct cmd_rx_offload_get_configuration_result,
16158 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16159 TOKEN_NUM_INITIALIZER
16160 (struct cmd_rx_offload_get_configuration_result,
16161 port_id, RTE_UINT16);
16162 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16163 TOKEN_STRING_INITIALIZER
16164 (struct cmd_rx_offload_get_configuration_result,
16165 rx_offload, "rx_offload");
16166 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16167 TOKEN_STRING_INITIALIZER
16168 (struct cmd_rx_offload_get_configuration_result,
16169 configuration, "configuration");
16172 cmd_rx_offload_get_configuration_parsed(
16173 void *parsed_result,
16174 __rte_unused struct cmdline *cl,
16175 __rte_unused void *data)
16177 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16178 struct rte_eth_dev_info dev_info;
16179 portid_t port_id = res->port_id;
16180 struct rte_port *port = &ports[port_id];
16181 struct rte_eth_conf dev_conf;
16182 uint64_t port_offloads;
16183 uint64_t queue_offloads;
16184 uint16_t nb_rx_queues;
16188 printf("Rx Offloading Configuration of port %d :\n", port_id);
16190 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16194 port_offloads = dev_conf.rxmode.offloads;
16196 print_rx_offloads(port_offloads);
16199 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16203 nb_rx_queues = dev_info.nb_rx_queues;
16204 for (q = 0; q < nb_rx_queues; q++) {
16205 queue_offloads = port->rx_conf[q].offloads;
16206 printf(" Queue[%2d] :", q);
16207 print_rx_offloads(queue_offloads);
16213 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16214 .f = cmd_rx_offload_get_configuration_parsed,
16216 .help_str = "show port <port_id> rx_offload configuration",
16218 (void *)&cmd_rx_offload_get_configuration_show,
16219 (void *)&cmd_rx_offload_get_configuration_port,
16220 (void *)&cmd_rx_offload_get_configuration_port_id,
16221 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16222 (void *)&cmd_rx_offload_get_configuration_configuration,
16227 /* Enable/Disable a per port offloading */
16228 struct cmd_config_per_port_rx_offload_result {
16229 cmdline_fixed_string_t port;
16230 cmdline_fixed_string_t config;
16232 cmdline_fixed_string_t rx_offload;
16233 cmdline_fixed_string_t offload;
16234 cmdline_fixed_string_t on_off;
16237 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16238 TOKEN_STRING_INITIALIZER
16239 (struct cmd_config_per_port_rx_offload_result,
16241 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16242 TOKEN_STRING_INITIALIZER
16243 (struct cmd_config_per_port_rx_offload_result,
16245 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16246 TOKEN_NUM_INITIALIZER
16247 (struct cmd_config_per_port_rx_offload_result,
16248 port_id, RTE_UINT16);
16249 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16250 TOKEN_STRING_INITIALIZER
16251 (struct cmd_config_per_port_rx_offload_result,
16252 rx_offload, "rx_offload");
16253 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16254 TOKEN_STRING_INITIALIZER
16255 (struct cmd_config_per_port_rx_offload_result,
16256 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16257 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16258 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16259 "scatter#buffer_split#timestamp#security#"
16260 "keep_crc#rss_hash");
16261 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16262 TOKEN_STRING_INITIALIZER
16263 (struct cmd_config_per_port_rx_offload_result,
16267 search_rx_offload(const char *name)
16269 uint64_t single_offload;
16270 const char *single_name;
16274 single_offload = 1;
16275 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16276 single_name = rte_eth_dev_rx_offload_name(single_offload);
16277 if (!strcasecmp(single_name, name)) {
16281 single_offload <<= 1;
16285 return single_offload;
16291 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16292 __rte_unused struct cmdline *cl,
16293 __rte_unused void *data)
16295 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16296 portid_t port_id = res->port_id;
16297 struct rte_eth_dev_info dev_info;
16298 struct rte_port *port = &ports[port_id];
16299 uint64_t single_offload;
16300 uint16_t nb_rx_queues;
16304 if (port->port_status != RTE_PORT_STOPPED) {
16306 "Error: Can't config offload when Port %d is not stopped\n",
16311 single_offload = search_rx_offload(res->offload);
16312 if (single_offload == 0) {
16313 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16317 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16321 nb_rx_queues = dev_info.nb_rx_queues;
16322 if (!strcmp(res->on_off, "on")) {
16323 port->dev_conf.rxmode.offloads |= single_offload;
16324 for (q = 0; q < nb_rx_queues; q++)
16325 port->rx_conf[q].offloads |= single_offload;
16327 port->dev_conf.rxmode.offloads &= ~single_offload;
16328 for (q = 0; q < nb_rx_queues; q++)
16329 port->rx_conf[q].offloads &= ~single_offload;
16332 cmd_reconfig_device_queue(port_id, 1, 1);
16335 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16336 .f = cmd_config_per_port_rx_offload_parsed,
16338 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16339 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16340 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16341 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16342 "keep_crc|rss_hash on|off",
16344 (void *)&cmd_config_per_port_rx_offload_result_port,
16345 (void *)&cmd_config_per_port_rx_offload_result_config,
16346 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16347 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16348 (void *)&cmd_config_per_port_rx_offload_result_offload,
16349 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16354 /* Enable/Disable a per queue offloading */
16355 struct cmd_config_per_queue_rx_offload_result {
16356 cmdline_fixed_string_t port;
16358 cmdline_fixed_string_t rxq;
16360 cmdline_fixed_string_t rx_offload;
16361 cmdline_fixed_string_t offload;
16362 cmdline_fixed_string_t on_off;
16365 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16366 TOKEN_STRING_INITIALIZER
16367 (struct cmd_config_per_queue_rx_offload_result,
16369 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16370 TOKEN_NUM_INITIALIZER
16371 (struct cmd_config_per_queue_rx_offload_result,
16372 port_id, RTE_UINT16);
16373 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16374 TOKEN_STRING_INITIALIZER
16375 (struct cmd_config_per_queue_rx_offload_result,
16377 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16378 TOKEN_NUM_INITIALIZER
16379 (struct cmd_config_per_queue_rx_offload_result,
16380 queue_id, RTE_UINT16);
16381 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16382 TOKEN_STRING_INITIALIZER
16383 (struct cmd_config_per_queue_rx_offload_result,
16384 rx_offload, "rx_offload");
16385 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16386 TOKEN_STRING_INITIALIZER
16387 (struct cmd_config_per_queue_rx_offload_result,
16388 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16389 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16390 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16391 "scatter#buffer_split#timestamp#security#keep_crc");
16392 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16393 TOKEN_STRING_INITIALIZER
16394 (struct cmd_config_per_queue_rx_offload_result,
16398 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16399 __rte_unused struct cmdline *cl,
16400 __rte_unused void *data)
16402 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16403 struct rte_eth_dev_info dev_info;
16404 portid_t port_id = res->port_id;
16405 uint16_t queue_id = res->queue_id;
16406 struct rte_port *port = &ports[port_id];
16407 uint64_t single_offload;
16410 if (port->port_status != RTE_PORT_STOPPED) {
16412 "Error: Can't config offload when Port %d is not stopped\n",
16417 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16421 if (queue_id >= dev_info.nb_rx_queues) {
16423 "Error: input queue_id should be 0 ... %d\n",
16424 dev_info.nb_rx_queues - 1);
16428 single_offload = search_rx_offload(res->offload);
16429 if (single_offload == 0) {
16430 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16434 if (!strcmp(res->on_off, "on"))
16435 port->rx_conf[queue_id].offloads |= single_offload;
16437 port->rx_conf[queue_id].offloads &= ~single_offload;
16439 cmd_reconfig_device_queue(port_id, 1, 1);
16442 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16443 .f = cmd_config_per_queue_rx_offload_parsed,
16445 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16446 "vlan_strip|ipv4_cksum|"
16447 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16448 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16449 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16452 (void *)&cmd_config_per_queue_rx_offload_result_port,
16453 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16454 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16455 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16456 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16457 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16458 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16463 /* Get Tx offloads capabilities */
16464 struct cmd_tx_offload_get_capa_result {
16465 cmdline_fixed_string_t show;
16466 cmdline_fixed_string_t port;
16468 cmdline_fixed_string_t tx_offload;
16469 cmdline_fixed_string_t capabilities;
16472 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16473 TOKEN_STRING_INITIALIZER
16474 (struct cmd_tx_offload_get_capa_result,
16476 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16477 TOKEN_STRING_INITIALIZER
16478 (struct cmd_tx_offload_get_capa_result,
16480 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16481 TOKEN_NUM_INITIALIZER
16482 (struct cmd_tx_offload_get_capa_result,
16483 port_id, RTE_UINT16);
16484 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16485 TOKEN_STRING_INITIALIZER
16486 (struct cmd_tx_offload_get_capa_result,
16487 tx_offload, "tx_offload");
16488 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16489 TOKEN_STRING_INITIALIZER
16490 (struct cmd_tx_offload_get_capa_result,
16491 capabilities, "capabilities");
16494 print_tx_offloads(uint64_t offloads)
16496 uint64_t single_offload;
16504 begin = __builtin_ctzll(offloads);
16505 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16507 single_offload = 1ULL << begin;
16508 for (bit = begin; bit < end; bit++) {
16509 if (offloads & single_offload)
16511 rte_eth_dev_tx_offload_name(single_offload));
16512 single_offload <<= 1;
16517 cmd_tx_offload_get_capa_parsed(
16518 void *parsed_result,
16519 __rte_unused struct cmdline *cl,
16520 __rte_unused void *data)
16522 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16523 struct rte_eth_dev_info dev_info;
16524 portid_t port_id = res->port_id;
16525 uint64_t queue_offloads;
16526 uint64_t port_offloads;
16529 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16533 queue_offloads = dev_info.tx_queue_offload_capa;
16534 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16536 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16537 printf(" Per Queue :");
16538 print_tx_offloads(queue_offloads);
16541 printf(" Per Port :");
16542 print_tx_offloads(port_offloads);
16546 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16547 .f = cmd_tx_offload_get_capa_parsed,
16549 .help_str = "show port <port_id> tx_offload capabilities",
16551 (void *)&cmd_tx_offload_get_capa_show,
16552 (void *)&cmd_tx_offload_get_capa_port,
16553 (void *)&cmd_tx_offload_get_capa_port_id,
16554 (void *)&cmd_tx_offload_get_capa_tx_offload,
16555 (void *)&cmd_tx_offload_get_capa_capabilities,
16560 /* Get Tx offloads configuration */
16561 struct cmd_tx_offload_get_configuration_result {
16562 cmdline_fixed_string_t show;
16563 cmdline_fixed_string_t port;
16565 cmdline_fixed_string_t tx_offload;
16566 cmdline_fixed_string_t configuration;
16569 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16570 TOKEN_STRING_INITIALIZER
16571 (struct cmd_tx_offload_get_configuration_result,
16573 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16574 TOKEN_STRING_INITIALIZER
16575 (struct cmd_tx_offload_get_configuration_result,
16577 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16578 TOKEN_NUM_INITIALIZER
16579 (struct cmd_tx_offload_get_configuration_result,
16580 port_id, RTE_UINT16);
16581 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16582 TOKEN_STRING_INITIALIZER
16583 (struct cmd_tx_offload_get_configuration_result,
16584 tx_offload, "tx_offload");
16585 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16586 TOKEN_STRING_INITIALIZER
16587 (struct cmd_tx_offload_get_configuration_result,
16588 configuration, "configuration");
16591 cmd_tx_offload_get_configuration_parsed(
16592 void *parsed_result,
16593 __rte_unused struct cmdline *cl,
16594 __rte_unused void *data)
16596 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16597 struct rte_eth_dev_info dev_info;
16598 portid_t port_id = res->port_id;
16599 struct rte_port *port = &ports[port_id];
16600 struct rte_eth_conf dev_conf;
16601 uint64_t port_offloads;
16602 uint64_t queue_offloads;
16603 uint16_t nb_tx_queues;
16607 printf("Tx Offloading Configuration of port %d :\n", port_id);
16609 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16613 port_offloads = dev_conf.txmode.offloads;
16615 print_tx_offloads(port_offloads);
16618 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16622 nb_tx_queues = dev_info.nb_tx_queues;
16623 for (q = 0; q < nb_tx_queues; q++) {
16624 queue_offloads = port->tx_conf[q].offloads;
16625 printf(" Queue[%2d] :", q);
16626 print_tx_offloads(queue_offloads);
16632 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16633 .f = cmd_tx_offload_get_configuration_parsed,
16635 .help_str = "show port <port_id> tx_offload configuration",
16637 (void *)&cmd_tx_offload_get_configuration_show,
16638 (void *)&cmd_tx_offload_get_configuration_port,
16639 (void *)&cmd_tx_offload_get_configuration_port_id,
16640 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16641 (void *)&cmd_tx_offload_get_configuration_configuration,
16646 /* Enable/Disable a per port offloading */
16647 struct cmd_config_per_port_tx_offload_result {
16648 cmdline_fixed_string_t port;
16649 cmdline_fixed_string_t config;
16651 cmdline_fixed_string_t tx_offload;
16652 cmdline_fixed_string_t offload;
16653 cmdline_fixed_string_t on_off;
16656 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16657 TOKEN_STRING_INITIALIZER
16658 (struct cmd_config_per_port_tx_offload_result,
16660 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16661 TOKEN_STRING_INITIALIZER
16662 (struct cmd_config_per_port_tx_offload_result,
16664 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16665 TOKEN_NUM_INITIALIZER
16666 (struct cmd_config_per_port_tx_offload_result,
16667 port_id, RTE_UINT16);
16668 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16669 TOKEN_STRING_INITIALIZER
16670 (struct cmd_config_per_port_tx_offload_result,
16671 tx_offload, "tx_offload");
16672 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16673 TOKEN_STRING_INITIALIZER
16674 (struct cmd_config_per_port_tx_offload_result,
16675 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16676 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16677 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16678 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16679 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16680 "send_on_timestamp");
16681 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16682 TOKEN_STRING_INITIALIZER
16683 (struct cmd_config_per_port_tx_offload_result,
16687 search_tx_offload(const char *name)
16689 uint64_t single_offload;
16690 const char *single_name;
16694 single_offload = 1;
16695 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16696 single_name = rte_eth_dev_tx_offload_name(single_offload);
16697 if (single_name == NULL)
16699 if (!strcasecmp(single_name, name)) {
16702 } else if (!strcasecmp(single_name, "UNKNOWN"))
16704 single_offload <<= 1;
16708 return single_offload;
16714 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16715 __rte_unused struct cmdline *cl,
16716 __rte_unused void *data)
16718 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16719 portid_t port_id = res->port_id;
16720 struct rte_eth_dev_info dev_info;
16721 struct rte_port *port = &ports[port_id];
16722 uint64_t single_offload;
16723 uint16_t nb_tx_queues;
16727 if (port->port_status != RTE_PORT_STOPPED) {
16729 "Error: Can't config offload when Port %d is not stopped\n",
16734 single_offload = search_tx_offload(res->offload);
16735 if (single_offload == 0) {
16736 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16740 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16744 nb_tx_queues = dev_info.nb_tx_queues;
16745 if (!strcmp(res->on_off, "on")) {
16746 port->dev_conf.txmode.offloads |= single_offload;
16747 for (q = 0; q < nb_tx_queues; q++)
16748 port->tx_conf[q].offloads |= single_offload;
16750 port->dev_conf.txmode.offloads &= ~single_offload;
16751 for (q = 0; q < nb_tx_queues; q++)
16752 port->tx_conf[q].offloads &= ~single_offload;
16755 cmd_reconfig_device_queue(port_id, 1, 1);
16758 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16759 .f = cmd_config_per_port_tx_offload_parsed,
16761 .help_str = "port config <port_id> tx_offload "
16762 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16763 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16764 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16765 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16766 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16767 "send_on_timestamp on|off",
16769 (void *)&cmd_config_per_port_tx_offload_result_port,
16770 (void *)&cmd_config_per_port_tx_offload_result_config,
16771 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16772 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16773 (void *)&cmd_config_per_port_tx_offload_result_offload,
16774 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16779 /* Enable/Disable a per queue offloading */
16780 struct cmd_config_per_queue_tx_offload_result {
16781 cmdline_fixed_string_t port;
16783 cmdline_fixed_string_t txq;
16785 cmdline_fixed_string_t tx_offload;
16786 cmdline_fixed_string_t offload;
16787 cmdline_fixed_string_t on_off;
16790 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16791 TOKEN_STRING_INITIALIZER
16792 (struct cmd_config_per_queue_tx_offload_result,
16794 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16795 TOKEN_NUM_INITIALIZER
16796 (struct cmd_config_per_queue_tx_offload_result,
16797 port_id, RTE_UINT16);
16798 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16799 TOKEN_STRING_INITIALIZER
16800 (struct cmd_config_per_queue_tx_offload_result,
16802 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16803 TOKEN_NUM_INITIALIZER
16804 (struct cmd_config_per_queue_tx_offload_result,
16805 queue_id, RTE_UINT16);
16806 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16807 TOKEN_STRING_INITIALIZER
16808 (struct cmd_config_per_queue_tx_offload_result,
16809 tx_offload, "tx_offload");
16810 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16811 TOKEN_STRING_INITIALIZER
16812 (struct cmd_config_per_queue_tx_offload_result,
16813 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16814 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16815 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16816 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16817 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16818 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16819 TOKEN_STRING_INITIALIZER
16820 (struct cmd_config_per_queue_tx_offload_result,
16824 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16825 __rte_unused struct cmdline *cl,
16826 __rte_unused void *data)
16828 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16829 struct rte_eth_dev_info dev_info;
16830 portid_t port_id = res->port_id;
16831 uint16_t queue_id = res->queue_id;
16832 struct rte_port *port = &ports[port_id];
16833 uint64_t single_offload;
16836 if (port->port_status != RTE_PORT_STOPPED) {
16838 "Error: Can't config offload when Port %d is not stopped\n",
16843 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16847 if (queue_id >= dev_info.nb_tx_queues) {
16849 "Error: input queue_id should be 0 ... %d\n",
16850 dev_info.nb_tx_queues - 1);
16854 single_offload = search_tx_offload(res->offload);
16855 if (single_offload == 0) {
16856 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16860 if (!strcmp(res->on_off, "on"))
16861 port->tx_conf[queue_id].offloads |= single_offload;
16863 port->tx_conf[queue_id].offloads &= ~single_offload;
16865 cmd_reconfig_device_queue(port_id, 1, 1);
16868 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16869 .f = cmd_config_per_queue_tx_offload_parsed,
16871 .help_str = "port <port_id> txq <queue_id> tx_offload "
16872 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16873 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16874 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16875 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16876 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16879 (void *)&cmd_config_per_queue_tx_offload_result_port,
16880 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16881 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16882 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16883 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16884 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16885 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16890 /* *** configure tx_metadata for specific port *** */
16891 struct cmd_config_tx_metadata_specific_result {
16892 cmdline_fixed_string_t port;
16893 cmdline_fixed_string_t keyword;
16895 cmdline_fixed_string_t item;
16900 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16901 __rte_unused struct cmdline *cl,
16902 __rte_unused void *data)
16904 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16906 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16908 ports[res->port_id].tx_metadata = res->value;
16909 /* Add/remove callback to insert valid metadata in every Tx packet. */
16910 if (ports[res->port_id].tx_metadata)
16911 add_tx_md_callback(res->port_id);
16913 remove_tx_md_callback(res->port_id);
16914 rte_flow_dynf_metadata_register();
16917 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16918 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16920 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16921 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16922 keyword, "config");
16923 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16924 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16925 port_id, RTE_UINT16);
16926 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16927 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16928 item, "tx_metadata");
16929 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16930 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16931 value, RTE_UINT32);
16933 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16934 .f = cmd_config_tx_metadata_specific_parsed,
16936 .help_str = "port config <port_id> tx_metadata <value>",
16938 (void *)&cmd_config_tx_metadata_specific_port,
16939 (void *)&cmd_config_tx_metadata_specific_keyword,
16940 (void *)&cmd_config_tx_metadata_specific_id,
16941 (void *)&cmd_config_tx_metadata_specific_item,
16942 (void *)&cmd_config_tx_metadata_specific_value,
16947 /* *** set dynf *** */
16948 struct cmd_config_tx_dynf_specific_result {
16949 cmdline_fixed_string_t port;
16950 cmdline_fixed_string_t keyword;
16952 cmdline_fixed_string_t item;
16953 cmdline_fixed_string_t name;
16954 cmdline_fixed_string_t value;
16958 cmd_config_dynf_specific_parsed(void *parsed_result,
16959 __rte_unused struct cmdline *cl,
16960 __rte_unused void *data)
16962 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16963 struct rte_mbuf_dynflag desc_flag;
16965 uint64_t old_port_flags;
16967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16969 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16971 if (strlcpy(desc_flag.name, res->name,
16972 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16973 fprintf(stderr, "Flag name too long\n");
16976 desc_flag.flags = 0;
16977 flag = rte_mbuf_dynflag_register(&desc_flag);
16979 fprintf(stderr, "Can't register flag\n");
16982 strcpy(dynf_names[flag], desc_flag.name);
16984 old_port_flags = ports[res->port_id].mbuf_dynf;
16985 if (!strcmp(res->value, "set")) {
16986 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16987 if (old_port_flags == 0)
16988 add_tx_dynf_callback(res->port_id);
16990 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16991 if (ports[res->port_id].mbuf_dynf == 0)
16992 remove_tx_dynf_callback(res->port_id);
16996 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16997 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16999 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
17000 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17001 keyword, "config");
17002 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17003 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17004 port_id, RTE_UINT16);
17005 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17006 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17008 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17009 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17011 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17012 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17013 value, "set#clear");
17015 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17016 .f = cmd_config_dynf_specific_parsed,
17018 .help_str = "port config <port id> dynf <name> set|clear",
17020 (void *)&cmd_config_tx_dynf_specific_port,
17021 (void *)&cmd_config_tx_dynf_specific_keyword,
17022 (void *)&cmd_config_tx_dynf_specific_port_id,
17023 (void *)&cmd_config_tx_dynf_specific_item,
17024 (void *)&cmd_config_tx_dynf_specific_name,
17025 (void *)&cmd_config_tx_dynf_specific_value,
17030 /* *** display tx_metadata per port configuration *** */
17031 struct cmd_show_tx_metadata_result {
17032 cmdline_fixed_string_t cmd_show;
17033 cmdline_fixed_string_t cmd_port;
17034 cmdline_fixed_string_t cmd_keyword;
17039 cmd_show_tx_metadata_parsed(void *parsed_result,
17040 __rte_unused struct cmdline *cl,
17041 __rte_unused void *data)
17043 struct cmd_show_tx_metadata_result *res = parsed_result;
17045 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17046 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17049 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17050 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17051 ports[res->cmd_pid].tx_metadata);
17055 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17056 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17058 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17059 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17061 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17062 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17063 cmd_pid, RTE_UINT16);
17064 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17065 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17066 cmd_keyword, "tx_metadata");
17068 cmdline_parse_inst_t cmd_show_tx_metadata = {
17069 .f = cmd_show_tx_metadata_parsed,
17071 .help_str = "show port <port_id> tx_metadata",
17073 (void *)&cmd_show_tx_metadata_show,
17074 (void *)&cmd_show_tx_metadata_port,
17075 (void *)&cmd_show_tx_metadata_pid,
17076 (void *)&cmd_show_tx_metadata_keyword,
17081 /* *** show fec capability per port configuration *** */
17082 struct cmd_show_fec_capability_result {
17083 cmdline_fixed_string_t cmd_show;
17084 cmdline_fixed_string_t cmd_port;
17085 cmdline_fixed_string_t cmd_fec;
17086 cmdline_fixed_string_t cmd_keyword;
17091 cmd_show_fec_capability_parsed(void *parsed_result,
17092 __rte_unused struct cmdline *cl,
17093 __rte_unused void *data)
17095 struct cmd_show_fec_capability_result *res = parsed_result;
17096 struct rte_eth_fec_capa *speed_fec_capa;
17100 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17101 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17105 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
17106 if (ret == -ENOTSUP) {
17107 fprintf(stderr, "Function not implemented\n");
17109 } else if (ret < 0) {
17110 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
17114 num = (unsigned int)ret;
17115 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
17116 if (speed_fec_capa == NULL) {
17117 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
17121 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17123 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17127 show_fec_capability(num, speed_fec_capa);
17129 free(speed_fec_capa);
17132 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17133 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17135 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17136 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17138 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17139 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17140 cmd_pid, RTE_UINT16);
17141 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17142 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17144 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17145 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17146 cmd_keyword, "capabilities");
17148 cmdline_parse_inst_t cmd_show_capability = {
17149 .f = cmd_show_fec_capability_parsed,
17151 .help_str = "show port <port_id> fec capabilities",
17153 (void *)&cmd_show_fec_capability_show,
17154 (void *)&cmd_show_fec_capability_port,
17155 (void *)&cmd_show_fec_capability_pid,
17156 (void *)&cmd_show_fec_capability_fec,
17157 (void *)&cmd_show_fec_capability_keyword,
17162 /* *** show fec mode per port configuration *** */
17163 struct cmd_show_fec_metadata_result {
17164 cmdline_fixed_string_t cmd_show;
17165 cmdline_fixed_string_t cmd_port;
17166 cmdline_fixed_string_t cmd_keyword;
17171 cmd_show_fec_mode_parsed(void *parsed_result,
17172 __rte_unused struct cmdline *cl,
17173 __rte_unused void *data)
17175 #define FEC_NAME_SIZE 16
17176 struct cmd_show_fec_metadata_result *res = parsed_result;
17178 char buf[FEC_NAME_SIZE];
17181 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17182 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17185 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17186 if (ret == -ENOTSUP) {
17187 fprintf(stderr, "Function not implemented\n");
17189 } else if (ret < 0) {
17190 fprintf(stderr, "Get FEC mode failed\n");
17195 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17196 strlcpy(buf, "off", sizeof(buf));
17198 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17199 strlcpy(buf, "auto", sizeof(buf));
17201 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17202 strlcpy(buf, "baser", sizeof(buf));
17204 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17205 strlcpy(buf, "rs", sizeof(buf));
17211 printf("%s\n", buf);
17214 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17215 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17217 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17218 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17220 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17221 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17222 cmd_pid, RTE_UINT16);
17223 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17224 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17225 cmd_keyword, "fec_mode");
17227 cmdline_parse_inst_t cmd_show_fec_mode = {
17228 .f = cmd_show_fec_mode_parsed,
17230 .help_str = "show port <port_id> fec_mode",
17232 (void *)&cmd_show_fec_mode_show,
17233 (void *)&cmd_show_fec_mode_port,
17234 (void *)&cmd_show_fec_mode_pid,
17235 (void *)&cmd_show_fec_mode_keyword,
17240 /* *** set fec mode per port configuration *** */
17241 struct cmd_set_port_fec_mode {
17242 cmdline_fixed_string_t set;
17243 cmdline_fixed_string_t port;
17245 cmdline_fixed_string_t fec_mode;
17246 cmdline_fixed_string_t fec_value;
17249 /* Common CLI fields for set fec mode */
17250 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17251 TOKEN_STRING_INITIALIZER
17252 (struct cmd_set_port_fec_mode,
17254 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17255 TOKEN_STRING_INITIALIZER
17256 (struct cmd_set_port_fec_mode,
17258 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17259 TOKEN_NUM_INITIALIZER
17260 (struct cmd_set_port_fec_mode,
17261 port_id, RTE_UINT16);
17262 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17263 TOKEN_STRING_INITIALIZER
17264 (struct cmd_set_port_fec_mode,
17265 fec_mode, "fec_mode");
17266 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17267 TOKEN_STRING_INITIALIZER
17268 (struct cmd_set_port_fec_mode,
17272 cmd_set_port_fec_mode_parsed(
17273 void *parsed_result,
17274 __rte_unused struct cmdline *cl,
17275 __rte_unused void *data)
17277 struct cmd_set_port_fec_mode *res = parsed_result;
17278 uint16_t port_id = res->port_id;
17282 ret = parse_fec_mode(res->fec_value, &fec_capa);
17284 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17285 res->fec_value, port_id);
17289 ret = rte_eth_fec_set(port_id, fec_capa);
17290 if (ret == -ENOTSUP) {
17291 fprintf(stderr, "Function not implemented\n");
17293 } else if (ret < 0) {
17294 fprintf(stderr, "Set FEC mode failed\n");
17299 cmdline_parse_inst_t cmd_set_fec_mode = {
17300 .f = cmd_set_port_fec_mode_parsed,
17302 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17304 (void *)&cmd_set_port_fec_mode_set,
17305 (void *)&cmd_set_port_fec_mode_port,
17306 (void *)&cmd_set_port_fec_mode_port_id,
17307 (void *)&cmd_set_port_fec_mode_str,
17308 (void *)&cmd_set_port_fec_mode_value,
17313 /* show port supported ptypes */
17315 /* Common result structure for show port ptypes */
17316 struct cmd_show_port_supported_ptypes_result {
17317 cmdline_fixed_string_t show;
17318 cmdline_fixed_string_t port;
17320 cmdline_fixed_string_t ptypes;
17323 /* Common CLI fields for show port ptypes */
17324 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17325 TOKEN_STRING_INITIALIZER
17326 (struct cmd_show_port_supported_ptypes_result,
17328 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17329 TOKEN_STRING_INITIALIZER
17330 (struct cmd_show_port_supported_ptypes_result,
17332 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17333 TOKEN_NUM_INITIALIZER
17334 (struct cmd_show_port_supported_ptypes_result,
17335 port_id, RTE_UINT16);
17336 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17337 TOKEN_STRING_INITIALIZER
17338 (struct cmd_show_port_supported_ptypes_result,
17342 cmd_show_port_supported_ptypes_parsed(
17343 void *parsed_result,
17344 __rte_unused struct cmdline *cl,
17345 __rte_unused void *data)
17347 #define RSVD_PTYPE_MASK 0xf0000000
17348 #define MAX_PTYPES_PER_LAYER 16
17349 #define LTYPE_NAMESIZE 32
17350 #define PTYPE_NAMESIZE 256
17351 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17352 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17353 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17354 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17355 uint16_t port_id = res->port_id;
17358 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17362 while (ptype_mask != RSVD_PTYPE_MASK) {
17364 switch (ptype_mask) {
17365 case RTE_PTYPE_L2_MASK:
17366 strlcpy(ltype, "L2", sizeof(ltype));
17368 case RTE_PTYPE_L3_MASK:
17369 strlcpy(ltype, "L3", sizeof(ltype));
17371 case RTE_PTYPE_L4_MASK:
17372 strlcpy(ltype, "L4", sizeof(ltype));
17374 case RTE_PTYPE_TUNNEL_MASK:
17375 strlcpy(ltype, "Tunnel", sizeof(ltype));
17377 case RTE_PTYPE_INNER_L2_MASK:
17378 strlcpy(ltype, "Inner L2", sizeof(ltype));
17380 case RTE_PTYPE_INNER_L3_MASK:
17381 strlcpy(ltype, "Inner L3", sizeof(ltype));
17383 case RTE_PTYPE_INNER_L4_MASK:
17384 strlcpy(ltype, "Inner L4", sizeof(ltype));
17390 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17391 ptype_mask, ptypes,
17392 MAX_PTYPES_PER_LAYER);
17395 printf("Supported %s ptypes:\n", ltype);
17397 printf("%s ptypes unsupported\n", ltype);
17399 for (i = 0; i < ret; ++i) {
17400 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17401 printf("%s\n", buf);
17408 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17409 .f = cmd_show_port_supported_ptypes_parsed,
17411 .help_str = "show port <port_id> ptypes",
17413 (void *)&cmd_show_port_supported_ptypes_show,
17414 (void *)&cmd_show_port_supported_ptypes_port,
17415 (void *)&cmd_show_port_supported_ptypes_port_id,
17416 (void *)&cmd_show_port_supported_ptypes_ptypes,
17421 /* *** display rx/tx descriptor status *** */
17422 struct cmd_show_rx_tx_desc_status_result {
17423 cmdline_fixed_string_t cmd_show;
17424 cmdline_fixed_string_t cmd_port;
17425 cmdline_fixed_string_t cmd_keyword;
17426 cmdline_fixed_string_t cmd_desc;
17427 cmdline_fixed_string_t cmd_status;
17434 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17435 __rte_unused struct cmdline *cl,
17436 __rte_unused void *data)
17438 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17441 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17442 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17446 if (!strcmp(res->cmd_keyword, "rxq")) {
17447 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17451 "Invalid input: queue id = %d, desc id = %d\n",
17452 res->cmd_qid, res->cmd_did);
17455 if (rc == RTE_ETH_RX_DESC_AVAIL)
17456 printf("Desc status = AVAILABLE\n");
17457 else if (rc == RTE_ETH_RX_DESC_DONE)
17458 printf("Desc status = DONE\n");
17460 printf("Desc status = UNAVAILABLE\n");
17461 } else if (!strcmp(res->cmd_keyword, "txq")) {
17462 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17466 "Invalid input: queue id = %d, desc id = %d\n",
17467 res->cmd_qid, res->cmd_did);
17470 if (rc == RTE_ETH_TX_DESC_FULL)
17471 printf("Desc status = FULL\n");
17472 else if (rc == RTE_ETH_TX_DESC_DONE)
17473 printf("Desc status = DONE\n");
17475 printf("Desc status = UNAVAILABLE\n");
17479 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17480 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17482 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17483 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17485 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17486 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17487 cmd_pid, RTE_UINT16);
17488 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17489 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17490 cmd_keyword, "rxq#txq");
17491 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17492 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17493 cmd_qid, RTE_UINT16);
17494 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17495 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17497 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17498 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17499 cmd_did, RTE_UINT16);
17500 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17501 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17502 cmd_status, "status");
17503 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17504 .f = cmd_show_rx_tx_desc_status_parsed,
17506 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17509 (void *)&cmd_show_rx_tx_desc_status_show,
17510 (void *)&cmd_show_rx_tx_desc_status_port,
17511 (void *)&cmd_show_rx_tx_desc_status_pid,
17512 (void *)&cmd_show_rx_tx_desc_status_keyword,
17513 (void *)&cmd_show_rx_tx_desc_status_qid,
17514 (void *)&cmd_show_rx_tx_desc_status_desc,
17515 (void *)&cmd_show_rx_tx_desc_status_did,
17516 (void *)&cmd_show_rx_tx_desc_status_status,
17521 /* *** display rx queue desc used count *** */
17522 struct cmd_show_rx_queue_desc_used_count_result {
17523 cmdline_fixed_string_t cmd_show;
17524 cmdline_fixed_string_t cmd_port;
17525 cmdline_fixed_string_t cmd_rxq;
17526 cmdline_fixed_string_t cmd_desc;
17527 cmdline_fixed_string_t cmd_used;
17528 cmdline_fixed_string_t cmd_count;
17534 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17535 __rte_unused struct cmdline *cl,
17536 __rte_unused void *data)
17538 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17541 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17542 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17546 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17548 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17551 printf("Used desc count = %d\n", rc);
17554 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17555 TOKEN_STRING_INITIALIZER
17556 (struct cmd_show_rx_queue_desc_used_count_result,
17558 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17559 TOKEN_STRING_INITIALIZER
17560 (struct cmd_show_rx_queue_desc_used_count_result,
17562 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17563 TOKEN_NUM_INITIALIZER
17564 (struct cmd_show_rx_queue_desc_used_count_result,
17565 cmd_pid, RTE_UINT16);
17566 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17567 TOKEN_STRING_INITIALIZER
17568 (struct cmd_show_rx_queue_desc_used_count_result,
17570 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17571 TOKEN_NUM_INITIALIZER
17572 (struct cmd_show_rx_queue_desc_used_count_result,
17573 cmd_qid, RTE_UINT16);
17574 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17575 TOKEN_STRING_INITIALIZER
17576 (struct cmd_show_rx_queue_desc_used_count_result,
17577 cmd_count, "desc");
17578 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17579 TOKEN_STRING_INITIALIZER
17580 (struct cmd_show_rx_queue_desc_used_count_result,
17581 cmd_count, "used");
17582 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17583 TOKEN_STRING_INITIALIZER
17584 (struct cmd_show_rx_queue_desc_used_count_result,
17585 cmd_count, "count");
17586 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17587 .f = cmd_show_rx_queue_desc_used_count_parsed,
17589 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17591 (void *)&cmd_show_rx_queue_desc_used_count_show,
17592 (void *)&cmd_show_rx_queue_desc_used_count_port,
17593 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17594 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17595 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17596 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17597 (void *)&cmd_show_rx_queue_desc_used_count_used,
17598 (void *)&cmd_show_rx_queue_desc_used_count_count,
17603 /* Common result structure for set port ptypes */
17604 struct cmd_set_port_ptypes_result {
17605 cmdline_fixed_string_t set;
17606 cmdline_fixed_string_t port;
17608 cmdline_fixed_string_t ptype_mask;
17612 /* Common CLI fields for set port ptypes */
17613 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17614 TOKEN_STRING_INITIALIZER
17615 (struct cmd_set_port_ptypes_result,
17617 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17618 TOKEN_STRING_INITIALIZER
17619 (struct cmd_set_port_ptypes_result,
17621 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17622 TOKEN_NUM_INITIALIZER
17623 (struct cmd_set_port_ptypes_result,
17624 port_id, RTE_UINT16);
17625 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17626 TOKEN_STRING_INITIALIZER
17627 (struct cmd_set_port_ptypes_result,
17628 ptype_mask, "ptype_mask");
17629 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17630 TOKEN_NUM_INITIALIZER
17631 (struct cmd_set_port_ptypes_result,
17635 cmd_set_port_ptypes_parsed(
17636 void *parsed_result,
17637 __rte_unused struct cmdline *cl,
17638 __rte_unused void *data)
17640 struct cmd_set_port_ptypes_result *res = parsed_result;
17641 #define PTYPE_NAMESIZE 256
17642 char ptype_name[PTYPE_NAMESIZE];
17643 uint16_t port_id = res->port_id;
17644 uint32_t ptype_mask = res->mask;
17647 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17650 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17655 uint32_t ptypes[ret];
17657 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17659 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17664 printf("Successfully set following ptypes for Port %d\n", port_id);
17665 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17666 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17667 printf("%s\n", ptype_name);
17670 clear_ptypes = false;
17673 cmdline_parse_inst_t cmd_set_port_ptypes = {
17674 .f = cmd_set_port_ptypes_parsed,
17676 .help_str = "set port <port_id> ptype_mask <mask>",
17678 (void *)&cmd_set_port_ptypes_set,
17679 (void *)&cmd_set_port_ptypes_port,
17680 (void *)&cmd_set_port_ptypes_port_id,
17681 (void *)&cmd_set_port_ptypes_mask_str,
17682 (void *)&cmd_set_port_ptypes_mask_u32,
17687 /* *** display mac addresses added to a port *** */
17688 struct cmd_showport_macs_result {
17689 cmdline_fixed_string_t cmd_show;
17690 cmdline_fixed_string_t cmd_port;
17691 cmdline_fixed_string_t cmd_keyword;
17696 cmd_showport_macs_parsed(void *parsed_result,
17697 __rte_unused struct cmdline *cl,
17698 __rte_unused void *data)
17700 struct cmd_showport_macs_result *res = parsed_result;
17702 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17705 if (!strcmp(res->cmd_keyword, "macs"))
17706 show_macs(res->cmd_pid);
17707 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17708 show_mcast_macs(res->cmd_pid);
17711 cmdline_parse_token_string_t cmd_showport_macs_show =
17712 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17714 cmdline_parse_token_string_t cmd_showport_macs_port =
17715 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17717 cmdline_parse_token_num_t cmd_showport_macs_pid =
17718 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17719 cmd_pid, RTE_UINT16);
17720 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17721 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17722 cmd_keyword, "macs#mcast_macs");
17724 cmdline_parse_inst_t cmd_showport_macs = {
17725 .f = cmd_showport_macs_parsed,
17727 .help_str = "show port <port_id> macs|mcast_macs",
17729 (void *)&cmd_showport_macs_show,
17730 (void *)&cmd_showport_macs_port,
17731 (void *)&cmd_showport_macs_pid,
17732 (void *)&cmd_showport_macs_keyword,
17737 /* *** show flow transfer proxy port ID for the given port *** */
17738 struct cmd_show_port_flow_transfer_proxy_result {
17739 cmdline_fixed_string_t show;
17740 cmdline_fixed_string_t port;
17742 cmdline_fixed_string_t flow;
17743 cmdline_fixed_string_t transfer;
17744 cmdline_fixed_string_t proxy;
17747 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17748 TOKEN_STRING_INITIALIZER
17749 (struct cmd_show_port_flow_transfer_proxy_result,
17751 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17752 TOKEN_STRING_INITIALIZER
17753 (struct cmd_show_port_flow_transfer_proxy_result,
17755 cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17756 TOKEN_NUM_INITIALIZER
17757 (struct cmd_show_port_flow_transfer_proxy_result,
17758 port_id, RTE_UINT16);
17759 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17760 TOKEN_STRING_INITIALIZER
17761 (struct cmd_show_port_flow_transfer_proxy_result,
17763 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17764 TOKEN_STRING_INITIALIZER
17765 (struct cmd_show_port_flow_transfer_proxy_result,
17766 transfer, "transfer");
17767 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17768 TOKEN_STRING_INITIALIZER
17769 (struct cmd_show_port_flow_transfer_proxy_result,
17773 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17774 __rte_unused struct cmdline *cl,
17775 __rte_unused void *data)
17777 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17778 portid_t proxy_port_id;
17783 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17785 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17786 rte_strerror(-ret));
17790 printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17793 cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17794 .f = cmd_show_port_flow_transfer_proxy_parsed,
17796 .help_str = "show port <port_id> flow transfer proxy",
17798 (void *)&cmd_show_port_flow_transfer_proxy_show,
17799 (void *)&cmd_show_port_flow_transfer_proxy_port,
17800 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
17801 (void *)&cmd_show_port_flow_transfer_proxy_flow,
17802 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
17803 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
17808 /* ******************************************************************************** */
17810 /* list of instructions */
17811 cmdline_parse_ctx_t main_ctx[] = {
17812 (cmdline_parse_inst_t *)&cmd_help_brief,
17813 (cmdline_parse_inst_t *)&cmd_help_long,
17814 (cmdline_parse_inst_t *)&cmd_quit,
17815 (cmdline_parse_inst_t *)&cmd_load_from_file,
17816 (cmdline_parse_inst_t *)&cmd_showport,
17817 (cmdline_parse_inst_t *)&cmd_showqueue,
17818 (cmdline_parse_inst_t *)&cmd_showeeprom,
17819 (cmdline_parse_inst_t *)&cmd_showportall,
17820 (cmdline_parse_inst_t *)&cmd_representor_info,
17821 (cmdline_parse_inst_t *)&cmd_showdevice,
17822 (cmdline_parse_inst_t *)&cmd_showcfg,
17823 (cmdline_parse_inst_t *)&cmd_showfwdall,
17824 (cmdline_parse_inst_t *)&cmd_start,
17825 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17826 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17827 (cmdline_parse_inst_t *)&cmd_set_link_up,
17828 (cmdline_parse_inst_t *)&cmd_set_link_down,
17829 (cmdline_parse_inst_t *)&cmd_reset,
17830 (cmdline_parse_inst_t *)&cmd_set_numbers,
17831 (cmdline_parse_inst_t *)&cmd_set_log,
17832 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17833 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17834 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17835 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17836 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17837 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17838 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17839 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17840 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17841 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17842 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17843 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17844 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17845 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17846 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17847 (cmdline_parse_inst_t *)&cmd_set_link_check,
17848 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17849 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17850 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17851 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17852 #ifdef RTE_NET_BOND
17853 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17854 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17855 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17856 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17857 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17858 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17859 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17860 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17861 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17862 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17863 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17864 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17866 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17867 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17868 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17869 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17870 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17871 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17872 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17873 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17874 (cmdline_parse_inst_t *)&cmd_csum_set,
17875 (cmdline_parse_inst_t *)&cmd_csum_show,
17876 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17877 (cmdline_parse_inst_t *)&cmd_tso_set,
17878 (cmdline_parse_inst_t *)&cmd_tso_show,
17879 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17880 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17882 (cmdline_parse_inst_t *)&cmd_gro_enable,
17883 (cmdline_parse_inst_t *)&cmd_gro_flush,
17884 (cmdline_parse_inst_t *)&cmd_gro_show,
17887 (cmdline_parse_inst_t *)&cmd_gso_enable,
17888 (cmdline_parse_inst_t *)&cmd_gso_size,
17889 (cmdline_parse_inst_t *)&cmd_gso_show,
17891 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17892 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17893 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17894 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17895 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17896 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17897 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17898 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17899 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17900 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17901 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17902 (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
17903 (cmdline_parse_inst_t *)&cmd_config_dcb,
17904 (cmdline_parse_inst_t *)&cmd_read_reg,
17905 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17906 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17907 (cmdline_parse_inst_t *)&cmd_write_reg,
17908 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17909 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17910 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17911 (cmdline_parse_inst_t *)&cmd_stop,
17912 (cmdline_parse_inst_t *)&cmd_mac_addr,
17913 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17914 (cmdline_parse_inst_t *)&cmd_set_qmap,
17915 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17916 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17917 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17918 (cmdline_parse_inst_t *)&cmd_operate_port,
17919 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17920 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17921 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17922 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17923 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17924 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17925 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17926 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17927 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17928 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17929 (cmdline_parse_inst_t *)&cmd_config_mtu,
17930 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17931 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17932 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17933 (cmdline_parse_inst_t *)&cmd_config_rss,
17934 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17935 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17936 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17937 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17938 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17939 (cmdline_parse_inst_t *)&cmd_showport_reta,
17940 (cmdline_parse_inst_t *)&cmd_showport_macs,
17941 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17942 (cmdline_parse_inst_t *)&cmd_config_burst,
17943 (cmdline_parse_inst_t *)&cmd_config_thresh,
17944 (cmdline_parse_inst_t *)&cmd_config_threshold,
17945 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17946 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17947 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17948 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17949 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17950 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17951 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17952 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17953 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17954 (cmdline_parse_inst_t *)&cmd_dump,
17955 (cmdline_parse_inst_t *)&cmd_dump_one,
17956 #ifdef RTE_NET_I40E
17957 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17959 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17960 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17961 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17962 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17963 (cmdline_parse_inst_t *)&cmd_flow,
17964 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17965 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17966 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17967 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17968 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17969 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17970 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17971 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17972 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17973 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17974 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17975 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17976 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17977 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17978 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17979 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17980 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17981 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17982 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17983 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17984 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17985 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17986 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17987 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17988 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17989 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17990 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17991 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17992 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17993 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17994 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17995 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17996 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17997 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17998 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17999 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18000 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18001 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18002 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18003 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18004 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18005 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18006 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18007 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18008 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18009 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18010 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18011 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18012 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18013 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18014 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18015 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18016 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18017 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18018 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18019 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18020 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
18021 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
18022 (cmdline_parse_inst_t *)&cmd_ddp_add,
18023 (cmdline_parse_inst_t *)&cmd_ddp_del,
18024 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18025 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18026 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18027 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18028 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18029 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18030 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18031 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18032 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18033 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18034 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18035 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18037 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18038 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18039 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18040 (cmdline_parse_inst_t *)&cmd_queue_region,
18041 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18042 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18043 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18044 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18045 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18046 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18047 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18048 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18049 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18050 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18051 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18052 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18053 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18054 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18055 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18056 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18057 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18058 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18059 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18060 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18061 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18062 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18063 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18064 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18065 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18066 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18067 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18068 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18069 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18070 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18071 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18072 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18073 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18074 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18075 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18076 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18078 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18079 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18081 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18082 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18083 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18084 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
18085 (cmdline_parse_inst_t *)&cmd_set_raw,
18086 (cmdline_parse_inst_t *)&cmd_show_set_raw,
18087 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18088 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18089 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
18090 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
18091 (cmdline_parse_inst_t *)&cmd_show_capability,
18092 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
18093 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
18097 /* read cmdline commands from file */
18099 cmdline_read_from_file(const char *filename)
18101 struct cmdline *cl;
18103 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18106 "Failed to create file based cmdline context: %s\n",
18111 cmdline_interact(cl);
18116 printf("Read CLI commands from %s\n", filename);
18119 /* prompt function, called from main on MAIN lcore */
18124 /* initialize non-constant commands */
18125 cmd_set_fwd_mode_init();
18126 cmd_set_fwd_retry_mode_init();
18128 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18129 if (testpmd_cl == NULL)
18132 ret = atexit(prompt_exit);
18134 fprintf(stderr, "Cannot set exit function for cmdline\n");
18136 cmdline_interact(testpmd_cl);
18138 cmdline_stdin_exit(testpmd_cl);
18144 if (testpmd_cl != NULL) {
18145 cmdline_quit(testpmd_cl);
18146 cmdline_stdin_exit(testpmd_cl);
18151 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18153 if (id == (portid_t)RTE_PORT_ALL) {
18156 RTE_ETH_FOREACH_DEV(pid) {
18157 /* check if need_reconfig has been set to 1 */
18158 if (ports[pid].need_reconfig == 0)
18159 ports[pid].need_reconfig = dev;
18160 /* check if need_reconfig_queues has been set to 1 */
18161 if (ports[pid].need_reconfig_queues == 0)
18162 ports[pid].need_reconfig_queues = queue;
18164 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18165 /* check if need_reconfig has been set to 1 */
18166 if (ports[id].need_reconfig == 0)
18167 ports[id].need_reconfig = dev;
18168 /* check if need_reconfig_queues has been set to 1 */
18169 if (ports[id].need_reconfig_queues == 0)
18170 ports[id].need_reconfig_queues = queue;