1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
13 #include <sys/queue.h>
15 #include <rte_common.h>
16 #include <rte_byteorder.h>
18 #include <rte_debug.h>
19 #include <rte_cycles.h>
20 #include <rte_memory.h>
21 #include <rte_memzone.h>
22 #include <rte_malloc.h>
23 #include <rte_launch.h>
25 #include <rte_per_lcore.h>
26 #include <rte_lcore.h>
27 #include <rte_branch_prediction.h>
29 #include <rte_mempool.h>
30 #include <rte_interrupts.h>
32 #include <rte_ether.h>
33 #include <rte_ethdev.h>
34 #include <rte_string_fns.h>
35 #include <rte_devargs.h>
40 #include <rte_mbuf_dyn.h>
42 #include <cmdline_rdline.h>
43 #include <cmdline_parse.h>
44 #include <cmdline_parse_num.h>
45 #include <cmdline_parse_string.h>
46 #include <cmdline_parse_ipaddr.h>
47 #include <cmdline_parse_etheraddr.h>
48 #include <cmdline_socket.h>
51 #include <rte_eth_bond.h>
52 #include <rte_eth_bond_8023ad.h>
54 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
55 #include <rte_pmd_dpaa.h>
58 #include <rte_pmd_ixgbe.h>
61 #include <rte_pmd_i40e.h>
64 #include <rte_pmd_bnxt.h>
67 #include "cmdline_mtr.h"
68 #include "cmdline_tm.h"
71 static struct cmdline *testpmd_cl;
73 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
75 /* *** Help command with introduction. *** */
76 struct cmd_help_brief_result {
77 cmdline_fixed_string_t help;
80 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
82 __rte_unused void *data)
87 "Help is available for the following sections:\n\n"
88 " help control : Start and stop forwarding.\n"
89 " help display : Displaying port, stats and config "
91 " help config : Configuration information.\n"
92 " help ports : Configuring ports.\n"
93 " help registers : Reading and setting port registers.\n"
94 " help filters : Filters configuration help.\n"
95 " help traffic_management : Traffic Management commands.\n"
96 " help devices : Device related cmds.\n"
97 " help all : All of the above sections.\n\n"
102 cmdline_parse_token_string_t cmd_help_brief_help =
103 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
105 cmdline_parse_inst_t cmd_help_brief = {
106 .f = cmd_help_brief_parsed,
108 .help_str = "help: Show help",
110 (void *)&cmd_help_brief_help,
115 /* *** Help command with help sections. *** */
116 struct cmd_help_long_result {
117 cmdline_fixed_string_t help;
118 cmdline_fixed_string_t section;
121 static void cmd_help_long_parsed(void *parsed_result,
123 __rte_unused void *data)
126 struct cmd_help_long_result *res = parsed_result;
128 if (!strcmp(res->section, "all"))
131 if (show_all || !strcmp(res->section, "control")) {
136 "Control forwarding:\n"
137 "-------------------\n\n"
140 " Start packet forwarding with current configuration.\n\n"
143 " Start packet forwarding with current config"
144 " after sending one burst of packets.\n\n"
147 " Stop packet forwarding, and display accumulated"
151 " Quit to prompt.\n\n"
155 if (show_all || !strcmp(res->section, "display")) {
163 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
164 " Display information for port_id, or all.\n\n"
166 "show port info (port_id) representor\n"
167 " Show supported representors for a specific port\n\n"
169 "show port port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) rxq (queue_id) desc used count\n"
250 " Show current number of filled receive"
251 " packet descriptors.\n\n"
253 "show port (port_id) macs|mcast_macs"
254 " Display list of mac addresses added to port.\n\n"
256 "show port (port_id) flow transfer proxy\n"
257 " Display proxy port to manage transfer flows\n\n"
259 "show port (port_id) fec capabilities"
260 " Show fec capabilities of a port.\n\n"
262 "show port (port_id) fec_mode"
263 " Show fec mode of a port.\n\n"
265 "show port (port_id) flow_ctrl"
266 " Show flow control info of a port.\n\n"
270 if (show_all || !strcmp(res->section, "config")) {
276 "Configuration changes only become active when"
277 " forwarding is started/restarted.\n\n"
280 " Reset forwarding to the default configuration.\n\n"
282 "set verbose (level)\n"
283 " Set the debug verbosity level X.\n\n"
285 "set log global|(type) (level)\n"
286 " Set the log level.\n\n"
289 " Set number of ports.\n\n"
292 " Set number of cores.\n\n"
294 "set coremask (mask)\n"
295 " Set the forwarding cores hexadecimal mask.\n\n"
297 "set portmask (mask)\n"
298 " Set the forwarding ports hexadecimal mask.\n\n"
301 " Set number of packets per burst.\n\n"
303 "set burst tx delay (microseconds) retry (num)\n"
304 " Set the transmit delay time and number of retries,"
305 " effective when retry is enabled.\n\n"
307 "set rxoffs (x[,y]*)\n"
308 " Set the offset of each packet segment on"
309 " receiving if split feature is engaged."
310 " Affects only the queues configured with split"
313 "set rxpkts (x[,y]*)\n"
314 " Set the length of each segment to scatter"
315 " packets on receiving if split feature is engaged."
316 " Affects only the queues configured with split"
319 "set txpkts (x[,y]*)\n"
320 " Set the length of each segment of TXONLY"
321 " and optionally CSUM packets.\n\n"
323 "set txsplit (off|on|rand)\n"
324 " Set the split policy for the TX packets."
325 " Right now only applicable for CSUM and TXONLY"
328 "set txtimes (x, y)\n"
329 " Set the scheduling on timestamps"
330 " timings for the TXONLY mode\n\n"
332 "set corelist (x[,y]*)\n"
333 " Set the list of forwarding cores.\n\n"
335 "set portlist (x[,y]*)\n"
336 " Set the list of forwarding ports.\n\n"
338 "set port setup on (iterator|event)\n"
339 " Select how attached port is retrieved for setup.\n\n"
341 "set tx loopback (port_id) (on|off)\n"
342 " Enable or disable tx loopback.\n\n"
344 "set all queues drop (port_id) (on|off)\n"
345 " Set drop enable bit for all queues.\n\n"
347 "set vf split drop (port_id) (vf_id) (on|off)\n"
348 " Set split drop enable bit for a VF from the PF.\n\n"
350 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
351 " Set MAC antispoof for a VF from the PF.\n\n"
353 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
354 " Enable MACsec offload.\n\n"
356 "set macsec offload (port_id) off\n"
357 " Disable MACsec offload.\n\n"
359 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
360 " Configure MACsec secure connection (SC).\n\n"
362 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
363 " Configure MACsec secure association (SA).\n\n"
365 "set vf broadcast (port_id) (vf_id) (on|off)\n"
366 " Set VF broadcast for a VF from the PF.\n\n"
368 "vlan set stripq (on|off) (port_id,queue_id)\n"
369 " Set the VLAN strip for a queue on a port.\n\n"
371 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
372 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
374 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
375 " Set VLAN insert for a VF from the PF.\n\n"
377 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
378 " Set VLAN antispoof for a VF from the PF.\n\n"
380 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
381 " Set VLAN tag for a VF from the PF.\n\n"
383 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
384 " Set a VF's max bandwidth(Mbps).\n\n"
386 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
387 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
389 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
390 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
392 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
393 " Set some TCs' strict link priority mode on a physical port.\n\n"
395 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
396 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
398 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
399 " Set the VLAN strip or filter or qinq strip or extend\n\n"
401 "vlan set (inner|outer) tpid (value) (port_id)\n"
402 " Set the VLAN TPID for Packet Filtering on"
405 "rx_vlan add (vlan_id|all) (port_id)\n"
406 " Add a vlan_id, or all identifiers, to the set"
407 " of VLAN identifiers filtered by port_id.\n\n"
409 "rx_vlan rm (vlan_id|all) (port_id)\n"
410 " Remove a vlan_id, or all identifiers, from the set"
411 " of VLAN identifiers filtered by port_id.\n\n"
413 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
414 " Add a vlan_id, to the set of VLAN identifiers"
415 "filtered for VF(s) from port_id.\n\n"
417 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
418 " Remove a vlan_id, to the set of VLAN identifiers"
419 "filtered for VF(s) from port_id.\n\n"
421 "rx_vxlan_port add (udp_port) (port_id)\n"
422 " Add an UDP port for VXLAN packet filter on a port\n\n"
424 "rx_vxlan_port rm (udp_port) (port_id)\n"
425 " Remove an UDP port for VXLAN packet filter on a port\n\n"
427 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
428 " Set hardware insertion of VLAN IDs (single or double VLAN "
429 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
431 "tx_vlan set pvid port_id vlan_id (on|off)\n"
432 " Set port based TX VLAN insertion.\n\n"
434 "tx_vlan reset (port_id)\n"
435 " Disable hardware insertion of a VLAN header in"
436 " packets sent on a port.\n\n"
438 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
439 " Select hardware or software calculation of the"
440 " checksum when transmitting a packet using the"
441 " csum forward engine.\n"
442 " ip|udp|tcp|sctp always concern the inner layer.\n"
443 " outer-ip concerns the outer IP layer in"
444 " outer-udp concerns the outer UDP layer in"
445 " case the packet is recognized as a tunnel packet by"
446 " the forward engine (vxlan, gre and ipip are supported)\n"
447 " Please check the NIC datasheet for HW limits.\n\n"
449 "csum parse-tunnel (on|off) (tx_port_id)\n"
450 " If disabled, treat tunnel packets as non-tunneled"
451 " packets (treat inner headers as payload). The port\n"
452 " argument is the port used for TX in csum forward"
455 "csum show (port_id)\n"
456 " Display tx checksum offload configuration\n\n"
458 "tso set (segsize) (portid)\n"
459 " Enable TCP Segmentation Offload in csum forward"
461 " Please check the NIC datasheet for HW limits.\n\n"
464 " Display the status of TCP Segmentation Offload.\n\n"
467 "set port (port_id) gro on|off\n"
468 " Enable or disable Generic Receive Offload in"
469 " csum forwarding engine.\n\n"
471 "show port (port_id) gro\n"
472 " Display GRO configuration.\n\n"
474 "set gro flush (cycles)\n"
475 " Set the cycle to flush GROed packets from"
476 " reassembly tables.\n\n"
480 "set port (port_id) gso (on|off)"
481 " Enable or disable Generic Segmentation Offload in"
482 " csum forwarding engine.\n\n"
484 "set gso segsz (length)\n"
485 " Set max packet length for output GSO segments,"
486 " including packet header and payload.\n\n"
488 "show port (port_id) gso\n"
489 " Show GSO configuration.\n\n"
493 " Set packet forwarding mode.\n\n"
495 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
496 " Add a MAC address on port_id.\n\n"
498 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
499 " Remove a MAC address from port_id.\n\n"
501 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
502 " Set the default MAC address for port_id.\n\n"
504 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
505 " Add a MAC address for a VF on the port.\n\n"
507 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
508 " Set the MAC address for a VF from the PF.\n\n"
510 "set eth-peer (port_id) (peer_addr)\n"
511 " set the peer address for certain port.\n\n"
513 "set port (port_id) uta (mac_address|all) (on|off)\n"
514 " Add/Remove a or all unicast hash filter(s)"
517 "set promisc (port_id|all) (on|off)\n"
518 " Set the promiscuous mode on port_id, or all.\n\n"
520 "set allmulti (port_id|all) (on|off)\n"
521 " Set the allmulti mode on port_id, or all.\n\n"
523 "set vf promisc (port_id) (vf_id) (on|off)\n"
524 " Set unicast promiscuous mode for a VF from the PF.\n\n"
526 "set vf allmulti (port_id) (vf_id) (on|off)\n"
527 " Set multicast promiscuous mode for a VF from the PF.\n\n"
529 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
530 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
531 " (on|off) autoneg (on|off) (port_id)\n"
532 "set flow_ctrl rx (on|off) (portid)\n"
533 "set flow_ctrl tx (on|off) (portid)\n"
534 "set flow_ctrl high_water (high_water) (portid)\n"
535 "set flow_ctrl low_water (low_water) (portid)\n"
536 "set flow_ctrl pause_time (pause_time) (portid)\n"
537 "set flow_ctrl send_xon (send_xon) (portid)\n"
538 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
539 "set flow_ctrl autoneg (on|off) (port_id)\n"
540 " Set the link flow control parameter on a port.\n\n"
542 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
543 " (low_water) (pause_time) (priority) (port_id)\n"
544 " Set the priority flow control parameter on a"
547 "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
548 " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
549 " Set the queue priority flow control parameter on a"
550 " given Rx and Tx queues of a port.\n\n"
552 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
553 " Set statistics mapping (qmapping 0..15) for RX/TX"
555 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
556 " on port 0 to mapping 5.\n\n"
558 "set xstats-hide-zero on|off\n"
559 " Set the option to hide the zero values"
560 " for xstats display.\n"
562 "set record-core-cycles on|off\n"
563 " Set the option to enable measurement of CPU cycles.\n"
565 "set record-burst-stats on|off\n"
566 " Set the option to enable display of RX and TX bursts.\n"
568 "set port (port_id) vf (vf_id) rx|tx on|off\n"
569 " Enable/Disable a VF receive/transmit from a port\n\n"
571 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
573 " AUPE:accepts untagged VLAN;"
574 "ROPE:accept unicast hash\n\n"
575 " BAM:accepts broadcast packets;"
576 "MPE:accepts all multicast packets\n\n"
577 " Enable/Disable a VF receive mode of a port\n\n"
579 "set port (port_id) queue (queue_id) rate (rate_num)\n"
580 " Set rate limit for a queue of a port\n\n"
582 "set port (port_id) vf (vf_id) rate (rate_num) "
583 "queue_mask (queue_mask_value)\n"
584 " Set rate limit for queues in VF of a port\n\n"
586 "set flush_rx (on|off)\n"
587 " Flush (default) or don't flush RX streams before"
588 " forwarding. Mainly used with PCAP drivers.\n\n"
590 "set bypass mode (normal|bypass|isolate) (port_id)\n"
591 " Set the bypass mode for the lowest port on bypass enabled"
594 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
595 "mode (normal|bypass|isolate) (port_id)\n"
596 " Set the event required to initiate specified bypass mode for"
597 " the lowest port on a bypass enabled NIC where:\n"
598 " timeout = enable bypass after watchdog timeout.\n"
599 " os_on = enable bypass when OS/board is powered on.\n"
600 " os_off = enable bypass when OS/board is powered off.\n"
601 " power_on = enable bypass when power supply is turned on.\n"
602 " power_off = enable bypass when power supply is turned off."
605 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
606 " Set the bypass watchdog timeout to 'n' seconds"
607 " where 0 = instant.\n\n"
609 "show bypass config (port_id)\n"
610 " Show the bypass configuration for a bypass enabled NIC"
611 " using the lowest port on the NIC.\n\n"
614 "create bonded device (mode) (socket)\n"
615 " Create a new bonded device with specific bonding mode and socket.\n\n"
617 "add bonding slave (slave_id) (port_id)\n"
618 " Add a slave device to a bonded device.\n\n"
620 "remove bonding slave (slave_id) (port_id)\n"
621 " Remove a slave device from a bonded device.\n\n"
623 "set bonding mode (value) (port_id)\n"
624 " Set the bonding mode on a bonded device.\n\n"
626 "set bonding primary (slave_id) (port_id)\n"
627 " Set the primary slave for a bonded device.\n\n"
629 "show bonding config (port_id)\n"
630 " Show the bonding config for port_id.\n\n"
632 "show bonding lacp info (port_id)\n"
633 " Show the bonding lacp information for port_id.\n\n"
635 "set bonding mac_addr (port_id) (address)\n"
636 " Set the MAC address of a bonded device.\n\n"
638 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
639 " Set Aggregation mode for IEEE802.3AD (mode 4)"
641 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
642 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
644 "set bonding mon_period (port_id) (value)\n"
645 " Set the bonding link status monitoring polling period in ms.\n\n"
647 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
648 " Enable/disable dedicated queues for LACP control traffic.\n\n"
651 "set link-up port (port_id)\n"
652 " Set link up for a port.\n\n"
654 "set link-down port (port_id)\n"
655 " Set link down for a port.\n\n"
657 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
658 " Load a profile package on a port\n\n"
660 "ddp del (port_id) (backup_profile_path)\n"
661 " Delete a profile package from a port\n\n"
663 "ptype mapping get (port_id) (valid_only)\n"
664 " Get ptype mapping on a port\n\n"
666 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
667 " Replace target with the pkt_type in ptype mapping\n\n"
669 "ptype mapping reset (port_id)\n"
670 " Reset ptype mapping on a port\n\n"
672 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
673 " Update a ptype mapping item on a port\n\n"
675 "set port (port_id) ptype_mask (ptype_mask)\n"
676 " set packet types classification for a specific port\n\n"
678 "set port (port_id) queue-region region_id (value) "
679 "queue_start_index (value) queue_num (value)\n"
680 " Set a queue region on a port\n\n"
682 "set port (port_id) queue-region region_id (value) "
684 " Set a flowtype region index on a port\n\n"
686 "set port (port_id) queue-region UP (value) region_id (value)\n"
687 " Set the mapping of User Priority to "
688 "queue region on a port\n\n"
690 "set port (port_id) queue-region flush (on|off)\n"
691 " flush all queue region related configuration\n\n"
693 "show port meter cap (port_id)\n"
694 " Show port meter capability information\n\n"
696 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
697 " meter profile add - srtcm rfc 2697\n\n"
699 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
700 " meter profile add - trtcm rfc 2698\n\n"
702 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
703 " meter profile add - trtcm rfc 4115\n\n"
705 "del port meter profile (port_id) (profile_id)\n"
706 " meter profile delete\n\n"
708 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
709 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
710 "(dscp_tbl_entry63)]\n"
713 "enable port meter (port_id) (mtr_id)\n"
716 "disable port meter (port_id) (mtr_id)\n"
719 "del port meter (port_id) (mtr_id)\n"
722 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
723 "y_actions (actions) r_actions (actions)\n"
724 " meter policy add\n\n"
726 "del port meter policy (port_id) (policy_id)\n"
727 " meter policy delete\n\n"
729 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
730 " meter update meter profile\n\n"
732 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
733 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
734 " update meter dscp table entries\n\n"
736 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
737 "(action0) [(action1) (action2)]\n"
738 " meter update policer action\n\n"
740 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
741 " meter update stats\n\n"
743 "show port (port_id) queue-region\n"
744 " show all queue region related configuration info\n\n"
746 "set port (port_id) fec_mode auto|off|rs|baser\n"
747 " set fec mode for a specific port\n\n"
749 , list_pkt_forwarding_modes()
753 if (show_all || !strcmp(res->section, "ports")) {
759 "----------------\n\n"
761 "port start (port_id|all)\n"
762 " Start all ports or port_id.\n\n"
764 "port stop (port_id|all)\n"
765 " Stop all ports or port_id.\n\n"
767 "port close (port_id|all)\n"
768 " Close all ports or port_id.\n\n"
770 "port reset (port_id|all)\n"
771 " Reset all ports or port_id.\n\n"
773 "port attach (ident)\n"
774 " Attach physical or virtual dev by pci address or virtual device name\n\n"
776 "port detach (port_id)\n"
777 " Detach physical or virtual dev by port_id\n\n"
779 "port config (port_id|all)"
780 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
781 " duplex (half|full|auto)\n"
782 " Set speed and duplex for all ports or port_id\n\n"
784 "port config (port_id|all) loopback (mode)\n"
785 " Set loopback mode for all ports or port_id\n\n"
787 "port config all (rxq|txq|rxd|txd) (value)\n"
788 " Set number for rxq/txq/rxd/txd.\n\n"
790 "port config all max-pkt-len (value)\n"
791 " Set the max packet length.\n\n"
793 "port config all max-lro-pkt-size (value)\n"
794 " Set the max LRO aggregated packet size.\n\n"
796 "port config all drop-en (on|off)\n"
797 " Enable or disable packet drop on all RX queues of all ports when no "
798 "receive buffers available.\n\n"
800 "port config all rss (all|default|ip|tcp|udp|sctp|"
801 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|l2tpv2|"
802 "none|level-default|level-outer|level-inner|<flowtype_id>)\n"
803 " Set the RSS mode.\n\n"
805 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
806 " Set the RSS redirection table.\n\n"
808 "port config (port_id) dcb vt (on|off) (traffic_class)"
810 " Set the DCB mode.\n\n"
812 "port config all burst (value)\n"
813 " Set the number of packets per burst.\n\n"
815 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
817 " Set the ring prefetch/host/writeback threshold"
818 " for tx/rx queue.\n\n"
820 "port config all (txfreet|txrst|rxfreet) (value)\n"
821 " Set free threshold for rx/tx, or set"
822 " tx rs bit threshold.\n\n"
823 "port config mtu X value\n"
824 " Set the MTU of port X to a given value\n\n"
826 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
827 " Set a rx/tx queue's ring size configuration, the new"
828 " value will take effect after command that (re-)start the port"
829 " or command that setup the specific queue\n\n"
831 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
832 " Start/stop a rx/tx queue of port X. Only take effect"
833 " when port X is started\n\n"
835 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
836 " Switch on/off a deferred start of port X rx/tx queue. Only"
837 " take effect when port X is stopped.\n\n"
839 "port (port_id) (rxq|txq) (queue_id) setup\n"
840 " Setup a rx/tx queue of port X.\n\n"
842 "port config (port_id) pctype mapping reset\n"
843 " Reset flow type to pctype mapping on a port\n\n"
845 "port config (port_id) pctype mapping update"
846 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
847 " Update a flow type to pctype mapping item on a port\n\n"
849 "port config (port_id) pctype (pctype_id) hash_inset|"
850 "fdir_inset|fdir_flx_inset get|set|clear field\n"
852 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
854 "port config (port_id) pctype (pctype_id) hash_inset|"
855 "fdir_inset|fdir_flx_inset clear all"
856 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
858 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
859 " Add/remove UDP tunnel port for tunneling offload\n\n"
861 "port config <port_id> rx_offload vlan_strip|"
862 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
863 "outer_ipv4_cksum|macsec_strip|header_split|"
864 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
865 "buffer_split|timestamp|security|keep_crc on|off\n"
866 " Enable or disable a per port Rx offloading"
867 " on all Rx queues of a port\n\n"
869 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
870 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
871 "outer_ipv4_cksum|macsec_strip|header_split|"
872 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
873 "buffer_split|timestamp|security|keep_crc on|off\n"
874 " Enable or disable a per queue Rx offloading"
875 " only on a specific Rx queue\n\n"
877 "port config (port_id) tx_offload vlan_insert|"
878 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
879 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
880 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
881 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
883 " Enable or disable a per port Tx offloading"
884 " on all Tx queues of a port\n\n"
886 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
887 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
888 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
889 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
890 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
892 " Enable or disable a per queue Tx offloading"
893 " only on a specific Tx queue\n\n"
895 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
896 " Load an eBPF program as a callback"
897 " for particular RX/TX queue\n\n"
899 "bpf-unload rx|tx (port) (queue)\n"
900 " Unload previously loaded eBPF program"
901 " for particular RX/TX queue\n\n"
903 "port config (port_id) tx_metadata (value)\n"
904 " Set Tx metadata value per port. Testpmd will add this value"
905 " to any Tx packet sent from this port\n\n"
907 "port config (port_id) dynf (name) set|clear\n"
908 " Register a dynf and Set/clear this flag on Tx. "
909 "Testpmd will set this value to any Tx packet "
910 "sent from this port\n\n"
912 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
913 " Cleanup txq mbufs for a specific Tx queue\n\n"
917 if (show_all || !strcmp(res->section, "registers")) {
925 "read reg (port_id) (address)\n"
926 " Display value of a port register.\n\n"
928 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
929 " Display a port register bit field.\n\n"
931 "read regbit (port_id) (address) (bit_x)\n"
932 " Display a single port register bit.\n\n"
934 "write reg (port_id) (address) (value)\n"
935 " Set value of a port register.\n\n"
937 "write regfield (port_id) (address) (bit_x) (bit_y)"
939 " Set bit field of a port register.\n\n"
941 "write regbit (port_id) (address) (bit_x) (value)\n"
942 " Set single bit value of a port register.\n\n"
945 if (show_all || !strcmp(res->section, "filters")) {
954 "flow_director_filter (port_id) mode raw (add|del|update)"
955 " flow (flow_id) (drop|fwd) queue (queue_id)"
956 " fd_id (fd_id_value) packet (packet file name)\n"
957 " Add/Del a raw type flow director filter.\n\n"
960 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
961 " src_mask (ipv4_src) (ipv6_src) (src_port)"
962 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
963 " Set flow director IP mask.\n\n"
965 "flow_director_mask (port_id) mode MAC-VLAN"
966 " vlan (vlan_value)\n"
967 " Set flow director MAC-VLAN mask.\n\n"
969 "flow_director_mask (port_id) mode Tunnel"
970 " vlan (vlan_value) mac (mac_value)"
971 " tunnel-type (tunnel_type_value)"
972 " tunnel-id (tunnel_id_value)\n"
973 " Set flow director Tunnel mask.\n\n"
975 "flow_director_flex_payload (port_id)"
976 " (raw|l2|l3|l4) (config)\n"
977 " Configure flex payload selection.\n\n"
979 "flow validate {port_id}"
980 " [group {group_id}] [priority {level}]"
981 " [ingress] [egress]"
982 " pattern {item} [/ {item} [...]] / end"
983 " actions {action} [/ {action} [...]] / end\n"
984 " Check whether a flow rule can be created.\n\n"
986 "flow create {port_id}"
987 " [group {group_id}] [priority {level}]"
988 " [ingress] [egress]"
989 " pattern {item} [/ {item} [...]] / end"
990 " actions {action} [/ {action} [...]] / end\n"
991 " Create a flow rule.\n\n"
993 "flow destroy {port_id} rule {rule_id} [...]\n"
994 " Destroy specific flow rules.\n\n"
996 "flow flush {port_id}\n"
997 " Destroy all flow rules.\n\n"
999 "flow query {port_id} {rule_id} {action}\n"
1000 " Query an existing flow rule.\n\n"
1002 "flow list {port_id} [group {group_id}] [...]\n"
1003 " List existing flow rules sorted by priority,"
1004 " filtered by group identifiers.\n\n"
1006 "flow isolate {port_id} {boolean}\n"
1007 " Restrict ingress traffic to the defined"
1010 "flow aged {port_id} [destroy]\n"
1011 " List and destroy aged flows"
1014 "flow indirect_action {port_id} create"
1015 " [action_id {indirect_action_id}]"
1016 " [ingress] [egress]"
1017 " action {action} / end\n"
1018 " Create indirect action.\n\n"
1020 "flow indirect_action {port_id} update"
1021 " {indirect_action_id} action {action} / end\n"
1022 " Update indirect action.\n\n"
1024 "flow indirect_action {port_id} destroy"
1025 " action_id {indirect_action_id} [...]\n"
1026 " Destroy specific indirect actions.\n\n"
1028 "flow indirect_action {port_id} query"
1029 " {indirect_action_id}\n"
1030 " Query an existing indirect action.\n\n"
1032 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1033 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1034 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1035 " Configure the VXLAN encapsulation for flows.\n\n"
1037 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1038 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1039 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1040 " eth-dst (eth-dst)\n"
1041 " Configure the VXLAN encapsulation for flows.\n\n"
1043 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1044 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1045 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1046 " eth-dst (eth-dst)\n"
1047 " Configure the VXLAN encapsulation for flows.\n\n"
1049 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1050 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1052 " Configure the NVGRE encapsulation for flows.\n\n"
1054 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1055 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1056 " eth-src (eth-src) eth-dst (eth-dst)\n"
1057 " Configure the NVGRE encapsulation for flows.\n\n"
1059 "set raw_encap {flow items}\n"
1060 " Configure the encapsulation with raw data.\n\n"
1062 "set raw_decap {flow items}\n"
1063 " Configure the decapsulation with raw data.\n\n"
1068 if (show_all || !strcmp(res->section, "traffic_management")) {
1072 "Traffic Management:\n"
1074 "show port tm cap (port_id)\n"
1075 " Display the port TM capability.\n\n"
1077 "show port tm level cap (port_id) (level_id)\n"
1078 " Display the port TM hierarchical level capability.\n\n"
1080 "show port tm node cap (port_id) (node_id)\n"
1081 " Display the port TM node capability.\n\n"
1083 "show port tm node type (port_id) (node_id)\n"
1084 " Display the port TM node type.\n\n"
1086 "show port tm node stats (port_id) (node_id) (clear)\n"
1087 " Display the port TM node stats.\n\n"
1089 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1090 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1091 " (packet_length_adjust) (packet_mode)\n"
1092 " Add port tm node private shaper profile.\n\n"
1094 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1095 " Delete port tm node private shaper profile.\n\n"
1097 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1098 " (shaper_profile_id)\n"
1099 " Add/update port tm node shared shaper.\n\n"
1101 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1102 " Delete port tm node shared shaper.\n\n"
1104 "set port tm node shaper profile (port_id) (node_id)"
1105 " (shaper_profile_id)\n"
1106 " Set port tm node shaper profile.\n\n"
1108 "add port tm node wred profile (port_id) (wred_profile_id)"
1109 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1110 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1111 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1112 " Add port tm node wred profile.\n\n"
1114 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1115 " Delete port tm node wred profile.\n\n"
1117 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1118 " (priority) (weight) (level_id) (shaper_profile_id)"
1119 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1120 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1121 " Add port tm nonleaf node.\n\n"
1123 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1124 " (priority) (weight) (level_id) (shaper_profile_id)"
1125 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1126 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1127 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1129 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1130 " (priority) (weight) (level_id) (shaper_profile_id)"
1131 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1132 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1133 " Add port tm leaf node.\n\n"
1135 "del port tm node (port_id) (node_id)\n"
1136 " Delete port tm node.\n\n"
1138 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1139 " (priority) (weight)\n"
1140 " Set port tm node parent.\n\n"
1142 "suspend port tm node (port_id) (node_id)"
1143 " Suspend tm node.\n\n"
1145 "resume port tm node (port_id) (node_id)"
1146 " Resume tm node.\n\n"
1148 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1149 " Commit tm hierarchy.\n\n"
1151 "set port tm mark ip_ecn (port) (green) (yellow)"
1153 " Enables/Disables the traffic management marking"
1154 " for IP ECN (Explicit Congestion Notification)"
1155 " packets on a given port\n\n"
1157 "set port tm mark ip_dscp (port) (green) (yellow)"
1159 " Enables/Disables the traffic management marking"
1160 " on the port for IP dscp packets\n\n"
1162 "set port tm mark vlan_dei (port) (green) (yellow)"
1164 " Enables/Disables the traffic management marking"
1165 " on the port for VLAN packets with DEI enabled\n\n"
1169 if (show_all || !strcmp(res->section, "devices")) {
1173 "Device Operations:\n"
1175 "device detach (identifier)\n"
1176 " Detach device by identifier.\n\n"
1182 cmdline_parse_token_string_t cmd_help_long_help =
1183 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1185 cmdline_parse_token_string_t cmd_help_long_section =
1186 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1187 "all#control#display#config#"
1188 "ports#registers#filters#traffic_management#devices");
1190 cmdline_parse_inst_t cmd_help_long = {
1191 .f = cmd_help_long_parsed,
1193 .help_str = "help all|control|display|config|ports|register|"
1194 "filters|traffic_management|devices: "
1197 (void *)&cmd_help_long_help,
1198 (void *)&cmd_help_long_section,
1204 /* *** start/stop/close all ports *** */
1205 struct cmd_operate_port_result {
1206 cmdline_fixed_string_t keyword;
1207 cmdline_fixed_string_t name;
1208 cmdline_fixed_string_t value;
1211 static void cmd_operate_port_parsed(void *parsed_result,
1212 __rte_unused struct cmdline *cl,
1213 __rte_unused void *data)
1215 struct cmd_operate_port_result *res = parsed_result;
1217 if (!strcmp(res->name, "start"))
1218 start_port(RTE_PORT_ALL);
1219 else if (!strcmp(res->name, "stop"))
1220 stop_port(RTE_PORT_ALL);
1221 else if (!strcmp(res->name, "close"))
1222 close_port(RTE_PORT_ALL);
1223 else if (!strcmp(res->name, "reset"))
1224 reset_port(RTE_PORT_ALL);
1226 fprintf(stderr, "Unknown parameter\n");
1229 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1230 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1232 cmdline_parse_token_string_t cmd_operate_port_all_port =
1233 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1234 "start#stop#close#reset");
1235 cmdline_parse_token_string_t cmd_operate_port_all_all =
1236 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1238 cmdline_parse_inst_t cmd_operate_port = {
1239 .f = cmd_operate_port_parsed,
1241 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1243 (void *)&cmd_operate_port_all_cmd,
1244 (void *)&cmd_operate_port_all_port,
1245 (void *)&cmd_operate_port_all_all,
1250 /* *** start/stop/close specific port *** */
1251 struct cmd_operate_specific_port_result {
1252 cmdline_fixed_string_t keyword;
1253 cmdline_fixed_string_t name;
1257 static void cmd_operate_specific_port_parsed(void *parsed_result,
1258 __rte_unused struct cmdline *cl,
1259 __rte_unused void *data)
1261 struct cmd_operate_specific_port_result *res = parsed_result;
1263 if (!strcmp(res->name, "start"))
1264 start_port(res->value);
1265 else if (!strcmp(res->name, "stop"))
1266 stop_port(res->value);
1267 else if (!strcmp(res->name, "close"))
1268 close_port(res->value);
1269 else if (!strcmp(res->name, "reset"))
1270 reset_port(res->value);
1272 fprintf(stderr, "Unknown parameter\n");
1275 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1278 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1280 name, "start#stop#close#reset");
1281 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1282 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1285 cmdline_parse_inst_t cmd_operate_specific_port = {
1286 .f = cmd_operate_specific_port_parsed,
1288 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1290 (void *)&cmd_operate_specific_port_cmd,
1291 (void *)&cmd_operate_specific_port_port,
1292 (void *)&cmd_operate_specific_port_id,
1297 /* *** enable port setup (after attach) via iterator or event *** */
1298 struct cmd_set_port_setup_on_result {
1299 cmdline_fixed_string_t set;
1300 cmdline_fixed_string_t port;
1301 cmdline_fixed_string_t setup;
1302 cmdline_fixed_string_t on;
1303 cmdline_fixed_string_t mode;
1306 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1307 __rte_unused struct cmdline *cl,
1308 __rte_unused void *data)
1310 struct cmd_set_port_setup_on_result *res = parsed_result;
1312 if (strcmp(res->mode, "event") == 0)
1313 setup_on_probe_event = true;
1314 else if (strcmp(res->mode, "iterator") == 0)
1315 setup_on_probe_event = false;
1317 fprintf(stderr, "Unknown mode\n");
1320 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1321 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1323 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1324 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1326 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1327 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1329 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1330 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1332 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1333 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1334 mode, "iterator#event");
1336 cmdline_parse_inst_t cmd_set_port_setup_on = {
1337 .f = cmd_set_port_setup_on_parsed,
1339 .help_str = "set port setup on iterator|event",
1341 (void *)&cmd_set_port_setup_on_set,
1342 (void *)&cmd_set_port_setup_on_port,
1343 (void *)&cmd_set_port_setup_on_setup,
1344 (void *)&cmd_set_port_setup_on_on,
1345 (void *)&cmd_set_port_setup_on_mode,
1350 /* *** attach a specified port *** */
1351 struct cmd_operate_attach_port_result {
1352 cmdline_fixed_string_t port;
1353 cmdline_fixed_string_t keyword;
1354 cmdline_multi_string_t identifier;
1357 static void cmd_operate_attach_port_parsed(void *parsed_result,
1358 __rte_unused struct cmdline *cl,
1359 __rte_unused void *data)
1361 struct cmd_operate_attach_port_result *res = parsed_result;
1363 if (!strcmp(res->keyword, "attach"))
1364 attach_port(res->identifier);
1366 fprintf(stderr, "Unknown parameter\n");
1369 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1370 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1372 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1373 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1375 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1376 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1377 identifier, TOKEN_STRING_MULTI);
1379 cmdline_parse_inst_t cmd_operate_attach_port = {
1380 .f = cmd_operate_attach_port_parsed,
1382 .help_str = "port attach <identifier>: "
1383 "(identifier: pci address or virtual dev name)",
1385 (void *)&cmd_operate_attach_port_port,
1386 (void *)&cmd_operate_attach_port_keyword,
1387 (void *)&cmd_operate_attach_port_identifier,
1392 /* *** detach a specified port *** */
1393 struct cmd_operate_detach_port_result {
1394 cmdline_fixed_string_t port;
1395 cmdline_fixed_string_t keyword;
1399 static void cmd_operate_detach_port_parsed(void *parsed_result,
1400 __rte_unused struct cmdline *cl,
1401 __rte_unused void *data)
1403 struct cmd_operate_detach_port_result *res = parsed_result;
1405 if (!strcmp(res->keyword, "detach")) {
1406 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1407 detach_port_device(res->port_id);
1409 fprintf(stderr, "Unknown parameter\n");
1413 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1414 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1416 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1417 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1419 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1420 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1421 port_id, RTE_UINT16);
1423 cmdline_parse_inst_t cmd_operate_detach_port = {
1424 .f = cmd_operate_detach_port_parsed,
1426 .help_str = "port detach <port_id>",
1428 (void *)&cmd_operate_detach_port_port,
1429 (void *)&cmd_operate_detach_port_keyword,
1430 (void *)&cmd_operate_detach_port_port_id,
1435 /* *** detach device by identifier *** */
1436 struct cmd_operate_detach_device_result {
1437 cmdline_fixed_string_t device;
1438 cmdline_fixed_string_t keyword;
1439 cmdline_fixed_string_t identifier;
1442 static void cmd_operate_detach_device_parsed(void *parsed_result,
1443 __rte_unused struct cmdline *cl,
1444 __rte_unused void *data)
1446 struct cmd_operate_detach_device_result *res = parsed_result;
1448 if (!strcmp(res->keyword, "detach"))
1449 detach_devargs(res->identifier);
1451 fprintf(stderr, "Unknown parameter\n");
1454 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1457 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1460 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1461 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1464 cmdline_parse_inst_t cmd_operate_detach_device = {
1465 .f = cmd_operate_detach_device_parsed,
1467 .help_str = "device detach <identifier>:"
1468 "(identifier: pci address or virtual dev name)",
1470 (void *)&cmd_operate_detach_device_device,
1471 (void *)&cmd_operate_detach_device_keyword,
1472 (void *)&cmd_operate_detach_device_identifier,
1476 /* *** configure speed for all ports *** */
1477 struct cmd_config_speed_all {
1478 cmdline_fixed_string_t port;
1479 cmdline_fixed_string_t keyword;
1480 cmdline_fixed_string_t all;
1481 cmdline_fixed_string_t item1;
1482 cmdline_fixed_string_t item2;
1483 cmdline_fixed_string_t value1;
1484 cmdline_fixed_string_t value2;
1488 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1493 if (!strcmp(duplexstr, "half")) {
1494 duplex = RTE_ETH_LINK_HALF_DUPLEX;
1495 } else if (!strcmp(duplexstr, "full")) {
1496 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1497 } else if (!strcmp(duplexstr, "auto")) {
1498 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1500 fprintf(stderr, "Unknown duplex parameter\n");
1504 if (!strcmp(speedstr, "10")) {
1505 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1506 RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1507 } else if (!strcmp(speedstr, "100")) {
1508 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1509 RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1511 if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1512 fprintf(stderr, "Invalid speed/duplex parameters\n");
1515 if (!strcmp(speedstr, "1000")) {
1516 *speed = RTE_ETH_LINK_SPEED_1G;
1517 } else if (!strcmp(speedstr, "10000")) {
1518 *speed = RTE_ETH_LINK_SPEED_10G;
1519 } else if (!strcmp(speedstr, "25000")) {
1520 *speed = RTE_ETH_LINK_SPEED_25G;
1521 } else if (!strcmp(speedstr, "40000")) {
1522 *speed = RTE_ETH_LINK_SPEED_40G;
1523 } else if (!strcmp(speedstr, "50000")) {
1524 *speed = RTE_ETH_LINK_SPEED_50G;
1525 } else if (!strcmp(speedstr, "100000")) {
1526 *speed = RTE_ETH_LINK_SPEED_100G;
1527 } else if (!strcmp(speedstr, "200000")) {
1528 *speed = RTE_ETH_LINK_SPEED_200G;
1529 } else if (!strcmp(speedstr, "auto")) {
1530 *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1532 fprintf(stderr, "Unknown speed parameter\n");
1537 if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1538 *speed |= RTE_ETH_LINK_SPEED_FIXED;
1544 cmd_config_speed_all_parsed(void *parsed_result,
1545 __rte_unused struct cmdline *cl,
1546 __rte_unused void *data)
1548 struct cmd_config_speed_all *res = parsed_result;
1549 uint32_t link_speed;
1552 if (!all_ports_stopped()) {
1553 fprintf(stderr, "Please stop all ports first\n");
1557 if (parse_and_check_speed_duplex(res->value1, res->value2,
1561 RTE_ETH_FOREACH_DEV(pid) {
1562 ports[pid].dev_conf.link_speeds = link_speed;
1565 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1568 cmdline_parse_token_string_t cmd_config_speed_all_port =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1570 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1573 cmdline_parse_token_string_t cmd_config_speed_all_all =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1575 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1576 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1577 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1579 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1580 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1582 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1586 cmdline_parse_inst_t cmd_config_speed_all = {
1587 .f = cmd_config_speed_all_parsed,
1589 .help_str = "port config all speed "
1590 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1593 (void *)&cmd_config_speed_all_port,
1594 (void *)&cmd_config_speed_all_keyword,
1595 (void *)&cmd_config_speed_all_all,
1596 (void *)&cmd_config_speed_all_item1,
1597 (void *)&cmd_config_speed_all_value1,
1598 (void *)&cmd_config_speed_all_item2,
1599 (void *)&cmd_config_speed_all_value2,
1604 /* *** configure speed for specific port *** */
1605 struct cmd_config_speed_specific {
1606 cmdline_fixed_string_t port;
1607 cmdline_fixed_string_t keyword;
1609 cmdline_fixed_string_t item1;
1610 cmdline_fixed_string_t item2;
1611 cmdline_fixed_string_t value1;
1612 cmdline_fixed_string_t value2;
1616 cmd_config_speed_specific_parsed(void *parsed_result,
1617 __rte_unused struct cmdline *cl,
1618 __rte_unused void *data)
1620 struct cmd_config_speed_specific *res = parsed_result;
1621 uint32_t link_speed;
1623 if (port_id_is_invalid(res->id, ENABLED_WARN))
1626 if (!port_is_stopped(res->id)) {
1627 fprintf(stderr, "Please stop port %d first\n", res->id);
1631 if (parse_and_check_speed_duplex(res->value1, res->value2,
1635 ports[res->id].dev_conf.link_speeds = link_speed;
1637 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1641 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1644 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1647 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1648 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1649 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1652 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1654 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1655 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1658 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1662 cmdline_parse_inst_t cmd_config_speed_specific = {
1663 .f = cmd_config_speed_specific_parsed,
1665 .help_str = "port config <port_id> speed "
1666 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1669 (void *)&cmd_config_speed_specific_port,
1670 (void *)&cmd_config_speed_specific_keyword,
1671 (void *)&cmd_config_speed_specific_id,
1672 (void *)&cmd_config_speed_specific_item1,
1673 (void *)&cmd_config_speed_specific_value1,
1674 (void *)&cmd_config_speed_specific_item2,
1675 (void *)&cmd_config_speed_specific_value2,
1680 /* *** configure loopback for all ports *** */
1681 struct cmd_config_loopback_all {
1682 cmdline_fixed_string_t port;
1683 cmdline_fixed_string_t keyword;
1684 cmdline_fixed_string_t all;
1685 cmdline_fixed_string_t item;
1690 cmd_config_loopback_all_parsed(void *parsed_result,
1691 __rte_unused struct cmdline *cl,
1692 __rte_unused void *data)
1694 struct cmd_config_loopback_all *res = parsed_result;
1697 if (!all_ports_stopped()) {
1698 fprintf(stderr, "Please stop all ports first\n");
1702 RTE_ETH_FOREACH_DEV(pid) {
1703 ports[pid].dev_conf.lpbk_mode = res->mode;
1706 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1709 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1711 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1714 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1716 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1719 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1720 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1722 cmdline_parse_inst_t cmd_config_loopback_all = {
1723 .f = cmd_config_loopback_all_parsed,
1725 .help_str = "port config all loopback <mode>",
1727 (void *)&cmd_config_loopback_all_port,
1728 (void *)&cmd_config_loopback_all_keyword,
1729 (void *)&cmd_config_loopback_all_all,
1730 (void *)&cmd_config_loopback_all_item,
1731 (void *)&cmd_config_loopback_all_mode,
1736 /* *** configure loopback for specific port *** */
1737 struct cmd_config_loopback_specific {
1738 cmdline_fixed_string_t port;
1739 cmdline_fixed_string_t keyword;
1741 cmdline_fixed_string_t item;
1746 cmd_config_loopback_specific_parsed(void *parsed_result,
1747 __rte_unused struct cmdline *cl,
1748 __rte_unused void *data)
1750 struct cmd_config_loopback_specific *res = parsed_result;
1752 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1755 if (!port_is_stopped(res->port_id)) {
1756 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1760 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1762 cmd_reconfig_device_queue(res->port_id, 1, 1);
1766 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1767 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1769 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1772 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1773 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1775 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1778 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1779 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1782 cmdline_parse_inst_t cmd_config_loopback_specific = {
1783 .f = cmd_config_loopback_specific_parsed,
1785 .help_str = "port config <port_id> loopback <mode>",
1787 (void *)&cmd_config_loopback_specific_port,
1788 (void *)&cmd_config_loopback_specific_keyword,
1789 (void *)&cmd_config_loopback_specific_id,
1790 (void *)&cmd_config_loopback_specific_item,
1791 (void *)&cmd_config_loopback_specific_mode,
1796 /* *** configure txq/rxq, txd/rxd *** */
1797 struct cmd_config_rx_tx {
1798 cmdline_fixed_string_t port;
1799 cmdline_fixed_string_t keyword;
1800 cmdline_fixed_string_t all;
1801 cmdline_fixed_string_t name;
1806 cmd_config_rx_tx_parsed(void *parsed_result,
1807 __rte_unused struct cmdline *cl,
1808 __rte_unused void *data)
1810 struct cmd_config_rx_tx *res = parsed_result;
1812 if (!all_ports_stopped()) {
1813 fprintf(stderr, "Please stop all ports first\n");
1816 if (!strcmp(res->name, "rxq")) {
1817 if (!res->value && !nb_txq) {
1818 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1821 if (check_nb_rxq(res->value) != 0)
1823 nb_rxq = res->value;
1825 else if (!strcmp(res->name, "txq")) {
1826 if (!res->value && !nb_rxq) {
1827 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1830 if (check_nb_txq(res->value) != 0)
1832 nb_txq = res->value;
1834 else if (!strcmp(res->name, "rxd")) {
1835 if (check_nb_rxd(res->value) != 0)
1837 nb_rxd = res->value;
1838 } else if (!strcmp(res->name, "txd")) {
1839 if (check_nb_txd(res->value) != 0)
1842 nb_txd = res->value;
1844 fprintf(stderr, "Unknown parameter\n");
1852 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1855 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1856 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1857 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1859 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1861 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1864 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1865 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1867 cmdline_parse_inst_t cmd_config_rx_tx = {
1868 .f = cmd_config_rx_tx_parsed,
1870 .help_str = "port config all rxq|txq|rxd|txd <value>",
1872 (void *)&cmd_config_rx_tx_port,
1873 (void *)&cmd_config_rx_tx_keyword,
1874 (void *)&cmd_config_rx_tx_all,
1875 (void *)&cmd_config_rx_tx_name,
1876 (void *)&cmd_config_rx_tx_value,
1881 /* *** config max packet length *** */
1882 struct cmd_config_max_pkt_len_result {
1883 cmdline_fixed_string_t port;
1884 cmdline_fixed_string_t keyword;
1885 cmdline_fixed_string_t all;
1886 cmdline_fixed_string_t name;
1891 cmd_config_max_pkt_len_parsed(void *parsed_result,
1892 __rte_unused struct cmdline *cl,
1893 __rte_unused void *data)
1895 struct cmd_config_max_pkt_len_result *res = parsed_result;
1899 if (strcmp(res->name, "max-pkt-len") != 0) {
1900 printf("Unknown parameter\n");
1904 if (!all_ports_stopped()) {
1905 fprintf(stderr, "Please stop all ports first\n");
1909 RTE_ETH_FOREACH_DEV(port_id) {
1910 struct rte_port *port = &ports[port_id];
1912 if (res->value < RTE_ETHER_MIN_LEN) {
1914 "max-pkt-len can not be less than %d\n",
1919 ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1922 "rte_eth_dev_info_get() failed for port %u\n",
1927 update_mtu_from_frame_size(port_id, res->value);
1932 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1935 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1938 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1941 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1944 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1947 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1948 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1951 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1952 .f = cmd_config_max_pkt_len_parsed,
1954 .help_str = "port config all max-pkt-len <value>",
1956 (void *)&cmd_config_max_pkt_len_port,
1957 (void *)&cmd_config_max_pkt_len_keyword,
1958 (void *)&cmd_config_max_pkt_len_all,
1959 (void *)&cmd_config_max_pkt_len_name,
1960 (void *)&cmd_config_max_pkt_len_value,
1965 /* *** config max LRO aggregated packet size *** */
1966 struct cmd_config_max_lro_pkt_size_result {
1967 cmdline_fixed_string_t port;
1968 cmdline_fixed_string_t keyword;
1969 cmdline_fixed_string_t all;
1970 cmdline_fixed_string_t name;
1975 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1976 __rte_unused struct cmdline *cl,
1977 __rte_unused void *data)
1979 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1982 if (!all_ports_stopped()) {
1983 fprintf(stderr, "Please stop all ports first\n");
1987 RTE_ETH_FOREACH_DEV(pid) {
1988 struct rte_port *port = &ports[pid];
1990 if (!strcmp(res->name, "max-lro-pkt-size")) {
1992 port->dev_conf.rxmode.max_lro_pkt_size)
1995 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1997 fprintf(stderr, "Unknown parameter\n");
2004 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2007 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2010 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2011 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2013 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2016 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2018 name, "max-lro-pkt-size");
2019 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2020 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2023 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2024 .f = cmd_config_max_lro_pkt_size_parsed,
2026 .help_str = "port config all max-lro-pkt-size <value>",
2028 (void *)&cmd_config_max_lro_pkt_size_port,
2029 (void *)&cmd_config_max_lro_pkt_size_keyword,
2030 (void *)&cmd_config_max_lro_pkt_size_all,
2031 (void *)&cmd_config_max_lro_pkt_size_name,
2032 (void *)&cmd_config_max_lro_pkt_size_value,
2037 /* *** configure port MTU *** */
2038 struct cmd_config_mtu_result {
2039 cmdline_fixed_string_t port;
2040 cmdline_fixed_string_t keyword;
2041 cmdline_fixed_string_t mtu;
2047 cmd_config_mtu_parsed(void *parsed_result,
2048 __rte_unused struct cmdline *cl,
2049 __rte_unused void *data)
2051 struct cmd_config_mtu_result *res = parsed_result;
2053 port_mtu_set(res->port_id, res->value);
2056 cmdline_parse_token_string_t cmd_config_mtu_port =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2059 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2060 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2062 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2063 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2065 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2066 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2068 cmdline_parse_token_num_t cmd_config_mtu_value =
2069 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2072 cmdline_parse_inst_t cmd_config_mtu = {
2073 .f = cmd_config_mtu_parsed,
2075 .help_str = "port config mtu <port_id> <value>",
2077 (void *)&cmd_config_mtu_port,
2078 (void *)&cmd_config_mtu_keyword,
2079 (void *)&cmd_config_mtu_mtu,
2080 (void *)&cmd_config_mtu_port_id,
2081 (void *)&cmd_config_mtu_value,
2086 /* *** configure rx mode *** */
2087 struct cmd_config_rx_mode_flag {
2088 cmdline_fixed_string_t port;
2089 cmdline_fixed_string_t keyword;
2090 cmdline_fixed_string_t all;
2091 cmdline_fixed_string_t name;
2092 cmdline_fixed_string_t value;
2096 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2097 __rte_unused struct cmdline *cl,
2098 __rte_unused void *data)
2100 struct cmd_config_rx_mode_flag *res = parsed_result;
2102 if (!all_ports_stopped()) {
2103 fprintf(stderr, "Please stop all ports first\n");
2107 if (!strcmp(res->name, "drop-en")) {
2108 if (!strcmp(res->value, "on"))
2110 else if (!strcmp(res->value, "off"))
2113 fprintf(stderr, "Unknown parameter\n");
2117 fprintf(stderr, "Unknown parameter\n");
2123 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2126 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2127 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2128 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2129 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2131 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2133 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2134 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2140 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2141 .f = cmd_config_rx_mode_flag_parsed,
2143 .help_str = "port config all drop-en on|off",
2145 (void *)&cmd_config_rx_mode_flag_port,
2146 (void *)&cmd_config_rx_mode_flag_keyword,
2147 (void *)&cmd_config_rx_mode_flag_all,
2148 (void *)&cmd_config_rx_mode_flag_name,
2149 (void *)&cmd_config_rx_mode_flag_value,
2154 /* *** configure rss *** */
2155 struct cmd_config_rss {
2156 cmdline_fixed_string_t port;
2157 cmdline_fixed_string_t keyword;
2158 cmdline_fixed_string_t all;
2159 cmdline_fixed_string_t name;
2160 cmdline_fixed_string_t value;
2164 cmd_config_rss_parsed(void *parsed_result,
2165 __rte_unused struct cmdline *cl,
2166 __rte_unused void *data)
2168 struct cmd_config_rss *res = parsed_result;
2169 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2170 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2171 int use_default = 0;
2172 int all_updated = 1;
2177 if (!strcmp(res->value, "all"))
2178 rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2179 RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2180 RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2181 RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2182 RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_L2TPV2;
2183 else if (!strcmp(res->value, "eth"))
2184 rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2185 else if (!strcmp(res->value, "vlan"))
2186 rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2187 else if (!strcmp(res->value, "ip"))
2188 rss_conf.rss_hf = RTE_ETH_RSS_IP;
2189 else if (!strcmp(res->value, "udp"))
2190 rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2191 else if (!strcmp(res->value, "tcp"))
2192 rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2193 else if (!strcmp(res->value, "sctp"))
2194 rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2195 else if (!strcmp(res->value, "ether"))
2196 rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2197 else if (!strcmp(res->value, "port"))
2198 rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2199 else if (!strcmp(res->value, "vxlan"))
2200 rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2201 else if (!strcmp(res->value, "geneve"))
2202 rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2203 else if (!strcmp(res->value, "nvgre"))
2204 rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2205 else if (!strcmp(res->value, "l3-pre32"))
2206 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2207 else if (!strcmp(res->value, "l3-pre40"))
2208 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2209 else if (!strcmp(res->value, "l3-pre48"))
2210 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2211 else if (!strcmp(res->value, "l3-pre56"))
2212 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2213 else if (!strcmp(res->value, "l3-pre64"))
2214 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2215 else if (!strcmp(res->value, "l3-pre96"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2217 else if (!strcmp(res->value, "l3-src-only"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2219 else if (!strcmp(res->value, "l3-dst-only"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2221 else if (!strcmp(res->value, "l4-src-only"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2223 else if (!strcmp(res->value, "l4-dst-only"))
2224 rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2225 else if (!strcmp(res->value, "l2-src-only"))
2226 rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2227 else if (!strcmp(res->value, "l2-dst-only"))
2228 rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2229 else if (!strcmp(res->value, "l2tpv3"))
2230 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2231 else if (!strcmp(res->value, "esp"))
2232 rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2233 else if (!strcmp(res->value, "ah"))
2234 rss_conf.rss_hf = RTE_ETH_RSS_AH;
2235 else if (!strcmp(res->value, "pfcp"))
2236 rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2237 else if (!strcmp(res->value, "pppoe"))
2238 rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2239 else if (!strcmp(res->value, "gtpu"))
2240 rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2241 else if (!strcmp(res->value, "ecpri"))
2242 rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2243 else if (!strcmp(res->value, "mpls"))
2244 rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2245 else if (!strcmp(res->value, "ipv4-chksum"))
2246 rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2247 else if (!strcmp(res->value, "l2tpv2"))
2248 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV2;
2249 else if (!strcmp(res->value, "none"))
2250 rss_conf.rss_hf = 0;
2251 else if (!strcmp(res->value, "level-default")) {
2252 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2253 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2254 } else if (!strcmp(res->value, "level-outer")) {
2255 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2256 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2257 } else if (!strcmp(res->value, "level-inner")) {
2258 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2259 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2260 } else if (!strcmp(res->value, "default"))
2262 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2263 atoi(res->value) < 64)
2264 rss_conf.rss_hf = 1ULL << atoi(res->value);
2266 fprintf(stderr, "Unknown parameter\n");
2269 rss_conf.rss_key = NULL;
2270 /* Update global configuration for RSS types. */
2271 RTE_ETH_FOREACH_DEV(i) {
2272 struct rte_eth_rss_conf local_rss_conf;
2274 ret = eth_dev_info_get_print_err(i, &dev_info);
2279 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2281 local_rss_conf = rss_conf;
2282 local_rss_conf.rss_hf = rss_conf.rss_hf &
2283 dev_info.flow_type_rss_offloads;
2284 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2285 printf("Port %u modified RSS hash function based on hardware support,"
2286 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2287 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2289 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2293 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2294 i, -diag, strerror(-diag));
2297 if (all_updated && !use_default) {
2298 rss_hf = rss_conf.rss_hf;
2299 printf("rss_hf %#"PRIx64"\n", rss_hf);
2303 cmdline_parse_token_string_t cmd_config_rss_port =
2304 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2305 cmdline_parse_token_string_t cmd_config_rss_keyword =
2306 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2307 cmdline_parse_token_string_t cmd_config_rss_all =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2309 cmdline_parse_token_string_t cmd_config_rss_name =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2311 cmdline_parse_token_string_t cmd_config_rss_value =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2314 cmdline_parse_inst_t cmd_config_rss = {
2315 .f = cmd_config_rss_parsed,
2317 .help_str = "port config all rss "
2318 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2319 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|l2tpv2|"
2320 "none|level-default|level-outer|level-inner|<flowtype_id>",
2322 (void *)&cmd_config_rss_port,
2323 (void *)&cmd_config_rss_keyword,
2324 (void *)&cmd_config_rss_all,
2325 (void *)&cmd_config_rss_name,
2326 (void *)&cmd_config_rss_value,
2331 /* *** configure rss hash key *** */
2332 struct cmd_config_rss_hash_key {
2333 cmdline_fixed_string_t port;
2334 cmdline_fixed_string_t config;
2336 cmdline_fixed_string_t rss_hash_key;
2337 cmdline_fixed_string_t rss_type;
2338 cmdline_fixed_string_t key;
2342 hexa_digit_to_value(char hexa_digit)
2344 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2345 return (uint8_t) (hexa_digit - '0');
2346 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2347 return (uint8_t) ((hexa_digit - 'a') + 10);
2348 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2349 return (uint8_t) ((hexa_digit - 'A') + 10);
2350 /* Invalid hexa digit */
2355 parse_and_check_key_hexa_digit(char *key, int idx)
2359 hexa_v = hexa_digit_to_value(key[idx]);
2362 "invalid key: character %c at position %d is not a valid hexa digit\n",
2368 cmd_config_rss_hash_key_parsed(void *parsed_result,
2369 __rte_unused struct cmdline *cl,
2370 __rte_unused void *data)
2372 struct cmd_config_rss_hash_key *res = parsed_result;
2373 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2377 struct rte_eth_dev_info dev_info;
2378 uint8_t hash_key_size;
2382 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2386 if (dev_info.hash_key_size > 0 &&
2387 dev_info.hash_key_size <= sizeof(hash_key))
2388 hash_key_size = dev_info.hash_key_size;
2391 "dev_info did not provide a valid hash key size\n");
2394 /* Check the length of the RSS hash key */
2395 key_len = strlen(res->key);
2396 if (key_len != (hash_key_size * 2)) {
2398 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2399 (int)key_len, hash_key_size * 2);
2402 /* Translate RSS hash key into binary representation */
2403 for (i = 0; i < hash_key_size; i++) {
2404 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2407 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2410 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2412 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2416 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2417 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2418 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2421 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2422 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2425 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2426 rss_hash_key, "rss-hash-key");
2427 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2428 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2429 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2430 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2431 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2432 "ipv6-tcp-ex#ipv6-udp-ex#"
2433 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2434 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2435 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2436 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2437 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2439 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2440 .f = cmd_config_rss_hash_key_parsed,
2442 .help_str = "port config <port_id> rss-hash-key "
2443 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2444 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2445 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2446 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2447 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2448 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2449 "<string of hex digits (variable length, NIC dependent)>",
2451 (void *)&cmd_config_rss_hash_key_port,
2452 (void *)&cmd_config_rss_hash_key_config,
2453 (void *)&cmd_config_rss_hash_key_port_id,
2454 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2455 (void *)&cmd_config_rss_hash_key_rss_type,
2456 (void *)&cmd_config_rss_hash_key_value,
2461 /* *** cleanup txq mbufs *** */
2462 struct cmd_cleanup_txq_mbufs_result {
2463 cmdline_fixed_string_t port;
2464 cmdline_fixed_string_t keyword;
2465 cmdline_fixed_string_t name;
2472 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2473 __rte_unused struct cmdline *cl,
2474 __rte_unused void *data)
2476 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2477 uint16_t port_id = res->port_id;
2478 uint16_t queue_id = res->queue_id;
2479 uint32_t free_cnt = res->free_cnt;
2480 struct rte_eth_txq_info qinfo;
2483 if (test_done == 0) {
2484 fprintf(stderr, "Please stop forwarding first\n");
2488 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2489 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2494 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2495 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2499 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2502 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2503 port_id, queue_id, strerror(-ret), ret);
2507 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2508 port_id, queue_id, ret);
2511 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2512 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2514 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2515 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2517 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2518 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2520 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2521 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2523 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2524 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2526 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2527 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2530 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2531 .f = cmd_cleanup_txq_mbufs_parsed,
2533 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2535 (void *)&cmd_cleanup_txq_mbufs_port,
2536 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2537 (void *)&cmd_cleanup_txq_mbufs_port_id,
2538 (void *)&cmd_cleanup_txq_mbufs_txq,
2539 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2540 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2545 /* *** configure port rxq/txq ring size *** */
2546 struct cmd_config_rxtx_ring_size {
2547 cmdline_fixed_string_t port;
2548 cmdline_fixed_string_t config;
2550 cmdline_fixed_string_t rxtxq;
2552 cmdline_fixed_string_t rsize;
2557 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2558 __rte_unused struct cmdline *cl,
2559 __rte_unused void *data)
2561 struct cmd_config_rxtx_ring_size *res = parsed_result;
2562 struct rte_port *port;
2565 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2568 if (res->portid == (portid_t)RTE_PORT_ALL) {
2569 fprintf(stderr, "Invalid port id\n");
2573 port = &ports[res->portid];
2575 if (!strcmp(res->rxtxq, "rxq"))
2577 else if (!strcmp(res->rxtxq, "txq"))
2580 fprintf(stderr, "Unknown parameter\n");
2584 if (isrx && rx_queue_id_is_invalid(res->qid))
2586 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2589 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2591 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2597 port->nb_rx_desc[res->qid] = res->size;
2599 port->nb_tx_desc[res->qid] = res->size;
2601 cmd_reconfig_device_queue(res->portid, 0, 1);
2604 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2605 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2607 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2608 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2611 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2612 portid, RTE_UINT16);
2613 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2614 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2616 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2617 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2619 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2621 rsize, "ring_size");
2622 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2623 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2626 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2627 .f = cmd_config_rxtx_ring_size_parsed,
2629 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2631 (void *)&cmd_config_rxtx_ring_size_port,
2632 (void *)&cmd_config_rxtx_ring_size_config,
2633 (void *)&cmd_config_rxtx_ring_size_portid,
2634 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2635 (void *)&cmd_config_rxtx_ring_size_qid,
2636 (void *)&cmd_config_rxtx_ring_size_rsize,
2637 (void *)&cmd_config_rxtx_ring_size_size,
2642 /* *** configure port rxq/txq start/stop *** */
2643 struct cmd_config_rxtx_queue {
2644 cmdline_fixed_string_t port;
2646 cmdline_fixed_string_t rxtxq;
2648 cmdline_fixed_string_t opname;
2652 cmd_config_rxtx_queue_parsed(void *parsed_result,
2653 __rte_unused struct cmdline *cl,
2654 __rte_unused void *data)
2656 struct cmd_config_rxtx_queue *res = parsed_result;
2661 if (test_done == 0) {
2662 fprintf(stderr, "Please stop forwarding first\n");
2666 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2669 if (port_is_started(res->portid) != 1) {
2670 fprintf(stderr, "Please start port %u first\n", res->portid);
2674 if (!strcmp(res->rxtxq, "rxq"))
2676 else if (!strcmp(res->rxtxq, "txq"))
2679 fprintf(stderr, "Unknown parameter\n");
2683 if (isrx && rx_queue_id_is_invalid(res->qid))
2685 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2688 if (!strcmp(res->opname, "start"))
2690 else if (!strcmp(res->opname, "stop"))
2693 fprintf(stderr, "Unknown parameter\n");
2697 if (isstart && isrx)
2698 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2699 else if (!isstart && isrx)
2700 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2701 else if (isstart && !isrx)
2702 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2704 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2706 if (ret == -ENOTSUP)
2707 fprintf(stderr, "Function not supported in PMD\n");
2710 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2711 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2712 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2713 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2714 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2715 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2716 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2717 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2718 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2719 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2722 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2723 .f = cmd_config_rxtx_queue_parsed,
2725 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2727 (void *)&cmd_config_rxtx_queue_port,
2728 (void *)&cmd_config_rxtx_queue_portid,
2729 (void *)&cmd_config_rxtx_queue_rxtxq,
2730 (void *)&cmd_config_rxtx_queue_qid,
2731 (void *)&cmd_config_rxtx_queue_opname,
2736 /* *** configure port rxq/txq deferred start on/off *** */
2737 struct cmd_config_deferred_start_rxtx_queue {
2738 cmdline_fixed_string_t port;
2740 cmdline_fixed_string_t rxtxq;
2742 cmdline_fixed_string_t opname;
2743 cmdline_fixed_string_t state;
2747 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2748 __rte_unused struct cmdline *cl,
2749 __rte_unused void *data)
2751 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2752 struct rte_port *port;
2755 uint8_t needreconfig = 0;
2757 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2760 if (port_is_started(res->port_id) != 0) {
2761 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2765 port = &ports[res->port_id];
2767 isrx = !strcmp(res->rxtxq, "rxq");
2769 if (isrx && rx_queue_id_is_invalid(res->qid))
2771 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2774 ison = !strcmp(res->state, "on");
2776 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2777 port->rx_conf[res->qid].rx_deferred_start = ison;
2779 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2780 port->tx_conf[res->qid].tx_deferred_start = ison;
2785 cmd_reconfig_device_queue(res->port_id, 0, 1);
2788 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2789 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2791 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2792 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2793 port_id, RTE_UINT16);
2794 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2795 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2797 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2798 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2800 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2801 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2802 opname, "deferred_start");
2803 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2804 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2807 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2808 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2810 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2812 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2813 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2814 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2815 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2816 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2817 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2822 /* *** configure port rxq/txq setup *** */
2823 struct cmd_setup_rxtx_queue {
2824 cmdline_fixed_string_t port;
2826 cmdline_fixed_string_t rxtxq;
2828 cmdline_fixed_string_t setup;
2831 /* Common CLI fields for queue setup */
2832 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2833 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2834 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2835 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2836 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2837 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2838 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2839 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2840 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2841 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2844 cmd_setup_rxtx_queue_parsed(
2845 void *parsed_result,
2846 __rte_unused struct cmdline *cl,
2847 __rte_unused void *data)
2849 struct cmd_setup_rxtx_queue *res = parsed_result;
2850 struct rte_port *port;
2851 struct rte_mempool *mp;
2852 unsigned int socket_id;
2856 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2859 if (res->portid == (portid_t)RTE_PORT_ALL) {
2860 fprintf(stderr, "Invalid port id\n");
2864 if (!strcmp(res->rxtxq, "rxq"))
2866 else if (!strcmp(res->rxtxq, "txq"))
2869 fprintf(stderr, "Unknown parameter\n");
2873 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2874 fprintf(stderr, "Invalid rx queue\n");
2876 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2877 fprintf(stderr, "Invalid tx queue\n");
2881 port = &ports[res->portid];
2883 socket_id = rxring_numa[res->portid];
2884 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2885 socket_id = port->socket_id;
2887 mp = mbuf_pool_find(socket_id, 0);
2890 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2891 rxring_numa[res->portid]);
2894 ret = rx_queue_setup(res->portid,
2896 port->nb_rx_desc[res->qid],
2898 &port->rx_conf[res->qid],
2901 fprintf(stderr, "Failed to setup RX queue\n");
2903 socket_id = txring_numa[res->portid];
2904 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2905 socket_id = port->socket_id;
2907 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2909 "Failed to setup TX queue: not enough descriptors\n");
2912 ret = rte_eth_tx_queue_setup(res->portid,
2914 port->nb_tx_desc[res->qid],
2916 &port->tx_conf[res->qid]);
2918 fprintf(stderr, "Failed to setup TX queue\n");
2922 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2923 .f = cmd_setup_rxtx_queue_parsed,
2925 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2927 (void *)&cmd_setup_rxtx_queue_port,
2928 (void *)&cmd_setup_rxtx_queue_portid,
2929 (void *)&cmd_setup_rxtx_queue_rxtxq,
2930 (void *)&cmd_setup_rxtx_queue_qid,
2931 (void *)&cmd_setup_rxtx_queue_setup,
2937 /* *** Configure RSS RETA *** */
2938 struct cmd_config_rss_reta {
2939 cmdline_fixed_string_t port;
2940 cmdline_fixed_string_t keyword;
2942 cmdline_fixed_string_t name;
2943 cmdline_fixed_string_t list_name;
2944 cmdline_fixed_string_t list_of_items;
2948 parse_reta_config(const char *str,
2949 struct rte_eth_rss_reta_entry64 *reta_conf,
2950 uint16_t nb_entries)
2954 uint16_t hash_index, idx, shift;
2957 const char *p, *p0 = str;
2964 unsigned long int_fld[_NUM_FLD];
2965 char *str_fld[_NUM_FLD];
2967 while ((p = strchr(p0,'(')) != NULL) {
2969 if((p0 = strchr(p,')')) == NULL)
2973 if(size >= sizeof(s))
2976 snprintf(s, sizeof(s), "%.*s", size, p);
2977 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2979 for (i = 0; i < _NUM_FLD; i++) {
2981 int_fld[i] = strtoul(str_fld[i], &end, 0);
2982 if (errno != 0 || end == str_fld[i] ||
2987 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2988 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2990 if (hash_index >= nb_entries) {
2991 fprintf(stderr, "Invalid RETA hash index=%d\n",
2996 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
2997 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
2998 reta_conf[idx].mask |= (1ULL << shift);
2999 reta_conf[idx].reta[shift] = nb_queue;
3006 cmd_set_rss_reta_parsed(void *parsed_result,
3007 __rte_unused struct cmdline *cl,
3008 __rte_unused void *data)
3011 struct rte_eth_dev_info dev_info;
3012 struct rte_eth_rss_reta_entry64 reta_conf[8];
3013 struct cmd_config_rss_reta *res = parsed_result;
3015 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3019 if (dev_info.reta_size == 0) {
3021 "Redirection table size is 0 which is invalid for RSS\n");
3024 printf("The reta size of port %d is %u\n",
3025 res->port_id, dev_info.reta_size);
3026 if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3028 "Currently do not support more than %u entries of redirection table\n",
3029 RTE_ETH_RSS_RETA_SIZE_512);
3033 memset(reta_conf, 0, sizeof(reta_conf));
3034 if (!strcmp(res->list_name, "reta")) {
3035 if (parse_reta_config(res->list_of_items, reta_conf,
3036 dev_info.reta_size)) {
3038 "Invalid RSS Redirection Table config entered\n");
3041 ret = rte_eth_dev_rss_reta_update(res->port_id,
3042 reta_conf, dev_info.reta_size);
3045 "Bad redirection table parameter, return code = %d\n",
3050 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3051 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3052 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3054 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3055 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3056 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3058 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3060 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3063 cmdline_parse_inst_t cmd_config_rss_reta = {
3064 .f = cmd_set_rss_reta_parsed,
3066 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3068 (void *)&cmd_config_rss_reta_port,
3069 (void *)&cmd_config_rss_reta_keyword,
3070 (void *)&cmd_config_rss_reta_port_id,
3071 (void *)&cmd_config_rss_reta_name,
3072 (void *)&cmd_config_rss_reta_list_name,
3073 (void *)&cmd_config_rss_reta_list_of_items,
3078 /* *** SHOW PORT RETA INFO *** */
3079 struct cmd_showport_reta {
3080 cmdline_fixed_string_t show;
3081 cmdline_fixed_string_t port;
3083 cmdline_fixed_string_t rss;
3084 cmdline_fixed_string_t reta;
3086 cmdline_fixed_string_t list_of_items;
3090 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3091 uint16_t nb_entries,
3095 const char *p, *p0 = str;
3100 uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3101 RTE_ETH_RETA_GROUP_SIZE;
3104 p = strchr(p0, '(');
3108 p0 = strchr(p, ')');
3112 if (size >= sizeof(s)) {
3114 "The string size exceeds the internal buffer size\n");
3117 snprintf(s, sizeof(s), "%.*s", size, p);
3118 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3119 if (ret <= 0 || ret != num) {
3121 "The bits of masks do not match the number of reta entries: %u\n",
3125 for (i = 0; i < ret; i++)
3126 conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3132 cmd_showport_reta_parsed(void *parsed_result,
3133 __rte_unused struct cmdline *cl,
3134 __rte_unused void *data)
3136 struct cmd_showport_reta *res = parsed_result;
3137 struct rte_eth_rss_reta_entry64 reta_conf[8];
3138 struct rte_eth_dev_info dev_info;
3139 uint16_t max_reta_size;
3142 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3146 max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3147 if (res->size == 0 || res->size > max_reta_size) {
3148 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3149 res->size, max_reta_size);
3153 memset(reta_conf, 0, sizeof(reta_conf));
3154 if (showport_parse_reta_config(reta_conf, res->size,
3155 res->list_of_items) < 0) {
3156 fprintf(stderr, "Invalid string: %s for reta masks\n",
3157 res->list_of_items);
3160 port_rss_reta_info(res->port_id, reta_conf, res->size);
3163 cmdline_parse_token_string_t cmd_showport_reta_show =
3164 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3165 cmdline_parse_token_string_t cmd_showport_reta_port =
3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3167 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3168 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3169 cmdline_parse_token_string_t cmd_showport_reta_rss =
3170 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3171 cmdline_parse_token_string_t cmd_showport_reta_reta =
3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3173 cmdline_parse_token_num_t cmd_showport_reta_size =
3174 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3175 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3176 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3177 list_of_items, NULL);
3179 cmdline_parse_inst_t cmd_showport_reta = {
3180 .f = cmd_showport_reta_parsed,
3182 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3184 (void *)&cmd_showport_reta_show,
3185 (void *)&cmd_showport_reta_port,
3186 (void *)&cmd_showport_reta_port_id,
3187 (void *)&cmd_showport_reta_rss,
3188 (void *)&cmd_showport_reta_reta,
3189 (void *)&cmd_showport_reta_size,
3190 (void *)&cmd_showport_reta_list_of_items,
3195 /* *** Show RSS hash configuration *** */
3196 struct cmd_showport_rss_hash {
3197 cmdline_fixed_string_t show;
3198 cmdline_fixed_string_t port;
3200 cmdline_fixed_string_t rss_hash;
3201 cmdline_fixed_string_t rss_type;
3202 cmdline_fixed_string_t key; /* optional argument */
3205 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3206 __rte_unused struct cmdline *cl,
3209 struct cmd_showport_rss_hash *res = parsed_result;
3211 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3214 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3215 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3216 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3217 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3218 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3219 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3221 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3222 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3224 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3225 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3227 cmdline_parse_inst_t cmd_showport_rss_hash = {
3228 .f = cmd_showport_rss_hash_parsed,
3230 .help_str = "show port <port_id> rss-hash",
3232 (void *)&cmd_showport_rss_hash_show,
3233 (void *)&cmd_showport_rss_hash_port,
3234 (void *)&cmd_showport_rss_hash_port_id,
3235 (void *)&cmd_showport_rss_hash_rss_hash,
3240 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3241 .f = cmd_showport_rss_hash_parsed,
3243 .help_str = "show port <port_id> rss-hash key",
3245 (void *)&cmd_showport_rss_hash_show,
3246 (void *)&cmd_showport_rss_hash_port,
3247 (void *)&cmd_showport_rss_hash_port_id,
3248 (void *)&cmd_showport_rss_hash_rss_hash,
3249 (void *)&cmd_showport_rss_hash_rss_key,
3254 /* *** Configure DCB *** */
3255 struct cmd_config_dcb {
3256 cmdline_fixed_string_t port;
3257 cmdline_fixed_string_t config;
3259 cmdline_fixed_string_t dcb;
3260 cmdline_fixed_string_t vt;
3261 cmdline_fixed_string_t vt_en;
3263 cmdline_fixed_string_t pfc;
3264 cmdline_fixed_string_t pfc_en;
3268 cmd_config_dcb_parsed(void *parsed_result,
3269 __rte_unused struct cmdline *cl,
3270 __rte_unused void *data)
3272 struct cmd_config_dcb *res = parsed_result;
3273 struct rte_eth_dcb_info dcb_info;
3274 portid_t port_id = res->port_id;
3275 struct rte_port *port;
3279 port = &ports[port_id];
3280 /** Check if the port is not started **/
3281 if (port->port_status != RTE_PORT_STOPPED) {
3282 fprintf(stderr, "Please stop port %d first\n", port_id);
3286 if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3288 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3292 if (nb_fwd_lcores < res->num_tcs) {
3294 "nb_cores shouldn't be less than number of TCs.\n");
3298 /* Check whether the port supports the report of DCB info. */
3299 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3300 if (ret == -ENOTSUP) {
3301 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3305 if (!strncmp(res->pfc_en, "on", 2))
3310 /* DCB in VT mode */
3311 if (!strncmp(res->vt_en, "on", 2))
3312 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3313 (enum rte_eth_nb_tcs)res->num_tcs,
3316 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3317 (enum rte_eth_nb_tcs)res->num_tcs,
3320 fprintf(stderr, "Cannot initialize network ports.\n");
3326 cmd_reconfig_device_queue(port_id, 1, 1);
3329 cmdline_parse_token_string_t cmd_config_dcb_port =
3330 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3331 cmdline_parse_token_string_t cmd_config_dcb_config =
3332 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3333 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3334 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3335 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3336 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3337 cmdline_parse_token_string_t cmd_config_dcb_vt =
3338 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3339 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3340 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3341 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3342 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3343 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3344 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3345 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3346 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3348 cmdline_parse_inst_t cmd_config_dcb = {
3349 .f = cmd_config_dcb_parsed,
3351 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3353 (void *)&cmd_config_dcb_port,
3354 (void *)&cmd_config_dcb_config,
3355 (void *)&cmd_config_dcb_port_id,
3356 (void *)&cmd_config_dcb_dcb,
3357 (void *)&cmd_config_dcb_vt,
3358 (void *)&cmd_config_dcb_vt_en,
3359 (void *)&cmd_config_dcb_num_tcs,
3360 (void *)&cmd_config_dcb_pfc,
3361 (void *)&cmd_config_dcb_pfc_en,
3366 /* *** configure number of packets per burst *** */
3367 struct cmd_config_burst {
3368 cmdline_fixed_string_t port;
3369 cmdline_fixed_string_t keyword;
3370 cmdline_fixed_string_t all;
3371 cmdline_fixed_string_t name;
3376 cmd_config_burst_parsed(void *parsed_result,
3377 __rte_unused struct cmdline *cl,
3378 __rte_unused void *data)
3380 struct cmd_config_burst *res = parsed_result;
3381 struct rte_eth_dev_info dev_info;
3382 uint16_t rec_nb_pkts;
3385 if (!all_ports_stopped()) {
3386 fprintf(stderr, "Please stop all ports first\n");
3390 if (!strcmp(res->name, "burst")) {
3391 if (res->value == 0) {
3392 /* If user gives a value of zero, query the PMD for
3393 * its recommended Rx burst size. Testpmd uses a single
3394 * size for all ports, so assume all ports are the same
3395 * NIC model and use the values from Port 0.
3397 ret = eth_dev_info_get_print_err(0, &dev_info);
3401 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3403 if (rec_nb_pkts == 0) {
3404 printf("PMD does not recommend a burst size.\n"
3405 "User provided value must be between"
3406 " 1 and %d\n", MAX_PKT_BURST);
3408 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3409 printf("PMD recommended burst size of %d"
3410 " exceeds maximum value of %d\n",
3411 rec_nb_pkts, MAX_PKT_BURST);
3414 printf("Using PMD-provided burst value of %d\n",
3416 nb_pkt_per_burst = rec_nb_pkts;
3417 } else if (res->value > MAX_PKT_BURST) {
3418 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3422 nb_pkt_per_burst = res->value;
3424 fprintf(stderr, "Unknown parameter\n");
3430 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3433 cmdline_parse_token_string_t cmd_config_burst_port =
3434 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3435 cmdline_parse_token_string_t cmd_config_burst_keyword =
3436 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3437 cmdline_parse_token_string_t cmd_config_burst_all =
3438 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3439 cmdline_parse_token_string_t cmd_config_burst_name =
3440 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3441 cmdline_parse_token_num_t cmd_config_burst_value =
3442 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3444 cmdline_parse_inst_t cmd_config_burst = {
3445 .f = cmd_config_burst_parsed,
3447 .help_str = "port config all burst <value>",
3449 (void *)&cmd_config_burst_port,
3450 (void *)&cmd_config_burst_keyword,
3451 (void *)&cmd_config_burst_all,
3452 (void *)&cmd_config_burst_name,
3453 (void *)&cmd_config_burst_value,
3458 /* *** configure rx/tx queues *** */
3459 struct cmd_config_thresh {
3460 cmdline_fixed_string_t port;
3461 cmdline_fixed_string_t keyword;
3462 cmdline_fixed_string_t all;
3463 cmdline_fixed_string_t name;
3468 cmd_config_thresh_parsed(void *parsed_result,
3469 __rte_unused struct cmdline *cl,
3470 __rte_unused void *data)
3472 struct cmd_config_thresh *res = parsed_result;
3474 if (!all_ports_stopped()) {
3475 fprintf(stderr, "Please stop all ports first\n");
3479 if (!strcmp(res->name, "txpt"))
3480 tx_pthresh = res->value;
3481 else if(!strcmp(res->name, "txht"))
3482 tx_hthresh = res->value;
3483 else if(!strcmp(res->name, "txwt"))
3484 tx_wthresh = res->value;
3485 else if(!strcmp(res->name, "rxpt"))
3486 rx_pthresh = res->value;
3487 else if(!strcmp(res->name, "rxht"))
3488 rx_hthresh = res->value;
3489 else if(!strcmp(res->name, "rxwt"))
3490 rx_wthresh = res->value;
3492 fprintf(stderr, "Unknown parameter\n");
3498 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3501 cmdline_parse_token_string_t cmd_config_thresh_port =
3502 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3503 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3504 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3505 cmdline_parse_token_string_t cmd_config_thresh_all =
3506 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3507 cmdline_parse_token_string_t cmd_config_thresh_name =
3508 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3509 "txpt#txht#txwt#rxpt#rxht#rxwt");
3510 cmdline_parse_token_num_t cmd_config_thresh_value =
3511 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3513 cmdline_parse_inst_t cmd_config_thresh = {
3514 .f = cmd_config_thresh_parsed,
3516 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3518 (void *)&cmd_config_thresh_port,
3519 (void *)&cmd_config_thresh_keyword,
3520 (void *)&cmd_config_thresh_all,
3521 (void *)&cmd_config_thresh_name,
3522 (void *)&cmd_config_thresh_value,
3527 /* *** configure free/rs threshold *** */
3528 struct cmd_config_threshold {
3529 cmdline_fixed_string_t port;
3530 cmdline_fixed_string_t keyword;
3531 cmdline_fixed_string_t all;
3532 cmdline_fixed_string_t name;
3537 cmd_config_threshold_parsed(void *parsed_result,
3538 __rte_unused struct cmdline *cl,
3539 __rte_unused void *data)
3541 struct cmd_config_threshold *res = parsed_result;
3543 if (!all_ports_stopped()) {
3544 fprintf(stderr, "Please stop all ports first\n");
3548 if (!strcmp(res->name, "txfreet"))
3549 tx_free_thresh = res->value;
3550 else if (!strcmp(res->name, "txrst"))
3551 tx_rs_thresh = res->value;
3552 else if (!strcmp(res->name, "rxfreet"))
3553 rx_free_thresh = res->value;
3555 fprintf(stderr, "Unknown parameter\n");
3561 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3564 cmdline_parse_token_string_t cmd_config_threshold_port =
3565 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3566 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3567 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3569 cmdline_parse_token_string_t cmd_config_threshold_all =
3570 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3571 cmdline_parse_token_string_t cmd_config_threshold_name =
3572 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3573 "txfreet#txrst#rxfreet");
3574 cmdline_parse_token_num_t cmd_config_threshold_value =
3575 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3577 cmdline_parse_inst_t cmd_config_threshold = {
3578 .f = cmd_config_threshold_parsed,
3580 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3582 (void *)&cmd_config_threshold_port,
3583 (void *)&cmd_config_threshold_keyword,
3584 (void *)&cmd_config_threshold_all,
3585 (void *)&cmd_config_threshold_name,
3586 (void *)&cmd_config_threshold_value,
3592 struct cmd_stop_result {
3593 cmdline_fixed_string_t stop;
3596 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3597 __rte_unused struct cmdline *cl,
3598 __rte_unused void *data)
3600 stop_packet_forwarding();
3603 cmdline_parse_token_string_t cmd_stop_stop =
3604 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3606 cmdline_parse_inst_t cmd_stop = {
3607 .f = cmd_stop_parsed,
3609 .help_str = "stop: Stop packet forwarding",
3611 (void *)&cmd_stop_stop,
3616 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3619 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3620 unsigned int *parsed_items, int check_unique_values)
3622 unsigned int nb_item;
3630 * First parse all items in the list and store their value.
3635 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3637 if ((c >= '0') && (c <= '9')) {
3638 value = (unsigned int) (value * 10 + (c - '0'));
3643 fprintf(stderr, "character %c is not a decimal digit\n", c);
3647 fprintf(stderr, "No valid value before comma\n");
3650 if (nb_item < max_items) {
3651 parsed_items[nb_item] = value;
3657 if (nb_item >= max_items) {
3658 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3659 item_name, nb_item + 1, max_items);
3662 parsed_items[nb_item++] = value;
3663 if (! check_unique_values)
3667 * Then, check that all values in the list are different.
3668 * No optimization here...
3670 for (i = 0; i < nb_item; i++) {
3671 for (j = i + 1; j < nb_item; j++) {
3672 if (parsed_items[j] == parsed_items[i]) {
3674 "duplicated %s %u at index %u and %u\n",
3675 item_name, parsed_items[i], i, j);
3683 struct cmd_set_list_result {
3684 cmdline_fixed_string_t cmd_keyword;
3685 cmdline_fixed_string_t list_name;
3686 cmdline_fixed_string_t list_of_items;
3689 static void cmd_set_list_parsed(void *parsed_result,
3690 __rte_unused struct cmdline *cl,
3691 __rte_unused void *data)
3693 struct cmd_set_list_result *res;
3695 unsigned int lcorelist[RTE_MAX_LCORE];
3696 unsigned int portlist[RTE_MAX_ETHPORTS];
3698 unsigned int nb_item;
3700 if (test_done == 0) {
3701 fprintf(stderr, "Please stop forwarding first\n");
3705 res = parsed_result;
3706 if (!strcmp(res->list_name, "corelist")) {
3707 nb_item = parse_item_list(res->list_of_items, "core",
3709 parsed_items.lcorelist, 1);
3711 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3716 if (!strcmp(res->list_name, "portlist")) {
3717 nb_item = parse_item_list(res->list_of_items, "port",
3719 parsed_items.portlist, 1);
3721 set_fwd_ports_list(parsed_items.portlist, nb_item);
3727 cmdline_parse_token_string_t cmd_set_list_keyword =
3728 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3730 cmdline_parse_token_string_t cmd_set_list_name =
3731 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3732 "corelist#portlist");
3733 cmdline_parse_token_string_t cmd_set_list_of_items =
3734 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3737 cmdline_parse_inst_t cmd_set_fwd_list = {
3738 .f = cmd_set_list_parsed,
3740 .help_str = "set corelist|portlist <list0[,list1]*>",
3742 (void *)&cmd_set_list_keyword,
3743 (void *)&cmd_set_list_name,
3744 (void *)&cmd_set_list_of_items,
3749 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3751 struct cmd_setmask_result {
3752 cmdline_fixed_string_t set;
3753 cmdline_fixed_string_t mask;
3757 static void cmd_set_mask_parsed(void *parsed_result,
3758 __rte_unused struct cmdline *cl,
3759 __rte_unused void *data)
3761 struct cmd_setmask_result *res = parsed_result;
3763 if (test_done == 0) {
3764 fprintf(stderr, "Please stop forwarding first\n");
3767 if (!strcmp(res->mask, "coremask")) {
3768 set_fwd_lcores_mask(res->hexavalue);
3770 } else if (!strcmp(res->mask, "portmask")) {
3771 set_fwd_ports_mask(res->hexavalue);
3776 cmdline_parse_token_string_t cmd_setmask_set =
3777 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3778 cmdline_parse_token_string_t cmd_setmask_mask =
3779 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3780 "coremask#portmask");
3781 cmdline_parse_token_num_t cmd_setmask_value =
3782 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3784 cmdline_parse_inst_t cmd_set_fwd_mask = {
3785 .f = cmd_set_mask_parsed,
3787 .help_str = "set coremask|portmask <hexadecimal value>",
3789 (void *)&cmd_setmask_set,
3790 (void *)&cmd_setmask_mask,
3791 (void *)&cmd_setmask_value,
3797 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3799 struct cmd_set_result {
3800 cmdline_fixed_string_t set;
3801 cmdline_fixed_string_t what;
3805 static void cmd_set_parsed(void *parsed_result,
3806 __rte_unused struct cmdline *cl,
3807 __rte_unused void *data)
3809 struct cmd_set_result *res = parsed_result;
3810 if (!strcmp(res->what, "nbport")) {
3811 set_fwd_ports_number(res->value);
3813 } else if (!strcmp(res->what, "nbcore")) {
3814 set_fwd_lcores_number(res->value);
3816 } else if (!strcmp(res->what, "burst"))
3817 set_nb_pkt_per_burst(res->value);
3818 else if (!strcmp(res->what, "verbose"))
3819 set_verbose_level(res->value);
3822 cmdline_parse_token_string_t cmd_set_set =
3823 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3824 cmdline_parse_token_string_t cmd_set_what =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3826 "nbport#nbcore#burst#verbose");
3827 cmdline_parse_token_num_t cmd_set_value =
3828 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3830 cmdline_parse_inst_t cmd_set_numbers = {
3831 .f = cmd_set_parsed,
3833 .help_str = "set nbport|nbcore|burst|verbose <value>",
3835 (void *)&cmd_set_set,
3836 (void *)&cmd_set_what,
3837 (void *)&cmd_set_value,
3842 /* *** SET LOG LEVEL CONFIGURATION *** */
3844 struct cmd_set_log_result {
3845 cmdline_fixed_string_t set;
3846 cmdline_fixed_string_t log;
3847 cmdline_fixed_string_t type;
3852 cmd_set_log_parsed(void *parsed_result,
3853 __rte_unused struct cmdline *cl,
3854 __rte_unused void *data)
3856 struct cmd_set_log_result *res;
3859 res = parsed_result;
3860 if (!strcmp(res->type, "global"))
3861 rte_log_set_global_level(res->level);
3863 ret = rte_log_set_level_regexp(res->type, res->level);
3865 fprintf(stderr, "Unable to set log level\n");
3869 cmdline_parse_token_string_t cmd_set_log_set =
3870 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3871 cmdline_parse_token_string_t cmd_set_log_log =
3872 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3873 cmdline_parse_token_string_t cmd_set_log_type =
3874 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3875 cmdline_parse_token_num_t cmd_set_log_level =
3876 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3878 cmdline_parse_inst_t cmd_set_log = {
3879 .f = cmd_set_log_parsed,
3881 .help_str = "set log global|<type> <level>",
3883 (void *)&cmd_set_log_set,
3884 (void *)&cmd_set_log_log,
3885 (void *)&cmd_set_log_type,
3886 (void *)&cmd_set_log_level,
3891 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3893 struct cmd_set_rxoffs_result {
3894 cmdline_fixed_string_t cmd_keyword;
3895 cmdline_fixed_string_t rxoffs;
3896 cmdline_fixed_string_t seg_offsets;
3900 cmd_set_rxoffs_parsed(void *parsed_result,
3901 __rte_unused struct cmdline *cl,
3902 __rte_unused void *data)
3904 struct cmd_set_rxoffs_result *res;
3905 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3906 unsigned int nb_segs;
3908 res = parsed_result;
3909 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3910 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3912 set_rx_pkt_offsets(seg_offsets, nb_segs);
3913 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3916 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3917 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3918 cmd_keyword, "set");
3919 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3920 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3922 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3923 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3926 cmdline_parse_inst_t cmd_set_rxoffs = {
3927 .f = cmd_set_rxoffs_parsed,
3929 .help_str = "set rxoffs <len0[,len1]*>",
3931 (void *)&cmd_set_rxoffs_keyword,
3932 (void *)&cmd_set_rxoffs_name,
3933 (void *)&cmd_set_rxoffs_offsets,
3938 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3940 struct cmd_set_rxpkts_result {
3941 cmdline_fixed_string_t cmd_keyword;
3942 cmdline_fixed_string_t rxpkts;
3943 cmdline_fixed_string_t seg_lengths;
3947 cmd_set_rxpkts_parsed(void *parsed_result,
3948 __rte_unused struct cmdline *cl,
3949 __rte_unused void *data)
3951 struct cmd_set_rxpkts_result *res;
3952 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3953 unsigned int nb_segs;
3955 res = parsed_result;
3956 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3957 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3959 set_rx_pkt_segments(seg_lengths, nb_segs);
3960 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3963 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3964 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3965 cmd_keyword, "set");
3966 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3967 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3969 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3970 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3973 cmdline_parse_inst_t cmd_set_rxpkts = {
3974 .f = cmd_set_rxpkts_parsed,
3976 .help_str = "set rxpkts <len0[,len1]*>",
3978 (void *)&cmd_set_rxpkts_keyword,
3979 (void *)&cmd_set_rxpkts_name,
3980 (void *)&cmd_set_rxpkts_lengths,
3985 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3987 struct cmd_set_txpkts_result {
3988 cmdline_fixed_string_t cmd_keyword;
3989 cmdline_fixed_string_t txpkts;
3990 cmdline_fixed_string_t seg_lengths;
3994 cmd_set_txpkts_parsed(void *parsed_result,
3995 __rte_unused struct cmdline *cl,
3996 __rte_unused void *data)
3998 struct cmd_set_txpkts_result *res;
3999 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4000 unsigned int nb_segs;
4002 res = parsed_result;
4003 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4004 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4006 set_tx_pkt_segments(seg_lengths, nb_segs);
4009 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4010 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4011 cmd_keyword, "set");
4012 cmdline_parse_token_string_t cmd_set_txpkts_name =
4013 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4015 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4016 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4019 cmdline_parse_inst_t cmd_set_txpkts = {
4020 .f = cmd_set_txpkts_parsed,
4022 .help_str = "set txpkts <len0[,len1]*>",
4024 (void *)&cmd_set_txpkts_keyword,
4025 (void *)&cmd_set_txpkts_name,
4026 (void *)&cmd_set_txpkts_lengths,
4031 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4033 struct cmd_set_txsplit_result {
4034 cmdline_fixed_string_t cmd_keyword;
4035 cmdline_fixed_string_t txsplit;
4036 cmdline_fixed_string_t mode;
4040 cmd_set_txsplit_parsed(void *parsed_result,
4041 __rte_unused struct cmdline *cl,
4042 __rte_unused void *data)
4044 struct cmd_set_txsplit_result *res;
4046 res = parsed_result;
4047 set_tx_pkt_split(res->mode);
4050 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4052 cmd_keyword, "set");
4053 cmdline_parse_token_string_t cmd_set_txsplit_name =
4054 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4055 txsplit, "txsplit");
4056 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4057 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4060 cmdline_parse_inst_t cmd_set_txsplit = {
4061 .f = cmd_set_txsplit_parsed,
4063 .help_str = "set txsplit on|off|rand",
4065 (void *)&cmd_set_txsplit_keyword,
4066 (void *)&cmd_set_txsplit_name,
4067 (void *)&cmd_set_txsplit_mode,
4072 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4074 struct cmd_set_txtimes_result {
4075 cmdline_fixed_string_t cmd_keyword;
4076 cmdline_fixed_string_t txtimes;
4077 cmdline_fixed_string_t tx_times;
4081 cmd_set_txtimes_parsed(void *parsed_result,
4082 __rte_unused struct cmdline *cl,
4083 __rte_unused void *data)
4085 struct cmd_set_txtimes_result *res;
4086 unsigned int tx_times[2] = {0, 0};
4087 unsigned int n_times;
4089 res = parsed_result;
4090 n_times = parse_item_list(res->tx_times, "tx times",
4093 set_tx_pkt_times(tx_times);
4096 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4097 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4098 cmd_keyword, "set");
4099 cmdline_parse_token_string_t cmd_set_txtimes_name =
4100 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4101 txtimes, "txtimes");
4102 cmdline_parse_token_string_t cmd_set_txtimes_value =
4103 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4106 cmdline_parse_inst_t cmd_set_txtimes = {
4107 .f = cmd_set_txtimes_parsed,
4109 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4111 (void *)&cmd_set_txtimes_keyword,
4112 (void *)&cmd_set_txtimes_name,
4113 (void *)&cmd_set_txtimes_value,
4118 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4119 struct cmd_rx_vlan_filter_all_result {
4120 cmdline_fixed_string_t rx_vlan;
4121 cmdline_fixed_string_t what;
4122 cmdline_fixed_string_t all;
4127 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4128 __rte_unused struct cmdline *cl,
4129 __rte_unused void *data)
4131 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4133 if (!strcmp(res->what, "add"))
4134 rx_vlan_all_filter_set(res->port_id, 1);
4136 rx_vlan_all_filter_set(res->port_id, 0);
4139 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4140 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4141 rx_vlan, "rx_vlan");
4142 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4143 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4145 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4146 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4148 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4149 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4150 port_id, RTE_UINT16);
4152 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4153 .f = cmd_rx_vlan_filter_all_parsed,
4155 .help_str = "rx_vlan add|rm all <port_id>: "
4156 "Add/Remove all identifiers to/from the set of VLAN "
4157 "identifiers filtered by a port",
4159 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4160 (void *)&cmd_rx_vlan_filter_all_what,
4161 (void *)&cmd_rx_vlan_filter_all_all,
4162 (void *)&cmd_rx_vlan_filter_all_portid,
4167 /* *** VLAN OFFLOAD SET ON A PORT *** */
4168 struct cmd_vlan_offload_result {
4169 cmdline_fixed_string_t vlan;
4170 cmdline_fixed_string_t set;
4171 cmdline_fixed_string_t vlan_type;
4172 cmdline_fixed_string_t what;
4173 cmdline_fixed_string_t on;
4174 cmdline_fixed_string_t port_id;
4178 cmd_vlan_offload_parsed(void *parsed_result,
4179 __rte_unused struct cmdline *cl,
4180 __rte_unused void *data)
4183 struct cmd_vlan_offload_result *res = parsed_result;
4186 portid_t port_id = 0;
4190 len = strnlen(str, STR_TOKEN_SIZE);
4192 /* Get port_id first */
4200 tmp = strtoul(str, NULL, 0);
4201 /* If port_id greater that what portid_t can represent, return */
4202 if(tmp >= RTE_MAX_ETHPORTS)
4204 port_id = (portid_t)tmp;
4206 if (!strcmp(res->on, "on"))
4211 if (!strcmp(res->what, "strip"))
4212 rx_vlan_strip_set(port_id, on);
4213 else if(!strcmp(res->what, "stripq")){
4214 uint16_t queue_id = 0;
4216 /* No queue_id, return */
4218 fprintf(stderr, "must specify (port,queue_id)\n");
4221 tmp = strtoul(str + i + 1, NULL, 0);
4222 /* If queue_id greater that what 16-bits can represent, return */
4226 queue_id = (uint16_t)tmp;
4227 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4229 else if (!strcmp(res->what, "filter"))
4230 rx_vlan_filter_set(port_id, on);
4231 else if (!strcmp(res->what, "qinq_strip"))
4232 rx_vlan_qinq_strip_set(port_id, on);
4234 vlan_extend_set(port_id, on);
4239 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4240 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4242 cmdline_parse_token_string_t cmd_vlan_offload_set =
4243 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4245 cmdline_parse_token_string_t cmd_vlan_offload_what =
4246 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4247 what, "strip#filter#qinq_strip#extend#stripq");
4248 cmdline_parse_token_string_t cmd_vlan_offload_on =
4249 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4251 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4252 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4255 cmdline_parse_inst_t cmd_vlan_offload = {
4256 .f = cmd_vlan_offload_parsed,
4258 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4259 "<port_id[,queue_id]>: "
4260 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4262 (void *)&cmd_vlan_offload_vlan,
4263 (void *)&cmd_vlan_offload_set,
4264 (void *)&cmd_vlan_offload_what,
4265 (void *)&cmd_vlan_offload_on,
4266 (void *)&cmd_vlan_offload_portid,
4271 /* *** VLAN TPID SET ON A PORT *** */
4272 struct cmd_vlan_tpid_result {
4273 cmdline_fixed_string_t vlan;
4274 cmdline_fixed_string_t set;
4275 cmdline_fixed_string_t vlan_type;
4276 cmdline_fixed_string_t what;
4282 cmd_vlan_tpid_parsed(void *parsed_result,
4283 __rte_unused struct cmdline *cl,
4284 __rte_unused void *data)
4286 struct cmd_vlan_tpid_result *res = parsed_result;
4287 enum rte_vlan_type vlan_type;
4289 if (!strcmp(res->vlan_type, "inner"))
4290 vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4291 else if (!strcmp(res->vlan_type, "outer"))
4292 vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4294 fprintf(stderr, "Unknown vlan type\n");
4297 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4300 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4301 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4303 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4304 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4306 cmdline_parse_token_string_t cmd_vlan_type =
4307 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4308 vlan_type, "inner#outer");
4309 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4310 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4312 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4313 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4315 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4316 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4317 port_id, RTE_UINT16);
4319 cmdline_parse_inst_t cmd_vlan_tpid = {
4320 .f = cmd_vlan_tpid_parsed,
4322 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4323 "Set the VLAN Ether type",
4325 (void *)&cmd_vlan_tpid_vlan,
4326 (void *)&cmd_vlan_tpid_set,
4327 (void *)&cmd_vlan_type,
4328 (void *)&cmd_vlan_tpid_what,
4329 (void *)&cmd_vlan_tpid_tpid,
4330 (void *)&cmd_vlan_tpid_portid,
4335 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4336 struct cmd_rx_vlan_filter_result {
4337 cmdline_fixed_string_t rx_vlan;
4338 cmdline_fixed_string_t what;
4344 cmd_rx_vlan_filter_parsed(void *parsed_result,
4345 __rte_unused struct cmdline *cl,
4346 __rte_unused void *data)
4348 struct cmd_rx_vlan_filter_result *res = parsed_result;
4350 if (!strcmp(res->what, "add"))
4351 rx_vft_set(res->port_id, res->vlan_id, 1);
4353 rx_vft_set(res->port_id, res->vlan_id, 0);
4356 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4357 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4358 rx_vlan, "rx_vlan");
4359 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4360 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4362 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4363 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4364 vlan_id, RTE_UINT16);
4365 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4366 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4367 port_id, RTE_UINT16);
4369 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4370 .f = cmd_rx_vlan_filter_parsed,
4372 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4373 "Add/Remove a VLAN identifier to/from the set of VLAN "
4374 "identifiers filtered by a port",
4376 (void *)&cmd_rx_vlan_filter_rx_vlan,
4377 (void *)&cmd_rx_vlan_filter_what,
4378 (void *)&cmd_rx_vlan_filter_vlanid,
4379 (void *)&cmd_rx_vlan_filter_portid,
4384 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4385 struct cmd_tx_vlan_set_result {
4386 cmdline_fixed_string_t tx_vlan;
4387 cmdline_fixed_string_t set;
4393 cmd_tx_vlan_set_parsed(void *parsed_result,
4394 __rte_unused struct cmdline *cl,
4395 __rte_unused void *data)
4397 struct cmd_tx_vlan_set_result *res = parsed_result;
4399 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4402 if (!port_is_stopped(res->port_id)) {
4403 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4407 tx_vlan_set(res->port_id, res->vlan_id);
4409 cmd_reconfig_device_queue(res->port_id, 1, 1);
4412 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4413 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4414 tx_vlan, "tx_vlan");
4415 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4416 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4418 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4419 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4420 port_id, RTE_UINT16);
4421 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4422 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4423 vlan_id, RTE_UINT16);
4425 cmdline_parse_inst_t cmd_tx_vlan_set = {
4426 .f = cmd_tx_vlan_set_parsed,
4428 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4429 "Enable hardware insertion of a single VLAN header "
4430 "with a given TAG Identifier in packets sent on a port",
4432 (void *)&cmd_tx_vlan_set_tx_vlan,
4433 (void *)&cmd_tx_vlan_set_set,
4434 (void *)&cmd_tx_vlan_set_portid,
4435 (void *)&cmd_tx_vlan_set_vlanid,
4440 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4441 struct cmd_tx_vlan_set_qinq_result {
4442 cmdline_fixed_string_t tx_vlan;
4443 cmdline_fixed_string_t set;
4446 uint16_t vlan_id_outer;
4450 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4451 __rte_unused struct cmdline *cl,
4452 __rte_unused void *data)
4454 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4456 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4459 if (!port_is_stopped(res->port_id)) {
4460 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4464 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4466 cmd_reconfig_device_queue(res->port_id, 1, 1);
4469 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4470 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4471 tx_vlan, "tx_vlan");
4472 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4473 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4475 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4476 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4477 port_id, RTE_UINT16);
4478 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4479 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4480 vlan_id, RTE_UINT16);
4481 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4482 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4483 vlan_id_outer, RTE_UINT16);
4485 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4486 .f = cmd_tx_vlan_set_qinq_parsed,
4488 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4489 "Enable hardware insertion of double VLAN header "
4490 "with given TAG Identifiers in packets sent on a port",
4492 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4493 (void *)&cmd_tx_vlan_set_qinq_set,
4494 (void *)&cmd_tx_vlan_set_qinq_portid,
4495 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4496 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4501 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4502 struct cmd_tx_vlan_set_pvid_result {
4503 cmdline_fixed_string_t tx_vlan;
4504 cmdline_fixed_string_t set;
4505 cmdline_fixed_string_t pvid;
4508 cmdline_fixed_string_t mode;
4512 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4513 __rte_unused struct cmdline *cl,
4514 __rte_unused void *data)
4516 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4518 if (strcmp(res->mode, "on") == 0)
4519 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4521 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4524 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4525 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4526 tx_vlan, "tx_vlan");
4527 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4528 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4530 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4531 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4533 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4534 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4535 port_id, RTE_UINT16);
4536 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4537 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4538 vlan_id, RTE_UINT16);
4539 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4540 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4543 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4544 .f = cmd_tx_vlan_set_pvid_parsed,
4546 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4548 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4549 (void *)&cmd_tx_vlan_set_pvid_set,
4550 (void *)&cmd_tx_vlan_set_pvid_pvid,
4551 (void *)&cmd_tx_vlan_set_pvid_port_id,
4552 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4553 (void *)&cmd_tx_vlan_set_pvid_mode,
4558 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4559 struct cmd_tx_vlan_reset_result {
4560 cmdline_fixed_string_t tx_vlan;
4561 cmdline_fixed_string_t reset;
4566 cmd_tx_vlan_reset_parsed(void *parsed_result,
4567 __rte_unused struct cmdline *cl,
4568 __rte_unused void *data)
4570 struct cmd_tx_vlan_reset_result *res = parsed_result;
4572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4575 if (!port_is_stopped(res->port_id)) {
4576 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4580 tx_vlan_reset(res->port_id);
4582 cmd_reconfig_device_queue(res->port_id, 1, 1);
4585 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4586 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4587 tx_vlan, "tx_vlan");
4588 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4589 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4591 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4592 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4593 port_id, RTE_UINT16);
4595 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4596 .f = cmd_tx_vlan_reset_parsed,
4598 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4599 "VLAN header in packets sent on a port",
4601 (void *)&cmd_tx_vlan_reset_tx_vlan,
4602 (void *)&cmd_tx_vlan_reset_reset,
4603 (void *)&cmd_tx_vlan_reset_portid,
4609 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4610 struct cmd_csum_result {
4611 cmdline_fixed_string_t csum;
4612 cmdline_fixed_string_t mode;
4613 cmdline_fixed_string_t proto;
4614 cmdline_fixed_string_t hwsw;
4619 csum_show(int port_id)
4621 struct rte_eth_dev_info dev_info;
4622 uint64_t tx_offloads;
4625 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4626 printf("Parse tunnel is %s\n",
4627 (ports[port_id].parse_tunnel) ? "on" : "off");
4628 printf("IP checksum offload is %s\n",
4629 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4630 printf("UDP checksum offload is %s\n",
4631 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4632 printf("TCP checksum offload is %s\n",
4633 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4634 printf("SCTP checksum offload is %s\n",
4635 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4636 printf("Outer-Ip checksum offload is %s\n",
4637 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4638 printf("Outer-Udp checksum offload is %s\n",
4639 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4641 /* display warnings if configuration is not supported by the NIC */
4642 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4646 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4647 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4649 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4652 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4653 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4655 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4658 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4659 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4661 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4664 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4665 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4667 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4670 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4671 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4673 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4676 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4677 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4680 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4686 cmd_config_queue_tx_offloads(struct rte_port *port)
4690 /* Apply queue tx offloads configuration */
4691 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4692 port->tx_conf[k].offloads =
4693 port->dev_conf.txmode.offloads;
4697 cmd_csum_parsed(void *parsed_result,
4698 __rte_unused struct cmdline *cl,
4699 __rte_unused void *data)
4701 struct cmd_csum_result *res = parsed_result;
4703 uint64_t csum_offloads = 0;
4704 struct rte_eth_dev_info dev_info;
4707 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4708 fprintf(stderr, "invalid port %d\n", res->port_id);
4711 if (!port_is_stopped(res->port_id)) {
4712 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4716 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4720 if (!strcmp(res->mode, "set")) {
4722 if (!strcmp(res->hwsw, "hw"))
4725 if (!strcmp(res->proto, "ip")) {
4726 if (hw == 0 || (dev_info.tx_offload_capa &
4727 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4728 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4731 "IP checksum offload is not supported by port %u\n",
4734 } else if (!strcmp(res->proto, "udp")) {
4735 if (hw == 0 || (dev_info.tx_offload_capa &
4736 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4737 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4740 "UDP checksum offload is not supported by port %u\n",
4743 } else if (!strcmp(res->proto, "tcp")) {
4744 if (hw == 0 || (dev_info.tx_offload_capa &
4745 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4746 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4749 "TCP checksum offload is not supported by port %u\n",
4752 } else if (!strcmp(res->proto, "sctp")) {
4753 if (hw == 0 || (dev_info.tx_offload_capa &
4754 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4755 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4758 "SCTP checksum offload is not supported by port %u\n",
4761 } else if (!strcmp(res->proto, "outer-ip")) {
4762 if (hw == 0 || (dev_info.tx_offload_capa &
4763 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4765 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4768 "Outer IP checksum offload is not supported by port %u\n",
4771 } else if (!strcmp(res->proto, "outer-udp")) {
4772 if (hw == 0 || (dev_info.tx_offload_capa &
4773 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4775 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4778 "Outer UDP checksum offload is not supported by port %u\n",
4784 ports[res->port_id].dev_conf.txmode.offloads |=
4787 ports[res->port_id].dev_conf.txmode.offloads &=
4790 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4792 csum_show(res->port_id);
4794 cmd_reconfig_device_queue(res->port_id, 1, 1);
4797 cmdline_parse_token_string_t cmd_csum_csum =
4798 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4800 cmdline_parse_token_string_t cmd_csum_mode =
4801 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4803 cmdline_parse_token_string_t cmd_csum_proto =
4804 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4805 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4806 cmdline_parse_token_string_t cmd_csum_hwsw =
4807 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4809 cmdline_parse_token_num_t cmd_csum_portid =
4810 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4811 port_id, RTE_UINT16);
4813 cmdline_parse_inst_t cmd_csum_set = {
4814 .f = cmd_csum_parsed,
4816 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4817 "Enable/Disable hardware calculation of L3/L4 checksum when "
4818 "using csum forward engine",
4820 (void *)&cmd_csum_csum,
4821 (void *)&cmd_csum_mode,
4822 (void *)&cmd_csum_proto,
4823 (void *)&cmd_csum_hwsw,
4824 (void *)&cmd_csum_portid,
4829 cmdline_parse_token_string_t cmd_csum_mode_show =
4830 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4833 cmdline_parse_inst_t cmd_csum_show = {
4834 .f = cmd_csum_parsed,
4836 .help_str = "csum show <port_id>: Show checksum offload configuration",
4838 (void *)&cmd_csum_csum,
4839 (void *)&cmd_csum_mode_show,
4840 (void *)&cmd_csum_portid,
4845 /* Enable/disable tunnel parsing */
4846 struct cmd_csum_tunnel_result {
4847 cmdline_fixed_string_t csum;
4848 cmdline_fixed_string_t parse;
4849 cmdline_fixed_string_t onoff;
4854 cmd_csum_tunnel_parsed(void *parsed_result,
4855 __rte_unused struct cmdline *cl,
4856 __rte_unused void *data)
4858 struct cmd_csum_tunnel_result *res = parsed_result;
4860 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4863 if (!strcmp(res->onoff, "on"))
4864 ports[res->port_id].parse_tunnel = 1;
4866 ports[res->port_id].parse_tunnel = 0;
4868 csum_show(res->port_id);
4871 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4872 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4874 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4875 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4876 parse, "parse-tunnel");
4877 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4878 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4880 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4881 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4882 port_id, RTE_UINT16);
4884 cmdline_parse_inst_t cmd_csum_tunnel = {
4885 .f = cmd_csum_tunnel_parsed,
4887 .help_str = "csum parse-tunnel on|off <port_id>: "
4888 "Enable/Disable parsing of tunnels for csum engine",
4890 (void *)&cmd_csum_tunnel_csum,
4891 (void *)&cmd_csum_tunnel_parse,
4892 (void *)&cmd_csum_tunnel_onoff,
4893 (void *)&cmd_csum_tunnel_portid,
4898 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4899 struct cmd_tso_set_result {
4900 cmdline_fixed_string_t tso;
4901 cmdline_fixed_string_t mode;
4907 cmd_tso_set_parsed(void *parsed_result,
4908 __rte_unused struct cmdline *cl,
4909 __rte_unused void *data)
4911 struct cmd_tso_set_result *res = parsed_result;
4912 struct rte_eth_dev_info dev_info;
4915 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4917 if (!port_is_stopped(res->port_id)) {
4918 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4922 if (!strcmp(res->mode, "set"))
4923 ports[res->port_id].tso_segsz = res->tso_segsz;
4925 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4929 if ((ports[res->port_id].tso_segsz != 0) &&
4930 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4931 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4936 if (ports[res->port_id].tso_segsz == 0) {
4937 ports[res->port_id].dev_conf.txmode.offloads &=
4938 ~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4939 printf("TSO for non-tunneled packets is disabled\n");
4941 ports[res->port_id].dev_conf.txmode.offloads |=
4942 RTE_ETH_TX_OFFLOAD_TCP_TSO;
4943 printf("TSO segment size for non-tunneled packets is %d\n",
4944 ports[res->port_id].tso_segsz);
4946 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4948 /* display warnings if configuration is not supported by the NIC */
4949 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4953 if ((ports[res->port_id].tso_segsz != 0) &&
4954 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4956 "Warning: TSO enabled but not supported by port %d\n",
4960 cmd_reconfig_device_queue(res->port_id, 1, 1);
4963 cmdline_parse_token_string_t cmd_tso_set_tso =
4964 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4966 cmdline_parse_token_string_t cmd_tso_set_mode =
4967 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4969 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4970 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4971 tso_segsz, RTE_UINT16);
4972 cmdline_parse_token_num_t cmd_tso_set_portid =
4973 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4974 port_id, RTE_UINT16);
4976 cmdline_parse_inst_t cmd_tso_set = {
4977 .f = cmd_tso_set_parsed,
4979 .help_str = "tso set <tso_segsz> <port_id>: "
4980 "Set TSO segment size of non-tunneled packets for csum engine "
4983 (void *)&cmd_tso_set_tso,
4984 (void *)&cmd_tso_set_mode,
4985 (void *)&cmd_tso_set_tso_segsz,
4986 (void *)&cmd_tso_set_portid,
4991 cmdline_parse_token_string_t cmd_tso_show_mode =
4992 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4996 cmdline_parse_inst_t cmd_tso_show = {
4997 .f = cmd_tso_set_parsed,
4999 .help_str = "tso show <port_id>: "
5000 "Show TSO segment size of non-tunneled packets for csum engine",
5002 (void *)&cmd_tso_set_tso,
5003 (void *)&cmd_tso_show_mode,
5004 (void *)&cmd_tso_set_portid,
5009 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5010 struct cmd_tunnel_tso_set_result {
5011 cmdline_fixed_string_t tso;
5012 cmdline_fixed_string_t mode;
5017 static struct rte_eth_dev_info
5018 check_tunnel_tso_nic_support(portid_t port_id)
5020 struct rte_eth_dev_info dev_info;
5022 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5025 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5027 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5029 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5031 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5033 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5035 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5037 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5039 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5041 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5043 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5045 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5047 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5053 cmd_tunnel_tso_set_parsed(void *parsed_result,
5054 __rte_unused struct cmdline *cl,
5055 __rte_unused void *data)
5057 struct cmd_tunnel_tso_set_result *res = parsed_result;
5058 struct rte_eth_dev_info dev_info;
5060 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5062 if (!port_is_stopped(res->port_id)) {
5063 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5067 if (!strcmp(res->mode, "set"))
5068 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5070 dev_info = check_tunnel_tso_nic_support(res->port_id);
5071 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5072 ports[res->port_id].dev_conf.txmode.offloads &=
5073 ~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5074 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5075 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5076 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5077 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5078 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5079 printf("TSO for tunneled packets is disabled\n");
5081 uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5082 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5083 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5084 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5085 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5086 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5088 ports[res->port_id].dev_conf.txmode.offloads |=
5089 (tso_offloads & dev_info.tx_offload_capa);
5090 printf("TSO segment size for tunneled packets is %d\n",
5091 ports[res->port_id].tunnel_tso_segsz);
5093 /* Below conditions are needed to make it work:
5094 * (1) tunnel TSO is supported by the NIC;
5095 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5097 * (3) for tunneled pkts with outer L3 of IPv4,
5098 * "csum set outer-ip" must be set to hw, because after tso,
5099 * total_len of outer IP header is changed, and the checksum
5100 * of outer IP header calculated by sw should be wrong; that
5101 * is not necessary for IPv6 tunneled pkts because there's no
5102 * checksum in IP header anymore.
5105 if (!ports[res->port_id].parse_tunnel)
5107 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5108 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5109 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5111 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5114 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5115 cmd_reconfig_device_queue(res->port_id, 1, 1);
5118 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5119 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5121 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5122 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5124 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5125 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5126 tso_segsz, RTE_UINT16);
5127 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5128 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5129 port_id, RTE_UINT16);
5131 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5132 .f = cmd_tunnel_tso_set_parsed,
5134 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5135 "Set TSO segment size of tunneled packets for csum engine "
5138 (void *)&cmd_tunnel_tso_set_tso,
5139 (void *)&cmd_tunnel_tso_set_mode,
5140 (void *)&cmd_tunnel_tso_set_tso_segsz,
5141 (void *)&cmd_tunnel_tso_set_portid,
5146 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5147 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5151 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5152 .f = cmd_tunnel_tso_set_parsed,
5154 .help_str = "tunnel_tso show <port_id> "
5155 "Show TSO segment size of tunneled packets for csum engine",
5157 (void *)&cmd_tunnel_tso_set_tso,
5158 (void *)&cmd_tunnel_tso_show_mode,
5159 (void *)&cmd_tunnel_tso_set_portid,
5165 /* *** SET GRO FOR A PORT *** */
5166 struct cmd_gro_enable_result {
5167 cmdline_fixed_string_t cmd_set;
5168 cmdline_fixed_string_t cmd_port;
5169 cmdline_fixed_string_t cmd_keyword;
5170 cmdline_fixed_string_t cmd_onoff;
5175 cmd_gro_enable_parsed(void *parsed_result,
5176 __rte_unused struct cmdline *cl,
5177 __rte_unused void *data)
5179 struct cmd_gro_enable_result *res;
5181 res = parsed_result;
5182 if (!strcmp(res->cmd_keyword, "gro"))
5183 setup_gro(res->cmd_onoff, res->cmd_pid);
5186 cmdline_parse_token_string_t cmd_gro_enable_set =
5187 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5189 cmdline_parse_token_string_t cmd_gro_enable_port =
5190 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5191 cmd_keyword, "port");
5192 cmdline_parse_token_num_t cmd_gro_enable_pid =
5193 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5194 cmd_pid, RTE_UINT16);
5195 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5196 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5197 cmd_keyword, "gro");
5198 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5199 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5200 cmd_onoff, "on#off");
5202 cmdline_parse_inst_t cmd_gro_enable = {
5203 .f = cmd_gro_enable_parsed,
5205 .help_str = "set port <port_id> gro on|off",
5207 (void *)&cmd_gro_enable_set,
5208 (void *)&cmd_gro_enable_port,
5209 (void *)&cmd_gro_enable_pid,
5210 (void *)&cmd_gro_enable_keyword,
5211 (void *)&cmd_gro_enable_onoff,
5216 /* *** DISPLAY GRO CONFIGURATION *** */
5217 struct cmd_gro_show_result {
5218 cmdline_fixed_string_t cmd_show;
5219 cmdline_fixed_string_t cmd_port;
5220 cmdline_fixed_string_t cmd_keyword;
5225 cmd_gro_show_parsed(void *parsed_result,
5226 __rte_unused struct cmdline *cl,
5227 __rte_unused void *data)
5229 struct cmd_gro_show_result *res;
5231 res = parsed_result;
5232 if (!strcmp(res->cmd_keyword, "gro"))
5233 show_gro(res->cmd_pid);
5236 cmdline_parse_token_string_t cmd_gro_show_show =
5237 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5239 cmdline_parse_token_string_t cmd_gro_show_port =
5240 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5242 cmdline_parse_token_num_t cmd_gro_show_pid =
5243 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5244 cmd_pid, RTE_UINT16);
5245 cmdline_parse_token_string_t cmd_gro_show_keyword =
5246 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5247 cmd_keyword, "gro");
5249 cmdline_parse_inst_t cmd_gro_show = {
5250 .f = cmd_gro_show_parsed,
5252 .help_str = "show port <port_id> gro",
5254 (void *)&cmd_gro_show_show,
5255 (void *)&cmd_gro_show_port,
5256 (void *)&cmd_gro_show_pid,
5257 (void *)&cmd_gro_show_keyword,
5262 /* *** SET FLUSH CYCLES FOR GRO *** */
5263 struct cmd_gro_flush_result {
5264 cmdline_fixed_string_t cmd_set;
5265 cmdline_fixed_string_t cmd_keyword;
5266 cmdline_fixed_string_t cmd_flush;
5271 cmd_gro_flush_parsed(void *parsed_result,
5272 __rte_unused struct cmdline *cl,
5273 __rte_unused void *data)
5275 struct cmd_gro_flush_result *res;
5277 res = parsed_result;
5278 if ((!strcmp(res->cmd_keyword, "gro")) &&
5279 (!strcmp(res->cmd_flush, "flush")))
5280 setup_gro_flush_cycles(res->cmd_cycles);
5283 cmdline_parse_token_string_t cmd_gro_flush_set =
5284 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5286 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5287 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5288 cmd_keyword, "gro");
5289 cmdline_parse_token_string_t cmd_gro_flush_flush =
5290 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5291 cmd_flush, "flush");
5292 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5293 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5294 cmd_cycles, RTE_UINT8);
5296 cmdline_parse_inst_t cmd_gro_flush = {
5297 .f = cmd_gro_flush_parsed,
5299 .help_str = "set gro flush <cycles>",
5301 (void *)&cmd_gro_flush_set,
5302 (void *)&cmd_gro_flush_keyword,
5303 (void *)&cmd_gro_flush_flush,
5304 (void *)&cmd_gro_flush_cycles,
5308 #endif /* RTE_LIB_GRO */
5311 /* *** ENABLE/DISABLE GSO *** */
5312 struct cmd_gso_enable_result {
5313 cmdline_fixed_string_t cmd_set;
5314 cmdline_fixed_string_t cmd_port;
5315 cmdline_fixed_string_t cmd_keyword;
5316 cmdline_fixed_string_t cmd_mode;
5321 cmd_gso_enable_parsed(void *parsed_result,
5322 __rte_unused struct cmdline *cl,
5323 __rte_unused void *data)
5325 struct cmd_gso_enable_result *res;
5327 res = parsed_result;
5328 if (!strcmp(res->cmd_keyword, "gso"))
5329 setup_gso(res->cmd_mode, res->cmd_pid);
5332 cmdline_parse_token_string_t cmd_gso_enable_set =
5333 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5335 cmdline_parse_token_string_t cmd_gso_enable_port =
5336 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5338 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5339 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5340 cmd_keyword, "gso");
5341 cmdline_parse_token_string_t cmd_gso_enable_mode =
5342 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5343 cmd_mode, "on#off");
5344 cmdline_parse_token_num_t cmd_gso_enable_pid =
5345 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5346 cmd_pid, RTE_UINT16);
5348 cmdline_parse_inst_t cmd_gso_enable = {
5349 .f = cmd_gso_enable_parsed,
5351 .help_str = "set port <port_id> gso on|off",
5353 (void *)&cmd_gso_enable_set,
5354 (void *)&cmd_gso_enable_port,
5355 (void *)&cmd_gso_enable_pid,
5356 (void *)&cmd_gso_enable_keyword,
5357 (void *)&cmd_gso_enable_mode,
5362 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5363 struct cmd_gso_size_result {
5364 cmdline_fixed_string_t cmd_set;
5365 cmdline_fixed_string_t cmd_keyword;
5366 cmdline_fixed_string_t cmd_segsz;
5371 cmd_gso_size_parsed(void *parsed_result,
5372 __rte_unused struct cmdline *cl,
5373 __rte_unused void *data)
5375 struct cmd_gso_size_result *res = parsed_result;
5377 if (test_done == 0) {
5379 "Before setting GSO segsz, please first stop forwarding\n");
5383 if (!strcmp(res->cmd_keyword, "gso") &&
5384 !strcmp(res->cmd_segsz, "segsz")) {
5385 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5387 "gso_size should be larger than %zu. Please input a legal value\n",
5388 RTE_GSO_SEG_SIZE_MIN);
5390 gso_max_segment_size = res->cmd_size;
5394 cmdline_parse_token_string_t cmd_gso_size_set =
5395 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5397 cmdline_parse_token_string_t cmd_gso_size_keyword =
5398 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5399 cmd_keyword, "gso");
5400 cmdline_parse_token_string_t cmd_gso_size_segsz =
5401 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5402 cmd_segsz, "segsz");
5403 cmdline_parse_token_num_t cmd_gso_size_size =
5404 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5405 cmd_size, RTE_UINT16);
5407 cmdline_parse_inst_t cmd_gso_size = {
5408 .f = cmd_gso_size_parsed,
5410 .help_str = "set gso segsz <length>",
5412 (void *)&cmd_gso_size_set,
5413 (void *)&cmd_gso_size_keyword,
5414 (void *)&cmd_gso_size_segsz,
5415 (void *)&cmd_gso_size_size,
5420 /* *** SHOW GSO CONFIGURATION *** */
5421 struct cmd_gso_show_result {
5422 cmdline_fixed_string_t cmd_show;
5423 cmdline_fixed_string_t cmd_port;
5424 cmdline_fixed_string_t cmd_keyword;
5429 cmd_gso_show_parsed(void *parsed_result,
5430 __rte_unused struct cmdline *cl,
5431 __rte_unused void *data)
5433 struct cmd_gso_show_result *res = parsed_result;
5435 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5436 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5439 if (!strcmp(res->cmd_keyword, "gso")) {
5440 if (gso_ports[res->cmd_pid].enable) {
5441 printf("Max GSO'd packet size: %uB\n"
5442 "Supported GSO types: TCP/IPv4, "
5443 "UDP/IPv4, VxLAN with inner "
5444 "TCP/IPv4 packet, GRE with inner "
5445 "TCP/IPv4 packet\n",
5446 gso_max_segment_size);
5448 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5452 cmdline_parse_token_string_t cmd_gso_show_show =
5453 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5455 cmdline_parse_token_string_t cmd_gso_show_port =
5456 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5458 cmdline_parse_token_string_t cmd_gso_show_keyword =
5459 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5460 cmd_keyword, "gso");
5461 cmdline_parse_token_num_t cmd_gso_show_pid =
5462 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5463 cmd_pid, RTE_UINT16);
5465 cmdline_parse_inst_t cmd_gso_show = {
5466 .f = cmd_gso_show_parsed,
5468 .help_str = "show port <port_id> gso",
5470 (void *)&cmd_gso_show_show,
5471 (void *)&cmd_gso_show_port,
5472 (void *)&cmd_gso_show_pid,
5473 (void *)&cmd_gso_show_keyword,
5477 #endif /* RTE_LIB_GSO */
5479 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5480 struct cmd_set_flush_rx {
5481 cmdline_fixed_string_t set;
5482 cmdline_fixed_string_t flush_rx;
5483 cmdline_fixed_string_t mode;
5487 cmd_set_flush_rx_parsed(void *parsed_result,
5488 __rte_unused struct cmdline *cl,
5489 __rte_unused void *data)
5491 struct cmd_set_flush_rx *res = parsed_result;
5493 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5494 printf("multi-process doesn't support to flush Rx queues.\n");
5498 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5501 cmdline_parse_token_string_t cmd_setflushrx_set =
5502 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5504 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5505 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5506 flush_rx, "flush_rx");
5507 cmdline_parse_token_string_t cmd_setflushrx_mode =
5508 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5512 cmdline_parse_inst_t cmd_set_flush_rx = {
5513 .f = cmd_set_flush_rx_parsed,
5514 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5517 (void *)&cmd_setflushrx_set,
5518 (void *)&cmd_setflushrx_flush_rx,
5519 (void *)&cmd_setflushrx_mode,
5524 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5525 struct cmd_set_link_check {
5526 cmdline_fixed_string_t set;
5527 cmdline_fixed_string_t link_check;
5528 cmdline_fixed_string_t mode;
5532 cmd_set_link_check_parsed(void *parsed_result,
5533 __rte_unused struct cmdline *cl,
5534 __rte_unused void *data)
5536 struct cmd_set_link_check *res = parsed_result;
5537 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5540 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5541 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5543 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5544 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5545 link_check, "link_check");
5546 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5547 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5551 cmdline_parse_inst_t cmd_set_link_check = {
5552 .f = cmd_set_link_check_parsed,
5553 .help_str = "set link_check on|off: Enable/Disable link status check "
5554 "when starting/stopping a port",
5557 (void *)&cmd_setlinkcheck_set,
5558 (void *)&cmd_setlinkcheck_link_check,
5559 (void *)&cmd_setlinkcheck_mode,
5564 /* *** SET NIC BYPASS MODE *** */
5565 struct cmd_set_bypass_mode_result {
5566 cmdline_fixed_string_t set;
5567 cmdline_fixed_string_t bypass;
5568 cmdline_fixed_string_t mode;
5569 cmdline_fixed_string_t value;
5574 cmd_set_bypass_mode_parsed(void *parsed_result,
5575 __rte_unused struct cmdline *cl,
5576 __rte_unused void *data)
5578 struct cmd_set_bypass_mode_result *res = parsed_result;
5579 portid_t port_id = res->port_id;
5580 int32_t rc = -EINVAL;
5582 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5583 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5585 if (!strcmp(res->value, "bypass"))
5586 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5587 else if (!strcmp(res->value, "isolate"))
5588 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5590 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5592 /* Set the bypass mode for the relevant port. */
5593 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5596 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5600 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5601 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5603 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5606 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5607 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5609 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5610 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5611 value, "normal#bypass#isolate");
5612 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5613 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5614 port_id, RTE_UINT16);
5616 cmdline_parse_inst_t cmd_set_bypass_mode = {
5617 .f = cmd_set_bypass_mode_parsed,
5618 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5619 "Set the NIC bypass mode for port_id",
5622 (void *)&cmd_setbypass_mode_set,
5623 (void *)&cmd_setbypass_mode_bypass,
5624 (void *)&cmd_setbypass_mode_mode,
5625 (void *)&cmd_setbypass_mode_value,
5626 (void *)&cmd_setbypass_mode_port,
5631 /* *** SET NIC BYPASS EVENT *** */
5632 struct cmd_set_bypass_event_result {
5633 cmdline_fixed_string_t set;
5634 cmdline_fixed_string_t bypass;
5635 cmdline_fixed_string_t event;
5636 cmdline_fixed_string_t event_value;
5637 cmdline_fixed_string_t mode;
5638 cmdline_fixed_string_t mode_value;
5643 cmd_set_bypass_event_parsed(void *parsed_result,
5644 __rte_unused struct cmdline *cl,
5645 __rte_unused void *data)
5647 int32_t rc = -EINVAL;
5648 struct cmd_set_bypass_event_result *res = parsed_result;
5649 portid_t port_id = res->port_id;
5651 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5652 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5653 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5655 if (!strcmp(res->event_value, "timeout"))
5656 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5657 else if (!strcmp(res->event_value, "os_on"))
5658 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5659 else if (!strcmp(res->event_value, "os_off"))
5660 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5661 else if (!strcmp(res->event_value, "power_on"))
5662 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5663 else if (!strcmp(res->event_value, "power_off"))
5664 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5666 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5668 if (!strcmp(res->mode_value, "bypass"))
5669 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5670 else if (!strcmp(res->mode_value, "isolate"))
5671 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5673 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5675 /* Set the watchdog timeout. */
5676 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5679 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5680 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5685 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5686 bypass_timeout, port_id, rc);
5690 /* Set the bypass event to transition to bypass mode. */
5691 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5696 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5700 cmdline_parse_token_string_t cmd_setbypass_event_set =
5701 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5703 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5706 cmdline_parse_token_string_t cmd_setbypass_event_event =
5707 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5709 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5710 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5711 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5712 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5713 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5715 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5716 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5717 mode_value, "normal#bypass#isolate");
5718 cmdline_parse_token_num_t cmd_setbypass_event_port =
5719 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5720 port_id, RTE_UINT16);
5722 cmdline_parse_inst_t cmd_set_bypass_event = {
5723 .f = cmd_set_bypass_event_parsed,
5724 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5725 "power_off mode normal|bypass|isolate <port_id>: "
5726 "Set the NIC bypass event mode for port_id",
5729 (void *)&cmd_setbypass_event_set,
5730 (void *)&cmd_setbypass_event_bypass,
5731 (void *)&cmd_setbypass_event_event,
5732 (void *)&cmd_setbypass_event_event_value,
5733 (void *)&cmd_setbypass_event_mode,
5734 (void *)&cmd_setbypass_event_mode_value,
5735 (void *)&cmd_setbypass_event_port,
5741 /* *** SET NIC BYPASS TIMEOUT *** */
5742 struct cmd_set_bypass_timeout_result {
5743 cmdline_fixed_string_t set;
5744 cmdline_fixed_string_t bypass;
5745 cmdline_fixed_string_t timeout;
5746 cmdline_fixed_string_t value;
5750 cmd_set_bypass_timeout_parsed(void *parsed_result,
5751 __rte_unused struct cmdline *cl,
5752 __rte_unused void *data)
5754 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5756 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5757 if (!strcmp(res->value, "1.5"))
5758 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5759 else if (!strcmp(res->value, "2"))
5760 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5761 else if (!strcmp(res->value, "3"))
5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5763 else if (!strcmp(res->value, "4"))
5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5765 else if (!strcmp(res->value, "8"))
5766 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5767 else if (!strcmp(res->value, "16"))
5768 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5769 else if (!strcmp(res->value, "32"))
5770 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5772 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5776 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5777 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5779 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5782 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5783 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5784 timeout, "timeout");
5785 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5786 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5787 value, "0#1.5#2#3#4#8#16#32");
5789 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5790 .f = cmd_set_bypass_timeout_parsed,
5791 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5792 "Set the NIC bypass watchdog timeout in seconds",
5795 (void *)&cmd_setbypass_timeout_set,
5796 (void *)&cmd_setbypass_timeout_bypass,
5797 (void *)&cmd_setbypass_timeout_timeout,
5798 (void *)&cmd_setbypass_timeout_value,
5803 /* *** SHOW NIC BYPASS MODE *** */
5804 struct cmd_show_bypass_config_result {
5805 cmdline_fixed_string_t show;
5806 cmdline_fixed_string_t bypass;
5807 cmdline_fixed_string_t config;
5812 cmd_show_bypass_config_parsed(void *parsed_result,
5813 __rte_unused struct cmdline *cl,
5814 __rte_unused void *data)
5816 struct cmd_show_bypass_config_result *res = parsed_result;
5817 portid_t port_id = res->port_id;
5819 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5820 uint32_t event_mode;
5821 uint32_t bypass_mode;
5822 uint32_t timeout = bypass_timeout;
5825 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5826 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5827 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5828 {"UNKNOWN", "normal", "bypass", "isolate"};
5829 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5837 /* Display the bypass mode.*/
5838 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5839 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5844 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5845 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5847 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5850 /* Display the bypass timeout.*/
5851 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5852 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5854 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5856 /* Display the bypass events and associated modes. */
5857 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5859 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5861 "\tFailed to get bypass mode for event = %s\n",
5864 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5865 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5867 printf("\tbypass event: %-16s = %s\n", events[i],
5874 "\tFailed to get bypass configuration for port = %d\n",
5878 cmdline_parse_token_string_t cmd_showbypass_config_show =
5879 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5881 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5882 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5884 cmdline_parse_token_string_t cmd_showbypass_config_config =
5885 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5887 cmdline_parse_token_num_t cmd_showbypass_config_port =
5888 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5889 port_id, RTE_UINT16);
5891 cmdline_parse_inst_t cmd_show_bypass_config = {
5892 .f = cmd_show_bypass_config_parsed,
5893 .help_str = "show bypass config <port_id>: "
5894 "Show the NIC bypass config for port_id",
5897 (void *)&cmd_showbypass_config_show,
5898 (void *)&cmd_showbypass_config_bypass,
5899 (void *)&cmd_showbypass_config_config,
5900 (void *)&cmd_showbypass_config_port,
5906 /* *** SET BONDING MODE *** */
5907 struct cmd_set_bonding_mode_result {
5908 cmdline_fixed_string_t set;
5909 cmdline_fixed_string_t bonding;
5910 cmdline_fixed_string_t mode;
5915 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5916 __rte_unused struct cmdline *cl,
5917 __rte_unused void *data)
5919 struct cmd_set_bonding_mode_result *res = parsed_result;
5920 portid_t port_id = res->port_id;
5921 struct rte_port *port = &ports[port_id];
5924 * Bonding mode changed means resources of device changed, like whether
5925 * started rte timer or not. Device should be restarted when resources
5926 * of device changed.
5928 if (port->port_status != RTE_PORT_STOPPED) {
5930 "\t Error: Can't set bonding mode when port %d is not stopped\n",
5935 /* Set the bonding mode for the relevant port. */
5936 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5937 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5941 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5942 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5944 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5945 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5946 bonding, "bonding");
5947 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5948 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5950 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5951 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5953 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5954 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5955 port_id, RTE_UINT16);
5957 cmdline_parse_inst_t cmd_set_bonding_mode = {
5958 .f = cmd_set_bonding_mode_parsed,
5959 .help_str = "set bonding mode <mode_value> <port_id>: "
5960 "Set the bonding mode for port_id",
5963 (void *) &cmd_setbonding_mode_set,
5964 (void *) &cmd_setbonding_mode_bonding,
5965 (void *) &cmd_setbonding_mode_mode,
5966 (void *) &cmd_setbonding_mode_value,
5967 (void *) &cmd_setbonding_mode_port,
5972 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5973 struct cmd_set_bonding_lacp_dedicated_queues_result {
5974 cmdline_fixed_string_t set;
5975 cmdline_fixed_string_t bonding;
5976 cmdline_fixed_string_t lacp;
5977 cmdline_fixed_string_t dedicated_queues;
5979 cmdline_fixed_string_t mode;
5982 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5983 __rte_unused struct cmdline *cl,
5984 __rte_unused void *data)
5986 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5987 portid_t port_id = res->port_id;
5988 struct rte_port *port;
5990 port = &ports[port_id];
5992 /** Check if the port is not started **/
5993 if (port->port_status != RTE_PORT_STOPPED) {
5994 fprintf(stderr, "Please stop port %d first\n", port_id);
5998 if (!strcmp(res->mode, "enable")) {
5999 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
6000 printf("Dedicate queues for LACP control packets"
6003 printf("Enabling dedicate queues for LACP control "
6004 "packets on port %d failed\n", port_id);
6005 } else if (!strcmp(res->mode, "disable")) {
6006 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
6007 printf("Dedicated queues for LACP control packets "
6010 printf("Disabling dedicated queues for LACP control "
6011 "traffic on port %d failed\n", port_id);
6015 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6018 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6019 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6020 bonding, "bonding");
6021 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6022 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6024 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6025 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6026 dedicated_queues, "dedicated_queues");
6027 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6028 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6029 port_id, RTE_UINT16);
6030 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6031 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6032 mode, "enable#disable");
6034 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6035 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6036 .help_str = "set bonding lacp dedicated_queues <port_id> "
6038 "Enable/disable dedicated queues for LACP control traffic for port_id",
6041 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6042 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6043 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6044 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6045 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6046 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6051 /* *** SET BALANCE XMIT POLICY *** */
6052 struct cmd_set_bonding_balance_xmit_policy_result {
6053 cmdline_fixed_string_t set;
6054 cmdline_fixed_string_t bonding;
6055 cmdline_fixed_string_t balance_xmit_policy;
6057 cmdline_fixed_string_t policy;
6060 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6061 __rte_unused struct cmdline *cl,
6062 __rte_unused void *data)
6064 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6065 portid_t port_id = res->port_id;
6068 if (!strcmp(res->policy, "l2")) {
6069 policy = BALANCE_XMIT_POLICY_LAYER2;
6070 } else if (!strcmp(res->policy, "l23")) {
6071 policy = BALANCE_XMIT_POLICY_LAYER23;
6072 } else if (!strcmp(res->policy, "l34")) {
6073 policy = BALANCE_XMIT_POLICY_LAYER34;
6075 fprintf(stderr, "\t Invalid xmit policy selection");
6079 /* Set the bonding mode for the relevant port. */
6080 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6082 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6087 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6088 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6090 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6091 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6092 bonding, "bonding");
6093 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6094 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6095 balance_xmit_policy, "balance_xmit_policy");
6096 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6097 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6098 port_id, RTE_UINT16);
6099 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6100 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6101 policy, "l2#l23#l34");
6103 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6104 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6105 .help_str = "set bonding balance_xmit_policy <port_id> "
6107 "Set the bonding balance_xmit_policy for port_id",
6110 (void *)&cmd_setbonding_balance_xmit_policy_set,
6111 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6112 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6113 (void *)&cmd_setbonding_balance_xmit_policy_port,
6114 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6119 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6120 struct cmd_show_bonding_lacp_info_result {
6121 cmdline_fixed_string_t show;
6122 cmdline_fixed_string_t bonding;
6123 cmdline_fixed_string_t lacp;
6124 cmdline_fixed_string_t info;
6128 static void port_param_show(struct port_params *params)
6130 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6132 printf("\t\tsystem priority: %u\n", params->system_priority);
6133 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6134 printf("\t\tsystem mac address: %s\n", buf);
6135 printf("\t\tport key: %u\n", params->key);
6136 printf("\t\tport priority: %u\n", params->port_priority);
6137 printf("\t\tport number: %u\n", params->port_number);
6140 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6142 char a_state[256] = { 0 };
6143 char p_state[256] = { 0 };
6148 static const char * const state[] = {
6158 static const char * const selection[] = {
6164 for (i = 0; i < RTE_DIM(state); i++) {
6165 if ((info->actor_state >> i) & 1)
6166 a_len += snprintf(&a_state[a_len],
6167 RTE_DIM(a_state) - a_len, "%s ",
6170 if ((info->partner_state >> i) & 1)
6171 p_len += snprintf(&p_state[p_len],
6172 RTE_DIM(p_state) - p_len, "%s ",
6175 printf("\tAggregator port id: %u\n", info->agg_port_id);
6176 printf("\tselection: %s\n", selection[info->selected]);
6177 printf("\tActor detail info:\n");
6178 port_param_show(&info->actor);
6179 printf("\t\tport state: %s\n", a_state);
6180 printf("\tPartner detail info:\n");
6181 port_param_show(&info->partner);
6182 printf("\t\tport state: %s\n", p_state);
6186 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6188 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6189 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6190 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6191 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6192 printf("\taggregate wait timeout: %u ms\n",
6193 conf->aggregate_wait_timeout_ms);
6194 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6195 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6196 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6197 switch (conf->agg_selection) {
6199 printf("\taggregation mode: bandwidth\n");
6202 printf("\taggregation mode: stable\n");
6205 printf("\taggregation mode: count\n");
6208 printf("\taggregation mode: invalid\n");
6215 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6216 __rte_unused struct cmdline *cl,
6217 __rte_unused void *data)
6219 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6220 struct rte_eth_bond_8023ad_slave_info slave_info;
6221 struct rte_eth_bond_8023ad_conf port_conf;
6222 portid_t slaves[RTE_MAX_ETHPORTS];
6223 portid_t port_id = res->port_id;
6224 int num_active_slaves;
6229 bonding_mode = rte_eth_bond_mode_get(port_id);
6230 if (bonding_mode != BONDING_MODE_8023AD) {
6231 fprintf(stderr, "\tBonding mode is not mode 4\n");
6235 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6237 if (num_active_slaves < 0) {
6238 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6242 if (num_active_slaves == 0)
6243 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6246 printf("\tIEEE802.3 port: %u\n", port_id);
6247 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6249 fprintf(stderr, "\tGet bonded device %u info failed\n",
6253 lacp_conf_show(&port_conf);
6255 for (i = 0; i < num_active_slaves; i++) {
6256 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6259 fprintf(stderr, "\tGet slave device %u info failed\n",
6263 printf("\tSlave Port: %u\n", slaves[i]);
6264 lacp_slave_info_show(&slave_info);
6268 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6269 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6271 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6272 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6273 bonding, "bonding");
6274 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6275 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6277 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6278 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6280 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6281 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6282 port_id, RTE_UINT16);
6284 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6285 .f = cmd_show_bonding_lacp_info_parsed,
6286 .help_str = "show bonding lacp info <port_id> : "
6287 "Show bonding IEEE802.3 information for port_id",
6290 (void *)&cmd_show_bonding_lacp_info_show,
6291 (void *)&cmd_show_bonding_lacp_info_bonding,
6292 (void *)&cmd_show_bonding_lacp_info_lacp,
6293 (void *)&cmd_show_bonding_lacp_info_info,
6294 (void *)&cmd_show_bonding_lacp_info_port_id,
6299 /* *** SHOW NIC BONDING CONFIGURATION *** */
6300 struct cmd_show_bonding_config_result {
6301 cmdline_fixed_string_t show;
6302 cmdline_fixed_string_t bonding;
6303 cmdline_fixed_string_t config;
6307 static void cmd_show_bonding_config_parsed(void *parsed_result,
6308 __rte_unused struct cmdline *cl,
6309 __rte_unused void *data)
6311 struct cmd_show_bonding_config_result *res = parsed_result;
6312 int bonding_mode, agg_mode;
6313 portid_t slaves[RTE_MAX_ETHPORTS];
6314 int num_slaves, num_active_slaves;
6317 portid_t port_id = res->port_id;
6319 /* Display the bonding mode.*/
6320 bonding_mode = rte_eth_bond_mode_get(port_id);
6321 if (bonding_mode < 0) {
6322 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6326 printf("\tBonding mode: %d\n", bonding_mode);
6328 if (bonding_mode == BONDING_MODE_BALANCE ||
6329 bonding_mode == BONDING_MODE_8023AD) {
6330 int balance_xmit_policy;
6332 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6333 if (balance_xmit_policy < 0) {
6335 "\tFailed to get balance xmit policy for port = %d\n",
6339 printf("\tBalance Xmit Policy: ");
6341 switch (balance_xmit_policy) {
6342 case BALANCE_XMIT_POLICY_LAYER2:
6343 printf("BALANCE_XMIT_POLICY_LAYER2");
6345 case BALANCE_XMIT_POLICY_LAYER23:
6346 printf("BALANCE_XMIT_POLICY_LAYER23");
6348 case BALANCE_XMIT_POLICY_LAYER34:
6349 printf("BALANCE_XMIT_POLICY_LAYER34");
6356 if (bonding_mode == BONDING_MODE_8023AD) {
6357 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6358 printf("\tIEEE802.3AD Aggregator Mode: ");
6361 printf("bandwidth");
6373 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6375 if (num_slaves < 0) {
6376 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6380 if (num_slaves > 0) {
6381 printf("\tSlaves (%d): [", num_slaves);
6382 for (i = 0; i < num_slaves - 1; i++)
6383 printf("%d ", slaves[i]);
6385 printf("%d]\n", slaves[num_slaves - 1]);
6387 printf("\tSlaves: []\n");
6391 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6394 if (num_active_slaves < 0) {
6396 "\tFailed to get active slave list for port = %d\n",
6400 if (num_active_slaves > 0) {
6401 printf("\tActive Slaves (%d): [", num_active_slaves);
6402 for (i = 0; i < num_active_slaves - 1; i++)
6403 printf("%d ", slaves[i]);
6405 printf("%d]\n", slaves[num_active_slaves - 1]);
6408 printf("\tActive Slaves: []\n");
6412 primary_id = rte_eth_bond_primary_get(port_id);
6413 if (primary_id < 0) {
6414 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6418 printf("\tPrimary: [%d]\n", primary_id);
6422 cmdline_parse_token_string_t cmd_showbonding_config_show =
6423 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6425 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6426 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6427 bonding, "bonding");
6428 cmdline_parse_token_string_t cmd_showbonding_config_config =
6429 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6431 cmdline_parse_token_num_t cmd_showbonding_config_port =
6432 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6433 port_id, RTE_UINT16);
6435 cmdline_parse_inst_t cmd_show_bonding_config = {
6436 .f = cmd_show_bonding_config_parsed,
6437 .help_str = "show bonding config <port_id>: "
6438 "Show the bonding config for port_id",
6441 (void *)&cmd_showbonding_config_show,
6442 (void *)&cmd_showbonding_config_bonding,
6443 (void *)&cmd_showbonding_config_config,
6444 (void *)&cmd_showbonding_config_port,
6449 /* *** SET BONDING PRIMARY *** */
6450 struct cmd_set_bonding_primary_result {
6451 cmdline_fixed_string_t set;
6452 cmdline_fixed_string_t bonding;
6453 cmdline_fixed_string_t primary;
6458 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6459 __rte_unused struct cmdline *cl,
6460 __rte_unused void *data)
6462 struct cmd_set_bonding_primary_result *res = parsed_result;
6463 portid_t master_port_id = res->port_id;
6464 portid_t slave_port_id = res->slave_id;
6466 /* Set the primary slave for a bonded device. */
6467 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6468 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6475 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6476 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6478 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6480 bonding, "bonding");
6481 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6483 primary, "primary");
6484 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6485 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6486 slave_id, RTE_UINT16);
6487 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6488 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6489 port_id, RTE_UINT16);
6491 cmdline_parse_inst_t cmd_set_bonding_primary = {
6492 .f = cmd_set_bonding_primary_parsed,
6493 .help_str = "set bonding primary <slave_id> <port_id>: "
6494 "Set the primary slave for port_id",
6497 (void *)&cmd_setbonding_primary_set,
6498 (void *)&cmd_setbonding_primary_bonding,
6499 (void *)&cmd_setbonding_primary_primary,
6500 (void *)&cmd_setbonding_primary_slave,
6501 (void *)&cmd_setbonding_primary_port,
6506 /* *** ADD SLAVE *** */
6507 struct cmd_add_bonding_slave_result {
6508 cmdline_fixed_string_t add;
6509 cmdline_fixed_string_t bonding;
6510 cmdline_fixed_string_t slave;
6515 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6516 __rte_unused struct cmdline *cl,
6517 __rte_unused void *data)
6519 struct cmd_add_bonding_slave_result *res = parsed_result;
6520 portid_t master_port_id = res->port_id;
6521 portid_t slave_port_id = res->slave_id;
6523 /* add the slave for a bonded device. */
6524 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6526 "\t Failed to add slave %d to master port = %d.\n",
6527 slave_port_id, master_port_id);
6531 set_port_slave_flag(slave_port_id);
6534 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6535 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6537 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6538 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6539 bonding, "bonding");
6540 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6541 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6543 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6544 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6545 slave_id, RTE_UINT16);
6546 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6547 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6548 port_id, RTE_UINT16);
6550 cmdline_parse_inst_t cmd_add_bonding_slave = {
6551 .f = cmd_add_bonding_slave_parsed,
6552 .help_str = "add bonding slave <slave_id> <port_id>: "
6553 "Add a slave device to a bonded device",
6556 (void *)&cmd_addbonding_slave_add,
6557 (void *)&cmd_addbonding_slave_bonding,
6558 (void *)&cmd_addbonding_slave_slave,
6559 (void *)&cmd_addbonding_slave_slaveid,
6560 (void *)&cmd_addbonding_slave_port,
6565 /* *** REMOVE SLAVE *** */
6566 struct cmd_remove_bonding_slave_result {
6567 cmdline_fixed_string_t remove;
6568 cmdline_fixed_string_t bonding;
6569 cmdline_fixed_string_t slave;
6574 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6575 __rte_unused struct cmdline *cl,
6576 __rte_unused void *data)
6578 struct cmd_remove_bonding_slave_result *res = parsed_result;
6579 portid_t master_port_id = res->port_id;
6580 portid_t slave_port_id = res->slave_id;
6582 /* remove the slave from a bonded device. */
6583 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6585 "\t Failed to remove slave %d from master port = %d.\n",
6586 slave_port_id, master_port_id);
6590 clear_port_slave_flag(slave_port_id);
6593 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6594 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6596 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6597 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6598 bonding, "bonding");
6599 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6600 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6602 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6603 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6604 slave_id, RTE_UINT16);
6605 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6606 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6607 port_id, RTE_UINT16);
6609 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6610 .f = cmd_remove_bonding_slave_parsed,
6611 .help_str = "remove bonding slave <slave_id> <port_id>: "
6612 "Remove a slave device from a bonded device",
6615 (void *)&cmd_removebonding_slave_remove,
6616 (void *)&cmd_removebonding_slave_bonding,
6617 (void *)&cmd_removebonding_slave_slave,
6618 (void *)&cmd_removebonding_slave_slaveid,
6619 (void *)&cmd_removebonding_slave_port,
6624 /* *** CREATE BONDED DEVICE *** */
6625 struct cmd_create_bonded_device_result {
6626 cmdline_fixed_string_t create;
6627 cmdline_fixed_string_t bonded;
6628 cmdline_fixed_string_t device;
6633 static int bond_dev_num = 0;
6635 static void cmd_create_bonded_device_parsed(void *parsed_result,
6636 __rte_unused struct cmdline *cl,
6637 __rte_unused void *data)
6639 struct cmd_create_bonded_device_result *res = parsed_result;
6640 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6644 if (test_done == 0) {
6645 fprintf(stderr, "Please stop forwarding first\n");
6649 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6652 /* Create a new bonded device. */
6653 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6655 fprintf(stderr, "\t Failed to create bonded device.\n");
6658 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6661 /* Update number of ports */
6662 nb_ports = rte_eth_dev_count_avail();
6663 reconfig(port_id, res->socket);
6664 ret = rte_eth_promiscuous_enable(port_id);
6667 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6668 port_id, rte_strerror(-ret));
6670 ports[port_id].bond_flag = 1;
6671 ports[port_id].need_setup = 0;
6672 ports[port_id].port_status = RTE_PORT_STOPPED;
6677 cmdline_parse_token_string_t cmd_createbonded_device_create =
6678 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6680 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6681 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6683 cmdline_parse_token_string_t cmd_createbonded_device_device =
6684 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6686 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6687 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6689 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6690 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6693 cmdline_parse_inst_t cmd_create_bonded_device = {
6694 .f = cmd_create_bonded_device_parsed,
6695 .help_str = "create bonded device <mode> <socket>: "
6696 "Create a new bonded device with specific bonding mode and socket",
6699 (void *)&cmd_createbonded_device_create,
6700 (void *)&cmd_createbonded_device_bonded,
6701 (void *)&cmd_createbonded_device_device,
6702 (void *)&cmd_createbonded_device_mode,
6703 (void *)&cmd_createbonded_device_socket,
6708 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6709 struct cmd_set_bond_mac_addr_result {
6710 cmdline_fixed_string_t set;
6711 cmdline_fixed_string_t bonding;
6712 cmdline_fixed_string_t mac_addr;
6714 struct rte_ether_addr address;
6717 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6718 __rte_unused struct cmdline *cl,
6719 __rte_unused void *data)
6721 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6724 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6727 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6729 /* check the return value and print it if is < 0 */
6731 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6735 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6736 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6737 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6738 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6740 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6743 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6744 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6745 port_num, RTE_UINT16);
6746 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6747 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6749 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6750 .f = cmd_set_bond_mac_addr_parsed,
6752 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6754 (void *)&cmd_set_bond_mac_addr_set,
6755 (void *)&cmd_set_bond_mac_addr_bonding,
6756 (void *)&cmd_set_bond_mac_addr_mac,
6757 (void *)&cmd_set_bond_mac_addr_portnum,
6758 (void *)&cmd_set_bond_mac_addr_addr,
6764 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6765 struct cmd_set_bond_mon_period_result {
6766 cmdline_fixed_string_t set;
6767 cmdline_fixed_string_t bonding;
6768 cmdline_fixed_string_t mon_period;
6773 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6774 __rte_unused struct cmdline *cl,
6775 __rte_unused void *data)
6777 struct cmd_set_bond_mon_period_result *res = parsed_result;
6780 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6782 /* check the return value and print it if is < 0 */
6784 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6788 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6789 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6791 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6792 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6793 bonding, "bonding");
6794 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6795 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6796 mon_period, "mon_period");
6797 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6798 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6799 port_num, RTE_UINT16);
6800 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6801 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6802 period_ms, RTE_UINT32);
6804 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6805 .f = cmd_set_bond_mon_period_parsed,
6807 .help_str = "set bonding mon_period <port_id> <period_ms>",
6809 (void *)&cmd_set_bond_mon_period_set,
6810 (void *)&cmd_set_bond_mon_period_bonding,
6811 (void *)&cmd_set_bond_mon_period_mon_period,
6812 (void *)&cmd_set_bond_mon_period_portnum,
6813 (void *)&cmd_set_bond_mon_period_period_ms,
6820 struct cmd_set_bonding_agg_mode_policy_result {
6821 cmdline_fixed_string_t set;
6822 cmdline_fixed_string_t bonding;
6823 cmdline_fixed_string_t agg_mode;
6825 cmdline_fixed_string_t policy;
6830 cmd_set_bonding_agg_mode(void *parsed_result,
6831 __rte_unused struct cmdline *cl,
6832 __rte_unused void *data)
6834 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6835 uint8_t policy = AGG_BANDWIDTH;
6837 if (!strcmp(res->policy, "bandwidth"))
6838 policy = AGG_BANDWIDTH;
6839 else if (!strcmp(res->policy, "stable"))
6840 policy = AGG_STABLE;
6841 else if (!strcmp(res->policy, "count"))
6844 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6848 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6849 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6851 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6852 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6853 bonding, "bonding");
6855 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6856 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6857 agg_mode, "agg_mode");
6859 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6860 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6861 port_num, RTE_UINT16);
6863 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6864 TOKEN_STRING_INITIALIZER(
6865 struct cmd_set_bonding_balance_xmit_policy_result,
6866 policy, "stable#bandwidth#count");
6868 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6869 .f = cmd_set_bonding_agg_mode,
6871 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6873 (void *)&cmd_set_bonding_agg_mode_set,
6874 (void *)&cmd_set_bonding_agg_mode_bonding,
6875 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6876 (void *)&cmd_set_bonding_agg_mode_portnum,
6877 (void *)&cmd_set_bonding_agg_mode_policy_string,
6883 #endif /* RTE_NET_BOND */
6885 /* *** SET FORWARDING MODE *** */
6886 struct cmd_set_fwd_mode_result {
6887 cmdline_fixed_string_t set;
6888 cmdline_fixed_string_t fwd;
6889 cmdline_fixed_string_t mode;
6892 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6893 __rte_unused struct cmdline *cl,
6894 __rte_unused void *data)
6896 struct cmd_set_fwd_mode_result *res = parsed_result;
6899 set_pkt_forwarding_mode(res->mode);
6902 cmdline_parse_token_string_t cmd_setfwd_set =
6903 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6904 cmdline_parse_token_string_t cmd_setfwd_fwd =
6905 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6906 cmdline_parse_token_string_t cmd_setfwd_mode =
6907 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6908 "" /* defined at init */);
6910 cmdline_parse_inst_t cmd_set_fwd_mode = {
6911 .f = cmd_set_fwd_mode_parsed,
6913 .help_str = NULL, /* defined at init */
6915 (void *)&cmd_setfwd_set,
6916 (void *)&cmd_setfwd_fwd,
6917 (void *)&cmd_setfwd_mode,
6922 static void cmd_set_fwd_mode_init(void)
6925 static char token[128];
6926 static char help[256];
6927 cmdline_parse_token_string_t *token_struct;
6929 modes = list_pkt_forwarding_modes();
6930 snprintf(help, sizeof(help), "set fwd %s: "
6931 "Set packet forwarding mode", modes);
6932 cmd_set_fwd_mode.help_str = help;
6934 /* string token separator is # */
6935 for (c = token; *modes != '\0'; modes++)
6940 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6941 token_struct->string_data.str = token;
6944 /* *** SET RETRY FORWARDING MODE *** */
6945 struct cmd_set_fwd_retry_mode_result {
6946 cmdline_fixed_string_t set;
6947 cmdline_fixed_string_t fwd;
6948 cmdline_fixed_string_t mode;
6949 cmdline_fixed_string_t retry;
6952 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6953 __rte_unused struct cmdline *cl,
6954 __rte_unused void *data)
6956 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6959 set_pkt_forwarding_mode(res->mode);
6962 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6963 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6965 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6966 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6968 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6969 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6971 "" /* defined at init */);
6972 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6973 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6976 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6977 .f = cmd_set_fwd_retry_mode_parsed,
6979 .help_str = NULL, /* defined at init */
6981 (void *)&cmd_setfwd_retry_set,
6982 (void *)&cmd_setfwd_retry_fwd,
6983 (void *)&cmd_setfwd_retry_mode,
6984 (void *)&cmd_setfwd_retry_retry,
6989 static void cmd_set_fwd_retry_mode_init(void)
6992 static char token[128];
6993 static char help[256];
6994 cmdline_parse_token_string_t *token_struct;
6996 modes = list_pkt_forwarding_retry_modes();
6997 snprintf(help, sizeof(help), "set fwd %s retry: "
6998 "Set packet forwarding mode with retry", modes);
6999 cmd_set_fwd_retry_mode.help_str = help;
7001 /* string token separator is # */
7002 for (c = token; *modes != '\0'; modes++)
7007 token_struct = (cmdline_parse_token_string_t *)
7008 cmd_set_fwd_retry_mode.tokens[2];
7009 token_struct->string_data.str = token;
7012 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
7013 struct cmd_set_burst_tx_retry_result {
7014 cmdline_fixed_string_t set;
7015 cmdline_fixed_string_t burst;
7016 cmdline_fixed_string_t tx;
7017 cmdline_fixed_string_t delay;
7019 cmdline_fixed_string_t retry;
7023 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7024 __rte_unused struct cmdline *cl,
7025 __rte_unused void *data)
7027 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7029 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7030 && !strcmp(res->tx, "tx")) {
7031 if (!strcmp(res->delay, "delay"))
7032 burst_tx_delay_time = res->time;
7033 if (!strcmp(res->retry, "retry"))
7034 burst_tx_retry_num = res->retry_num;
7039 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7040 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7041 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7042 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7044 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7045 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7046 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7047 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7048 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7049 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7051 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7052 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7053 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7054 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7057 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7058 .f = cmd_set_burst_tx_retry_parsed,
7059 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7061 (void *)&cmd_set_burst_tx_retry_set,
7062 (void *)&cmd_set_burst_tx_retry_burst,
7063 (void *)&cmd_set_burst_tx_retry_tx,
7064 (void *)&cmd_set_burst_tx_retry_delay,
7065 (void *)&cmd_set_burst_tx_retry_time,
7066 (void *)&cmd_set_burst_tx_retry_retry,
7067 (void *)&cmd_set_burst_tx_retry_retry_num,
7072 /* *** SET PROMISC MODE *** */
7073 struct cmd_set_promisc_mode_result {
7074 cmdline_fixed_string_t set;
7075 cmdline_fixed_string_t promisc;
7076 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7077 uint16_t port_num; /* valid if "allports" argument == 0 */
7078 cmdline_fixed_string_t mode;
7081 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7082 __rte_unused struct cmdline *cl,
7085 struct cmd_set_promisc_mode_result *res = parsed_result;
7089 if (!strcmp(res->mode, "on"))
7096 RTE_ETH_FOREACH_DEV(i)
7097 eth_set_promisc_mode(i, enable);
7099 eth_set_promisc_mode(res->port_num, enable);
7103 cmdline_parse_token_string_t cmd_setpromisc_set =
7104 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7105 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7106 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7108 cmdline_parse_token_string_t cmd_setpromisc_portall =
7109 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7111 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7112 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7114 cmdline_parse_token_string_t cmd_setpromisc_mode =
7115 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7118 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7119 .f = cmd_set_promisc_mode_parsed,
7121 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7123 (void *)&cmd_setpromisc_set,
7124 (void *)&cmd_setpromisc_promisc,
7125 (void *)&cmd_setpromisc_portall,
7126 (void *)&cmd_setpromisc_mode,
7131 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7132 .f = cmd_set_promisc_mode_parsed,
7134 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7136 (void *)&cmd_setpromisc_set,
7137 (void *)&cmd_setpromisc_promisc,
7138 (void *)&cmd_setpromisc_portnum,
7139 (void *)&cmd_setpromisc_mode,
7144 /* *** SET ALLMULTI MODE *** */
7145 struct cmd_set_allmulti_mode_result {
7146 cmdline_fixed_string_t set;
7147 cmdline_fixed_string_t allmulti;
7148 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7149 uint16_t port_num; /* valid if "allports" argument == 0 */
7150 cmdline_fixed_string_t mode;
7153 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7154 __rte_unused struct cmdline *cl,
7157 struct cmd_set_allmulti_mode_result *res = parsed_result;
7161 if (!strcmp(res->mode, "on"))
7168 RTE_ETH_FOREACH_DEV(i) {
7169 eth_set_allmulticast_mode(i, enable);
7173 eth_set_allmulticast_mode(res->port_num, enable);
7177 cmdline_parse_token_string_t cmd_setallmulti_set =
7178 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7179 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7180 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7182 cmdline_parse_token_string_t cmd_setallmulti_portall =
7183 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7185 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7186 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7188 cmdline_parse_token_string_t cmd_setallmulti_mode =
7189 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7192 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7193 .f = cmd_set_allmulti_mode_parsed,
7195 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7197 (void *)&cmd_setallmulti_set,
7198 (void *)&cmd_setallmulti_allmulti,
7199 (void *)&cmd_setallmulti_portall,
7200 (void *)&cmd_setallmulti_mode,
7205 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7206 .f = cmd_set_allmulti_mode_parsed,
7208 .help_str = "set allmulti <port_id> on|off: "
7209 "Set allmulti mode on port_id",
7211 (void *)&cmd_setallmulti_set,
7212 (void *)&cmd_setallmulti_allmulti,
7213 (void *)&cmd_setallmulti_portnum,
7214 (void *)&cmd_setallmulti_mode,
7219 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7220 struct cmd_link_flow_ctrl_show {
7221 cmdline_fixed_string_t show;
7222 cmdline_fixed_string_t port;
7224 cmdline_fixed_string_t flow_ctrl;
7227 cmdline_parse_token_string_t cmd_lfc_show_show =
7228 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7230 cmdline_parse_token_string_t cmd_lfc_show_port =
7231 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7233 cmdline_parse_token_num_t cmd_lfc_show_portid =
7234 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7235 port_id, RTE_UINT16);
7236 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7237 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7238 flow_ctrl, "flow_ctrl");
7241 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7242 __rte_unused struct cmdline *cl,
7243 __rte_unused void *data)
7245 struct cmd_link_flow_ctrl_show *res = parsed_result;
7246 static const char *info_border = "*********************";
7247 struct rte_eth_fc_conf fc_conf;
7248 bool rx_fc_en = false;
7249 bool tx_fc_en = false;
7252 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7255 "Failed to get current flow ctrl information: err = %d\n",
7260 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7262 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7265 printf("\n%s Flow control infos for port %-2d %s\n",
7266 info_border, res->port_id, info_border);
7267 printf("FC mode:\n");
7268 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7269 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7270 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7271 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7272 printf("High waterline: 0x%x\n", fc_conf.high_water);
7273 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7274 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7275 printf("Forward MAC control frames: %s\n",
7276 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7277 printf("\n%s************** End ***********%s\n",
7278 info_border, info_border);
7281 cmdline_parse_inst_t cmd_link_flow_control_show = {
7282 .f = cmd_link_flow_ctrl_show_parsed,
7284 .help_str = "show port <port_id> flow_ctrl",
7286 (void *)&cmd_lfc_show_show,
7287 (void *)&cmd_lfc_show_port,
7288 (void *)&cmd_lfc_show_portid,
7289 (void *)&cmd_lfc_show_flow_ctrl,
7294 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7295 struct cmd_link_flow_ctrl_set_result {
7296 cmdline_fixed_string_t set;
7297 cmdline_fixed_string_t flow_ctrl;
7298 cmdline_fixed_string_t rx;
7299 cmdline_fixed_string_t rx_lfc_mode;
7300 cmdline_fixed_string_t tx;
7301 cmdline_fixed_string_t tx_lfc_mode;
7302 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7303 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7304 cmdline_fixed_string_t autoneg_str;
7305 cmdline_fixed_string_t autoneg;
7306 cmdline_fixed_string_t hw_str;
7307 uint32_t high_water;
7308 cmdline_fixed_string_t lw_str;
7310 cmdline_fixed_string_t pt_str;
7311 uint16_t pause_time;
7312 cmdline_fixed_string_t xon_str;
7317 cmdline_parse_token_string_t cmd_lfc_set_set =
7318 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7320 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7321 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7322 flow_ctrl, "flow_ctrl");
7323 cmdline_parse_token_string_t cmd_lfc_set_rx =
7324 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7326 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7327 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7328 rx_lfc_mode, "on#off");
7329 cmdline_parse_token_string_t cmd_lfc_set_tx =
7330 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7332 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7333 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7334 tx_lfc_mode, "on#off");
7335 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7336 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7337 hw_str, "high_water");
7338 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7339 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7340 high_water, RTE_UINT32);
7341 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7342 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7343 lw_str, "low_water");
7344 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7345 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7346 low_water, RTE_UINT32);
7347 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7348 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7349 pt_str, "pause_time");
7350 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7351 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7352 pause_time, RTE_UINT16);
7353 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7354 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7355 xon_str, "send_xon");
7356 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7357 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7358 send_xon, RTE_UINT16);
7359 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7360 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7361 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7362 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7363 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7364 mac_ctrl_frame_fwd_mode, "on#off");
7365 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7366 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7367 autoneg_str, "autoneg");
7368 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7369 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7371 cmdline_parse_token_num_t cmd_lfc_set_portid =
7372 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7373 port_id, RTE_UINT16);
7375 /* forward declaration */
7377 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7380 cmdline_parse_inst_t cmd_link_flow_control_set = {
7381 .f = cmd_link_flow_ctrl_set_parsed,
7383 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7384 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7385 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7387 (void *)&cmd_lfc_set_set,
7388 (void *)&cmd_lfc_set_flow_ctrl,
7389 (void *)&cmd_lfc_set_rx,
7390 (void *)&cmd_lfc_set_rx_mode,
7391 (void *)&cmd_lfc_set_tx,
7392 (void *)&cmd_lfc_set_tx_mode,
7393 (void *)&cmd_lfc_set_high_water,
7394 (void *)&cmd_lfc_set_low_water,
7395 (void *)&cmd_lfc_set_pause_time,
7396 (void *)&cmd_lfc_set_send_xon,
7397 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7398 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7399 (void *)&cmd_lfc_set_autoneg_str,
7400 (void *)&cmd_lfc_set_autoneg,
7401 (void *)&cmd_lfc_set_portid,
7406 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7407 .f = cmd_link_flow_ctrl_set_parsed,
7408 .data = (void *)&cmd_link_flow_control_set_rx,
7409 .help_str = "set flow_ctrl rx on|off <port_id>: "
7410 "Change rx flow control parameter",
7412 (void *)&cmd_lfc_set_set,
7413 (void *)&cmd_lfc_set_flow_ctrl,
7414 (void *)&cmd_lfc_set_rx,
7415 (void *)&cmd_lfc_set_rx_mode,
7416 (void *)&cmd_lfc_set_portid,
7421 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7422 .f = cmd_link_flow_ctrl_set_parsed,
7423 .data = (void *)&cmd_link_flow_control_set_tx,
7424 .help_str = "set flow_ctrl tx on|off <port_id>: "
7425 "Change tx flow control parameter",
7427 (void *)&cmd_lfc_set_set,
7428 (void *)&cmd_lfc_set_flow_ctrl,
7429 (void *)&cmd_lfc_set_tx,
7430 (void *)&cmd_lfc_set_tx_mode,
7431 (void *)&cmd_lfc_set_portid,
7436 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7437 .f = cmd_link_flow_ctrl_set_parsed,
7438 .data = (void *)&cmd_link_flow_control_set_hw,
7439 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7440 "Change high water flow control parameter",
7442 (void *)&cmd_lfc_set_set,
7443 (void *)&cmd_lfc_set_flow_ctrl,
7444 (void *)&cmd_lfc_set_high_water_str,
7445 (void *)&cmd_lfc_set_high_water,
7446 (void *)&cmd_lfc_set_portid,
7451 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7452 .f = cmd_link_flow_ctrl_set_parsed,
7453 .data = (void *)&cmd_link_flow_control_set_lw,
7454 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7455 "Change low water flow control parameter",
7457 (void *)&cmd_lfc_set_set,
7458 (void *)&cmd_lfc_set_flow_ctrl,
7459 (void *)&cmd_lfc_set_low_water_str,
7460 (void *)&cmd_lfc_set_low_water,
7461 (void *)&cmd_lfc_set_portid,
7466 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7467 .f = cmd_link_flow_ctrl_set_parsed,
7468 .data = (void *)&cmd_link_flow_control_set_pt,
7469 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7470 "Change pause time flow control parameter",
7472 (void *)&cmd_lfc_set_set,
7473 (void *)&cmd_lfc_set_flow_ctrl,
7474 (void *)&cmd_lfc_set_pause_time_str,
7475 (void *)&cmd_lfc_set_pause_time,
7476 (void *)&cmd_lfc_set_portid,
7481 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7482 .f = cmd_link_flow_ctrl_set_parsed,
7483 .data = (void *)&cmd_link_flow_control_set_xon,
7484 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7485 "Change send_xon flow control parameter",
7487 (void *)&cmd_lfc_set_set,
7488 (void *)&cmd_lfc_set_flow_ctrl,
7489 (void *)&cmd_lfc_set_send_xon_str,
7490 (void *)&cmd_lfc_set_send_xon,
7491 (void *)&cmd_lfc_set_portid,
7496 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7497 .f = cmd_link_flow_ctrl_set_parsed,
7498 .data = (void *)&cmd_link_flow_control_set_macfwd,
7499 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7500 "Change mac ctrl fwd flow control parameter",
7502 (void *)&cmd_lfc_set_set,
7503 (void *)&cmd_lfc_set_flow_ctrl,
7504 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7505 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7506 (void *)&cmd_lfc_set_portid,
7511 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7512 .f = cmd_link_flow_ctrl_set_parsed,
7513 .data = (void *)&cmd_link_flow_control_set_autoneg,
7514 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7515 "Change autoneg flow control parameter",
7517 (void *)&cmd_lfc_set_set,
7518 (void *)&cmd_lfc_set_flow_ctrl,
7519 (void *)&cmd_lfc_set_autoneg_str,
7520 (void *)&cmd_lfc_set_autoneg,
7521 (void *)&cmd_lfc_set_portid,
7527 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7528 __rte_unused struct cmdline *cl,
7531 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7532 cmdline_parse_inst_t *cmd = data;
7533 struct rte_eth_fc_conf fc_conf;
7539 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7540 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7541 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7542 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7544 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7545 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7548 /* Partial command line, retrieve current configuration */
7550 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7553 "cannot get current flow ctrl parameters, return code = %d\n",
7558 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7559 (fc_conf.mode == RTE_ETH_FC_FULL))
7561 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7562 (fc_conf.mode == RTE_ETH_FC_FULL))
7566 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7567 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7569 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7570 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7572 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7574 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7575 fc_conf.high_water = res->high_water;
7577 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7578 fc_conf.low_water = res->low_water;
7580 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7581 fc_conf.pause_time = res->pause_time;
7583 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7584 fc_conf.send_xon = res->send_xon;
7586 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7587 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7588 fc_conf.mac_ctrl_frame_fwd = 1;
7590 fc_conf.mac_ctrl_frame_fwd = 0;
7593 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7594 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7596 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7599 "bad flow control parameter, return code = %d\n",
7603 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7604 struct cmd_priority_flow_ctrl_set_result {
7605 cmdline_fixed_string_t set;
7606 cmdline_fixed_string_t pfc_ctrl;
7607 cmdline_fixed_string_t rx;
7608 cmdline_fixed_string_t rx_pfc_mode;
7609 cmdline_fixed_string_t tx;
7610 cmdline_fixed_string_t tx_pfc_mode;
7611 uint32_t high_water;
7613 uint16_t pause_time;
7619 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7620 __rte_unused struct cmdline *cl,
7621 __rte_unused void *data)
7623 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7624 struct rte_eth_pfc_conf pfc_conf;
7625 int rx_fc_enable, tx_fc_enable;
7629 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7630 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7631 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7632 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7634 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7635 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7638 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7639 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7640 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7641 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7642 pfc_conf.fc.high_water = res->high_water;
7643 pfc_conf.fc.low_water = res->low_water;
7644 pfc_conf.fc.pause_time = res->pause_time;
7645 pfc_conf.priority = res->priority;
7647 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7650 "bad priority flow control parameter, return code = %d\n",
7654 cmdline_parse_token_string_t cmd_pfc_set_set =
7655 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7657 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7658 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7659 pfc_ctrl, "pfc_ctrl");
7660 cmdline_parse_token_string_t cmd_pfc_set_rx =
7661 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7663 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7664 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7665 rx_pfc_mode, "on#off");
7666 cmdline_parse_token_string_t cmd_pfc_set_tx =
7667 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7669 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7670 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7671 tx_pfc_mode, "on#off");
7672 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7673 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7674 high_water, RTE_UINT32);
7675 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7676 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7677 low_water, RTE_UINT32);
7678 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7679 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7680 pause_time, RTE_UINT16);
7681 cmdline_parse_token_num_t cmd_pfc_set_priority =
7682 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7683 priority, RTE_UINT8);
7684 cmdline_parse_token_num_t cmd_pfc_set_portid =
7685 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7686 port_id, RTE_UINT16);
7688 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7689 .f = cmd_priority_flow_ctrl_set_parsed,
7691 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7692 "<pause_time> <priority> <port_id>: "
7693 "Configure the Ethernet priority flow control",
7695 (void *)&cmd_pfc_set_set,
7696 (void *)&cmd_pfc_set_flow_ctrl,
7697 (void *)&cmd_pfc_set_rx,
7698 (void *)&cmd_pfc_set_rx_mode,
7699 (void *)&cmd_pfc_set_tx,
7700 (void *)&cmd_pfc_set_tx_mode,
7701 (void *)&cmd_pfc_set_high_water,
7702 (void *)&cmd_pfc_set_low_water,
7703 (void *)&cmd_pfc_set_pause_time,
7704 (void *)&cmd_pfc_set_priority,
7705 (void *)&cmd_pfc_set_portid,
7710 struct cmd_queue_priority_flow_ctrl_set_result {
7711 cmdline_fixed_string_t set;
7712 cmdline_fixed_string_t pfc_queue_ctrl;
7714 cmdline_fixed_string_t rx;
7715 cmdline_fixed_string_t rx_pfc_mode;
7718 cmdline_fixed_string_t tx;
7719 cmdline_fixed_string_t tx_pfc_mode;
7722 uint16_t pause_time;
7726 cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7727 __rte_unused struct cmdline *cl,
7728 __rte_unused void *data)
7730 struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7731 struct rte_eth_pfc_queue_conf pfc_queue_conf;
7732 int rx_fc_enable, tx_fc_enable;
7736 * Rx on/off, flow control is enabled/disabled on RX side. This can
7737 * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7738 * side. Tx on/off, flow control is enabled/disabled on TX side. This
7739 * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7742 static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7743 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7744 {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7747 memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7748 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7749 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7750 pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7751 pfc_queue_conf.rx_pause.tc = res->tx_tc;
7752 pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7753 pfc_queue_conf.tx_pause.tc = res->rx_tc;
7754 pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7755 pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7757 ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7761 "bad queue priority flow control parameter, rc = %d\n",
7766 cmdline_parse_token_string_t cmd_q_pfc_set_set =
7767 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7769 cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7770 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7771 pfc_queue_ctrl, "pfc_queue_ctrl");
7772 cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7773 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7774 port_id, RTE_UINT16);
7775 cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7776 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7778 cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7779 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7780 rx_pfc_mode, "on#off");
7781 cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7782 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7783 tx_qid, RTE_UINT16);
7784 cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7785 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7787 cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7788 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7790 cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7791 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7792 tx_pfc_mode, "on#off");
7793 cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7794 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7795 rx_qid, RTE_UINT16);
7796 cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7797 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7799 cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7800 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7801 pause_time, RTE_UINT16);
7803 cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7804 .f = cmd_queue_priority_flow_ctrl_set_parsed,
7806 .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7807 "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7808 "Configure the Ethernet queue priority flow control",
7810 (void *)&cmd_q_pfc_set_set,
7811 (void *)&cmd_q_pfc_set_flow_ctrl,
7812 (void *)&cmd_q_pfc_set_portid,
7813 (void *)&cmd_q_pfc_set_rx,
7814 (void *)&cmd_q_pfc_set_rx_mode,
7815 (void *)&cmd_q_pfc_set_tx_qid,
7816 (void *)&cmd_q_pfc_set_tx_tc,
7817 (void *)&cmd_q_pfc_set_tx,
7818 (void *)&cmd_q_pfc_set_tx_mode,
7819 (void *)&cmd_q_pfc_set_rx_qid,
7820 (void *)&cmd_q_pfc_set_rx_tc,
7821 (void *)&cmd_q_pfc_set_pause_time,
7826 /* *** RESET CONFIGURATION *** */
7827 struct cmd_reset_result {
7828 cmdline_fixed_string_t reset;
7829 cmdline_fixed_string_t def;
7832 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7834 __rte_unused void *data)
7836 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7837 set_def_fwd_config();
7840 cmdline_parse_token_string_t cmd_reset_set =
7841 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7842 cmdline_parse_token_string_t cmd_reset_def =
7843 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7846 cmdline_parse_inst_t cmd_reset = {
7847 .f = cmd_reset_parsed,
7849 .help_str = "set default: Reset default forwarding configuration",
7851 (void *)&cmd_reset_set,
7852 (void *)&cmd_reset_def,
7857 /* *** START FORWARDING *** */
7858 struct cmd_start_result {
7859 cmdline_fixed_string_t start;
7862 cmdline_parse_token_string_t cmd_start_start =
7863 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7865 static void cmd_start_parsed(__rte_unused void *parsed_result,
7866 __rte_unused struct cmdline *cl,
7867 __rte_unused void *data)
7869 start_packet_forwarding(0);
7872 cmdline_parse_inst_t cmd_start = {
7873 .f = cmd_start_parsed,
7875 .help_str = "start: Start packet forwarding",
7877 (void *)&cmd_start_start,
7882 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7883 struct cmd_start_tx_first_result {
7884 cmdline_fixed_string_t start;
7885 cmdline_fixed_string_t tx_first;
7889 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7890 __rte_unused struct cmdline *cl,
7891 __rte_unused void *data)
7893 start_packet_forwarding(1);
7896 cmdline_parse_token_string_t cmd_start_tx_first_start =
7897 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7899 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7900 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7901 tx_first, "tx_first");
7903 cmdline_parse_inst_t cmd_start_tx_first = {
7904 .f = cmd_start_tx_first_parsed,
7906 .help_str = "start tx_first: Start packet forwarding, "
7907 "after sending 1 burst of packets",
7909 (void *)&cmd_start_tx_first_start,
7910 (void *)&cmd_start_tx_first_tx_first,
7915 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7916 struct cmd_start_tx_first_n_result {
7917 cmdline_fixed_string_t start;
7918 cmdline_fixed_string_t tx_first;
7923 cmd_start_tx_first_n_parsed(void *parsed_result,
7924 __rte_unused struct cmdline *cl,
7925 __rte_unused void *data)
7927 struct cmd_start_tx_first_n_result *res = parsed_result;
7929 start_packet_forwarding(res->tx_num);
7932 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7933 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7935 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7936 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7937 tx_first, "tx_first");
7938 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7939 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7940 tx_num, RTE_UINT32);
7942 cmdline_parse_inst_t cmd_start_tx_first_n = {
7943 .f = cmd_start_tx_first_n_parsed,
7945 .help_str = "start tx_first <num>: "
7946 "packet forwarding, after sending <num> bursts of packets",
7948 (void *)&cmd_start_tx_first_n_start,
7949 (void *)&cmd_start_tx_first_n_tx_first,
7950 (void *)&cmd_start_tx_first_n_tx_num,
7955 /* *** SET LINK UP *** */
7956 struct cmd_set_link_up_result {
7957 cmdline_fixed_string_t set;
7958 cmdline_fixed_string_t link_up;
7959 cmdline_fixed_string_t port;
7963 cmdline_parse_token_string_t cmd_set_link_up_set =
7964 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7965 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7966 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7968 cmdline_parse_token_string_t cmd_set_link_up_port =
7969 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7970 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7971 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7974 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7975 __rte_unused struct cmdline *cl,
7976 __rte_unused void *data)
7978 struct cmd_set_link_up_result *res = parsed_result;
7979 dev_set_link_up(res->port_id);
7982 cmdline_parse_inst_t cmd_set_link_up = {
7983 .f = cmd_set_link_up_parsed,
7985 .help_str = "set link-up port <port id>",
7987 (void *)&cmd_set_link_up_set,
7988 (void *)&cmd_set_link_up_link_up,
7989 (void *)&cmd_set_link_up_port,
7990 (void *)&cmd_set_link_up_port_id,
7995 /* *** SET LINK DOWN *** */
7996 struct cmd_set_link_down_result {
7997 cmdline_fixed_string_t set;
7998 cmdline_fixed_string_t link_down;
7999 cmdline_fixed_string_t port;
8003 cmdline_parse_token_string_t cmd_set_link_down_set =
8004 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
8005 cmdline_parse_token_string_t cmd_set_link_down_link_down =
8006 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
8008 cmdline_parse_token_string_t cmd_set_link_down_port =
8009 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
8010 cmdline_parse_token_num_t cmd_set_link_down_port_id =
8011 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
8014 static void cmd_set_link_down_parsed(
8015 __rte_unused void *parsed_result,
8016 __rte_unused struct cmdline *cl,
8017 __rte_unused void *data)
8019 struct cmd_set_link_down_result *res = parsed_result;
8020 dev_set_link_down(res->port_id);
8023 cmdline_parse_inst_t cmd_set_link_down = {
8024 .f = cmd_set_link_down_parsed,
8026 .help_str = "set link-down port <port id>",
8028 (void *)&cmd_set_link_down_set,
8029 (void *)&cmd_set_link_down_link_down,
8030 (void *)&cmd_set_link_down_port,
8031 (void *)&cmd_set_link_down_port_id,
8036 /* *** SHOW CFG *** */
8037 struct cmd_showcfg_result {
8038 cmdline_fixed_string_t show;
8039 cmdline_fixed_string_t cfg;
8040 cmdline_fixed_string_t what;
8043 static void cmd_showcfg_parsed(void *parsed_result,
8044 __rte_unused struct cmdline *cl,
8045 __rte_unused void *data)
8047 struct cmd_showcfg_result *res = parsed_result;
8048 if (!strcmp(res->what, "rxtx"))
8049 rxtx_config_display();
8050 else if (!strcmp(res->what, "cores"))
8051 fwd_lcores_config_display();
8052 else if (!strcmp(res->what, "fwd"))
8053 pkt_fwd_config_display(&cur_fwd_config);
8054 else if (!strcmp(res->what, "rxoffs"))
8055 show_rx_pkt_offsets();
8056 else if (!strcmp(res->what, "rxpkts"))
8057 show_rx_pkt_segments();
8058 else if (!strcmp(res->what, "txpkts"))
8059 show_tx_pkt_segments();
8060 else if (!strcmp(res->what, "txtimes"))
8061 show_tx_pkt_times();
8064 cmdline_parse_token_string_t cmd_showcfg_show =
8065 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
8066 cmdline_parse_token_string_t cmd_showcfg_port =
8067 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
8068 cmdline_parse_token_string_t cmd_showcfg_what =
8069 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
8070 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
8072 cmdline_parse_inst_t cmd_showcfg = {
8073 .f = cmd_showcfg_parsed,
8075 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
8077 (void *)&cmd_showcfg_show,
8078 (void *)&cmd_showcfg_port,
8079 (void *)&cmd_showcfg_what,
8084 /* *** SHOW ALL PORT INFO *** */
8085 struct cmd_showportall_result {
8086 cmdline_fixed_string_t show;
8087 cmdline_fixed_string_t port;
8088 cmdline_fixed_string_t what;
8089 cmdline_fixed_string_t all;
8092 static void cmd_showportall_parsed(void *parsed_result,
8093 __rte_unused struct cmdline *cl,
8094 __rte_unused void *data)
8098 struct cmd_showportall_result *res = parsed_result;
8099 if (!strcmp(res->show, "clear")) {
8100 if (!strcmp(res->what, "stats"))
8101 RTE_ETH_FOREACH_DEV(i)
8103 else if (!strcmp(res->what, "xstats"))
8104 RTE_ETH_FOREACH_DEV(i)
8105 nic_xstats_clear(i);
8106 } else if (!strcmp(res->what, "info"))
8107 RTE_ETH_FOREACH_DEV(i)
8108 port_infos_display(i);
8109 else if (!strcmp(res->what, "summary")) {
8110 port_summary_header_display();
8111 RTE_ETH_FOREACH_DEV(i)
8112 port_summary_display(i);
8114 else if (!strcmp(res->what, "stats"))
8115 RTE_ETH_FOREACH_DEV(i)
8116 nic_stats_display(i);
8117 else if (!strcmp(res->what, "xstats"))
8118 RTE_ETH_FOREACH_DEV(i)
8119 nic_xstats_display(i);
8120 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8121 else if (!strcmp(res->what, "fdir"))
8122 RTE_ETH_FOREACH_DEV(i)
8125 else if (!strcmp(res->what, "dcb_tc"))
8126 RTE_ETH_FOREACH_DEV(i)
8127 port_dcb_info_display(i);
8130 cmdline_parse_token_string_t cmd_showportall_show =
8131 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
8133 cmdline_parse_token_string_t cmd_showportall_port =
8134 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8135 cmdline_parse_token_string_t cmd_showportall_what =
8136 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8137 "info#summary#stats#xstats#fdir#dcb_tc");
8138 cmdline_parse_token_string_t cmd_showportall_all =
8139 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8140 cmdline_parse_inst_t cmd_showportall = {
8141 .f = cmd_showportall_parsed,
8143 .help_str = "show|clear port "
8144 "info|summary|stats|xstats|fdir|dcb_tc all",
8146 (void *)&cmd_showportall_show,
8147 (void *)&cmd_showportall_port,
8148 (void *)&cmd_showportall_what,
8149 (void *)&cmd_showportall_all,
8154 /* *** SHOW PORT INFO *** */
8155 struct cmd_showport_result {
8156 cmdline_fixed_string_t show;
8157 cmdline_fixed_string_t port;
8158 cmdline_fixed_string_t what;
8162 static void cmd_showport_parsed(void *parsed_result,
8163 __rte_unused struct cmdline *cl,
8164 __rte_unused void *data)
8166 struct cmd_showport_result *res = parsed_result;
8167 if (!strcmp(res->show, "clear")) {
8168 if (!strcmp(res->what, "stats"))
8169 nic_stats_clear(res->portnum);
8170 else if (!strcmp(res->what, "xstats"))
8171 nic_xstats_clear(res->portnum);
8172 } else if (!strcmp(res->what, "info"))
8173 port_infos_display(res->portnum);
8174 else if (!strcmp(res->what, "summary")) {
8175 port_summary_header_display();
8176 port_summary_display(res->portnum);
8178 else if (!strcmp(res->what, "stats"))
8179 nic_stats_display(res->portnum);
8180 else if (!strcmp(res->what, "xstats"))
8181 nic_xstats_display(res->portnum);
8182 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8183 else if (!strcmp(res->what, "fdir"))
8184 fdir_get_infos(res->portnum);
8186 else if (!strcmp(res->what, "dcb_tc"))
8187 port_dcb_info_display(res->portnum);
8190 cmdline_parse_token_string_t cmd_showport_show =
8191 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8193 cmdline_parse_token_string_t cmd_showport_port =
8194 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8195 cmdline_parse_token_string_t cmd_showport_what =
8196 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8197 "info#summary#stats#xstats#fdir#dcb_tc");
8198 cmdline_parse_token_num_t cmd_showport_portnum =
8199 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8201 cmdline_parse_inst_t cmd_showport = {
8202 .f = cmd_showport_parsed,
8204 .help_str = "show|clear port "
8205 "info|summary|stats|xstats|fdir|dcb_tc "
8208 (void *)&cmd_showport_show,
8209 (void *)&cmd_showport_port,
8210 (void *)&cmd_showport_what,
8211 (void *)&cmd_showport_portnum,
8216 /* *** show port representors information *** */
8217 struct cmd_representor_info_result {
8218 cmdline_fixed_string_t cmd_show;
8219 cmdline_fixed_string_t cmd_port;
8220 cmdline_fixed_string_t cmd_info;
8221 cmdline_fixed_string_t cmd_keyword;
8226 cmd_representor_info_parsed(void *parsed_result,
8227 __rte_unused struct cmdline *cl,
8228 __rte_unused void *data)
8230 struct cmd_representor_info_result *res = parsed_result;
8231 struct rte_eth_representor_info *info;
8232 struct rte_eth_representor_range *range;
8233 uint32_t range_diff;
8238 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8239 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8243 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8246 "Failed to get the number of representor info ranges for port %hu: %s\n",
8247 res->cmd_pid, rte_strerror(-ret));
8252 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8255 "Failed to allocate memory for representor info for port %hu\n",
8259 info->nb_ranges_alloc = num;
8261 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8264 "Failed to get the representor info for port %hu: %s\n",
8265 res->cmd_pid, rte_strerror(-ret));
8270 printf("Port controller: %hu\n", info->controller);
8271 printf("Port PF: %hu\n", info->pf);
8273 printf("Ranges: %u\n", info->nb_ranges);
8274 for (i = 0; i < info->nb_ranges; i++) {
8275 range = &info->ranges[i];
8276 range_diff = range->id_end - range->id_base;
8278 printf("%u. ", i + 1);
8279 printf("'%s' ", range->name);
8281 printf("[%u-%u]: ", range->id_base, range->id_end);
8283 printf("[%u]: ", range->id_base);
8285 printf("Controller %d, PF %d", range->controller, range->pf);
8287 switch (range->type) {
8288 case RTE_ETH_REPRESENTOR_NONE:
8291 case RTE_ETH_REPRESENTOR_VF:
8293 printf(", VF %d..%d\n", range->vf,
8294 range->vf + range_diff);
8296 printf(", VF %d\n", range->vf);
8298 case RTE_ETH_REPRESENTOR_SF:
8299 printf(", SF %d\n", range->sf);
8301 case RTE_ETH_REPRESENTOR_PF:
8303 printf("..%d\n", range->pf + range_diff);
8308 printf(", UNKNOWN TYPE %d\n", range->type);
8316 cmdline_parse_token_string_t cmd_representor_info_show =
8317 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8319 cmdline_parse_token_string_t cmd_representor_info_port =
8320 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8322 cmdline_parse_token_string_t cmd_representor_info_info =
8323 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8325 cmdline_parse_token_num_t cmd_representor_info_pid =
8326 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8327 cmd_pid, RTE_UINT16);
8328 cmdline_parse_token_string_t cmd_representor_info_keyword =
8329 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8330 cmd_keyword, "representor");
8332 cmdline_parse_inst_t cmd_representor_info = {
8333 .f = cmd_representor_info_parsed,
8335 .help_str = "show port info <port_id> representor",
8337 (void *)&cmd_representor_info_show,
8338 (void *)&cmd_representor_info_port,
8339 (void *)&cmd_representor_info_info,
8340 (void *)&cmd_representor_info_pid,
8341 (void *)&cmd_representor_info_keyword,
8347 /* *** SHOW DEVICE INFO *** */
8348 struct cmd_showdevice_result {
8349 cmdline_fixed_string_t show;
8350 cmdline_fixed_string_t device;
8351 cmdline_fixed_string_t what;
8352 cmdline_fixed_string_t identifier;
8355 static void cmd_showdevice_parsed(void *parsed_result,
8356 __rte_unused struct cmdline *cl,
8357 __rte_unused void *data)
8359 struct cmd_showdevice_result *res = parsed_result;
8360 if (!strcmp(res->what, "info")) {
8361 if (!strcmp(res->identifier, "all"))
8362 device_infos_display(NULL);
8364 device_infos_display(res->identifier);
8368 cmdline_parse_token_string_t cmd_showdevice_show =
8369 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8371 cmdline_parse_token_string_t cmd_showdevice_device =
8372 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8373 cmdline_parse_token_string_t cmd_showdevice_what =
8374 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8376 cmdline_parse_token_string_t cmd_showdevice_identifier =
8377 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8380 cmdline_parse_inst_t cmd_showdevice = {
8381 .f = cmd_showdevice_parsed,
8383 .help_str = "show device info <identifier>|all",
8385 (void *)&cmd_showdevice_show,
8386 (void *)&cmd_showdevice_device,
8387 (void *)&cmd_showdevice_what,
8388 (void *)&cmd_showdevice_identifier,
8393 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8394 struct cmd_showeeprom_result {
8395 cmdline_fixed_string_t show;
8396 cmdline_fixed_string_t port;
8398 cmdline_fixed_string_t type;
8401 static void cmd_showeeprom_parsed(void *parsed_result,
8402 __rte_unused struct cmdline *cl,
8403 __rte_unused void *data)
8405 struct cmd_showeeprom_result *res = parsed_result;
8407 if (!strcmp(res->type, "eeprom"))
8408 port_eeprom_display(res->portnum);
8409 else if (!strcmp(res->type, "module_eeprom"))
8410 port_module_eeprom_display(res->portnum);
8412 fprintf(stderr, "Unknown argument\n");
8415 cmdline_parse_token_string_t cmd_showeeprom_show =
8416 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8417 cmdline_parse_token_string_t cmd_showeeprom_port =
8418 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8419 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8420 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8422 cmdline_parse_token_string_t cmd_showeeprom_type =
8423 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8425 cmdline_parse_inst_t cmd_showeeprom = {
8426 .f = cmd_showeeprom_parsed,
8428 .help_str = "show port <port_id> module_eeprom|eeprom",
8430 (void *)&cmd_showeeprom_show,
8431 (void *)&cmd_showeeprom_port,
8432 (void *)&cmd_showeeprom_portnum,
8433 (void *)&cmd_showeeprom_type,
8438 /* *** SHOW QUEUE INFO *** */
8439 struct cmd_showqueue_result {
8440 cmdline_fixed_string_t show;
8441 cmdline_fixed_string_t type;
8442 cmdline_fixed_string_t what;
8448 cmd_showqueue_parsed(void *parsed_result,
8449 __rte_unused struct cmdline *cl,
8450 __rte_unused void *data)
8452 struct cmd_showqueue_result *res = parsed_result;
8454 if (!strcmp(res->type, "rxq"))
8455 rx_queue_infos_display(res->portnum, res->queuenum);
8456 else if (!strcmp(res->type, "txq"))
8457 tx_queue_infos_display(res->portnum, res->queuenum);
8460 cmdline_parse_token_string_t cmd_showqueue_show =
8461 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8462 cmdline_parse_token_string_t cmd_showqueue_type =
8463 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8464 cmdline_parse_token_string_t cmd_showqueue_what =
8465 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8466 cmdline_parse_token_num_t cmd_showqueue_portnum =
8467 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8469 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8470 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8473 cmdline_parse_inst_t cmd_showqueue = {
8474 .f = cmd_showqueue_parsed,
8476 .help_str = "show rxq|txq info <port_id> <queue_id>",
8478 (void *)&cmd_showqueue_show,
8479 (void *)&cmd_showqueue_type,
8480 (void *)&cmd_showqueue_what,
8481 (void *)&cmd_showqueue_portnum,
8482 (void *)&cmd_showqueue_queuenum,
8487 /* show/clear fwd engine statistics */
8489 cmdline_fixed_string_t action;
8490 cmdline_fixed_string_t fwd;
8491 cmdline_fixed_string_t stats;
8492 cmdline_fixed_string_t all;
8495 cmdline_parse_token_string_t cmd_fwd_action =
8496 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8497 cmdline_parse_token_string_t cmd_fwd_fwd =
8498 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8499 cmdline_parse_token_string_t cmd_fwd_stats =
8500 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8501 cmdline_parse_token_string_t cmd_fwd_all =
8502 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8505 cmd_showfwdall_parsed(void *parsed_result,
8506 __rte_unused struct cmdline *cl,
8507 __rte_unused void *data)
8509 struct fwd_result *res = parsed_result;
8511 if (!strcmp(res->action, "show"))
8512 fwd_stats_display();
8517 static cmdline_parse_inst_t cmd_showfwdall = {
8518 .f = cmd_showfwdall_parsed,
8520 .help_str = "show|clear fwd stats all",
8522 (void *)&cmd_fwd_action,
8523 (void *)&cmd_fwd_fwd,
8524 (void *)&cmd_fwd_stats,
8525 (void *)&cmd_fwd_all,
8530 /* *** READ PORT REGISTER *** */
8531 struct cmd_read_reg_result {
8532 cmdline_fixed_string_t read;
8533 cmdline_fixed_string_t reg;
8539 cmd_read_reg_parsed(void *parsed_result,
8540 __rte_unused struct cmdline *cl,
8541 __rte_unused void *data)
8543 struct cmd_read_reg_result *res = parsed_result;
8544 port_reg_display(res->port_id, res->reg_off);
8547 cmdline_parse_token_string_t cmd_read_reg_read =
8548 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8549 cmdline_parse_token_string_t cmd_read_reg_reg =
8550 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8551 cmdline_parse_token_num_t cmd_read_reg_port_id =
8552 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8553 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8554 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8556 cmdline_parse_inst_t cmd_read_reg = {
8557 .f = cmd_read_reg_parsed,
8559 .help_str = "read reg <port_id> <reg_off>",
8561 (void *)&cmd_read_reg_read,
8562 (void *)&cmd_read_reg_reg,
8563 (void *)&cmd_read_reg_port_id,
8564 (void *)&cmd_read_reg_reg_off,
8569 /* *** READ PORT REGISTER BIT FIELD *** */
8570 struct cmd_read_reg_bit_field_result {
8571 cmdline_fixed_string_t read;
8572 cmdline_fixed_string_t regfield;
8580 cmd_read_reg_bit_field_parsed(void *parsed_result,
8581 __rte_unused struct cmdline *cl,
8582 __rte_unused void *data)
8584 struct cmd_read_reg_bit_field_result *res = parsed_result;
8585 port_reg_bit_field_display(res->port_id, res->reg_off,
8586 res->bit1_pos, res->bit2_pos);
8589 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8590 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8592 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8593 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8594 regfield, "regfield");
8595 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8596 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8598 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8599 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8601 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8602 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8604 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8605 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8608 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8609 .f = cmd_read_reg_bit_field_parsed,
8611 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8612 "Read register bit field between bit_x and bit_y included",
8614 (void *)&cmd_read_reg_bit_field_read,
8615 (void *)&cmd_read_reg_bit_field_regfield,
8616 (void *)&cmd_read_reg_bit_field_port_id,
8617 (void *)&cmd_read_reg_bit_field_reg_off,
8618 (void *)&cmd_read_reg_bit_field_bit1_pos,
8619 (void *)&cmd_read_reg_bit_field_bit2_pos,
8624 /* *** READ PORT REGISTER BIT *** */
8625 struct cmd_read_reg_bit_result {
8626 cmdline_fixed_string_t read;
8627 cmdline_fixed_string_t regbit;
8634 cmd_read_reg_bit_parsed(void *parsed_result,
8635 __rte_unused struct cmdline *cl,
8636 __rte_unused void *data)
8638 struct cmd_read_reg_bit_result *res = parsed_result;
8639 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8642 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8643 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8644 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8645 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8647 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8648 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8650 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8651 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8653 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8654 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8657 cmdline_parse_inst_t cmd_read_reg_bit = {
8658 .f = cmd_read_reg_bit_parsed,
8660 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8662 (void *)&cmd_read_reg_bit_read,
8663 (void *)&cmd_read_reg_bit_regbit,
8664 (void *)&cmd_read_reg_bit_port_id,
8665 (void *)&cmd_read_reg_bit_reg_off,
8666 (void *)&cmd_read_reg_bit_bit_pos,
8671 /* *** WRITE PORT REGISTER *** */
8672 struct cmd_write_reg_result {
8673 cmdline_fixed_string_t write;
8674 cmdline_fixed_string_t reg;
8681 cmd_write_reg_parsed(void *parsed_result,
8682 __rte_unused struct cmdline *cl,
8683 __rte_unused void *data)
8685 struct cmd_write_reg_result *res = parsed_result;
8686 port_reg_set(res->port_id, res->reg_off, res->value);
8689 cmdline_parse_token_string_t cmd_write_reg_write =
8690 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8691 cmdline_parse_token_string_t cmd_write_reg_reg =
8692 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8693 cmdline_parse_token_num_t cmd_write_reg_port_id =
8694 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8695 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8696 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8697 cmdline_parse_token_num_t cmd_write_reg_value =
8698 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8700 cmdline_parse_inst_t cmd_write_reg = {
8701 .f = cmd_write_reg_parsed,
8703 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8705 (void *)&cmd_write_reg_write,
8706 (void *)&cmd_write_reg_reg,
8707 (void *)&cmd_write_reg_port_id,
8708 (void *)&cmd_write_reg_reg_off,
8709 (void *)&cmd_write_reg_value,
8714 /* *** WRITE PORT REGISTER BIT FIELD *** */
8715 struct cmd_write_reg_bit_field_result {
8716 cmdline_fixed_string_t write;
8717 cmdline_fixed_string_t regfield;
8726 cmd_write_reg_bit_field_parsed(void *parsed_result,
8727 __rte_unused struct cmdline *cl,
8728 __rte_unused void *data)
8730 struct cmd_write_reg_bit_field_result *res = parsed_result;
8731 port_reg_bit_field_set(res->port_id, res->reg_off,
8732 res->bit1_pos, res->bit2_pos, res->value);
8735 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8736 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8738 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8739 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8740 regfield, "regfield");
8741 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8742 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8744 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8745 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8747 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8748 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8750 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8751 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8753 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8754 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8757 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8758 .f = cmd_write_reg_bit_field_parsed,
8760 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8762 "Set register bit field between bit_x and bit_y included",
8764 (void *)&cmd_write_reg_bit_field_write,
8765 (void *)&cmd_write_reg_bit_field_regfield,
8766 (void *)&cmd_write_reg_bit_field_port_id,
8767 (void *)&cmd_write_reg_bit_field_reg_off,
8768 (void *)&cmd_write_reg_bit_field_bit1_pos,
8769 (void *)&cmd_write_reg_bit_field_bit2_pos,
8770 (void *)&cmd_write_reg_bit_field_value,
8775 /* *** WRITE PORT REGISTER BIT *** */
8776 struct cmd_write_reg_bit_result {
8777 cmdline_fixed_string_t write;
8778 cmdline_fixed_string_t regbit;
8786 cmd_write_reg_bit_parsed(void *parsed_result,
8787 __rte_unused struct cmdline *cl,
8788 __rte_unused void *data)
8790 struct cmd_write_reg_bit_result *res = parsed_result;
8791 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8794 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8795 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8797 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8798 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8800 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8801 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8803 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8804 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8806 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8807 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8809 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8810 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8813 cmdline_parse_inst_t cmd_write_reg_bit = {
8814 .f = cmd_write_reg_bit_parsed,
8816 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8819 (void *)&cmd_write_reg_bit_write,
8820 (void *)&cmd_write_reg_bit_regbit,
8821 (void *)&cmd_write_reg_bit_port_id,
8822 (void *)&cmd_write_reg_bit_reg_off,
8823 (void *)&cmd_write_reg_bit_bit_pos,
8824 (void *)&cmd_write_reg_bit_value,
8829 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8830 struct cmd_read_rxd_txd_result {
8831 cmdline_fixed_string_t read;
8832 cmdline_fixed_string_t rxd_txd;
8839 cmd_read_rxd_txd_parsed(void *parsed_result,
8840 __rte_unused struct cmdline *cl,
8841 __rte_unused void *data)
8843 struct cmd_read_rxd_txd_result *res = parsed_result;
8845 if (!strcmp(res->rxd_txd, "rxd"))
8846 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8847 else if (!strcmp(res->rxd_txd, "txd"))
8848 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8851 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8852 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8853 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8854 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8856 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8857 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8859 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8860 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8862 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8863 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8866 cmdline_parse_inst_t cmd_read_rxd_txd = {
8867 .f = cmd_read_rxd_txd_parsed,
8869 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8871 (void *)&cmd_read_rxd_txd_read,
8872 (void *)&cmd_read_rxd_txd_rxd_txd,
8873 (void *)&cmd_read_rxd_txd_port_id,
8874 (void *)&cmd_read_rxd_txd_queue_id,
8875 (void *)&cmd_read_rxd_txd_desc_id,
8881 struct cmd_quit_result {
8882 cmdline_fixed_string_t quit;
8885 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8887 __rte_unused void *data)
8892 cmdline_parse_token_string_t cmd_quit_quit =
8893 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8895 cmdline_parse_inst_t cmd_quit = {
8896 .f = cmd_quit_parsed,
8898 .help_str = "quit: Exit application",
8900 (void *)&cmd_quit_quit,
8905 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8906 struct cmd_mac_addr_result {
8907 cmdline_fixed_string_t mac_addr_cmd;
8908 cmdline_fixed_string_t what;
8910 struct rte_ether_addr address;
8913 static void cmd_mac_addr_parsed(void *parsed_result,
8914 __rte_unused struct cmdline *cl,
8915 __rte_unused void *data)
8917 struct cmd_mac_addr_result *res = parsed_result;
8920 if (strcmp(res->what, "add") == 0)
8921 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8922 else if (strcmp(res->what, "set") == 0)
8923 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8926 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8928 /* check the return value and print it if is < 0 */
8930 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8934 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8935 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8937 cmdline_parse_token_string_t cmd_mac_addr_what =
8938 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8940 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8941 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8943 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8944 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8946 cmdline_parse_inst_t cmd_mac_addr = {
8947 .f = cmd_mac_addr_parsed,
8949 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8950 "Add/Remove/Set MAC address on port_id",
8952 (void *)&cmd_mac_addr_cmd,
8953 (void *)&cmd_mac_addr_what,
8954 (void *)&cmd_mac_addr_portnum,
8955 (void *)&cmd_mac_addr_addr,
8960 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8961 struct cmd_eth_peer_result {
8962 cmdline_fixed_string_t set;
8963 cmdline_fixed_string_t eth_peer;
8965 cmdline_fixed_string_t peer_addr;
8968 static void cmd_set_eth_peer_parsed(void *parsed_result,
8969 __rte_unused struct cmdline *cl,
8970 __rte_unused void *data)
8972 struct cmd_eth_peer_result *res = parsed_result;
8974 if (test_done == 0) {
8975 fprintf(stderr, "Please stop forwarding first\n");
8978 if (!strcmp(res->eth_peer, "eth-peer")) {
8979 set_fwd_eth_peer(res->port_id, res->peer_addr);
8983 cmdline_parse_token_string_t cmd_eth_peer_set =
8984 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8985 cmdline_parse_token_string_t cmd_eth_peer =
8986 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8987 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8988 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8990 cmdline_parse_token_string_t cmd_eth_peer_addr =
8991 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8993 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8994 .f = cmd_set_eth_peer_parsed,
8996 .help_str = "set eth-peer <port_id> <peer_mac>",
8998 (void *)&cmd_eth_peer_set,
8999 (void *)&cmd_eth_peer,
9000 (void *)&cmd_eth_peer_port_id,
9001 (void *)&cmd_eth_peer_addr,
9006 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
9007 struct cmd_set_qmap_result {
9008 cmdline_fixed_string_t set;
9009 cmdline_fixed_string_t qmap;
9010 cmdline_fixed_string_t what;
9017 cmd_set_qmap_parsed(void *parsed_result,
9018 __rte_unused struct cmdline *cl,
9019 __rte_unused void *data)
9021 struct cmd_set_qmap_result *res = parsed_result;
9022 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
9024 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
9027 cmdline_parse_token_string_t cmd_setqmap_set =
9028 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9030 cmdline_parse_token_string_t cmd_setqmap_qmap =
9031 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9033 cmdline_parse_token_string_t cmd_setqmap_what =
9034 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9036 cmdline_parse_token_num_t cmd_setqmap_portid =
9037 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9038 port_id, RTE_UINT16);
9039 cmdline_parse_token_num_t cmd_setqmap_queueid =
9040 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9041 queue_id, RTE_UINT16);
9042 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
9043 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9044 map_value, RTE_UINT8);
9046 cmdline_parse_inst_t cmd_set_qmap = {
9047 .f = cmd_set_qmap_parsed,
9049 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
9050 "Set statistics mapping value on tx|rx queue_id of port_id",
9052 (void *)&cmd_setqmap_set,
9053 (void *)&cmd_setqmap_qmap,
9054 (void *)&cmd_setqmap_what,
9055 (void *)&cmd_setqmap_portid,
9056 (void *)&cmd_setqmap_queueid,
9057 (void *)&cmd_setqmap_mapvalue,
9062 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
9063 struct cmd_set_xstats_hide_zero_result {
9064 cmdline_fixed_string_t keyword;
9065 cmdline_fixed_string_t name;
9066 cmdline_fixed_string_t on_off;
9070 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
9071 __rte_unused struct cmdline *cl,
9072 __rte_unused void *data)
9074 struct cmd_set_xstats_hide_zero_result *res;
9075 uint16_t on_off = 0;
9077 res = parsed_result;
9078 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9079 set_xstats_hide_zero(on_off);
9082 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
9083 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9085 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
9086 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9087 name, "xstats-hide-zero");
9088 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
9089 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9092 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
9093 .f = cmd_set_xstats_hide_zero_parsed,
9095 .help_str = "set xstats-hide-zero on|off",
9097 (void *)&cmd_set_xstats_hide_zero_keyword,
9098 (void *)&cmd_set_xstats_hide_zero_name,
9099 (void *)&cmd_set_xstats_hide_zero_on_off,
9104 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
9105 struct cmd_set_record_core_cycles_result {
9106 cmdline_fixed_string_t keyword;
9107 cmdline_fixed_string_t name;
9108 cmdline_fixed_string_t on_off;
9112 cmd_set_record_core_cycles_parsed(void *parsed_result,
9113 __rte_unused struct cmdline *cl,
9114 __rte_unused void *data)
9116 struct cmd_set_record_core_cycles_result *res;
9117 uint16_t on_off = 0;
9119 res = parsed_result;
9120 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9121 set_record_core_cycles(on_off);
9124 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
9125 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9127 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
9128 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9129 name, "record-core-cycles");
9130 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
9131 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9134 cmdline_parse_inst_t cmd_set_record_core_cycles = {
9135 .f = cmd_set_record_core_cycles_parsed,
9137 .help_str = "set record-core-cycles on|off",
9139 (void *)&cmd_set_record_core_cycles_keyword,
9140 (void *)&cmd_set_record_core_cycles_name,
9141 (void *)&cmd_set_record_core_cycles_on_off,
9146 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9147 struct cmd_set_record_burst_stats_result {
9148 cmdline_fixed_string_t keyword;
9149 cmdline_fixed_string_t name;
9150 cmdline_fixed_string_t on_off;
9154 cmd_set_record_burst_stats_parsed(void *parsed_result,
9155 __rte_unused struct cmdline *cl,
9156 __rte_unused void *data)
9158 struct cmd_set_record_burst_stats_result *res;
9159 uint16_t on_off = 0;
9161 res = parsed_result;
9162 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9163 set_record_burst_stats(on_off);
9166 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9167 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9169 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9170 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9171 name, "record-burst-stats");
9172 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9173 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9176 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9177 .f = cmd_set_record_burst_stats_parsed,
9179 .help_str = "set record-burst-stats on|off",
9181 (void *)&cmd_set_record_burst_stats_keyword,
9182 (void *)&cmd_set_record_burst_stats_name,
9183 (void *)&cmd_set_record_burst_stats_on_off,
9188 /* *** CONFIGURE UNICAST HASH TABLE *** */
9189 struct cmd_set_uc_hash_table {
9190 cmdline_fixed_string_t set;
9191 cmdline_fixed_string_t port;
9193 cmdline_fixed_string_t what;
9194 struct rte_ether_addr address;
9195 cmdline_fixed_string_t mode;
9199 cmd_set_uc_hash_parsed(void *parsed_result,
9200 __rte_unused struct cmdline *cl,
9201 __rte_unused void *data)
9204 struct cmd_set_uc_hash_table *res = parsed_result;
9206 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9208 if (strcmp(res->what, "uta") == 0)
9209 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9210 &res->address,(uint8_t)is_on);
9213 "bad unicast hash table parameter, return code = %d\n",
9218 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9219 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9221 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9222 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9224 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9225 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9226 port_id, RTE_UINT16);
9227 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9228 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9230 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9231 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9233 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9234 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9237 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9238 .f = cmd_set_uc_hash_parsed,
9240 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9242 (void *)&cmd_set_uc_hash_set,
9243 (void *)&cmd_set_uc_hash_port,
9244 (void *)&cmd_set_uc_hash_portid,
9245 (void *)&cmd_set_uc_hash_what,
9246 (void *)&cmd_set_uc_hash_mac,
9247 (void *)&cmd_set_uc_hash_mode,
9252 struct cmd_set_uc_all_hash_table {
9253 cmdline_fixed_string_t set;
9254 cmdline_fixed_string_t port;
9256 cmdline_fixed_string_t what;
9257 cmdline_fixed_string_t value;
9258 cmdline_fixed_string_t mode;
9262 cmd_set_uc_all_hash_parsed(void *parsed_result,
9263 __rte_unused struct cmdline *cl,
9264 __rte_unused void *data)
9267 struct cmd_set_uc_all_hash_table *res = parsed_result;
9269 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9271 if ((strcmp(res->what, "uta") == 0) &&
9272 (strcmp(res->value, "all") == 0))
9273 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9276 "bad unicast hash table parameter, return code = %d\n",
9280 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9281 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9283 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9284 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9286 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9287 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9288 port_id, RTE_UINT16);
9289 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9290 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9292 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9293 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9295 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9296 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9299 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9300 .f = cmd_set_uc_all_hash_parsed,
9302 .help_str = "set port <port_id> uta all on|off",
9304 (void *)&cmd_set_uc_all_hash_set,
9305 (void *)&cmd_set_uc_all_hash_port,
9306 (void *)&cmd_set_uc_all_hash_portid,
9307 (void *)&cmd_set_uc_all_hash_what,
9308 (void *)&cmd_set_uc_all_hash_value,
9309 (void *)&cmd_set_uc_all_hash_mode,
9314 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9315 struct cmd_set_vf_traffic {
9316 cmdline_fixed_string_t set;
9317 cmdline_fixed_string_t port;
9319 cmdline_fixed_string_t vf;
9321 cmdline_fixed_string_t what;
9322 cmdline_fixed_string_t mode;
9326 cmd_set_vf_traffic_parsed(void *parsed_result,
9327 __rte_unused struct cmdline *cl,
9328 __rte_unused void *data)
9330 struct cmd_set_vf_traffic *res = parsed_result;
9331 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9332 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9334 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9337 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9338 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9340 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9341 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9343 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9344 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9345 port_id, RTE_UINT16);
9346 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9347 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9349 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9350 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9352 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9353 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9355 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9356 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9359 cmdline_parse_inst_t cmd_set_vf_traffic = {
9360 .f = cmd_set_vf_traffic_parsed,
9362 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9364 (void *)&cmd_setvf_traffic_set,
9365 (void *)&cmd_setvf_traffic_port,
9366 (void *)&cmd_setvf_traffic_portid,
9367 (void *)&cmd_setvf_traffic_vf,
9368 (void *)&cmd_setvf_traffic_vfid,
9369 (void *)&cmd_setvf_traffic_what,
9370 (void *)&cmd_setvf_traffic_mode,
9375 /* *** CONFIGURE VF RECEIVE MODE *** */
9376 struct cmd_set_vf_rxmode {
9377 cmdline_fixed_string_t set;
9378 cmdline_fixed_string_t port;
9380 cmdline_fixed_string_t vf;
9382 cmdline_fixed_string_t what;
9383 cmdline_fixed_string_t mode;
9384 cmdline_fixed_string_t on;
9388 cmd_set_vf_rxmode_parsed(void *parsed_result,
9389 __rte_unused struct cmdline *cl,
9390 __rte_unused void *data)
9393 uint16_t vf_rxmode = 0;
9394 struct cmd_set_vf_rxmode *res = parsed_result;
9396 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9397 if (!strcmp(res->what,"rxmode")) {
9398 if (!strcmp(res->mode, "AUPE"))
9399 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9400 else if (!strcmp(res->mode, "ROPE"))
9401 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9402 else if (!strcmp(res->mode, "BAM"))
9403 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9404 else if (!strncmp(res->mode, "MPE",3))
9405 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9408 RTE_SET_USED(is_on);
9409 RTE_SET_USED(vf_rxmode);
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);
14835 if (ret == -ENOTSUP)
14836 fprintf(stderr, "Function not supported in PMD\n");
14840 cmdline_parse_inst_t cmd_ddp_get_info = {
14841 .f = cmd_ddp_info_parsed,
14843 .help_str = "ddp get info <profile_path>",
14845 (void *)&cmd_ddp_info_ddp,
14846 (void *)&cmd_ddp_info_get,
14847 (void *)&cmd_ddp_info_info,
14848 (void *)&cmd_ddp_info_filepath,
14853 /* Get dynamic device personalization profile info list*/
14854 #define PROFILE_INFO_SIZE 48
14855 #define MAX_PROFILE_NUM 16
14857 struct cmd_ddp_get_list_result {
14858 cmdline_fixed_string_t ddp;
14859 cmdline_fixed_string_t get;
14860 cmdline_fixed_string_t list;
14864 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14865 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14866 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14867 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14868 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14869 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14870 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14871 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14875 cmd_ddp_get_list_parsed(
14876 __rte_unused void *parsed_result,
14877 __rte_unused struct cmdline *cl,
14878 __rte_unused void *data)
14880 #ifdef RTE_NET_I40E
14881 struct cmd_ddp_get_list_result *res = parsed_result;
14882 struct rte_pmd_i40e_profile_list *p_list;
14883 struct rte_pmd_i40e_profile_info *p_info;
14888 int ret = -ENOTSUP;
14890 #ifdef RTE_NET_I40E
14891 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14892 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14894 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14898 if (ret == -ENOTSUP)
14899 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14900 (uint8_t *)p_list, size);
14903 p_num = p_list->p_count;
14904 printf("Profile number is: %d\n\n", p_num);
14906 for (i = 0; i < p_num; i++) {
14907 p_info = &p_list->p_info[i];
14908 printf("Profile %d:\n", i);
14909 printf("Track id: 0x%x\n", p_info->track_id);
14910 printf("Version: %d.%d.%d.%d\n",
14911 p_info->version.major,
14912 p_info->version.minor,
14913 p_info->version.update,
14914 p_info->version.draft);
14915 printf("Profile name: %s\n\n", p_info->name);
14923 fprintf(stderr, "Failed to get ddp list\n");
14926 cmdline_parse_inst_t cmd_ddp_get_list = {
14927 .f = cmd_ddp_get_list_parsed,
14929 .help_str = "ddp get list <port_id>",
14931 (void *)&cmd_ddp_get_list_ddp,
14932 (void *)&cmd_ddp_get_list_get,
14933 (void *)&cmd_ddp_get_list_list,
14934 (void *)&cmd_ddp_get_list_port_id,
14939 /* Configure input set */
14940 struct cmd_cfg_input_set_result {
14941 cmdline_fixed_string_t port;
14942 cmdline_fixed_string_t cfg;
14944 cmdline_fixed_string_t pctype;
14946 cmdline_fixed_string_t inset_type;
14947 cmdline_fixed_string_t opt;
14948 cmdline_fixed_string_t field;
14953 cmd_cfg_input_set_parsed(
14954 __rte_unused void *parsed_result,
14955 __rte_unused struct cmdline *cl,
14956 __rte_unused void *data)
14958 #ifdef RTE_NET_I40E
14959 struct cmd_cfg_input_set_result *res = parsed_result;
14960 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14961 struct rte_pmd_i40e_inset inset;
14963 int ret = -ENOTSUP;
14965 if (!all_ports_stopped()) {
14966 fprintf(stderr, "Please stop all ports first\n");
14970 #ifdef RTE_NET_I40E
14971 if (!strcmp(res->inset_type, "hash_inset"))
14972 inset_type = INSET_HASH;
14973 else if (!strcmp(res->inset_type, "fdir_inset"))
14974 inset_type = INSET_FDIR;
14975 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14976 inset_type = INSET_FDIR_FLX;
14977 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14978 &inset, inset_type);
14980 fprintf(stderr, "Failed to get input set.\n");
14984 if (!strcmp(res->opt, "get")) {
14985 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14988 printf("Field index %d is enabled.\n", res->field_idx);
14990 printf("Field index %d is disabled.\n", res->field_idx);
14992 } else if (!strcmp(res->opt, "set"))
14993 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14995 else if (!strcmp(res->opt, "clear"))
14996 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14999 fprintf(stderr, "Failed to configure input set field.\n");
15003 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15004 &inset, inset_type);
15006 fprintf(stderr, "Failed to set input set.\n");
15011 if (ret == -ENOTSUP)
15012 fprintf(stderr, "Function not supported\n");
15015 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15016 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15018 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15019 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15021 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15022 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15023 port_id, RTE_UINT16);
15024 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15025 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15027 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15028 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15029 pctype_id, RTE_UINT8);
15030 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15031 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15033 "hash_inset#fdir_inset#fdir_flx_inset");
15034 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15035 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15036 opt, "get#set#clear");
15037 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15038 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15040 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15041 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15042 field_idx, RTE_UINT8);
15044 cmdline_parse_inst_t cmd_cfg_input_set = {
15045 .f = cmd_cfg_input_set_parsed,
15047 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15048 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15050 (void *)&cmd_cfg_input_set_port,
15051 (void *)&cmd_cfg_input_set_cfg,
15052 (void *)&cmd_cfg_input_set_port_id,
15053 (void *)&cmd_cfg_input_set_pctype,
15054 (void *)&cmd_cfg_input_set_pctype_id,
15055 (void *)&cmd_cfg_input_set_inset_type,
15056 (void *)&cmd_cfg_input_set_opt,
15057 (void *)&cmd_cfg_input_set_field,
15058 (void *)&cmd_cfg_input_set_field_idx,
15063 /* Clear input set */
15064 struct cmd_clear_input_set_result {
15065 cmdline_fixed_string_t port;
15066 cmdline_fixed_string_t cfg;
15068 cmdline_fixed_string_t pctype;
15070 cmdline_fixed_string_t inset_type;
15071 cmdline_fixed_string_t clear;
15072 cmdline_fixed_string_t all;
15076 cmd_clear_input_set_parsed(
15077 __rte_unused void *parsed_result,
15078 __rte_unused struct cmdline *cl,
15079 __rte_unused void *data)
15081 #ifdef RTE_NET_I40E
15082 struct cmd_clear_input_set_result *res = parsed_result;
15083 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15084 struct rte_pmd_i40e_inset inset;
15086 int ret = -ENOTSUP;
15088 if (!all_ports_stopped()) {
15089 fprintf(stderr, "Please stop all ports first\n");
15093 #ifdef RTE_NET_I40E
15094 if (!strcmp(res->inset_type, "hash_inset"))
15095 inset_type = INSET_HASH;
15096 else if (!strcmp(res->inset_type, "fdir_inset"))
15097 inset_type = INSET_FDIR;
15098 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15099 inset_type = INSET_FDIR_FLX;
15101 memset(&inset, 0, sizeof(inset));
15103 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15104 &inset, inset_type);
15106 fprintf(stderr, "Failed to clear input set.\n");
15112 if (ret == -ENOTSUP)
15113 fprintf(stderr, "Function not supported\n");
15116 cmdline_parse_token_string_t cmd_clear_input_set_port =
15117 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15119 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15120 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15122 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15123 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15124 port_id, RTE_UINT16);
15125 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15126 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15128 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15129 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15130 pctype_id, RTE_UINT8);
15131 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15132 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15134 "hash_inset#fdir_inset#fdir_flx_inset");
15135 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15136 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15138 cmdline_parse_token_string_t cmd_clear_input_set_all =
15139 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15142 cmdline_parse_inst_t cmd_clear_input_set = {
15143 .f = cmd_clear_input_set_parsed,
15145 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15146 "fdir_inset|fdir_flx_inset clear all",
15148 (void *)&cmd_clear_input_set_port,
15149 (void *)&cmd_clear_input_set_cfg,
15150 (void *)&cmd_clear_input_set_port_id,
15151 (void *)&cmd_clear_input_set_pctype,
15152 (void *)&cmd_clear_input_set_pctype_id,
15153 (void *)&cmd_clear_input_set_inset_type,
15154 (void *)&cmd_clear_input_set_clear,
15155 (void *)&cmd_clear_input_set_all,
15160 /* show vf stats */
15162 /* Common result structure for show vf stats */
15163 struct cmd_show_vf_stats_result {
15164 cmdline_fixed_string_t show;
15165 cmdline_fixed_string_t vf;
15166 cmdline_fixed_string_t stats;
15171 /* Common CLI fields show vf stats*/
15172 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15173 TOKEN_STRING_INITIALIZER
15174 (struct cmd_show_vf_stats_result,
15176 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15177 TOKEN_STRING_INITIALIZER
15178 (struct cmd_show_vf_stats_result,
15180 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15181 TOKEN_STRING_INITIALIZER
15182 (struct cmd_show_vf_stats_result,
15184 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15185 TOKEN_NUM_INITIALIZER
15186 (struct cmd_show_vf_stats_result,
15187 port_id, RTE_UINT16);
15188 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15189 TOKEN_NUM_INITIALIZER
15190 (struct cmd_show_vf_stats_result,
15191 vf_id, RTE_UINT16);
15194 cmd_show_vf_stats_parsed(
15195 void *parsed_result,
15196 __rte_unused struct cmdline *cl,
15197 __rte_unused void *data)
15199 struct cmd_show_vf_stats_result *res = parsed_result;
15200 struct rte_eth_stats stats;
15201 int ret = -ENOTSUP;
15202 static const char *nic_stats_border = "########################";
15204 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15207 memset(&stats, 0, sizeof(stats));
15209 #ifdef RTE_NET_I40E
15210 if (ret == -ENOTSUP)
15211 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15215 #ifdef RTE_NET_BNXT
15216 if (ret == -ENOTSUP)
15217 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15226 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15229 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15232 fprintf(stderr, "function not implemented\n");
15235 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15238 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15239 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15241 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15243 stats.ipackets, stats.imissed, stats.ibytes);
15244 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15245 printf(" RX-nombuf: %-10"PRIu64"\n",
15247 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15249 stats.opackets, stats.oerrors, stats.obytes);
15251 printf(" %s############################%s\n",
15252 nic_stats_border, nic_stats_border);
15255 cmdline_parse_inst_t cmd_show_vf_stats = {
15256 .f = cmd_show_vf_stats_parsed,
15258 .help_str = "show vf stats <port_id> <vf_id>",
15260 (void *)&cmd_show_vf_stats_show,
15261 (void *)&cmd_show_vf_stats_vf,
15262 (void *)&cmd_show_vf_stats_stats,
15263 (void *)&cmd_show_vf_stats_port_id,
15264 (void *)&cmd_show_vf_stats_vf_id,
15269 /* clear vf stats */
15271 /* Common result structure for clear vf stats */
15272 struct cmd_clear_vf_stats_result {
15273 cmdline_fixed_string_t clear;
15274 cmdline_fixed_string_t vf;
15275 cmdline_fixed_string_t stats;
15280 /* Common CLI fields clear vf stats*/
15281 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15282 TOKEN_STRING_INITIALIZER
15283 (struct cmd_clear_vf_stats_result,
15285 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15286 TOKEN_STRING_INITIALIZER
15287 (struct cmd_clear_vf_stats_result,
15289 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15290 TOKEN_STRING_INITIALIZER
15291 (struct cmd_clear_vf_stats_result,
15293 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15294 TOKEN_NUM_INITIALIZER
15295 (struct cmd_clear_vf_stats_result,
15296 port_id, RTE_UINT16);
15297 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15298 TOKEN_NUM_INITIALIZER
15299 (struct cmd_clear_vf_stats_result,
15300 vf_id, RTE_UINT16);
15303 cmd_clear_vf_stats_parsed(
15304 void *parsed_result,
15305 __rte_unused struct cmdline *cl,
15306 __rte_unused void *data)
15308 struct cmd_clear_vf_stats_result *res = parsed_result;
15309 int ret = -ENOTSUP;
15311 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15314 #ifdef RTE_NET_I40E
15315 if (ret == -ENOTSUP)
15316 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15319 #ifdef RTE_NET_BNXT
15320 if (ret == -ENOTSUP)
15321 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15329 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15332 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15335 fprintf(stderr, "function not implemented\n");
15338 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15342 cmdline_parse_inst_t cmd_clear_vf_stats = {
15343 .f = cmd_clear_vf_stats_parsed,
15345 .help_str = "clear vf stats <port_id> <vf_id>",
15347 (void *)&cmd_clear_vf_stats_clear,
15348 (void *)&cmd_clear_vf_stats_vf,
15349 (void *)&cmd_clear_vf_stats_stats,
15350 (void *)&cmd_clear_vf_stats_port_id,
15351 (void *)&cmd_clear_vf_stats_vf_id,
15356 /* port config pctype mapping reset */
15358 /* Common result structure for port config pctype mapping reset */
15359 struct cmd_pctype_mapping_reset_result {
15360 cmdline_fixed_string_t port;
15361 cmdline_fixed_string_t config;
15363 cmdline_fixed_string_t pctype;
15364 cmdline_fixed_string_t mapping;
15365 cmdline_fixed_string_t reset;
15368 /* Common CLI fields for port config pctype mapping reset*/
15369 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15370 TOKEN_STRING_INITIALIZER
15371 (struct cmd_pctype_mapping_reset_result,
15373 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15374 TOKEN_STRING_INITIALIZER
15375 (struct cmd_pctype_mapping_reset_result,
15377 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15378 TOKEN_NUM_INITIALIZER
15379 (struct cmd_pctype_mapping_reset_result,
15380 port_id, RTE_UINT16);
15381 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15382 TOKEN_STRING_INITIALIZER
15383 (struct cmd_pctype_mapping_reset_result,
15385 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15386 TOKEN_STRING_INITIALIZER
15387 (struct cmd_pctype_mapping_reset_result,
15388 mapping, "mapping");
15389 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15390 TOKEN_STRING_INITIALIZER
15391 (struct cmd_pctype_mapping_reset_result,
15395 cmd_pctype_mapping_reset_parsed(
15396 void *parsed_result,
15397 __rte_unused struct cmdline *cl,
15398 __rte_unused void *data)
15400 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15401 int ret = -ENOTSUP;
15403 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15406 #ifdef RTE_NET_I40E
15407 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15414 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15417 fprintf(stderr, "function not implemented\n");
15420 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15424 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15425 .f = cmd_pctype_mapping_reset_parsed,
15427 .help_str = "port config <port_id> pctype mapping reset",
15429 (void *)&cmd_pctype_mapping_reset_port,
15430 (void *)&cmd_pctype_mapping_reset_config,
15431 (void *)&cmd_pctype_mapping_reset_port_id,
15432 (void *)&cmd_pctype_mapping_reset_pctype,
15433 (void *)&cmd_pctype_mapping_reset_mapping,
15434 (void *)&cmd_pctype_mapping_reset_reset,
15439 /* show port pctype mapping */
15441 /* Common result structure for show port pctype mapping */
15442 struct cmd_pctype_mapping_get_result {
15443 cmdline_fixed_string_t show;
15444 cmdline_fixed_string_t port;
15446 cmdline_fixed_string_t pctype;
15447 cmdline_fixed_string_t mapping;
15450 /* Common CLI fields for pctype mapping get */
15451 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15452 TOKEN_STRING_INITIALIZER
15453 (struct cmd_pctype_mapping_get_result,
15455 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15456 TOKEN_STRING_INITIALIZER
15457 (struct cmd_pctype_mapping_get_result,
15459 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15460 TOKEN_NUM_INITIALIZER
15461 (struct cmd_pctype_mapping_get_result,
15462 port_id, RTE_UINT16);
15463 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15464 TOKEN_STRING_INITIALIZER
15465 (struct cmd_pctype_mapping_get_result,
15467 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15468 TOKEN_STRING_INITIALIZER
15469 (struct cmd_pctype_mapping_get_result,
15470 mapping, "mapping");
15473 cmd_pctype_mapping_get_parsed(
15474 void *parsed_result,
15475 __rte_unused struct cmdline *cl,
15476 __rte_unused void *data)
15478 struct cmd_pctype_mapping_get_result *res = parsed_result;
15479 int ret = -ENOTSUP;
15480 #ifdef RTE_NET_I40E
15481 struct rte_pmd_i40e_flow_type_mapping
15482 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15483 int i, j, first_pctype;
15486 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15489 #ifdef RTE_NET_I40E
15490 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15497 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15500 fprintf(stderr, "function not implemented\n");
15503 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15507 #ifdef RTE_NET_I40E
15508 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15509 if (mapping[i].pctype != 0ULL) {
15512 printf("pctype: ");
15513 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15514 if (mapping[i].pctype & (1ULL << j)) {
15515 printf(first_pctype ?
15516 "%02d" : ",%02d", j);
15520 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15526 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15527 .f = cmd_pctype_mapping_get_parsed,
15529 .help_str = "show port <port_id> pctype mapping",
15531 (void *)&cmd_pctype_mapping_get_show,
15532 (void *)&cmd_pctype_mapping_get_port,
15533 (void *)&cmd_pctype_mapping_get_port_id,
15534 (void *)&cmd_pctype_mapping_get_pctype,
15535 (void *)&cmd_pctype_mapping_get_mapping,
15540 /* port config pctype mapping update */
15542 /* Common result structure for port config pctype mapping update */
15543 struct cmd_pctype_mapping_update_result {
15544 cmdline_fixed_string_t port;
15545 cmdline_fixed_string_t config;
15547 cmdline_fixed_string_t pctype;
15548 cmdline_fixed_string_t mapping;
15549 cmdline_fixed_string_t update;
15550 cmdline_fixed_string_t pctype_list;
15551 uint16_t flow_type;
15554 /* Common CLI fields for pctype mapping update*/
15555 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15556 TOKEN_STRING_INITIALIZER
15557 (struct cmd_pctype_mapping_update_result,
15559 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15560 TOKEN_STRING_INITIALIZER
15561 (struct cmd_pctype_mapping_update_result,
15563 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15564 TOKEN_NUM_INITIALIZER
15565 (struct cmd_pctype_mapping_update_result,
15566 port_id, RTE_UINT16);
15567 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15568 TOKEN_STRING_INITIALIZER
15569 (struct cmd_pctype_mapping_update_result,
15571 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15572 TOKEN_STRING_INITIALIZER
15573 (struct cmd_pctype_mapping_update_result,
15574 mapping, "mapping");
15575 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15576 TOKEN_STRING_INITIALIZER
15577 (struct cmd_pctype_mapping_update_result,
15579 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15580 TOKEN_STRING_INITIALIZER
15581 (struct cmd_pctype_mapping_update_result,
15582 pctype_list, NULL);
15583 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15584 TOKEN_NUM_INITIALIZER
15585 (struct cmd_pctype_mapping_update_result,
15586 flow_type, RTE_UINT16);
15589 cmd_pctype_mapping_update_parsed(
15590 void *parsed_result,
15591 __rte_unused struct cmdline *cl,
15592 __rte_unused void *data)
15594 struct cmd_pctype_mapping_update_result *res = parsed_result;
15595 int ret = -ENOTSUP;
15596 #ifdef RTE_NET_I40E
15597 struct rte_pmd_i40e_flow_type_mapping mapping;
15599 unsigned int nb_item;
15600 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15603 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15606 #ifdef RTE_NET_I40E
15607 nb_item = parse_item_list(res->pctype_list, "pctypes",
15608 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15609 mapping.flow_type = res->flow_type;
15610 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15611 mapping.pctype |= (1ULL << pctype_list[i]);
15612 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15622 fprintf(stderr, "invalid pctype or flow type\n");
15625 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15628 fprintf(stderr, "function not implemented\n");
15631 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15635 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15636 .f = cmd_pctype_mapping_update_parsed,
15638 .help_str = "port config <port_id> pctype mapping update"
15639 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15641 (void *)&cmd_pctype_mapping_update_port,
15642 (void *)&cmd_pctype_mapping_update_config,
15643 (void *)&cmd_pctype_mapping_update_port_id,
15644 (void *)&cmd_pctype_mapping_update_pctype,
15645 (void *)&cmd_pctype_mapping_update_mapping,
15646 (void *)&cmd_pctype_mapping_update_update,
15647 (void *)&cmd_pctype_mapping_update_pc_type,
15648 (void *)&cmd_pctype_mapping_update_flow_type,
15653 /* ptype mapping get */
15655 /* Common result structure for ptype mapping get */
15656 struct cmd_ptype_mapping_get_result {
15657 cmdline_fixed_string_t ptype;
15658 cmdline_fixed_string_t mapping;
15659 cmdline_fixed_string_t get;
15661 uint8_t valid_only;
15664 /* Common CLI fields for ptype mapping get */
15665 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15666 TOKEN_STRING_INITIALIZER
15667 (struct cmd_ptype_mapping_get_result,
15669 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15670 TOKEN_STRING_INITIALIZER
15671 (struct cmd_ptype_mapping_get_result,
15672 mapping, "mapping");
15673 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15674 TOKEN_STRING_INITIALIZER
15675 (struct cmd_ptype_mapping_get_result,
15677 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15678 TOKEN_NUM_INITIALIZER
15679 (struct cmd_ptype_mapping_get_result,
15680 port_id, RTE_UINT16);
15681 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15682 TOKEN_NUM_INITIALIZER
15683 (struct cmd_ptype_mapping_get_result,
15684 valid_only, RTE_UINT8);
15687 cmd_ptype_mapping_get_parsed(
15688 void *parsed_result,
15689 __rte_unused struct cmdline *cl,
15690 __rte_unused void *data)
15692 struct cmd_ptype_mapping_get_result *res = parsed_result;
15693 int ret = -ENOTSUP;
15694 #ifdef RTE_NET_I40E
15695 int max_ptype_num = 256;
15696 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15701 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15704 #ifdef RTE_NET_I40E
15705 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15716 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15719 fprintf(stderr, "function not implemented\n");
15722 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15725 #ifdef RTE_NET_I40E
15727 for (i = 0; i < count; i++)
15728 printf("%3d\t0x%08x\n",
15729 mapping[i].hw_ptype, mapping[i].sw_ptype);
15734 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15735 .f = cmd_ptype_mapping_get_parsed,
15737 .help_str = "ptype mapping get <port_id> <valid_only>",
15739 (void *)&cmd_ptype_mapping_get_ptype,
15740 (void *)&cmd_ptype_mapping_get_mapping,
15741 (void *)&cmd_ptype_mapping_get_get,
15742 (void *)&cmd_ptype_mapping_get_port_id,
15743 (void *)&cmd_ptype_mapping_get_valid_only,
15748 /* ptype mapping replace */
15750 /* Common result structure for ptype mapping replace */
15751 struct cmd_ptype_mapping_replace_result {
15752 cmdline_fixed_string_t ptype;
15753 cmdline_fixed_string_t mapping;
15754 cmdline_fixed_string_t replace;
15761 /* Common CLI fields for ptype mapping replace */
15762 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15763 TOKEN_STRING_INITIALIZER
15764 (struct cmd_ptype_mapping_replace_result,
15766 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15767 TOKEN_STRING_INITIALIZER
15768 (struct cmd_ptype_mapping_replace_result,
15769 mapping, "mapping");
15770 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15771 TOKEN_STRING_INITIALIZER
15772 (struct cmd_ptype_mapping_replace_result,
15773 replace, "replace");
15774 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15775 TOKEN_NUM_INITIALIZER
15776 (struct cmd_ptype_mapping_replace_result,
15777 port_id, RTE_UINT16);
15778 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15779 TOKEN_NUM_INITIALIZER
15780 (struct cmd_ptype_mapping_replace_result,
15781 target, RTE_UINT32);
15782 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15783 TOKEN_NUM_INITIALIZER
15784 (struct cmd_ptype_mapping_replace_result,
15786 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15787 TOKEN_NUM_INITIALIZER
15788 (struct cmd_ptype_mapping_replace_result,
15789 pkt_type, RTE_UINT32);
15792 cmd_ptype_mapping_replace_parsed(
15793 void *parsed_result,
15794 __rte_unused struct cmdline *cl,
15795 __rte_unused void *data)
15797 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15798 int ret = -ENOTSUP;
15800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15803 #ifdef RTE_NET_I40E
15804 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15814 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15815 res->target, res->pkt_type);
15818 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15821 fprintf(stderr, "function not implemented\n");
15824 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15828 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15829 .f = cmd_ptype_mapping_replace_parsed,
15832 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15834 (void *)&cmd_ptype_mapping_replace_ptype,
15835 (void *)&cmd_ptype_mapping_replace_mapping,
15836 (void *)&cmd_ptype_mapping_replace_replace,
15837 (void *)&cmd_ptype_mapping_replace_port_id,
15838 (void *)&cmd_ptype_mapping_replace_target,
15839 (void *)&cmd_ptype_mapping_replace_mask,
15840 (void *)&cmd_ptype_mapping_replace_pkt_type,
15845 /* ptype mapping reset */
15847 /* Common result structure for ptype mapping reset */
15848 struct cmd_ptype_mapping_reset_result {
15849 cmdline_fixed_string_t ptype;
15850 cmdline_fixed_string_t mapping;
15851 cmdline_fixed_string_t reset;
15855 /* Common CLI fields for ptype mapping reset*/
15856 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15857 TOKEN_STRING_INITIALIZER
15858 (struct cmd_ptype_mapping_reset_result,
15860 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15861 TOKEN_STRING_INITIALIZER
15862 (struct cmd_ptype_mapping_reset_result,
15863 mapping, "mapping");
15864 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15865 TOKEN_STRING_INITIALIZER
15866 (struct cmd_ptype_mapping_reset_result,
15868 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15869 TOKEN_NUM_INITIALIZER
15870 (struct cmd_ptype_mapping_reset_result,
15871 port_id, RTE_UINT16);
15874 cmd_ptype_mapping_reset_parsed(
15875 void *parsed_result,
15876 __rte_unused struct cmdline *cl,
15877 __rte_unused void *data)
15879 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15880 int ret = -ENOTSUP;
15882 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15885 #ifdef RTE_NET_I40E
15886 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15893 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15896 fprintf(stderr, "function not implemented\n");
15899 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15903 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15904 .f = cmd_ptype_mapping_reset_parsed,
15906 .help_str = "ptype mapping reset <port_id>",
15908 (void *)&cmd_ptype_mapping_reset_ptype,
15909 (void *)&cmd_ptype_mapping_reset_mapping,
15910 (void *)&cmd_ptype_mapping_reset_reset,
15911 (void *)&cmd_ptype_mapping_reset_port_id,
15916 /* ptype mapping update */
15918 /* Common result structure for ptype mapping update */
15919 struct cmd_ptype_mapping_update_result {
15920 cmdline_fixed_string_t ptype;
15921 cmdline_fixed_string_t mapping;
15922 cmdline_fixed_string_t reset;
15928 /* Common CLI fields for ptype mapping update*/
15929 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15930 TOKEN_STRING_INITIALIZER
15931 (struct cmd_ptype_mapping_update_result,
15933 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15934 TOKEN_STRING_INITIALIZER
15935 (struct cmd_ptype_mapping_update_result,
15936 mapping, "mapping");
15937 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15938 TOKEN_STRING_INITIALIZER
15939 (struct cmd_ptype_mapping_update_result,
15941 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15942 TOKEN_NUM_INITIALIZER
15943 (struct cmd_ptype_mapping_update_result,
15944 port_id, RTE_UINT16);
15945 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15946 TOKEN_NUM_INITIALIZER
15947 (struct cmd_ptype_mapping_update_result,
15948 hw_ptype, RTE_UINT8);
15949 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15950 TOKEN_NUM_INITIALIZER
15951 (struct cmd_ptype_mapping_update_result,
15952 sw_ptype, RTE_UINT32);
15955 cmd_ptype_mapping_update_parsed(
15956 void *parsed_result,
15957 __rte_unused struct cmdline *cl,
15958 __rte_unused void *data)
15960 struct cmd_ptype_mapping_update_result *res = parsed_result;
15961 int ret = -ENOTSUP;
15962 #ifdef RTE_NET_I40E
15963 struct rte_pmd_i40e_ptype_mapping mapping;
15965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15968 #ifdef RTE_NET_I40E
15969 mapping.hw_ptype = res->hw_ptype;
15970 mapping.sw_ptype = res->sw_ptype;
15971 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15981 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15984 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15987 fprintf(stderr, "function not implemented\n");
15990 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15994 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15995 .f = cmd_ptype_mapping_update_parsed,
15997 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15999 (void *)&cmd_ptype_mapping_update_ptype,
16000 (void *)&cmd_ptype_mapping_update_mapping,
16001 (void *)&cmd_ptype_mapping_update_update,
16002 (void *)&cmd_ptype_mapping_update_port_id,
16003 (void *)&cmd_ptype_mapping_update_hw_ptype,
16004 (void *)&cmd_ptype_mapping_update_sw_ptype,
16009 /* Common result structure for file commands */
16010 struct cmd_cmdfile_result {
16011 cmdline_fixed_string_t load;
16012 cmdline_fixed_string_t filename;
16015 /* Common CLI fields for file commands */
16016 cmdline_parse_token_string_t cmd_load_cmdfile =
16017 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16018 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16019 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16022 cmd_load_from_file_parsed(
16023 void *parsed_result,
16024 __rte_unused struct cmdline *cl,
16025 __rte_unused void *data)
16027 struct cmd_cmdfile_result *res = parsed_result;
16029 cmdline_read_from_file(res->filename);
16032 cmdline_parse_inst_t cmd_load_from_file = {
16033 .f = cmd_load_from_file_parsed,
16035 .help_str = "load <filename>",
16037 (void *)&cmd_load_cmdfile,
16038 (void *)&cmd_load_cmdfile_filename,
16043 /* Get Rx offloads capabilities */
16044 struct cmd_rx_offload_get_capa_result {
16045 cmdline_fixed_string_t show;
16046 cmdline_fixed_string_t port;
16048 cmdline_fixed_string_t rx_offload;
16049 cmdline_fixed_string_t capabilities;
16052 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16053 TOKEN_STRING_INITIALIZER
16054 (struct cmd_rx_offload_get_capa_result,
16056 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16057 TOKEN_STRING_INITIALIZER
16058 (struct cmd_rx_offload_get_capa_result,
16060 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16061 TOKEN_NUM_INITIALIZER
16062 (struct cmd_rx_offload_get_capa_result,
16063 port_id, RTE_UINT16);
16064 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16065 TOKEN_STRING_INITIALIZER
16066 (struct cmd_rx_offload_get_capa_result,
16067 rx_offload, "rx_offload");
16068 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16069 TOKEN_STRING_INITIALIZER
16070 (struct cmd_rx_offload_get_capa_result,
16071 capabilities, "capabilities");
16074 print_rx_offloads(uint64_t offloads)
16076 uint64_t single_offload;
16084 begin = __builtin_ctzll(offloads);
16085 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16087 single_offload = 1ULL << begin;
16088 for (bit = begin; bit < end; bit++) {
16089 if (offloads & single_offload)
16091 rte_eth_dev_rx_offload_name(single_offload));
16092 single_offload <<= 1;
16097 cmd_rx_offload_get_capa_parsed(
16098 void *parsed_result,
16099 __rte_unused struct cmdline *cl,
16100 __rte_unused void *data)
16102 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16103 struct rte_eth_dev_info dev_info;
16104 portid_t port_id = res->port_id;
16105 uint64_t queue_offloads;
16106 uint64_t port_offloads;
16109 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16113 queue_offloads = dev_info.rx_queue_offload_capa;
16114 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16116 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16117 printf(" Per Queue :");
16118 print_rx_offloads(queue_offloads);
16121 printf(" Per Port :");
16122 print_rx_offloads(port_offloads);
16126 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16127 .f = cmd_rx_offload_get_capa_parsed,
16129 .help_str = "show port <port_id> rx_offload capabilities",
16131 (void *)&cmd_rx_offload_get_capa_show,
16132 (void *)&cmd_rx_offload_get_capa_port,
16133 (void *)&cmd_rx_offload_get_capa_port_id,
16134 (void *)&cmd_rx_offload_get_capa_rx_offload,
16135 (void *)&cmd_rx_offload_get_capa_capabilities,
16140 /* Get Rx offloads configuration */
16141 struct cmd_rx_offload_get_configuration_result {
16142 cmdline_fixed_string_t show;
16143 cmdline_fixed_string_t port;
16145 cmdline_fixed_string_t rx_offload;
16146 cmdline_fixed_string_t configuration;
16149 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16150 TOKEN_STRING_INITIALIZER
16151 (struct cmd_rx_offload_get_configuration_result,
16153 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16154 TOKEN_STRING_INITIALIZER
16155 (struct cmd_rx_offload_get_configuration_result,
16157 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16158 TOKEN_NUM_INITIALIZER
16159 (struct cmd_rx_offload_get_configuration_result,
16160 port_id, RTE_UINT16);
16161 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16162 TOKEN_STRING_INITIALIZER
16163 (struct cmd_rx_offload_get_configuration_result,
16164 rx_offload, "rx_offload");
16165 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16166 TOKEN_STRING_INITIALIZER
16167 (struct cmd_rx_offload_get_configuration_result,
16168 configuration, "configuration");
16171 cmd_rx_offload_get_configuration_parsed(
16172 void *parsed_result,
16173 __rte_unused struct cmdline *cl,
16174 __rte_unused void *data)
16176 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16177 struct rte_eth_dev_info dev_info;
16178 portid_t port_id = res->port_id;
16179 struct rte_port *port = &ports[port_id];
16180 struct rte_eth_conf dev_conf;
16181 uint64_t port_offloads;
16182 uint64_t queue_offloads;
16183 uint16_t nb_rx_queues;
16187 printf("Rx Offloading Configuration of port %d :\n", port_id);
16189 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16193 port_offloads = dev_conf.rxmode.offloads;
16195 print_rx_offloads(port_offloads);
16198 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16202 nb_rx_queues = dev_info.nb_rx_queues;
16203 for (q = 0; q < nb_rx_queues; q++) {
16204 queue_offloads = port->rx_conf[q].offloads;
16205 printf(" Queue[%2d] :", q);
16206 print_rx_offloads(queue_offloads);
16212 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16213 .f = cmd_rx_offload_get_configuration_parsed,
16215 .help_str = "show port <port_id> rx_offload configuration",
16217 (void *)&cmd_rx_offload_get_configuration_show,
16218 (void *)&cmd_rx_offload_get_configuration_port,
16219 (void *)&cmd_rx_offload_get_configuration_port_id,
16220 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16221 (void *)&cmd_rx_offload_get_configuration_configuration,
16226 /* Enable/Disable a per port offloading */
16227 struct cmd_config_per_port_rx_offload_result {
16228 cmdline_fixed_string_t port;
16229 cmdline_fixed_string_t config;
16231 cmdline_fixed_string_t rx_offload;
16232 cmdline_fixed_string_t offload;
16233 cmdline_fixed_string_t on_off;
16236 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16237 TOKEN_STRING_INITIALIZER
16238 (struct cmd_config_per_port_rx_offload_result,
16240 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16241 TOKEN_STRING_INITIALIZER
16242 (struct cmd_config_per_port_rx_offload_result,
16244 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16245 TOKEN_NUM_INITIALIZER
16246 (struct cmd_config_per_port_rx_offload_result,
16247 port_id, RTE_UINT16);
16248 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16249 TOKEN_STRING_INITIALIZER
16250 (struct cmd_config_per_port_rx_offload_result,
16251 rx_offload, "rx_offload");
16252 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16253 TOKEN_STRING_INITIALIZER
16254 (struct cmd_config_per_port_rx_offload_result,
16255 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16256 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16257 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16258 "scatter#buffer_split#timestamp#security#"
16259 "keep_crc#rss_hash");
16260 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16261 TOKEN_STRING_INITIALIZER
16262 (struct cmd_config_per_port_rx_offload_result,
16266 search_rx_offload(const char *name)
16268 uint64_t single_offload;
16269 const char *single_name;
16273 single_offload = 1;
16274 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16275 single_name = rte_eth_dev_rx_offload_name(single_offload);
16276 if (!strcasecmp(single_name, name)) {
16280 single_offload <<= 1;
16284 return single_offload;
16290 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16291 __rte_unused struct cmdline *cl,
16292 __rte_unused void *data)
16294 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16295 portid_t port_id = res->port_id;
16296 struct rte_eth_dev_info dev_info;
16297 struct rte_port *port = &ports[port_id];
16298 uint64_t single_offload;
16299 uint16_t nb_rx_queues;
16303 if (port->port_status != RTE_PORT_STOPPED) {
16305 "Error: Can't config offload when Port %d is not stopped\n",
16310 single_offload = search_rx_offload(res->offload);
16311 if (single_offload == 0) {
16312 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16316 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16320 nb_rx_queues = dev_info.nb_rx_queues;
16321 if (!strcmp(res->on_off, "on")) {
16322 port->dev_conf.rxmode.offloads |= single_offload;
16323 for (q = 0; q < nb_rx_queues; q++)
16324 port->rx_conf[q].offloads |= single_offload;
16326 port->dev_conf.rxmode.offloads &= ~single_offload;
16327 for (q = 0; q < nb_rx_queues; q++)
16328 port->rx_conf[q].offloads &= ~single_offload;
16331 cmd_reconfig_device_queue(port_id, 1, 1);
16334 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16335 .f = cmd_config_per_port_rx_offload_parsed,
16337 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16338 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16339 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16340 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16341 "keep_crc|rss_hash on|off",
16343 (void *)&cmd_config_per_port_rx_offload_result_port,
16344 (void *)&cmd_config_per_port_rx_offload_result_config,
16345 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16346 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16347 (void *)&cmd_config_per_port_rx_offload_result_offload,
16348 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16353 /* Enable/Disable a per queue offloading */
16354 struct cmd_config_per_queue_rx_offload_result {
16355 cmdline_fixed_string_t port;
16357 cmdline_fixed_string_t rxq;
16359 cmdline_fixed_string_t rx_offload;
16360 cmdline_fixed_string_t offload;
16361 cmdline_fixed_string_t on_off;
16364 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16365 TOKEN_STRING_INITIALIZER
16366 (struct cmd_config_per_queue_rx_offload_result,
16368 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16369 TOKEN_NUM_INITIALIZER
16370 (struct cmd_config_per_queue_rx_offload_result,
16371 port_id, RTE_UINT16);
16372 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16373 TOKEN_STRING_INITIALIZER
16374 (struct cmd_config_per_queue_rx_offload_result,
16376 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16377 TOKEN_NUM_INITIALIZER
16378 (struct cmd_config_per_queue_rx_offload_result,
16379 queue_id, RTE_UINT16);
16380 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16381 TOKEN_STRING_INITIALIZER
16382 (struct cmd_config_per_queue_rx_offload_result,
16383 rx_offload, "rx_offload");
16384 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16385 TOKEN_STRING_INITIALIZER
16386 (struct cmd_config_per_queue_rx_offload_result,
16387 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16388 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16389 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16390 "scatter#buffer_split#timestamp#security#keep_crc");
16391 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16392 TOKEN_STRING_INITIALIZER
16393 (struct cmd_config_per_queue_rx_offload_result,
16397 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16398 __rte_unused struct cmdline *cl,
16399 __rte_unused void *data)
16401 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16402 struct rte_eth_dev_info dev_info;
16403 portid_t port_id = res->port_id;
16404 uint16_t queue_id = res->queue_id;
16405 struct rte_port *port = &ports[port_id];
16406 uint64_t single_offload;
16409 if (port->port_status != RTE_PORT_STOPPED) {
16411 "Error: Can't config offload when Port %d is not stopped\n",
16416 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16420 if (queue_id >= dev_info.nb_rx_queues) {
16422 "Error: input queue_id should be 0 ... %d\n",
16423 dev_info.nb_rx_queues - 1);
16427 single_offload = search_rx_offload(res->offload);
16428 if (single_offload == 0) {
16429 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16433 if (!strcmp(res->on_off, "on"))
16434 port->rx_conf[queue_id].offloads |= single_offload;
16436 port->rx_conf[queue_id].offloads &= ~single_offload;
16438 cmd_reconfig_device_queue(port_id, 1, 1);
16441 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16442 .f = cmd_config_per_queue_rx_offload_parsed,
16444 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16445 "vlan_strip|ipv4_cksum|"
16446 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16447 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16448 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16451 (void *)&cmd_config_per_queue_rx_offload_result_port,
16452 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16453 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16454 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16455 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16456 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16457 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16462 /* Get Tx offloads capabilities */
16463 struct cmd_tx_offload_get_capa_result {
16464 cmdline_fixed_string_t show;
16465 cmdline_fixed_string_t port;
16467 cmdline_fixed_string_t tx_offload;
16468 cmdline_fixed_string_t capabilities;
16471 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16472 TOKEN_STRING_INITIALIZER
16473 (struct cmd_tx_offload_get_capa_result,
16475 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16476 TOKEN_STRING_INITIALIZER
16477 (struct cmd_tx_offload_get_capa_result,
16479 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16480 TOKEN_NUM_INITIALIZER
16481 (struct cmd_tx_offload_get_capa_result,
16482 port_id, RTE_UINT16);
16483 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16484 TOKEN_STRING_INITIALIZER
16485 (struct cmd_tx_offload_get_capa_result,
16486 tx_offload, "tx_offload");
16487 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16488 TOKEN_STRING_INITIALIZER
16489 (struct cmd_tx_offload_get_capa_result,
16490 capabilities, "capabilities");
16493 print_tx_offloads(uint64_t offloads)
16495 uint64_t single_offload;
16503 begin = __builtin_ctzll(offloads);
16504 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16506 single_offload = 1ULL << begin;
16507 for (bit = begin; bit < end; bit++) {
16508 if (offloads & single_offload)
16510 rte_eth_dev_tx_offload_name(single_offload));
16511 single_offload <<= 1;
16516 cmd_tx_offload_get_capa_parsed(
16517 void *parsed_result,
16518 __rte_unused struct cmdline *cl,
16519 __rte_unused void *data)
16521 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16522 struct rte_eth_dev_info dev_info;
16523 portid_t port_id = res->port_id;
16524 uint64_t queue_offloads;
16525 uint64_t port_offloads;
16528 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16532 queue_offloads = dev_info.tx_queue_offload_capa;
16533 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16535 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16536 printf(" Per Queue :");
16537 print_tx_offloads(queue_offloads);
16540 printf(" Per Port :");
16541 print_tx_offloads(port_offloads);
16545 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16546 .f = cmd_tx_offload_get_capa_parsed,
16548 .help_str = "show port <port_id> tx_offload capabilities",
16550 (void *)&cmd_tx_offload_get_capa_show,
16551 (void *)&cmd_tx_offload_get_capa_port,
16552 (void *)&cmd_tx_offload_get_capa_port_id,
16553 (void *)&cmd_tx_offload_get_capa_tx_offload,
16554 (void *)&cmd_tx_offload_get_capa_capabilities,
16559 /* Get Tx offloads configuration */
16560 struct cmd_tx_offload_get_configuration_result {
16561 cmdline_fixed_string_t show;
16562 cmdline_fixed_string_t port;
16564 cmdline_fixed_string_t tx_offload;
16565 cmdline_fixed_string_t configuration;
16568 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16569 TOKEN_STRING_INITIALIZER
16570 (struct cmd_tx_offload_get_configuration_result,
16572 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16573 TOKEN_STRING_INITIALIZER
16574 (struct cmd_tx_offload_get_configuration_result,
16576 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16577 TOKEN_NUM_INITIALIZER
16578 (struct cmd_tx_offload_get_configuration_result,
16579 port_id, RTE_UINT16);
16580 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16581 TOKEN_STRING_INITIALIZER
16582 (struct cmd_tx_offload_get_configuration_result,
16583 tx_offload, "tx_offload");
16584 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16585 TOKEN_STRING_INITIALIZER
16586 (struct cmd_tx_offload_get_configuration_result,
16587 configuration, "configuration");
16590 cmd_tx_offload_get_configuration_parsed(
16591 void *parsed_result,
16592 __rte_unused struct cmdline *cl,
16593 __rte_unused void *data)
16595 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16596 struct rte_eth_dev_info dev_info;
16597 portid_t port_id = res->port_id;
16598 struct rte_port *port = &ports[port_id];
16599 struct rte_eth_conf dev_conf;
16600 uint64_t port_offloads;
16601 uint64_t queue_offloads;
16602 uint16_t nb_tx_queues;
16606 printf("Tx Offloading Configuration of port %d :\n", port_id);
16608 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16612 port_offloads = dev_conf.txmode.offloads;
16614 print_tx_offloads(port_offloads);
16617 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16621 nb_tx_queues = dev_info.nb_tx_queues;
16622 for (q = 0; q < nb_tx_queues; q++) {
16623 queue_offloads = port->tx_conf[q].offloads;
16624 printf(" Queue[%2d] :", q);
16625 print_tx_offloads(queue_offloads);
16631 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16632 .f = cmd_tx_offload_get_configuration_parsed,
16634 .help_str = "show port <port_id> tx_offload configuration",
16636 (void *)&cmd_tx_offload_get_configuration_show,
16637 (void *)&cmd_tx_offload_get_configuration_port,
16638 (void *)&cmd_tx_offload_get_configuration_port_id,
16639 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16640 (void *)&cmd_tx_offload_get_configuration_configuration,
16645 /* Enable/Disable a per port offloading */
16646 struct cmd_config_per_port_tx_offload_result {
16647 cmdline_fixed_string_t port;
16648 cmdline_fixed_string_t config;
16650 cmdline_fixed_string_t tx_offload;
16651 cmdline_fixed_string_t offload;
16652 cmdline_fixed_string_t on_off;
16655 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16656 TOKEN_STRING_INITIALIZER
16657 (struct cmd_config_per_port_tx_offload_result,
16659 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16660 TOKEN_STRING_INITIALIZER
16661 (struct cmd_config_per_port_tx_offload_result,
16663 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16664 TOKEN_NUM_INITIALIZER
16665 (struct cmd_config_per_port_tx_offload_result,
16666 port_id, RTE_UINT16);
16667 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16668 TOKEN_STRING_INITIALIZER
16669 (struct cmd_config_per_port_tx_offload_result,
16670 tx_offload, "tx_offload");
16671 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16672 TOKEN_STRING_INITIALIZER
16673 (struct cmd_config_per_port_tx_offload_result,
16674 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16675 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16676 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16677 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16678 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16679 "send_on_timestamp");
16680 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16681 TOKEN_STRING_INITIALIZER
16682 (struct cmd_config_per_port_tx_offload_result,
16686 search_tx_offload(const char *name)
16688 uint64_t single_offload;
16689 const char *single_name;
16693 single_offload = 1;
16694 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16695 single_name = rte_eth_dev_tx_offload_name(single_offload);
16696 if (single_name == NULL)
16698 if (!strcasecmp(single_name, name)) {
16701 } else if (!strcasecmp(single_name, "UNKNOWN"))
16703 single_offload <<= 1;
16707 return single_offload;
16713 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16714 __rte_unused struct cmdline *cl,
16715 __rte_unused void *data)
16717 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16718 portid_t port_id = res->port_id;
16719 struct rte_eth_dev_info dev_info;
16720 struct rte_port *port = &ports[port_id];
16721 uint64_t single_offload;
16722 uint16_t nb_tx_queues;
16726 if (port->port_status != RTE_PORT_STOPPED) {
16728 "Error: Can't config offload when Port %d is not stopped\n",
16733 single_offload = search_tx_offload(res->offload);
16734 if (single_offload == 0) {
16735 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16739 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16743 nb_tx_queues = dev_info.nb_tx_queues;
16744 if (!strcmp(res->on_off, "on")) {
16745 port->dev_conf.txmode.offloads |= single_offload;
16746 for (q = 0; q < nb_tx_queues; q++)
16747 port->tx_conf[q].offloads |= single_offload;
16749 port->dev_conf.txmode.offloads &= ~single_offload;
16750 for (q = 0; q < nb_tx_queues; q++)
16751 port->tx_conf[q].offloads &= ~single_offload;
16754 cmd_reconfig_device_queue(port_id, 1, 1);
16757 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16758 .f = cmd_config_per_port_tx_offload_parsed,
16760 .help_str = "port config <port_id> tx_offload "
16761 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16762 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16763 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16764 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16765 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16766 "send_on_timestamp on|off",
16768 (void *)&cmd_config_per_port_tx_offload_result_port,
16769 (void *)&cmd_config_per_port_tx_offload_result_config,
16770 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16771 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16772 (void *)&cmd_config_per_port_tx_offload_result_offload,
16773 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16778 /* Enable/Disable a per queue offloading */
16779 struct cmd_config_per_queue_tx_offload_result {
16780 cmdline_fixed_string_t port;
16782 cmdline_fixed_string_t txq;
16784 cmdline_fixed_string_t tx_offload;
16785 cmdline_fixed_string_t offload;
16786 cmdline_fixed_string_t on_off;
16789 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16790 TOKEN_STRING_INITIALIZER
16791 (struct cmd_config_per_queue_tx_offload_result,
16793 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16794 TOKEN_NUM_INITIALIZER
16795 (struct cmd_config_per_queue_tx_offload_result,
16796 port_id, RTE_UINT16);
16797 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16798 TOKEN_STRING_INITIALIZER
16799 (struct cmd_config_per_queue_tx_offload_result,
16801 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16802 TOKEN_NUM_INITIALIZER
16803 (struct cmd_config_per_queue_tx_offload_result,
16804 queue_id, RTE_UINT16);
16805 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16806 TOKEN_STRING_INITIALIZER
16807 (struct cmd_config_per_queue_tx_offload_result,
16808 tx_offload, "tx_offload");
16809 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16810 TOKEN_STRING_INITIALIZER
16811 (struct cmd_config_per_queue_tx_offload_result,
16812 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16813 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16814 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16815 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16816 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16817 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16818 TOKEN_STRING_INITIALIZER
16819 (struct cmd_config_per_queue_tx_offload_result,
16823 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16824 __rte_unused struct cmdline *cl,
16825 __rte_unused void *data)
16827 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16828 struct rte_eth_dev_info dev_info;
16829 portid_t port_id = res->port_id;
16830 uint16_t queue_id = res->queue_id;
16831 struct rte_port *port = &ports[port_id];
16832 uint64_t single_offload;
16835 if (port->port_status != RTE_PORT_STOPPED) {
16837 "Error: Can't config offload when Port %d is not stopped\n",
16842 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16846 if (queue_id >= dev_info.nb_tx_queues) {
16848 "Error: input queue_id should be 0 ... %d\n",
16849 dev_info.nb_tx_queues - 1);
16853 single_offload = search_tx_offload(res->offload);
16854 if (single_offload == 0) {
16855 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16859 if (!strcmp(res->on_off, "on"))
16860 port->tx_conf[queue_id].offloads |= single_offload;
16862 port->tx_conf[queue_id].offloads &= ~single_offload;
16864 cmd_reconfig_device_queue(port_id, 1, 1);
16867 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16868 .f = cmd_config_per_queue_tx_offload_parsed,
16870 .help_str = "port <port_id> txq <queue_id> tx_offload "
16871 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16872 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16873 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16874 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16875 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16878 (void *)&cmd_config_per_queue_tx_offload_result_port,
16879 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16880 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16881 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16882 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16883 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16884 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16889 /* *** configure tx_metadata for specific port *** */
16890 struct cmd_config_tx_metadata_specific_result {
16891 cmdline_fixed_string_t port;
16892 cmdline_fixed_string_t keyword;
16894 cmdline_fixed_string_t item;
16899 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16900 __rte_unused struct cmdline *cl,
16901 __rte_unused void *data)
16903 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16907 ports[res->port_id].tx_metadata = res->value;
16908 /* Add/remove callback to insert valid metadata in every Tx packet. */
16909 if (ports[res->port_id].tx_metadata)
16910 add_tx_md_callback(res->port_id);
16912 remove_tx_md_callback(res->port_id);
16913 rte_flow_dynf_metadata_register();
16916 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16917 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16919 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16920 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16921 keyword, "config");
16922 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16923 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16924 port_id, RTE_UINT16);
16925 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16926 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16927 item, "tx_metadata");
16928 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16929 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16930 value, RTE_UINT32);
16932 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16933 .f = cmd_config_tx_metadata_specific_parsed,
16935 .help_str = "port config <port_id> tx_metadata <value>",
16937 (void *)&cmd_config_tx_metadata_specific_port,
16938 (void *)&cmd_config_tx_metadata_specific_keyword,
16939 (void *)&cmd_config_tx_metadata_specific_id,
16940 (void *)&cmd_config_tx_metadata_specific_item,
16941 (void *)&cmd_config_tx_metadata_specific_value,
16946 /* *** set dynf *** */
16947 struct cmd_config_tx_dynf_specific_result {
16948 cmdline_fixed_string_t port;
16949 cmdline_fixed_string_t keyword;
16951 cmdline_fixed_string_t item;
16952 cmdline_fixed_string_t name;
16953 cmdline_fixed_string_t value;
16957 cmd_config_dynf_specific_parsed(void *parsed_result,
16958 __rte_unused struct cmdline *cl,
16959 __rte_unused void *data)
16961 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16962 struct rte_mbuf_dynflag desc_flag;
16964 uint64_t old_port_flags;
16966 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16968 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16970 if (strlcpy(desc_flag.name, res->name,
16971 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16972 fprintf(stderr, "Flag name too long\n");
16975 desc_flag.flags = 0;
16976 flag = rte_mbuf_dynflag_register(&desc_flag);
16978 fprintf(stderr, "Can't register flag\n");
16981 strcpy(dynf_names[flag], desc_flag.name);
16983 old_port_flags = ports[res->port_id].mbuf_dynf;
16984 if (!strcmp(res->value, "set")) {
16985 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16986 if (old_port_flags == 0)
16987 add_tx_dynf_callback(res->port_id);
16989 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16990 if (ports[res->port_id].mbuf_dynf == 0)
16991 remove_tx_dynf_callback(res->port_id);
16995 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16996 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16998 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16999 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17000 keyword, "config");
17001 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17002 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17003 port_id, RTE_UINT16);
17004 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17005 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17007 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17008 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17010 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17011 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17012 value, "set#clear");
17014 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17015 .f = cmd_config_dynf_specific_parsed,
17017 .help_str = "port config <port id> dynf <name> set|clear",
17019 (void *)&cmd_config_tx_dynf_specific_port,
17020 (void *)&cmd_config_tx_dynf_specific_keyword,
17021 (void *)&cmd_config_tx_dynf_specific_port_id,
17022 (void *)&cmd_config_tx_dynf_specific_item,
17023 (void *)&cmd_config_tx_dynf_specific_name,
17024 (void *)&cmd_config_tx_dynf_specific_value,
17029 /* *** display tx_metadata per port configuration *** */
17030 struct cmd_show_tx_metadata_result {
17031 cmdline_fixed_string_t cmd_show;
17032 cmdline_fixed_string_t cmd_port;
17033 cmdline_fixed_string_t cmd_keyword;
17038 cmd_show_tx_metadata_parsed(void *parsed_result,
17039 __rte_unused struct cmdline *cl,
17040 __rte_unused void *data)
17042 struct cmd_show_tx_metadata_result *res = parsed_result;
17044 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17045 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17048 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17049 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17050 ports[res->cmd_pid].tx_metadata);
17054 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17055 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17057 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17058 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17060 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17061 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17062 cmd_pid, RTE_UINT16);
17063 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17064 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17065 cmd_keyword, "tx_metadata");
17067 cmdline_parse_inst_t cmd_show_tx_metadata = {
17068 .f = cmd_show_tx_metadata_parsed,
17070 .help_str = "show port <port_id> tx_metadata",
17072 (void *)&cmd_show_tx_metadata_show,
17073 (void *)&cmd_show_tx_metadata_port,
17074 (void *)&cmd_show_tx_metadata_pid,
17075 (void *)&cmd_show_tx_metadata_keyword,
17080 /* *** show fec capability per port configuration *** */
17081 struct cmd_show_fec_capability_result {
17082 cmdline_fixed_string_t cmd_show;
17083 cmdline_fixed_string_t cmd_port;
17084 cmdline_fixed_string_t cmd_fec;
17085 cmdline_fixed_string_t cmd_keyword;
17090 cmd_show_fec_capability_parsed(void *parsed_result,
17091 __rte_unused struct cmdline *cl,
17092 __rte_unused void *data)
17094 struct cmd_show_fec_capability_result *res = parsed_result;
17095 struct rte_eth_fec_capa *speed_fec_capa;
17099 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17100 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17104 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
17105 if (ret == -ENOTSUP) {
17106 fprintf(stderr, "Function not implemented\n");
17108 } else if (ret < 0) {
17109 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
17113 num = (unsigned int)ret;
17114 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
17115 if (speed_fec_capa == NULL) {
17116 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
17120 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17122 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17126 show_fec_capability(num, speed_fec_capa);
17128 free(speed_fec_capa);
17131 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17132 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17134 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17135 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17137 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17138 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17139 cmd_pid, RTE_UINT16);
17140 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17141 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17143 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17144 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17145 cmd_keyword, "capabilities");
17147 cmdline_parse_inst_t cmd_show_capability = {
17148 .f = cmd_show_fec_capability_parsed,
17150 .help_str = "show port <port_id> fec capabilities",
17152 (void *)&cmd_show_fec_capability_show,
17153 (void *)&cmd_show_fec_capability_port,
17154 (void *)&cmd_show_fec_capability_pid,
17155 (void *)&cmd_show_fec_capability_fec,
17156 (void *)&cmd_show_fec_capability_keyword,
17161 /* *** show fec mode per port configuration *** */
17162 struct cmd_show_fec_metadata_result {
17163 cmdline_fixed_string_t cmd_show;
17164 cmdline_fixed_string_t cmd_port;
17165 cmdline_fixed_string_t cmd_keyword;
17170 cmd_show_fec_mode_parsed(void *parsed_result,
17171 __rte_unused struct cmdline *cl,
17172 __rte_unused void *data)
17174 #define FEC_NAME_SIZE 16
17175 struct cmd_show_fec_metadata_result *res = parsed_result;
17177 char buf[FEC_NAME_SIZE];
17180 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17181 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17184 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17185 if (ret == -ENOTSUP) {
17186 fprintf(stderr, "Function not implemented\n");
17188 } else if (ret < 0) {
17189 fprintf(stderr, "Get FEC mode failed\n");
17194 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17195 strlcpy(buf, "off", sizeof(buf));
17197 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17198 strlcpy(buf, "auto", sizeof(buf));
17200 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17201 strlcpy(buf, "baser", sizeof(buf));
17203 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17204 strlcpy(buf, "rs", sizeof(buf));
17210 printf("%s\n", buf);
17213 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17214 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17216 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17217 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17219 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17220 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17221 cmd_pid, RTE_UINT16);
17222 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17223 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17224 cmd_keyword, "fec_mode");
17226 cmdline_parse_inst_t cmd_show_fec_mode = {
17227 .f = cmd_show_fec_mode_parsed,
17229 .help_str = "show port <port_id> fec_mode",
17231 (void *)&cmd_show_fec_mode_show,
17232 (void *)&cmd_show_fec_mode_port,
17233 (void *)&cmd_show_fec_mode_pid,
17234 (void *)&cmd_show_fec_mode_keyword,
17239 /* *** set fec mode per port configuration *** */
17240 struct cmd_set_port_fec_mode {
17241 cmdline_fixed_string_t set;
17242 cmdline_fixed_string_t port;
17244 cmdline_fixed_string_t fec_mode;
17245 cmdline_fixed_string_t fec_value;
17248 /* Common CLI fields for set fec mode */
17249 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17250 TOKEN_STRING_INITIALIZER
17251 (struct cmd_set_port_fec_mode,
17253 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17254 TOKEN_STRING_INITIALIZER
17255 (struct cmd_set_port_fec_mode,
17257 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17258 TOKEN_NUM_INITIALIZER
17259 (struct cmd_set_port_fec_mode,
17260 port_id, RTE_UINT16);
17261 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17262 TOKEN_STRING_INITIALIZER
17263 (struct cmd_set_port_fec_mode,
17264 fec_mode, "fec_mode");
17265 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17266 TOKEN_STRING_INITIALIZER
17267 (struct cmd_set_port_fec_mode,
17271 cmd_set_port_fec_mode_parsed(
17272 void *parsed_result,
17273 __rte_unused struct cmdline *cl,
17274 __rte_unused void *data)
17276 struct cmd_set_port_fec_mode *res = parsed_result;
17277 uint16_t port_id = res->port_id;
17281 ret = parse_fec_mode(res->fec_value, &fec_capa);
17283 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17284 res->fec_value, port_id);
17288 ret = rte_eth_fec_set(port_id, fec_capa);
17289 if (ret == -ENOTSUP) {
17290 fprintf(stderr, "Function not implemented\n");
17292 } else if (ret < 0) {
17293 fprintf(stderr, "Set FEC mode failed\n");
17298 cmdline_parse_inst_t cmd_set_fec_mode = {
17299 .f = cmd_set_port_fec_mode_parsed,
17301 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17303 (void *)&cmd_set_port_fec_mode_set,
17304 (void *)&cmd_set_port_fec_mode_port,
17305 (void *)&cmd_set_port_fec_mode_port_id,
17306 (void *)&cmd_set_port_fec_mode_str,
17307 (void *)&cmd_set_port_fec_mode_value,
17312 /* show port supported ptypes */
17314 /* Common result structure for show port ptypes */
17315 struct cmd_show_port_supported_ptypes_result {
17316 cmdline_fixed_string_t show;
17317 cmdline_fixed_string_t port;
17319 cmdline_fixed_string_t ptypes;
17322 /* Common CLI fields for show port ptypes */
17323 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17324 TOKEN_STRING_INITIALIZER
17325 (struct cmd_show_port_supported_ptypes_result,
17327 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17328 TOKEN_STRING_INITIALIZER
17329 (struct cmd_show_port_supported_ptypes_result,
17331 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17332 TOKEN_NUM_INITIALIZER
17333 (struct cmd_show_port_supported_ptypes_result,
17334 port_id, RTE_UINT16);
17335 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17336 TOKEN_STRING_INITIALIZER
17337 (struct cmd_show_port_supported_ptypes_result,
17341 cmd_show_port_supported_ptypes_parsed(
17342 void *parsed_result,
17343 __rte_unused struct cmdline *cl,
17344 __rte_unused void *data)
17346 #define RSVD_PTYPE_MASK 0xf0000000
17347 #define MAX_PTYPES_PER_LAYER 16
17348 #define LTYPE_NAMESIZE 32
17349 #define PTYPE_NAMESIZE 256
17350 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17351 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17352 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17353 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17354 uint16_t port_id = res->port_id;
17357 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17361 while (ptype_mask != RSVD_PTYPE_MASK) {
17363 switch (ptype_mask) {
17364 case RTE_PTYPE_L2_MASK:
17365 strlcpy(ltype, "L2", sizeof(ltype));
17367 case RTE_PTYPE_L3_MASK:
17368 strlcpy(ltype, "L3", sizeof(ltype));
17370 case RTE_PTYPE_L4_MASK:
17371 strlcpy(ltype, "L4", sizeof(ltype));
17373 case RTE_PTYPE_TUNNEL_MASK:
17374 strlcpy(ltype, "Tunnel", sizeof(ltype));
17376 case RTE_PTYPE_INNER_L2_MASK:
17377 strlcpy(ltype, "Inner L2", sizeof(ltype));
17379 case RTE_PTYPE_INNER_L3_MASK:
17380 strlcpy(ltype, "Inner L3", sizeof(ltype));
17382 case RTE_PTYPE_INNER_L4_MASK:
17383 strlcpy(ltype, "Inner L4", sizeof(ltype));
17389 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17390 ptype_mask, ptypes,
17391 MAX_PTYPES_PER_LAYER);
17394 printf("Supported %s ptypes:\n", ltype);
17396 printf("%s ptypes unsupported\n", ltype);
17398 for (i = 0; i < ret; ++i) {
17399 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17400 printf("%s\n", buf);
17407 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17408 .f = cmd_show_port_supported_ptypes_parsed,
17410 .help_str = "show port <port_id> ptypes",
17412 (void *)&cmd_show_port_supported_ptypes_show,
17413 (void *)&cmd_show_port_supported_ptypes_port,
17414 (void *)&cmd_show_port_supported_ptypes_port_id,
17415 (void *)&cmd_show_port_supported_ptypes_ptypes,
17420 /* *** display rx/tx descriptor status *** */
17421 struct cmd_show_rx_tx_desc_status_result {
17422 cmdline_fixed_string_t cmd_show;
17423 cmdline_fixed_string_t cmd_port;
17424 cmdline_fixed_string_t cmd_keyword;
17425 cmdline_fixed_string_t cmd_desc;
17426 cmdline_fixed_string_t cmd_status;
17433 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17434 __rte_unused struct cmdline *cl,
17435 __rte_unused void *data)
17437 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17440 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17441 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17445 if (!strcmp(res->cmd_keyword, "rxq")) {
17446 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17450 "Invalid input: queue id = %d, desc id = %d\n",
17451 res->cmd_qid, res->cmd_did);
17454 if (rc == RTE_ETH_RX_DESC_AVAIL)
17455 printf("Desc status = AVAILABLE\n");
17456 else if (rc == RTE_ETH_RX_DESC_DONE)
17457 printf("Desc status = DONE\n");
17459 printf("Desc status = UNAVAILABLE\n");
17460 } else if (!strcmp(res->cmd_keyword, "txq")) {
17461 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17465 "Invalid input: queue id = %d, desc id = %d\n",
17466 res->cmd_qid, res->cmd_did);
17469 if (rc == RTE_ETH_TX_DESC_FULL)
17470 printf("Desc status = FULL\n");
17471 else if (rc == RTE_ETH_TX_DESC_DONE)
17472 printf("Desc status = DONE\n");
17474 printf("Desc status = UNAVAILABLE\n");
17478 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17479 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17481 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17482 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17484 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17485 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17486 cmd_pid, RTE_UINT16);
17487 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17488 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17489 cmd_keyword, "rxq#txq");
17490 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17491 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17492 cmd_qid, RTE_UINT16);
17493 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17494 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17496 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17497 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17498 cmd_did, RTE_UINT16);
17499 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17500 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17501 cmd_status, "status");
17502 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17503 .f = cmd_show_rx_tx_desc_status_parsed,
17505 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17508 (void *)&cmd_show_rx_tx_desc_status_show,
17509 (void *)&cmd_show_rx_tx_desc_status_port,
17510 (void *)&cmd_show_rx_tx_desc_status_pid,
17511 (void *)&cmd_show_rx_tx_desc_status_keyword,
17512 (void *)&cmd_show_rx_tx_desc_status_qid,
17513 (void *)&cmd_show_rx_tx_desc_status_desc,
17514 (void *)&cmd_show_rx_tx_desc_status_did,
17515 (void *)&cmd_show_rx_tx_desc_status_status,
17520 /* *** display rx queue desc used count *** */
17521 struct cmd_show_rx_queue_desc_used_count_result {
17522 cmdline_fixed_string_t cmd_show;
17523 cmdline_fixed_string_t cmd_port;
17524 cmdline_fixed_string_t cmd_rxq;
17525 cmdline_fixed_string_t cmd_desc;
17526 cmdline_fixed_string_t cmd_used;
17527 cmdline_fixed_string_t cmd_count;
17533 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17534 __rte_unused struct cmdline *cl,
17535 __rte_unused void *data)
17537 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17540 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17541 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17545 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17547 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17550 printf("Used desc count = %d\n", rc);
17553 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17554 TOKEN_STRING_INITIALIZER
17555 (struct cmd_show_rx_queue_desc_used_count_result,
17557 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17558 TOKEN_STRING_INITIALIZER
17559 (struct cmd_show_rx_queue_desc_used_count_result,
17561 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17562 TOKEN_NUM_INITIALIZER
17563 (struct cmd_show_rx_queue_desc_used_count_result,
17564 cmd_pid, RTE_UINT16);
17565 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17566 TOKEN_STRING_INITIALIZER
17567 (struct cmd_show_rx_queue_desc_used_count_result,
17569 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17570 TOKEN_NUM_INITIALIZER
17571 (struct cmd_show_rx_queue_desc_used_count_result,
17572 cmd_qid, RTE_UINT16);
17573 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17574 TOKEN_STRING_INITIALIZER
17575 (struct cmd_show_rx_queue_desc_used_count_result,
17576 cmd_count, "desc");
17577 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17578 TOKEN_STRING_INITIALIZER
17579 (struct cmd_show_rx_queue_desc_used_count_result,
17580 cmd_count, "used");
17581 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17582 TOKEN_STRING_INITIALIZER
17583 (struct cmd_show_rx_queue_desc_used_count_result,
17584 cmd_count, "count");
17585 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17586 .f = cmd_show_rx_queue_desc_used_count_parsed,
17588 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17590 (void *)&cmd_show_rx_queue_desc_used_count_show,
17591 (void *)&cmd_show_rx_queue_desc_used_count_port,
17592 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17593 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17594 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17595 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17596 (void *)&cmd_show_rx_queue_desc_used_count_used,
17597 (void *)&cmd_show_rx_queue_desc_used_count_count,
17602 /* Common result structure for set port ptypes */
17603 struct cmd_set_port_ptypes_result {
17604 cmdline_fixed_string_t set;
17605 cmdline_fixed_string_t port;
17607 cmdline_fixed_string_t ptype_mask;
17611 /* Common CLI fields for set port ptypes */
17612 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17613 TOKEN_STRING_INITIALIZER
17614 (struct cmd_set_port_ptypes_result,
17616 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17617 TOKEN_STRING_INITIALIZER
17618 (struct cmd_set_port_ptypes_result,
17620 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17621 TOKEN_NUM_INITIALIZER
17622 (struct cmd_set_port_ptypes_result,
17623 port_id, RTE_UINT16);
17624 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17625 TOKEN_STRING_INITIALIZER
17626 (struct cmd_set_port_ptypes_result,
17627 ptype_mask, "ptype_mask");
17628 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17629 TOKEN_NUM_INITIALIZER
17630 (struct cmd_set_port_ptypes_result,
17634 cmd_set_port_ptypes_parsed(
17635 void *parsed_result,
17636 __rte_unused struct cmdline *cl,
17637 __rte_unused void *data)
17639 struct cmd_set_port_ptypes_result *res = parsed_result;
17640 #define PTYPE_NAMESIZE 256
17641 char ptype_name[PTYPE_NAMESIZE];
17642 uint16_t port_id = res->port_id;
17643 uint32_t ptype_mask = res->mask;
17646 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17649 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17654 uint32_t ptypes[ret];
17656 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17658 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17663 printf("Successfully set following ptypes for Port %d\n", port_id);
17664 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17665 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17666 printf("%s\n", ptype_name);
17669 clear_ptypes = false;
17672 cmdline_parse_inst_t cmd_set_port_ptypes = {
17673 .f = cmd_set_port_ptypes_parsed,
17675 .help_str = "set port <port_id> ptype_mask <mask>",
17677 (void *)&cmd_set_port_ptypes_set,
17678 (void *)&cmd_set_port_ptypes_port,
17679 (void *)&cmd_set_port_ptypes_port_id,
17680 (void *)&cmd_set_port_ptypes_mask_str,
17681 (void *)&cmd_set_port_ptypes_mask_u32,
17686 /* *** display mac addresses added to a port *** */
17687 struct cmd_showport_macs_result {
17688 cmdline_fixed_string_t cmd_show;
17689 cmdline_fixed_string_t cmd_port;
17690 cmdline_fixed_string_t cmd_keyword;
17695 cmd_showport_macs_parsed(void *parsed_result,
17696 __rte_unused struct cmdline *cl,
17697 __rte_unused void *data)
17699 struct cmd_showport_macs_result *res = parsed_result;
17701 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17704 if (!strcmp(res->cmd_keyword, "macs"))
17705 show_macs(res->cmd_pid);
17706 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17707 show_mcast_macs(res->cmd_pid);
17710 cmdline_parse_token_string_t cmd_showport_macs_show =
17711 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17713 cmdline_parse_token_string_t cmd_showport_macs_port =
17714 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17716 cmdline_parse_token_num_t cmd_showport_macs_pid =
17717 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17718 cmd_pid, RTE_UINT16);
17719 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17720 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17721 cmd_keyword, "macs#mcast_macs");
17723 cmdline_parse_inst_t cmd_showport_macs = {
17724 .f = cmd_showport_macs_parsed,
17726 .help_str = "show port <port_id> macs|mcast_macs",
17728 (void *)&cmd_showport_macs_show,
17729 (void *)&cmd_showport_macs_port,
17730 (void *)&cmd_showport_macs_pid,
17731 (void *)&cmd_showport_macs_keyword,
17736 /* *** show flow transfer proxy port ID for the given port *** */
17737 struct cmd_show_port_flow_transfer_proxy_result {
17738 cmdline_fixed_string_t show;
17739 cmdline_fixed_string_t port;
17741 cmdline_fixed_string_t flow;
17742 cmdline_fixed_string_t transfer;
17743 cmdline_fixed_string_t proxy;
17746 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17747 TOKEN_STRING_INITIALIZER
17748 (struct cmd_show_port_flow_transfer_proxy_result,
17750 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17751 TOKEN_STRING_INITIALIZER
17752 (struct cmd_show_port_flow_transfer_proxy_result,
17754 cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17755 TOKEN_NUM_INITIALIZER
17756 (struct cmd_show_port_flow_transfer_proxy_result,
17757 port_id, RTE_UINT16);
17758 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17759 TOKEN_STRING_INITIALIZER
17760 (struct cmd_show_port_flow_transfer_proxy_result,
17762 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17763 TOKEN_STRING_INITIALIZER
17764 (struct cmd_show_port_flow_transfer_proxy_result,
17765 transfer, "transfer");
17766 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17767 TOKEN_STRING_INITIALIZER
17768 (struct cmd_show_port_flow_transfer_proxy_result,
17772 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17773 __rte_unused struct cmdline *cl,
17774 __rte_unused void *data)
17776 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17777 portid_t proxy_port_id;
17782 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17784 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17785 rte_strerror(-ret));
17789 printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17792 cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17793 .f = cmd_show_port_flow_transfer_proxy_parsed,
17795 .help_str = "show port <port_id> flow transfer proxy",
17797 (void *)&cmd_show_port_flow_transfer_proxy_show,
17798 (void *)&cmd_show_port_flow_transfer_proxy_port,
17799 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
17800 (void *)&cmd_show_port_flow_transfer_proxy_flow,
17801 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
17802 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
17807 /* ******************************************************************************** */
17809 /* list of instructions */
17810 cmdline_parse_ctx_t main_ctx[] = {
17811 (cmdline_parse_inst_t *)&cmd_help_brief,
17812 (cmdline_parse_inst_t *)&cmd_help_long,
17813 (cmdline_parse_inst_t *)&cmd_quit,
17814 (cmdline_parse_inst_t *)&cmd_load_from_file,
17815 (cmdline_parse_inst_t *)&cmd_showport,
17816 (cmdline_parse_inst_t *)&cmd_showqueue,
17817 (cmdline_parse_inst_t *)&cmd_showeeprom,
17818 (cmdline_parse_inst_t *)&cmd_showportall,
17819 (cmdline_parse_inst_t *)&cmd_representor_info,
17820 (cmdline_parse_inst_t *)&cmd_showdevice,
17821 (cmdline_parse_inst_t *)&cmd_showcfg,
17822 (cmdline_parse_inst_t *)&cmd_showfwdall,
17823 (cmdline_parse_inst_t *)&cmd_start,
17824 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17825 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17826 (cmdline_parse_inst_t *)&cmd_set_link_up,
17827 (cmdline_parse_inst_t *)&cmd_set_link_down,
17828 (cmdline_parse_inst_t *)&cmd_reset,
17829 (cmdline_parse_inst_t *)&cmd_set_numbers,
17830 (cmdline_parse_inst_t *)&cmd_set_log,
17831 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17832 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17833 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17834 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17835 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17836 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17837 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17838 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17839 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17840 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17841 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17842 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17843 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17844 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17845 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17846 (cmdline_parse_inst_t *)&cmd_set_link_check,
17847 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17848 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17849 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17850 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17851 #ifdef RTE_NET_BOND
17852 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17853 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17854 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17855 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17856 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17857 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17858 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17859 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17860 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17861 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17862 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17863 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17865 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17866 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17867 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17868 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17869 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17870 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17871 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17872 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17873 (cmdline_parse_inst_t *)&cmd_csum_set,
17874 (cmdline_parse_inst_t *)&cmd_csum_show,
17875 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17876 (cmdline_parse_inst_t *)&cmd_tso_set,
17877 (cmdline_parse_inst_t *)&cmd_tso_show,
17878 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17879 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17881 (cmdline_parse_inst_t *)&cmd_gro_enable,
17882 (cmdline_parse_inst_t *)&cmd_gro_flush,
17883 (cmdline_parse_inst_t *)&cmd_gro_show,
17886 (cmdline_parse_inst_t *)&cmd_gso_enable,
17887 (cmdline_parse_inst_t *)&cmd_gso_size,
17888 (cmdline_parse_inst_t *)&cmd_gso_show,
17890 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17891 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17892 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17893 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17894 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17895 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17896 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17897 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17898 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17899 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17900 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17901 (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
17902 (cmdline_parse_inst_t *)&cmd_config_dcb,
17903 (cmdline_parse_inst_t *)&cmd_read_reg,
17904 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17905 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17906 (cmdline_parse_inst_t *)&cmd_write_reg,
17907 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17908 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17909 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17910 (cmdline_parse_inst_t *)&cmd_stop,
17911 (cmdline_parse_inst_t *)&cmd_mac_addr,
17912 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17913 (cmdline_parse_inst_t *)&cmd_set_qmap,
17914 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17915 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17916 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17917 (cmdline_parse_inst_t *)&cmd_operate_port,
17918 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17919 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17920 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17921 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17922 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17923 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17924 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17925 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17926 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17927 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17928 (cmdline_parse_inst_t *)&cmd_config_mtu,
17929 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17930 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17931 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17932 (cmdline_parse_inst_t *)&cmd_config_rss,
17933 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17934 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17935 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17936 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17937 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17938 (cmdline_parse_inst_t *)&cmd_showport_reta,
17939 (cmdline_parse_inst_t *)&cmd_showport_macs,
17940 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17941 (cmdline_parse_inst_t *)&cmd_config_burst,
17942 (cmdline_parse_inst_t *)&cmd_config_thresh,
17943 (cmdline_parse_inst_t *)&cmd_config_threshold,
17944 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17945 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17946 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17947 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17948 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17949 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17950 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17951 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17952 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17953 (cmdline_parse_inst_t *)&cmd_dump,
17954 (cmdline_parse_inst_t *)&cmd_dump_one,
17955 #ifdef RTE_NET_I40E
17956 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17958 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17959 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17960 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17961 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17962 (cmdline_parse_inst_t *)&cmd_flow,
17963 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17964 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17965 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17966 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm_rfc4115,
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;