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 if (res->value < RTE_ETHER_MIN_LEN) {
2054 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2057 port_mtu_set(res->port_id, res->value);
2060 cmdline_parse_token_string_t cmd_config_mtu_port =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2063 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2066 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2069 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2070 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2072 cmdline_parse_token_num_t cmd_config_mtu_value =
2073 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2076 cmdline_parse_inst_t cmd_config_mtu = {
2077 .f = cmd_config_mtu_parsed,
2079 .help_str = "port config mtu <port_id> <value>",
2081 (void *)&cmd_config_mtu_port,
2082 (void *)&cmd_config_mtu_keyword,
2083 (void *)&cmd_config_mtu_mtu,
2084 (void *)&cmd_config_mtu_port_id,
2085 (void *)&cmd_config_mtu_value,
2090 /* *** configure rx mode *** */
2091 struct cmd_config_rx_mode_flag {
2092 cmdline_fixed_string_t port;
2093 cmdline_fixed_string_t keyword;
2094 cmdline_fixed_string_t all;
2095 cmdline_fixed_string_t name;
2096 cmdline_fixed_string_t value;
2100 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2101 __rte_unused struct cmdline *cl,
2102 __rte_unused void *data)
2104 struct cmd_config_rx_mode_flag *res = parsed_result;
2106 if (!all_ports_stopped()) {
2107 fprintf(stderr, "Please stop all ports first\n");
2111 if (!strcmp(res->name, "drop-en")) {
2112 if (!strcmp(res->value, "on"))
2114 else if (!strcmp(res->value, "off"))
2117 fprintf(stderr, "Unknown parameter\n");
2121 fprintf(stderr, "Unknown parameter\n");
2127 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2130 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2131 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2132 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2133 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2135 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2137 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2138 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2140 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2141 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2144 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2145 .f = cmd_config_rx_mode_flag_parsed,
2147 .help_str = "port config all drop-en on|off",
2149 (void *)&cmd_config_rx_mode_flag_port,
2150 (void *)&cmd_config_rx_mode_flag_keyword,
2151 (void *)&cmd_config_rx_mode_flag_all,
2152 (void *)&cmd_config_rx_mode_flag_name,
2153 (void *)&cmd_config_rx_mode_flag_value,
2158 /* *** configure rss *** */
2159 struct cmd_config_rss {
2160 cmdline_fixed_string_t port;
2161 cmdline_fixed_string_t keyword;
2162 cmdline_fixed_string_t all;
2163 cmdline_fixed_string_t name;
2164 cmdline_fixed_string_t value;
2168 cmd_config_rss_parsed(void *parsed_result,
2169 __rte_unused struct cmdline *cl,
2170 __rte_unused void *data)
2172 struct cmd_config_rss *res = parsed_result;
2173 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2174 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2175 int use_default = 0;
2176 int all_updated = 1;
2181 if (!strcmp(res->value, "all"))
2182 rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2183 RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2184 RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2185 RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2186 RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_L2TPV2;
2187 else if (!strcmp(res->value, "eth"))
2188 rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2189 else if (!strcmp(res->value, "vlan"))
2190 rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2191 else if (!strcmp(res->value, "ip"))
2192 rss_conf.rss_hf = RTE_ETH_RSS_IP;
2193 else if (!strcmp(res->value, "udp"))
2194 rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2195 else if (!strcmp(res->value, "tcp"))
2196 rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2197 else if (!strcmp(res->value, "sctp"))
2198 rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2199 else if (!strcmp(res->value, "ether"))
2200 rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2201 else if (!strcmp(res->value, "port"))
2202 rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2203 else if (!strcmp(res->value, "vxlan"))
2204 rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2205 else if (!strcmp(res->value, "geneve"))
2206 rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2207 else if (!strcmp(res->value, "nvgre"))
2208 rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2209 else if (!strcmp(res->value, "l3-pre32"))
2210 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2211 else if (!strcmp(res->value, "l3-pre40"))
2212 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2213 else if (!strcmp(res->value, "l3-pre48"))
2214 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2215 else if (!strcmp(res->value, "l3-pre56"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2217 else if (!strcmp(res->value, "l3-pre64"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2219 else if (!strcmp(res->value, "l3-pre96"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2221 else if (!strcmp(res->value, "l3-src-only"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2223 else if (!strcmp(res->value, "l3-dst-only"))
2224 rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2225 else if (!strcmp(res->value, "l4-src-only"))
2226 rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2227 else if (!strcmp(res->value, "l4-dst-only"))
2228 rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2229 else if (!strcmp(res->value, "l2-src-only"))
2230 rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2231 else if (!strcmp(res->value, "l2-dst-only"))
2232 rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2233 else if (!strcmp(res->value, "l2tpv3"))
2234 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2235 else if (!strcmp(res->value, "esp"))
2236 rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2237 else if (!strcmp(res->value, "ah"))
2238 rss_conf.rss_hf = RTE_ETH_RSS_AH;
2239 else if (!strcmp(res->value, "pfcp"))
2240 rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2241 else if (!strcmp(res->value, "pppoe"))
2242 rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2243 else if (!strcmp(res->value, "gtpu"))
2244 rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2245 else if (!strcmp(res->value, "ecpri"))
2246 rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2247 else if (!strcmp(res->value, "mpls"))
2248 rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2249 else if (!strcmp(res->value, "ipv4-chksum"))
2250 rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2251 else if (!strcmp(res->value, "l2tpv2"))
2252 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV2;
2253 else if (!strcmp(res->value, "none"))
2254 rss_conf.rss_hf = 0;
2255 else if (!strcmp(res->value, "level-default")) {
2256 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2257 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2258 } else if (!strcmp(res->value, "level-outer")) {
2259 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2260 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2261 } else if (!strcmp(res->value, "level-inner")) {
2262 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2263 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2264 } else if (!strcmp(res->value, "default"))
2266 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2267 atoi(res->value) < 64)
2268 rss_conf.rss_hf = 1ULL << atoi(res->value);
2270 fprintf(stderr, "Unknown parameter\n");
2273 rss_conf.rss_key = NULL;
2274 /* Update global configuration for RSS types. */
2275 RTE_ETH_FOREACH_DEV(i) {
2276 struct rte_eth_rss_conf local_rss_conf;
2278 ret = eth_dev_info_get_print_err(i, &dev_info);
2283 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2285 local_rss_conf = rss_conf;
2286 local_rss_conf.rss_hf = rss_conf.rss_hf &
2287 dev_info.flow_type_rss_offloads;
2288 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2289 printf("Port %u modified RSS hash function based on hardware support,"
2290 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2291 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2293 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2297 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2298 i, -diag, strerror(-diag));
2301 if (all_updated && !use_default) {
2302 rss_hf = rss_conf.rss_hf;
2303 printf("rss_hf %#"PRIx64"\n", rss_hf);
2307 cmdline_parse_token_string_t cmd_config_rss_port =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2309 cmdline_parse_token_string_t cmd_config_rss_keyword =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2311 cmdline_parse_token_string_t cmd_config_rss_all =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2313 cmdline_parse_token_string_t cmd_config_rss_name =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2315 cmdline_parse_token_string_t cmd_config_rss_value =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2318 cmdline_parse_inst_t cmd_config_rss = {
2319 .f = cmd_config_rss_parsed,
2321 .help_str = "port config all rss "
2322 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2323 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|l2tpv2|"
2324 "none|level-default|level-outer|level-inner|<flowtype_id>",
2326 (void *)&cmd_config_rss_port,
2327 (void *)&cmd_config_rss_keyword,
2328 (void *)&cmd_config_rss_all,
2329 (void *)&cmd_config_rss_name,
2330 (void *)&cmd_config_rss_value,
2335 /* *** configure rss hash key *** */
2336 struct cmd_config_rss_hash_key {
2337 cmdline_fixed_string_t port;
2338 cmdline_fixed_string_t config;
2340 cmdline_fixed_string_t rss_hash_key;
2341 cmdline_fixed_string_t rss_type;
2342 cmdline_fixed_string_t key;
2346 hexa_digit_to_value(char hexa_digit)
2348 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2349 return (uint8_t) (hexa_digit - '0');
2350 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2351 return (uint8_t) ((hexa_digit - 'a') + 10);
2352 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2353 return (uint8_t) ((hexa_digit - 'A') + 10);
2354 /* Invalid hexa digit */
2359 parse_and_check_key_hexa_digit(char *key, int idx)
2363 hexa_v = hexa_digit_to_value(key[idx]);
2366 "invalid key: character %c at position %d is not a valid hexa digit\n",
2372 cmd_config_rss_hash_key_parsed(void *parsed_result,
2373 __rte_unused struct cmdline *cl,
2374 __rte_unused void *data)
2376 struct cmd_config_rss_hash_key *res = parsed_result;
2377 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2381 struct rte_eth_dev_info dev_info;
2382 uint8_t hash_key_size;
2386 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2390 if (dev_info.hash_key_size > 0 &&
2391 dev_info.hash_key_size <= sizeof(hash_key))
2392 hash_key_size = dev_info.hash_key_size;
2395 "dev_info did not provide a valid hash key size\n");
2398 /* Check the length of the RSS hash key */
2399 key_len = strlen(res->key);
2400 if (key_len != (hash_key_size * 2)) {
2402 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2403 (int)key_len, hash_key_size * 2);
2406 /* Translate RSS hash key into binary representation */
2407 for (i = 0; i < hash_key_size; i++) {
2408 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2411 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2414 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2416 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2420 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2421 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2422 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2423 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2425 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2426 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2428 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2429 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2430 rss_hash_key, "rss-hash-key");
2431 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2432 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2433 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2434 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2435 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2436 "ipv6-tcp-ex#ipv6-udp-ex#"
2437 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2438 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2439 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2440 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2441 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2443 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2444 .f = cmd_config_rss_hash_key_parsed,
2446 .help_str = "port config <port_id> rss-hash-key "
2447 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2448 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2449 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2450 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2451 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2452 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2453 "<string of hex digits (variable length, NIC dependent)>",
2455 (void *)&cmd_config_rss_hash_key_port,
2456 (void *)&cmd_config_rss_hash_key_config,
2457 (void *)&cmd_config_rss_hash_key_port_id,
2458 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2459 (void *)&cmd_config_rss_hash_key_rss_type,
2460 (void *)&cmd_config_rss_hash_key_value,
2465 /* *** cleanup txq mbufs *** */
2466 struct cmd_cleanup_txq_mbufs_result {
2467 cmdline_fixed_string_t port;
2468 cmdline_fixed_string_t keyword;
2469 cmdline_fixed_string_t name;
2476 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2477 __rte_unused struct cmdline *cl,
2478 __rte_unused void *data)
2480 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2481 uint16_t port_id = res->port_id;
2482 uint16_t queue_id = res->queue_id;
2483 uint32_t free_cnt = res->free_cnt;
2484 struct rte_eth_txq_info qinfo;
2487 if (test_done == 0) {
2488 fprintf(stderr, "Please stop forwarding first\n");
2492 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2493 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2498 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2499 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2503 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2506 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2507 port_id, queue_id, strerror(-ret), ret);
2511 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2512 port_id, queue_id, ret);
2515 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2516 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2518 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2519 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2521 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2522 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2524 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2525 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2527 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2528 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2530 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2531 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2534 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2535 .f = cmd_cleanup_txq_mbufs_parsed,
2537 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2539 (void *)&cmd_cleanup_txq_mbufs_port,
2540 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2541 (void *)&cmd_cleanup_txq_mbufs_port_id,
2542 (void *)&cmd_cleanup_txq_mbufs_txq,
2543 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2544 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2549 /* *** configure port rxq/txq ring size *** */
2550 struct cmd_config_rxtx_ring_size {
2551 cmdline_fixed_string_t port;
2552 cmdline_fixed_string_t config;
2554 cmdline_fixed_string_t rxtxq;
2556 cmdline_fixed_string_t rsize;
2561 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2562 __rte_unused struct cmdline *cl,
2563 __rte_unused void *data)
2565 struct cmd_config_rxtx_ring_size *res = parsed_result;
2566 struct rte_port *port;
2569 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2572 if (res->portid == (portid_t)RTE_PORT_ALL) {
2573 fprintf(stderr, "Invalid port id\n");
2577 port = &ports[res->portid];
2579 if (!strcmp(res->rxtxq, "rxq"))
2581 else if (!strcmp(res->rxtxq, "txq"))
2584 fprintf(stderr, "Unknown parameter\n");
2588 if (isrx && rx_queue_id_is_invalid(res->qid))
2590 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2593 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2595 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2601 port->nb_rx_desc[res->qid] = res->size;
2603 port->nb_tx_desc[res->qid] = res->size;
2605 cmd_reconfig_device_queue(res->portid, 0, 1);
2608 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2609 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2611 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2612 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2614 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2615 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2616 portid, RTE_UINT16);
2617 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2618 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2620 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2621 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2623 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2624 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2625 rsize, "ring_size");
2626 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2627 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2630 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2631 .f = cmd_config_rxtx_ring_size_parsed,
2633 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2635 (void *)&cmd_config_rxtx_ring_size_port,
2636 (void *)&cmd_config_rxtx_ring_size_config,
2637 (void *)&cmd_config_rxtx_ring_size_portid,
2638 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2639 (void *)&cmd_config_rxtx_ring_size_qid,
2640 (void *)&cmd_config_rxtx_ring_size_rsize,
2641 (void *)&cmd_config_rxtx_ring_size_size,
2646 /* *** configure port rxq/txq start/stop *** */
2647 struct cmd_config_rxtx_queue {
2648 cmdline_fixed_string_t port;
2650 cmdline_fixed_string_t rxtxq;
2652 cmdline_fixed_string_t opname;
2656 cmd_config_rxtx_queue_parsed(void *parsed_result,
2657 __rte_unused struct cmdline *cl,
2658 __rte_unused void *data)
2660 struct cmd_config_rxtx_queue *res = parsed_result;
2665 if (test_done == 0) {
2666 fprintf(stderr, "Please stop forwarding first\n");
2670 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2673 if (port_is_started(res->portid) != 1) {
2674 fprintf(stderr, "Please start port %u first\n", res->portid);
2678 if (!strcmp(res->rxtxq, "rxq"))
2680 else if (!strcmp(res->rxtxq, "txq"))
2683 fprintf(stderr, "Unknown parameter\n");
2687 if (isrx && rx_queue_id_is_invalid(res->qid))
2689 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2692 if (!strcmp(res->opname, "start"))
2694 else if (!strcmp(res->opname, "stop"))
2697 fprintf(stderr, "Unknown parameter\n");
2701 if (isstart && isrx)
2702 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2703 else if (!isstart && isrx)
2704 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2705 else if (isstart && !isrx)
2706 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2708 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2710 if (ret == -ENOTSUP)
2711 fprintf(stderr, "Function not supported in PMD\n");
2714 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2715 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2716 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2717 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2718 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2719 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2720 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2721 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2722 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2723 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2726 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2727 .f = cmd_config_rxtx_queue_parsed,
2729 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2731 (void *)&cmd_config_rxtx_queue_port,
2732 (void *)&cmd_config_rxtx_queue_portid,
2733 (void *)&cmd_config_rxtx_queue_rxtxq,
2734 (void *)&cmd_config_rxtx_queue_qid,
2735 (void *)&cmd_config_rxtx_queue_opname,
2740 /* *** configure port rxq/txq deferred start on/off *** */
2741 struct cmd_config_deferred_start_rxtx_queue {
2742 cmdline_fixed_string_t port;
2744 cmdline_fixed_string_t rxtxq;
2746 cmdline_fixed_string_t opname;
2747 cmdline_fixed_string_t state;
2751 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2752 __rte_unused struct cmdline *cl,
2753 __rte_unused void *data)
2755 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2756 struct rte_port *port;
2759 uint8_t needreconfig = 0;
2761 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2764 if (port_is_started(res->port_id) != 0) {
2765 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2769 port = &ports[res->port_id];
2771 isrx = !strcmp(res->rxtxq, "rxq");
2773 if (isrx && rx_queue_id_is_invalid(res->qid))
2775 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2778 ison = !strcmp(res->state, "on");
2780 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2781 port->rx_conf[res->qid].rx_deferred_start = ison;
2783 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2784 port->tx_conf[res->qid].tx_deferred_start = ison;
2789 cmd_reconfig_device_queue(res->port_id, 0, 1);
2792 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2793 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2795 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2796 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2797 port_id, RTE_UINT16);
2798 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2799 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2801 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2802 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2804 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2805 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2806 opname, "deferred_start");
2807 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2808 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2811 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2812 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2814 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2816 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2817 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2818 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2819 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2820 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2821 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2826 /* *** configure port rxq/txq setup *** */
2827 struct cmd_setup_rxtx_queue {
2828 cmdline_fixed_string_t port;
2830 cmdline_fixed_string_t rxtxq;
2832 cmdline_fixed_string_t setup;
2835 /* Common CLI fields for queue setup */
2836 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2837 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2838 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2839 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2840 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2841 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2842 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2843 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2844 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2845 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2848 cmd_setup_rxtx_queue_parsed(
2849 void *parsed_result,
2850 __rte_unused struct cmdline *cl,
2851 __rte_unused void *data)
2853 struct cmd_setup_rxtx_queue *res = parsed_result;
2854 struct rte_port *port;
2855 struct rte_mempool *mp;
2856 unsigned int socket_id;
2860 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2863 if (res->portid == (portid_t)RTE_PORT_ALL) {
2864 fprintf(stderr, "Invalid port id\n");
2868 if (!strcmp(res->rxtxq, "rxq"))
2870 else if (!strcmp(res->rxtxq, "txq"))
2873 fprintf(stderr, "Unknown parameter\n");
2877 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2878 fprintf(stderr, "Invalid rx queue\n");
2880 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2881 fprintf(stderr, "Invalid tx queue\n");
2885 port = &ports[res->portid];
2887 socket_id = rxring_numa[res->portid];
2888 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2889 socket_id = port->socket_id;
2891 mp = mbuf_pool_find(socket_id, 0);
2894 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2895 rxring_numa[res->portid]);
2898 ret = rx_queue_setup(res->portid,
2900 port->nb_rx_desc[res->qid],
2902 &port->rx_conf[res->qid],
2905 fprintf(stderr, "Failed to setup RX queue\n");
2907 socket_id = txring_numa[res->portid];
2908 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2909 socket_id = port->socket_id;
2911 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2913 "Failed to setup TX queue: not enough descriptors\n");
2916 ret = rte_eth_tx_queue_setup(res->portid,
2918 port->nb_tx_desc[res->qid],
2920 &port->tx_conf[res->qid]);
2922 fprintf(stderr, "Failed to setup TX queue\n");
2926 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2927 .f = cmd_setup_rxtx_queue_parsed,
2929 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2931 (void *)&cmd_setup_rxtx_queue_port,
2932 (void *)&cmd_setup_rxtx_queue_portid,
2933 (void *)&cmd_setup_rxtx_queue_rxtxq,
2934 (void *)&cmd_setup_rxtx_queue_qid,
2935 (void *)&cmd_setup_rxtx_queue_setup,
2941 /* *** Configure RSS RETA *** */
2942 struct cmd_config_rss_reta {
2943 cmdline_fixed_string_t port;
2944 cmdline_fixed_string_t keyword;
2946 cmdline_fixed_string_t name;
2947 cmdline_fixed_string_t list_name;
2948 cmdline_fixed_string_t list_of_items;
2952 parse_reta_config(const char *str,
2953 struct rte_eth_rss_reta_entry64 *reta_conf,
2954 uint16_t nb_entries)
2958 uint16_t hash_index, idx, shift;
2961 const char *p, *p0 = str;
2968 unsigned long int_fld[_NUM_FLD];
2969 char *str_fld[_NUM_FLD];
2971 while ((p = strchr(p0,'(')) != NULL) {
2973 if((p0 = strchr(p,')')) == NULL)
2977 if(size >= sizeof(s))
2980 snprintf(s, sizeof(s), "%.*s", size, p);
2981 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2983 for (i = 0; i < _NUM_FLD; i++) {
2985 int_fld[i] = strtoul(str_fld[i], &end, 0);
2986 if (errno != 0 || end == str_fld[i] ||
2991 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2992 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2994 if (hash_index >= nb_entries) {
2995 fprintf(stderr, "Invalid RETA hash index=%d\n",
3000 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3001 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3002 reta_conf[idx].mask |= (1ULL << shift);
3003 reta_conf[idx].reta[shift] = nb_queue;
3010 cmd_set_rss_reta_parsed(void *parsed_result,
3011 __rte_unused struct cmdline *cl,
3012 __rte_unused void *data)
3015 struct rte_eth_dev_info dev_info;
3016 struct rte_eth_rss_reta_entry64 reta_conf[8];
3017 struct cmd_config_rss_reta *res = parsed_result;
3019 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3023 if (dev_info.reta_size == 0) {
3025 "Redirection table size is 0 which is invalid for RSS\n");
3028 printf("The reta size of port %d is %u\n",
3029 res->port_id, dev_info.reta_size);
3030 if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3032 "Currently do not support more than %u entries of redirection table\n",
3033 RTE_ETH_RSS_RETA_SIZE_512);
3037 memset(reta_conf, 0, sizeof(reta_conf));
3038 if (!strcmp(res->list_name, "reta")) {
3039 if (parse_reta_config(res->list_of_items, reta_conf,
3040 dev_info.reta_size)) {
3042 "Invalid RSS Redirection Table config entered\n");
3045 ret = rte_eth_dev_rss_reta_update(res->port_id,
3046 reta_conf, dev_info.reta_size);
3049 "Bad redirection table parameter, return code = %d\n",
3054 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3056 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3058 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3059 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3060 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3062 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3064 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3067 cmdline_parse_inst_t cmd_config_rss_reta = {
3068 .f = cmd_set_rss_reta_parsed,
3070 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3072 (void *)&cmd_config_rss_reta_port,
3073 (void *)&cmd_config_rss_reta_keyword,
3074 (void *)&cmd_config_rss_reta_port_id,
3075 (void *)&cmd_config_rss_reta_name,
3076 (void *)&cmd_config_rss_reta_list_name,
3077 (void *)&cmd_config_rss_reta_list_of_items,
3082 /* *** SHOW PORT RETA INFO *** */
3083 struct cmd_showport_reta {
3084 cmdline_fixed_string_t show;
3085 cmdline_fixed_string_t port;
3087 cmdline_fixed_string_t rss;
3088 cmdline_fixed_string_t reta;
3090 cmdline_fixed_string_t list_of_items;
3094 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3095 uint16_t nb_entries,
3099 const char *p, *p0 = str;
3104 uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3105 RTE_ETH_RETA_GROUP_SIZE;
3108 p = strchr(p0, '(');
3112 p0 = strchr(p, ')');
3116 if (size >= sizeof(s)) {
3118 "The string size exceeds the internal buffer size\n");
3121 snprintf(s, sizeof(s), "%.*s", size, p);
3122 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3123 if (ret <= 0 || ret != num) {
3125 "The bits of masks do not match the number of reta entries: %u\n",
3129 for (i = 0; i < ret; i++)
3130 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3136 cmd_showport_reta_parsed(void *parsed_result,
3137 __rte_unused struct cmdline *cl,
3138 __rte_unused void *data)
3140 struct cmd_showport_reta *res = parsed_result;
3141 struct rte_eth_rss_reta_entry64 reta_conf[8];
3142 struct rte_eth_dev_info dev_info;
3143 uint16_t max_reta_size;
3146 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3150 max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3151 if (res->size == 0 || res->size > max_reta_size) {
3152 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3153 res->size, max_reta_size);
3157 memset(reta_conf, 0, sizeof(reta_conf));
3158 if (showport_parse_reta_config(reta_conf, res->size,
3159 res->list_of_items) < 0) {
3160 fprintf(stderr, "Invalid string: %s for reta masks\n",
3161 res->list_of_items);
3164 port_rss_reta_info(res->port_id, reta_conf, res->size);
3167 cmdline_parse_token_string_t cmd_showport_reta_show =
3168 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3169 cmdline_parse_token_string_t cmd_showport_reta_port =
3170 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3171 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3172 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3173 cmdline_parse_token_string_t cmd_showport_reta_rss =
3174 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3175 cmdline_parse_token_string_t cmd_showport_reta_reta =
3176 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3177 cmdline_parse_token_num_t cmd_showport_reta_size =
3178 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3179 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3180 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3181 list_of_items, NULL);
3183 cmdline_parse_inst_t cmd_showport_reta = {
3184 .f = cmd_showport_reta_parsed,
3186 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3188 (void *)&cmd_showport_reta_show,
3189 (void *)&cmd_showport_reta_port,
3190 (void *)&cmd_showport_reta_port_id,
3191 (void *)&cmd_showport_reta_rss,
3192 (void *)&cmd_showport_reta_reta,
3193 (void *)&cmd_showport_reta_size,
3194 (void *)&cmd_showport_reta_list_of_items,
3199 /* *** Show RSS hash configuration *** */
3200 struct cmd_showport_rss_hash {
3201 cmdline_fixed_string_t show;
3202 cmdline_fixed_string_t port;
3204 cmdline_fixed_string_t rss_hash;
3205 cmdline_fixed_string_t rss_type;
3206 cmdline_fixed_string_t key; /* optional argument */
3209 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3210 __rte_unused struct cmdline *cl,
3213 struct cmd_showport_rss_hash *res = parsed_result;
3215 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3218 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3219 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3220 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3221 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3222 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3223 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3225 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3226 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3228 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3229 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3231 cmdline_parse_inst_t cmd_showport_rss_hash = {
3232 .f = cmd_showport_rss_hash_parsed,
3234 .help_str = "show port <port_id> rss-hash",
3236 (void *)&cmd_showport_rss_hash_show,
3237 (void *)&cmd_showport_rss_hash_port,
3238 (void *)&cmd_showport_rss_hash_port_id,
3239 (void *)&cmd_showport_rss_hash_rss_hash,
3244 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3245 .f = cmd_showport_rss_hash_parsed,
3247 .help_str = "show port <port_id> rss-hash key",
3249 (void *)&cmd_showport_rss_hash_show,
3250 (void *)&cmd_showport_rss_hash_port,
3251 (void *)&cmd_showport_rss_hash_port_id,
3252 (void *)&cmd_showport_rss_hash_rss_hash,
3253 (void *)&cmd_showport_rss_hash_rss_key,
3258 /* *** Configure DCB *** */
3259 struct cmd_config_dcb {
3260 cmdline_fixed_string_t port;
3261 cmdline_fixed_string_t config;
3263 cmdline_fixed_string_t dcb;
3264 cmdline_fixed_string_t vt;
3265 cmdline_fixed_string_t vt_en;
3267 cmdline_fixed_string_t pfc;
3268 cmdline_fixed_string_t pfc_en;
3272 cmd_config_dcb_parsed(void *parsed_result,
3273 __rte_unused struct cmdline *cl,
3274 __rte_unused void *data)
3276 struct cmd_config_dcb *res = parsed_result;
3277 struct rte_eth_dcb_info dcb_info;
3278 portid_t port_id = res->port_id;
3279 struct rte_port *port;
3283 port = &ports[port_id];
3284 /** Check if the port is not started **/
3285 if (port->port_status != RTE_PORT_STOPPED) {
3286 fprintf(stderr, "Please stop port %d first\n", port_id);
3290 if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3292 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3296 if (nb_fwd_lcores < res->num_tcs) {
3298 "nb_cores shouldn't be less than number of TCs.\n");
3302 /* Check whether the port supports the report of DCB info. */
3303 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3304 if (ret == -ENOTSUP) {
3305 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3309 if (!strncmp(res->pfc_en, "on", 2))
3314 /* DCB in VT mode */
3315 if (!strncmp(res->vt_en, "on", 2))
3316 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3317 (enum rte_eth_nb_tcs)res->num_tcs,
3320 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3321 (enum rte_eth_nb_tcs)res->num_tcs,
3324 fprintf(stderr, "Cannot initialize network ports.\n");
3330 cmd_reconfig_device_queue(port_id, 1, 1);
3333 cmdline_parse_token_string_t cmd_config_dcb_port =
3334 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3335 cmdline_parse_token_string_t cmd_config_dcb_config =
3336 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3337 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3338 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3339 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3340 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3341 cmdline_parse_token_string_t cmd_config_dcb_vt =
3342 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3343 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3344 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3345 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3346 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3347 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3348 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3349 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3350 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3352 cmdline_parse_inst_t cmd_config_dcb = {
3353 .f = cmd_config_dcb_parsed,
3355 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3357 (void *)&cmd_config_dcb_port,
3358 (void *)&cmd_config_dcb_config,
3359 (void *)&cmd_config_dcb_port_id,
3360 (void *)&cmd_config_dcb_dcb,
3361 (void *)&cmd_config_dcb_vt,
3362 (void *)&cmd_config_dcb_vt_en,
3363 (void *)&cmd_config_dcb_num_tcs,
3364 (void *)&cmd_config_dcb_pfc,
3365 (void *)&cmd_config_dcb_pfc_en,
3370 /* *** configure number of packets per burst *** */
3371 struct cmd_config_burst {
3372 cmdline_fixed_string_t port;
3373 cmdline_fixed_string_t keyword;
3374 cmdline_fixed_string_t all;
3375 cmdline_fixed_string_t name;
3380 cmd_config_burst_parsed(void *parsed_result,
3381 __rte_unused struct cmdline *cl,
3382 __rte_unused void *data)
3384 struct cmd_config_burst *res = parsed_result;
3385 struct rte_eth_dev_info dev_info;
3386 uint16_t rec_nb_pkts;
3389 if (!all_ports_stopped()) {
3390 fprintf(stderr, "Please stop all ports first\n");
3394 if (!strcmp(res->name, "burst")) {
3395 if (res->value == 0) {
3396 /* If user gives a value of zero, query the PMD for
3397 * its recommended Rx burst size. Testpmd uses a single
3398 * size for all ports, so assume all ports are the same
3399 * NIC model and use the values from Port 0.
3401 ret = eth_dev_info_get_print_err(0, &dev_info);
3405 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3407 if (rec_nb_pkts == 0) {
3408 printf("PMD does not recommend a burst size.\n"
3409 "User provided value must be between"
3410 " 1 and %d\n", MAX_PKT_BURST);
3412 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3413 printf("PMD recommended burst size of %d"
3414 " exceeds maximum value of %d\n",
3415 rec_nb_pkts, MAX_PKT_BURST);
3418 printf("Using PMD-provided burst value of %d\n",
3420 nb_pkt_per_burst = rec_nb_pkts;
3421 } else if (res->value > MAX_PKT_BURST) {
3422 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3426 nb_pkt_per_burst = res->value;
3428 fprintf(stderr, "Unknown parameter\n");
3434 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3437 cmdline_parse_token_string_t cmd_config_burst_port =
3438 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3439 cmdline_parse_token_string_t cmd_config_burst_keyword =
3440 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3441 cmdline_parse_token_string_t cmd_config_burst_all =
3442 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3443 cmdline_parse_token_string_t cmd_config_burst_name =
3444 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3445 cmdline_parse_token_num_t cmd_config_burst_value =
3446 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3448 cmdline_parse_inst_t cmd_config_burst = {
3449 .f = cmd_config_burst_parsed,
3451 .help_str = "port config all burst <value>",
3453 (void *)&cmd_config_burst_port,
3454 (void *)&cmd_config_burst_keyword,
3455 (void *)&cmd_config_burst_all,
3456 (void *)&cmd_config_burst_name,
3457 (void *)&cmd_config_burst_value,
3462 /* *** configure rx/tx queues *** */
3463 struct cmd_config_thresh {
3464 cmdline_fixed_string_t port;
3465 cmdline_fixed_string_t keyword;
3466 cmdline_fixed_string_t all;
3467 cmdline_fixed_string_t name;
3472 cmd_config_thresh_parsed(void *parsed_result,
3473 __rte_unused struct cmdline *cl,
3474 __rte_unused void *data)
3476 struct cmd_config_thresh *res = parsed_result;
3478 if (!all_ports_stopped()) {
3479 fprintf(stderr, "Please stop all ports first\n");
3483 if (!strcmp(res->name, "txpt"))
3484 tx_pthresh = res->value;
3485 else if(!strcmp(res->name, "txht"))
3486 tx_hthresh = res->value;
3487 else if(!strcmp(res->name, "txwt"))
3488 tx_wthresh = res->value;
3489 else if(!strcmp(res->name, "rxpt"))
3490 rx_pthresh = res->value;
3491 else if(!strcmp(res->name, "rxht"))
3492 rx_hthresh = res->value;
3493 else if(!strcmp(res->name, "rxwt"))
3494 rx_wthresh = res->value;
3496 fprintf(stderr, "Unknown parameter\n");
3502 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3505 cmdline_parse_token_string_t cmd_config_thresh_port =
3506 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3507 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3508 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3509 cmdline_parse_token_string_t cmd_config_thresh_all =
3510 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3511 cmdline_parse_token_string_t cmd_config_thresh_name =
3512 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3513 "txpt#txht#txwt#rxpt#rxht#rxwt");
3514 cmdline_parse_token_num_t cmd_config_thresh_value =
3515 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3517 cmdline_parse_inst_t cmd_config_thresh = {
3518 .f = cmd_config_thresh_parsed,
3520 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3522 (void *)&cmd_config_thresh_port,
3523 (void *)&cmd_config_thresh_keyword,
3524 (void *)&cmd_config_thresh_all,
3525 (void *)&cmd_config_thresh_name,
3526 (void *)&cmd_config_thresh_value,
3531 /* *** configure free/rs threshold *** */
3532 struct cmd_config_threshold {
3533 cmdline_fixed_string_t port;
3534 cmdline_fixed_string_t keyword;
3535 cmdline_fixed_string_t all;
3536 cmdline_fixed_string_t name;
3541 cmd_config_threshold_parsed(void *parsed_result,
3542 __rte_unused struct cmdline *cl,
3543 __rte_unused void *data)
3545 struct cmd_config_threshold *res = parsed_result;
3547 if (!all_ports_stopped()) {
3548 fprintf(stderr, "Please stop all ports first\n");
3552 if (!strcmp(res->name, "txfreet"))
3553 tx_free_thresh = res->value;
3554 else if (!strcmp(res->name, "txrst"))
3555 tx_rs_thresh = res->value;
3556 else if (!strcmp(res->name, "rxfreet"))
3557 rx_free_thresh = res->value;
3559 fprintf(stderr, "Unknown parameter\n");
3565 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3568 cmdline_parse_token_string_t cmd_config_threshold_port =
3569 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3570 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3571 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3573 cmdline_parse_token_string_t cmd_config_threshold_all =
3574 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3575 cmdline_parse_token_string_t cmd_config_threshold_name =
3576 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3577 "txfreet#txrst#rxfreet");
3578 cmdline_parse_token_num_t cmd_config_threshold_value =
3579 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3581 cmdline_parse_inst_t cmd_config_threshold = {
3582 .f = cmd_config_threshold_parsed,
3584 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3586 (void *)&cmd_config_threshold_port,
3587 (void *)&cmd_config_threshold_keyword,
3588 (void *)&cmd_config_threshold_all,
3589 (void *)&cmd_config_threshold_name,
3590 (void *)&cmd_config_threshold_value,
3596 struct cmd_stop_result {
3597 cmdline_fixed_string_t stop;
3600 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3601 __rte_unused struct cmdline *cl,
3602 __rte_unused void *data)
3604 stop_packet_forwarding();
3607 cmdline_parse_token_string_t cmd_stop_stop =
3608 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3610 cmdline_parse_inst_t cmd_stop = {
3611 .f = cmd_stop_parsed,
3613 .help_str = "stop: Stop packet forwarding",
3615 (void *)&cmd_stop_stop,
3620 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3623 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3624 unsigned int *parsed_items, int check_unique_values)
3626 unsigned int nb_item;
3634 * First parse all items in the list and store their value.
3639 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3641 if ((c >= '0') && (c <= '9')) {
3642 value = (unsigned int) (value * 10 + (c - '0'));
3647 fprintf(stderr, "character %c is not a decimal digit\n", c);
3651 fprintf(stderr, "No valid value before comma\n");
3654 if (nb_item < max_items) {
3655 parsed_items[nb_item] = value;
3661 if (nb_item >= max_items) {
3662 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3663 item_name, nb_item + 1, max_items);
3666 parsed_items[nb_item++] = value;
3667 if (! check_unique_values)
3671 * Then, check that all values in the list are different.
3672 * No optimization here...
3674 for (i = 0; i < nb_item; i++) {
3675 for (j = i + 1; j < nb_item; j++) {
3676 if (parsed_items[j] == parsed_items[i]) {
3678 "duplicated %s %u at index %u and %u\n",
3679 item_name, parsed_items[i], i, j);
3687 struct cmd_set_list_result {
3688 cmdline_fixed_string_t cmd_keyword;
3689 cmdline_fixed_string_t list_name;
3690 cmdline_fixed_string_t list_of_items;
3693 static void cmd_set_list_parsed(void *parsed_result,
3694 __rte_unused struct cmdline *cl,
3695 __rte_unused void *data)
3697 struct cmd_set_list_result *res;
3699 unsigned int lcorelist[RTE_MAX_LCORE];
3700 unsigned int portlist[RTE_MAX_ETHPORTS];
3702 unsigned int nb_item;
3704 if (test_done == 0) {
3705 fprintf(stderr, "Please stop forwarding first\n");
3709 res = parsed_result;
3710 if (!strcmp(res->list_name, "corelist")) {
3711 nb_item = parse_item_list(res->list_of_items, "core",
3713 parsed_items.lcorelist, 1);
3715 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3720 if (!strcmp(res->list_name, "portlist")) {
3721 nb_item = parse_item_list(res->list_of_items, "port",
3723 parsed_items.portlist, 1);
3725 set_fwd_ports_list(parsed_items.portlist, nb_item);
3731 cmdline_parse_token_string_t cmd_set_list_keyword =
3732 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3734 cmdline_parse_token_string_t cmd_set_list_name =
3735 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3736 "corelist#portlist");
3737 cmdline_parse_token_string_t cmd_set_list_of_items =
3738 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3741 cmdline_parse_inst_t cmd_set_fwd_list = {
3742 .f = cmd_set_list_parsed,
3744 .help_str = "set corelist|portlist <list0[,list1]*>",
3746 (void *)&cmd_set_list_keyword,
3747 (void *)&cmd_set_list_name,
3748 (void *)&cmd_set_list_of_items,
3753 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3755 struct cmd_setmask_result {
3756 cmdline_fixed_string_t set;
3757 cmdline_fixed_string_t mask;
3761 static void cmd_set_mask_parsed(void *parsed_result,
3762 __rte_unused struct cmdline *cl,
3763 __rte_unused void *data)
3765 struct cmd_setmask_result *res = parsed_result;
3767 if (test_done == 0) {
3768 fprintf(stderr, "Please stop forwarding first\n");
3771 if (!strcmp(res->mask, "coremask")) {
3772 set_fwd_lcores_mask(res->hexavalue);
3774 } else if (!strcmp(res->mask, "portmask")) {
3775 set_fwd_ports_mask(res->hexavalue);
3780 cmdline_parse_token_string_t cmd_setmask_set =
3781 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3782 cmdline_parse_token_string_t cmd_setmask_mask =
3783 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3784 "coremask#portmask");
3785 cmdline_parse_token_num_t cmd_setmask_value =
3786 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3788 cmdline_parse_inst_t cmd_set_fwd_mask = {
3789 .f = cmd_set_mask_parsed,
3791 .help_str = "set coremask|portmask <hexadecimal value>",
3793 (void *)&cmd_setmask_set,
3794 (void *)&cmd_setmask_mask,
3795 (void *)&cmd_setmask_value,
3801 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3803 struct cmd_set_result {
3804 cmdline_fixed_string_t set;
3805 cmdline_fixed_string_t what;
3809 static void cmd_set_parsed(void *parsed_result,
3810 __rte_unused struct cmdline *cl,
3811 __rte_unused void *data)
3813 struct cmd_set_result *res = parsed_result;
3814 if (!strcmp(res->what, "nbport")) {
3815 set_fwd_ports_number(res->value);
3817 } else if (!strcmp(res->what, "nbcore")) {
3818 set_fwd_lcores_number(res->value);
3820 } else if (!strcmp(res->what, "burst"))
3821 set_nb_pkt_per_burst(res->value);
3822 else if (!strcmp(res->what, "verbose"))
3823 set_verbose_level(res->value);
3826 cmdline_parse_token_string_t cmd_set_set =
3827 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3828 cmdline_parse_token_string_t cmd_set_what =
3829 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3830 "nbport#nbcore#burst#verbose");
3831 cmdline_parse_token_num_t cmd_set_value =
3832 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3834 cmdline_parse_inst_t cmd_set_numbers = {
3835 .f = cmd_set_parsed,
3837 .help_str = "set nbport|nbcore|burst|verbose <value>",
3839 (void *)&cmd_set_set,
3840 (void *)&cmd_set_what,
3841 (void *)&cmd_set_value,
3846 /* *** SET LOG LEVEL CONFIGURATION *** */
3848 struct cmd_set_log_result {
3849 cmdline_fixed_string_t set;
3850 cmdline_fixed_string_t log;
3851 cmdline_fixed_string_t type;
3856 cmd_set_log_parsed(void *parsed_result,
3857 __rte_unused struct cmdline *cl,
3858 __rte_unused void *data)
3860 struct cmd_set_log_result *res;
3863 res = parsed_result;
3864 if (!strcmp(res->type, "global"))
3865 rte_log_set_global_level(res->level);
3867 ret = rte_log_set_level_regexp(res->type, res->level);
3869 fprintf(stderr, "Unable to set log level\n");
3873 cmdline_parse_token_string_t cmd_set_log_set =
3874 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3875 cmdline_parse_token_string_t cmd_set_log_log =
3876 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3877 cmdline_parse_token_string_t cmd_set_log_type =
3878 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3879 cmdline_parse_token_num_t cmd_set_log_level =
3880 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3882 cmdline_parse_inst_t cmd_set_log = {
3883 .f = cmd_set_log_parsed,
3885 .help_str = "set log global|<type> <level>",
3887 (void *)&cmd_set_log_set,
3888 (void *)&cmd_set_log_log,
3889 (void *)&cmd_set_log_type,
3890 (void *)&cmd_set_log_level,
3895 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3897 struct cmd_set_rxoffs_result {
3898 cmdline_fixed_string_t cmd_keyword;
3899 cmdline_fixed_string_t rxoffs;
3900 cmdline_fixed_string_t seg_offsets;
3904 cmd_set_rxoffs_parsed(void *parsed_result,
3905 __rte_unused struct cmdline *cl,
3906 __rte_unused void *data)
3908 struct cmd_set_rxoffs_result *res;
3909 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3910 unsigned int nb_segs;
3912 res = parsed_result;
3913 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3914 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3916 set_rx_pkt_offsets(seg_offsets, nb_segs);
3917 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3920 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3921 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3922 cmd_keyword, "set");
3923 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3924 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3926 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3927 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3930 cmdline_parse_inst_t cmd_set_rxoffs = {
3931 .f = cmd_set_rxoffs_parsed,
3933 .help_str = "set rxoffs <len0[,len1]*>",
3935 (void *)&cmd_set_rxoffs_keyword,
3936 (void *)&cmd_set_rxoffs_name,
3937 (void *)&cmd_set_rxoffs_offsets,
3942 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3944 struct cmd_set_rxpkts_result {
3945 cmdline_fixed_string_t cmd_keyword;
3946 cmdline_fixed_string_t rxpkts;
3947 cmdline_fixed_string_t seg_lengths;
3951 cmd_set_rxpkts_parsed(void *parsed_result,
3952 __rte_unused struct cmdline *cl,
3953 __rte_unused void *data)
3955 struct cmd_set_rxpkts_result *res;
3956 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3957 unsigned int nb_segs;
3959 res = parsed_result;
3960 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3961 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3963 set_rx_pkt_segments(seg_lengths, nb_segs);
3964 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3967 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3968 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3969 cmd_keyword, "set");
3970 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3971 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3973 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3974 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3977 cmdline_parse_inst_t cmd_set_rxpkts = {
3978 .f = cmd_set_rxpkts_parsed,
3980 .help_str = "set rxpkts <len0[,len1]*>",
3982 (void *)&cmd_set_rxpkts_keyword,
3983 (void *)&cmd_set_rxpkts_name,
3984 (void *)&cmd_set_rxpkts_lengths,
3989 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3991 struct cmd_set_txpkts_result {
3992 cmdline_fixed_string_t cmd_keyword;
3993 cmdline_fixed_string_t txpkts;
3994 cmdline_fixed_string_t seg_lengths;
3998 cmd_set_txpkts_parsed(void *parsed_result,
3999 __rte_unused struct cmdline *cl,
4000 __rte_unused void *data)
4002 struct cmd_set_txpkts_result *res;
4003 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4004 unsigned int nb_segs;
4006 res = parsed_result;
4007 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4008 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4010 set_tx_pkt_segments(seg_lengths, nb_segs);
4013 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4014 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4015 cmd_keyword, "set");
4016 cmdline_parse_token_string_t cmd_set_txpkts_name =
4017 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4019 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4020 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4023 cmdline_parse_inst_t cmd_set_txpkts = {
4024 .f = cmd_set_txpkts_parsed,
4026 .help_str = "set txpkts <len0[,len1]*>",
4028 (void *)&cmd_set_txpkts_keyword,
4029 (void *)&cmd_set_txpkts_name,
4030 (void *)&cmd_set_txpkts_lengths,
4035 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4037 struct cmd_set_txsplit_result {
4038 cmdline_fixed_string_t cmd_keyword;
4039 cmdline_fixed_string_t txsplit;
4040 cmdline_fixed_string_t mode;
4044 cmd_set_txsplit_parsed(void *parsed_result,
4045 __rte_unused struct cmdline *cl,
4046 __rte_unused void *data)
4048 struct cmd_set_txsplit_result *res;
4050 res = parsed_result;
4051 set_tx_pkt_split(res->mode);
4054 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4055 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4056 cmd_keyword, "set");
4057 cmdline_parse_token_string_t cmd_set_txsplit_name =
4058 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4059 txsplit, "txsplit");
4060 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4061 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4064 cmdline_parse_inst_t cmd_set_txsplit = {
4065 .f = cmd_set_txsplit_parsed,
4067 .help_str = "set txsplit on|off|rand",
4069 (void *)&cmd_set_txsplit_keyword,
4070 (void *)&cmd_set_txsplit_name,
4071 (void *)&cmd_set_txsplit_mode,
4076 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4078 struct cmd_set_txtimes_result {
4079 cmdline_fixed_string_t cmd_keyword;
4080 cmdline_fixed_string_t txtimes;
4081 cmdline_fixed_string_t tx_times;
4085 cmd_set_txtimes_parsed(void *parsed_result,
4086 __rte_unused struct cmdline *cl,
4087 __rte_unused void *data)
4089 struct cmd_set_txtimes_result *res;
4090 unsigned int tx_times[2] = {0, 0};
4091 unsigned int n_times;
4093 res = parsed_result;
4094 n_times = parse_item_list(res->tx_times, "tx times",
4097 set_tx_pkt_times(tx_times);
4100 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4101 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4102 cmd_keyword, "set");
4103 cmdline_parse_token_string_t cmd_set_txtimes_name =
4104 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4105 txtimes, "txtimes");
4106 cmdline_parse_token_string_t cmd_set_txtimes_value =
4107 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4110 cmdline_parse_inst_t cmd_set_txtimes = {
4111 .f = cmd_set_txtimes_parsed,
4113 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4115 (void *)&cmd_set_txtimes_keyword,
4116 (void *)&cmd_set_txtimes_name,
4117 (void *)&cmd_set_txtimes_value,
4122 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4123 struct cmd_rx_vlan_filter_all_result {
4124 cmdline_fixed_string_t rx_vlan;
4125 cmdline_fixed_string_t what;
4126 cmdline_fixed_string_t all;
4131 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4132 __rte_unused struct cmdline *cl,
4133 __rte_unused void *data)
4135 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4137 if (!strcmp(res->what, "add"))
4138 rx_vlan_all_filter_set(res->port_id, 1);
4140 rx_vlan_all_filter_set(res->port_id, 0);
4143 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4144 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4145 rx_vlan, "rx_vlan");
4146 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4147 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4149 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4150 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4152 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4153 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4154 port_id, RTE_UINT16);
4156 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4157 .f = cmd_rx_vlan_filter_all_parsed,
4159 .help_str = "rx_vlan add|rm all <port_id>: "
4160 "Add/Remove all identifiers to/from the set of VLAN "
4161 "identifiers filtered by a port",
4163 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4164 (void *)&cmd_rx_vlan_filter_all_what,
4165 (void *)&cmd_rx_vlan_filter_all_all,
4166 (void *)&cmd_rx_vlan_filter_all_portid,
4171 /* *** VLAN OFFLOAD SET ON A PORT *** */
4172 struct cmd_vlan_offload_result {
4173 cmdline_fixed_string_t vlan;
4174 cmdline_fixed_string_t set;
4175 cmdline_fixed_string_t vlan_type;
4176 cmdline_fixed_string_t what;
4177 cmdline_fixed_string_t on;
4178 cmdline_fixed_string_t port_id;
4182 cmd_vlan_offload_parsed(void *parsed_result,
4183 __rte_unused struct cmdline *cl,
4184 __rte_unused void *data)
4187 struct cmd_vlan_offload_result *res = parsed_result;
4190 portid_t port_id = 0;
4194 len = strnlen(str, STR_TOKEN_SIZE);
4196 /* Get port_id first */
4204 tmp = strtoul(str, NULL, 0);
4205 /* If port_id greater that what portid_t can represent, return */
4206 if(tmp >= RTE_MAX_ETHPORTS)
4208 port_id = (portid_t)tmp;
4210 if (!strcmp(res->on, "on"))
4215 if (!strcmp(res->what, "strip"))
4216 rx_vlan_strip_set(port_id, on);
4217 else if(!strcmp(res->what, "stripq")){
4218 uint16_t queue_id = 0;
4220 /* No queue_id, return */
4222 fprintf(stderr, "must specify (port,queue_id)\n");
4225 tmp = strtoul(str + i + 1, NULL, 0);
4226 /* If queue_id greater that what 16-bits can represent, return */
4230 queue_id = (uint16_t)tmp;
4231 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4233 else if (!strcmp(res->what, "filter"))
4234 rx_vlan_filter_set(port_id, on);
4235 else if (!strcmp(res->what, "qinq_strip"))
4236 rx_vlan_qinq_strip_set(port_id, on);
4238 vlan_extend_set(port_id, on);
4243 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4244 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4246 cmdline_parse_token_string_t cmd_vlan_offload_set =
4247 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4249 cmdline_parse_token_string_t cmd_vlan_offload_what =
4250 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4251 what, "strip#filter#qinq_strip#extend#stripq");
4252 cmdline_parse_token_string_t cmd_vlan_offload_on =
4253 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4255 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4256 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4259 cmdline_parse_inst_t cmd_vlan_offload = {
4260 .f = cmd_vlan_offload_parsed,
4262 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4263 "<port_id[,queue_id]>: "
4264 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4266 (void *)&cmd_vlan_offload_vlan,
4267 (void *)&cmd_vlan_offload_set,
4268 (void *)&cmd_vlan_offload_what,
4269 (void *)&cmd_vlan_offload_on,
4270 (void *)&cmd_vlan_offload_portid,
4275 /* *** VLAN TPID SET ON A PORT *** */
4276 struct cmd_vlan_tpid_result {
4277 cmdline_fixed_string_t vlan;
4278 cmdline_fixed_string_t set;
4279 cmdline_fixed_string_t vlan_type;
4280 cmdline_fixed_string_t what;
4286 cmd_vlan_tpid_parsed(void *parsed_result,
4287 __rte_unused struct cmdline *cl,
4288 __rte_unused void *data)
4290 struct cmd_vlan_tpid_result *res = parsed_result;
4291 enum rte_vlan_type vlan_type;
4293 if (!strcmp(res->vlan_type, "inner"))
4294 vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4295 else if (!strcmp(res->vlan_type, "outer"))
4296 vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4298 fprintf(stderr, "Unknown vlan type\n");
4301 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4304 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4305 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4307 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4308 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4310 cmdline_parse_token_string_t cmd_vlan_type =
4311 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4312 vlan_type, "inner#outer");
4313 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4314 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4316 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4317 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4319 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4320 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4321 port_id, RTE_UINT16);
4323 cmdline_parse_inst_t cmd_vlan_tpid = {
4324 .f = cmd_vlan_tpid_parsed,
4326 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4327 "Set the VLAN Ether type",
4329 (void *)&cmd_vlan_tpid_vlan,
4330 (void *)&cmd_vlan_tpid_set,
4331 (void *)&cmd_vlan_type,
4332 (void *)&cmd_vlan_tpid_what,
4333 (void *)&cmd_vlan_tpid_tpid,
4334 (void *)&cmd_vlan_tpid_portid,
4339 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4340 struct cmd_rx_vlan_filter_result {
4341 cmdline_fixed_string_t rx_vlan;
4342 cmdline_fixed_string_t what;
4348 cmd_rx_vlan_filter_parsed(void *parsed_result,
4349 __rte_unused struct cmdline *cl,
4350 __rte_unused void *data)
4352 struct cmd_rx_vlan_filter_result *res = parsed_result;
4354 if (!strcmp(res->what, "add"))
4355 rx_vft_set(res->port_id, res->vlan_id, 1);
4357 rx_vft_set(res->port_id, res->vlan_id, 0);
4360 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4361 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4362 rx_vlan, "rx_vlan");
4363 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4364 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4366 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4367 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4368 vlan_id, RTE_UINT16);
4369 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4370 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4371 port_id, RTE_UINT16);
4373 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4374 .f = cmd_rx_vlan_filter_parsed,
4376 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4377 "Add/Remove a VLAN identifier to/from the set of VLAN "
4378 "identifiers filtered by a port",
4380 (void *)&cmd_rx_vlan_filter_rx_vlan,
4381 (void *)&cmd_rx_vlan_filter_what,
4382 (void *)&cmd_rx_vlan_filter_vlanid,
4383 (void *)&cmd_rx_vlan_filter_portid,
4388 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4389 struct cmd_tx_vlan_set_result {
4390 cmdline_fixed_string_t tx_vlan;
4391 cmdline_fixed_string_t set;
4397 cmd_tx_vlan_set_parsed(void *parsed_result,
4398 __rte_unused struct cmdline *cl,
4399 __rte_unused void *data)
4401 struct cmd_tx_vlan_set_result *res = parsed_result;
4403 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4406 if (!port_is_stopped(res->port_id)) {
4407 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4411 tx_vlan_set(res->port_id, res->vlan_id);
4413 cmd_reconfig_device_queue(res->port_id, 1, 1);
4416 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4417 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4418 tx_vlan, "tx_vlan");
4419 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4420 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4422 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4423 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4424 port_id, RTE_UINT16);
4425 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4426 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4427 vlan_id, RTE_UINT16);
4429 cmdline_parse_inst_t cmd_tx_vlan_set = {
4430 .f = cmd_tx_vlan_set_parsed,
4432 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4433 "Enable hardware insertion of a single VLAN header "
4434 "with a given TAG Identifier in packets sent on a port",
4436 (void *)&cmd_tx_vlan_set_tx_vlan,
4437 (void *)&cmd_tx_vlan_set_set,
4438 (void *)&cmd_tx_vlan_set_portid,
4439 (void *)&cmd_tx_vlan_set_vlanid,
4444 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4445 struct cmd_tx_vlan_set_qinq_result {
4446 cmdline_fixed_string_t tx_vlan;
4447 cmdline_fixed_string_t set;
4450 uint16_t vlan_id_outer;
4454 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4455 __rte_unused struct cmdline *cl,
4456 __rte_unused void *data)
4458 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4460 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4463 if (!port_is_stopped(res->port_id)) {
4464 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4468 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4470 cmd_reconfig_device_queue(res->port_id, 1, 1);
4473 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4474 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4475 tx_vlan, "tx_vlan");
4476 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4477 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4479 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4480 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4481 port_id, RTE_UINT16);
4482 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4483 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4484 vlan_id, RTE_UINT16);
4485 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4486 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4487 vlan_id_outer, RTE_UINT16);
4489 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4490 .f = cmd_tx_vlan_set_qinq_parsed,
4492 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4493 "Enable hardware insertion of double VLAN header "
4494 "with given TAG Identifiers in packets sent on a port",
4496 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4497 (void *)&cmd_tx_vlan_set_qinq_set,
4498 (void *)&cmd_tx_vlan_set_qinq_portid,
4499 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4500 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4505 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4506 struct cmd_tx_vlan_set_pvid_result {
4507 cmdline_fixed_string_t tx_vlan;
4508 cmdline_fixed_string_t set;
4509 cmdline_fixed_string_t pvid;
4512 cmdline_fixed_string_t mode;
4516 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4517 __rte_unused struct cmdline *cl,
4518 __rte_unused void *data)
4520 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4522 if (strcmp(res->mode, "on") == 0)
4523 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4525 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4528 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4529 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4530 tx_vlan, "tx_vlan");
4531 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4532 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4534 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4535 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4537 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4538 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4539 port_id, RTE_UINT16);
4540 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4541 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4542 vlan_id, RTE_UINT16);
4543 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4544 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4547 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4548 .f = cmd_tx_vlan_set_pvid_parsed,
4550 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4552 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4553 (void *)&cmd_tx_vlan_set_pvid_set,
4554 (void *)&cmd_tx_vlan_set_pvid_pvid,
4555 (void *)&cmd_tx_vlan_set_pvid_port_id,
4556 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4557 (void *)&cmd_tx_vlan_set_pvid_mode,
4562 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4563 struct cmd_tx_vlan_reset_result {
4564 cmdline_fixed_string_t tx_vlan;
4565 cmdline_fixed_string_t reset;
4570 cmd_tx_vlan_reset_parsed(void *parsed_result,
4571 __rte_unused struct cmdline *cl,
4572 __rte_unused void *data)
4574 struct cmd_tx_vlan_reset_result *res = parsed_result;
4576 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4579 if (!port_is_stopped(res->port_id)) {
4580 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4584 tx_vlan_reset(res->port_id);
4586 cmd_reconfig_device_queue(res->port_id, 1, 1);
4589 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4590 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4591 tx_vlan, "tx_vlan");
4592 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4593 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4595 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4596 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4597 port_id, RTE_UINT16);
4599 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4600 .f = cmd_tx_vlan_reset_parsed,
4602 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4603 "VLAN header in packets sent on a port",
4605 (void *)&cmd_tx_vlan_reset_tx_vlan,
4606 (void *)&cmd_tx_vlan_reset_reset,
4607 (void *)&cmd_tx_vlan_reset_portid,
4613 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4614 struct cmd_csum_result {
4615 cmdline_fixed_string_t csum;
4616 cmdline_fixed_string_t mode;
4617 cmdline_fixed_string_t proto;
4618 cmdline_fixed_string_t hwsw;
4623 csum_show(int port_id)
4625 struct rte_eth_dev_info dev_info;
4626 uint64_t tx_offloads;
4629 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4630 printf("Parse tunnel is %s\n",
4631 (ports[port_id].parse_tunnel) ? "on" : "off");
4632 printf("IP checksum offload is %s\n",
4633 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4634 printf("UDP checksum offload is %s\n",
4635 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4636 printf("TCP checksum offload is %s\n",
4637 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4638 printf("SCTP checksum offload is %s\n",
4639 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4640 printf("Outer-Ip checksum offload is %s\n",
4641 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4642 printf("Outer-Udp checksum offload is %s\n",
4643 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4645 /* display warnings if configuration is not supported by the NIC */
4646 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4650 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4651 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4653 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4656 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4657 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4659 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4662 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4663 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4665 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4668 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4669 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4671 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4674 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4675 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4677 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4680 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4681 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4684 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4690 cmd_config_queue_tx_offloads(struct rte_port *port)
4694 /* Apply queue tx offloads configuration */
4695 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4696 port->tx_conf[k].offloads =
4697 port->dev_conf.txmode.offloads;
4701 cmd_csum_parsed(void *parsed_result,
4702 __rte_unused struct cmdline *cl,
4703 __rte_unused void *data)
4705 struct cmd_csum_result *res = parsed_result;
4707 uint64_t csum_offloads = 0;
4708 struct rte_eth_dev_info dev_info;
4711 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4712 fprintf(stderr, "invalid port %d\n", res->port_id);
4715 if (!port_is_stopped(res->port_id)) {
4716 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4720 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4724 if (!strcmp(res->mode, "set")) {
4726 if (!strcmp(res->hwsw, "hw"))
4729 if (!strcmp(res->proto, "ip")) {
4730 if (hw == 0 || (dev_info.tx_offload_capa &
4731 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4732 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4735 "IP checksum offload is not supported by port %u\n",
4738 } else if (!strcmp(res->proto, "udp")) {
4739 if (hw == 0 || (dev_info.tx_offload_capa &
4740 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4741 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4744 "UDP checksum offload is not supported by port %u\n",
4747 } else if (!strcmp(res->proto, "tcp")) {
4748 if (hw == 0 || (dev_info.tx_offload_capa &
4749 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4750 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4753 "TCP checksum offload is not supported by port %u\n",
4756 } else if (!strcmp(res->proto, "sctp")) {
4757 if (hw == 0 || (dev_info.tx_offload_capa &
4758 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4759 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4762 "SCTP checksum offload is not supported by port %u\n",
4765 } else if (!strcmp(res->proto, "outer-ip")) {
4766 if (hw == 0 || (dev_info.tx_offload_capa &
4767 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4769 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4772 "Outer IP checksum offload is not supported by port %u\n",
4775 } else if (!strcmp(res->proto, "outer-udp")) {
4776 if (hw == 0 || (dev_info.tx_offload_capa &
4777 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4779 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4782 "Outer UDP checksum offload is not supported by port %u\n",
4788 ports[res->port_id].dev_conf.txmode.offloads |=
4791 ports[res->port_id].dev_conf.txmode.offloads &=
4794 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4796 csum_show(res->port_id);
4798 cmd_reconfig_device_queue(res->port_id, 1, 1);
4801 cmdline_parse_token_string_t cmd_csum_csum =
4802 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4804 cmdline_parse_token_string_t cmd_csum_mode =
4805 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4807 cmdline_parse_token_string_t cmd_csum_proto =
4808 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4809 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4810 cmdline_parse_token_string_t cmd_csum_hwsw =
4811 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4813 cmdline_parse_token_num_t cmd_csum_portid =
4814 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4815 port_id, RTE_UINT16);
4817 cmdline_parse_inst_t cmd_csum_set = {
4818 .f = cmd_csum_parsed,
4820 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4821 "Enable/Disable hardware calculation of L3/L4 checksum when "
4822 "using csum forward engine",
4824 (void *)&cmd_csum_csum,
4825 (void *)&cmd_csum_mode,
4826 (void *)&cmd_csum_proto,
4827 (void *)&cmd_csum_hwsw,
4828 (void *)&cmd_csum_portid,
4833 cmdline_parse_token_string_t cmd_csum_mode_show =
4834 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4837 cmdline_parse_inst_t cmd_csum_show = {
4838 .f = cmd_csum_parsed,
4840 .help_str = "csum show <port_id>: Show checksum offload configuration",
4842 (void *)&cmd_csum_csum,
4843 (void *)&cmd_csum_mode_show,
4844 (void *)&cmd_csum_portid,
4849 /* Enable/disable tunnel parsing */
4850 struct cmd_csum_tunnel_result {
4851 cmdline_fixed_string_t csum;
4852 cmdline_fixed_string_t parse;
4853 cmdline_fixed_string_t onoff;
4858 cmd_csum_tunnel_parsed(void *parsed_result,
4859 __rte_unused struct cmdline *cl,
4860 __rte_unused void *data)
4862 struct cmd_csum_tunnel_result *res = parsed_result;
4864 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4867 if (!strcmp(res->onoff, "on"))
4868 ports[res->port_id].parse_tunnel = 1;
4870 ports[res->port_id].parse_tunnel = 0;
4872 csum_show(res->port_id);
4875 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4876 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4878 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4879 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4880 parse, "parse-tunnel");
4881 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4882 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4884 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4885 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4886 port_id, RTE_UINT16);
4888 cmdline_parse_inst_t cmd_csum_tunnel = {
4889 .f = cmd_csum_tunnel_parsed,
4891 .help_str = "csum parse-tunnel on|off <port_id>: "
4892 "Enable/Disable parsing of tunnels for csum engine",
4894 (void *)&cmd_csum_tunnel_csum,
4895 (void *)&cmd_csum_tunnel_parse,
4896 (void *)&cmd_csum_tunnel_onoff,
4897 (void *)&cmd_csum_tunnel_portid,
4902 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4903 struct cmd_tso_set_result {
4904 cmdline_fixed_string_t tso;
4905 cmdline_fixed_string_t mode;
4911 cmd_tso_set_parsed(void *parsed_result,
4912 __rte_unused struct cmdline *cl,
4913 __rte_unused void *data)
4915 struct cmd_tso_set_result *res = parsed_result;
4916 struct rte_eth_dev_info dev_info;
4919 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4921 if (!port_is_stopped(res->port_id)) {
4922 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4926 if (!strcmp(res->mode, "set"))
4927 ports[res->port_id].tso_segsz = res->tso_segsz;
4929 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4933 if ((ports[res->port_id].tso_segsz != 0) &&
4934 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4935 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4940 if (ports[res->port_id].tso_segsz == 0) {
4941 ports[res->port_id].dev_conf.txmode.offloads &=
4942 ~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4943 printf("TSO for non-tunneled packets is disabled\n");
4945 ports[res->port_id].dev_conf.txmode.offloads |=
4946 RTE_ETH_TX_OFFLOAD_TCP_TSO;
4947 printf("TSO segment size for non-tunneled packets is %d\n",
4948 ports[res->port_id].tso_segsz);
4950 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4952 /* display warnings if configuration is not supported by the NIC */
4953 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4957 if ((ports[res->port_id].tso_segsz != 0) &&
4958 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4960 "Warning: TSO enabled but not supported by port %d\n",
4964 cmd_reconfig_device_queue(res->port_id, 1, 1);
4967 cmdline_parse_token_string_t cmd_tso_set_tso =
4968 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4970 cmdline_parse_token_string_t cmd_tso_set_mode =
4971 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4973 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4974 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4975 tso_segsz, RTE_UINT16);
4976 cmdline_parse_token_num_t cmd_tso_set_portid =
4977 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4978 port_id, RTE_UINT16);
4980 cmdline_parse_inst_t cmd_tso_set = {
4981 .f = cmd_tso_set_parsed,
4983 .help_str = "tso set <tso_segsz> <port_id>: "
4984 "Set TSO segment size of non-tunneled packets for csum engine "
4987 (void *)&cmd_tso_set_tso,
4988 (void *)&cmd_tso_set_mode,
4989 (void *)&cmd_tso_set_tso_segsz,
4990 (void *)&cmd_tso_set_portid,
4995 cmdline_parse_token_string_t cmd_tso_show_mode =
4996 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5000 cmdline_parse_inst_t cmd_tso_show = {
5001 .f = cmd_tso_set_parsed,
5003 .help_str = "tso show <port_id>: "
5004 "Show TSO segment size of non-tunneled packets for csum engine",
5006 (void *)&cmd_tso_set_tso,
5007 (void *)&cmd_tso_show_mode,
5008 (void *)&cmd_tso_set_portid,
5013 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5014 struct cmd_tunnel_tso_set_result {
5015 cmdline_fixed_string_t tso;
5016 cmdline_fixed_string_t mode;
5021 static struct rte_eth_dev_info
5022 check_tunnel_tso_nic_support(portid_t port_id)
5024 struct rte_eth_dev_info dev_info;
5026 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5029 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5031 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5033 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5035 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5037 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5039 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5041 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5043 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5045 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5047 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5049 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5051 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5057 cmd_tunnel_tso_set_parsed(void *parsed_result,
5058 __rte_unused struct cmdline *cl,
5059 __rte_unused void *data)
5061 struct cmd_tunnel_tso_set_result *res = parsed_result;
5062 struct rte_eth_dev_info dev_info;
5064 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5066 if (!port_is_stopped(res->port_id)) {
5067 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5071 if (!strcmp(res->mode, "set"))
5072 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5074 dev_info = check_tunnel_tso_nic_support(res->port_id);
5075 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5076 ports[res->port_id].dev_conf.txmode.offloads &=
5077 ~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5078 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5079 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5080 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5081 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5082 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5083 printf("TSO for tunneled packets is disabled\n");
5085 uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5086 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5087 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5088 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5089 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5090 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5092 ports[res->port_id].dev_conf.txmode.offloads |=
5093 (tso_offloads & dev_info.tx_offload_capa);
5094 printf("TSO segment size for tunneled packets is %d\n",
5095 ports[res->port_id].tunnel_tso_segsz);
5097 /* Below conditions are needed to make it work:
5098 * (1) tunnel TSO is supported by the NIC;
5099 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5101 * (3) for tunneled pkts with outer L3 of IPv4,
5102 * "csum set outer-ip" must be set to hw, because after tso,
5103 * total_len of outer IP header is changed, and the checksum
5104 * of outer IP header calculated by sw should be wrong; that
5105 * is not necessary for IPv6 tunneled pkts because there's no
5106 * checksum in IP header anymore.
5109 if (!ports[res->port_id].parse_tunnel)
5111 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5112 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5113 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5115 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5118 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5119 cmd_reconfig_device_queue(res->port_id, 1, 1);
5122 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5123 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5125 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5126 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5128 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5129 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5130 tso_segsz, RTE_UINT16);
5131 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5132 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5133 port_id, RTE_UINT16);
5135 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5136 .f = cmd_tunnel_tso_set_parsed,
5138 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5139 "Set TSO segment size of tunneled packets for csum engine "
5142 (void *)&cmd_tunnel_tso_set_tso,
5143 (void *)&cmd_tunnel_tso_set_mode,
5144 (void *)&cmd_tunnel_tso_set_tso_segsz,
5145 (void *)&cmd_tunnel_tso_set_portid,
5150 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5151 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5155 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5156 .f = cmd_tunnel_tso_set_parsed,
5158 .help_str = "tunnel_tso show <port_id> "
5159 "Show TSO segment size of tunneled packets for csum engine",
5161 (void *)&cmd_tunnel_tso_set_tso,
5162 (void *)&cmd_tunnel_tso_show_mode,
5163 (void *)&cmd_tunnel_tso_set_portid,
5169 /* *** SET GRO FOR A PORT *** */
5170 struct cmd_gro_enable_result {
5171 cmdline_fixed_string_t cmd_set;
5172 cmdline_fixed_string_t cmd_port;
5173 cmdline_fixed_string_t cmd_keyword;
5174 cmdline_fixed_string_t cmd_onoff;
5179 cmd_gro_enable_parsed(void *parsed_result,
5180 __rte_unused struct cmdline *cl,
5181 __rte_unused void *data)
5183 struct cmd_gro_enable_result *res;
5185 res = parsed_result;
5186 if (!strcmp(res->cmd_keyword, "gro"))
5187 setup_gro(res->cmd_onoff, res->cmd_pid);
5190 cmdline_parse_token_string_t cmd_gro_enable_set =
5191 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5193 cmdline_parse_token_string_t cmd_gro_enable_port =
5194 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5195 cmd_keyword, "port");
5196 cmdline_parse_token_num_t cmd_gro_enable_pid =
5197 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5198 cmd_pid, RTE_UINT16);
5199 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5200 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5201 cmd_keyword, "gro");
5202 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5203 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5204 cmd_onoff, "on#off");
5206 cmdline_parse_inst_t cmd_gro_enable = {
5207 .f = cmd_gro_enable_parsed,
5209 .help_str = "set port <port_id> gro on|off",
5211 (void *)&cmd_gro_enable_set,
5212 (void *)&cmd_gro_enable_port,
5213 (void *)&cmd_gro_enable_pid,
5214 (void *)&cmd_gro_enable_keyword,
5215 (void *)&cmd_gro_enable_onoff,
5220 /* *** DISPLAY GRO CONFIGURATION *** */
5221 struct cmd_gro_show_result {
5222 cmdline_fixed_string_t cmd_show;
5223 cmdline_fixed_string_t cmd_port;
5224 cmdline_fixed_string_t cmd_keyword;
5229 cmd_gro_show_parsed(void *parsed_result,
5230 __rte_unused struct cmdline *cl,
5231 __rte_unused void *data)
5233 struct cmd_gro_show_result *res;
5235 res = parsed_result;
5236 if (!strcmp(res->cmd_keyword, "gro"))
5237 show_gro(res->cmd_pid);
5240 cmdline_parse_token_string_t cmd_gro_show_show =
5241 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5243 cmdline_parse_token_string_t cmd_gro_show_port =
5244 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5246 cmdline_parse_token_num_t cmd_gro_show_pid =
5247 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5248 cmd_pid, RTE_UINT16);
5249 cmdline_parse_token_string_t cmd_gro_show_keyword =
5250 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5251 cmd_keyword, "gro");
5253 cmdline_parse_inst_t cmd_gro_show = {
5254 .f = cmd_gro_show_parsed,
5256 .help_str = "show port <port_id> gro",
5258 (void *)&cmd_gro_show_show,
5259 (void *)&cmd_gro_show_port,
5260 (void *)&cmd_gro_show_pid,
5261 (void *)&cmd_gro_show_keyword,
5266 /* *** SET FLUSH CYCLES FOR GRO *** */
5267 struct cmd_gro_flush_result {
5268 cmdline_fixed_string_t cmd_set;
5269 cmdline_fixed_string_t cmd_keyword;
5270 cmdline_fixed_string_t cmd_flush;
5275 cmd_gro_flush_parsed(void *parsed_result,
5276 __rte_unused struct cmdline *cl,
5277 __rte_unused void *data)
5279 struct cmd_gro_flush_result *res;
5281 res = parsed_result;
5282 if ((!strcmp(res->cmd_keyword, "gro")) &&
5283 (!strcmp(res->cmd_flush, "flush")))
5284 setup_gro_flush_cycles(res->cmd_cycles);
5287 cmdline_parse_token_string_t cmd_gro_flush_set =
5288 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5290 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5291 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5292 cmd_keyword, "gro");
5293 cmdline_parse_token_string_t cmd_gro_flush_flush =
5294 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5295 cmd_flush, "flush");
5296 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5297 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5298 cmd_cycles, RTE_UINT8);
5300 cmdline_parse_inst_t cmd_gro_flush = {
5301 .f = cmd_gro_flush_parsed,
5303 .help_str = "set gro flush <cycles>",
5305 (void *)&cmd_gro_flush_set,
5306 (void *)&cmd_gro_flush_keyword,
5307 (void *)&cmd_gro_flush_flush,
5308 (void *)&cmd_gro_flush_cycles,
5312 #endif /* RTE_LIB_GRO */
5315 /* *** ENABLE/DISABLE GSO *** */
5316 struct cmd_gso_enable_result {
5317 cmdline_fixed_string_t cmd_set;
5318 cmdline_fixed_string_t cmd_port;
5319 cmdline_fixed_string_t cmd_keyword;
5320 cmdline_fixed_string_t cmd_mode;
5325 cmd_gso_enable_parsed(void *parsed_result,
5326 __rte_unused struct cmdline *cl,
5327 __rte_unused void *data)
5329 struct cmd_gso_enable_result *res;
5331 res = parsed_result;
5332 if (!strcmp(res->cmd_keyword, "gso"))
5333 setup_gso(res->cmd_mode, res->cmd_pid);
5336 cmdline_parse_token_string_t cmd_gso_enable_set =
5337 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5339 cmdline_parse_token_string_t cmd_gso_enable_port =
5340 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5342 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5343 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5344 cmd_keyword, "gso");
5345 cmdline_parse_token_string_t cmd_gso_enable_mode =
5346 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5347 cmd_mode, "on#off");
5348 cmdline_parse_token_num_t cmd_gso_enable_pid =
5349 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5350 cmd_pid, RTE_UINT16);
5352 cmdline_parse_inst_t cmd_gso_enable = {
5353 .f = cmd_gso_enable_parsed,
5355 .help_str = "set port <port_id> gso on|off",
5357 (void *)&cmd_gso_enable_set,
5358 (void *)&cmd_gso_enable_port,
5359 (void *)&cmd_gso_enable_pid,
5360 (void *)&cmd_gso_enable_keyword,
5361 (void *)&cmd_gso_enable_mode,
5366 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5367 struct cmd_gso_size_result {
5368 cmdline_fixed_string_t cmd_set;
5369 cmdline_fixed_string_t cmd_keyword;
5370 cmdline_fixed_string_t cmd_segsz;
5375 cmd_gso_size_parsed(void *parsed_result,
5376 __rte_unused struct cmdline *cl,
5377 __rte_unused void *data)
5379 struct cmd_gso_size_result *res = parsed_result;
5381 if (test_done == 0) {
5383 "Before setting GSO segsz, please first stop forwarding\n");
5387 if (!strcmp(res->cmd_keyword, "gso") &&
5388 !strcmp(res->cmd_segsz, "segsz")) {
5389 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5391 "gso_size should be larger than %zu. Please input a legal value\n",
5392 RTE_GSO_SEG_SIZE_MIN);
5394 gso_max_segment_size = res->cmd_size;
5398 cmdline_parse_token_string_t cmd_gso_size_set =
5399 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5401 cmdline_parse_token_string_t cmd_gso_size_keyword =
5402 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5403 cmd_keyword, "gso");
5404 cmdline_parse_token_string_t cmd_gso_size_segsz =
5405 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5406 cmd_segsz, "segsz");
5407 cmdline_parse_token_num_t cmd_gso_size_size =
5408 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5409 cmd_size, RTE_UINT16);
5411 cmdline_parse_inst_t cmd_gso_size = {
5412 .f = cmd_gso_size_parsed,
5414 .help_str = "set gso segsz <length>",
5416 (void *)&cmd_gso_size_set,
5417 (void *)&cmd_gso_size_keyword,
5418 (void *)&cmd_gso_size_segsz,
5419 (void *)&cmd_gso_size_size,
5424 /* *** SHOW GSO CONFIGURATION *** */
5425 struct cmd_gso_show_result {
5426 cmdline_fixed_string_t cmd_show;
5427 cmdline_fixed_string_t cmd_port;
5428 cmdline_fixed_string_t cmd_keyword;
5433 cmd_gso_show_parsed(void *parsed_result,
5434 __rte_unused struct cmdline *cl,
5435 __rte_unused void *data)
5437 struct cmd_gso_show_result *res = parsed_result;
5439 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5440 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5443 if (!strcmp(res->cmd_keyword, "gso")) {
5444 if (gso_ports[res->cmd_pid].enable) {
5445 printf("Max GSO'd packet size: %uB\n"
5446 "Supported GSO types: TCP/IPv4, "
5447 "UDP/IPv4, VxLAN with inner "
5448 "TCP/IPv4 packet, GRE with inner "
5449 "TCP/IPv4 packet\n",
5450 gso_max_segment_size);
5452 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5456 cmdline_parse_token_string_t cmd_gso_show_show =
5457 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5459 cmdline_parse_token_string_t cmd_gso_show_port =
5460 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5462 cmdline_parse_token_string_t cmd_gso_show_keyword =
5463 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5464 cmd_keyword, "gso");
5465 cmdline_parse_token_num_t cmd_gso_show_pid =
5466 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5467 cmd_pid, RTE_UINT16);
5469 cmdline_parse_inst_t cmd_gso_show = {
5470 .f = cmd_gso_show_parsed,
5472 .help_str = "show port <port_id> gso",
5474 (void *)&cmd_gso_show_show,
5475 (void *)&cmd_gso_show_port,
5476 (void *)&cmd_gso_show_pid,
5477 (void *)&cmd_gso_show_keyword,
5481 #endif /* RTE_LIB_GSO */
5483 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5484 struct cmd_set_flush_rx {
5485 cmdline_fixed_string_t set;
5486 cmdline_fixed_string_t flush_rx;
5487 cmdline_fixed_string_t mode;
5491 cmd_set_flush_rx_parsed(void *parsed_result,
5492 __rte_unused struct cmdline *cl,
5493 __rte_unused void *data)
5495 struct cmd_set_flush_rx *res = parsed_result;
5497 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5498 printf("multi-process doesn't support to flush Rx queues.\n");
5502 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5505 cmdline_parse_token_string_t cmd_setflushrx_set =
5506 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5508 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5509 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5510 flush_rx, "flush_rx");
5511 cmdline_parse_token_string_t cmd_setflushrx_mode =
5512 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5516 cmdline_parse_inst_t cmd_set_flush_rx = {
5517 .f = cmd_set_flush_rx_parsed,
5518 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5521 (void *)&cmd_setflushrx_set,
5522 (void *)&cmd_setflushrx_flush_rx,
5523 (void *)&cmd_setflushrx_mode,
5528 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5529 struct cmd_set_link_check {
5530 cmdline_fixed_string_t set;
5531 cmdline_fixed_string_t link_check;
5532 cmdline_fixed_string_t mode;
5536 cmd_set_link_check_parsed(void *parsed_result,
5537 __rte_unused struct cmdline *cl,
5538 __rte_unused void *data)
5540 struct cmd_set_link_check *res = parsed_result;
5541 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5544 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5545 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5547 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5549 link_check, "link_check");
5550 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5551 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5555 cmdline_parse_inst_t cmd_set_link_check = {
5556 .f = cmd_set_link_check_parsed,
5557 .help_str = "set link_check on|off: Enable/Disable link status check "
5558 "when starting/stopping a port",
5561 (void *)&cmd_setlinkcheck_set,
5562 (void *)&cmd_setlinkcheck_link_check,
5563 (void *)&cmd_setlinkcheck_mode,
5568 /* *** SET NIC BYPASS MODE *** */
5569 struct cmd_set_bypass_mode_result {
5570 cmdline_fixed_string_t set;
5571 cmdline_fixed_string_t bypass;
5572 cmdline_fixed_string_t mode;
5573 cmdline_fixed_string_t value;
5578 cmd_set_bypass_mode_parsed(void *parsed_result,
5579 __rte_unused struct cmdline *cl,
5580 __rte_unused void *data)
5582 struct cmd_set_bypass_mode_result *res = parsed_result;
5583 portid_t port_id = res->port_id;
5584 int32_t rc = -EINVAL;
5586 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5587 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5589 if (!strcmp(res->value, "bypass"))
5590 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5591 else if (!strcmp(res->value, "isolate"))
5592 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5594 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5596 /* Set the bypass mode for the relevant port. */
5597 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5600 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5604 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5605 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5607 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5608 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5610 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5613 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5615 value, "normal#bypass#isolate");
5616 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5617 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5618 port_id, RTE_UINT16);
5620 cmdline_parse_inst_t cmd_set_bypass_mode = {
5621 .f = cmd_set_bypass_mode_parsed,
5622 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5623 "Set the NIC bypass mode for port_id",
5626 (void *)&cmd_setbypass_mode_set,
5627 (void *)&cmd_setbypass_mode_bypass,
5628 (void *)&cmd_setbypass_mode_mode,
5629 (void *)&cmd_setbypass_mode_value,
5630 (void *)&cmd_setbypass_mode_port,
5635 /* *** SET NIC BYPASS EVENT *** */
5636 struct cmd_set_bypass_event_result {
5637 cmdline_fixed_string_t set;
5638 cmdline_fixed_string_t bypass;
5639 cmdline_fixed_string_t event;
5640 cmdline_fixed_string_t event_value;
5641 cmdline_fixed_string_t mode;
5642 cmdline_fixed_string_t mode_value;
5647 cmd_set_bypass_event_parsed(void *parsed_result,
5648 __rte_unused struct cmdline *cl,
5649 __rte_unused void *data)
5651 int32_t rc = -EINVAL;
5652 struct cmd_set_bypass_event_result *res = parsed_result;
5653 portid_t port_id = res->port_id;
5655 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5656 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5657 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5659 if (!strcmp(res->event_value, "timeout"))
5660 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5661 else if (!strcmp(res->event_value, "os_on"))
5662 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5663 else if (!strcmp(res->event_value, "os_off"))
5664 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5665 else if (!strcmp(res->event_value, "power_on"))
5666 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5667 else if (!strcmp(res->event_value, "power_off"))
5668 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5670 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5672 if (!strcmp(res->mode_value, "bypass"))
5673 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5674 else if (!strcmp(res->mode_value, "isolate"))
5675 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5677 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5679 /* Set the watchdog timeout. */
5680 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5683 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5684 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5689 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5690 bypass_timeout, port_id, rc);
5694 /* Set the bypass event to transition to bypass mode. */
5695 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5700 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5704 cmdline_parse_token_string_t cmd_setbypass_event_set =
5705 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5707 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5708 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5710 cmdline_parse_token_string_t cmd_setbypass_event_event =
5711 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5713 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5714 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5715 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5716 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5717 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5719 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5720 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5721 mode_value, "normal#bypass#isolate");
5722 cmdline_parse_token_num_t cmd_setbypass_event_port =
5723 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5724 port_id, RTE_UINT16);
5726 cmdline_parse_inst_t cmd_set_bypass_event = {
5727 .f = cmd_set_bypass_event_parsed,
5728 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5729 "power_off mode normal|bypass|isolate <port_id>: "
5730 "Set the NIC bypass event mode for port_id",
5733 (void *)&cmd_setbypass_event_set,
5734 (void *)&cmd_setbypass_event_bypass,
5735 (void *)&cmd_setbypass_event_event,
5736 (void *)&cmd_setbypass_event_event_value,
5737 (void *)&cmd_setbypass_event_mode,
5738 (void *)&cmd_setbypass_event_mode_value,
5739 (void *)&cmd_setbypass_event_port,
5745 /* *** SET NIC BYPASS TIMEOUT *** */
5746 struct cmd_set_bypass_timeout_result {
5747 cmdline_fixed_string_t set;
5748 cmdline_fixed_string_t bypass;
5749 cmdline_fixed_string_t timeout;
5750 cmdline_fixed_string_t value;
5754 cmd_set_bypass_timeout_parsed(void *parsed_result,
5755 __rte_unused struct cmdline *cl,
5756 __rte_unused void *data)
5758 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5760 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5761 if (!strcmp(res->value, "1.5"))
5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5763 else if (!strcmp(res->value, "2"))
5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5765 else if (!strcmp(res->value, "3"))
5766 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5767 else if (!strcmp(res->value, "4"))
5768 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5769 else if (!strcmp(res->value, "8"))
5770 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5771 else if (!strcmp(res->value, "16"))
5772 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5773 else if (!strcmp(res->value, "32"))
5774 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5776 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5780 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5781 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5783 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5784 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5786 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5787 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5788 timeout, "timeout");
5789 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5790 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5791 value, "0#1.5#2#3#4#8#16#32");
5793 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5794 .f = cmd_set_bypass_timeout_parsed,
5795 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5796 "Set the NIC bypass watchdog timeout in seconds",
5799 (void *)&cmd_setbypass_timeout_set,
5800 (void *)&cmd_setbypass_timeout_bypass,
5801 (void *)&cmd_setbypass_timeout_timeout,
5802 (void *)&cmd_setbypass_timeout_value,
5807 /* *** SHOW NIC BYPASS MODE *** */
5808 struct cmd_show_bypass_config_result {
5809 cmdline_fixed_string_t show;
5810 cmdline_fixed_string_t bypass;
5811 cmdline_fixed_string_t config;
5816 cmd_show_bypass_config_parsed(void *parsed_result,
5817 __rte_unused struct cmdline *cl,
5818 __rte_unused void *data)
5820 struct cmd_show_bypass_config_result *res = parsed_result;
5821 portid_t port_id = res->port_id;
5823 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5824 uint32_t event_mode;
5825 uint32_t bypass_mode;
5826 uint32_t timeout = bypass_timeout;
5829 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5830 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5831 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5832 {"UNKNOWN", "normal", "bypass", "isolate"};
5833 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5841 /* Display the bypass mode.*/
5842 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5843 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5848 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5849 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5851 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5854 /* Display the bypass timeout.*/
5855 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5856 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5858 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5860 /* Display the bypass events and associated modes. */
5861 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5863 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5865 "\tFailed to get bypass mode for event = %s\n",
5868 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5869 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5871 printf("\tbypass event: %-16s = %s\n", events[i],
5878 "\tFailed to get bypass configuration for port = %d\n",
5882 cmdline_parse_token_string_t cmd_showbypass_config_show =
5883 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5885 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5886 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5888 cmdline_parse_token_string_t cmd_showbypass_config_config =
5889 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5891 cmdline_parse_token_num_t cmd_showbypass_config_port =
5892 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5893 port_id, RTE_UINT16);
5895 cmdline_parse_inst_t cmd_show_bypass_config = {
5896 .f = cmd_show_bypass_config_parsed,
5897 .help_str = "show bypass config <port_id>: "
5898 "Show the NIC bypass config for port_id",
5901 (void *)&cmd_showbypass_config_show,
5902 (void *)&cmd_showbypass_config_bypass,
5903 (void *)&cmd_showbypass_config_config,
5904 (void *)&cmd_showbypass_config_port,
5910 /* *** SET BONDING MODE *** */
5911 struct cmd_set_bonding_mode_result {
5912 cmdline_fixed_string_t set;
5913 cmdline_fixed_string_t bonding;
5914 cmdline_fixed_string_t mode;
5919 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5920 __rte_unused struct cmdline *cl,
5921 __rte_unused void *data)
5923 struct cmd_set_bonding_mode_result *res = parsed_result;
5924 portid_t port_id = res->port_id;
5925 struct rte_port *port = &ports[port_id];
5928 * Bonding mode changed means resources of device changed, like whether
5929 * started rte timer or not. Device should be restarted when resources
5930 * of device changed.
5932 if (port->port_status != RTE_PORT_STOPPED) {
5934 "\t Error: Can't set bonding mode when port %d is not stopped\n",
5939 /* Set the bonding mode for the relevant port. */
5940 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5941 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5945 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5946 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5948 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5949 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5950 bonding, "bonding");
5951 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5952 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5954 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5955 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5957 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5958 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5959 port_id, RTE_UINT16);
5961 cmdline_parse_inst_t cmd_set_bonding_mode = {
5962 .f = cmd_set_bonding_mode_parsed,
5963 .help_str = "set bonding mode <mode_value> <port_id>: "
5964 "Set the bonding mode for port_id",
5967 (void *) &cmd_setbonding_mode_set,
5968 (void *) &cmd_setbonding_mode_bonding,
5969 (void *) &cmd_setbonding_mode_mode,
5970 (void *) &cmd_setbonding_mode_value,
5971 (void *) &cmd_setbonding_mode_port,
5976 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5977 struct cmd_set_bonding_lacp_dedicated_queues_result {
5978 cmdline_fixed_string_t set;
5979 cmdline_fixed_string_t bonding;
5980 cmdline_fixed_string_t lacp;
5981 cmdline_fixed_string_t dedicated_queues;
5983 cmdline_fixed_string_t mode;
5986 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5987 __rte_unused struct cmdline *cl,
5988 __rte_unused void *data)
5990 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5991 portid_t port_id = res->port_id;
5992 struct rte_port *port;
5994 port = &ports[port_id];
5996 /** Check if the port is not started **/
5997 if (port->port_status != RTE_PORT_STOPPED) {
5998 fprintf(stderr, "Please stop port %d first\n", port_id);
6002 if (!strcmp(res->mode, "enable")) {
6003 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
6004 printf("Dedicate queues for LACP control packets"
6007 printf("Enabling dedicate queues for LACP control "
6008 "packets on port %d failed\n", port_id);
6009 } else if (!strcmp(res->mode, "disable")) {
6010 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
6011 printf("Dedicated queues for LACP control packets "
6014 printf("Disabling dedicated queues for LACP control "
6015 "traffic on port %d failed\n", port_id);
6019 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6020 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6022 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6023 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6024 bonding, "bonding");
6025 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6026 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6028 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6029 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6030 dedicated_queues, "dedicated_queues");
6031 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6032 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6033 port_id, RTE_UINT16);
6034 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6035 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6036 mode, "enable#disable");
6038 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6039 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6040 .help_str = "set bonding lacp dedicated_queues <port_id> "
6042 "Enable/disable dedicated queues for LACP control traffic for port_id",
6045 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6046 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6047 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6048 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6049 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6050 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6055 /* *** SET BALANCE XMIT POLICY *** */
6056 struct cmd_set_bonding_balance_xmit_policy_result {
6057 cmdline_fixed_string_t set;
6058 cmdline_fixed_string_t bonding;
6059 cmdline_fixed_string_t balance_xmit_policy;
6061 cmdline_fixed_string_t policy;
6064 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6065 __rte_unused struct cmdline *cl,
6066 __rte_unused void *data)
6068 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6069 portid_t port_id = res->port_id;
6072 if (!strcmp(res->policy, "l2")) {
6073 policy = BALANCE_XMIT_POLICY_LAYER2;
6074 } else if (!strcmp(res->policy, "l23")) {
6075 policy = BALANCE_XMIT_POLICY_LAYER23;
6076 } else if (!strcmp(res->policy, "l34")) {
6077 policy = BALANCE_XMIT_POLICY_LAYER34;
6079 fprintf(stderr, "\t Invalid xmit policy selection");
6083 /* Set the bonding mode for the relevant port. */
6084 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6086 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6091 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6092 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6094 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6095 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6096 bonding, "bonding");
6097 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6098 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6099 balance_xmit_policy, "balance_xmit_policy");
6100 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6101 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6102 port_id, RTE_UINT16);
6103 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6104 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6105 policy, "l2#l23#l34");
6107 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6108 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6109 .help_str = "set bonding balance_xmit_policy <port_id> "
6111 "Set the bonding balance_xmit_policy for port_id",
6114 (void *)&cmd_setbonding_balance_xmit_policy_set,
6115 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6116 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6117 (void *)&cmd_setbonding_balance_xmit_policy_port,
6118 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6123 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6124 struct cmd_show_bonding_lacp_info_result {
6125 cmdline_fixed_string_t show;
6126 cmdline_fixed_string_t bonding;
6127 cmdline_fixed_string_t lacp;
6128 cmdline_fixed_string_t info;
6132 static void port_param_show(struct port_params *params)
6134 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6136 printf("\t\tsystem priority: %u\n", params->system_priority);
6137 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6138 printf("\t\tsystem mac address: %s\n", buf);
6139 printf("\t\tport key: %u\n", params->key);
6140 printf("\t\tport priority: %u\n", params->port_priority);
6141 printf("\t\tport number: %u\n", params->port_number);
6144 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6146 char a_state[256] = { 0 };
6147 char p_state[256] = { 0 };
6152 static const char * const state[] = {
6162 static const char * const selection[] = {
6168 for (i = 0; i < RTE_DIM(state); i++) {
6169 if ((info->actor_state >> i) & 1)
6170 a_len += snprintf(&a_state[a_len],
6171 RTE_DIM(a_state) - a_len, "%s ",
6174 if ((info->partner_state >> i) & 1)
6175 p_len += snprintf(&p_state[p_len],
6176 RTE_DIM(p_state) - p_len, "%s ",
6179 printf("\tAggregator port id: %u\n", info->agg_port_id);
6180 printf("\tselection: %s\n", selection[info->selected]);
6181 printf("\tActor detail info:\n");
6182 port_param_show(&info->actor);
6183 printf("\t\tport state: %s\n", a_state);
6184 printf("\tPartner detail info:\n");
6185 port_param_show(&info->partner);
6186 printf("\t\tport state: %s\n", p_state);
6190 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6192 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6193 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6194 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6195 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6196 printf("\taggregate wait timeout: %u ms\n",
6197 conf->aggregate_wait_timeout_ms);
6198 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6199 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6200 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6201 switch (conf->agg_selection) {
6203 printf("\taggregation mode: bandwidth\n");
6206 printf("\taggregation mode: stable\n");
6209 printf("\taggregation mode: count\n");
6212 printf("\taggregation mode: invalid\n");
6219 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6220 __rte_unused struct cmdline *cl,
6221 __rte_unused void *data)
6223 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6224 struct rte_eth_bond_8023ad_slave_info slave_info;
6225 struct rte_eth_bond_8023ad_conf port_conf;
6226 portid_t slaves[RTE_MAX_ETHPORTS];
6227 portid_t port_id = res->port_id;
6228 int num_active_slaves;
6233 bonding_mode = rte_eth_bond_mode_get(port_id);
6234 if (bonding_mode != BONDING_MODE_8023AD) {
6235 fprintf(stderr, "\tBonding mode is not mode 4\n");
6239 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6241 if (num_active_slaves < 0) {
6242 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6246 if (num_active_slaves == 0)
6247 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6250 printf("\tIEEE802.3 port: %u\n", port_id);
6251 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6253 fprintf(stderr, "\tGet bonded device %u info failed\n",
6257 lacp_conf_show(&port_conf);
6259 for (i = 0; i < num_active_slaves; i++) {
6260 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6263 fprintf(stderr, "\tGet slave device %u info failed\n",
6267 printf("\tSlave Port: %u\n", slaves[i]);
6268 lacp_slave_info_show(&slave_info);
6272 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6273 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6275 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6276 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6277 bonding, "bonding");
6278 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6279 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6281 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6282 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6284 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6285 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6286 port_id, RTE_UINT16);
6288 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6289 .f = cmd_show_bonding_lacp_info_parsed,
6290 .help_str = "show bonding lacp info <port_id> : "
6291 "Show bonding IEEE802.3 information for port_id",
6294 (void *)&cmd_show_bonding_lacp_info_show,
6295 (void *)&cmd_show_bonding_lacp_info_bonding,
6296 (void *)&cmd_show_bonding_lacp_info_lacp,
6297 (void *)&cmd_show_bonding_lacp_info_info,
6298 (void *)&cmd_show_bonding_lacp_info_port_id,
6303 /* *** SHOW NIC BONDING CONFIGURATION *** */
6304 struct cmd_show_bonding_config_result {
6305 cmdline_fixed_string_t show;
6306 cmdline_fixed_string_t bonding;
6307 cmdline_fixed_string_t config;
6311 static void cmd_show_bonding_config_parsed(void *parsed_result,
6312 __rte_unused struct cmdline *cl,
6313 __rte_unused void *data)
6315 struct cmd_show_bonding_config_result *res = parsed_result;
6316 int bonding_mode, agg_mode;
6317 portid_t slaves[RTE_MAX_ETHPORTS];
6318 int num_slaves, num_active_slaves;
6321 portid_t port_id = res->port_id;
6323 /* Display the bonding mode.*/
6324 bonding_mode = rte_eth_bond_mode_get(port_id);
6325 if (bonding_mode < 0) {
6326 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6330 printf("\tBonding mode: %d\n", bonding_mode);
6332 if (bonding_mode == BONDING_MODE_BALANCE ||
6333 bonding_mode == BONDING_MODE_8023AD) {
6334 int balance_xmit_policy;
6336 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6337 if (balance_xmit_policy < 0) {
6339 "\tFailed to get balance xmit policy for port = %d\n",
6343 printf("\tBalance Xmit Policy: ");
6345 switch (balance_xmit_policy) {
6346 case BALANCE_XMIT_POLICY_LAYER2:
6347 printf("BALANCE_XMIT_POLICY_LAYER2");
6349 case BALANCE_XMIT_POLICY_LAYER23:
6350 printf("BALANCE_XMIT_POLICY_LAYER23");
6352 case BALANCE_XMIT_POLICY_LAYER34:
6353 printf("BALANCE_XMIT_POLICY_LAYER34");
6360 if (bonding_mode == BONDING_MODE_8023AD) {
6361 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6362 printf("\tIEEE802.3AD Aggregator Mode: ");
6365 printf("bandwidth");
6377 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6379 if (num_slaves < 0) {
6380 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6384 if (num_slaves > 0) {
6385 printf("\tSlaves (%d): [", num_slaves);
6386 for (i = 0; i < num_slaves - 1; i++)
6387 printf("%d ", slaves[i]);
6389 printf("%d]\n", slaves[num_slaves - 1]);
6391 printf("\tSlaves: []\n");
6395 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6398 if (num_active_slaves < 0) {
6400 "\tFailed to get active slave list for port = %d\n",
6404 if (num_active_slaves > 0) {
6405 printf("\tActive Slaves (%d): [", num_active_slaves);
6406 for (i = 0; i < num_active_slaves - 1; i++)
6407 printf("%d ", slaves[i]);
6409 printf("%d]\n", slaves[num_active_slaves - 1]);
6412 printf("\tActive Slaves: []\n");
6416 primary_id = rte_eth_bond_primary_get(port_id);
6417 if (primary_id < 0) {
6418 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6422 printf("\tPrimary: [%d]\n", primary_id);
6426 cmdline_parse_token_string_t cmd_showbonding_config_show =
6427 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6429 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6430 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6431 bonding, "bonding");
6432 cmdline_parse_token_string_t cmd_showbonding_config_config =
6433 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6435 cmdline_parse_token_num_t cmd_showbonding_config_port =
6436 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6437 port_id, RTE_UINT16);
6439 cmdline_parse_inst_t cmd_show_bonding_config = {
6440 .f = cmd_show_bonding_config_parsed,
6441 .help_str = "show bonding config <port_id>: "
6442 "Show the bonding config for port_id",
6445 (void *)&cmd_showbonding_config_show,
6446 (void *)&cmd_showbonding_config_bonding,
6447 (void *)&cmd_showbonding_config_config,
6448 (void *)&cmd_showbonding_config_port,
6453 /* *** SET BONDING PRIMARY *** */
6454 struct cmd_set_bonding_primary_result {
6455 cmdline_fixed_string_t set;
6456 cmdline_fixed_string_t bonding;
6457 cmdline_fixed_string_t primary;
6462 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6463 __rte_unused struct cmdline *cl,
6464 __rte_unused void *data)
6466 struct cmd_set_bonding_primary_result *res = parsed_result;
6467 portid_t master_port_id = res->port_id;
6468 portid_t slave_port_id = res->slave_id;
6470 /* Set the primary slave for a bonded device. */
6471 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6472 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6479 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6480 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6482 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6484 bonding, "bonding");
6485 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6486 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6487 primary, "primary");
6488 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6489 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6490 slave_id, RTE_UINT16);
6491 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6492 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6493 port_id, RTE_UINT16);
6495 cmdline_parse_inst_t cmd_set_bonding_primary = {
6496 .f = cmd_set_bonding_primary_parsed,
6497 .help_str = "set bonding primary <slave_id> <port_id>: "
6498 "Set the primary slave for port_id",
6501 (void *)&cmd_setbonding_primary_set,
6502 (void *)&cmd_setbonding_primary_bonding,
6503 (void *)&cmd_setbonding_primary_primary,
6504 (void *)&cmd_setbonding_primary_slave,
6505 (void *)&cmd_setbonding_primary_port,
6510 /* *** ADD SLAVE *** */
6511 struct cmd_add_bonding_slave_result {
6512 cmdline_fixed_string_t add;
6513 cmdline_fixed_string_t bonding;
6514 cmdline_fixed_string_t slave;
6519 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6520 __rte_unused struct cmdline *cl,
6521 __rte_unused void *data)
6523 struct cmd_add_bonding_slave_result *res = parsed_result;
6524 portid_t master_port_id = res->port_id;
6525 portid_t slave_port_id = res->slave_id;
6527 /* add the slave for a bonded device. */
6528 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6530 "\t Failed to add slave %d to master port = %d.\n",
6531 slave_port_id, master_port_id);
6535 set_port_slave_flag(slave_port_id);
6538 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6539 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6541 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6542 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6543 bonding, "bonding");
6544 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6545 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6547 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6548 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6549 slave_id, RTE_UINT16);
6550 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6551 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6552 port_id, RTE_UINT16);
6554 cmdline_parse_inst_t cmd_add_bonding_slave = {
6555 .f = cmd_add_bonding_slave_parsed,
6556 .help_str = "add bonding slave <slave_id> <port_id>: "
6557 "Add a slave device to a bonded device",
6560 (void *)&cmd_addbonding_slave_add,
6561 (void *)&cmd_addbonding_slave_bonding,
6562 (void *)&cmd_addbonding_slave_slave,
6563 (void *)&cmd_addbonding_slave_slaveid,
6564 (void *)&cmd_addbonding_slave_port,
6569 /* *** REMOVE SLAVE *** */
6570 struct cmd_remove_bonding_slave_result {
6571 cmdline_fixed_string_t remove;
6572 cmdline_fixed_string_t bonding;
6573 cmdline_fixed_string_t slave;
6578 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6579 __rte_unused struct cmdline *cl,
6580 __rte_unused void *data)
6582 struct cmd_remove_bonding_slave_result *res = parsed_result;
6583 portid_t master_port_id = res->port_id;
6584 portid_t slave_port_id = res->slave_id;
6586 /* remove the slave from a bonded device. */
6587 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6589 "\t Failed to remove slave %d from master port = %d.\n",
6590 slave_port_id, master_port_id);
6594 clear_port_slave_flag(slave_port_id);
6597 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6598 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6600 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6601 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6602 bonding, "bonding");
6603 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6604 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6606 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6607 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6608 slave_id, RTE_UINT16);
6609 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6610 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6611 port_id, RTE_UINT16);
6613 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6614 .f = cmd_remove_bonding_slave_parsed,
6615 .help_str = "remove bonding slave <slave_id> <port_id>: "
6616 "Remove a slave device from a bonded device",
6619 (void *)&cmd_removebonding_slave_remove,
6620 (void *)&cmd_removebonding_slave_bonding,
6621 (void *)&cmd_removebonding_slave_slave,
6622 (void *)&cmd_removebonding_slave_slaveid,
6623 (void *)&cmd_removebonding_slave_port,
6628 /* *** CREATE BONDED DEVICE *** */
6629 struct cmd_create_bonded_device_result {
6630 cmdline_fixed_string_t create;
6631 cmdline_fixed_string_t bonded;
6632 cmdline_fixed_string_t device;
6637 static int bond_dev_num = 0;
6639 static void cmd_create_bonded_device_parsed(void *parsed_result,
6640 __rte_unused struct cmdline *cl,
6641 __rte_unused void *data)
6643 struct cmd_create_bonded_device_result *res = parsed_result;
6644 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6648 if (test_done == 0) {
6649 fprintf(stderr, "Please stop forwarding first\n");
6653 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6656 /* Create a new bonded device. */
6657 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6659 fprintf(stderr, "\t Failed to create bonded device.\n");
6662 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6665 /* Update number of ports */
6666 nb_ports = rte_eth_dev_count_avail();
6667 reconfig(port_id, res->socket);
6668 ret = rte_eth_promiscuous_enable(port_id);
6671 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6672 port_id, rte_strerror(-ret));
6674 ports[port_id].need_setup = 0;
6675 ports[port_id].port_status = RTE_PORT_STOPPED;
6680 cmdline_parse_token_string_t cmd_createbonded_device_create =
6681 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6683 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6684 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6686 cmdline_parse_token_string_t cmd_createbonded_device_device =
6687 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6689 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6690 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6692 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6693 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6696 cmdline_parse_inst_t cmd_create_bonded_device = {
6697 .f = cmd_create_bonded_device_parsed,
6698 .help_str = "create bonded device <mode> <socket>: "
6699 "Create a new bonded device with specific bonding mode and socket",
6702 (void *)&cmd_createbonded_device_create,
6703 (void *)&cmd_createbonded_device_bonded,
6704 (void *)&cmd_createbonded_device_device,
6705 (void *)&cmd_createbonded_device_mode,
6706 (void *)&cmd_createbonded_device_socket,
6711 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6712 struct cmd_set_bond_mac_addr_result {
6713 cmdline_fixed_string_t set;
6714 cmdline_fixed_string_t bonding;
6715 cmdline_fixed_string_t mac_addr;
6717 struct rte_ether_addr address;
6720 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6721 __rte_unused struct cmdline *cl,
6722 __rte_unused void *data)
6724 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6727 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6730 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6732 /* check the return value and print it if is < 0 */
6734 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6738 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6739 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6740 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6743 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6744 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6746 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6747 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6748 port_num, RTE_UINT16);
6749 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6750 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6752 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6753 .f = cmd_set_bond_mac_addr_parsed,
6755 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6757 (void *)&cmd_set_bond_mac_addr_set,
6758 (void *)&cmd_set_bond_mac_addr_bonding,
6759 (void *)&cmd_set_bond_mac_addr_mac,
6760 (void *)&cmd_set_bond_mac_addr_portnum,
6761 (void *)&cmd_set_bond_mac_addr_addr,
6767 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6768 struct cmd_set_bond_mon_period_result {
6769 cmdline_fixed_string_t set;
6770 cmdline_fixed_string_t bonding;
6771 cmdline_fixed_string_t mon_period;
6776 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6777 __rte_unused struct cmdline *cl,
6778 __rte_unused void *data)
6780 struct cmd_set_bond_mon_period_result *res = parsed_result;
6783 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6785 /* check the return value and print it if is < 0 */
6787 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6791 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6792 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6794 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6795 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6796 bonding, "bonding");
6797 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6798 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6799 mon_period, "mon_period");
6800 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6801 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6802 port_num, RTE_UINT16);
6803 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6804 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6805 period_ms, RTE_UINT32);
6807 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6808 .f = cmd_set_bond_mon_period_parsed,
6810 .help_str = "set bonding mon_period <port_id> <period_ms>",
6812 (void *)&cmd_set_bond_mon_period_set,
6813 (void *)&cmd_set_bond_mon_period_bonding,
6814 (void *)&cmd_set_bond_mon_period_mon_period,
6815 (void *)&cmd_set_bond_mon_period_portnum,
6816 (void *)&cmd_set_bond_mon_period_period_ms,
6823 struct cmd_set_bonding_agg_mode_policy_result {
6824 cmdline_fixed_string_t set;
6825 cmdline_fixed_string_t bonding;
6826 cmdline_fixed_string_t agg_mode;
6828 cmdline_fixed_string_t policy;
6833 cmd_set_bonding_agg_mode(void *parsed_result,
6834 __rte_unused struct cmdline *cl,
6835 __rte_unused void *data)
6837 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6838 uint8_t policy = AGG_BANDWIDTH;
6840 if (!strcmp(res->policy, "bandwidth"))
6841 policy = AGG_BANDWIDTH;
6842 else if (!strcmp(res->policy, "stable"))
6843 policy = AGG_STABLE;
6844 else if (!strcmp(res->policy, "count"))
6847 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6851 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6852 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6854 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6855 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6856 bonding, "bonding");
6858 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6859 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6860 agg_mode, "agg_mode");
6862 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6863 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6864 port_num, RTE_UINT16);
6866 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6867 TOKEN_STRING_INITIALIZER(
6868 struct cmd_set_bonding_balance_xmit_policy_result,
6869 policy, "stable#bandwidth#count");
6871 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6872 .f = cmd_set_bonding_agg_mode,
6874 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6876 (void *)&cmd_set_bonding_agg_mode_set,
6877 (void *)&cmd_set_bonding_agg_mode_bonding,
6878 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6879 (void *)&cmd_set_bonding_agg_mode_portnum,
6880 (void *)&cmd_set_bonding_agg_mode_policy_string,
6886 #endif /* RTE_NET_BOND */
6888 /* *** SET FORWARDING MODE *** */
6889 struct cmd_set_fwd_mode_result {
6890 cmdline_fixed_string_t set;
6891 cmdline_fixed_string_t fwd;
6892 cmdline_fixed_string_t mode;
6895 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6896 __rte_unused struct cmdline *cl,
6897 __rte_unused void *data)
6899 struct cmd_set_fwd_mode_result *res = parsed_result;
6902 set_pkt_forwarding_mode(res->mode);
6905 cmdline_parse_token_string_t cmd_setfwd_set =
6906 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6907 cmdline_parse_token_string_t cmd_setfwd_fwd =
6908 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6909 cmdline_parse_token_string_t cmd_setfwd_mode =
6910 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6911 "" /* defined at init */);
6913 cmdline_parse_inst_t cmd_set_fwd_mode = {
6914 .f = cmd_set_fwd_mode_parsed,
6916 .help_str = NULL, /* defined at init */
6918 (void *)&cmd_setfwd_set,
6919 (void *)&cmd_setfwd_fwd,
6920 (void *)&cmd_setfwd_mode,
6925 static void cmd_set_fwd_mode_init(void)
6928 static char token[128];
6929 static char help[256];
6930 cmdline_parse_token_string_t *token_struct;
6932 modes = list_pkt_forwarding_modes();
6933 snprintf(help, sizeof(help), "set fwd %s: "
6934 "Set packet forwarding mode", modes);
6935 cmd_set_fwd_mode.help_str = help;
6937 /* string token separator is # */
6938 for (c = token; *modes != '\0'; modes++)
6943 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6944 token_struct->string_data.str = token;
6947 /* *** SET RETRY FORWARDING MODE *** */
6948 struct cmd_set_fwd_retry_mode_result {
6949 cmdline_fixed_string_t set;
6950 cmdline_fixed_string_t fwd;
6951 cmdline_fixed_string_t mode;
6952 cmdline_fixed_string_t retry;
6955 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6956 __rte_unused struct cmdline *cl,
6957 __rte_unused void *data)
6959 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6962 set_pkt_forwarding_mode(res->mode);
6965 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6966 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6968 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6969 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6971 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6972 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6974 "" /* defined at init */);
6975 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6976 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6979 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6980 .f = cmd_set_fwd_retry_mode_parsed,
6982 .help_str = NULL, /* defined at init */
6984 (void *)&cmd_setfwd_retry_set,
6985 (void *)&cmd_setfwd_retry_fwd,
6986 (void *)&cmd_setfwd_retry_mode,
6987 (void *)&cmd_setfwd_retry_retry,
6992 static void cmd_set_fwd_retry_mode_init(void)
6995 static char token[128];
6996 static char help[256];
6997 cmdline_parse_token_string_t *token_struct;
6999 modes = list_pkt_forwarding_retry_modes();
7000 snprintf(help, sizeof(help), "set fwd %s retry: "
7001 "Set packet forwarding mode with retry", modes);
7002 cmd_set_fwd_retry_mode.help_str = help;
7004 /* string token separator is # */
7005 for (c = token; *modes != '\0'; modes++)
7010 token_struct = (cmdline_parse_token_string_t *)
7011 cmd_set_fwd_retry_mode.tokens[2];
7012 token_struct->string_data.str = token;
7015 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
7016 struct cmd_set_burst_tx_retry_result {
7017 cmdline_fixed_string_t set;
7018 cmdline_fixed_string_t burst;
7019 cmdline_fixed_string_t tx;
7020 cmdline_fixed_string_t delay;
7022 cmdline_fixed_string_t retry;
7026 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7027 __rte_unused struct cmdline *cl,
7028 __rte_unused void *data)
7030 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7032 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7033 && !strcmp(res->tx, "tx")) {
7034 if (!strcmp(res->delay, "delay"))
7035 burst_tx_delay_time = res->time;
7036 if (!strcmp(res->retry, "retry"))
7037 burst_tx_retry_num = res->retry_num;
7042 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7043 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7044 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7045 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7047 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7048 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7049 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7050 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7051 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7052 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7054 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7055 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7056 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7057 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7060 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7061 .f = cmd_set_burst_tx_retry_parsed,
7062 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7064 (void *)&cmd_set_burst_tx_retry_set,
7065 (void *)&cmd_set_burst_tx_retry_burst,
7066 (void *)&cmd_set_burst_tx_retry_tx,
7067 (void *)&cmd_set_burst_tx_retry_delay,
7068 (void *)&cmd_set_burst_tx_retry_time,
7069 (void *)&cmd_set_burst_tx_retry_retry,
7070 (void *)&cmd_set_burst_tx_retry_retry_num,
7075 /* *** SET PROMISC MODE *** */
7076 struct cmd_set_promisc_mode_result {
7077 cmdline_fixed_string_t set;
7078 cmdline_fixed_string_t promisc;
7079 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7080 uint16_t port_num; /* valid if "allports" argument == 0 */
7081 cmdline_fixed_string_t mode;
7084 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7085 __rte_unused struct cmdline *cl,
7088 struct cmd_set_promisc_mode_result *res = parsed_result;
7092 if (!strcmp(res->mode, "on"))
7099 RTE_ETH_FOREACH_DEV(i)
7100 eth_set_promisc_mode(i, enable);
7102 eth_set_promisc_mode(res->port_num, enable);
7106 cmdline_parse_token_string_t cmd_setpromisc_set =
7107 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7108 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7109 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7111 cmdline_parse_token_string_t cmd_setpromisc_portall =
7112 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7114 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7115 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7117 cmdline_parse_token_string_t cmd_setpromisc_mode =
7118 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7121 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7122 .f = cmd_set_promisc_mode_parsed,
7124 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7126 (void *)&cmd_setpromisc_set,
7127 (void *)&cmd_setpromisc_promisc,
7128 (void *)&cmd_setpromisc_portall,
7129 (void *)&cmd_setpromisc_mode,
7134 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7135 .f = cmd_set_promisc_mode_parsed,
7137 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7139 (void *)&cmd_setpromisc_set,
7140 (void *)&cmd_setpromisc_promisc,
7141 (void *)&cmd_setpromisc_portnum,
7142 (void *)&cmd_setpromisc_mode,
7147 /* *** SET ALLMULTI MODE *** */
7148 struct cmd_set_allmulti_mode_result {
7149 cmdline_fixed_string_t set;
7150 cmdline_fixed_string_t allmulti;
7151 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7152 uint16_t port_num; /* valid if "allports" argument == 0 */
7153 cmdline_fixed_string_t mode;
7156 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7157 __rte_unused struct cmdline *cl,
7160 struct cmd_set_allmulti_mode_result *res = parsed_result;
7164 if (!strcmp(res->mode, "on"))
7171 RTE_ETH_FOREACH_DEV(i) {
7172 eth_set_allmulticast_mode(i, enable);
7176 eth_set_allmulticast_mode(res->port_num, enable);
7180 cmdline_parse_token_string_t cmd_setallmulti_set =
7181 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7182 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7183 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7185 cmdline_parse_token_string_t cmd_setallmulti_portall =
7186 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7188 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7189 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7191 cmdline_parse_token_string_t cmd_setallmulti_mode =
7192 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7195 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7196 .f = cmd_set_allmulti_mode_parsed,
7198 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7200 (void *)&cmd_setallmulti_set,
7201 (void *)&cmd_setallmulti_allmulti,
7202 (void *)&cmd_setallmulti_portall,
7203 (void *)&cmd_setallmulti_mode,
7208 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7209 .f = cmd_set_allmulti_mode_parsed,
7211 .help_str = "set allmulti <port_id> on|off: "
7212 "Set allmulti mode on port_id",
7214 (void *)&cmd_setallmulti_set,
7215 (void *)&cmd_setallmulti_allmulti,
7216 (void *)&cmd_setallmulti_portnum,
7217 (void *)&cmd_setallmulti_mode,
7222 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7223 struct cmd_link_flow_ctrl_show {
7224 cmdline_fixed_string_t show;
7225 cmdline_fixed_string_t port;
7227 cmdline_fixed_string_t flow_ctrl;
7230 cmdline_parse_token_string_t cmd_lfc_show_show =
7231 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7233 cmdline_parse_token_string_t cmd_lfc_show_port =
7234 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7236 cmdline_parse_token_num_t cmd_lfc_show_portid =
7237 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7238 port_id, RTE_UINT16);
7239 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7240 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7241 flow_ctrl, "flow_ctrl");
7244 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7245 __rte_unused struct cmdline *cl,
7246 __rte_unused void *data)
7248 struct cmd_link_flow_ctrl_show *res = parsed_result;
7249 static const char *info_border = "*********************";
7250 struct rte_eth_fc_conf fc_conf;
7251 bool rx_fc_en = false;
7252 bool tx_fc_en = false;
7255 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7258 "Failed to get current flow ctrl information: err = %d\n",
7263 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7265 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7268 printf("\n%s Flow control infos for port %-2d %s\n",
7269 info_border, res->port_id, info_border);
7270 printf("FC mode:\n");
7271 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7272 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7273 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7274 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7275 printf("High waterline: 0x%x\n", fc_conf.high_water);
7276 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7277 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7278 printf("Forward MAC control frames: %s\n",
7279 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7280 printf("\n%s************** End ***********%s\n",
7281 info_border, info_border);
7284 cmdline_parse_inst_t cmd_link_flow_control_show = {
7285 .f = cmd_link_flow_ctrl_show_parsed,
7287 .help_str = "show port <port_id> flow_ctrl",
7289 (void *)&cmd_lfc_show_show,
7290 (void *)&cmd_lfc_show_port,
7291 (void *)&cmd_lfc_show_portid,
7292 (void *)&cmd_lfc_show_flow_ctrl,
7297 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7298 struct cmd_link_flow_ctrl_set_result {
7299 cmdline_fixed_string_t set;
7300 cmdline_fixed_string_t flow_ctrl;
7301 cmdline_fixed_string_t rx;
7302 cmdline_fixed_string_t rx_lfc_mode;
7303 cmdline_fixed_string_t tx;
7304 cmdline_fixed_string_t tx_lfc_mode;
7305 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7306 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7307 cmdline_fixed_string_t autoneg_str;
7308 cmdline_fixed_string_t autoneg;
7309 cmdline_fixed_string_t hw_str;
7310 uint32_t high_water;
7311 cmdline_fixed_string_t lw_str;
7313 cmdline_fixed_string_t pt_str;
7314 uint16_t pause_time;
7315 cmdline_fixed_string_t xon_str;
7320 cmdline_parse_token_string_t cmd_lfc_set_set =
7321 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7323 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7324 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7325 flow_ctrl, "flow_ctrl");
7326 cmdline_parse_token_string_t cmd_lfc_set_rx =
7327 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7329 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7330 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7331 rx_lfc_mode, "on#off");
7332 cmdline_parse_token_string_t cmd_lfc_set_tx =
7333 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7335 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7336 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7337 tx_lfc_mode, "on#off");
7338 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7339 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7340 hw_str, "high_water");
7341 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7342 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7343 high_water, RTE_UINT32);
7344 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7345 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7346 lw_str, "low_water");
7347 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7348 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7349 low_water, RTE_UINT32);
7350 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7351 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7352 pt_str, "pause_time");
7353 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7354 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7355 pause_time, RTE_UINT16);
7356 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7357 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7358 xon_str, "send_xon");
7359 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7360 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7361 send_xon, RTE_UINT16);
7362 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7363 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7364 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7365 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7366 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7367 mac_ctrl_frame_fwd_mode, "on#off");
7368 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7369 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7370 autoneg_str, "autoneg");
7371 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7372 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7374 cmdline_parse_token_num_t cmd_lfc_set_portid =
7375 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7376 port_id, RTE_UINT16);
7378 /* forward declaration */
7380 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7383 cmdline_parse_inst_t cmd_link_flow_control_set = {
7384 .f = cmd_link_flow_ctrl_set_parsed,
7386 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7387 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7388 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7390 (void *)&cmd_lfc_set_set,
7391 (void *)&cmd_lfc_set_flow_ctrl,
7392 (void *)&cmd_lfc_set_rx,
7393 (void *)&cmd_lfc_set_rx_mode,
7394 (void *)&cmd_lfc_set_tx,
7395 (void *)&cmd_lfc_set_tx_mode,
7396 (void *)&cmd_lfc_set_high_water,
7397 (void *)&cmd_lfc_set_low_water,
7398 (void *)&cmd_lfc_set_pause_time,
7399 (void *)&cmd_lfc_set_send_xon,
7400 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7401 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7402 (void *)&cmd_lfc_set_autoneg_str,
7403 (void *)&cmd_lfc_set_autoneg,
7404 (void *)&cmd_lfc_set_portid,
7409 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7410 .f = cmd_link_flow_ctrl_set_parsed,
7411 .data = (void *)&cmd_link_flow_control_set_rx,
7412 .help_str = "set flow_ctrl rx on|off <port_id>: "
7413 "Change rx flow control parameter",
7415 (void *)&cmd_lfc_set_set,
7416 (void *)&cmd_lfc_set_flow_ctrl,
7417 (void *)&cmd_lfc_set_rx,
7418 (void *)&cmd_lfc_set_rx_mode,
7419 (void *)&cmd_lfc_set_portid,
7424 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7425 .f = cmd_link_flow_ctrl_set_parsed,
7426 .data = (void *)&cmd_link_flow_control_set_tx,
7427 .help_str = "set flow_ctrl tx on|off <port_id>: "
7428 "Change tx flow control parameter",
7430 (void *)&cmd_lfc_set_set,
7431 (void *)&cmd_lfc_set_flow_ctrl,
7432 (void *)&cmd_lfc_set_tx,
7433 (void *)&cmd_lfc_set_tx_mode,
7434 (void *)&cmd_lfc_set_portid,
7439 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7440 .f = cmd_link_flow_ctrl_set_parsed,
7441 .data = (void *)&cmd_link_flow_control_set_hw,
7442 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7443 "Change high water flow control parameter",
7445 (void *)&cmd_lfc_set_set,
7446 (void *)&cmd_lfc_set_flow_ctrl,
7447 (void *)&cmd_lfc_set_high_water_str,
7448 (void *)&cmd_lfc_set_high_water,
7449 (void *)&cmd_lfc_set_portid,
7454 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7455 .f = cmd_link_flow_ctrl_set_parsed,
7456 .data = (void *)&cmd_link_flow_control_set_lw,
7457 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7458 "Change low water flow control parameter",
7460 (void *)&cmd_lfc_set_set,
7461 (void *)&cmd_lfc_set_flow_ctrl,
7462 (void *)&cmd_lfc_set_low_water_str,
7463 (void *)&cmd_lfc_set_low_water,
7464 (void *)&cmd_lfc_set_portid,
7469 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7470 .f = cmd_link_flow_ctrl_set_parsed,
7471 .data = (void *)&cmd_link_flow_control_set_pt,
7472 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7473 "Change pause time flow control parameter",
7475 (void *)&cmd_lfc_set_set,
7476 (void *)&cmd_lfc_set_flow_ctrl,
7477 (void *)&cmd_lfc_set_pause_time_str,
7478 (void *)&cmd_lfc_set_pause_time,
7479 (void *)&cmd_lfc_set_portid,
7484 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7485 .f = cmd_link_flow_ctrl_set_parsed,
7486 .data = (void *)&cmd_link_flow_control_set_xon,
7487 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7488 "Change send_xon flow control parameter",
7490 (void *)&cmd_lfc_set_set,
7491 (void *)&cmd_lfc_set_flow_ctrl,
7492 (void *)&cmd_lfc_set_send_xon_str,
7493 (void *)&cmd_lfc_set_send_xon,
7494 (void *)&cmd_lfc_set_portid,
7499 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7500 .f = cmd_link_flow_ctrl_set_parsed,
7501 .data = (void *)&cmd_link_flow_control_set_macfwd,
7502 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7503 "Change mac ctrl fwd flow control parameter",
7505 (void *)&cmd_lfc_set_set,
7506 (void *)&cmd_lfc_set_flow_ctrl,
7507 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7508 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7509 (void *)&cmd_lfc_set_portid,
7514 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7515 .f = cmd_link_flow_ctrl_set_parsed,
7516 .data = (void *)&cmd_link_flow_control_set_autoneg,
7517 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7518 "Change autoneg flow control parameter",
7520 (void *)&cmd_lfc_set_set,
7521 (void *)&cmd_lfc_set_flow_ctrl,
7522 (void *)&cmd_lfc_set_autoneg_str,
7523 (void *)&cmd_lfc_set_autoneg,
7524 (void *)&cmd_lfc_set_portid,
7530 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7531 __rte_unused struct cmdline *cl,
7534 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7535 cmdline_parse_inst_t *cmd = data;
7536 struct rte_eth_fc_conf fc_conf;
7542 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7543 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7544 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7545 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7547 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7548 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7551 /* Partial command line, retrieve current configuration */
7553 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7556 "cannot get current flow ctrl parameters, return code = %d\n",
7561 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7562 (fc_conf.mode == RTE_ETH_FC_FULL))
7564 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7565 (fc_conf.mode == RTE_ETH_FC_FULL))
7569 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7570 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7572 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7573 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7575 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7577 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7578 fc_conf.high_water = res->high_water;
7580 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7581 fc_conf.low_water = res->low_water;
7583 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7584 fc_conf.pause_time = res->pause_time;
7586 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7587 fc_conf.send_xon = res->send_xon;
7589 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7590 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7591 fc_conf.mac_ctrl_frame_fwd = 1;
7593 fc_conf.mac_ctrl_frame_fwd = 0;
7596 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7597 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7599 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7602 "bad flow control parameter, return code = %d\n",
7606 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7607 struct cmd_priority_flow_ctrl_set_result {
7608 cmdline_fixed_string_t set;
7609 cmdline_fixed_string_t pfc_ctrl;
7610 cmdline_fixed_string_t rx;
7611 cmdline_fixed_string_t rx_pfc_mode;
7612 cmdline_fixed_string_t tx;
7613 cmdline_fixed_string_t tx_pfc_mode;
7614 uint32_t high_water;
7616 uint16_t pause_time;
7622 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7623 __rte_unused struct cmdline *cl,
7624 __rte_unused void *data)
7626 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7627 struct rte_eth_pfc_conf pfc_conf;
7628 int rx_fc_enable, tx_fc_enable;
7632 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7633 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7634 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7635 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7637 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7638 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7641 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7642 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7643 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7644 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7645 pfc_conf.fc.high_water = res->high_water;
7646 pfc_conf.fc.low_water = res->low_water;
7647 pfc_conf.fc.pause_time = res->pause_time;
7648 pfc_conf.priority = res->priority;
7650 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7653 "bad priority flow control parameter, return code = %d\n",
7657 cmdline_parse_token_string_t cmd_pfc_set_set =
7658 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7660 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7661 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7662 pfc_ctrl, "pfc_ctrl");
7663 cmdline_parse_token_string_t cmd_pfc_set_rx =
7664 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7666 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7667 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7668 rx_pfc_mode, "on#off");
7669 cmdline_parse_token_string_t cmd_pfc_set_tx =
7670 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7672 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7673 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7674 tx_pfc_mode, "on#off");
7675 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7676 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7677 high_water, RTE_UINT32);
7678 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7679 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7680 low_water, RTE_UINT32);
7681 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7682 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7683 pause_time, RTE_UINT16);
7684 cmdline_parse_token_num_t cmd_pfc_set_priority =
7685 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7686 priority, RTE_UINT8);
7687 cmdline_parse_token_num_t cmd_pfc_set_portid =
7688 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7689 port_id, RTE_UINT16);
7691 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7692 .f = cmd_priority_flow_ctrl_set_parsed,
7694 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7695 "<pause_time> <priority> <port_id>: "
7696 "Configure the Ethernet priority flow control",
7698 (void *)&cmd_pfc_set_set,
7699 (void *)&cmd_pfc_set_flow_ctrl,
7700 (void *)&cmd_pfc_set_rx,
7701 (void *)&cmd_pfc_set_rx_mode,
7702 (void *)&cmd_pfc_set_tx,
7703 (void *)&cmd_pfc_set_tx_mode,
7704 (void *)&cmd_pfc_set_high_water,
7705 (void *)&cmd_pfc_set_low_water,
7706 (void *)&cmd_pfc_set_pause_time,
7707 (void *)&cmd_pfc_set_priority,
7708 (void *)&cmd_pfc_set_portid,
7713 struct cmd_queue_priority_flow_ctrl_set_result {
7714 cmdline_fixed_string_t set;
7715 cmdline_fixed_string_t pfc_queue_ctrl;
7717 cmdline_fixed_string_t rx;
7718 cmdline_fixed_string_t rx_pfc_mode;
7721 cmdline_fixed_string_t tx;
7722 cmdline_fixed_string_t tx_pfc_mode;
7725 uint16_t pause_time;
7729 cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7730 __rte_unused struct cmdline *cl,
7731 __rte_unused void *data)
7733 struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7734 struct rte_eth_pfc_queue_conf pfc_queue_conf;
7735 int rx_fc_enable, tx_fc_enable;
7739 * Rx on/off, flow control is enabled/disabled on RX side. This can
7740 * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7741 * side. Tx on/off, flow control is enabled/disabled on TX side. This
7742 * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7745 static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7746 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7747 {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7750 memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7751 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7752 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7753 pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7754 pfc_queue_conf.rx_pause.tc = res->tx_tc;
7755 pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7756 pfc_queue_conf.tx_pause.tc = res->rx_tc;
7757 pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7758 pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7760 ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7764 "bad queue priority flow control parameter, rc = %d\n",
7769 cmdline_parse_token_string_t cmd_q_pfc_set_set =
7770 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7772 cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7773 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7774 pfc_queue_ctrl, "pfc_queue_ctrl");
7775 cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7776 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7777 port_id, RTE_UINT16);
7778 cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7779 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7781 cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7782 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7783 rx_pfc_mode, "on#off");
7784 cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7785 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7786 tx_qid, RTE_UINT16);
7787 cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7788 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7790 cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7791 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7793 cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7794 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7795 tx_pfc_mode, "on#off");
7796 cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7797 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7798 rx_qid, RTE_UINT16);
7799 cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7800 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7802 cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7803 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7804 pause_time, RTE_UINT16);
7806 cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7807 .f = cmd_queue_priority_flow_ctrl_set_parsed,
7809 .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7810 "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7811 "Configure the Ethernet queue priority flow control",
7813 (void *)&cmd_q_pfc_set_set,
7814 (void *)&cmd_q_pfc_set_flow_ctrl,
7815 (void *)&cmd_q_pfc_set_portid,
7816 (void *)&cmd_q_pfc_set_rx,
7817 (void *)&cmd_q_pfc_set_rx_mode,
7818 (void *)&cmd_q_pfc_set_tx_qid,
7819 (void *)&cmd_q_pfc_set_tx_tc,
7820 (void *)&cmd_q_pfc_set_tx,
7821 (void *)&cmd_q_pfc_set_tx_mode,
7822 (void *)&cmd_q_pfc_set_rx_qid,
7823 (void *)&cmd_q_pfc_set_rx_tc,
7824 (void *)&cmd_q_pfc_set_pause_time,
7829 /* *** RESET CONFIGURATION *** */
7830 struct cmd_reset_result {
7831 cmdline_fixed_string_t reset;
7832 cmdline_fixed_string_t def;
7835 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7837 __rte_unused void *data)
7839 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7840 set_def_fwd_config();
7843 cmdline_parse_token_string_t cmd_reset_set =
7844 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7845 cmdline_parse_token_string_t cmd_reset_def =
7846 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7849 cmdline_parse_inst_t cmd_reset = {
7850 .f = cmd_reset_parsed,
7852 .help_str = "set default: Reset default forwarding configuration",
7854 (void *)&cmd_reset_set,
7855 (void *)&cmd_reset_def,
7860 /* *** START FORWARDING *** */
7861 struct cmd_start_result {
7862 cmdline_fixed_string_t start;
7865 cmdline_parse_token_string_t cmd_start_start =
7866 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7868 static void cmd_start_parsed(__rte_unused void *parsed_result,
7869 __rte_unused struct cmdline *cl,
7870 __rte_unused void *data)
7872 start_packet_forwarding(0);
7875 cmdline_parse_inst_t cmd_start = {
7876 .f = cmd_start_parsed,
7878 .help_str = "start: Start packet forwarding",
7880 (void *)&cmd_start_start,
7885 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7886 struct cmd_start_tx_first_result {
7887 cmdline_fixed_string_t start;
7888 cmdline_fixed_string_t tx_first;
7892 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7893 __rte_unused struct cmdline *cl,
7894 __rte_unused void *data)
7896 start_packet_forwarding(1);
7899 cmdline_parse_token_string_t cmd_start_tx_first_start =
7900 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7902 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7903 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7904 tx_first, "tx_first");
7906 cmdline_parse_inst_t cmd_start_tx_first = {
7907 .f = cmd_start_tx_first_parsed,
7909 .help_str = "start tx_first: Start packet forwarding, "
7910 "after sending 1 burst of packets",
7912 (void *)&cmd_start_tx_first_start,
7913 (void *)&cmd_start_tx_first_tx_first,
7918 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7919 struct cmd_start_tx_first_n_result {
7920 cmdline_fixed_string_t start;
7921 cmdline_fixed_string_t tx_first;
7926 cmd_start_tx_first_n_parsed(void *parsed_result,
7927 __rte_unused struct cmdline *cl,
7928 __rte_unused void *data)
7930 struct cmd_start_tx_first_n_result *res = parsed_result;
7932 start_packet_forwarding(res->tx_num);
7935 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7936 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7938 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7939 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7940 tx_first, "tx_first");
7941 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7942 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7943 tx_num, RTE_UINT32);
7945 cmdline_parse_inst_t cmd_start_tx_first_n = {
7946 .f = cmd_start_tx_first_n_parsed,
7948 .help_str = "start tx_first <num>: "
7949 "packet forwarding, after sending <num> bursts of packets",
7951 (void *)&cmd_start_tx_first_n_start,
7952 (void *)&cmd_start_tx_first_n_tx_first,
7953 (void *)&cmd_start_tx_first_n_tx_num,
7958 /* *** SET LINK UP *** */
7959 struct cmd_set_link_up_result {
7960 cmdline_fixed_string_t set;
7961 cmdline_fixed_string_t link_up;
7962 cmdline_fixed_string_t port;
7966 cmdline_parse_token_string_t cmd_set_link_up_set =
7967 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7968 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7969 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7971 cmdline_parse_token_string_t cmd_set_link_up_port =
7972 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7973 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7974 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7977 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7978 __rte_unused struct cmdline *cl,
7979 __rte_unused void *data)
7981 struct cmd_set_link_up_result *res = parsed_result;
7982 dev_set_link_up(res->port_id);
7985 cmdline_parse_inst_t cmd_set_link_up = {
7986 .f = cmd_set_link_up_parsed,
7988 .help_str = "set link-up port <port id>",
7990 (void *)&cmd_set_link_up_set,
7991 (void *)&cmd_set_link_up_link_up,
7992 (void *)&cmd_set_link_up_port,
7993 (void *)&cmd_set_link_up_port_id,
7998 /* *** SET LINK DOWN *** */
7999 struct cmd_set_link_down_result {
8000 cmdline_fixed_string_t set;
8001 cmdline_fixed_string_t link_down;
8002 cmdline_fixed_string_t port;
8006 cmdline_parse_token_string_t cmd_set_link_down_set =
8007 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
8008 cmdline_parse_token_string_t cmd_set_link_down_link_down =
8009 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
8011 cmdline_parse_token_string_t cmd_set_link_down_port =
8012 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
8013 cmdline_parse_token_num_t cmd_set_link_down_port_id =
8014 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
8017 static void cmd_set_link_down_parsed(
8018 __rte_unused void *parsed_result,
8019 __rte_unused struct cmdline *cl,
8020 __rte_unused void *data)
8022 struct cmd_set_link_down_result *res = parsed_result;
8023 dev_set_link_down(res->port_id);
8026 cmdline_parse_inst_t cmd_set_link_down = {
8027 .f = cmd_set_link_down_parsed,
8029 .help_str = "set link-down port <port id>",
8031 (void *)&cmd_set_link_down_set,
8032 (void *)&cmd_set_link_down_link_down,
8033 (void *)&cmd_set_link_down_port,
8034 (void *)&cmd_set_link_down_port_id,
8039 /* *** SHOW CFG *** */
8040 struct cmd_showcfg_result {
8041 cmdline_fixed_string_t show;
8042 cmdline_fixed_string_t cfg;
8043 cmdline_fixed_string_t what;
8046 static void cmd_showcfg_parsed(void *parsed_result,
8047 __rte_unused struct cmdline *cl,
8048 __rte_unused void *data)
8050 struct cmd_showcfg_result *res = parsed_result;
8051 if (!strcmp(res->what, "rxtx"))
8052 rxtx_config_display();
8053 else if (!strcmp(res->what, "cores"))
8054 fwd_lcores_config_display();
8055 else if (!strcmp(res->what, "fwd"))
8056 pkt_fwd_config_display(&cur_fwd_config);
8057 else if (!strcmp(res->what, "rxoffs"))
8058 show_rx_pkt_offsets();
8059 else if (!strcmp(res->what, "rxpkts"))
8060 show_rx_pkt_segments();
8061 else if (!strcmp(res->what, "txpkts"))
8062 show_tx_pkt_segments();
8063 else if (!strcmp(res->what, "txtimes"))
8064 show_tx_pkt_times();
8067 cmdline_parse_token_string_t cmd_showcfg_show =
8068 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
8069 cmdline_parse_token_string_t cmd_showcfg_port =
8070 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
8071 cmdline_parse_token_string_t cmd_showcfg_what =
8072 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
8073 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
8075 cmdline_parse_inst_t cmd_showcfg = {
8076 .f = cmd_showcfg_parsed,
8078 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
8080 (void *)&cmd_showcfg_show,
8081 (void *)&cmd_showcfg_port,
8082 (void *)&cmd_showcfg_what,
8087 /* *** SHOW ALL PORT INFO *** */
8088 struct cmd_showportall_result {
8089 cmdline_fixed_string_t show;
8090 cmdline_fixed_string_t port;
8091 cmdline_fixed_string_t what;
8092 cmdline_fixed_string_t all;
8095 static void cmd_showportall_parsed(void *parsed_result,
8096 __rte_unused struct cmdline *cl,
8097 __rte_unused void *data)
8101 struct cmd_showportall_result *res = parsed_result;
8102 if (!strcmp(res->show, "clear")) {
8103 if (!strcmp(res->what, "stats"))
8104 RTE_ETH_FOREACH_DEV(i)
8106 else if (!strcmp(res->what, "xstats"))
8107 RTE_ETH_FOREACH_DEV(i)
8108 nic_xstats_clear(i);
8109 } else if (!strcmp(res->what, "info"))
8110 RTE_ETH_FOREACH_DEV(i)
8111 port_infos_display(i);
8112 else if (!strcmp(res->what, "summary")) {
8113 port_summary_header_display();
8114 RTE_ETH_FOREACH_DEV(i)
8115 port_summary_display(i);
8117 else if (!strcmp(res->what, "stats"))
8118 RTE_ETH_FOREACH_DEV(i)
8119 nic_stats_display(i);
8120 else if (!strcmp(res->what, "xstats"))
8121 RTE_ETH_FOREACH_DEV(i)
8122 nic_xstats_display(i);
8123 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8124 else if (!strcmp(res->what, "fdir"))
8125 RTE_ETH_FOREACH_DEV(i)
8128 else if (!strcmp(res->what, "dcb_tc"))
8129 RTE_ETH_FOREACH_DEV(i)
8130 port_dcb_info_display(i);
8133 cmdline_parse_token_string_t cmd_showportall_show =
8134 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
8136 cmdline_parse_token_string_t cmd_showportall_port =
8137 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8138 cmdline_parse_token_string_t cmd_showportall_what =
8139 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8140 "info#summary#stats#xstats#fdir#dcb_tc");
8141 cmdline_parse_token_string_t cmd_showportall_all =
8142 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8143 cmdline_parse_inst_t cmd_showportall = {
8144 .f = cmd_showportall_parsed,
8146 .help_str = "show|clear port "
8147 "info|summary|stats|xstats|fdir|dcb_tc all",
8149 (void *)&cmd_showportall_show,
8150 (void *)&cmd_showportall_port,
8151 (void *)&cmd_showportall_what,
8152 (void *)&cmd_showportall_all,
8157 /* *** SHOW PORT INFO *** */
8158 struct cmd_showport_result {
8159 cmdline_fixed_string_t show;
8160 cmdline_fixed_string_t port;
8161 cmdline_fixed_string_t what;
8165 static void cmd_showport_parsed(void *parsed_result,
8166 __rte_unused struct cmdline *cl,
8167 __rte_unused void *data)
8169 struct cmd_showport_result *res = parsed_result;
8170 if (!strcmp(res->show, "clear")) {
8171 if (!strcmp(res->what, "stats"))
8172 nic_stats_clear(res->portnum);
8173 else if (!strcmp(res->what, "xstats"))
8174 nic_xstats_clear(res->portnum);
8175 } else if (!strcmp(res->what, "info"))
8176 port_infos_display(res->portnum);
8177 else if (!strcmp(res->what, "summary")) {
8178 port_summary_header_display();
8179 port_summary_display(res->portnum);
8181 else if (!strcmp(res->what, "stats"))
8182 nic_stats_display(res->portnum);
8183 else if (!strcmp(res->what, "xstats"))
8184 nic_xstats_display(res->portnum);
8185 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8186 else if (!strcmp(res->what, "fdir"))
8187 fdir_get_infos(res->portnum);
8189 else if (!strcmp(res->what, "dcb_tc"))
8190 port_dcb_info_display(res->portnum);
8193 cmdline_parse_token_string_t cmd_showport_show =
8194 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8196 cmdline_parse_token_string_t cmd_showport_port =
8197 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8198 cmdline_parse_token_string_t cmd_showport_what =
8199 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8200 "info#summary#stats#xstats#fdir#dcb_tc");
8201 cmdline_parse_token_num_t cmd_showport_portnum =
8202 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8204 cmdline_parse_inst_t cmd_showport = {
8205 .f = cmd_showport_parsed,
8207 .help_str = "show|clear port "
8208 "info|summary|stats|xstats|fdir|dcb_tc "
8211 (void *)&cmd_showport_show,
8212 (void *)&cmd_showport_port,
8213 (void *)&cmd_showport_what,
8214 (void *)&cmd_showport_portnum,
8219 /* *** show port representors information *** */
8220 struct cmd_representor_info_result {
8221 cmdline_fixed_string_t cmd_show;
8222 cmdline_fixed_string_t cmd_port;
8223 cmdline_fixed_string_t cmd_info;
8224 cmdline_fixed_string_t cmd_keyword;
8229 cmd_representor_info_parsed(void *parsed_result,
8230 __rte_unused struct cmdline *cl,
8231 __rte_unused void *data)
8233 struct cmd_representor_info_result *res = parsed_result;
8234 struct rte_eth_representor_info *info;
8235 struct rte_eth_representor_range *range;
8236 uint32_t range_diff;
8241 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8242 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8246 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8249 "Failed to get the number of representor info ranges for port %hu: %s\n",
8250 res->cmd_pid, rte_strerror(-ret));
8255 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8258 "Failed to allocate memory for representor info for port %hu\n",
8262 info->nb_ranges_alloc = num;
8264 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8267 "Failed to get the representor info for port %hu: %s\n",
8268 res->cmd_pid, rte_strerror(-ret));
8273 printf("Port controller: %hu\n", info->controller);
8274 printf("Port PF: %hu\n", info->pf);
8276 printf("Ranges: %u\n", info->nb_ranges);
8277 for (i = 0; i < info->nb_ranges; i++) {
8278 range = &info->ranges[i];
8279 range_diff = range->id_end - range->id_base;
8281 printf("%u. ", i + 1);
8282 printf("'%s' ", range->name);
8284 printf("[%u-%u]: ", range->id_base, range->id_end);
8286 printf("[%u]: ", range->id_base);
8288 printf("Controller %d, PF %d", range->controller, range->pf);
8290 switch (range->type) {
8291 case RTE_ETH_REPRESENTOR_NONE:
8294 case RTE_ETH_REPRESENTOR_VF:
8296 printf(", VF %d..%d\n", range->vf,
8297 range->vf + range_diff);
8299 printf(", VF %d\n", range->vf);
8301 case RTE_ETH_REPRESENTOR_SF:
8302 printf(", SF %d\n", range->sf);
8304 case RTE_ETH_REPRESENTOR_PF:
8306 printf("..%d\n", range->pf + range_diff);
8311 printf(", UNKNOWN TYPE %d\n", range->type);
8319 cmdline_parse_token_string_t cmd_representor_info_show =
8320 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8322 cmdline_parse_token_string_t cmd_representor_info_port =
8323 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8325 cmdline_parse_token_string_t cmd_representor_info_info =
8326 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8328 cmdline_parse_token_num_t cmd_representor_info_pid =
8329 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8330 cmd_pid, RTE_UINT16);
8331 cmdline_parse_token_string_t cmd_representor_info_keyword =
8332 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8333 cmd_keyword, "representor");
8335 cmdline_parse_inst_t cmd_representor_info = {
8336 .f = cmd_representor_info_parsed,
8338 .help_str = "show port info <port_id> representor",
8340 (void *)&cmd_representor_info_show,
8341 (void *)&cmd_representor_info_port,
8342 (void *)&cmd_representor_info_info,
8343 (void *)&cmd_representor_info_pid,
8344 (void *)&cmd_representor_info_keyword,
8350 /* *** SHOW DEVICE INFO *** */
8351 struct cmd_showdevice_result {
8352 cmdline_fixed_string_t show;
8353 cmdline_fixed_string_t device;
8354 cmdline_fixed_string_t what;
8355 cmdline_fixed_string_t identifier;
8358 static void cmd_showdevice_parsed(void *parsed_result,
8359 __rte_unused struct cmdline *cl,
8360 __rte_unused void *data)
8362 struct cmd_showdevice_result *res = parsed_result;
8363 if (!strcmp(res->what, "info")) {
8364 if (!strcmp(res->identifier, "all"))
8365 device_infos_display(NULL);
8367 device_infos_display(res->identifier);
8371 cmdline_parse_token_string_t cmd_showdevice_show =
8372 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8374 cmdline_parse_token_string_t cmd_showdevice_device =
8375 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8376 cmdline_parse_token_string_t cmd_showdevice_what =
8377 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8379 cmdline_parse_token_string_t cmd_showdevice_identifier =
8380 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8383 cmdline_parse_inst_t cmd_showdevice = {
8384 .f = cmd_showdevice_parsed,
8386 .help_str = "show device info <identifier>|all",
8388 (void *)&cmd_showdevice_show,
8389 (void *)&cmd_showdevice_device,
8390 (void *)&cmd_showdevice_what,
8391 (void *)&cmd_showdevice_identifier,
8396 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8397 struct cmd_showeeprom_result {
8398 cmdline_fixed_string_t show;
8399 cmdline_fixed_string_t port;
8401 cmdline_fixed_string_t type;
8404 static void cmd_showeeprom_parsed(void *parsed_result,
8405 __rte_unused struct cmdline *cl,
8406 __rte_unused void *data)
8408 struct cmd_showeeprom_result *res = parsed_result;
8410 if (!strcmp(res->type, "eeprom"))
8411 port_eeprom_display(res->portnum);
8412 else if (!strcmp(res->type, "module_eeprom"))
8413 port_module_eeprom_display(res->portnum);
8415 fprintf(stderr, "Unknown argument\n");
8418 cmdline_parse_token_string_t cmd_showeeprom_show =
8419 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8420 cmdline_parse_token_string_t cmd_showeeprom_port =
8421 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8422 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8423 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8425 cmdline_parse_token_string_t cmd_showeeprom_type =
8426 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8428 cmdline_parse_inst_t cmd_showeeprom = {
8429 .f = cmd_showeeprom_parsed,
8431 .help_str = "show port <port_id> module_eeprom|eeprom",
8433 (void *)&cmd_showeeprom_show,
8434 (void *)&cmd_showeeprom_port,
8435 (void *)&cmd_showeeprom_portnum,
8436 (void *)&cmd_showeeprom_type,
8441 /* *** SHOW QUEUE INFO *** */
8442 struct cmd_showqueue_result {
8443 cmdline_fixed_string_t show;
8444 cmdline_fixed_string_t type;
8445 cmdline_fixed_string_t what;
8451 cmd_showqueue_parsed(void *parsed_result,
8452 __rte_unused struct cmdline *cl,
8453 __rte_unused void *data)
8455 struct cmd_showqueue_result *res = parsed_result;
8457 if (!strcmp(res->type, "rxq"))
8458 rx_queue_infos_display(res->portnum, res->queuenum);
8459 else if (!strcmp(res->type, "txq"))
8460 tx_queue_infos_display(res->portnum, res->queuenum);
8463 cmdline_parse_token_string_t cmd_showqueue_show =
8464 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8465 cmdline_parse_token_string_t cmd_showqueue_type =
8466 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8467 cmdline_parse_token_string_t cmd_showqueue_what =
8468 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8469 cmdline_parse_token_num_t cmd_showqueue_portnum =
8470 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8472 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8473 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8476 cmdline_parse_inst_t cmd_showqueue = {
8477 .f = cmd_showqueue_parsed,
8479 .help_str = "show rxq|txq info <port_id> <queue_id>",
8481 (void *)&cmd_showqueue_show,
8482 (void *)&cmd_showqueue_type,
8483 (void *)&cmd_showqueue_what,
8484 (void *)&cmd_showqueue_portnum,
8485 (void *)&cmd_showqueue_queuenum,
8490 /* show/clear fwd engine statistics */
8492 cmdline_fixed_string_t action;
8493 cmdline_fixed_string_t fwd;
8494 cmdline_fixed_string_t stats;
8495 cmdline_fixed_string_t all;
8498 cmdline_parse_token_string_t cmd_fwd_action =
8499 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8500 cmdline_parse_token_string_t cmd_fwd_fwd =
8501 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8502 cmdline_parse_token_string_t cmd_fwd_stats =
8503 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8504 cmdline_parse_token_string_t cmd_fwd_all =
8505 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8508 cmd_showfwdall_parsed(void *parsed_result,
8509 __rte_unused struct cmdline *cl,
8510 __rte_unused void *data)
8512 struct fwd_result *res = parsed_result;
8514 if (!strcmp(res->action, "show"))
8515 fwd_stats_display();
8520 static cmdline_parse_inst_t cmd_showfwdall = {
8521 .f = cmd_showfwdall_parsed,
8523 .help_str = "show|clear fwd stats all",
8525 (void *)&cmd_fwd_action,
8526 (void *)&cmd_fwd_fwd,
8527 (void *)&cmd_fwd_stats,
8528 (void *)&cmd_fwd_all,
8533 /* *** READ PORT REGISTER *** */
8534 struct cmd_read_reg_result {
8535 cmdline_fixed_string_t read;
8536 cmdline_fixed_string_t reg;
8542 cmd_read_reg_parsed(void *parsed_result,
8543 __rte_unused struct cmdline *cl,
8544 __rte_unused void *data)
8546 struct cmd_read_reg_result *res = parsed_result;
8547 port_reg_display(res->port_id, res->reg_off);
8550 cmdline_parse_token_string_t cmd_read_reg_read =
8551 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8552 cmdline_parse_token_string_t cmd_read_reg_reg =
8553 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8554 cmdline_parse_token_num_t cmd_read_reg_port_id =
8555 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8556 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8557 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8559 cmdline_parse_inst_t cmd_read_reg = {
8560 .f = cmd_read_reg_parsed,
8562 .help_str = "read reg <port_id> <reg_off>",
8564 (void *)&cmd_read_reg_read,
8565 (void *)&cmd_read_reg_reg,
8566 (void *)&cmd_read_reg_port_id,
8567 (void *)&cmd_read_reg_reg_off,
8572 /* *** READ PORT REGISTER BIT FIELD *** */
8573 struct cmd_read_reg_bit_field_result {
8574 cmdline_fixed_string_t read;
8575 cmdline_fixed_string_t regfield;
8583 cmd_read_reg_bit_field_parsed(void *parsed_result,
8584 __rte_unused struct cmdline *cl,
8585 __rte_unused void *data)
8587 struct cmd_read_reg_bit_field_result *res = parsed_result;
8588 port_reg_bit_field_display(res->port_id, res->reg_off,
8589 res->bit1_pos, res->bit2_pos);
8592 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8593 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8595 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8596 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8597 regfield, "regfield");
8598 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8599 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8601 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8602 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8604 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8605 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8607 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8608 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8611 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8612 .f = cmd_read_reg_bit_field_parsed,
8614 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8615 "Read register bit field between bit_x and bit_y included",
8617 (void *)&cmd_read_reg_bit_field_read,
8618 (void *)&cmd_read_reg_bit_field_regfield,
8619 (void *)&cmd_read_reg_bit_field_port_id,
8620 (void *)&cmd_read_reg_bit_field_reg_off,
8621 (void *)&cmd_read_reg_bit_field_bit1_pos,
8622 (void *)&cmd_read_reg_bit_field_bit2_pos,
8627 /* *** READ PORT REGISTER BIT *** */
8628 struct cmd_read_reg_bit_result {
8629 cmdline_fixed_string_t read;
8630 cmdline_fixed_string_t regbit;
8637 cmd_read_reg_bit_parsed(void *parsed_result,
8638 __rte_unused struct cmdline *cl,
8639 __rte_unused void *data)
8641 struct cmd_read_reg_bit_result *res = parsed_result;
8642 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8645 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8646 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8647 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8648 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8650 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8651 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8653 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8654 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8656 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8657 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8660 cmdline_parse_inst_t cmd_read_reg_bit = {
8661 .f = cmd_read_reg_bit_parsed,
8663 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8665 (void *)&cmd_read_reg_bit_read,
8666 (void *)&cmd_read_reg_bit_regbit,
8667 (void *)&cmd_read_reg_bit_port_id,
8668 (void *)&cmd_read_reg_bit_reg_off,
8669 (void *)&cmd_read_reg_bit_bit_pos,
8674 /* *** WRITE PORT REGISTER *** */
8675 struct cmd_write_reg_result {
8676 cmdline_fixed_string_t write;
8677 cmdline_fixed_string_t reg;
8684 cmd_write_reg_parsed(void *parsed_result,
8685 __rte_unused struct cmdline *cl,
8686 __rte_unused void *data)
8688 struct cmd_write_reg_result *res = parsed_result;
8689 port_reg_set(res->port_id, res->reg_off, res->value);
8692 cmdline_parse_token_string_t cmd_write_reg_write =
8693 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8694 cmdline_parse_token_string_t cmd_write_reg_reg =
8695 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8696 cmdline_parse_token_num_t cmd_write_reg_port_id =
8697 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8698 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8699 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8700 cmdline_parse_token_num_t cmd_write_reg_value =
8701 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8703 cmdline_parse_inst_t cmd_write_reg = {
8704 .f = cmd_write_reg_parsed,
8706 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8708 (void *)&cmd_write_reg_write,
8709 (void *)&cmd_write_reg_reg,
8710 (void *)&cmd_write_reg_port_id,
8711 (void *)&cmd_write_reg_reg_off,
8712 (void *)&cmd_write_reg_value,
8717 /* *** WRITE PORT REGISTER BIT FIELD *** */
8718 struct cmd_write_reg_bit_field_result {
8719 cmdline_fixed_string_t write;
8720 cmdline_fixed_string_t regfield;
8729 cmd_write_reg_bit_field_parsed(void *parsed_result,
8730 __rte_unused struct cmdline *cl,
8731 __rte_unused void *data)
8733 struct cmd_write_reg_bit_field_result *res = parsed_result;
8734 port_reg_bit_field_set(res->port_id, res->reg_off,
8735 res->bit1_pos, res->bit2_pos, res->value);
8738 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8739 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8741 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8742 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8743 regfield, "regfield");
8744 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8745 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8747 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8748 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8750 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8751 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8753 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8754 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8756 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8757 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8760 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8761 .f = cmd_write_reg_bit_field_parsed,
8763 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8765 "Set register bit field between bit_x and bit_y included",
8767 (void *)&cmd_write_reg_bit_field_write,
8768 (void *)&cmd_write_reg_bit_field_regfield,
8769 (void *)&cmd_write_reg_bit_field_port_id,
8770 (void *)&cmd_write_reg_bit_field_reg_off,
8771 (void *)&cmd_write_reg_bit_field_bit1_pos,
8772 (void *)&cmd_write_reg_bit_field_bit2_pos,
8773 (void *)&cmd_write_reg_bit_field_value,
8778 /* *** WRITE PORT REGISTER BIT *** */
8779 struct cmd_write_reg_bit_result {
8780 cmdline_fixed_string_t write;
8781 cmdline_fixed_string_t regbit;
8789 cmd_write_reg_bit_parsed(void *parsed_result,
8790 __rte_unused struct cmdline *cl,
8791 __rte_unused void *data)
8793 struct cmd_write_reg_bit_result *res = parsed_result;
8794 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8797 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8798 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8800 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8801 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8803 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8804 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8806 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8807 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8809 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8810 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8812 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8813 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8816 cmdline_parse_inst_t cmd_write_reg_bit = {
8817 .f = cmd_write_reg_bit_parsed,
8819 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8822 (void *)&cmd_write_reg_bit_write,
8823 (void *)&cmd_write_reg_bit_regbit,
8824 (void *)&cmd_write_reg_bit_port_id,
8825 (void *)&cmd_write_reg_bit_reg_off,
8826 (void *)&cmd_write_reg_bit_bit_pos,
8827 (void *)&cmd_write_reg_bit_value,
8832 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8833 struct cmd_read_rxd_txd_result {
8834 cmdline_fixed_string_t read;
8835 cmdline_fixed_string_t rxd_txd;
8842 cmd_read_rxd_txd_parsed(void *parsed_result,
8843 __rte_unused struct cmdline *cl,
8844 __rte_unused void *data)
8846 struct cmd_read_rxd_txd_result *res = parsed_result;
8848 if (!strcmp(res->rxd_txd, "rxd"))
8849 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8850 else if (!strcmp(res->rxd_txd, "txd"))
8851 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8854 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8855 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8856 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8857 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8859 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8860 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8862 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8863 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8865 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8866 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8869 cmdline_parse_inst_t cmd_read_rxd_txd = {
8870 .f = cmd_read_rxd_txd_parsed,
8872 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8874 (void *)&cmd_read_rxd_txd_read,
8875 (void *)&cmd_read_rxd_txd_rxd_txd,
8876 (void *)&cmd_read_rxd_txd_port_id,
8877 (void *)&cmd_read_rxd_txd_queue_id,
8878 (void *)&cmd_read_rxd_txd_desc_id,
8884 struct cmd_quit_result {
8885 cmdline_fixed_string_t quit;
8888 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8890 __rte_unused void *data)
8895 cmdline_parse_token_string_t cmd_quit_quit =
8896 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8898 cmdline_parse_inst_t cmd_quit = {
8899 .f = cmd_quit_parsed,
8901 .help_str = "quit: Exit application",
8903 (void *)&cmd_quit_quit,
8908 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8909 struct cmd_mac_addr_result {
8910 cmdline_fixed_string_t mac_addr_cmd;
8911 cmdline_fixed_string_t what;
8913 struct rte_ether_addr address;
8916 static void cmd_mac_addr_parsed(void *parsed_result,
8917 __rte_unused struct cmdline *cl,
8918 __rte_unused void *data)
8920 struct cmd_mac_addr_result *res = parsed_result;
8923 if (strcmp(res->what, "add") == 0)
8924 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8925 else if (strcmp(res->what, "set") == 0)
8926 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8929 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8931 /* check the return value and print it if is < 0 */
8933 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8937 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8938 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8940 cmdline_parse_token_string_t cmd_mac_addr_what =
8941 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8943 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8944 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8946 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8947 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8949 cmdline_parse_inst_t cmd_mac_addr = {
8950 .f = cmd_mac_addr_parsed,
8952 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8953 "Add/Remove/Set MAC address on port_id",
8955 (void *)&cmd_mac_addr_cmd,
8956 (void *)&cmd_mac_addr_what,
8957 (void *)&cmd_mac_addr_portnum,
8958 (void *)&cmd_mac_addr_addr,
8963 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8964 struct cmd_eth_peer_result {
8965 cmdline_fixed_string_t set;
8966 cmdline_fixed_string_t eth_peer;
8968 cmdline_fixed_string_t peer_addr;
8971 static void cmd_set_eth_peer_parsed(void *parsed_result,
8972 __rte_unused struct cmdline *cl,
8973 __rte_unused void *data)
8975 struct cmd_eth_peer_result *res = parsed_result;
8977 if (test_done == 0) {
8978 fprintf(stderr, "Please stop forwarding first\n");
8981 if (!strcmp(res->eth_peer, "eth-peer")) {
8982 set_fwd_eth_peer(res->port_id, res->peer_addr);
8986 cmdline_parse_token_string_t cmd_eth_peer_set =
8987 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8988 cmdline_parse_token_string_t cmd_eth_peer =
8989 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8990 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8991 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8993 cmdline_parse_token_string_t cmd_eth_peer_addr =
8994 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8996 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8997 .f = cmd_set_eth_peer_parsed,
8999 .help_str = "set eth-peer <port_id> <peer_mac>",
9001 (void *)&cmd_eth_peer_set,
9002 (void *)&cmd_eth_peer,
9003 (void *)&cmd_eth_peer_port_id,
9004 (void *)&cmd_eth_peer_addr,
9009 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
9010 struct cmd_set_qmap_result {
9011 cmdline_fixed_string_t set;
9012 cmdline_fixed_string_t qmap;
9013 cmdline_fixed_string_t what;
9020 cmd_set_qmap_parsed(void *parsed_result,
9021 __rte_unused struct cmdline *cl,
9022 __rte_unused void *data)
9024 struct cmd_set_qmap_result *res = parsed_result;
9025 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
9027 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
9030 cmdline_parse_token_string_t cmd_setqmap_set =
9031 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9033 cmdline_parse_token_string_t cmd_setqmap_qmap =
9034 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9036 cmdline_parse_token_string_t cmd_setqmap_what =
9037 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9039 cmdline_parse_token_num_t cmd_setqmap_portid =
9040 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9041 port_id, RTE_UINT16);
9042 cmdline_parse_token_num_t cmd_setqmap_queueid =
9043 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9044 queue_id, RTE_UINT16);
9045 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
9046 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9047 map_value, RTE_UINT8);
9049 cmdline_parse_inst_t cmd_set_qmap = {
9050 .f = cmd_set_qmap_parsed,
9052 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
9053 "Set statistics mapping value on tx|rx queue_id of port_id",
9055 (void *)&cmd_setqmap_set,
9056 (void *)&cmd_setqmap_qmap,
9057 (void *)&cmd_setqmap_what,
9058 (void *)&cmd_setqmap_portid,
9059 (void *)&cmd_setqmap_queueid,
9060 (void *)&cmd_setqmap_mapvalue,
9065 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
9066 struct cmd_set_xstats_hide_zero_result {
9067 cmdline_fixed_string_t keyword;
9068 cmdline_fixed_string_t name;
9069 cmdline_fixed_string_t on_off;
9073 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
9074 __rte_unused struct cmdline *cl,
9075 __rte_unused void *data)
9077 struct cmd_set_xstats_hide_zero_result *res;
9078 uint16_t on_off = 0;
9080 res = parsed_result;
9081 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9082 set_xstats_hide_zero(on_off);
9085 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
9086 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9088 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
9089 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9090 name, "xstats-hide-zero");
9091 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
9092 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9095 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
9096 .f = cmd_set_xstats_hide_zero_parsed,
9098 .help_str = "set xstats-hide-zero on|off",
9100 (void *)&cmd_set_xstats_hide_zero_keyword,
9101 (void *)&cmd_set_xstats_hide_zero_name,
9102 (void *)&cmd_set_xstats_hide_zero_on_off,
9107 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
9108 struct cmd_set_record_core_cycles_result {
9109 cmdline_fixed_string_t keyword;
9110 cmdline_fixed_string_t name;
9111 cmdline_fixed_string_t on_off;
9115 cmd_set_record_core_cycles_parsed(void *parsed_result,
9116 __rte_unused struct cmdline *cl,
9117 __rte_unused void *data)
9119 struct cmd_set_record_core_cycles_result *res;
9120 uint16_t on_off = 0;
9122 res = parsed_result;
9123 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9124 set_record_core_cycles(on_off);
9127 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
9128 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9130 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
9131 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9132 name, "record-core-cycles");
9133 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
9134 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9137 cmdline_parse_inst_t cmd_set_record_core_cycles = {
9138 .f = cmd_set_record_core_cycles_parsed,
9140 .help_str = "set record-core-cycles on|off",
9142 (void *)&cmd_set_record_core_cycles_keyword,
9143 (void *)&cmd_set_record_core_cycles_name,
9144 (void *)&cmd_set_record_core_cycles_on_off,
9149 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9150 struct cmd_set_record_burst_stats_result {
9151 cmdline_fixed_string_t keyword;
9152 cmdline_fixed_string_t name;
9153 cmdline_fixed_string_t on_off;
9157 cmd_set_record_burst_stats_parsed(void *parsed_result,
9158 __rte_unused struct cmdline *cl,
9159 __rte_unused void *data)
9161 struct cmd_set_record_burst_stats_result *res;
9162 uint16_t on_off = 0;
9164 res = parsed_result;
9165 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9166 set_record_burst_stats(on_off);
9169 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9170 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9172 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9173 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9174 name, "record-burst-stats");
9175 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9176 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9179 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9180 .f = cmd_set_record_burst_stats_parsed,
9182 .help_str = "set record-burst-stats on|off",
9184 (void *)&cmd_set_record_burst_stats_keyword,
9185 (void *)&cmd_set_record_burst_stats_name,
9186 (void *)&cmd_set_record_burst_stats_on_off,
9191 /* *** CONFIGURE UNICAST HASH TABLE *** */
9192 struct cmd_set_uc_hash_table {
9193 cmdline_fixed_string_t set;
9194 cmdline_fixed_string_t port;
9196 cmdline_fixed_string_t what;
9197 struct rte_ether_addr address;
9198 cmdline_fixed_string_t mode;
9202 cmd_set_uc_hash_parsed(void *parsed_result,
9203 __rte_unused struct cmdline *cl,
9204 __rte_unused void *data)
9207 struct cmd_set_uc_hash_table *res = parsed_result;
9209 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9211 if (strcmp(res->what, "uta") == 0)
9212 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9213 &res->address,(uint8_t)is_on);
9216 "bad unicast hash table parameter, return code = %d\n",
9221 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9222 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9224 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9225 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9227 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9228 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9229 port_id, RTE_UINT16);
9230 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9231 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9233 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9234 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9236 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9237 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9240 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9241 .f = cmd_set_uc_hash_parsed,
9243 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9245 (void *)&cmd_set_uc_hash_set,
9246 (void *)&cmd_set_uc_hash_port,
9247 (void *)&cmd_set_uc_hash_portid,
9248 (void *)&cmd_set_uc_hash_what,
9249 (void *)&cmd_set_uc_hash_mac,
9250 (void *)&cmd_set_uc_hash_mode,
9255 struct cmd_set_uc_all_hash_table {
9256 cmdline_fixed_string_t set;
9257 cmdline_fixed_string_t port;
9259 cmdline_fixed_string_t what;
9260 cmdline_fixed_string_t value;
9261 cmdline_fixed_string_t mode;
9265 cmd_set_uc_all_hash_parsed(void *parsed_result,
9266 __rte_unused struct cmdline *cl,
9267 __rte_unused void *data)
9270 struct cmd_set_uc_all_hash_table *res = parsed_result;
9272 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9274 if ((strcmp(res->what, "uta") == 0) &&
9275 (strcmp(res->value, "all") == 0))
9276 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9279 "bad unicast hash table parameter, return code = %d\n",
9283 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9284 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9286 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9287 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9289 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9290 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9291 port_id, RTE_UINT16);
9292 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9293 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9295 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9296 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9298 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9299 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9302 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9303 .f = cmd_set_uc_all_hash_parsed,
9305 .help_str = "set port <port_id> uta all on|off",
9307 (void *)&cmd_set_uc_all_hash_set,
9308 (void *)&cmd_set_uc_all_hash_port,
9309 (void *)&cmd_set_uc_all_hash_portid,
9310 (void *)&cmd_set_uc_all_hash_what,
9311 (void *)&cmd_set_uc_all_hash_value,
9312 (void *)&cmd_set_uc_all_hash_mode,
9317 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9318 struct cmd_set_vf_traffic {
9319 cmdline_fixed_string_t set;
9320 cmdline_fixed_string_t port;
9322 cmdline_fixed_string_t vf;
9324 cmdline_fixed_string_t what;
9325 cmdline_fixed_string_t mode;
9329 cmd_set_vf_traffic_parsed(void *parsed_result,
9330 __rte_unused struct cmdline *cl,
9331 __rte_unused void *data)
9333 struct cmd_set_vf_traffic *res = parsed_result;
9334 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9335 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9337 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9340 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9341 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9343 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9344 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9346 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9347 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9348 port_id, RTE_UINT16);
9349 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9350 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9352 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9353 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9355 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9356 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9358 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9359 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9362 cmdline_parse_inst_t cmd_set_vf_traffic = {
9363 .f = cmd_set_vf_traffic_parsed,
9365 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9367 (void *)&cmd_setvf_traffic_set,
9368 (void *)&cmd_setvf_traffic_port,
9369 (void *)&cmd_setvf_traffic_portid,
9370 (void *)&cmd_setvf_traffic_vf,
9371 (void *)&cmd_setvf_traffic_vfid,
9372 (void *)&cmd_setvf_traffic_what,
9373 (void *)&cmd_setvf_traffic_mode,
9378 /* *** CONFIGURE VF RECEIVE MODE *** */
9379 struct cmd_set_vf_rxmode {
9380 cmdline_fixed_string_t set;
9381 cmdline_fixed_string_t port;
9383 cmdline_fixed_string_t vf;
9385 cmdline_fixed_string_t what;
9386 cmdline_fixed_string_t mode;
9387 cmdline_fixed_string_t on;
9391 cmd_set_vf_rxmode_parsed(void *parsed_result,
9392 __rte_unused struct cmdline *cl,
9393 __rte_unused void *data)
9396 uint16_t vf_rxmode = 0;
9397 struct cmd_set_vf_rxmode *res = parsed_result;
9399 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9400 if (!strcmp(res->what,"rxmode")) {
9401 if (!strcmp(res->mode, "AUPE"))
9402 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9403 else if (!strcmp(res->mode, "ROPE"))
9404 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9405 else if (!strcmp(res->mode, "BAM"))
9406 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9407 else if (!strncmp(res->mode, "MPE",3))
9408 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9411 RTE_SET_USED(is_on);
9413 #ifdef RTE_NET_IXGBE
9414 if (ret == -ENOTSUP)
9415 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9416 vf_rxmode, (uint8_t)is_on);
9419 if (ret == -ENOTSUP)
9420 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9421 vf_rxmode, (uint8_t)is_on);
9425 "bad VF receive mode parameter, return code = %d\n",
9429 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9430 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9432 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9433 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9435 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9436 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9437 port_id, RTE_UINT16);
9438 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9439 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9441 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9442 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9444 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9445 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9447 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9448 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9449 mode, "AUPE#ROPE#BAM#MPE");
9450 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9451 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9454 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9455 .f = cmd_set_vf_rxmode_parsed,
9457 .help_str = "set port <port_id> vf <vf_id> rxmode "
9458 "AUPE|ROPE|BAM|MPE on|off",
9460 (void *)&cmd_set_vf_rxmode_set,
9461 (void *)&cmd_set_vf_rxmode_port,
9462 (void *)&cmd_set_vf_rxmode_portid,
9463 (void *)&cmd_set_vf_rxmode_vf,
9464 (void *)&cmd_set_vf_rxmode_vfid,
9465 (void *)&cmd_set_vf_rxmode_what,
9466 (void *)&cmd_set_vf_rxmode_mode,
9467 (void *)&cmd_set_vf_rxmode_on,
9472 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9473 struct cmd_vf_mac_addr_result {
9474 cmdline_fixed_string_t mac_addr_cmd;
9475 cmdline_fixed_string_t what;
9476 cmdline_fixed_string_t port;
9478 cmdline_fixed_string_t vf;
9480 struct rte_ether_addr address;
9483 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9484 __rte_unused struct cmdline *cl,
9485 __rte_unused void *data)
9487 struct cmd_vf_mac_addr_result *res = parsed_result;
9490 if (strcmp(res->what, "add") != 0)
9494 if (ret == -ENOTSUP)
9495 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9499 if (ret == -ENOTSUP)
9500 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9505 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9509 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9510 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9511 mac_addr_cmd,"mac_addr");
9512 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9513 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9515 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9516 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9518 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9519 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9520 port_num, RTE_UINT16);
9521 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9522 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9524 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9525 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9527 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9528 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9531 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9532 .f = cmd_vf_mac_addr_parsed,
9534 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9535 "Add MAC address filtering for a VF on port_id",
9537 (void *)&cmd_vf_mac_addr_cmd,
9538 (void *)&cmd_vf_mac_addr_what,
9539 (void *)&cmd_vf_mac_addr_port,
9540 (void *)&cmd_vf_mac_addr_portnum,
9541 (void *)&cmd_vf_mac_addr_vf,
9542 (void *)&cmd_vf_mac_addr_vfnum,
9543 (void *)&cmd_vf_mac_addr_addr,
9548 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9549 struct cmd_vf_rx_vlan_filter {
9550 cmdline_fixed_string_t rx_vlan;
9551 cmdline_fixed_string_t what;
9553 cmdline_fixed_string_t port;
9555 cmdline_fixed_string_t vf;
9560 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9561 __rte_unused struct cmdline *cl,
9562 __rte_unused void *data)
9564 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9567 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9569 #ifdef RTE_NET_IXGBE
9570 if (ret == -ENOTSUP)
9571 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9572 res->vlan_id, res->vf_mask, is_add);
9575 if (ret == -ENOTSUP)
9576 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9577 res->vlan_id, res->vf_mask, is_add);
9580 if (ret == -ENOTSUP)
9581 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9582 res->vlan_id, res->vf_mask, is_add);
9589 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9590 res->vlan_id, res->vf_mask);
9593 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9596 fprintf(stderr, "function not implemented or supported\n");
9599 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9603 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9604 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9605 rx_vlan, "rx_vlan");
9606 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9607 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9609 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9610 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9611 vlan_id, RTE_UINT16);
9612 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9613 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9615 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9616 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9617 port_id, RTE_UINT16);
9618 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9619 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9621 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9622 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9623 vf_mask, RTE_UINT64);
9625 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9626 .f = cmd_vf_rx_vlan_filter_parsed,
9628 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9629 "(vf_mask = hexadecimal VF mask)",
9631 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9632 (void *)&cmd_vf_rx_vlan_filter_what,
9633 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9634 (void *)&cmd_vf_rx_vlan_filter_port,
9635 (void *)&cmd_vf_rx_vlan_filter_portid,
9636 (void *)&cmd_vf_rx_vlan_filter_vf,
9637 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9642 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9643 struct cmd_queue_rate_limit_result {
9644 cmdline_fixed_string_t set;
9645 cmdline_fixed_string_t port;
9647 cmdline_fixed_string_t queue;
9649 cmdline_fixed_string_t rate;
9653 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9654 __rte_unused struct cmdline *cl,
9655 __rte_unused void *data)
9657 struct cmd_queue_rate_limit_result *res = parsed_result;
9660 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9661 && (strcmp(res->queue, "queue") == 0)
9662 && (strcmp(res->rate, "rate") == 0))
9663 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9666 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9671 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9672 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9674 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9675 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9677 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9678 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9679 port_num, RTE_UINT16);
9680 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9681 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9683 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9684 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9685 queue_num, RTE_UINT8);
9686 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9687 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9689 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9690 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9691 rate_num, RTE_UINT16);
9693 cmdline_parse_inst_t cmd_queue_rate_limit = {
9694 .f = cmd_queue_rate_limit_parsed,
9696 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9697 "Set rate limit for a queue on port_id",
9699 (void *)&cmd_queue_rate_limit_set,
9700 (void *)&cmd_queue_rate_limit_port,
9701 (void *)&cmd_queue_rate_limit_portnum,
9702 (void *)&cmd_queue_rate_limit_queue,
9703 (void *)&cmd_queue_rate_limit_queuenum,
9704 (void *)&cmd_queue_rate_limit_rate,
9705 (void *)&cmd_queue_rate_limit_ratenum,
9710 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9711 struct cmd_vf_rate_limit_result {
9712 cmdline_fixed_string_t set;
9713 cmdline_fixed_string_t port;
9715 cmdline_fixed_string_t vf;
9717 cmdline_fixed_string_t rate;
9719 cmdline_fixed_string_t q_msk;
9723 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9724 __rte_unused struct cmdline *cl,
9725 __rte_unused void *data)
9727 struct cmd_vf_rate_limit_result *res = parsed_result;
9730 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9731 && (strcmp(res->vf, "vf") == 0)
9732 && (strcmp(res->rate, "rate") == 0)
9733 && (strcmp(res->q_msk, "queue_mask") == 0))
9734 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9735 res->rate_num, res->q_msk_val);
9737 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9742 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9743 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9745 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9746 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9748 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9749 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9750 port_num, RTE_UINT16);
9751 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9752 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9754 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9755 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9757 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9758 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9760 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9761 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9762 rate_num, RTE_UINT16);
9763 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9764 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9765 q_msk, "queue_mask");
9766 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9767 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9768 q_msk_val, RTE_UINT64);
9770 cmdline_parse_inst_t cmd_vf_rate_limit = {
9771 .f = cmd_vf_rate_limit_parsed,
9773 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9774 "queue_mask <queue_mask_value>: "
9775 "Set rate limit for queues of VF on port_id",
9777 (void *)&cmd_vf_rate_limit_set,
9778 (void *)&cmd_vf_rate_limit_port,
9779 (void *)&cmd_vf_rate_limit_portnum,
9780 (void *)&cmd_vf_rate_limit_vf,
9781 (void *)&cmd_vf_rate_limit_vfnum,
9782 (void *)&cmd_vf_rate_limit_rate,
9783 (void *)&cmd_vf_rate_limit_ratenum,
9784 (void *)&cmd_vf_rate_limit_q_msk,
9785 (void *)&cmd_vf_rate_limit_q_msk_val,
9790 /* *** CONFIGURE TUNNEL UDP PORT *** */
9791 struct cmd_tunnel_udp_config {
9792 cmdline_fixed_string_t rx_vxlan_port;
9793 cmdline_fixed_string_t what;
9799 cmd_tunnel_udp_config_parsed(void *parsed_result,
9800 __rte_unused struct cmdline *cl,
9801 __rte_unused void *data)
9803 struct cmd_tunnel_udp_config *res = parsed_result;
9804 struct rte_eth_udp_tunnel tunnel_udp;
9807 tunnel_udp.udp_port = res->udp_port;
9808 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9810 if (!strcmp(res->what, "add"))
9811 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9814 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9818 fprintf(stderr, "udp tunneling add error: (%s)\n",
9822 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9823 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9824 rx_vxlan_port, "rx_vxlan_port");
9825 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9826 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9828 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9829 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9830 udp_port, RTE_UINT16);
9831 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9832 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9833 port_id, RTE_UINT16);
9835 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9836 .f = cmd_tunnel_udp_config_parsed,
9838 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9839 "Add/Remove a tunneling UDP port filter",
9841 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9842 (void *)&cmd_tunnel_udp_config_what,
9843 (void *)&cmd_tunnel_udp_config_udp_port,
9844 (void *)&cmd_tunnel_udp_config_port_id,
9849 struct cmd_config_tunnel_udp_port {
9850 cmdline_fixed_string_t port;
9851 cmdline_fixed_string_t config;
9853 cmdline_fixed_string_t udp_tunnel_port;
9854 cmdline_fixed_string_t action;
9855 cmdline_fixed_string_t tunnel_type;
9860 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9861 __rte_unused struct cmdline *cl,
9862 __rte_unused void *data)
9864 struct cmd_config_tunnel_udp_port *res = parsed_result;
9865 struct rte_eth_udp_tunnel tunnel_udp;
9868 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9871 tunnel_udp.udp_port = res->udp_port;
9873 if (!strcmp(res->tunnel_type, "vxlan")) {
9874 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9875 } else if (!strcmp(res->tunnel_type, "geneve")) {
9876 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9877 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9878 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9879 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9880 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9882 fprintf(stderr, "Invalid tunnel type\n");
9886 if (!strcmp(res->action, "add"))
9887 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9890 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9894 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9898 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9899 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9901 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9902 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9904 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9905 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9907 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9908 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9911 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9912 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9914 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9915 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9916 "vxlan#geneve#vxlan-gpe#ecpri");
9917 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9918 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9921 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9922 .f = cmd_cfg_tunnel_udp_port_parsed,
9924 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9925 "geneve|vxlan-gpe|ecpri <udp_port>",
9927 (void *)&cmd_config_tunnel_udp_port_port,
9928 (void *)&cmd_config_tunnel_udp_port_config,
9929 (void *)&cmd_config_tunnel_udp_port_port_id,
9930 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9931 (void *)&cmd_config_tunnel_udp_port_action,
9932 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9933 (void *)&cmd_config_tunnel_udp_port_value,
9938 /* ******************************************************************************** */
9940 struct cmd_dump_result {
9941 cmdline_fixed_string_t dump;
9945 dump_struct_sizes(void)
9947 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9948 DUMP_SIZE(struct rte_mbuf);
9949 DUMP_SIZE(struct rte_mempool);
9950 DUMP_SIZE(struct rte_ring);
9955 /* Dump the socket memory statistics on console */
9957 dump_socket_mem(FILE *f)
9959 struct rte_malloc_socket_stats socket_stats;
9964 unsigned int n_alloc = 0;
9965 unsigned int n_free = 0;
9966 static size_t last_allocs;
9967 static size_t last_total;
9970 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9971 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9972 !socket_stats.heap_totalsz_bytes)
9974 total += socket_stats.heap_totalsz_bytes;
9975 alloc += socket_stats.heap_allocsz_bytes;
9976 free += socket_stats.heap_freesz_bytes;
9977 n_alloc += socket_stats.alloc_count;
9978 n_free += socket_stats.free_count;
9980 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9982 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9983 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9984 (double)socket_stats.heap_allocsz_bytes * 100 /
9985 (double)socket_stats.heap_totalsz_bytes,
9986 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9987 socket_stats.alloc_count,
9988 socket_stats.free_count);
9991 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9992 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9993 total ? ((double)alloc * 100 / (double)total) : 0,
9994 (double)free / (1024 * 1024),
9997 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9998 ((double)total - (double)last_total) / (1024 * 1024),
9999 (double)(alloc - (double)last_allocs) / 1024 / 1024);
10000 last_allocs = alloc;
10001 last_total = total;
10004 static void cmd_dump_parsed(void *parsed_result,
10005 __rte_unused struct cmdline *cl,
10006 __rte_unused void *data)
10008 struct cmd_dump_result *res = parsed_result;
10010 if (!strcmp(res->dump, "dump_physmem"))
10011 rte_dump_physmem_layout(stdout);
10012 else if (!strcmp(res->dump, "dump_socket_mem"))
10013 dump_socket_mem(stdout);
10014 else if (!strcmp(res->dump, "dump_memzone"))
10015 rte_memzone_dump(stdout);
10016 else if (!strcmp(res->dump, "dump_struct_sizes"))
10017 dump_struct_sizes();
10018 else if (!strcmp(res->dump, "dump_ring"))
10019 rte_ring_list_dump(stdout);
10020 else if (!strcmp(res->dump, "dump_mempool"))
10021 rte_mempool_list_dump(stdout);
10022 else if (!strcmp(res->dump, "dump_devargs"))
10023 rte_devargs_dump(stdout);
10024 else if (!strcmp(res->dump, "dump_log_types"))
10025 rte_log_dump(stdout);
10028 cmdline_parse_token_string_t cmd_dump_dump =
10029 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
10033 "dump_struct_sizes#"
10039 cmdline_parse_inst_t cmd_dump = {
10040 .f = cmd_dump_parsed, /* function to call */
10041 .data = NULL, /* 2nd arg of func */
10042 .help_str = "Dump status",
10043 .tokens = { /* token list, NULL terminated */
10044 (void *)&cmd_dump_dump,
10049 /* ******************************************************************************** */
10051 struct cmd_dump_one_result {
10052 cmdline_fixed_string_t dump;
10053 cmdline_fixed_string_t name;
10056 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
10057 __rte_unused void *data)
10059 struct cmd_dump_one_result *res = parsed_result;
10061 if (!strcmp(res->dump, "dump_ring")) {
10062 struct rte_ring *r;
10063 r = rte_ring_lookup(res->name);
10065 cmdline_printf(cl, "Cannot find ring\n");
10068 rte_ring_dump(stdout, r);
10069 } else if (!strcmp(res->dump, "dump_mempool")) {
10070 struct rte_mempool *mp;
10071 mp = rte_mempool_lookup(res->name);
10073 cmdline_printf(cl, "Cannot find mempool\n");
10076 rte_mempool_dump(stdout, mp);
10080 cmdline_parse_token_string_t cmd_dump_one_dump =
10081 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
10082 "dump_ring#dump_mempool");
10084 cmdline_parse_token_string_t cmd_dump_one_name =
10085 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
10087 cmdline_parse_inst_t cmd_dump_one = {
10088 .f = cmd_dump_one_parsed, /* function to call */
10089 .data = NULL, /* 2nd arg of func */
10090 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
10091 .tokens = { /* token list, NULL terminated */
10092 (void *)&cmd_dump_one_dump,
10093 (void *)&cmd_dump_one_name,
10098 /* *** queue region set *** */
10099 struct cmd_queue_region_result {
10100 cmdline_fixed_string_t set;
10101 cmdline_fixed_string_t port;
10103 cmdline_fixed_string_t cmd;
10104 cmdline_fixed_string_t region;
10106 cmdline_fixed_string_t queue_start_index;
10108 cmdline_fixed_string_t queue_num;
10109 uint8_t queue_num_value;
10113 cmd_queue_region_parsed(void *parsed_result,
10114 __rte_unused struct cmdline *cl,
10115 __rte_unused void *data)
10117 struct cmd_queue_region_result *res = parsed_result;
10118 int ret = -ENOTSUP;
10119 #ifdef RTE_NET_I40E
10120 struct rte_pmd_i40e_queue_region_conf region_conf;
10121 enum rte_pmd_i40e_queue_region_op op_type;
10124 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10127 #ifdef RTE_NET_I40E
10128 memset(®ion_conf, 0, sizeof(region_conf));
10129 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10130 region_conf.region_id = res->region_id;
10131 region_conf.queue_num = res->queue_num_value;
10132 region_conf.queue_start_index = res->queue_id;
10134 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10135 op_type, ®ion_conf);
10142 fprintf(stderr, "function not implemented or supported\n");
10145 fprintf(stderr, "queue region config error: (%s)\n",
10150 cmdline_parse_token_string_t cmd_queue_region_set =
10151 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10153 cmdline_parse_token_string_t cmd_queue_region_port =
10154 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10155 cmdline_parse_token_num_t cmd_queue_region_port_id =
10156 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10157 port_id, RTE_UINT16);
10158 cmdline_parse_token_string_t cmd_queue_region_cmd =
10159 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10160 cmd, "queue-region");
10161 cmdline_parse_token_string_t cmd_queue_region_id =
10162 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10163 region, "region_id");
10164 cmdline_parse_token_num_t cmd_queue_region_index =
10165 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10166 region_id, RTE_UINT8);
10167 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10168 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10169 queue_start_index, "queue_start_index");
10170 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10171 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10172 queue_id, RTE_UINT8);
10173 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10174 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10175 queue_num, "queue_num");
10176 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10177 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10178 queue_num_value, RTE_UINT8);
10180 cmdline_parse_inst_t cmd_queue_region = {
10181 .f = cmd_queue_region_parsed,
10183 .help_str = "set port <port_id> queue-region region_id <value> "
10184 "queue_start_index <value> queue_num <value>: Set a queue region",
10186 (void *)&cmd_queue_region_set,
10187 (void *)&cmd_queue_region_port,
10188 (void *)&cmd_queue_region_port_id,
10189 (void *)&cmd_queue_region_cmd,
10190 (void *)&cmd_queue_region_id,
10191 (void *)&cmd_queue_region_index,
10192 (void *)&cmd_queue_region_queue_start_index,
10193 (void *)&cmd_queue_region_queue_id,
10194 (void *)&cmd_queue_region_queue_num,
10195 (void *)&cmd_queue_region_queue_num_value,
10200 /* *** queue region and flowtype set *** */
10201 struct cmd_region_flowtype_result {
10202 cmdline_fixed_string_t set;
10203 cmdline_fixed_string_t port;
10205 cmdline_fixed_string_t cmd;
10206 cmdline_fixed_string_t region;
10208 cmdline_fixed_string_t flowtype;
10209 uint8_t flowtype_id;
10213 cmd_region_flowtype_parsed(void *parsed_result,
10214 __rte_unused struct cmdline *cl,
10215 __rte_unused void *data)
10217 struct cmd_region_flowtype_result *res = parsed_result;
10218 int ret = -ENOTSUP;
10219 #ifdef RTE_NET_I40E
10220 struct rte_pmd_i40e_queue_region_conf region_conf;
10221 enum rte_pmd_i40e_queue_region_op op_type;
10224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10227 #ifdef RTE_NET_I40E
10228 memset(®ion_conf, 0, sizeof(region_conf));
10230 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10231 region_conf.region_id = res->region_id;
10232 region_conf.hw_flowtype = res->flowtype_id;
10234 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10235 op_type, ®ion_conf);
10242 fprintf(stderr, "function not implemented or supported\n");
10245 fprintf(stderr, "region flowtype config error: (%s)\n",
10250 cmdline_parse_token_string_t cmd_region_flowtype_set =
10251 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10253 cmdline_parse_token_string_t cmd_region_flowtype_port =
10254 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10256 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10257 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10258 port_id, RTE_UINT16);
10259 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10260 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10261 cmd, "queue-region");
10262 cmdline_parse_token_string_t cmd_region_flowtype_index =
10263 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10264 region, "region_id");
10265 cmdline_parse_token_num_t cmd_region_flowtype_id =
10266 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10267 region_id, RTE_UINT8);
10268 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10269 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10270 flowtype, "flowtype");
10271 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10272 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10273 flowtype_id, RTE_UINT8);
10274 cmdline_parse_inst_t cmd_region_flowtype = {
10275 .f = cmd_region_flowtype_parsed,
10277 .help_str = "set port <port_id> queue-region region_id <value> "
10278 "flowtype <value>: Set a flowtype region index",
10280 (void *)&cmd_region_flowtype_set,
10281 (void *)&cmd_region_flowtype_port,
10282 (void *)&cmd_region_flowtype_port_index,
10283 (void *)&cmd_region_flowtype_cmd,
10284 (void *)&cmd_region_flowtype_index,
10285 (void *)&cmd_region_flowtype_id,
10286 (void *)&cmd_region_flowtype_flow_index,
10287 (void *)&cmd_region_flowtype_flow_id,
10292 /* *** User Priority (UP) to queue region (region_id) set *** */
10293 struct cmd_user_priority_region_result {
10294 cmdline_fixed_string_t set;
10295 cmdline_fixed_string_t port;
10297 cmdline_fixed_string_t cmd;
10298 cmdline_fixed_string_t user_priority;
10299 uint8_t user_priority_id;
10300 cmdline_fixed_string_t region;
10305 cmd_user_priority_region_parsed(void *parsed_result,
10306 __rte_unused struct cmdline *cl,
10307 __rte_unused void *data)
10309 struct cmd_user_priority_region_result *res = parsed_result;
10310 int ret = -ENOTSUP;
10311 #ifdef RTE_NET_I40E
10312 struct rte_pmd_i40e_queue_region_conf region_conf;
10313 enum rte_pmd_i40e_queue_region_op op_type;
10316 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10319 #ifdef RTE_NET_I40E
10320 memset(®ion_conf, 0, sizeof(region_conf));
10321 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10322 region_conf.user_priority = res->user_priority_id;
10323 region_conf.region_id = res->region_id;
10325 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10326 op_type, ®ion_conf);
10333 fprintf(stderr, "function not implemented or supported\n");
10336 fprintf(stderr, "user_priority region config error: (%s)\n",
10341 cmdline_parse_token_string_t cmd_user_priority_region_set =
10342 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10344 cmdline_parse_token_string_t cmd_user_priority_region_port =
10345 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10347 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10348 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10349 port_id, RTE_UINT16);
10350 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10351 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10352 cmd, "queue-region");
10353 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10354 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10355 user_priority, "UP");
10356 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10357 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10358 user_priority_id, RTE_UINT8);
10359 cmdline_parse_token_string_t cmd_user_priority_region_region =
10360 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10361 region, "region_id");
10362 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10363 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10364 region_id, RTE_UINT8);
10366 cmdline_parse_inst_t cmd_user_priority_region = {
10367 .f = cmd_user_priority_region_parsed,
10369 .help_str = "set port <port_id> queue-region UP <value> "
10370 "region_id <value>: Set the mapping of User Priority (UP) "
10371 "to queue region (region_id) ",
10373 (void *)&cmd_user_priority_region_set,
10374 (void *)&cmd_user_priority_region_port,
10375 (void *)&cmd_user_priority_region_port_index,
10376 (void *)&cmd_user_priority_region_cmd,
10377 (void *)&cmd_user_priority_region_UP,
10378 (void *)&cmd_user_priority_region_UP_id,
10379 (void *)&cmd_user_priority_region_region,
10380 (void *)&cmd_user_priority_region_region_id,
10385 /* *** flush all queue region related configuration *** */
10386 struct cmd_flush_queue_region_result {
10387 cmdline_fixed_string_t set;
10388 cmdline_fixed_string_t port;
10390 cmdline_fixed_string_t cmd;
10391 cmdline_fixed_string_t flush;
10392 cmdline_fixed_string_t what;
10396 cmd_flush_queue_region_parsed(void *parsed_result,
10397 __rte_unused struct cmdline *cl,
10398 __rte_unused void *data)
10400 struct cmd_flush_queue_region_result *res = parsed_result;
10401 int ret = -ENOTSUP;
10402 #ifdef RTE_NET_I40E
10403 struct rte_pmd_i40e_queue_region_conf region_conf;
10404 enum rte_pmd_i40e_queue_region_op op_type;
10407 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10410 #ifdef RTE_NET_I40E
10411 memset(®ion_conf, 0, sizeof(region_conf));
10413 if (strcmp(res->what, "on") == 0)
10414 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10416 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10418 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10419 op_type, ®ion_conf);
10426 fprintf(stderr, "function not implemented or supported\n");
10429 fprintf(stderr, "queue region config flush error: (%s)\n",
10434 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10435 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10437 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10438 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10440 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10441 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10442 port_id, RTE_UINT16);
10443 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10444 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10445 cmd, "queue-region");
10446 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10447 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10449 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10450 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10453 cmdline_parse_inst_t cmd_flush_queue_region = {
10454 .f = cmd_flush_queue_region_parsed,
10456 .help_str = "set port <port_id> queue-region flush on|off"
10457 ": flush all queue region related configuration",
10459 (void *)&cmd_flush_queue_region_set,
10460 (void *)&cmd_flush_queue_region_port,
10461 (void *)&cmd_flush_queue_region_port_index,
10462 (void *)&cmd_flush_queue_region_cmd,
10463 (void *)&cmd_flush_queue_region_flush,
10464 (void *)&cmd_flush_queue_region_what,
10469 /* *** get all queue region related configuration info *** */
10470 struct cmd_show_queue_region_info {
10471 cmdline_fixed_string_t show;
10472 cmdline_fixed_string_t port;
10474 cmdline_fixed_string_t cmd;
10478 cmd_show_queue_region_info_parsed(void *parsed_result,
10479 __rte_unused struct cmdline *cl,
10480 __rte_unused void *data)
10482 struct cmd_show_queue_region_info *res = parsed_result;
10483 int ret = -ENOTSUP;
10484 #ifdef RTE_NET_I40E
10485 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10486 enum rte_pmd_i40e_queue_region_op op_type;
10489 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10492 #ifdef RTE_NET_I40E
10493 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10495 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10497 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10498 op_type, &rte_pmd_regions);
10500 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10507 fprintf(stderr, "function not implemented or supported\n");
10510 fprintf(stderr, "queue region config info show error: (%s)\n",
10515 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10516 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10518 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10519 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10521 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10522 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10523 port_id, RTE_UINT16);
10524 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10525 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10526 cmd, "queue-region");
10528 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10529 .f = cmd_show_queue_region_info_parsed,
10531 .help_str = "show port <port_id> queue-region"
10532 ": show all queue region related configuration info",
10534 (void *)&cmd_show_queue_region_info_get,
10535 (void *)&cmd_show_queue_region_info_port,
10536 (void *)&cmd_show_queue_region_info_port_index,
10537 (void *)&cmd_show_queue_region_info_cmd,
10542 /* *** Filters Control *** */
10544 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10546 if ((ip_addr).family == AF_INET) \
10547 (ip) = (ip_addr).addr.ipv4.s_addr; \
10549 fprintf(stderr, "invalid parameter.\n"); \
10554 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10556 if ((ip_addr).family == AF_INET6) \
10557 rte_memcpy(&(ip), \
10558 &((ip_addr).addr.ipv6), \
10559 sizeof(struct in6_addr)); \
10561 fprintf(stderr, "invalid parameter.\n"); \
10566 #ifdef RTE_NET_I40E
10569 str2flowtype(char *string)
10572 static const struct {
10575 } flowtype_str[] = {
10576 {"raw", RTE_ETH_FLOW_RAW},
10577 {"ipv4", RTE_ETH_FLOW_IPV4},
10578 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10579 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10580 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10581 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10582 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10583 {"ipv6", RTE_ETH_FLOW_IPV6},
10584 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10585 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10586 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10587 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10588 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10589 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10590 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10591 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10592 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10593 {"gtpu", RTE_ETH_FLOW_GTPU},
10596 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10597 if (!strcmp(flowtype_str[i].str, string))
10598 return flowtype_str[i].type;
10601 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10602 return (uint16_t)atoi(string);
10604 return RTE_ETH_FLOW_UNKNOWN;
10607 /* *** deal with flow director filter *** */
10608 struct cmd_flow_director_result {
10609 cmdline_fixed_string_t flow_director_filter;
10611 cmdline_fixed_string_t mode;
10612 cmdline_fixed_string_t mode_value;
10613 cmdline_fixed_string_t ops;
10614 cmdline_fixed_string_t flow;
10615 cmdline_fixed_string_t flow_type;
10616 cmdline_fixed_string_t drop;
10617 cmdline_fixed_string_t queue;
10619 cmdline_fixed_string_t fd_id;
10620 uint32_t fd_id_value;
10621 cmdline_fixed_string_t packet;
10626 cmd_flow_director_filter_parsed(void *parsed_result,
10627 __rte_unused struct cmdline *cl,
10628 __rte_unused void *data)
10630 struct cmd_flow_director_result *res = parsed_result;
10632 struct rte_pmd_i40e_flow_type_mapping
10633 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10634 struct rte_pmd_i40e_pkt_template_conf conf;
10635 uint16_t flow_type = str2flowtype(res->flow_type);
10636 uint16_t i, port = res->port_id;
10639 memset(&conf, 0, sizeof(conf));
10641 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10642 fprintf(stderr, "Invalid flow type specified.\n");
10645 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10649 if (mapping[flow_type].pctype == 0ULL) {
10650 fprintf(stderr, "Invalid flow type specified.\n");
10653 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10654 if (mapping[flow_type].pctype & (1ULL << i)) {
10655 conf.input.pctype = i;
10660 conf.input.packet = open_file(res->filepath,
10661 &conf.input.length);
10662 if (!conf.input.packet)
10664 if (!strcmp(res->drop, "drop"))
10665 conf.action.behavior =
10666 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10668 conf.action.behavior =
10669 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10670 conf.action.report_status =
10671 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10672 conf.action.rx_queue = res->queue_id;
10673 conf.soft_id = res->fd_id_value;
10674 add = strcmp(res->ops, "del") ? 1 : 0;
10675 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10679 fprintf(stderr, "flow director config error: (%s)\n",
10681 close_file(conf.input.packet);
10684 cmdline_parse_token_string_t cmd_flow_director_filter =
10685 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10686 flow_director_filter, "flow_director_filter");
10687 cmdline_parse_token_num_t cmd_flow_director_port_id =
10688 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10689 port_id, RTE_UINT16);
10690 cmdline_parse_token_string_t cmd_flow_director_ops =
10691 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10692 ops, "add#del#update");
10693 cmdline_parse_token_string_t cmd_flow_director_flow =
10694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10696 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10697 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10699 cmdline_parse_token_string_t cmd_flow_director_drop =
10700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10702 cmdline_parse_token_string_t cmd_flow_director_queue =
10703 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10705 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10706 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10707 queue_id, RTE_UINT16);
10708 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10709 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10711 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10712 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10713 fd_id_value, RTE_UINT32);
10715 cmdline_parse_token_string_t cmd_flow_director_mode =
10716 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10718 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10719 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10720 mode_value, "raw");
10721 cmdline_parse_token_string_t cmd_flow_director_packet =
10722 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10724 cmdline_parse_token_string_t cmd_flow_director_filepath =
10725 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10728 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10729 .f = cmd_flow_director_filter_parsed,
10731 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10732 "director entry on NIC",
10734 (void *)&cmd_flow_director_filter,
10735 (void *)&cmd_flow_director_port_id,
10736 (void *)&cmd_flow_director_mode,
10737 (void *)&cmd_flow_director_mode_raw,
10738 (void *)&cmd_flow_director_ops,
10739 (void *)&cmd_flow_director_flow,
10740 (void *)&cmd_flow_director_flow_type,
10741 (void *)&cmd_flow_director_drop,
10742 (void *)&cmd_flow_director_queue,
10743 (void *)&cmd_flow_director_queue_id,
10744 (void *)&cmd_flow_director_fd_id,
10745 (void *)&cmd_flow_director_fd_id_value,
10746 (void *)&cmd_flow_director_packet,
10747 (void *)&cmd_flow_director_filepath,
10752 #endif /* RTE_NET_I40E */
10754 /* *** deal with flow director mask *** */
10755 struct cmd_flow_director_mask_result {
10756 cmdline_fixed_string_t flow_director_mask;
10758 cmdline_fixed_string_t mode;
10759 cmdline_fixed_string_t mode_value;
10760 cmdline_fixed_string_t vlan;
10761 uint16_t vlan_mask;
10762 cmdline_fixed_string_t src_mask;
10763 cmdline_ipaddr_t ipv4_src;
10764 cmdline_ipaddr_t ipv6_src;
10766 cmdline_fixed_string_t dst_mask;
10767 cmdline_ipaddr_t ipv4_dst;
10768 cmdline_ipaddr_t ipv6_dst;
10770 cmdline_fixed_string_t mac;
10771 uint8_t mac_addr_byte_mask;
10772 cmdline_fixed_string_t tunnel_id;
10773 uint32_t tunnel_id_mask;
10774 cmdline_fixed_string_t tunnel_type;
10775 uint8_t tunnel_type_mask;
10779 cmd_flow_director_mask_parsed(void *parsed_result,
10780 __rte_unused struct cmdline *cl,
10781 __rte_unused void *data)
10783 struct cmd_flow_director_mask_result *res = parsed_result;
10784 struct rte_eth_fdir_masks *mask;
10785 struct rte_port *port;
10787 port = &ports[res->port_id];
10788 /** Check if the port is not started **/
10789 if (port->port_status != RTE_PORT_STOPPED) {
10790 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10794 mask = &port->dev_conf.fdir_conf.mask;
10796 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10797 if (strcmp(res->mode_value, "MAC-VLAN")) {
10798 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10802 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10803 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10804 if (strcmp(res->mode_value, "Tunnel")) {
10805 fprintf(stderr, "Please set mode to Tunnel.\n");
10809 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10810 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10811 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10812 mask->tunnel_type_mask = res->tunnel_type_mask;
10814 if (strcmp(res->mode_value, "IP")) {
10815 fprintf(stderr, "Please set mode to IP.\n");
10819 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10820 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10821 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10822 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10823 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10824 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10825 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10828 cmd_reconfig_device_queue(res->port_id, 1, 1);
10831 cmdline_parse_token_string_t cmd_flow_director_mask =
10832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10833 flow_director_mask, "flow_director_mask");
10834 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10835 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10836 port_id, RTE_UINT16);
10837 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10838 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10840 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10841 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10842 vlan_mask, RTE_UINT16);
10843 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10844 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10845 src_mask, "src_mask");
10846 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10847 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10849 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10850 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10852 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10853 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10854 port_src, RTE_UINT16);
10855 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10857 dst_mask, "dst_mask");
10858 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10859 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10861 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10862 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10864 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10865 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10866 port_dst, RTE_UINT16);
10868 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10871 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10874 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10876 mode_value, "MAC-VLAN");
10877 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10878 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10879 mode_value, "Tunnel");
10880 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10881 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10883 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10884 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10885 mac_addr_byte_mask, RTE_UINT8);
10886 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10887 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10888 tunnel_type, "tunnel-type");
10889 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10890 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10891 tunnel_type_mask, RTE_UINT8);
10892 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10893 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10894 tunnel_id, "tunnel-id");
10895 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10896 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10897 tunnel_id_mask, RTE_UINT32);
10899 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10900 .f = cmd_flow_director_mask_parsed,
10902 .help_str = "flow_director_mask ... : "
10903 "Set IP mode flow director's mask on NIC",
10905 (void *)&cmd_flow_director_mask,
10906 (void *)&cmd_flow_director_mask_port_id,
10907 (void *)&cmd_flow_director_mask_mode,
10908 (void *)&cmd_flow_director_mask_mode_ip,
10909 (void *)&cmd_flow_director_mask_vlan,
10910 (void *)&cmd_flow_director_mask_vlan_value,
10911 (void *)&cmd_flow_director_mask_src,
10912 (void *)&cmd_flow_director_mask_ipv4_src,
10913 (void *)&cmd_flow_director_mask_ipv6_src,
10914 (void *)&cmd_flow_director_mask_port_src,
10915 (void *)&cmd_flow_director_mask_dst,
10916 (void *)&cmd_flow_director_mask_ipv4_dst,
10917 (void *)&cmd_flow_director_mask_ipv6_dst,
10918 (void *)&cmd_flow_director_mask_port_dst,
10923 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10924 .f = cmd_flow_director_mask_parsed,
10926 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10927 "flow director's mask on NIC",
10929 (void *)&cmd_flow_director_mask,
10930 (void *)&cmd_flow_director_mask_port_id,
10931 (void *)&cmd_flow_director_mask_mode,
10932 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10933 (void *)&cmd_flow_director_mask_vlan,
10934 (void *)&cmd_flow_director_mask_vlan_value,
10939 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10940 .f = cmd_flow_director_mask_parsed,
10942 .help_str = "flow_director_mask ... : Set tunnel mode "
10943 "flow director's mask on NIC",
10945 (void *)&cmd_flow_director_mask,
10946 (void *)&cmd_flow_director_mask_port_id,
10947 (void *)&cmd_flow_director_mask_mode,
10948 (void *)&cmd_flow_director_mask_mode_tunnel,
10949 (void *)&cmd_flow_director_mask_vlan,
10950 (void *)&cmd_flow_director_mask_vlan_value,
10951 (void *)&cmd_flow_director_mask_mac,
10952 (void *)&cmd_flow_director_mask_mac_value,
10953 (void *)&cmd_flow_director_mask_tunnel_type,
10954 (void *)&cmd_flow_director_mask_tunnel_type_value,
10955 (void *)&cmd_flow_director_mask_tunnel_id,
10956 (void *)&cmd_flow_director_mask_tunnel_id_value,
10961 /* *** deal with flow director flexible payload configuration *** */
10962 struct cmd_flow_director_flexpayload_result {
10963 cmdline_fixed_string_t flow_director_flexpayload;
10965 cmdline_fixed_string_t payload_layer;
10966 cmdline_fixed_string_t payload_cfg;
10970 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10973 const char *p, *p0 = q_arg;
10975 unsigned long int_fld;
10976 char *str_fld[max_num];
10981 p = strchr(p0, '(');
10985 p0 = strchr(p, ')');
10990 if (size >= sizeof(s))
10993 snprintf(s, sizeof(s), "%.*s", size, p);
10994 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10995 if (ret < 0 || ret > max_num)
10997 for (i = 0; i < ret; i++) {
10999 int_fld = strtoul(str_fld[i], &end, 0);
11000 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11002 offsets[i] = (uint16_t)int_fld;
11008 cmd_flow_director_flxpld_parsed(void *parsed_result,
11009 __rte_unused struct cmdline *cl,
11010 __rte_unused void *data)
11012 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11013 struct rte_eth_flex_payload_cfg flex_cfg;
11014 struct rte_port *port;
11017 port = &ports[res->port_id];
11018 /** Check if the port is not started **/
11019 if (port->port_status != RTE_PORT_STOPPED) {
11020 fprintf(stderr, "Please stop port %d first\n", res->port_id);
11024 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11026 if (!strcmp(res->payload_layer, "raw"))
11027 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11028 else if (!strcmp(res->payload_layer, "l2"))
11029 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11030 else if (!strcmp(res->payload_layer, "l3"))
11031 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11032 else if (!strcmp(res->payload_layer, "l4"))
11033 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11035 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11036 RTE_ETH_FDIR_MAX_FLEXLEN);
11038 fprintf(stderr, "error: Cannot parse flex payload input.\n");
11042 fdir_set_flex_payload(res->port_id, &flex_cfg);
11043 cmd_reconfig_device_queue(res->port_id, 1, 1);
11046 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11048 flow_director_flexpayload,
11049 "flow_director_flex_payload");
11050 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11051 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11052 port_id, RTE_UINT16);
11053 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11054 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11055 payload_layer, "raw#l2#l3#l4");
11056 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11057 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11058 payload_cfg, NULL);
11060 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11061 .f = cmd_flow_director_flxpld_parsed,
11063 .help_str = "flow_director_flexpayload ... : "
11064 "Set flow director's flex payload on NIC",
11066 (void *)&cmd_flow_director_flexpayload,
11067 (void *)&cmd_flow_director_flexpayload_port_id,
11068 (void *)&cmd_flow_director_flexpayload_payload_layer,
11069 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11074 /* Generic flow interface command. */
11075 extern cmdline_parse_inst_t cmd_flow;
11077 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11078 struct cmd_mcast_addr_result {
11079 cmdline_fixed_string_t mcast_addr_cmd;
11080 cmdline_fixed_string_t what;
11082 struct rte_ether_addr mc_addr;
11085 static void cmd_mcast_addr_parsed(void *parsed_result,
11086 __rte_unused struct cmdline *cl,
11087 __rte_unused void *data)
11089 struct cmd_mcast_addr_result *res = parsed_result;
11091 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11093 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
11094 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
11097 if (strcmp(res->what, "add") == 0)
11098 mcast_addr_add(res->port_num, &res->mc_addr);
11100 mcast_addr_remove(res->port_num, &res->mc_addr);
11103 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11104 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11105 mcast_addr_cmd, "mcast_addr");
11106 cmdline_parse_token_string_t cmd_mcast_addr_what =
11107 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11109 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11110 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
11112 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11113 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11115 cmdline_parse_inst_t cmd_mcast_addr = {
11116 .f = cmd_mcast_addr_parsed,
11118 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11119 "Add/Remove multicast MAC address on port_id",
11121 (void *)&cmd_mcast_addr_cmd,
11122 (void *)&cmd_mcast_addr_what,
11123 (void *)&cmd_mcast_addr_portnum,
11124 (void *)&cmd_mcast_addr_addr,
11129 /* vf vlan anti spoof configuration */
11131 /* Common result structure for vf vlan anti spoof */
11132 struct cmd_vf_vlan_anti_spoof_result {
11133 cmdline_fixed_string_t set;
11134 cmdline_fixed_string_t vf;
11135 cmdline_fixed_string_t vlan;
11136 cmdline_fixed_string_t antispoof;
11139 cmdline_fixed_string_t on_off;
11142 /* Common CLI fields for vf vlan anti spoof enable disable */
11143 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11144 TOKEN_STRING_INITIALIZER
11145 (struct cmd_vf_vlan_anti_spoof_result,
11147 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11148 TOKEN_STRING_INITIALIZER
11149 (struct cmd_vf_vlan_anti_spoof_result,
11151 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11152 TOKEN_STRING_INITIALIZER
11153 (struct cmd_vf_vlan_anti_spoof_result,
11155 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11156 TOKEN_STRING_INITIALIZER
11157 (struct cmd_vf_vlan_anti_spoof_result,
11158 antispoof, "antispoof");
11159 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11160 TOKEN_NUM_INITIALIZER
11161 (struct cmd_vf_vlan_anti_spoof_result,
11162 port_id, RTE_UINT16);
11163 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11164 TOKEN_NUM_INITIALIZER
11165 (struct cmd_vf_vlan_anti_spoof_result,
11166 vf_id, RTE_UINT32);
11167 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11168 TOKEN_STRING_INITIALIZER
11169 (struct cmd_vf_vlan_anti_spoof_result,
11173 cmd_set_vf_vlan_anti_spoof_parsed(
11174 void *parsed_result,
11175 __rte_unused struct cmdline *cl,
11176 __rte_unused void *data)
11178 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11179 int ret = -ENOTSUP;
11181 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11183 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11186 #ifdef RTE_NET_IXGBE
11187 if (ret == -ENOTSUP)
11188 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11189 res->vf_id, is_on);
11191 #ifdef RTE_NET_I40E
11192 if (ret == -ENOTSUP)
11193 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11194 res->vf_id, is_on);
11196 #ifdef RTE_NET_BNXT
11197 if (ret == -ENOTSUP)
11198 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11199 res->vf_id, is_on);
11206 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11209 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11212 fprintf(stderr, "function not implemented\n");
11215 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11219 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11220 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11222 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11224 (void *)&cmd_vf_vlan_anti_spoof_set,
11225 (void *)&cmd_vf_vlan_anti_spoof_vf,
11226 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11227 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11228 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11229 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11230 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11235 /* vf mac anti spoof configuration */
11237 /* Common result structure for vf mac anti spoof */
11238 struct cmd_vf_mac_anti_spoof_result {
11239 cmdline_fixed_string_t set;
11240 cmdline_fixed_string_t vf;
11241 cmdline_fixed_string_t mac;
11242 cmdline_fixed_string_t antispoof;
11245 cmdline_fixed_string_t on_off;
11248 /* Common CLI fields for vf mac anti spoof enable disable */
11249 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11250 TOKEN_STRING_INITIALIZER
11251 (struct cmd_vf_mac_anti_spoof_result,
11253 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11254 TOKEN_STRING_INITIALIZER
11255 (struct cmd_vf_mac_anti_spoof_result,
11257 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11258 TOKEN_STRING_INITIALIZER
11259 (struct cmd_vf_mac_anti_spoof_result,
11261 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11262 TOKEN_STRING_INITIALIZER
11263 (struct cmd_vf_mac_anti_spoof_result,
11264 antispoof, "antispoof");
11265 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11266 TOKEN_NUM_INITIALIZER
11267 (struct cmd_vf_mac_anti_spoof_result,
11268 port_id, RTE_UINT16);
11269 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11270 TOKEN_NUM_INITIALIZER
11271 (struct cmd_vf_mac_anti_spoof_result,
11272 vf_id, RTE_UINT32);
11273 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11274 TOKEN_STRING_INITIALIZER
11275 (struct cmd_vf_mac_anti_spoof_result,
11279 cmd_set_vf_mac_anti_spoof_parsed(
11280 void *parsed_result,
11281 __rte_unused struct cmdline *cl,
11282 __rte_unused void *data)
11284 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11285 int ret = -ENOTSUP;
11287 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11289 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11292 #ifdef RTE_NET_IXGBE
11293 if (ret == -ENOTSUP)
11294 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11295 res->vf_id, is_on);
11297 #ifdef RTE_NET_I40E
11298 if (ret == -ENOTSUP)
11299 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11300 res->vf_id, is_on);
11302 #ifdef RTE_NET_BNXT
11303 if (ret == -ENOTSUP)
11304 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11305 res->vf_id, is_on);
11312 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11313 res->vf_id, is_on);
11316 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11319 fprintf(stderr, "function not implemented\n");
11322 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11326 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11327 .f = cmd_set_vf_mac_anti_spoof_parsed,
11329 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11331 (void *)&cmd_vf_mac_anti_spoof_set,
11332 (void *)&cmd_vf_mac_anti_spoof_vf,
11333 (void *)&cmd_vf_mac_anti_spoof_mac,
11334 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11335 (void *)&cmd_vf_mac_anti_spoof_port_id,
11336 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11337 (void *)&cmd_vf_mac_anti_spoof_on_off,
11342 /* vf vlan strip queue configuration */
11344 /* Common result structure for vf mac anti spoof */
11345 struct cmd_vf_vlan_stripq_result {
11346 cmdline_fixed_string_t set;
11347 cmdline_fixed_string_t vf;
11348 cmdline_fixed_string_t vlan;
11349 cmdline_fixed_string_t stripq;
11352 cmdline_fixed_string_t on_off;
11355 /* Common CLI fields for vf vlan strip enable disable */
11356 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11357 TOKEN_STRING_INITIALIZER
11358 (struct cmd_vf_vlan_stripq_result,
11360 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11361 TOKEN_STRING_INITIALIZER
11362 (struct cmd_vf_vlan_stripq_result,
11364 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11365 TOKEN_STRING_INITIALIZER
11366 (struct cmd_vf_vlan_stripq_result,
11368 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11369 TOKEN_STRING_INITIALIZER
11370 (struct cmd_vf_vlan_stripq_result,
11372 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11373 TOKEN_NUM_INITIALIZER
11374 (struct cmd_vf_vlan_stripq_result,
11375 port_id, RTE_UINT16);
11376 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11377 TOKEN_NUM_INITIALIZER
11378 (struct cmd_vf_vlan_stripq_result,
11379 vf_id, RTE_UINT16);
11380 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11381 TOKEN_STRING_INITIALIZER
11382 (struct cmd_vf_vlan_stripq_result,
11386 cmd_set_vf_vlan_stripq_parsed(
11387 void *parsed_result,
11388 __rte_unused struct cmdline *cl,
11389 __rte_unused void *data)
11391 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11392 int ret = -ENOTSUP;
11394 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11399 #ifdef RTE_NET_IXGBE
11400 if (ret == -ENOTSUP)
11401 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11402 res->vf_id, is_on);
11404 #ifdef RTE_NET_I40E
11405 if (ret == -ENOTSUP)
11406 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11407 res->vf_id, is_on);
11409 #ifdef RTE_NET_BNXT
11410 if (ret == -ENOTSUP)
11411 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11412 res->vf_id, is_on);
11419 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11420 res->vf_id, is_on);
11423 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11426 fprintf(stderr, "function not implemented\n");
11429 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11433 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11434 .f = cmd_set_vf_vlan_stripq_parsed,
11436 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11438 (void *)&cmd_vf_vlan_stripq_set,
11439 (void *)&cmd_vf_vlan_stripq_vf,
11440 (void *)&cmd_vf_vlan_stripq_vlan,
11441 (void *)&cmd_vf_vlan_stripq_stripq,
11442 (void *)&cmd_vf_vlan_stripq_port_id,
11443 (void *)&cmd_vf_vlan_stripq_vf_id,
11444 (void *)&cmd_vf_vlan_stripq_on_off,
11449 /* vf vlan insert configuration */
11451 /* Common result structure for vf vlan insert */
11452 struct cmd_vf_vlan_insert_result {
11453 cmdline_fixed_string_t set;
11454 cmdline_fixed_string_t vf;
11455 cmdline_fixed_string_t vlan;
11456 cmdline_fixed_string_t insert;
11462 /* Common CLI fields for vf vlan insert enable disable */
11463 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11464 TOKEN_STRING_INITIALIZER
11465 (struct cmd_vf_vlan_insert_result,
11467 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11468 TOKEN_STRING_INITIALIZER
11469 (struct cmd_vf_vlan_insert_result,
11471 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11472 TOKEN_STRING_INITIALIZER
11473 (struct cmd_vf_vlan_insert_result,
11475 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11476 TOKEN_STRING_INITIALIZER
11477 (struct cmd_vf_vlan_insert_result,
11479 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11480 TOKEN_NUM_INITIALIZER
11481 (struct cmd_vf_vlan_insert_result,
11482 port_id, RTE_UINT16);
11483 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11484 TOKEN_NUM_INITIALIZER
11485 (struct cmd_vf_vlan_insert_result,
11486 vf_id, RTE_UINT16);
11487 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11488 TOKEN_NUM_INITIALIZER
11489 (struct cmd_vf_vlan_insert_result,
11490 vlan_id, RTE_UINT16);
11493 cmd_set_vf_vlan_insert_parsed(
11494 void *parsed_result,
11495 __rte_unused struct cmdline *cl,
11496 __rte_unused void *data)
11498 struct cmd_vf_vlan_insert_result *res = parsed_result;
11499 int ret = -ENOTSUP;
11501 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11504 #ifdef RTE_NET_IXGBE
11505 if (ret == -ENOTSUP)
11506 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11509 #ifdef RTE_NET_I40E
11510 if (ret == -ENOTSUP)
11511 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11514 #ifdef RTE_NET_BNXT
11515 if (ret == -ENOTSUP)
11516 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11524 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11525 res->vf_id, res->vlan_id);
11528 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11531 fprintf(stderr, "function not implemented\n");
11534 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11538 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11539 .f = cmd_set_vf_vlan_insert_parsed,
11541 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11543 (void *)&cmd_vf_vlan_insert_set,
11544 (void *)&cmd_vf_vlan_insert_vf,
11545 (void *)&cmd_vf_vlan_insert_vlan,
11546 (void *)&cmd_vf_vlan_insert_insert,
11547 (void *)&cmd_vf_vlan_insert_port_id,
11548 (void *)&cmd_vf_vlan_insert_vf_id,
11549 (void *)&cmd_vf_vlan_insert_vlan_id,
11554 /* tx loopback configuration */
11556 /* Common result structure for tx loopback */
11557 struct cmd_tx_loopback_result {
11558 cmdline_fixed_string_t set;
11559 cmdline_fixed_string_t tx;
11560 cmdline_fixed_string_t loopback;
11562 cmdline_fixed_string_t on_off;
11565 /* Common CLI fields for tx loopback enable disable */
11566 cmdline_parse_token_string_t cmd_tx_loopback_set =
11567 TOKEN_STRING_INITIALIZER
11568 (struct cmd_tx_loopback_result,
11570 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11571 TOKEN_STRING_INITIALIZER
11572 (struct cmd_tx_loopback_result,
11574 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11575 TOKEN_STRING_INITIALIZER
11576 (struct cmd_tx_loopback_result,
11577 loopback, "loopback");
11578 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11579 TOKEN_NUM_INITIALIZER
11580 (struct cmd_tx_loopback_result,
11581 port_id, RTE_UINT16);
11582 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11583 TOKEN_STRING_INITIALIZER
11584 (struct cmd_tx_loopback_result,
11588 cmd_set_tx_loopback_parsed(
11589 void *parsed_result,
11590 __rte_unused struct cmdline *cl,
11591 __rte_unused void *data)
11593 struct cmd_tx_loopback_result *res = parsed_result;
11594 int ret = -ENOTSUP;
11596 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11598 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11601 #ifdef RTE_NET_IXGBE
11602 if (ret == -ENOTSUP)
11603 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11605 #ifdef RTE_NET_I40E
11606 if (ret == -ENOTSUP)
11607 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11609 #ifdef RTE_NET_BNXT
11610 if (ret == -ENOTSUP)
11611 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11613 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11614 if (ret == -ENOTSUP)
11615 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11622 fprintf(stderr, "invalid is_on %d\n", is_on);
11625 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11628 fprintf(stderr, "function not implemented\n");
11631 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11635 cmdline_parse_inst_t cmd_set_tx_loopback = {
11636 .f = cmd_set_tx_loopback_parsed,
11638 .help_str = "set tx loopback <port_id> on|off",
11640 (void *)&cmd_tx_loopback_set,
11641 (void *)&cmd_tx_loopback_tx,
11642 (void *)&cmd_tx_loopback_loopback,
11643 (void *)&cmd_tx_loopback_port_id,
11644 (void *)&cmd_tx_loopback_on_off,
11649 /* all queues drop enable configuration */
11651 /* Common result structure for all queues drop enable */
11652 struct cmd_all_queues_drop_en_result {
11653 cmdline_fixed_string_t set;
11654 cmdline_fixed_string_t all;
11655 cmdline_fixed_string_t queues;
11656 cmdline_fixed_string_t drop;
11658 cmdline_fixed_string_t on_off;
11661 /* Common CLI fields for tx loopback enable disable */
11662 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11663 TOKEN_STRING_INITIALIZER
11664 (struct cmd_all_queues_drop_en_result,
11666 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11667 TOKEN_STRING_INITIALIZER
11668 (struct cmd_all_queues_drop_en_result,
11670 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11671 TOKEN_STRING_INITIALIZER
11672 (struct cmd_all_queues_drop_en_result,
11674 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11675 TOKEN_STRING_INITIALIZER
11676 (struct cmd_all_queues_drop_en_result,
11678 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11679 TOKEN_NUM_INITIALIZER
11680 (struct cmd_all_queues_drop_en_result,
11681 port_id, RTE_UINT16);
11682 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11683 TOKEN_STRING_INITIALIZER
11684 (struct cmd_all_queues_drop_en_result,
11688 cmd_set_all_queues_drop_en_parsed(
11689 void *parsed_result,
11690 __rte_unused struct cmdline *cl,
11691 __rte_unused void *data)
11693 struct cmd_all_queues_drop_en_result *res = parsed_result;
11694 int ret = -ENOTSUP;
11695 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11697 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11700 #ifdef RTE_NET_IXGBE
11701 if (ret == -ENOTSUP)
11702 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11704 #ifdef RTE_NET_BNXT
11705 if (ret == -ENOTSUP)
11706 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11712 fprintf(stderr, "invalid is_on %d\n", is_on);
11715 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11718 fprintf(stderr, "function not implemented\n");
11721 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11725 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11726 .f = cmd_set_all_queues_drop_en_parsed,
11728 .help_str = "set all queues drop <port_id> on|off",
11730 (void *)&cmd_all_queues_drop_en_set,
11731 (void *)&cmd_all_queues_drop_en_all,
11732 (void *)&cmd_all_queues_drop_en_queues,
11733 (void *)&cmd_all_queues_drop_en_drop,
11734 (void *)&cmd_all_queues_drop_en_port_id,
11735 (void *)&cmd_all_queues_drop_en_on_off,
11740 /* vf split drop enable configuration */
11742 /* Common result structure for vf split drop enable */
11743 struct cmd_vf_split_drop_en_result {
11744 cmdline_fixed_string_t set;
11745 cmdline_fixed_string_t vf;
11746 cmdline_fixed_string_t split;
11747 cmdline_fixed_string_t drop;
11750 cmdline_fixed_string_t on_off;
11753 /* Common CLI fields for vf split drop enable disable */
11754 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11755 TOKEN_STRING_INITIALIZER
11756 (struct cmd_vf_split_drop_en_result,
11758 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11759 TOKEN_STRING_INITIALIZER
11760 (struct cmd_vf_split_drop_en_result,
11762 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11763 TOKEN_STRING_INITIALIZER
11764 (struct cmd_vf_split_drop_en_result,
11766 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11767 TOKEN_STRING_INITIALIZER
11768 (struct cmd_vf_split_drop_en_result,
11770 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11771 TOKEN_NUM_INITIALIZER
11772 (struct cmd_vf_split_drop_en_result,
11773 port_id, RTE_UINT16);
11774 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11775 TOKEN_NUM_INITIALIZER
11776 (struct cmd_vf_split_drop_en_result,
11777 vf_id, RTE_UINT16);
11778 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11779 TOKEN_STRING_INITIALIZER
11780 (struct cmd_vf_split_drop_en_result,
11784 cmd_set_vf_split_drop_en_parsed(
11785 void *parsed_result,
11786 __rte_unused struct cmdline *cl,
11787 __rte_unused void *data)
11789 struct cmd_vf_split_drop_en_result *res = parsed_result;
11790 int ret = -ENOTSUP;
11791 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11793 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11796 #ifdef RTE_NET_IXGBE
11797 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11804 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11805 res->vf_id, is_on);
11808 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11811 fprintf(stderr, "not supported on port %d\n", res->port_id);
11814 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11818 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11819 .f = cmd_set_vf_split_drop_en_parsed,
11821 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11823 (void *)&cmd_vf_split_drop_en_set,
11824 (void *)&cmd_vf_split_drop_en_vf,
11825 (void *)&cmd_vf_split_drop_en_split,
11826 (void *)&cmd_vf_split_drop_en_drop,
11827 (void *)&cmd_vf_split_drop_en_port_id,
11828 (void *)&cmd_vf_split_drop_en_vf_id,
11829 (void *)&cmd_vf_split_drop_en_on_off,
11834 /* vf mac address configuration */
11836 /* Common result structure for vf mac address */
11837 struct cmd_set_vf_mac_addr_result {
11838 cmdline_fixed_string_t set;
11839 cmdline_fixed_string_t vf;
11840 cmdline_fixed_string_t mac;
11841 cmdline_fixed_string_t addr;
11844 struct rte_ether_addr mac_addr;
11848 /* Common CLI fields for vf split drop enable disable */
11849 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11850 TOKEN_STRING_INITIALIZER
11851 (struct cmd_set_vf_mac_addr_result,
11853 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11854 TOKEN_STRING_INITIALIZER
11855 (struct cmd_set_vf_mac_addr_result,
11857 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11858 TOKEN_STRING_INITIALIZER
11859 (struct cmd_set_vf_mac_addr_result,
11861 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11862 TOKEN_STRING_INITIALIZER
11863 (struct cmd_set_vf_mac_addr_result,
11865 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11866 TOKEN_NUM_INITIALIZER
11867 (struct cmd_set_vf_mac_addr_result,
11868 port_id, RTE_UINT16);
11869 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11870 TOKEN_NUM_INITIALIZER
11871 (struct cmd_set_vf_mac_addr_result,
11872 vf_id, RTE_UINT16);
11873 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11874 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11878 cmd_set_vf_mac_addr_parsed(
11879 void *parsed_result,
11880 __rte_unused struct cmdline *cl,
11881 __rte_unused void *data)
11883 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11884 int ret = -ENOTSUP;
11886 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11889 #ifdef RTE_NET_IXGBE
11890 if (ret == -ENOTSUP)
11891 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11894 #ifdef RTE_NET_I40E
11895 if (ret == -ENOTSUP)
11896 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11899 #ifdef RTE_NET_BNXT
11900 if (ret == -ENOTSUP)
11901 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11909 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11912 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11915 fprintf(stderr, "function not implemented\n");
11918 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11922 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11923 .f = cmd_set_vf_mac_addr_parsed,
11925 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11927 (void *)&cmd_set_vf_mac_addr_set,
11928 (void *)&cmd_set_vf_mac_addr_vf,
11929 (void *)&cmd_set_vf_mac_addr_mac,
11930 (void *)&cmd_set_vf_mac_addr_addr,
11931 (void *)&cmd_set_vf_mac_addr_port_id,
11932 (void *)&cmd_set_vf_mac_addr_vf_id,
11933 (void *)&cmd_set_vf_mac_addr_mac_addr,
11938 /* MACsec configuration */
11940 /* Common result structure for MACsec offload enable */
11941 struct cmd_macsec_offload_on_result {
11942 cmdline_fixed_string_t set;
11943 cmdline_fixed_string_t macsec;
11944 cmdline_fixed_string_t offload;
11946 cmdline_fixed_string_t on;
11947 cmdline_fixed_string_t encrypt;
11948 cmdline_fixed_string_t en_on_off;
11949 cmdline_fixed_string_t replay_protect;
11950 cmdline_fixed_string_t rp_on_off;
11953 /* Common CLI fields for MACsec offload disable */
11954 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11955 TOKEN_STRING_INITIALIZER
11956 (struct cmd_macsec_offload_on_result,
11958 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11959 TOKEN_STRING_INITIALIZER
11960 (struct cmd_macsec_offload_on_result,
11962 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11963 TOKEN_STRING_INITIALIZER
11964 (struct cmd_macsec_offload_on_result,
11965 offload, "offload");
11966 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11967 TOKEN_NUM_INITIALIZER
11968 (struct cmd_macsec_offload_on_result,
11969 port_id, RTE_UINT16);
11970 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11971 TOKEN_STRING_INITIALIZER
11972 (struct cmd_macsec_offload_on_result,
11974 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11975 TOKEN_STRING_INITIALIZER
11976 (struct cmd_macsec_offload_on_result,
11977 encrypt, "encrypt");
11978 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11979 TOKEN_STRING_INITIALIZER
11980 (struct cmd_macsec_offload_on_result,
11981 en_on_off, "on#off");
11982 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11983 TOKEN_STRING_INITIALIZER
11984 (struct cmd_macsec_offload_on_result,
11985 replay_protect, "replay-protect");
11986 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11987 TOKEN_STRING_INITIALIZER
11988 (struct cmd_macsec_offload_on_result,
11989 rp_on_off, "on#off");
11992 cmd_set_macsec_offload_on_parsed(
11993 void *parsed_result,
11994 __rte_unused struct cmdline *cl,
11995 __rte_unused void *data)
11997 struct cmd_macsec_offload_on_result *res = parsed_result;
11998 int ret = -ENOTSUP;
11999 portid_t port_id = res->port_id;
12000 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12001 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12002 struct rte_eth_dev_info dev_info;
12004 if (port_id_is_invalid(port_id, ENABLED_WARN))
12006 if (!port_is_stopped(port_id)) {
12007 fprintf(stderr, "Please stop port %d first\n", port_id);
12011 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12015 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12016 #ifdef RTE_NET_IXGBE
12017 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12025 ports[port_id].dev_conf.txmode.offloads |=
12026 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12027 cmd_reconfig_device_queue(port_id, 1, 1);
12030 fprintf(stderr, "invalid port_id %d\n", port_id);
12033 fprintf(stderr, "not supported on port %d\n", port_id);
12036 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12040 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12041 .f = cmd_set_macsec_offload_on_parsed,
12043 .help_str = "set macsec offload <port_id> on "
12044 "encrypt on|off replay-protect on|off",
12046 (void *)&cmd_macsec_offload_on_set,
12047 (void *)&cmd_macsec_offload_on_macsec,
12048 (void *)&cmd_macsec_offload_on_offload,
12049 (void *)&cmd_macsec_offload_on_port_id,
12050 (void *)&cmd_macsec_offload_on_on,
12051 (void *)&cmd_macsec_offload_on_encrypt,
12052 (void *)&cmd_macsec_offload_on_en_on_off,
12053 (void *)&cmd_macsec_offload_on_replay_protect,
12054 (void *)&cmd_macsec_offload_on_rp_on_off,
12059 /* Common result structure for MACsec offload disable */
12060 struct cmd_macsec_offload_off_result {
12061 cmdline_fixed_string_t set;
12062 cmdline_fixed_string_t macsec;
12063 cmdline_fixed_string_t offload;
12065 cmdline_fixed_string_t off;
12068 /* Common CLI fields for MACsec offload disable */
12069 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12070 TOKEN_STRING_INITIALIZER
12071 (struct cmd_macsec_offload_off_result,
12073 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12074 TOKEN_STRING_INITIALIZER
12075 (struct cmd_macsec_offload_off_result,
12077 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12078 TOKEN_STRING_INITIALIZER
12079 (struct cmd_macsec_offload_off_result,
12080 offload, "offload");
12081 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12082 TOKEN_NUM_INITIALIZER
12083 (struct cmd_macsec_offload_off_result,
12084 port_id, RTE_UINT16);
12085 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12086 TOKEN_STRING_INITIALIZER
12087 (struct cmd_macsec_offload_off_result,
12091 cmd_set_macsec_offload_off_parsed(
12092 void *parsed_result,
12093 __rte_unused struct cmdline *cl,
12094 __rte_unused void *data)
12096 struct cmd_macsec_offload_off_result *res = parsed_result;
12097 int ret = -ENOTSUP;
12098 struct rte_eth_dev_info dev_info;
12099 portid_t port_id = res->port_id;
12101 if (port_id_is_invalid(port_id, ENABLED_WARN))
12103 if (!port_is_stopped(port_id)) {
12104 fprintf(stderr, "Please stop port %d first\n", port_id);
12108 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12112 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12113 #ifdef RTE_NET_IXGBE
12114 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12119 ports[port_id].dev_conf.txmode.offloads &=
12120 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12121 cmd_reconfig_device_queue(port_id, 1, 1);
12124 fprintf(stderr, "invalid port_id %d\n", port_id);
12127 fprintf(stderr, "not supported on port %d\n", port_id);
12130 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12134 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12135 .f = cmd_set_macsec_offload_off_parsed,
12137 .help_str = "set macsec offload <port_id> off",
12139 (void *)&cmd_macsec_offload_off_set,
12140 (void *)&cmd_macsec_offload_off_macsec,
12141 (void *)&cmd_macsec_offload_off_offload,
12142 (void *)&cmd_macsec_offload_off_port_id,
12143 (void *)&cmd_macsec_offload_off_off,
12148 /* Common result structure for MACsec secure connection configure */
12149 struct cmd_macsec_sc_result {
12150 cmdline_fixed_string_t set;
12151 cmdline_fixed_string_t macsec;
12152 cmdline_fixed_string_t sc;
12153 cmdline_fixed_string_t tx_rx;
12155 struct rte_ether_addr mac;
12159 /* Common CLI fields for MACsec secure connection configure */
12160 cmdline_parse_token_string_t cmd_macsec_sc_set =
12161 TOKEN_STRING_INITIALIZER
12162 (struct cmd_macsec_sc_result,
12164 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12165 TOKEN_STRING_INITIALIZER
12166 (struct cmd_macsec_sc_result,
12168 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12169 TOKEN_STRING_INITIALIZER
12170 (struct cmd_macsec_sc_result,
12172 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12173 TOKEN_STRING_INITIALIZER
12174 (struct cmd_macsec_sc_result,
12176 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12177 TOKEN_NUM_INITIALIZER
12178 (struct cmd_macsec_sc_result,
12179 port_id, RTE_UINT16);
12180 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12181 TOKEN_ETHERADDR_INITIALIZER
12182 (struct cmd_macsec_sc_result,
12184 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12185 TOKEN_NUM_INITIALIZER
12186 (struct cmd_macsec_sc_result,
12190 cmd_set_macsec_sc_parsed(
12191 void *parsed_result,
12192 __rte_unused struct cmdline *cl,
12193 __rte_unused void *data)
12195 struct cmd_macsec_sc_result *res = parsed_result;
12196 int ret = -ENOTSUP;
12197 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12199 #ifdef RTE_NET_IXGBE
12201 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12202 res->mac.addr_bytes) :
12203 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12204 res->mac.addr_bytes, res->pi);
12206 RTE_SET_USED(is_tx);
12212 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12215 fprintf(stderr, "not supported on port %d\n", res->port_id);
12218 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12222 cmdline_parse_inst_t cmd_set_macsec_sc = {
12223 .f = cmd_set_macsec_sc_parsed,
12225 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12227 (void *)&cmd_macsec_sc_set,
12228 (void *)&cmd_macsec_sc_macsec,
12229 (void *)&cmd_macsec_sc_sc,
12230 (void *)&cmd_macsec_sc_tx_rx,
12231 (void *)&cmd_macsec_sc_port_id,
12232 (void *)&cmd_macsec_sc_mac,
12233 (void *)&cmd_macsec_sc_pi,
12238 /* Common result structure for MACsec secure connection configure */
12239 struct cmd_macsec_sa_result {
12240 cmdline_fixed_string_t set;
12241 cmdline_fixed_string_t macsec;
12242 cmdline_fixed_string_t sa;
12243 cmdline_fixed_string_t tx_rx;
12248 cmdline_fixed_string_t key;
12251 /* Common CLI fields for MACsec secure connection configure */
12252 cmdline_parse_token_string_t cmd_macsec_sa_set =
12253 TOKEN_STRING_INITIALIZER
12254 (struct cmd_macsec_sa_result,
12256 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12257 TOKEN_STRING_INITIALIZER
12258 (struct cmd_macsec_sa_result,
12260 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12261 TOKEN_STRING_INITIALIZER
12262 (struct cmd_macsec_sa_result,
12264 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12265 TOKEN_STRING_INITIALIZER
12266 (struct cmd_macsec_sa_result,
12268 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12269 TOKEN_NUM_INITIALIZER
12270 (struct cmd_macsec_sa_result,
12271 port_id, RTE_UINT16);
12272 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12273 TOKEN_NUM_INITIALIZER
12274 (struct cmd_macsec_sa_result,
12276 cmdline_parse_token_num_t cmd_macsec_sa_an =
12277 TOKEN_NUM_INITIALIZER
12278 (struct cmd_macsec_sa_result,
12280 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12281 TOKEN_NUM_INITIALIZER
12282 (struct cmd_macsec_sa_result,
12284 cmdline_parse_token_string_t cmd_macsec_sa_key =
12285 TOKEN_STRING_INITIALIZER
12286 (struct cmd_macsec_sa_result,
12290 cmd_set_macsec_sa_parsed(
12291 void *parsed_result,
12292 __rte_unused struct cmdline *cl,
12293 __rte_unused void *data)
12295 struct cmd_macsec_sa_result *res = parsed_result;
12296 int ret = -ENOTSUP;
12297 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12298 uint8_t key[16] = { 0 };
12304 key_len = strlen(res->key) / 2;
12308 for (i = 0; i < key_len; i++) {
12309 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12312 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12315 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12318 #ifdef RTE_NET_IXGBE
12320 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12321 res->idx, res->an, res->pn, key) :
12322 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12323 res->idx, res->an, res->pn, key);
12325 RTE_SET_USED(is_tx);
12332 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12335 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12338 fprintf(stderr, "not supported on port %d\n", res->port_id);
12341 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12345 cmdline_parse_inst_t cmd_set_macsec_sa = {
12346 .f = cmd_set_macsec_sa_parsed,
12348 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12350 (void *)&cmd_macsec_sa_set,
12351 (void *)&cmd_macsec_sa_macsec,
12352 (void *)&cmd_macsec_sa_sa,
12353 (void *)&cmd_macsec_sa_tx_rx,
12354 (void *)&cmd_macsec_sa_port_id,
12355 (void *)&cmd_macsec_sa_idx,
12356 (void *)&cmd_macsec_sa_an,
12357 (void *)&cmd_macsec_sa_pn,
12358 (void *)&cmd_macsec_sa_key,
12363 /* VF unicast promiscuous mode configuration */
12365 /* Common result structure for VF unicast promiscuous mode */
12366 struct cmd_vf_promisc_result {
12367 cmdline_fixed_string_t set;
12368 cmdline_fixed_string_t vf;
12369 cmdline_fixed_string_t promisc;
12372 cmdline_fixed_string_t on_off;
12375 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12376 cmdline_parse_token_string_t cmd_vf_promisc_set =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_vf_promisc_result,
12380 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12381 TOKEN_STRING_INITIALIZER
12382 (struct cmd_vf_promisc_result,
12384 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12385 TOKEN_STRING_INITIALIZER
12386 (struct cmd_vf_promisc_result,
12387 promisc, "promisc");
12388 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12389 TOKEN_NUM_INITIALIZER
12390 (struct cmd_vf_promisc_result,
12391 port_id, RTE_UINT16);
12392 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12393 TOKEN_NUM_INITIALIZER
12394 (struct cmd_vf_promisc_result,
12395 vf_id, RTE_UINT32);
12396 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12397 TOKEN_STRING_INITIALIZER
12398 (struct cmd_vf_promisc_result,
12402 cmd_set_vf_promisc_parsed(
12403 void *parsed_result,
12404 __rte_unused struct cmdline *cl,
12405 __rte_unused void *data)
12407 struct cmd_vf_promisc_result *res = parsed_result;
12408 int ret = -ENOTSUP;
12410 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12412 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12415 #ifdef RTE_NET_I40E
12416 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12417 res->vf_id, is_on);
12424 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12427 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12430 fprintf(stderr, "function not implemented\n");
12433 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12437 cmdline_parse_inst_t cmd_set_vf_promisc = {
12438 .f = cmd_set_vf_promisc_parsed,
12440 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12441 "Set unicast promiscuous mode for a VF from the PF",
12443 (void *)&cmd_vf_promisc_set,
12444 (void *)&cmd_vf_promisc_vf,
12445 (void *)&cmd_vf_promisc_promisc,
12446 (void *)&cmd_vf_promisc_port_id,
12447 (void *)&cmd_vf_promisc_vf_id,
12448 (void *)&cmd_vf_promisc_on_off,
12453 /* VF multicast promiscuous mode configuration */
12455 /* Common result structure for VF multicast promiscuous mode */
12456 struct cmd_vf_allmulti_result {
12457 cmdline_fixed_string_t set;
12458 cmdline_fixed_string_t vf;
12459 cmdline_fixed_string_t allmulti;
12462 cmdline_fixed_string_t on_off;
12465 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12466 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12467 TOKEN_STRING_INITIALIZER
12468 (struct cmd_vf_allmulti_result,
12470 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12471 TOKEN_STRING_INITIALIZER
12472 (struct cmd_vf_allmulti_result,
12474 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12475 TOKEN_STRING_INITIALIZER
12476 (struct cmd_vf_allmulti_result,
12477 allmulti, "allmulti");
12478 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12479 TOKEN_NUM_INITIALIZER
12480 (struct cmd_vf_allmulti_result,
12481 port_id, RTE_UINT16);
12482 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12483 TOKEN_NUM_INITIALIZER
12484 (struct cmd_vf_allmulti_result,
12485 vf_id, RTE_UINT32);
12486 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12487 TOKEN_STRING_INITIALIZER
12488 (struct cmd_vf_allmulti_result,
12492 cmd_set_vf_allmulti_parsed(
12493 void *parsed_result,
12494 __rte_unused struct cmdline *cl,
12495 __rte_unused void *data)
12497 struct cmd_vf_allmulti_result *res = parsed_result;
12498 int ret = -ENOTSUP;
12500 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12502 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12505 #ifdef RTE_NET_I40E
12506 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12507 res->vf_id, is_on);
12514 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12517 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12520 fprintf(stderr, "function not implemented\n");
12523 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12527 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12528 .f = cmd_set_vf_allmulti_parsed,
12530 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12531 "Set multicast promiscuous mode for a VF from the PF",
12533 (void *)&cmd_vf_allmulti_set,
12534 (void *)&cmd_vf_allmulti_vf,
12535 (void *)&cmd_vf_allmulti_allmulti,
12536 (void *)&cmd_vf_allmulti_port_id,
12537 (void *)&cmd_vf_allmulti_vf_id,
12538 (void *)&cmd_vf_allmulti_on_off,
12543 /* vf broadcast mode configuration */
12545 /* Common result structure for vf broadcast */
12546 struct cmd_set_vf_broadcast_result {
12547 cmdline_fixed_string_t set;
12548 cmdline_fixed_string_t vf;
12549 cmdline_fixed_string_t broadcast;
12552 cmdline_fixed_string_t on_off;
12555 /* Common CLI fields for vf broadcast enable disable */
12556 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12557 TOKEN_STRING_INITIALIZER
12558 (struct cmd_set_vf_broadcast_result,
12560 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12561 TOKEN_STRING_INITIALIZER
12562 (struct cmd_set_vf_broadcast_result,
12564 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12565 TOKEN_STRING_INITIALIZER
12566 (struct cmd_set_vf_broadcast_result,
12567 broadcast, "broadcast");
12568 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12569 TOKEN_NUM_INITIALIZER
12570 (struct cmd_set_vf_broadcast_result,
12571 port_id, RTE_UINT16);
12572 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12573 TOKEN_NUM_INITIALIZER
12574 (struct cmd_set_vf_broadcast_result,
12575 vf_id, RTE_UINT16);
12576 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12577 TOKEN_STRING_INITIALIZER
12578 (struct cmd_set_vf_broadcast_result,
12582 cmd_set_vf_broadcast_parsed(
12583 void *parsed_result,
12584 __rte_unused struct cmdline *cl,
12585 __rte_unused void *data)
12587 struct cmd_set_vf_broadcast_result *res = parsed_result;
12588 int ret = -ENOTSUP;
12590 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12592 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12595 #ifdef RTE_NET_I40E
12596 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12597 res->vf_id, is_on);
12604 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12605 res->vf_id, is_on);
12608 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12611 fprintf(stderr, "function not implemented\n");
12614 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12618 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12619 .f = cmd_set_vf_broadcast_parsed,
12621 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12623 (void *)&cmd_set_vf_broadcast_set,
12624 (void *)&cmd_set_vf_broadcast_vf,
12625 (void *)&cmd_set_vf_broadcast_broadcast,
12626 (void *)&cmd_set_vf_broadcast_port_id,
12627 (void *)&cmd_set_vf_broadcast_vf_id,
12628 (void *)&cmd_set_vf_broadcast_on_off,
12633 /* vf vlan tag configuration */
12635 /* Common result structure for vf vlan tag */
12636 struct cmd_set_vf_vlan_tag_result {
12637 cmdline_fixed_string_t set;
12638 cmdline_fixed_string_t vf;
12639 cmdline_fixed_string_t vlan;
12640 cmdline_fixed_string_t tag;
12643 cmdline_fixed_string_t on_off;
12646 /* Common CLI fields for vf vlan tag enable disable */
12647 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12648 TOKEN_STRING_INITIALIZER
12649 (struct cmd_set_vf_vlan_tag_result,
12651 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12652 TOKEN_STRING_INITIALIZER
12653 (struct cmd_set_vf_vlan_tag_result,
12655 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12656 TOKEN_STRING_INITIALIZER
12657 (struct cmd_set_vf_vlan_tag_result,
12659 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12660 TOKEN_STRING_INITIALIZER
12661 (struct cmd_set_vf_vlan_tag_result,
12663 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12664 TOKEN_NUM_INITIALIZER
12665 (struct cmd_set_vf_vlan_tag_result,
12666 port_id, RTE_UINT16);
12667 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12668 TOKEN_NUM_INITIALIZER
12669 (struct cmd_set_vf_vlan_tag_result,
12670 vf_id, RTE_UINT16);
12671 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12672 TOKEN_STRING_INITIALIZER
12673 (struct cmd_set_vf_vlan_tag_result,
12677 cmd_set_vf_vlan_tag_parsed(
12678 void *parsed_result,
12679 __rte_unused struct cmdline *cl,
12680 __rte_unused void *data)
12682 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12683 int ret = -ENOTSUP;
12685 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12687 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12690 #ifdef RTE_NET_I40E
12691 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12692 res->vf_id, is_on);
12699 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12700 res->vf_id, is_on);
12703 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12706 fprintf(stderr, "function not implemented\n");
12709 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12713 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12714 .f = cmd_set_vf_vlan_tag_parsed,
12716 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12718 (void *)&cmd_set_vf_vlan_tag_set,
12719 (void *)&cmd_set_vf_vlan_tag_vf,
12720 (void *)&cmd_set_vf_vlan_tag_vlan,
12721 (void *)&cmd_set_vf_vlan_tag_tag,
12722 (void *)&cmd_set_vf_vlan_tag_port_id,
12723 (void *)&cmd_set_vf_vlan_tag_vf_id,
12724 (void *)&cmd_set_vf_vlan_tag_on_off,
12729 /* Common definition of VF and TC TX bandwidth configuration */
12730 struct cmd_vf_tc_bw_result {
12731 cmdline_fixed_string_t set;
12732 cmdline_fixed_string_t vf;
12733 cmdline_fixed_string_t tc;
12734 cmdline_fixed_string_t tx;
12735 cmdline_fixed_string_t min_bw;
12736 cmdline_fixed_string_t max_bw;
12737 cmdline_fixed_string_t strict_link_prio;
12742 cmdline_fixed_string_t bw_list;
12746 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12747 TOKEN_STRING_INITIALIZER
12748 (struct cmd_vf_tc_bw_result,
12750 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12751 TOKEN_STRING_INITIALIZER
12752 (struct cmd_vf_tc_bw_result,
12754 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12755 TOKEN_STRING_INITIALIZER
12756 (struct cmd_vf_tc_bw_result,
12758 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12759 TOKEN_STRING_INITIALIZER
12760 (struct cmd_vf_tc_bw_result,
12762 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12763 TOKEN_STRING_INITIALIZER
12764 (struct cmd_vf_tc_bw_result,
12765 strict_link_prio, "strict-link-priority");
12766 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12767 TOKEN_STRING_INITIALIZER
12768 (struct cmd_vf_tc_bw_result,
12769 min_bw, "min-bandwidth");
12770 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12771 TOKEN_STRING_INITIALIZER
12772 (struct cmd_vf_tc_bw_result,
12773 max_bw, "max-bandwidth");
12774 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12775 TOKEN_NUM_INITIALIZER
12776 (struct cmd_vf_tc_bw_result,
12777 port_id, RTE_UINT16);
12778 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12779 TOKEN_NUM_INITIALIZER
12780 (struct cmd_vf_tc_bw_result,
12781 vf_id, RTE_UINT16);
12782 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12783 TOKEN_NUM_INITIALIZER
12784 (struct cmd_vf_tc_bw_result,
12786 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12787 TOKEN_NUM_INITIALIZER
12788 (struct cmd_vf_tc_bw_result,
12790 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12791 TOKEN_STRING_INITIALIZER
12792 (struct cmd_vf_tc_bw_result,
12794 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12795 TOKEN_NUM_INITIALIZER
12796 (struct cmd_vf_tc_bw_result,
12797 tc_map, RTE_UINT8);
12799 /* VF max bandwidth setting */
12801 cmd_vf_max_bw_parsed(
12802 void *parsed_result,
12803 __rte_unused struct cmdline *cl,
12804 __rte_unused void *data)
12806 struct cmd_vf_tc_bw_result *res = parsed_result;
12807 int ret = -ENOTSUP;
12809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12812 #ifdef RTE_NET_I40E
12813 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12814 res->vf_id, res->bw);
12821 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12822 res->vf_id, res->bw);
12825 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12828 fprintf(stderr, "function not implemented\n");
12831 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12835 cmdline_parse_inst_t cmd_vf_max_bw = {
12836 .f = cmd_vf_max_bw_parsed,
12838 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12840 (void *)&cmd_vf_tc_bw_set,
12841 (void *)&cmd_vf_tc_bw_vf,
12842 (void *)&cmd_vf_tc_bw_tx,
12843 (void *)&cmd_vf_tc_bw_max_bw,
12844 (void *)&cmd_vf_tc_bw_port_id,
12845 (void *)&cmd_vf_tc_bw_vf_id,
12846 (void *)&cmd_vf_tc_bw_bw,
12852 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12857 const char *p, *p0 = str;
12864 p = strchr(p0, '(');
12867 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12871 p0 = strchr(p, ')');
12874 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12878 if (size >= sizeof(s)) {
12880 "The string size exceeds the internal buffer size\n");
12883 snprintf(s, sizeof(s), "%.*s", size, p);
12884 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12886 fprintf(stderr, "Failed to get the bandwidth list.\n");
12890 for (i = 0; i < ret; i++)
12891 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12896 /* TC min bandwidth setting */
12898 cmd_vf_tc_min_bw_parsed(
12899 void *parsed_result,
12900 __rte_unused struct cmdline *cl,
12901 __rte_unused void *data)
12903 struct cmd_vf_tc_bw_result *res = parsed_result;
12906 int ret = -ENOTSUP;
12908 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12911 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12915 #ifdef RTE_NET_I40E
12916 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12924 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12927 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12930 fprintf(stderr, "function not implemented\n");
12933 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12937 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12938 .f = cmd_vf_tc_min_bw_parsed,
12940 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12941 " <bw1, bw2, ...>",
12943 (void *)&cmd_vf_tc_bw_set,
12944 (void *)&cmd_vf_tc_bw_vf,
12945 (void *)&cmd_vf_tc_bw_tc,
12946 (void *)&cmd_vf_tc_bw_tx,
12947 (void *)&cmd_vf_tc_bw_min_bw,
12948 (void *)&cmd_vf_tc_bw_port_id,
12949 (void *)&cmd_vf_tc_bw_vf_id,
12950 (void *)&cmd_vf_tc_bw_bw_list,
12956 cmd_tc_min_bw_parsed(
12957 void *parsed_result,
12958 __rte_unused struct cmdline *cl,
12959 __rte_unused void *data)
12961 struct cmd_vf_tc_bw_result *res = parsed_result;
12962 struct rte_port *port;
12965 int ret = -ENOTSUP;
12967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12970 port = &ports[res->port_id];
12971 /** Check if the port is not started **/
12972 if (port->port_status != RTE_PORT_STOPPED) {
12973 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12977 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12981 #ifdef RTE_NET_IXGBE
12982 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12989 fprintf(stderr, "invalid bandwidth\n");
12992 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12995 fprintf(stderr, "function not implemented\n");
12998 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13002 cmdline_parse_inst_t cmd_tc_min_bw = {
13003 .f = cmd_tc_min_bw_parsed,
13005 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13007 (void *)&cmd_vf_tc_bw_set,
13008 (void *)&cmd_vf_tc_bw_tc,
13009 (void *)&cmd_vf_tc_bw_tx,
13010 (void *)&cmd_vf_tc_bw_min_bw,
13011 (void *)&cmd_vf_tc_bw_port_id,
13012 (void *)&cmd_vf_tc_bw_bw_list,
13017 /* TC max bandwidth setting */
13019 cmd_vf_tc_max_bw_parsed(
13020 void *parsed_result,
13021 __rte_unused struct cmdline *cl,
13022 __rte_unused void *data)
13024 struct cmd_vf_tc_bw_result *res = parsed_result;
13025 int ret = -ENOTSUP;
13027 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13030 #ifdef RTE_NET_I40E
13031 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13032 res->tc_no, res->bw);
13040 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
13041 res->vf_id, res->tc_no, res->bw);
13044 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13047 fprintf(stderr, "function not implemented\n");
13050 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13054 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13055 .f = cmd_vf_tc_max_bw_parsed,
13057 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13060 (void *)&cmd_vf_tc_bw_set,
13061 (void *)&cmd_vf_tc_bw_vf,
13062 (void *)&cmd_vf_tc_bw_tc,
13063 (void *)&cmd_vf_tc_bw_tx,
13064 (void *)&cmd_vf_tc_bw_max_bw,
13065 (void *)&cmd_vf_tc_bw_port_id,
13066 (void *)&cmd_vf_tc_bw_vf_id,
13067 (void *)&cmd_vf_tc_bw_tc_no,
13068 (void *)&cmd_vf_tc_bw_bw,
13073 /** Set VXLAN encapsulation details */
13074 struct cmd_set_vxlan_result {
13075 cmdline_fixed_string_t set;
13076 cmdline_fixed_string_t vxlan;
13077 cmdline_fixed_string_t pos_token;
13078 cmdline_fixed_string_t ip_version;
13079 uint32_t vlan_present:1;
13083 cmdline_ipaddr_t ip_src;
13084 cmdline_ipaddr_t ip_dst;
13088 struct rte_ether_addr eth_src;
13089 struct rte_ether_addr eth_dst;
13092 cmdline_parse_token_string_t cmd_set_vxlan_set =
13093 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
13094 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
13095 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
13096 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
13097 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13099 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
13100 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13101 "vxlan-with-vlan");
13102 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
13103 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13105 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
13106 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
13108 cmdline_parse_token_string_t cmd_set_vxlan_vni =
13109 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13111 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
13112 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
13113 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
13114 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13116 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
13117 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
13118 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
13119 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13121 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
13122 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
13123 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13124 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13126 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13127 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
13128 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13129 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13131 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13132 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
13133 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13134 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13136 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13137 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13138 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13139 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13141 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13142 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13143 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13144 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13146 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13147 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13148 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13149 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13151 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13152 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13153 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13154 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13156 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13157 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13159 static void cmd_set_vxlan_parsed(void *parsed_result,
13160 __rte_unused struct cmdline *cl,
13161 __rte_unused void *data)
13163 struct cmd_set_vxlan_result *res = parsed_result;
13168 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13171 vxlan_encap_conf.select_tos_ttl = 0;
13172 if (strcmp(res->vxlan, "vxlan") == 0)
13173 vxlan_encap_conf.select_vlan = 0;
13174 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13175 vxlan_encap_conf.select_vlan = 1;
13176 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13177 vxlan_encap_conf.select_vlan = 0;
13178 vxlan_encap_conf.select_tos_ttl = 1;
13180 if (strcmp(res->ip_version, "ipv4") == 0)
13181 vxlan_encap_conf.select_ipv4 = 1;
13182 else if (strcmp(res->ip_version, "ipv6") == 0)
13183 vxlan_encap_conf.select_ipv4 = 0;
13186 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13187 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13188 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13189 vxlan_encap_conf.ip_tos = res->tos;
13190 vxlan_encap_conf.ip_ttl = res->ttl;
13191 if (vxlan_encap_conf.select_ipv4) {
13192 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13193 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13195 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13196 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13198 if (vxlan_encap_conf.select_vlan)
13199 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13200 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13201 RTE_ETHER_ADDR_LEN);
13202 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13203 RTE_ETHER_ADDR_LEN);
13206 cmdline_parse_inst_t cmd_set_vxlan = {
13207 .f = cmd_set_vxlan_parsed,
13209 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13210 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13211 " eth-src <eth-src> eth-dst <eth-dst>",
13213 (void *)&cmd_set_vxlan_set,
13214 (void *)&cmd_set_vxlan_vxlan,
13215 (void *)&cmd_set_vxlan_ip_version,
13216 (void *)&cmd_set_vxlan_ip_version_value,
13217 (void *)&cmd_set_vxlan_vni,
13218 (void *)&cmd_set_vxlan_vni_value,
13219 (void *)&cmd_set_vxlan_udp_src,
13220 (void *)&cmd_set_vxlan_udp_src_value,
13221 (void *)&cmd_set_vxlan_udp_dst,
13222 (void *)&cmd_set_vxlan_udp_dst_value,
13223 (void *)&cmd_set_vxlan_ip_src,
13224 (void *)&cmd_set_vxlan_ip_src_value,
13225 (void *)&cmd_set_vxlan_ip_dst,
13226 (void *)&cmd_set_vxlan_ip_dst_value,
13227 (void *)&cmd_set_vxlan_eth_src,
13228 (void *)&cmd_set_vxlan_eth_src_value,
13229 (void *)&cmd_set_vxlan_eth_dst,
13230 (void *)&cmd_set_vxlan_eth_dst_value,
13235 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13236 .f = cmd_set_vxlan_parsed,
13238 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13239 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13240 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13241 " eth-dst <eth-dst>",
13243 (void *)&cmd_set_vxlan_set,
13244 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13245 (void *)&cmd_set_vxlan_ip_version,
13246 (void *)&cmd_set_vxlan_ip_version_value,
13247 (void *)&cmd_set_vxlan_vni,
13248 (void *)&cmd_set_vxlan_vni_value,
13249 (void *)&cmd_set_vxlan_udp_src,
13250 (void *)&cmd_set_vxlan_udp_src_value,
13251 (void *)&cmd_set_vxlan_udp_dst,
13252 (void *)&cmd_set_vxlan_udp_dst_value,
13253 (void *)&cmd_set_vxlan_ip_tos,
13254 (void *)&cmd_set_vxlan_ip_tos_value,
13255 (void *)&cmd_set_vxlan_ip_ttl,
13256 (void *)&cmd_set_vxlan_ip_ttl_value,
13257 (void *)&cmd_set_vxlan_ip_src,
13258 (void *)&cmd_set_vxlan_ip_src_value,
13259 (void *)&cmd_set_vxlan_ip_dst,
13260 (void *)&cmd_set_vxlan_ip_dst_value,
13261 (void *)&cmd_set_vxlan_eth_src,
13262 (void *)&cmd_set_vxlan_eth_src_value,
13263 (void *)&cmd_set_vxlan_eth_dst,
13264 (void *)&cmd_set_vxlan_eth_dst_value,
13269 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13270 .f = cmd_set_vxlan_parsed,
13272 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13273 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13274 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13277 (void *)&cmd_set_vxlan_set,
13278 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13279 (void *)&cmd_set_vxlan_ip_version,
13280 (void *)&cmd_set_vxlan_ip_version_value,
13281 (void *)&cmd_set_vxlan_vni,
13282 (void *)&cmd_set_vxlan_vni_value,
13283 (void *)&cmd_set_vxlan_udp_src,
13284 (void *)&cmd_set_vxlan_udp_src_value,
13285 (void *)&cmd_set_vxlan_udp_dst,
13286 (void *)&cmd_set_vxlan_udp_dst_value,
13287 (void *)&cmd_set_vxlan_ip_src,
13288 (void *)&cmd_set_vxlan_ip_src_value,
13289 (void *)&cmd_set_vxlan_ip_dst,
13290 (void *)&cmd_set_vxlan_ip_dst_value,
13291 (void *)&cmd_set_vxlan_vlan,
13292 (void *)&cmd_set_vxlan_vlan_value,
13293 (void *)&cmd_set_vxlan_eth_src,
13294 (void *)&cmd_set_vxlan_eth_src_value,
13295 (void *)&cmd_set_vxlan_eth_dst,
13296 (void *)&cmd_set_vxlan_eth_dst_value,
13301 /** Set NVGRE encapsulation details */
13302 struct cmd_set_nvgre_result {
13303 cmdline_fixed_string_t set;
13304 cmdline_fixed_string_t nvgre;
13305 cmdline_fixed_string_t pos_token;
13306 cmdline_fixed_string_t ip_version;
13308 cmdline_ipaddr_t ip_src;
13309 cmdline_ipaddr_t ip_dst;
13311 struct rte_ether_addr eth_src;
13312 struct rte_ether_addr eth_dst;
13315 cmdline_parse_token_string_t cmd_set_nvgre_set =
13316 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13317 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13318 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13319 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13320 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13321 "nvgre-with-vlan");
13322 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13323 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13325 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13326 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13328 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13329 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13331 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13332 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13333 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13334 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13336 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13337 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13338 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13339 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13341 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13342 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13343 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13344 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13346 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13347 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13348 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13349 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13351 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13352 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13353 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13354 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13356 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13357 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13359 static void cmd_set_nvgre_parsed(void *parsed_result,
13360 __rte_unused struct cmdline *cl,
13361 __rte_unused void *data)
13363 struct cmd_set_nvgre_result *res = parsed_result;
13365 uint32_t nvgre_tni;
13368 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13371 if (strcmp(res->nvgre, "nvgre") == 0)
13372 nvgre_encap_conf.select_vlan = 0;
13373 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13374 nvgre_encap_conf.select_vlan = 1;
13375 if (strcmp(res->ip_version, "ipv4") == 0)
13376 nvgre_encap_conf.select_ipv4 = 1;
13377 else if (strcmp(res->ip_version, "ipv6") == 0)
13378 nvgre_encap_conf.select_ipv4 = 0;
13381 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13382 if (nvgre_encap_conf.select_ipv4) {
13383 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13384 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13386 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13387 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13389 if (nvgre_encap_conf.select_vlan)
13390 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13391 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13392 RTE_ETHER_ADDR_LEN);
13393 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13394 RTE_ETHER_ADDR_LEN);
13397 cmdline_parse_inst_t cmd_set_nvgre = {
13398 .f = cmd_set_nvgre_parsed,
13400 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13401 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13402 " eth-dst <eth-dst>",
13404 (void *)&cmd_set_nvgre_set,
13405 (void *)&cmd_set_nvgre_nvgre,
13406 (void *)&cmd_set_nvgre_ip_version,
13407 (void *)&cmd_set_nvgre_ip_version_value,
13408 (void *)&cmd_set_nvgre_tni,
13409 (void *)&cmd_set_nvgre_tni_value,
13410 (void *)&cmd_set_nvgre_ip_src,
13411 (void *)&cmd_set_nvgre_ip_src_value,
13412 (void *)&cmd_set_nvgre_ip_dst,
13413 (void *)&cmd_set_nvgre_ip_dst_value,
13414 (void *)&cmd_set_nvgre_eth_src,
13415 (void *)&cmd_set_nvgre_eth_src_value,
13416 (void *)&cmd_set_nvgre_eth_dst,
13417 (void *)&cmd_set_nvgre_eth_dst_value,
13422 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13423 .f = cmd_set_nvgre_parsed,
13425 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13426 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13427 " eth-src <eth-src> eth-dst <eth-dst>",
13429 (void *)&cmd_set_nvgre_set,
13430 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13431 (void *)&cmd_set_nvgre_ip_version,
13432 (void *)&cmd_set_nvgre_ip_version_value,
13433 (void *)&cmd_set_nvgre_tni,
13434 (void *)&cmd_set_nvgre_tni_value,
13435 (void *)&cmd_set_nvgre_ip_src,
13436 (void *)&cmd_set_nvgre_ip_src_value,
13437 (void *)&cmd_set_nvgre_ip_dst,
13438 (void *)&cmd_set_nvgre_ip_dst_value,
13439 (void *)&cmd_set_nvgre_vlan,
13440 (void *)&cmd_set_nvgre_vlan_value,
13441 (void *)&cmd_set_nvgre_eth_src,
13442 (void *)&cmd_set_nvgre_eth_src_value,
13443 (void *)&cmd_set_nvgre_eth_dst,
13444 (void *)&cmd_set_nvgre_eth_dst_value,
13449 /** Set L2 encapsulation details */
13450 struct cmd_set_l2_encap_result {
13451 cmdline_fixed_string_t set;
13452 cmdline_fixed_string_t l2_encap;
13453 cmdline_fixed_string_t pos_token;
13454 cmdline_fixed_string_t ip_version;
13455 uint32_t vlan_present:1;
13457 struct rte_ether_addr eth_src;
13458 struct rte_ether_addr eth_dst;
13461 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13462 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13463 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13464 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13465 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13466 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13467 "l2_encap-with-vlan");
13468 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13469 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13471 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13472 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13474 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13475 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13477 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13478 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13479 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13480 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13482 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13483 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13484 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13485 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13487 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13488 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13490 static void cmd_set_l2_encap_parsed(void *parsed_result,
13491 __rte_unused struct cmdline *cl,
13492 __rte_unused void *data)
13494 struct cmd_set_l2_encap_result *res = parsed_result;
13496 if (strcmp(res->l2_encap, "l2_encap") == 0)
13497 l2_encap_conf.select_vlan = 0;
13498 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13499 l2_encap_conf.select_vlan = 1;
13500 if (strcmp(res->ip_version, "ipv4") == 0)
13501 l2_encap_conf.select_ipv4 = 1;
13502 else if (strcmp(res->ip_version, "ipv6") == 0)
13503 l2_encap_conf.select_ipv4 = 0;
13506 if (l2_encap_conf.select_vlan)
13507 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13508 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13509 RTE_ETHER_ADDR_LEN);
13510 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13511 RTE_ETHER_ADDR_LEN);
13514 cmdline_parse_inst_t cmd_set_l2_encap = {
13515 .f = cmd_set_l2_encap_parsed,
13517 .help_str = "set l2_encap ip-version ipv4|ipv6"
13518 " eth-src <eth-src> eth-dst <eth-dst>",
13520 (void *)&cmd_set_l2_encap_set,
13521 (void *)&cmd_set_l2_encap_l2_encap,
13522 (void *)&cmd_set_l2_encap_ip_version,
13523 (void *)&cmd_set_l2_encap_ip_version_value,
13524 (void *)&cmd_set_l2_encap_eth_src,
13525 (void *)&cmd_set_l2_encap_eth_src_value,
13526 (void *)&cmd_set_l2_encap_eth_dst,
13527 (void *)&cmd_set_l2_encap_eth_dst_value,
13532 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13533 .f = cmd_set_l2_encap_parsed,
13535 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13536 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13538 (void *)&cmd_set_l2_encap_set,
13539 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13540 (void *)&cmd_set_l2_encap_ip_version,
13541 (void *)&cmd_set_l2_encap_ip_version_value,
13542 (void *)&cmd_set_l2_encap_vlan,
13543 (void *)&cmd_set_l2_encap_vlan_value,
13544 (void *)&cmd_set_l2_encap_eth_src,
13545 (void *)&cmd_set_l2_encap_eth_src_value,
13546 (void *)&cmd_set_l2_encap_eth_dst,
13547 (void *)&cmd_set_l2_encap_eth_dst_value,
13552 /** Set L2 decapsulation details */
13553 struct cmd_set_l2_decap_result {
13554 cmdline_fixed_string_t set;
13555 cmdline_fixed_string_t l2_decap;
13556 cmdline_fixed_string_t pos_token;
13557 uint32_t vlan_present:1;
13560 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13561 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13562 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13563 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13565 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13566 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13567 "l2_decap-with-vlan");
13569 static void cmd_set_l2_decap_parsed(void *parsed_result,
13570 __rte_unused struct cmdline *cl,
13571 __rte_unused void *data)
13573 struct cmd_set_l2_decap_result *res = parsed_result;
13575 if (strcmp(res->l2_decap, "l2_decap") == 0)
13576 l2_decap_conf.select_vlan = 0;
13577 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13578 l2_decap_conf.select_vlan = 1;
13581 cmdline_parse_inst_t cmd_set_l2_decap = {
13582 .f = cmd_set_l2_decap_parsed,
13584 .help_str = "set l2_decap",
13586 (void *)&cmd_set_l2_decap_set,
13587 (void *)&cmd_set_l2_decap_l2_decap,
13592 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13593 .f = cmd_set_l2_decap_parsed,
13595 .help_str = "set l2_decap-with-vlan",
13597 (void *)&cmd_set_l2_decap_set,
13598 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13603 /** Set MPLSoGRE encapsulation details */
13604 struct cmd_set_mplsogre_encap_result {
13605 cmdline_fixed_string_t set;
13606 cmdline_fixed_string_t mplsogre;
13607 cmdline_fixed_string_t pos_token;
13608 cmdline_fixed_string_t ip_version;
13609 uint32_t vlan_present:1;
13611 cmdline_ipaddr_t ip_src;
13612 cmdline_ipaddr_t ip_dst;
13614 struct rte_ether_addr eth_src;
13615 struct rte_ether_addr eth_dst;
13618 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13619 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13621 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13622 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13624 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13625 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13626 mplsogre, "mplsogre_encap-with-vlan");
13627 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13628 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13629 pos_token, "ip-version");
13630 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13631 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13632 ip_version, "ipv4#ipv6");
13633 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13634 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13635 pos_token, "label");
13636 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13637 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13639 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13640 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13641 pos_token, "ip-src");
13642 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13643 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13644 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13645 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13646 pos_token, "ip-dst");
13647 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13648 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13649 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13650 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13651 pos_token, "vlan-tci");
13652 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13653 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13655 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13656 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13657 pos_token, "eth-src");
13658 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13659 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13661 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13662 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13663 pos_token, "eth-dst");
13664 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13665 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13668 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13669 __rte_unused struct cmdline *cl,
13670 __rte_unused void *data)
13672 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13674 uint32_t mplsogre_label;
13677 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13680 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13681 mplsogre_encap_conf.select_vlan = 0;
13682 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13683 mplsogre_encap_conf.select_vlan = 1;
13684 if (strcmp(res->ip_version, "ipv4") == 0)
13685 mplsogre_encap_conf.select_ipv4 = 1;
13686 else if (strcmp(res->ip_version, "ipv6") == 0)
13687 mplsogre_encap_conf.select_ipv4 = 0;
13690 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13691 if (mplsogre_encap_conf.select_ipv4) {
13692 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13693 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13695 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13696 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13698 if (mplsogre_encap_conf.select_vlan)
13699 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13700 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13701 RTE_ETHER_ADDR_LEN);
13702 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13703 RTE_ETHER_ADDR_LEN);
13706 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13707 .f = cmd_set_mplsogre_encap_parsed,
13709 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13710 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13711 " eth-dst <eth-dst>",
13713 (void *)&cmd_set_mplsogre_encap_set,
13714 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13715 (void *)&cmd_set_mplsogre_encap_ip_version,
13716 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13717 (void *)&cmd_set_mplsogre_encap_label,
13718 (void *)&cmd_set_mplsogre_encap_label_value,
13719 (void *)&cmd_set_mplsogre_encap_ip_src,
13720 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13721 (void *)&cmd_set_mplsogre_encap_ip_dst,
13722 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13723 (void *)&cmd_set_mplsogre_encap_eth_src,
13724 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13725 (void *)&cmd_set_mplsogre_encap_eth_dst,
13726 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13731 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13732 .f = cmd_set_mplsogre_encap_parsed,
13734 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13735 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13736 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13738 (void *)&cmd_set_mplsogre_encap_set,
13739 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13740 (void *)&cmd_set_mplsogre_encap_ip_version,
13741 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13742 (void *)&cmd_set_mplsogre_encap_label,
13743 (void *)&cmd_set_mplsogre_encap_label_value,
13744 (void *)&cmd_set_mplsogre_encap_ip_src,
13745 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13746 (void *)&cmd_set_mplsogre_encap_ip_dst,
13747 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13748 (void *)&cmd_set_mplsogre_encap_vlan,
13749 (void *)&cmd_set_mplsogre_encap_vlan_value,
13750 (void *)&cmd_set_mplsogre_encap_eth_src,
13751 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13752 (void *)&cmd_set_mplsogre_encap_eth_dst,
13753 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13758 /** Set MPLSoGRE decapsulation details */
13759 struct cmd_set_mplsogre_decap_result {
13760 cmdline_fixed_string_t set;
13761 cmdline_fixed_string_t mplsogre;
13762 cmdline_fixed_string_t pos_token;
13763 cmdline_fixed_string_t ip_version;
13764 uint32_t vlan_present:1;
13767 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13768 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13770 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13771 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13773 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13774 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13775 mplsogre, "mplsogre_decap-with-vlan");
13776 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13777 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13778 pos_token, "ip-version");
13779 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13780 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13781 ip_version, "ipv4#ipv6");
13783 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13784 __rte_unused struct cmdline *cl,
13785 __rte_unused void *data)
13787 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13789 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13790 mplsogre_decap_conf.select_vlan = 0;
13791 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13792 mplsogre_decap_conf.select_vlan = 1;
13793 if (strcmp(res->ip_version, "ipv4") == 0)
13794 mplsogre_decap_conf.select_ipv4 = 1;
13795 else if (strcmp(res->ip_version, "ipv6") == 0)
13796 mplsogre_decap_conf.select_ipv4 = 0;
13799 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13800 .f = cmd_set_mplsogre_decap_parsed,
13802 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13804 (void *)&cmd_set_mplsogre_decap_set,
13805 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13806 (void *)&cmd_set_mplsogre_decap_ip_version,
13807 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13812 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13813 .f = cmd_set_mplsogre_decap_parsed,
13815 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13817 (void *)&cmd_set_mplsogre_decap_set,
13818 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13819 (void *)&cmd_set_mplsogre_decap_ip_version,
13820 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13825 /** Set MPLSoUDP encapsulation details */
13826 struct cmd_set_mplsoudp_encap_result {
13827 cmdline_fixed_string_t set;
13828 cmdline_fixed_string_t mplsoudp;
13829 cmdline_fixed_string_t pos_token;
13830 cmdline_fixed_string_t ip_version;
13831 uint32_t vlan_present:1;
13835 cmdline_ipaddr_t ip_src;
13836 cmdline_ipaddr_t ip_dst;
13838 struct rte_ether_addr eth_src;
13839 struct rte_ether_addr eth_dst;
13842 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13843 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13845 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13846 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13848 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13849 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13850 mplsoudp, "mplsoudp_encap-with-vlan");
13851 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13852 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13853 pos_token, "ip-version");
13854 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13855 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13856 ip_version, "ipv4#ipv6");
13857 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13858 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13859 pos_token, "label");
13860 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13861 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13863 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13864 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13865 pos_token, "udp-src");
13866 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13867 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13869 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13870 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13871 pos_token, "udp-dst");
13872 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13873 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13875 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13876 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13877 pos_token, "ip-src");
13878 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13879 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13880 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13881 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13882 pos_token, "ip-dst");
13883 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13884 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13885 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13886 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13887 pos_token, "vlan-tci");
13888 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13889 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13891 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13892 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13893 pos_token, "eth-src");
13894 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13895 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13897 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13898 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13899 pos_token, "eth-dst");
13900 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13901 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13904 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13905 __rte_unused struct cmdline *cl,
13906 __rte_unused void *data)
13908 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13910 uint32_t mplsoudp_label;
13913 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13916 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13917 mplsoudp_encap_conf.select_vlan = 0;
13918 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13919 mplsoudp_encap_conf.select_vlan = 1;
13920 if (strcmp(res->ip_version, "ipv4") == 0)
13921 mplsoudp_encap_conf.select_ipv4 = 1;
13922 else if (strcmp(res->ip_version, "ipv6") == 0)
13923 mplsoudp_encap_conf.select_ipv4 = 0;
13926 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13927 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13928 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13929 if (mplsoudp_encap_conf.select_ipv4) {
13930 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13931 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13933 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13934 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13936 if (mplsoudp_encap_conf.select_vlan)
13937 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13938 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13939 RTE_ETHER_ADDR_LEN);
13940 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13941 RTE_ETHER_ADDR_LEN);
13944 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13945 .f = cmd_set_mplsoudp_encap_parsed,
13947 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13948 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13949 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13951 (void *)&cmd_set_mplsoudp_encap_set,
13952 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13953 (void *)&cmd_set_mplsoudp_encap_ip_version,
13954 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13955 (void *)&cmd_set_mplsoudp_encap_label,
13956 (void *)&cmd_set_mplsoudp_encap_label_value,
13957 (void *)&cmd_set_mplsoudp_encap_udp_src,
13958 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13959 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13960 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13961 (void *)&cmd_set_mplsoudp_encap_ip_src,
13962 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13963 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13964 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13965 (void *)&cmd_set_mplsoudp_encap_eth_src,
13966 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13967 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13968 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13973 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13974 .f = cmd_set_mplsoudp_encap_parsed,
13976 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13977 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13978 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13979 " eth-src <eth-src> eth-dst <eth-dst>",
13981 (void *)&cmd_set_mplsoudp_encap_set,
13982 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13983 (void *)&cmd_set_mplsoudp_encap_ip_version,
13984 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13985 (void *)&cmd_set_mplsoudp_encap_label,
13986 (void *)&cmd_set_mplsoudp_encap_label_value,
13987 (void *)&cmd_set_mplsoudp_encap_udp_src,
13988 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13989 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13990 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13991 (void *)&cmd_set_mplsoudp_encap_ip_src,
13992 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13993 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13994 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13995 (void *)&cmd_set_mplsoudp_encap_vlan,
13996 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13997 (void *)&cmd_set_mplsoudp_encap_eth_src,
13998 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13999 (void *)&cmd_set_mplsoudp_encap_eth_dst,
14000 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14005 /** Set MPLSoUDP decapsulation details */
14006 struct cmd_set_mplsoudp_decap_result {
14007 cmdline_fixed_string_t set;
14008 cmdline_fixed_string_t mplsoudp;
14009 cmdline_fixed_string_t pos_token;
14010 cmdline_fixed_string_t ip_version;
14011 uint32_t vlan_present:1;
14014 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
14015 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
14017 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
14018 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
14020 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
14021 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14022 mplsoudp, "mplsoudp_decap-with-vlan");
14023 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
14024 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14025 pos_token, "ip-version");
14026 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
14027 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14028 ip_version, "ipv4#ipv6");
14030 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
14031 __rte_unused struct cmdline *cl,
14032 __rte_unused void *data)
14034 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
14036 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
14037 mplsoudp_decap_conf.select_vlan = 0;
14038 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
14039 mplsoudp_decap_conf.select_vlan = 1;
14040 if (strcmp(res->ip_version, "ipv4") == 0)
14041 mplsoudp_decap_conf.select_ipv4 = 1;
14042 else if (strcmp(res->ip_version, "ipv6") == 0)
14043 mplsoudp_decap_conf.select_ipv4 = 0;
14046 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
14047 .f = cmd_set_mplsoudp_decap_parsed,
14049 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
14051 (void *)&cmd_set_mplsoudp_decap_set,
14052 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
14053 (void *)&cmd_set_mplsoudp_decap_ip_version,
14054 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14059 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
14060 .f = cmd_set_mplsoudp_decap_parsed,
14062 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
14064 (void *)&cmd_set_mplsoudp_decap_set,
14065 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
14066 (void *)&cmd_set_mplsoudp_decap_ip_version,
14067 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14072 /** Set connection tracking object common details */
14073 struct cmd_set_conntrack_common_result {
14074 cmdline_fixed_string_t set;
14075 cmdline_fixed_string_t conntrack;
14076 cmdline_fixed_string_t common;
14077 cmdline_fixed_string_t peer;
14078 cmdline_fixed_string_t is_orig;
14079 cmdline_fixed_string_t enable;
14080 cmdline_fixed_string_t live;
14081 cmdline_fixed_string_t sack;
14082 cmdline_fixed_string_t cack;
14083 cmdline_fixed_string_t last_dir;
14084 cmdline_fixed_string_t liberal;
14085 cmdline_fixed_string_t state;
14086 cmdline_fixed_string_t max_ack_win;
14087 cmdline_fixed_string_t retrans;
14088 cmdline_fixed_string_t last_win;
14089 cmdline_fixed_string_t last_seq;
14090 cmdline_fixed_string_t last_ack;
14091 cmdline_fixed_string_t last_end;
14092 cmdline_fixed_string_t last_index;
14095 uint16_t peer_port;
14096 uint32_t is_original;
14111 cmdline_parse_token_string_t cmd_set_conntrack_set =
14112 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14114 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
14115 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14116 conntrack, "conntrack");
14117 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
14118 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14120 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
14121 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14123 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
14124 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14125 peer_port, RTE_UINT16);
14126 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
14127 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14128 is_orig, "is_orig");
14129 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
14130 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14131 is_original, RTE_UINT32);
14132 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
14133 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14135 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14136 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14138 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14139 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14141 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14142 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14143 is_live, RTE_UINT32);
14144 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14145 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14147 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14148 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14149 s_ack, RTE_UINT32);
14150 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14151 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14153 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14154 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14155 c_ack, RTE_UINT32);
14156 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14157 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14158 last_dir, "last_dir");
14159 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14160 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14162 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14163 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14164 liberal, "liberal");
14165 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14166 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14168 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14169 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14171 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14172 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14174 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14175 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14176 max_ack_win, "max_ack_win");
14177 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14178 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14179 factor, RTE_UINT8);
14180 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14181 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14183 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14184 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14185 re_num, RTE_UINT8);
14186 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14187 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14188 last_win, "last_win");
14189 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14190 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14192 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14193 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14194 last_seq, "last_seq");
14195 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14196 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14198 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14199 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14200 last_ack, "last_ack");
14201 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14202 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14204 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14205 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14206 last_end, "last_end");
14207 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14208 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14210 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14211 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14212 last_index, "last_index");
14213 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14214 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14217 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14218 __rte_unused struct cmdline *cl,
14219 __rte_unused void *data)
14221 struct cmd_set_conntrack_common_result *res = parsed_result;
14223 /* No need to swap to big endian. */
14224 conntrack_context.peer_port = res->peer_port;
14225 conntrack_context.is_original_dir = res->is_original;
14226 conntrack_context.enable = res->en;
14227 conntrack_context.live_connection = res->is_live;
14228 conntrack_context.selective_ack = res->s_ack;
14229 conntrack_context.challenge_ack_passed = res->c_ack;
14230 conntrack_context.last_direction = res->ld;
14231 conntrack_context.liberal_mode = res->lb;
14232 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14233 conntrack_context.max_ack_window = res->factor;
14234 conntrack_context.retransmission_limit = res->re_num;
14235 conntrack_context.last_window = res->lw;
14236 conntrack_context.last_index =
14237 (enum rte_flow_conntrack_tcp_last_index)res->li;
14238 conntrack_context.last_seq = res->ls;
14239 conntrack_context.last_ack = res->la;
14240 conntrack_context.last_end = res->le;
14243 cmdline_parse_inst_t cmd_set_conntrack_common = {
14244 .f = cmd_set_conntrack_common_parsed,
14246 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14247 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14248 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14249 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14250 " last_index <flag>",
14252 (void *)&cmd_set_conntrack_set,
14253 (void *)&cmd_set_conntrack_conntrack,
14254 (void *)&cmd_set_conntrack_common_com,
14255 (void *)&cmd_set_conntrack_common_peer,
14256 (void *)&cmd_set_conntrack_common_peer_value,
14257 (void *)&cmd_set_conntrack_common_is_orig,
14258 (void *)&cmd_set_conntrack_common_is_orig_value,
14259 (void *)&cmd_set_conntrack_common_enable,
14260 (void *)&cmd_set_conntrack_common_enable_value,
14261 (void *)&cmd_set_conntrack_common_live,
14262 (void *)&cmd_set_conntrack_common_live_value,
14263 (void *)&cmd_set_conntrack_common_sack,
14264 (void *)&cmd_set_conntrack_common_sack_value,
14265 (void *)&cmd_set_conntrack_common_cack,
14266 (void *)&cmd_set_conntrack_common_cack_value,
14267 (void *)&cmd_set_conntrack_common_last_dir,
14268 (void *)&cmd_set_conntrack_common_last_dir_value,
14269 (void *)&cmd_set_conntrack_common_liberal,
14270 (void *)&cmd_set_conntrack_common_liberal_value,
14271 (void *)&cmd_set_conntrack_common_state,
14272 (void *)&cmd_set_conntrack_common_state_value,
14273 (void *)&cmd_set_conntrack_common_max_ackwin,
14274 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14275 (void *)&cmd_set_conntrack_common_retrans,
14276 (void *)&cmd_set_conntrack_common_retrans_value,
14277 (void *)&cmd_set_conntrack_common_last_win,
14278 (void *)&cmd_set_conntrack_common_last_win_value,
14279 (void *)&cmd_set_conntrack_common_last_seq,
14280 (void *)&cmd_set_conntrack_common_last_seq_value,
14281 (void *)&cmd_set_conntrack_common_last_ack,
14282 (void *)&cmd_set_conntrack_common_last_ack_value,
14283 (void *)&cmd_set_conntrack_common_last_end,
14284 (void *)&cmd_set_conntrack_common_last_end_value,
14285 (void *)&cmd_set_conntrack_common_last_index,
14286 (void *)&cmd_set_conntrack_common_last_index_value,
14291 /** Set connection tracking object both directions' details */
14292 struct cmd_set_conntrack_dir_result {
14293 cmdline_fixed_string_t set;
14294 cmdline_fixed_string_t conntrack;
14295 cmdline_fixed_string_t dir;
14296 cmdline_fixed_string_t scale;
14297 cmdline_fixed_string_t fin;
14298 cmdline_fixed_string_t ack_seen;
14299 cmdline_fixed_string_t unack;
14300 cmdline_fixed_string_t sent_end;
14301 cmdline_fixed_string_t reply_end;
14302 cmdline_fixed_string_t max_win;
14303 cmdline_fixed_string_t max_ack;
14314 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14315 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14317 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14318 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14319 conntrack, "conntrack");
14320 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14321 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14323 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14324 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14326 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14327 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14328 factor, RTE_UINT32);
14329 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14330 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14332 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14333 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14335 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14336 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14337 ack_seen, "acked");
14338 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14339 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14341 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14342 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14343 unack, "unack_data");
14344 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14345 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14347 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14348 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14349 sent_end, "sent_end");
14350 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14351 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14353 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14354 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14355 reply_end, "reply_end");
14356 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14357 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14359 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14360 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14361 max_win, "max_win");
14362 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14363 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14365 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14366 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14367 max_ack, "max_ack");
14368 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14369 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14372 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14373 __rte_unused struct cmdline *cl,
14374 __rte_unused void *data)
14376 struct cmd_set_conntrack_dir_result *res = parsed_result;
14377 struct rte_flow_tcp_dir_param *dir = NULL;
14379 if (strcmp(res->dir, "orig") == 0)
14380 dir = &conntrack_context.original_dir;
14381 else if (strcmp(res->dir, "rply") == 0)
14382 dir = &conntrack_context.reply_dir;
14385 dir->scale = res->factor;
14386 dir->close_initiated = res->f;
14387 dir->last_ack_seen = res->as;
14388 dir->data_unacked = res->un;
14389 dir->sent_end = res->se;
14390 dir->reply_end = res->re;
14391 dir->max_ack = res->ma;
14392 dir->max_win = res->mw;
14395 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14396 .f = cmd_set_conntrack_dir_parsed,
14398 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14399 " acked <seen> unack_data <unack> sent_end <sent>"
14400 " reply_end <reply> max_win <win> max_ack <ack>",
14402 (void *)&cmd_set_conntrack_set,
14403 (void *)&cmd_set_conntrack_conntrack,
14404 (void *)&cmd_set_conntrack_dir_dir,
14405 (void *)&cmd_set_conntrack_dir_scale,
14406 (void *)&cmd_set_conntrack_dir_scale_value,
14407 (void *)&cmd_set_conntrack_dir_fin,
14408 (void *)&cmd_set_conntrack_dir_fin_value,
14409 (void *)&cmd_set_conntrack_dir_ack,
14410 (void *)&cmd_set_conntrack_dir_ack_value,
14411 (void *)&cmd_set_conntrack_dir_unack_data,
14412 (void *)&cmd_set_conntrack_dir_unack_data_value,
14413 (void *)&cmd_set_conntrack_dir_sent_end,
14414 (void *)&cmd_set_conntrack_dir_sent_end_value,
14415 (void *)&cmd_set_conntrack_dir_reply_end,
14416 (void *)&cmd_set_conntrack_dir_reply_end_value,
14417 (void *)&cmd_set_conntrack_dir_max_win,
14418 (void *)&cmd_set_conntrack_dir_max_win_value,
14419 (void *)&cmd_set_conntrack_dir_max_ack,
14420 (void *)&cmd_set_conntrack_dir_max_ack_value,
14425 /* Strict link priority scheduling mode setting */
14427 cmd_strict_link_prio_parsed(
14428 void *parsed_result,
14429 __rte_unused struct cmdline *cl,
14430 __rte_unused void *data)
14432 struct cmd_vf_tc_bw_result *res = parsed_result;
14433 int ret = -ENOTSUP;
14435 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14438 #ifdef RTE_NET_I40E
14439 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14446 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14449 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14452 fprintf(stderr, "function not implemented\n");
14455 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14459 cmdline_parse_inst_t cmd_strict_link_prio = {
14460 .f = cmd_strict_link_prio_parsed,
14462 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14464 (void *)&cmd_vf_tc_bw_set,
14465 (void *)&cmd_vf_tc_bw_tx,
14466 (void *)&cmd_vf_tc_bw_strict_link_prio,
14467 (void *)&cmd_vf_tc_bw_port_id,
14468 (void *)&cmd_vf_tc_bw_tc_map,
14473 /* Load dynamic device personalization*/
14474 struct cmd_ddp_add_result {
14475 cmdline_fixed_string_t ddp;
14476 cmdline_fixed_string_t add;
14481 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14483 cmdline_parse_token_string_t cmd_ddp_add_add =
14484 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14485 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14486 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14488 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14489 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14492 cmd_ddp_add_parsed(
14493 void *parsed_result,
14494 __rte_unused struct cmdline *cl,
14495 __rte_unused void *data)
14497 struct cmd_ddp_add_result *res = parsed_result;
14503 int ret = -ENOTSUP;
14505 if (!all_ports_stopped()) {
14506 fprintf(stderr, "Please stop all ports first\n");
14510 filepath = strdup(res->filepath);
14511 if (filepath == NULL) {
14512 fprintf(stderr, "Failed to allocate memory\n");
14515 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14517 buff = open_file(file_fld[0], &size);
14519 free((void *)filepath);
14523 #ifdef RTE_NET_I40E
14524 if (ret == -ENOTSUP)
14525 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14527 RTE_PMD_I40E_PKG_OP_WR_ADD);
14530 if (ret == -EEXIST)
14531 fprintf(stderr, "Profile has already existed.\n");
14533 fprintf(stderr, "Failed to load profile.\n");
14534 else if (file_num == 2)
14535 save_file(file_fld[1], buff, size);
14538 free((void *)filepath);
14541 cmdline_parse_inst_t cmd_ddp_add = {
14542 .f = cmd_ddp_add_parsed,
14544 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14546 (void *)&cmd_ddp_add_ddp,
14547 (void *)&cmd_ddp_add_add,
14548 (void *)&cmd_ddp_add_port_id,
14549 (void *)&cmd_ddp_add_filepath,
14554 /* Delete dynamic device personalization*/
14555 struct cmd_ddp_del_result {
14556 cmdline_fixed_string_t ddp;
14557 cmdline_fixed_string_t del;
14562 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14563 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14564 cmdline_parse_token_string_t cmd_ddp_del_del =
14565 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14566 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14567 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14568 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14569 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14572 cmd_ddp_del_parsed(
14573 void *parsed_result,
14574 __rte_unused struct cmdline *cl,
14575 __rte_unused void *data)
14577 struct cmd_ddp_del_result *res = parsed_result;
14580 int ret = -ENOTSUP;
14582 if (!all_ports_stopped()) {
14583 fprintf(stderr, "Please stop all ports first\n");
14587 buff = open_file(res->filepath, &size);
14591 #ifdef RTE_NET_I40E
14592 if (ret == -ENOTSUP)
14593 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14595 RTE_PMD_I40E_PKG_OP_WR_DEL);
14598 if (ret == -EACCES)
14599 fprintf(stderr, "Profile does not exist.\n");
14601 fprintf(stderr, "Failed to delete profile.\n");
14606 cmdline_parse_inst_t cmd_ddp_del = {
14607 .f = cmd_ddp_del_parsed,
14609 .help_str = "ddp del <port_id> <backup_profile_path>",
14611 (void *)&cmd_ddp_del_ddp,
14612 (void *)&cmd_ddp_del_del,
14613 (void *)&cmd_ddp_del_port_id,
14614 (void *)&cmd_ddp_del_filepath,
14619 /* Get dynamic device personalization profile info */
14620 struct cmd_ddp_info_result {
14621 cmdline_fixed_string_t ddp;
14622 cmdline_fixed_string_t get;
14623 cmdline_fixed_string_t info;
14627 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14628 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14629 cmdline_parse_token_string_t cmd_ddp_info_get =
14630 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14631 cmdline_parse_token_string_t cmd_ddp_info_info =
14632 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14633 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14634 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14637 cmd_ddp_info_parsed(
14638 void *parsed_result,
14639 __rte_unused struct cmdline *cl,
14640 __rte_unused void *data)
14642 struct cmd_ddp_info_result *res = parsed_result;
14645 int ret = -ENOTSUP;
14646 #ifdef RTE_NET_I40E
14649 uint32_t buff_size = 0;
14650 struct rte_pmd_i40e_profile_info info;
14651 uint32_t dev_num = 0;
14652 struct rte_pmd_i40e_ddp_device_id *devs;
14653 uint32_t proto_num = 0;
14654 struct rte_pmd_i40e_proto_info *proto = NULL;
14655 uint32_t pctype_num = 0;
14656 struct rte_pmd_i40e_ptype_info *pctype;
14657 uint32_t ptype_num = 0;
14658 struct rte_pmd_i40e_ptype_info *ptype;
14663 pkg = open_file(res->filepath, &pkg_size);
14667 #ifdef RTE_NET_I40E
14668 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14669 (uint8_t *)&info, sizeof(info),
14670 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14672 printf("Global Track id: 0x%x\n", info.track_id);
14673 printf("Global Version: %d.%d.%d.%d\n",
14674 info.version.major,
14675 info.version.minor,
14676 info.version.update,
14677 info.version.draft);
14678 printf("Global Package name: %s\n\n", info.name);
14681 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14682 (uint8_t *)&info, sizeof(info),
14683 RTE_PMD_I40E_PKG_INFO_HEADER);
14685 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14686 printf("i40e Profile Version: %d.%d.%d.%d\n",
14687 info.version.major,
14688 info.version.minor,
14689 info.version.update,
14690 info.version.draft);
14691 printf("i40e Profile name: %s\n\n", info.name);
14694 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14695 (uint8_t *)&buff_size, sizeof(buff_size),
14696 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14697 if (!ret && buff_size) {
14698 buff = (uint8_t *)malloc(buff_size);
14700 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14702 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14704 printf("Package Notes:\n%s\n\n", buff);
14709 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14710 (uint8_t *)&dev_num, sizeof(dev_num),
14711 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14712 if (!ret && dev_num) {
14713 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14714 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14716 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14717 (uint8_t *)devs, buff_size,
14718 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14720 printf("List of supported devices:\n");
14721 for (i = 0; i < dev_num; i++) {
14722 printf(" %04X:%04X %04X:%04X\n",
14723 devs[i].vendor_dev_id >> 16,
14724 devs[i].vendor_dev_id & 0xFFFF,
14725 devs[i].sub_vendor_dev_id >> 16,
14726 devs[i].sub_vendor_dev_id & 0xFFFF);
14734 /* get information about protocols and packet types */
14735 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14736 (uint8_t *)&proto_num, sizeof(proto_num),
14737 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14738 if (ret || !proto_num)
14739 goto no_print_return;
14741 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14742 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14744 goto no_print_return;
14746 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14748 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14750 printf("List of used protocols:\n");
14751 for (i = 0; i < proto_num; i++)
14752 printf(" %2u: %s\n", proto[i].proto_id,
14756 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14757 (uint8_t *)&pctype_num, sizeof(pctype_num),
14758 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14759 if (ret || !pctype_num)
14760 goto no_print_pctypes;
14762 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14763 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14765 goto no_print_pctypes;
14767 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14769 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14772 goto no_print_pctypes;
14775 printf("List of defined packet classification types:\n");
14776 for (i = 0; i < pctype_num; i++) {
14777 printf(" %2u:", pctype[i].ptype_id);
14778 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14779 proto_id = pctype[i].protocols[j];
14780 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14781 for (n = 0; n < proto_num; n++) {
14782 if (proto[n].proto_id == proto_id) {
14783 printf(" %s", proto[n].name);
14796 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14798 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14799 if (ret || !ptype_num)
14800 goto no_print_return;
14802 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14803 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14805 goto no_print_return;
14807 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14809 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14812 goto no_print_return;
14814 printf("List of defined packet types:\n");
14815 for (i = 0; i < ptype_num; i++) {
14816 printf(" %2u:", ptype[i].ptype_id);
14817 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14818 proto_id = ptype[i].protocols[j];
14819 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14820 for (n = 0; n < proto_num; n++) {
14821 if (proto[n].proto_id == proto_id) {
14822 printf(" %s", proto[n].name);
14837 if (ret == -ENOTSUP)
14838 fprintf(stderr, "Function not supported in PMD\n");
14842 cmdline_parse_inst_t cmd_ddp_get_info = {
14843 .f = cmd_ddp_info_parsed,
14845 .help_str = "ddp get info <profile_path>",
14847 (void *)&cmd_ddp_info_ddp,
14848 (void *)&cmd_ddp_info_get,
14849 (void *)&cmd_ddp_info_info,
14850 (void *)&cmd_ddp_info_filepath,
14855 /* Get dynamic device personalization profile info list*/
14856 #define PROFILE_INFO_SIZE 48
14857 #define MAX_PROFILE_NUM 16
14859 struct cmd_ddp_get_list_result {
14860 cmdline_fixed_string_t ddp;
14861 cmdline_fixed_string_t get;
14862 cmdline_fixed_string_t list;
14866 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14867 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14868 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14869 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14870 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14871 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14872 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14873 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14877 cmd_ddp_get_list_parsed(
14878 __rte_unused void *parsed_result,
14879 __rte_unused struct cmdline *cl,
14880 __rte_unused void *data)
14882 #ifdef RTE_NET_I40E
14883 struct cmd_ddp_get_list_result *res = parsed_result;
14884 struct rte_pmd_i40e_profile_list *p_list;
14885 struct rte_pmd_i40e_profile_info *p_info;
14890 int ret = -ENOTSUP;
14892 #ifdef RTE_NET_I40E
14893 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14894 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14896 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14900 if (ret == -ENOTSUP)
14901 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14902 (uint8_t *)p_list, size);
14905 p_num = p_list->p_count;
14906 printf("Profile number is: %d\n\n", p_num);
14908 for (i = 0; i < p_num; i++) {
14909 p_info = &p_list->p_info[i];
14910 printf("Profile %d:\n", i);
14911 printf("Track id: 0x%x\n", p_info->track_id);
14912 printf("Version: %d.%d.%d.%d\n",
14913 p_info->version.major,
14914 p_info->version.minor,
14915 p_info->version.update,
14916 p_info->version.draft);
14917 printf("Profile name: %s\n\n", p_info->name);
14925 fprintf(stderr, "Failed to get ddp list\n");
14928 cmdline_parse_inst_t cmd_ddp_get_list = {
14929 .f = cmd_ddp_get_list_parsed,
14931 .help_str = "ddp get list <port_id>",
14933 (void *)&cmd_ddp_get_list_ddp,
14934 (void *)&cmd_ddp_get_list_get,
14935 (void *)&cmd_ddp_get_list_list,
14936 (void *)&cmd_ddp_get_list_port_id,
14941 /* Configure input set */
14942 struct cmd_cfg_input_set_result {
14943 cmdline_fixed_string_t port;
14944 cmdline_fixed_string_t cfg;
14946 cmdline_fixed_string_t pctype;
14948 cmdline_fixed_string_t inset_type;
14949 cmdline_fixed_string_t opt;
14950 cmdline_fixed_string_t field;
14955 cmd_cfg_input_set_parsed(
14956 __rte_unused void *parsed_result,
14957 __rte_unused struct cmdline *cl,
14958 __rte_unused void *data)
14960 #ifdef RTE_NET_I40E
14961 struct cmd_cfg_input_set_result *res = parsed_result;
14962 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14963 struct rte_pmd_i40e_inset inset;
14965 int ret = -ENOTSUP;
14967 if (!all_ports_stopped()) {
14968 fprintf(stderr, "Please stop all ports first\n");
14972 #ifdef RTE_NET_I40E
14973 if (!strcmp(res->inset_type, "hash_inset"))
14974 inset_type = INSET_HASH;
14975 else if (!strcmp(res->inset_type, "fdir_inset"))
14976 inset_type = INSET_FDIR;
14977 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14978 inset_type = INSET_FDIR_FLX;
14979 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14980 &inset, inset_type);
14982 fprintf(stderr, "Failed to get input set.\n");
14986 if (!strcmp(res->opt, "get")) {
14987 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14990 printf("Field index %d is enabled.\n", res->field_idx);
14992 printf("Field index %d is disabled.\n", res->field_idx);
14994 } else if (!strcmp(res->opt, "set"))
14995 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14997 else if (!strcmp(res->opt, "clear"))
14998 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15001 fprintf(stderr, "Failed to configure input set field.\n");
15005 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15006 &inset, inset_type);
15008 fprintf(stderr, "Failed to set input set.\n");
15013 if (ret == -ENOTSUP)
15014 fprintf(stderr, "Function not supported\n");
15017 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15018 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15020 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15021 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15023 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15024 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15025 port_id, RTE_UINT16);
15026 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15027 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15029 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15030 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15031 pctype_id, RTE_UINT8);
15032 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15033 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15035 "hash_inset#fdir_inset#fdir_flx_inset");
15036 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15037 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15038 opt, "get#set#clear");
15039 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15040 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15042 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15043 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15044 field_idx, RTE_UINT8);
15046 cmdline_parse_inst_t cmd_cfg_input_set = {
15047 .f = cmd_cfg_input_set_parsed,
15049 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15050 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15052 (void *)&cmd_cfg_input_set_port,
15053 (void *)&cmd_cfg_input_set_cfg,
15054 (void *)&cmd_cfg_input_set_port_id,
15055 (void *)&cmd_cfg_input_set_pctype,
15056 (void *)&cmd_cfg_input_set_pctype_id,
15057 (void *)&cmd_cfg_input_set_inset_type,
15058 (void *)&cmd_cfg_input_set_opt,
15059 (void *)&cmd_cfg_input_set_field,
15060 (void *)&cmd_cfg_input_set_field_idx,
15065 /* Clear input set */
15066 struct cmd_clear_input_set_result {
15067 cmdline_fixed_string_t port;
15068 cmdline_fixed_string_t cfg;
15070 cmdline_fixed_string_t pctype;
15072 cmdline_fixed_string_t inset_type;
15073 cmdline_fixed_string_t clear;
15074 cmdline_fixed_string_t all;
15078 cmd_clear_input_set_parsed(
15079 __rte_unused void *parsed_result,
15080 __rte_unused struct cmdline *cl,
15081 __rte_unused void *data)
15083 #ifdef RTE_NET_I40E
15084 struct cmd_clear_input_set_result *res = parsed_result;
15085 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15086 struct rte_pmd_i40e_inset inset;
15088 int ret = -ENOTSUP;
15090 if (!all_ports_stopped()) {
15091 fprintf(stderr, "Please stop all ports first\n");
15095 #ifdef RTE_NET_I40E
15096 if (!strcmp(res->inset_type, "hash_inset"))
15097 inset_type = INSET_HASH;
15098 else if (!strcmp(res->inset_type, "fdir_inset"))
15099 inset_type = INSET_FDIR;
15100 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15101 inset_type = INSET_FDIR_FLX;
15103 memset(&inset, 0, sizeof(inset));
15105 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15106 &inset, inset_type);
15108 fprintf(stderr, "Failed to clear input set.\n");
15114 if (ret == -ENOTSUP)
15115 fprintf(stderr, "Function not supported\n");
15118 cmdline_parse_token_string_t cmd_clear_input_set_port =
15119 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15121 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15122 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15124 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15125 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15126 port_id, RTE_UINT16);
15127 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15128 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15130 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15131 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15132 pctype_id, RTE_UINT8);
15133 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15134 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15136 "hash_inset#fdir_inset#fdir_flx_inset");
15137 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15138 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15140 cmdline_parse_token_string_t cmd_clear_input_set_all =
15141 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15144 cmdline_parse_inst_t cmd_clear_input_set = {
15145 .f = cmd_clear_input_set_parsed,
15147 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15148 "fdir_inset|fdir_flx_inset clear all",
15150 (void *)&cmd_clear_input_set_port,
15151 (void *)&cmd_clear_input_set_cfg,
15152 (void *)&cmd_clear_input_set_port_id,
15153 (void *)&cmd_clear_input_set_pctype,
15154 (void *)&cmd_clear_input_set_pctype_id,
15155 (void *)&cmd_clear_input_set_inset_type,
15156 (void *)&cmd_clear_input_set_clear,
15157 (void *)&cmd_clear_input_set_all,
15162 /* show vf stats */
15164 /* Common result structure for show vf stats */
15165 struct cmd_show_vf_stats_result {
15166 cmdline_fixed_string_t show;
15167 cmdline_fixed_string_t vf;
15168 cmdline_fixed_string_t stats;
15173 /* Common CLI fields show vf stats*/
15174 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15175 TOKEN_STRING_INITIALIZER
15176 (struct cmd_show_vf_stats_result,
15178 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15179 TOKEN_STRING_INITIALIZER
15180 (struct cmd_show_vf_stats_result,
15182 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15183 TOKEN_STRING_INITIALIZER
15184 (struct cmd_show_vf_stats_result,
15186 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15187 TOKEN_NUM_INITIALIZER
15188 (struct cmd_show_vf_stats_result,
15189 port_id, RTE_UINT16);
15190 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15191 TOKEN_NUM_INITIALIZER
15192 (struct cmd_show_vf_stats_result,
15193 vf_id, RTE_UINT16);
15196 cmd_show_vf_stats_parsed(
15197 void *parsed_result,
15198 __rte_unused struct cmdline *cl,
15199 __rte_unused void *data)
15201 struct cmd_show_vf_stats_result *res = parsed_result;
15202 struct rte_eth_stats stats;
15203 int ret = -ENOTSUP;
15204 static const char *nic_stats_border = "########################";
15206 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15209 memset(&stats, 0, sizeof(stats));
15211 #ifdef RTE_NET_I40E
15212 if (ret == -ENOTSUP)
15213 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15217 #ifdef RTE_NET_BNXT
15218 if (ret == -ENOTSUP)
15219 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15228 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15231 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15234 fprintf(stderr, "function not implemented\n");
15237 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15240 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15241 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15243 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15245 stats.ipackets, stats.imissed, stats.ibytes);
15246 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15247 printf(" RX-nombuf: %-10"PRIu64"\n",
15249 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15251 stats.opackets, stats.oerrors, stats.obytes);
15253 printf(" %s############################%s\n",
15254 nic_stats_border, nic_stats_border);
15257 cmdline_parse_inst_t cmd_show_vf_stats = {
15258 .f = cmd_show_vf_stats_parsed,
15260 .help_str = "show vf stats <port_id> <vf_id>",
15262 (void *)&cmd_show_vf_stats_show,
15263 (void *)&cmd_show_vf_stats_vf,
15264 (void *)&cmd_show_vf_stats_stats,
15265 (void *)&cmd_show_vf_stats_port_id,
15266 (void *)&cmd_show_vf_stats_vf_id,
15271 /* clear vf stats */
15273 /* Common result structure for clear vf stats */
15274 struct cmd_clear_vf_stats_result {
15275 cmdline_fixed_string_t clear;
15276 cmdline_fixed_string_t vf;
15277 cmdline_fixed_string_t stats;
15282 /* Common CLI fields clear vf stats*/
15283 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15284 TOKEN_STRING_INITIALIZER
15285 (struct cmd_clear_vf_stats_result,
15287 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15288 TOKEN_STRING_INITIALIZER
15289 (struct cmd_clear_vf_stats_result,
15291 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15292 TOKEN_STRING_INITIALIZER
15293 (struct cmd_clear_vf_stats_result,
15295 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15296 TOKEN_NUM_INITIALIZER
15297 (struct cmd_clear_vf_stats_result,
15298 port_id, RTE_UINT16);
15299 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15300 TOKEN_NUM_INITIALIZER
15301 (struct cmd_clear_vf_stats_result,
15302 vf_id, RTE_UINT16);
15305 cmd_clear_vf_stats_parsed(
15306 void *parsed_result,
15307 __rte_unused struct cmdline *cl,
15308 __rte_unused void *data)
15310 struct cmd_clear_vf_stats_result *res = parsed_result;
15311 int ret = -ENOTSUP;
15313 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15316 #ifdef RTE_NET_I40E
15317 if (ret == -ENOTSUP)
15318 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15321 #ifdef RTE_NET_BNXT
15322 if (ret == -ENOTSUP)
15323 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15331 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15334 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15337 fprintf(stderr, "function not implemented\n");
15340 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15344 cmdline_parse_inst_t cmd_clear_vf_stats = {
15345 .f = cmd_clear_vf_stats_parsed,
15347 .help_str = "clear vf stats <port_id> <vf_id>",
15349 (void *)&cmd_clear_vf_stats_clear,
15350 (void *)&cmd_clear_vf_stats_vf,
15351 (void *)&cmd_clear_vf_stats_stats,
15352 (void *)&cmd_clear_vf_stats_port_id,
15353 (void *)&cmd_clear_vf_stats_vf_id,
15358 /* port config pctype mapping reset */
15360 /* Common result structure for port config pctype mapping reset */
15361 struct cmd_pctype_mapping_reset_result {
15362 cmdline_fixed_string_t port;
15363 cmdline_fixed_string_t config;
15365 cmdline_fixed_string_t pctype;
15366 cmdline_fixed_string_t mapping;
15367 cmdline_fixed_string_t reset;
15370 /* Common CLI fields for port config pctype mapping reset*/
15371 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15372 TOKEN_STRING_INITIALIZER
15373 (struct cmd_pctype_mapping_reset_result,
15375 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15376 TOKEN_STRING_INITIALIZER
15377 (struct cmd_pctype_mapping_reset_result,
15379 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15380 TOKEN_NUM_INITIALIZER
15381 (struct cmd_pctype_mapping_reset_result,
15382 port_id, RTE_UINT16);
15383 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15384 TOKEN_STRING_INITIALIZER
15385 (struct cmd_pctype_mapping_reset_result,
15387 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15388 TOKEN_STRING_INITIALIZER
15389 (struct cmd_pctype_mapping_reset_result,
15390 mapping, "mapping");
15391 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15392 TOKEN_STRING_INITIALIZER
15393 (struct cmd_pctype_mapping_reset_result,
15397 cmd_pctype_mapping_reset_parsed(
15398 void *parsed_result,
15399 __rte_unused struct cmdline *cl,
15400 __rte_unused void *data)
15402 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15403 int ret = -ENOTSUP;
15405 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15408 #ifdef RTE_NET_I40E
15409 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15416 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15419 fprintf(stderr, "function not implemented\n");
15422 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15426 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15427 .f = cmd_pctype_mapping_reset_parsed,
15429 .help_str = "port config <port_id> pctype mapping reset",
15431 (void *)&cmd_pctype_mapping_reset_port,
15432 (void *)&cmd_pctype_mapping_reset_config,
15433 (void *)&cmd_pctype_mapping_reset_port_id,
15434 (void *)&cmd_pctype_mapping_reset_pctype,
15435 (void *)&cmd_pctype_mapping_reset_mapping,
15436 (void *)&cmd_pctype_mapping_reset_reset,
15441 /* show port pctype mapping */
15443 /* Common result structure for show port pctype mapping */
15444 struct cmd_pctype_mapping_get_result {
15445 cmdline_fixed_string_t show;
15446 cmdline_fixed_string_t port;
15448 cmdline_fixed_string_t pctype;
15449 cmdline_fixed_string_t mapping;
15452 /* Common CLI fields for pctype mapping get */
15453 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15454 TOKEN_STRING_INITIALIZER
15455 (struct cmd_pctype_mapping_get_result,
15457 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15458 TOKEN_STRING_INITIALIZER
15459 (struct cmd_pctype_mapping_get_result,
15461 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15462 TOKEN_NUM_INITIALIZER
15463 (struct cmd_pctype_mapping_get_result,
15464 port_id, RTE_UINT16);
15465 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15466 TOKEN_STRING_INITIALIZER
15467 (struct cmd_pctype_mapping_get_result,
15469 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15470 TOKEN_STRING_INITIALIZER
15471 (struct cmd_pctype_mapping_get_result,
15472 mapping, "mapping");
15475 cmd_pctype_mapping_get_parsed(
15476 void *parsed_result,
15477 __rte_unused struct cmdline *cl,
15478 __rte_unused void *data)
15480 struct cmd_pctype_mapping_get_result *res = parsed_result;
15481 int ret = -ENOTSUP;
15482 #ifdef RTE_NET_I40E
15483 struct rte_pmd_i40e_flow_type_mapping
15484 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15485 int i, j, first_pctype;
15488 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15491 #ifdef RTE_NET_I40E
15492 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15499 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15502 fprintf(stderr, "function not implemented\n");
15505 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15509 #ifdef RTE_NET_I40E
15510 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15511 if (mapping[i].pctype != 0ULL) {
15514 printf("pctype: ");
15515 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15516 if (mapping[i].pctype & (1ULL << j)) {
15517 printf(first_pctype ?
15518 "%02d" : ",%02d", j);
15522 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15528 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15529 .f = cmd_pctype_mapping_get_parsed,
15531 .help_str = "show port <port_id> pctype mapping",
15533 (void *)&cmd_pctype_mapping_get_show,
15534 (void *)&cmd_pctype_mapping_get_port,
15535 (void *)&cmd_pctype_mapping_get_port_id,
15536 (void *)&cmd_pctype_mapping_get_pctype,
15537 (void *)&cmd_pctype_mapping_get_mapping,
15542 /* port config pctype mapping update */
15544 /* Common result structure for port config pctype mapping update */
15545 struct cmd_pctype_mapping_update_result {
15546 cmdline_fixed_string_t port;
15547 cmdline_fixed_string_t config;
15549 cmdline_fixed_string_t pctype;
15550 cmdline_fixed_string_t mapping;
15551 cmdline_fixed_string_t update;
15552 cmdline_fixed_string_t pctype_list;
15553 uint16_t flow_type;
15556 /* Common CLI fields for pctype mapping update*/
15557 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15558 TOKEN_STRING_INITIALIZER
15559 (struct cmd_pctype_mapping_update_result,
15561 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15562 TOKEN_STRING_INITIALIZER
15563 (struct cmd_pctype_mapping_update_result,
15565 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15566 TOKEN_NUM_INITIALIZER
15567 (struct cmd_pctype_mapping_update_result,
15568 port_id, RTE_UINT16);
15569 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15570 TOKEN_STRING_INITIALIZER
15571 (struct cmd_pctype_mapping_update_result,
15573 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15574 TOKEN_STRING_INITIALIZER
15575 (struct cmd_pctype_mapping_update_result,
15576 mapping, "mapping");
15577 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15578 TOKEN_STRING_INITIALIZER
15579 (struct cmd_pctype_mapping_update_result,
15581 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15582 TOKEN_STRING_INITIALIZER
15583 (struct cmd_pctype_mapping_update_result,
15584 pctype_list, NULL);
15585 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15586 TOKEN_NUM_INITIALIZER
15587 (struct cmd_pctype_mapping_update_result,
15588 flow_type, RTE_UINT16);
15591 cmd_pctype_mapping_update_parsed(
15592 void *parsed_result,
15593 __rte_unused struct cmdline *cl,
15594 __rte_unused void *data)
15596 struct cmd_pctype_mapping_update_result *res = parsed_result;
15597 int ret = -ENOTSUP;
15598 #ifdef RTE_NET_I40E
15599 struct rte_pmd_i40e_flow_type_mapping mapping;
15601 unsigned int nb_item;
15602 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15608 #ifdef RTE_NET_I40E
15609 nb_item = parse_item_list(res->pctype_list, "pctypes",
15610 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15611 mapping.flow_type = res->flow_type;
15612 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15613 mapping.pctype |= (1ULL << pctype_list[i]);
15614 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15624 fprintf(stderr, "invalid pctype or flow type\n");
15627 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15630 fprintf(stderr, "function not implemented\n");
15633 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15637 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15638 .f = cmd_pctype_mapping_update_parsed,
15640 .help_str = "port config <port_id> pctype mapping update"
15641 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15643 (void *)&cmd_pctype_mapping_update_port,
15644 (void *)&cmd_pctype_mapping_update_config,
15645 (void *)&cmd_pctype_mapping_update_port_id,
15646 (void *)&cmd_pctype_mapping_update_pctype,
15647 (void *)&cmd_pctype_mapping_update_mapping,
15648 (void *)&cmd_pctype_mapping_update_update,
15649 (void *)&cmd_pctype_mapping_update_pc_type,
15650 (void *)&cmd_pctype_mapping_update_flow_type,
15655 /* ptype mapping get */
15657 /* Common result structure for ptype mapping get */
15658 struct cmd_ptype_mapping_get_result {
15659 cmdline_fixed_string_t ptype;
15660 cmdline_fixed_string_t mapping;
15661 cmdline_fixed_string_t get;
15663 uint8_t valid_only;
15666 /* Common CLI fields for ptype mapping get */
15667 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15668 TOKEN_STRING_INITIALIZER
15669 (struct cmd_ptype_mapping_get_result,
15671 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15672 TOKEN_STRING_INITIALIZER
15673 (struct cmd_ptype_mapping_get_result,
15674 mapping, "mapping");
15675 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15676 TOKEN_STRING_INITIALIZER
15677 (struct cmd_ptype_mapping_get_result,
15679 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15680 TOKEN_NUM_INITIALIZER
15681 (struct cmd_ptype_mapping_get_result,
15682 port_id, RTE_UINT16);
15683 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15684 TOKEN_NUM_INITIALIZER
15685 (struct cmd_ptype_mapping_get_result,
15686 valid_only, RTE_UINT8);
15689 cmd_ptype_mapping_get_parsed(
15690 void *parsed_result,
15691 __rte_unused struct cmdline *cl,
15692 __rte_unused void *data)
15694 struct cmd_ptype_mapping_get_result *res = parsed_result;
15695 int ret = -ENOTSUP;
15696 #ifdef RTE_NET_I40E
15697 int max_ptype_num = 256;
15698 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15706 #ifdef RTE_NET_I40E
15707 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15718 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15721 fprintf(stderr, "function not implemented\n");
15724 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15727 #ifdef RTE_NET_I40E
15729 for (i = 0; i < count; i++)
15730 printf("%3d\t0x%08x\n",
15731 mapping[i].hw_ptype, mapping[i].sw_ptype);
15736 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15737 .f = cmd_ptype_mapping_get_parsed,
15739 .help_str = "ptype mapping get <port_id> <valid_only>",
15741 (void *)&cmd_ptype_mapping_get_ptype,
15742 (void *)&cmd_ptype_mapping_get_mapping,
15743 (void *)&cmd_ptype_mapping_get_get,
15744 (void *)&cmd_ptype_mapping_get_port_id,
15745 (void *)&cmd_ptype_mapping_get_valid_only,
15750 /* ptype mapping replace */
15752 /* Common result structure for ptype mapping replace */
15753 struct cmd_ptype_mapping_replace_result {
15754 cmdline_fixed_string_t ptype;
15755 cmdline_fixed_string_t mapping;
15756 cmdline_fixed_string_t replace;
15763 /* Common CLI fields for ptype mapping replace */
15764 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15765 TOKEN_STRING_INITIALIZER
15766 (struct cmd_ptype_mapping_replace_result,
15768 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15769 TOKEN_STRING_INITIALIZER
15770 (struct cmd_ptype_mapping_replace_result,
15771 mapping, "mapping");
15772 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15773 TOKEN_STRING_INITIALIZER
15774 (struct cmd_ptype_mapping_replace_result,
15775 replace, "replace");
15776 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15777 TOKEN_NUM_INITIALIZER
15778 (struct cmd_ptype_mapping_replace_result,
15779 port_id, RTE_UINT16);
15780 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15781 TOKEN_NUM_INITIALIZER
15782 (struct cmd_ptype_mapping_replace_result,
15783 target, RTE_UINT32);
15784 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15785 TOKEN_NUM_INITIALIZER
15786 (struct cmd_ptype_mapping_replace_result,
15788 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15789 TOKEN_NUM_INITIALIZER
15790 (struct cmd_ptype_mapping_replace_result,
15791 pkt_type, RTE_UINT32);
15794 cmd_ptype_mapping_replace_parsed(
15795 void *parsed_result,
15796 __rte_unused struct cmdline *cl,
15797 __rte_unused void *data)
15799 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15800 int ret = -ENOTSUP;
15802 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15805 #ifdef RTE_NET_I40E
15806 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15816 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15817 res->target, res->pkt_type);
15820 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15823 fprintf(stderr, "function not implemented\n");
15826 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15830 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15831 .f = cmd_ptype_mapping_replace_parsed,
15834 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15836 (void *)&cmd_ptype_mapping_replace_ptype,
15837 (void *)&cmd_ptype_mapping_replace_mapping,
15838 (void *)&cmd_ptype_mapping_replace_replace,
15839 (void *)&cmd_ptype_mapping_replace_port_id,
15840 (void *)&cmd_ptype_mapping_replace_target,
15841 (void *)&cmd_ptype_mapping_replace_mask,
15842 (void *)&cmd_ptype_mapping_replace_pkt_type,
15847 /* ptype mapping reset */
15849 /* Common result structure for ptype mapping reset */
15850 struct cmd_ptype_mapping_reset_result {
15851 cmdline_fixed_string_t ptype;
15852 cmdline_fixed_string_t mapping;
15853 cmdline_fixed_string_t reset;
15857 /* Common CLI fields for ptype mapping reset*/
15858 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15859 TOKEN_STRING_INITIALIZER
15860 (struct cmd_ptype_mapping_reset_result,
15862 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15863 TOKEN_STRING_INITIALIZER
15864 (struct cmd_ptype_mapping_reset_result,
15865 mapping, "mapping");
15866 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15867 TOKEN_STRING_INITIALIZER
15868 (struct cmd_ptype_mapping_reset_result,
15870 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15871 TOKEN_NUM_INITIALIZER
15872 (struct cmd_ptype_mapping_reset_result,
15873 port_id, RTE_UINT16);
15876 cmd_ptype_mapping_reset_parsed(
15877 void *parsed_result,
15878 __rte_unused struct cmdline *cl,
15879 __rte_unused void *data)
15881 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15882 int ret = -ENOTSUP;
15884 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15887 #ifdef RTE_NET_I40E
15888 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15895 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15898 fprintf(stderr, "function not implemented\n");
15901 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15905 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15906 .f = cmd_ptype_mapping_reset_parsed,
15908 .help_str = "ptype mapping reset <port_id>",
15910 (void *)&cmd_ptype_mapping_reset_ptype,
15911 (void *)&cmd_ptype_mapping_reset_mapping,
15912 (void *)&cmd_ptype_mapping_reset_reset,
15913 (void *)&cmd_ptype_mapping_reset_port_id,
15918 /* ptype mapping update */
15920 /* Common result structure for ptype mapping update */
15921 struct cmd_ptype_mapping_update_result {
15922 cmdline_fixed_string_t ptype;
15923 cmdline_fixed_string_t mapping;
15924 cmdline_fixed_string_t reset;
15930 /* Common CLI fields for ptype mapping update*/
15931 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15932 TOKEN_STRING_INITIALIZER
15933 (struct cmd_ptype_mapping_update_result,
15935 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15936 TOKEN_STRING_INITIALIZER
15937 (struct cmd_ptype_mapping_update_result,
15938 mapping, "mapping");
15939 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15940 TOKEN_STRING_INITIALIZER
15941 (struct cmd_ptype_mapping_update_result,
15943 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15944 TOKEN_NUM_INITIALIZER
15945 (struct cmd_ptype_mapping_update_result,
15946 port_id, RTE_UINT16);
15947 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15948 TOKEN_NUM_INITIALIZER
15949 (struct cmd_ptype_mapping_update_result,
15950 hw_ptype, RTE_UINT8);
15951 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15952 TOKEN_NUM_INITIALIZER
15953 (struct cmd_ptype_mapping_update_result,
15954 sw_ptype, RTE_UINT32);
15957 cmd_ptype_mapping_update_parsed(
15958 void *parsed_result,
15959 __rte_unused struct cmdline *cl,
15960 __rte_unused void *data)
15962 struct cmd_ptype_mapping_update_result *res = parsed_result;
15963 int ret = -ENOTSUP;
15964 #ifdef RTE_NET_I40E
15965 struct rte_pmd_i40e_ptype_mapping mapping;
15967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15970 #ifdef RTE_NET_I40E
15971 mapping.hw_ptype = res->hw_ptype;
15972 mapping.sw_ptype = res->sw_ptype;
15973 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15983 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15986 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15989 fprintf(stderr, "function not implemented\n");
15992 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15996 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15997 .f = cmd_ptype_mapping_update_parsed,
15999 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16001 (void *)&cmd_ptype_mapping_update_ptype,
16002 (void *)&cmd_ptype_mapping_update_mapping,
16003 (void *)&cmd_ptype_mapping_update_update,
16004 (void *)&cmd_ptype_mapping_update_port_id,
16005 (void *)&cmd_ptype_mapping_update_hw_ptype,
16006 (void *)&cmd_ptype_mapping_update_sw_ptype,
16011 /* Common result structure for file commands */
16012 struct cmd_cmdfile_result {
16013 cmdline_fixed_string_t load;
16014 cmdline_fixed_string_t filename;
16017 /* Common CLI fields for file commands */
16018 cmdline_parse_token_string_t cmd_load_cmdfile =
16019 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16020 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16021 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16024 cmd_load_from_file_parsed(
16025 void *parsed_result,
16026 __rte_unused struct cmdline *cl,
16027 __rte_unused void *data)
16029 struct cmd_cmdfile_result *res = parsed_result;
16031 cmdline_read_from_file(res->filename);
16034 cmdline_parse_inst_t cmd_load_from_file = {
16035 .f = cmd_load_from_file_parsed,
16037 .help_str = "load <filename>",
16039 (void *)&cmd_load_cmdfile,
16040 (void *)&cmd_load_cmdfile_filename,
16045 /* Get Rx offloads capabilities */
16046 struct cmd_rx_offload_get_capa_result {
16047 cmdline_fixed_string_t show;
16048 cmdline_fixed_string_t port;
16050 cmdline_fixed_string_t rx_offload;
16051 cmdline_fixed_string_t capabilities;
16054 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16055 TOKEN_STRING_INITIALIZER
16056 (struct cmd_rx_offload_get_capa_result,
16058 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16059 TOKEN_STRING_INITIALIZER
16060 (struct cmd_rx_offload_get_capa_result,
16062 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16063 TOKEN_NUM_INITIALIZER
16064 (struct cmd_rx_offload_get_capa_result,
16065 port_id, RTE_UINT16);
16066 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16067 TOKEN_STRING_INITIALIZER
16068 (struct cmd_rx_offload_get_capa_result,
16069 rx_offload, "rx_offload");
16070 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16071 TOKEN_STRING_INITIALIZER
16072 (struct cmd_rx_offload_get_capa_result,
16073 capabilities, "capabilities");
16076 print_rx_offloads(uint64_t offloads)
16078 uint64_t single_offload;
16086 begin = __builtin_ctzll(offloads);
16087 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16089 single_offload = 1ULL << begin;
16090 for (bit = begin; bit < end; bit++) {
16091 if (offloads & single_offload)
16093 rte_eth_dev_rx_offload_name(single_offload));
16094 single_offload <<= 1;
16099 cmd_rx_offload_get_capa_parsed(
16100 void *parsed_result,
16101 __rte_unused struct cmdline *cl,
16102 __rte_unused void *data)
16104 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16105 struct rte_eth_dev_info dev_info;
16106 portid_t port_id = res->port_id;
16107 uint64_t queue_offloads;
16108 uint64_t port_offloads;
16111 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16115 queue_offloads = dev_info.rx_queue_offload_capa;
16116 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16118 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16119 printf(" Per Queue :");
16120 print_rx_offloads(queue_offloads);
16123 printf(" Per Port :");
16124 print_rx_offloads(port_offloads);
16128 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16129 .f = cmd_rx_offload_get_capa_parsed,
16131 .help_str = "show port <port_id> rx_offload capabilities",
16133 (void *)&cmd_rx_offload_get_capa_show,
16134 (void *)&cmd_rx_offload_get_capa_port,
16135 (void *)&cmd_rx_offload_get_capa_port_id,
16136 (void *)&cmd_rx_offload_get_capa_rx_offload,
16137 (void *)&cmd_rx_offload_get_capa_capabilities,
16142 /* Get Rx offloads configuration */
16143 struct cmd_rx_offload_get_configuration_result {
16144 cmdline_fixed_string_t show;
16145 cmdline_fixed_string_t port;
16147 cmdline_fixed_string_t rx_offload;
16148 cmdline_fixed_string_t configuration;
16151 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16152 TOKEN_STRING_INITIALIZER
16153 (struct cmd_rx_offload_get_configuration_result,
16155 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16156 TOKEN_STRING_INITIALIZER
16157 (struct cmd_rx_offload_get_configuration_result,
16159 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16160 TOKEN_NUM_INITIALIZER
16161 (struct cmd_rx_offload_get_configuration_result,
16162 port_id, RTE_UINT16);
16163 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16164 TOKEN_STRING_INITIALIZER
16165 (struct cmd_rx_offload_get_configuration_result,
16166 rx_offload, "rx_offload");
16167 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16168 TOKEN_STRING_INITIALIZER
16169 (struct cmd_rx_offload_get_configuration_result,
16170 configuration, "configuration");
16173 cmd_rx_offload_get_configuration_parsed(
16174 void *parsed_result,
16175 __rte_unused struct cmdline *cl,
16176 __rte_unused void *data)
16178 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16179 struct rte_eth_dev_info dev_info;
16180 portid_t port_id = res->port_id;
16181 struct rte_port *port = &ports[port_id];
16182 struct rte_eth_conf dev_conf;
16183 uint64_t port_offloads;
16184 uint64_t queue_offloads;
16185 uint16_t nb_rx_queues;
16189 printf("Rx Offloading Configuration of port %d :\n", port_id);
16191 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16195 port_offloads = dev_conf.rxmode.offloads;
16197 print_rx_offloads(port_offloads);
16200 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16204 nb_rx_queues = dev_info.nb_rx_queues;
16205 for (q = 0; q < nb_rx_queues; q++) {
16206 queue_offloads = port->rx_conf[q].offloads;
16207 printf(" Queue[%2d] :", q);
16208 print_rx_offloads(queue_offloads);
16214 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16215 .f = cmd_rx_offload_get_configuration_parsed,
16217 .help_str = "show port <port_id> rx_offload configuration",
16219 (void *)&cmd_rx_offload_get_configuration_show,
16220 (void *)&cmd_rx_offload_get_configuration_port,
16221 (void *)&cmd_rx_offload_get_configuration_port_id,
16222 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16223 (void *)&cmd_rx_offload_get_configuration_configuration,
16228 /* Enable/Disable a per port offloading */
16229 struct cmd_config_per_port_rx_offload_result {
16230 cmdline_fixed_string_t port;
16231 cmdline_fixed_string_t config;
16233 cmdline_fixed_string_t rx_offload;
16234 cmdline_fixed_string_t offload;
16235 cmdline_fixed_string_t on_off;
16238 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16239 TOKEN_STRING_INITIALIZER
16240 (struct cmd_config_per_port_rx_offload_result,
16242 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16243 TOKEN_STRING_INITIALIZER
16244 (struct cmd_config_per_port_rx_offload_result,
16246 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16247 TOKEN_NUM_INITIALIZER
16248 (struct cmd_config_per_port_rx_offload_result,
16249 port_id, RTE_UINT16);
16250 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16251 TOKEN_STRING_INITIALIZER
16252 (struct cmd_config_per_port_rx_offload_result,
16253 rx_offload, "rx_offload");
16254 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16255 TOKEN_STRING_INITIALIZER
16256 (struct cmd_config_per_port_rx_offload_result,
16257 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16258 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16259 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16260 "scatter#buffer_split#timestamp#security#"
16261 "keep_crc#rss_hash");
16262 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16263 TOKEN_STRING_INITIALIZER
16264 (struct cmd_config_per_port_rx_offload_result,
16268 search_rx_offload(const char *name)
16270 uint64_t single_offload;
16271 const char *single_name;
16275 single_offload = 1;
16276 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16277 single_name = rte_eth_dev_rx_offload_name(single_offload);
16278 if (!strcasecmp(single_name, name)) {
16282 single_offload <<= 1;
16286 return single_offload;
16292 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16293 __rte_unused struct cmdline *cl,
16294 __rte_unused void *data)
16296 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16297 portid_t port_id = res->port_id;
16298 struct rte_eth_dev_info dev_info;
16299 struct rte_port *port = &ports[port_id];
16300 uint64_t single_offload;
16301 uint16_t nb_rx_queues;
16305 if (port->port_status != RTE_PORT_STOPPED) {
16307 "Error: Can't config offload when Port %d is not stopped\n",
16312 single_offload = search_rx_offload(res->offload);
16313 if (single_offload == 0) {
16314 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16318 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16322 nb_rx_queues = dev_info.nb_rx_queues;
16323 if (!strcmp(res->on_off, "on")) {
16324 port->dev_conf.rxmode.offloads |= single_offload;
16325 for (q = 0; q < nb_rx_queues; q++)
16326 port->rx_conf[q].offloads |= single_offload;
16328 port->dev_conf.rxmode.offloads &= ~single_offload;
16329 for (q = 0; q < nb_rx_queues; q++)
16330 port->rx_conf[q].offloads &= ~single_offload;
16333 cmd_reconfig_device_queue(port_id, 1, 1);
16336 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16337 .f = cmd_config_per_port_rx_offload_parsed,
16339 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16340 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16341 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16342 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16343 "keep_crc|rss_hash on|off",
16345 (void *)&cmd_config_per_port_rx_offload_result_port,
16346 (void *)&cmd_config_per_port_rx_offload_result_config,
16347 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16348 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16349 (void *)&cmd_config_per_port_rx_offload_result_offload,
16350 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16355 /* Enable/Disable a per queue offloading */
16356 struct cmd_config_per_queue_rx_offload_result {
16357 cmdline_fixed_string_t port;
16359 cmdline_fixed_string_t rxq;
16361 cmdline_fixed_string_t rx_offload;
16362 cmdline_fixed_string_t offload;
16363 cmdline_fixed_string_t on_off;
16366 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16367 TOKEN_STRING_INITIALIZER
16368 (struct cmd_config_per_queue_rx_offload_result,
16370 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16371 TOKEN_NUM_INITIALIZER
16372 (struct cmd_config_per_queue_rx_offload_result,
16373 port_id, RTE_UINT16);
16374 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16375 TOKEN_STRING_INITIALIZER
16376 (struct cmd_config_per_queue_rx_offload_result,
16378 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16379 TOKEN_NUM_INITIALIZER
16380 (struct cmd_config_per_queue_rx_offload_result,
16381 queue_id, RTE_UINT16);
16382 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16383 TOKEN_STRING_INITIALIZER
16384 (struct cmd_config_per_queue_rx_offload_result,
16385 rx_offload, "rx_offload");
16386 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16387 TOKEN_STRING_INITIALIZER
16388 (struct cmd_config_per_queue_rx_offload_result,
16389 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16390 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16391 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16392 "scatter#buffer_split#timestamp#security#keep_crc");
16393 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16394 TOKEN_STRING_INITIALIZER
16395 (struct cmd_config_per_queue_rx_offload_result,
16399 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16400 __rte_unused struct cmdline *cl,
16401 __rte_unused void *data)
16403 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16404 struct rte_eth_dev_info dev_info;
16405 portid_t port_id = res->port_id;
16406 uint16_t queue_id = res->queue_id;
16407 struct rte_port *port = &ports[port_id];
16408 uint64_t single_offload;
16411 if (port->port_status != RTE_PORT_STOPPED) {
16413 "Error: Can't config offload when Port %d is not stopped\n",
16418 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16422 if (queue_id >= dev_info.nb_rx_queues) {
16424 "Error: input queue_id should be 0 ... %d\n",
16425 dev_info.nb_rx_queues - 1);
16429 single_offload = search_rx_offload(res->offload);
16430 if (single_offload == 0) {
16431 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16435 if (!strcmp(res->on_off, "on"))
16436 port->rx_conf[queue_id].offloads |= single_offload;
16438 port->rx_conf[queue_id].offloads &= ~single_offload;
16440 cmd_reconfig_device_queue(port_id, 1, 1);
16443 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16444 .f = cmd_config_per_queue_rx_offload_parsed,
16446 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16447 "vlan_strip|ipv4_cksum|"
16448 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16449 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16450 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16453 (void *)&cmd_config_per_queue_rx_offload_result_port,
16454 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16455 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16456 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16457 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16458 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16459 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16464 /* Get Tx offloads capabilities */
16465 struct cmd_tx_offload_get_capa_result {
16466 cmdline_fixed_string_t show;
16467 cmdline_fixed_string_t port;
16469 cmdline_fixed_string_t tx_offload;
16470 cmdline_fixed_string_t capabilities;
16473 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16474 TOKEN_STRING_INITIALIZER
16475 (struct cmd_tx_offload_get_capa_result,
16477 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16478 TOKEN_STRING_INITIALIZER
16479 (struct cmd_tx_offload_get_capa_result,
16481 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16482 TOKEN_NUM_INITIALIZER
16483 (struct cmd_tx_offload_get_capa_result,
16484 port_id, RTE_UINT16);
16485 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16486 TOKEN_STRING_INITIALIZER
16487 (struct cmd_tx_offload_get_capa_result,
16488 tx_offload, "tx_offload");
16489 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16490 TOKEN_STRING_INITIALIZER
16491 (struct cmd_tx_offload_get_capa_result,
16492 capabilities, "capabilities");
16495 print_tx_offloads(uint64_t offloads)
16497 uint64_t single_offload;
16505 begin = __builtin_ctzll(offloads);
16506 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16508 single_offload = 1ULL << begin;
16509 for (bit = begin; bit < end; bit++) {
16510 if (offloads & single_offload)
16512 rte_eth_dev_tx_offload_name(single_offload));
16513 single_offload <<= 1;
16518 cmd_tx_offload_get_capa_parsed(
16519 void *parsed_result,
16520 __rte_unused struct cmdline *cl,
16521 __rte_unused void *data)
16523 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16524 struct rte_eth_dev_info dev_info;
16525 portid_t port_id = res->port_id;
16526 uint64_t queue_offloads;
16527 uint64_t port_offloads;
16530 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16534 queue_offloads = dev_info.tx_queue_offload_capa;
16535 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16537 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16538 printf(" Per Queue :");
16539 print_tx_offloads(queue_offloads);
16542 printf(" Per Port :");
16543 print_tx_offloads(port_offloads);
16547 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16548 .f = cmd_tx_offload_get_capa_parsed,
16550 .help_str = "show port <port_id> tx_offload capabilities",
16552 (void *)&cmd_tx_offload_get_capa_show,
16553 (void *)&cmd_tx_offload_get_capa_port,
16554 (void *)&cmd_tx_offload_get_capa_port_id,
16555 (void *)&cmd_tx_offload_get_capa_tx_offload,
16556 (void *)&cmd_tx_offload_get_capa_capabilities,
16561 /* Get Tx offloads configuration */
16562 struct cmd_tx_offload_get_configuration_result {
16563 cmdline_fixed_string_t show;
16564 cmdline_fixed_string_t port;
16566 cmdline_fixed_string_t tx_offload;
16567 cmdline_fixed_string_t configuration;
16570 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16571 TOKEN_STRING_INITIALIZER
16572 (struct cmd_tx_offload_get_configuration_result,
16574 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16575 TOKEN_STRING_INITIALIZER
16576 (struct cmd_tx_offload_get_configuration_result,
16578 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16579 TOKEN_NUM_INITIALIZER
16580 (struct cmd_tx_offload_get_configuration_result,
16581 port_id, RTE_UINT16);
16582 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16583 TOKEN_STRING_INITIALIZER
16584 (struct cmd_tx_offload_get_configuration_result,
16585 tx_offload, "tx_offload");
16586 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16587 TOKEN_STRING_INITIALIZER
16588 (struct cmd_tx_offload_get_configuration_result,
16589 configuration, "configuration");
16592 cmd_tx_offload_get_configuration_parsed(
16593 void *parsed_result,
16594 __rte_unused struct cmdline *cl,
16595 __rte_unused void *data)
16597 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16598 struct rte_eth_dev_info dev_info;
16599 portid_t port_id = res->port_id;
16600 struct rte_port *port = &ports[port_id];
16601 struct rte_eth_conf dev_conf;
16602 uint64_t port_offloads;
16603 uint64_t queue_offloads;
16604 uint16_t nb_tx_queues;
16608 printf("Tx Offloading Configuration of port %d :\n", port_id);
16610 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16614 port_offloads = dev_conf.txmode.offloads;
16616 print_tx_offloads(port_offloads);
16619 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16623 nb_tx_queues = dev_info.nb_tx_queues;
16624 for (q = 0; q < nb_tx_queues; q++) {
16625 queue_offloads = port->tx_conf[q].offloads;
16626 printf(" Queue[%2d] :", q);
16627 print_tx_offloads(queue_offloads);
16633 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16634 .f = cmd_tx_offload_get_configuration_parsed,
16636 .help_str = "show port <port_id> tx_offload configuration",
16638 (void *)&cmd_tx_offload_get_configuration_show,
16639 (void *)&cmd_tx_offload_get_configuration_port,
16640 (void *)&cmd_tx_offload_get_configuration_port_id,
16641 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16642 (void *)&cmd_tx_offload_get_configuration_configuration,
16647 /* Enable/Disable a per port offloading */
16648 struct cmd_config_per_port_tx_offload_result {
16649 cmdline_fixed_string_t port;
16650 cmdline_fixed_string_t config;
16652 cmdline_fixed_string_t tx_offload;
16653 cmdline_fixed_string_t offload;
16654 cmdline_fixed_string_t on_off;
16657 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16658 TOKEN_STRING_INITIALIZER
16659 (struct cmd_config_per_port_tx_offload_result,
16661 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16662 TOKEN_STRING_INITIALIZER
16663 (struct cmd_config_per_port_tx_offload_result,
16665 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16666 TOKEN_NUM_INITIALIZER
16667 (struct cmd_config_per_port_tx_offload_result,
16668 port_id, RTE_UINT16);
16669 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16670 TOKEN_STRING_INITIALIZER
16671 (struct cmd_config_per_port_tx_offload_result,
16672 tx_offload, "tx_offload");
16673 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16674 TOKEN_STRING_INITIALIZER
16675 (struct cmd_config_per_port_tx_offload_result,
16676 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16677 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16678 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16679 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16680 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16681 "send_on_timestamp");
16682 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16683 TOKEN_STRING_INITIALIZER
16684 (struct cmd_config_per_port_tx_offload_result,
16688 search_tx_offload(const char *name)
16690 uint64_t single_offload;
16691 const char *single_name;
16695 single_offload = 1;
16696 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16697 single_name = rte_eth_dev_tx_offload_name(single_offload);
16698 if (single_name == NULL)
16700 if (!strcasecmp(single_name, name)) {
16703 } else if (!strcasecmp(single_name, "UNKNOWN"))
16705 single_offload <<= 1;
16709 return single_offload;
16715 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16716 __rte_unused struct cmdline *cl,
16717 __rte_unused void *data)
16719 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16720 portid_t port_id = res->port_id;
16721 struct rte_eth_dev_info dev_info;
16722 struct rte_port *port = &ports[port_id];
16723 uint64_t single_offload;
16724 uint16_t nb_tx_queues;
16728 if (port->port_status != RTE_PORT_STOPPED) {
16730 "Error: Can't config offload when Port %d is not stopped\n",
16735 single_offload = search_tx_offload(res->offload);
16736 if (single_offload == 0) {
16737 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16741 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16745 nb_tx_queues = dev_info.nb_tx_queues;
16746 if (!strcmp(res->on_off, "on")) {
16747 port->dev_conf.txmode.offloads |= single_offload;
16748 for (q = 0; q < nb_tx_queues; q++)
16749 port->tx_conf[q].offloads |= single_offload;
16751 port->dev_conf.txmode.offloads &= ~single_offload;
16752 for (q = 0; q < nb_tx_queues; q++)
16753 port->tx_conf[q].offloads &= ~single_offload;
16756 cmd_reconfig_device_queue(port_id, 1, 1);
16759 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16760 .f = cmd_config_per_port_tx_offload_parsed,
16762 .help_str = "port config <port_id> tx_offload "
16763 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16764 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16765 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16766 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16767 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16768 "send_on_timestamp on|off",
16770 (void *)&cmd_config_per_port_tx_offload_result_port,
16771 (void *)&cmd_config_per_port_tx_offload_result_config,
16772 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16773 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16774 (void *)&cmd_config_per_port_tx_offload_result_offload,
16775 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16780 /* Enable/Disable a per queue offloading */
16781 struct cmd_config_per_queue_tx_offload_result {
16782 cmdline_fixed_string_t port;
16784 cmdline_fixed_string_t txq;
16786 cmdline_fixed_string_t tx_offload;
16787 cmdline_fixed_string_t offload;
16788 cmdline_fixed_string_t on_off;
16791 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16792 TOKEN_STRING_INITIALIZER
16793 (struct cmd_config_per_queue_tx_offload_result,
16795 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16796 TOKEN_NUM_INITIALIZER
16797 (struct cmd_config_per_queue_tx_offload_result,
16798 port_id, RTE_UINT16);
16799 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16800 TOKEN_STRING_INITIALIZER
16801 (struct cmd_config_per_queue_tx_offload_result,
16803 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16804 TOKEN_NUM_INITIALIZER
16805 (struct cmd_config_per_queue_tx_offload_result,
16806 queue_id, RTE_UINT16);
16807 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16808 TOKEN_STRING_INITIALIZER
16809 (struct cmd_config_per_queue_tx_offload_result,
16810 tx_offload, "tx_offload");
16811 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16812 TOKEN_STRING_INITIALIZER
16813 (struct cmd_config_per_queue_tx_offload_result,
16814 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16815 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16816 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16817 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16818 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16819 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16820 TOKEN_STRING_INITIALIZER
16821 (struct cmd_config_per_queue_tx_offload_result,
16825 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16826 __rte_unused struct cmdline *cl,
16827 __rte_unused void *data)
16829 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16830 struct rte_eth_dev_info dev_info;
16831 portid_t port_id = res->port_id;
16832 uint16_t queue_id = res->queue_id;
16833 struct rte_port *port = &ports[port_id];
16834 uint64_t single_offload;
16837 if (port->port_status != RTE_PORT_STOPPED) {
16839 "Error: Can't config offload when Port %d is not stopped\n",
16844 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16848 if (queue_id >= dev_info.nb_tx_queues) {
16850 "Error: input queue_id should be 0 ... %d\n",
16851 dev_info.nb_tx_queues - 1);
16855 single_offload = search_tx_offload(res->offload);
16856 if (single_offload == 0) {
16857 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16861 if (!strcmp(res->on_off, "on"))
16862 port->tx_conf[queue_id].offloads |= single_offload;
16864 port->tx_conf[queue_id].offloads &= ~single_offload;
16866 cmd_reconfig_device_queue(port_id, 1, 1);
16869 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16870 .f = cmd_config_per_queue_tx_offload_parsed,
16872 .help_str = "port <port_id> txq <queue_id> tx_offload "
16873 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16874 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16875 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16876 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16877 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16880 (void *)&cmd_config_per_queue_tx_offload_result_port,
16881 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16882 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16883 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16884 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16885 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16886 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16891 /* *** configure tx_metadata for specific port *** */
16892 struct cmd_config_tx_metadata_specific_result {
16893 cmdline_fixed_string_t port;
16894 cmdline_fixed_string_t keyword;
16896 cmdline_fixed_string_t item;
16901 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16902 __rte_unused struct cmdline *cl,
16903 __rte_unused void *data)
16905 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16907 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16909 ports[res->port_id].tx_metadata = res->value;
16910 /* Add/remove callback to insert valid metadata in every Tx packet. */
16911 if (ports[res->port_id].tx_metadata)
16912 add_tx_md_callback(res->port_id);
16914 remove_tx_md_callback(res->port_id);
16915 rte_flow_dynf_metadata_register();
16918 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16919 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16921 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16922 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16923 keyword, "config");
16924 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16925 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16926 port_id, RTE_UINT16);
16927 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16928 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16929 item, "tx_metadata");
16930 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16931 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16932 value, RTE_UINT32);
16934 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16935 .f = cmd_config_tx_metadata_specific_parsed,
16937 .help_str = "port config <port_id> tx_metadata <value>",
16939 (void *)&cmd_config_tx_metadata_specific_port,
16940 (void *)&cmd_config_tx_metadata_specific_keyword,
16941 (void *)&cmd_config_tx_metadata_specific_id,
16942 (void *)&cmd_config_tx_metadata_specific_item,
16943 (void *)&cmd_config_tx_metadata_specific_value,
16948 /* *** set dynf *** */
16949 struct cmd_config_tx_dynf_specific_result {
16950 cmdline_fixed_string_t port;
16951 cmdline_fixed_string_t keyword;
16953 cmdline_fixed_string_t item;
16954 cmdline_fixed_string_t name;
16955 cmdline_fixed_string_t value;
16959 cmd_config_dynf_specific_parsed(void *parsed_result,
16960 __rte_unused struct cmdline *cl,
16961 __rte_unused void *data)
16963 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16964 struct rte_mbuf_dynflag desc_flag;
16966 uint64_t old_port_flags;
16968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16970 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16972 if (strlcpy(desc_flag.name, res->name,
16973 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16974 fprintf(stderr, "Flag name too long\n");
16977 desc_flag.flags = 0;
16978 flag = rte_mbuf_dynflag_register(&desc_flag);
16980 fprintf(stderr, "Can't register flag\n");
16983 strcpy(dynf_names[flag], desc_flag.name);
16985 old_port_flags = ports[res->port_id].mbuf_dynf;
16986 if (!strcmp(res->value, "set")) {
16987 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16988 if (old_port_flags == 0)
16989 add_tx_dynf_callback(res->port_id);
16991 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16992 if (ports[res->port_id].mbuf_dynf == 0)
16993 remove_tx_dynf_callback(res->port_id);
16997 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16998 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17000 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
17001 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17002 keyword, "config");
17003 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17004 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17005 port_id, RTE_UINT16);
17006 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17007 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17009 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17010 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17012 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17013 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17014 value, "set#clear");
17016 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17017 .f = cmd_config_dynf_specific_parsed,
17019 .help_str = "port config <port id> dynf <name> set|clear",
17021 (void *)&cmd_config_tx_dynf_specific_port,
17022 (void *)&cmd_config_tx_dynf_specific_keyword,
17023 (void *)&cmd_config_tx_dynf_specific_port_id,
17024 (void *)&cmd_config_tx_dynf_specific_item,
17025 (void *)&cmd_config_tx_dynf_specific_name,
17026 (void *)&cmd_config_tx_dynf_specific_value,
17031 /* *** display tx_metadata per port configuration *** */
17032 struct cmd_show_tx_metadata_result {
17033 cmdline_fixed_string_t cmd_show;
17034 cmdline_fixed_string_t cmd_port;
17035 cmdline_fixed_string_t cmd_keyword;
17040 cmd_show_tx_metadata_parsed(void *parsed_result,
17041 __rte_unused struct cmdline *cl,
17042 __rte_unused void *data)
17044 struct cmd_show_tx_metadata_result *res = parsed_result;
17046 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17047 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17050 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17051 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17052 ports[res->cmd_pid].tx_metadata);
17056 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17057 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17059 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17060 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17062 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17063 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17064 cmd_pid, RTE_UINT16);
17065 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17066 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17067 cmd_keyword, "tx_metadata");
17069 cmdline_parse_inst_t cmd_show_tx_metadata = {
17070 .f = cmd_show_tx_metadata_parsed,
17072 .help_str = "show port <port_id> tx_metadata",
17074 (void *)&cmd_show_tx_metadata_show,
17075 (void *)&cmd_show_tx_metadata_port,
17076 (void *)&cmd_show_tx_metadata_pid,
17077 (void *)&cmd_show_tx_metadata_keyword,
17082 /* *** show fec capability per port configuration *** */
17083 struct cmd_show_fec_capability_result {
17084 cmdline_fixed_string_t cmd_show;
17085 cmdline_fixed_string_t cmd_port;
17086 cmdline_fixed_string_t cmd_fec;
17087 cmdline_fixed_string_t cmd_keyword;
17092 cmd_show_fec_capability_parsed(void *parsed_result,
17093 __rte_unused struct cmdline *cl,
17094 __rte_unused void *data)
17096 struct cmd_show_fec_capability_result *res = parsed_result;
17097 struct rte_eth_fec_capa *speed_fec_capa;
17101 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17102 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17106 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
17107 if (ret == -ENOTSUP) {
17108 fprintf(stderr, "Function not implemented\n");
17110 } else if (ret < 0) {
17111 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
17115 num = (unsigned int)ret;
17116 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
17117 if (speed_fec_capa == NULL) {
17118 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
17122 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17124 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17128 show_fec_capability(num, speed_fec_capa);
17130 free(speed_fec_capa);
17133 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17134 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17136 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17137 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17139 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17140 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17141 cmd_pid, RTE_UINT16);
17142 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17143 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17145 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17146 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17147 cmd_keyword, "capabilities");
17149 cmdline_parse_inst_t cmd_show_capability = {
17150 .f = cmd_show_fec_capability_parsed,
17152 .help_str = "show port <port_id> fec capabilities",
17154 (void *)&cmd_show_fec_capability_show,
17155 (void *)&cmd_show_fec_capability_port,
17156 (void *)&cmd_show_fec_capability_pid,
17157 (void *)&cmd_show_fec_capability_fec,
17158 (void *)&cmd_show_fec_capability_keyword,
17163 /* *** show fec mode per port configuration *** */
17164 struct cmd_show_fec_metadata_result {
17165 cmdline_fixed_string_t cmd_show;
17166 cmdline_fixed_string_t cmd_port;
17167 cmdline_fixed_string_t cmd_keyword;
17172 cmd_show_fec_mode_parsed(void *parsed_result,
17173 __rte_unused struct cmdline *cl,
17174 __rte_unused void *data)
17176 #define FEC_NAME_SIZE 16
17177 struct cmd_show_fec_metadata_result *res = parsed_result;
17179 char buf[FEC_NAME_SIZE];
17182 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17183 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17186 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17187 if (ret == -ENOTSUP) {
17188 fprintf(stderr, "Function not implemented\n");
17190 } else if (ret < 0) {
17191 fprintf(stderr, "Get FEC mode failed\n");
17196 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17197 strlcpy(buf, "off", sizeof(buf));
17199 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17200 strlcpy(buf, "auto", sizeof(buf));
17202 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17203 strlcpy(buf, "baser", sizeof(buf));
17205 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17206 strlcpy(buf, "rs", sizeof(buf));
17212 printf("%s\n", buf);
17215 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17216 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17218 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17219 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17221 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17222 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17223 cmd_pid, RTE_UINT16);
17224 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17225 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17226 cmd_keyword, "fec_mode");
17228 cmdline_parse_inst_t cmd_show_fec_mode = {
17229 .f = cmd_show_fec_mode_parsed,
17231 .help_str = "show port <port_id> fec_mode",
17233 (void *)&cmd_show_fec_mode_show,
17234 (void *)&cmd_show_fec_mode_port,
17235 (void *)&cmd_show_fec_mode_pid,
17236 (void *)&cmd_show_fec_mode_keyword,
17241 /* *** set fec mode per port configuration *** */
17242 struct cmd_set_port_fec_mode {
17243 cmdline_fixed_string_t set;
17244 cmdline_fixed_string_t port;
17246 cmdline_fixed_string_t fec_mode;
17247 cmdline_fixed_string_t fec_value;
17250 /* Common CLI fields for set fec mode */
17251 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17252 TOKEN_STRING_INITIALIZER
17253 (struct cmd_set_port_fec_mode,
17255 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17256 TOKEN_STRING_INITIALIZER
17257 (struct cmd_set_port_fec_mode,
17259 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17260 TOKEN_NUM_INITIALIZER
17261 (struct cmd_set_port_fec_mode,
17262 port_id, RTE_UINT16);
17263 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17264 TOKEN_STRING_INITIALIZER
17265 (struct cmd_set_port_fec_mode,
17266 fec_mode, "fec_mode");
17267 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17268 TOKEN_STRING_INITIALIZER
17269 (struct cmd_set_port_fec_mode,
17273 cmd_set_port_fec_mode_parsed(
17274 void *parsed_result,
17275 __rte_unused struct cmdline *cl,
17276 __rte_unused void *data)
17278 struct cmd_set_port_fec_mode *res = parsed_result;
17279 uint16_t port_id = res->port_id;
17283 ret = parse_fec_mode(res->fec_value, &fec_capa);
17285 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17286 res->fec_value, port_id);
17290 ret = rte_eth_fec_set(port_id, fec_capa);
17291 if (ret == -ENOTSUP) {
17292 fprintf(stderr, "Function not implemented\n");
17294 } else if (ret < 0) {
17295 fprintf(stderr, "Set FEC mode failed\n");
17300 cmdline_parse_inst_t cmd_set_fec_mode = {
17301 .f = cmd_set_port_fec_mode_parsed,
17303 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17305 (void *)&cmd_set_port_fec_mode_set,
17306 (void *)&cmd_set_port_fec_mode_port,
17307 (void *)&cmd_set_port_fec_mode_port_id,
17308 (void *)&cmd_set_port_fec_mode_str,
17309 (void *)&cmd_set_port_fec_mode_value,
17314 /* show port supported ptypes */
17316 /* Common result structure for show port ptypes */
17317 struct cmd_show_port_supported_ptypes_result {
17318 cmdline_fixed_string_t show;
17319 cmdline_fixed_string_t port;
17321 cmdline_fixed_string_t ptypes;
17324 /* Common CLI fields for show port ptypes */
17325 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17326 TOKEN_STRING_INITIALIZER
17327 (struct cmd_show_port_supported_ptypes_result,
17329 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17330 TOKEN_STRING_INITIALIZER
17331 (struct cmd_show_port_supported_ptypes_result,
17333 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17334 TOKEN_NUM_INITIALIZER
17335 (struct cmd_show_port_supported_ptypes_result,
17336 port_id, RTE_UINT16);
17337 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17338 TOKEN_STRING_INITIALIZER
17339 (struct cmd_show_port_supported_ptypes_result,
17343 cmd_show_port_supported_ptypes_parsed(
17344 void *parsed_result,
17345 __rte_unused struct cmdline *cl,
17346 __rte_unused void *data)
17348 #define RSVD_PTYPE_MASK 0xf0000000
17349 #define MAX_PTYPES_PER_LAYER 16
17350 #define LTYPE_NAMESIZE 32
17351 #define PTYPE_NAMESIZE 256
17352 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17353 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17354 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17355 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17356 uint16_t port_id = res->port_id;
17359 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17363 while (ptype_mask != RSVD_PTYPE_MASK) {
17365 switch (ptype_mask) {
17366 case RTE_PTYPE_L2_MASK:
17367 strlcpy(ltype, "L2", sizeof(ltype));
17369 case RTE_PTYPE_L3_MASK:
17370 strlcpy(ltype, "L3", sizeof(ltype));
17372 case RTE_PTYPE_L4_MASK:
17373 strlcpy(ltype, "L4", sizeof(ltype));
17375 case RTE_PTYPE_TUNNEL_MASK:
17376 strlcpy(ltype, "Tunnel", sizeof(ltype));
17378 case RTE_PTYPE_INNER_L2_MASK:
17379 strlcpy(ltype, "Inner L2", sizeof(ltype));
17381 case RTE_PTYPE_INNER_L3_MASK:
17382 strlcpy(ltype, "Inner L3", sizeof(ltype));
17384 case RTE_PTYPE_INNER_L4_MASK:
17385 strlcpy(ltype, "Inner L4", sizeof(ltype));
17391 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17392 ptype_mask, ptypes,
17393 MAX_PTYPES_PER_LAYER);
17396 printf("Supported %s ptypes:\n", ltype);
17398 printf("%s ptypes unsupported\n", ltype);
17400 for (i = 0; i < ret; ++i) {
17401 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17402 printf("%s\n", buf);
17409 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17410 .f = cmd_show_port_supported_ptypes_parsed,
17412 .help_str = "show port <port_id> ptypes",
17414 (void *)&cmd_show_port_supported_ptypes_show,
17415 (void *)&cmd_show_port_supported_ptypes_port,
17416 (void *)&cmd_show_port_supported_ptypes_port_id,
17417 (void *)&cmd_show_port_supported_ptypes_ptypes,
17422 /* *** display rx/tx descriptor status *** */
17423 struct cmd_show_rx_tx_desc_status_result {
17424 cmdline_fixed_string_t cmd_show;
17425 cmdline_fixed_string_t cmd_port;
17426 cmdline_fixed_string_t cmd_keyword;
17427 cmdline_fixed_string_t cmd_desc;
17428 cmdline_fixed_string_t cmd_status;
17435 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17436 __rte_unused struct cmdline *cl,
17437 __rte_unused void *data)
17439 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17442 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17443 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17447 if (!strcmp(res->cmd_keyword, "rxq")) {
17448 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17452 "Invalid input: queue id = %d, desc id = %d\n",
17453 res->cmd_qid, res->cmd_did);
17456 if (rc == RTE_ETH_RX_DESC_AVAIL)
17457 printf("Desc status = AVAILABLE\n");
17458 else if (rc == RTE_ETH_RX_DESC_DONE)
17459 printf("Desc status = DONE\n");
17461 printf("Desc status = UNAVAILABLE\n");
17462 } else if (!strcmp(res->cmd_keyword, "txq")) {
17463 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17467 "Invalid input: queue id = %d, desc id = %d\n",
17468 res->cmd_qid, res->cmd_did);
17471 if (rc == RTE_ETH_TX_DESC_FULL)
17472 printf("Desc status = FULL\n");
17473 else if (rc == RTE_ETH_TX_DESC_DONE)
17474 printf("Desc status = DONE\n");
17476 printf("Desc status = UNAVAILABLE\n");
17480 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17481 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17483 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17484 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17486 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17487 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17488 cmd_pid, RTE_UINT16);
17489 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17490 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17491 cmd_keyword, "rxq#txq");
17492 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17493 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17494 cmd_qid, RTE_UINT16);
17495 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17496 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17498 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17499 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17500 cmd_did, RTE_UINT16);
17501 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17502 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17503 cmd_status, "status");
17504 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17505 .f = cmd_show_rx_tx_desc_status_parsed,
17507 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17510 (void *)&cmd_show_rx_tx_desc_status_show,
17511 (void *)&cmd_show_rx_tx_desc_status_port,
17512 (void *)&cmd_show_rx_tx_desc_status_pid,
17513 (void *)&cmd_show_rx_tx_desc_status_keyword,
17514 (void *)&cmd_show_rx_tx_desc_status_qid,
17515 (void *)&cmd_show_rx_tx_desc_status_desc,
17516 (void *)&cmd_show_rx_tx_desc_status_did,
17517 (void *)&cmd_show_rx_tx_desc_status_status,
17522 /* *** display rx queue desc used count *** */
17523 struct cmd_show_rx_queue_desc_used_count_result {
17524 cmdline_fixed_string_t cmd_show;
17525 cmdline_fixed_string_t cmd_port;
17526 cmdline_fixed_string_t cmd_rxq;
17527 cmdline_fixed_string_t cmd_desc;
17528 cmdline_fixed_string_t cmd_used;
17529 cmdline_fixed_string_t cmd_count;
17535 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17536 __rte_unused struct cmdline *cl,
17537 __rte_unused void *data)
17539 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17542 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17543 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17547 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17549 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17552 printf("Used desc count = %d\n", rc);
17555 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17556 TOKEN_STRING_INITIALIZER
17557 (struct cmd_show_rx_queue_desc_used_count_result,
17559 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17560 TOKEN_STRING_INITIALIZER
17561 (struct cmd_show_rx_queue_desc_used_count_result,
17563 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17564 TOKEN_NUM_INITIALIZER
17565 (struct cmd_show_rx_queue_desc_used_count_result,
17566 cmd_pid, RTE_UINT16);
17567 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17568 TOKEN_STRING_INITIALIZER
17569 (struct cmd_show_rx_queue_desc_used_count_result,
17571 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17572 TOKEN_NUM_INITIALIZER
17573 (struct cmd_show_rx_queue_desc_used_count_result,
17574 cmd_qid, RTE_UINT16);
17575 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17576 TOKEN_STRING_INITIALIZER
17577 (struct cmd_show_rx_queue_desc_used_count_result,
17578 cmd_count, "desc");
17579 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17580 TOKEN_STRING_INITIALIZER
17581 (struct cmd_show_rx_queue_desc_used_count_result,
17582 cmd_count, "used");
17583 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17584 TOKEN_STRING_INITIALIZER
17585 (struct cmd_show_rx_queue_desc_used_count_result,
17586 cmd_count, "count");
17587 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17588 .f = cmd_show_rx_queue_desc_used_count_parsed,
17590 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17592 (void *)&cmd_show_rx_queue_desc_used_count_show,
17593 (void *)&cmd_show_rx_queue_desc_used_count_port,
17594 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17595 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17596 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17597 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17598 (void *)&cmd_show_rx_queue_desc_used_count_used,
17599 (void *)&cmd_show_rx_queue_desc_used_count_count,
17604 /* Common result structure for set port ptypes */
17605 struct cmd_set_port_ptypes_result {
17606 cmdline_fixed_string_t set;
17607 cmdline_fixed_string_t port;
17609 cmdline_fixed_string_t ptype_mask;
17613 /* Common CLI fields for set port ptypes */
17614 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17615 TOKEN_STRING_INITIALIZER
17616 (struct cmd_set_port_ptypes_result,
17618 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17619 TOKEN_STRING_INITIALIZER
17620 (struct cmd_set_port_ptypes_result,
17622 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17623 TOKEN_NUM_INITIALIZER
17624 (struct cmd_set_port_ptypes_result,
17625 port_id, RTE_UINT16);
17626 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17627 TOKEN_STRING_INITIALIZER
17628 (struct cmd_set_port_ptypes_result,
17629 ptype_mask, "ptype_mask");
17630 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17631 TOKEN_NUM_INITIALIZER
17632 (struct cmd_set_port_ptypes_result,
17636 cmd_set_port_ptypes_parsed(
17637 void *parsed_result,
17638 __rte_unused struct cmdline *cl,
17639 __rte_unused void *data)
17641 struct cmd_set_port_ptypes_result *res = parsed_result;
17642 #define PTYPE_NAMESIZE 256
17643 char ptype_name[PTYPE_NAMESIZE];
17644 uint16_t port_id = res->port_id;
17645 uint32_t ptype_mask = res->mask;
17648 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17651 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17656 uint32_t ptypes[ret];
17658 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17660 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17665 printf("Successfully set following ptypes for Port %d\n", port_id);
17666 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17667 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17668 printf("%s\n", ptype_name);
17671 clear_ptypes = false;
17674 cmdline_parse_inst_t cmd_set_port_ptypes = {
17675 .f = cmd_set_port_ptypes_parsed,
17677 .help_str = "set port <port_id> ptype_mask <mask>",
17679 (void *)&cmd_set_port_ptypes_set,
17680 (void *)&cmd_set_port_ptypes_port,
17681 (void *)&cmd_set_port_ptypes_port_id,
17682 (void *)&cmd_set_port_ptypes_mask_str,
17683 (void *)&cmd_set_port_ptypes_mask_u32,
17688 /* *** display mac addresses added to a port *** */
17689 struct cmd_showport_macs_result {
17690 cmdline_fixed_string_t cmd_show;
17691 cmdline_fixed_string_t cmd_port;
17692 cmdline_fixed_string_t cmd_keyword;
17697 cmd_showport_macs_parsed(void *parsed_result,
17698 __rte_unused struct cmdline *cl,
17699 __rte_unused void *data)
17701 struct cmd_showport_macs_result *res = parsed_result;
17703 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17706 if (!strcmp(res->cmd_keyword, "macs"))
17707 show_macs(res->cmd_pid);
17708 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17709 show_mcast_macs(res->cmd_pid);
17712 cmdline_parse_token_string_t cmd_showport_macs_show =
17713 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17715 cmdline_parse_token_string_t cmd_showport_macs_port =
17716 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17718 cmdline_parse_token_num_t cmd_showport_macs_pid =
17719 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17720 cmd_pid, RTE_UINT16);
17721 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17722 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17723 cmd_keyword, "macs#mcast_macs");
17725 cmdline_parse_inst_t cmd_showport_macs = {
17726 .f = cmd_showport_macs_parsed,
17728 .help_str = "show port <port_id> macs|mcast_macs",
17730 (void *)&cmd_showport_macs_show,
17731 (void *)&cmd_showport_macs_port,
17732 (void *)&cmd_showport_macs_pid,
17733 (void *)&cmd_showport_macs_keyword,
17738 /* *** show flow transfer proxy port ID for the given port *** */
17739 struct cmd_show_port_flow_transfer_proxy_result {
17740 cmdline_fixed_string_t show;
17741 cmdline_fixed_string_t port;
17743 cmdline_fixed_string_t flow;
17744 cmdline_fixed_string_t transfer;
17745 cmdline_fixed_string_t proxy;
17748 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17749 TOKEN_STRING_INITIALIZER
17750 (struct cmd_show_port_flow_transfer_proxy_result,
17752 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17753 TOKEN_STRING_INITIALIZER
17754 (struct cmd_show_port_flow_transfer_proxy_result,
17756 cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17757 TOKEN_NUM_INITIALIZER
17758 (struct cmd_show_port_flow_transfer_proxy_result,
17759 port_id, RTE_UINT16);
17760 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17761 TOKEN_STRING_INITIALIZER
17762 (struct cmd_show_port_flow_transfer_proxy_result,
17764 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17765 TOKEN_STRING_INITIALIZER
17766 (struct cmd_show_port_flow_transfer_proxy_result,
17767 transfer, "transfer");
17768 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17769 TOKEN_STRING_INITIALIZER
17770 (struct cmd_show_port_flow_transfer_proxy_result,
17774 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17775 __rte_unused struct cmdline *cl,
17776 __rte_unused void *data)
17778 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17779 portid_t proxy_port_id;
17784 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17786 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17787 rte_strerror(-ret));
17791 printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17794 cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17795 .f = cmd_show_port_flow_transfer_proxy_parsed,
17797 .help_str = "show port <port_id> flow transfer proxy",
17799 (void *)&cmd_show_port_flow_transfer_proxy_show,
17800 (void *)&cmd_show_port_flow_transfer_proxy_port,
17801 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
17802 (void *)&cmd_show_port_flow_transfer_proxy_flow,
17803 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
17804 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
17809 /* ******************************************************************************** */
17811 /* list of instructions */
17812 cmdline_parse_ctx_t main_ctx[] = {
17813 (cmdline_parse_inst_t *)&cmd_help_brief,
17814 (cmdline_parse_inst_t *)&cmd_help_long,
17815 (cmdline_parse_inst_t *)&cmd_quit,
17816 (cmdline_parse_inst_t *)&cmd_load_from_file,
17817 (cmdline_parse_inst_t *)&cmd_showport,
17818 (cmdline_parse_inst_t *)&cmd_showqueue,
17819 (cmdline_parse_inst_t *)&cmd_showeeprom,
17820 (cmdline_parse_inst_t *)&cmd_showportall,
17821 (cmdline_parse_inst_t *)&cmd_representor_info,
17822 (cmdline_parse_inst_t *)&cmd_showdevice,
17823 (cmdline_parse_inst_t *)&cmd_showcfg,
17824 (cmdline_parse_inst_t *)&cmd_showfwdall,
17825 (cmdline_parse_inst_t *)&cmd_start,
17826 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17827 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17828 (cmdline_parse_inst_t *)&cmd_set_link_up,
17829 (cmdline_parse_inst_t *)&cmd_set_link_down,
17830 (cmdline_parse_inst_t *)&cmd_reset,
17831 (cmdline_parse_inst_t *)&cmd_set_numbers,
17832 (cmdline_parse_inst_t *)&cmd_set_log,
17833 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17834 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17835 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17836 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17837 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17838 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17839 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17840 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17841 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17842 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17843 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17844 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17845 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17846 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17847 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17848 (cmdline_parse_inst_t *)&cmd_set_link_check,
17849 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17850 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17851 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17852 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17853 #ifdef RTE_NET_BOND
17854 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17855 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17856 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17857 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17858 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17859 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17860 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17861 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17862 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17863 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17864 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17865 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17867 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17868 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17869 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17870 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17871 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17872 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17873 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17874 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17875 (cmdline_parse_inst_t *)&cmd_csum_set,
17876 (cmdline_parse_inst_t *)&cmd_csum_show,
17877 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17878 (cmdline_parse_inst_t *)&cmd_tso_set,
17879 (cmdline_parse_inst_t *)&cmd_tso_show,
17880 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17881 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17883 (cmdline_parse_inst_t *)&cmd_gro_enable,
17884 (cmdline_parse_inst_t *)&cmd_gro_flush,
17885 (cmdline_parse_inst_t *)&cmd_gro_show,
17888 (cmdline_parse_inst_t *)&cmd_gso_enable,
17889 (cmdline_parse_inst_t *)&cmd_gso_size,
17890 (cmdline_parse_inst_t *)&cmd_gso_show,
17892 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17893 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17894 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17895 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17896 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17897 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17898 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17899 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17900 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17901 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17902 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17903 (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
17904 (cmdline_parse_inst_t *)&cmd_config_dcb,
17905 (cmdline_parse_inst_t *)&cmd_read_reg,
17906 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17907 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17908 (cmdline_parse_inst_t *)&cmd_write_reg,
17909 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17910 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17911 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17912 (cmdline_parse_inst_t *)&cmd_stop,
17913 (cmdline_parse_inst_t *)&cmd_mac_addr,
17914 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17915 (cmdline_parse_inst_t *)&cmd_set_qmap,
17916 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17917 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17918 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17919 (cmdline_parse_inst_t *)&cmd_operate_port,
17920 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17921 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17922 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17923 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17924 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17925 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17926 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17927 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17928 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17929 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17930 (cmdline_parse_inst_t *)&cmd_config_mtu,
17931 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17932 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17933 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17934 (cmdline_parse_inst_t *)&cmd_config_rss,
17935 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17936 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17937 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17938 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17939 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17940 (cmdline_parse_inst_t *)&cmd_showport_reta,
17941 (cmdline_parse_inst_t *)&cmd_showport_macs,
17942 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17943 (cmdline_parse_inst_t *)&cmd_config_burst,
17944 (cmdline_parse_inst_t *)&cmd_config_thresh,
17945 (cmdline_parse_inst_t *)&cmd_config_threshold,
17946 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17947 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17948 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17949 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17950 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17951 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17952 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17953 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17954 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17955 (cmdline_parse_inst_t *)&cmd_dump,
17956 (cmdline_parse_inst_t *)&cmd_dump_one,
17957 #ifdef RTE_NET_I40E
17958 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17960 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17961 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17962 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17963 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17964 (cmdline_parse_inst_t *)&cmd_flow,
17965 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17966 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17967 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17968 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17969 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17970 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17971 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17972 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17973 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17974 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17975 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17976 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17977 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17978 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17979 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17980 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17981 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17982 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17983 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17984 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17985 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17986 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17987 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17988 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17989 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17990 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17991 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17992 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17993 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17994 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17995 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17996 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17997 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17998 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17999 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18000 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18001 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18002 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18003 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18004 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18005 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18006 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18007 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18008 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18009 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18010 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18011 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18012 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18013 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18014 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18015 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18016 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18017 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18018 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18019 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18020 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18021 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
18022 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
18023 (cmdline_parse_inst_t *)&cmd_ddp_add,
18024 (cmdline_parse_inst_t *)&cmd_ddp_del,
18025 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18026 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18027 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18028 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18029 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18030 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18031 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18032 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18033 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18034 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18035 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18036 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18038 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18039 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18040 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18041 (cmdline_parse_inst_t *)&cmd_queue_region,
18042 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18043 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18044 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18045 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18046 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18047 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18048 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18049 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18050 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18051 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18052 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18053 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18054 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18055 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18056 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18057 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18058 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18059 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18060 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18061 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18062 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18063 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18064 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18065 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18066 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18067 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18068 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18069 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18070 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18071 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18072 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18073 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18074 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18075 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18076 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18077 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18079 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18080 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18082 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18083 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18084 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18085 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
18086 (cmdline_parse_inst_t *)&cmd_set_raw,
18087 (cmdline_parse_inst_t *)&cmd_show_set_raw,
18088 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18089 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18090 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
18091 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
18092 (cmdline_parse_inst_t *)&cmd_show_capability,
18093 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
18094 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
18098 /* read cmdline commands from file */
18100 cmdline_read_from_file(const char *filename)
18102 struct cmdline *cl;
18104 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18107 "Failed to create file based cmdline context: %s\n",
18112 cmdline_interact(cl);
18117 printf("Read CLI commands from %s\n", filename);
18120 /* prompt function, called from main on MAIN lcore */
18125 /* initialize non-constant commands */
18126 cmd_set_fwd_mode_init();
18127 cmd_set_fwd_retry_mode_init();
18129 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18130 if (testpmd_cl == NULL)
18133 ret = atexit(prompt_exit);
18135 fprintf(stderr, "Cannot set exit function for cmdline\n");
18137 cmdline_interact(testpmd_cl);
18139 cmdline_stdin_exit(testpmd_cl);
18145 if (testpmd_cl != NULL) {
18146 cmdline_quit(testpmd_cl);
18147 cmdline_stdin_exit(testpmd_cl);
18152 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18154 if (id == (portid_t)RTE_PORT_ALL) {
18157 RTE_ETH_FOREACH_DEV(pid) {
18158 /* check if need_reconfig has been set to 1 */
18159 if (ports[pid].need_reconfig == 0)
18160 ports[pid].need_reconfig = dev;
18161 /* check if need_reconfig_queues has been set to 1 */
18162 if (ports[pid].need_reconfig_queues == 0)
18163 ports[pid].need_reconfig_queues = queue;
18165 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18166 /* check if need_reconfig has been set to 1 */
18167 if (ports[id].need_reconfig == 0)
18168 ports[id].need_reconfig = dev;
18169 /* check if need_reconfig_queues has been set to 1 */
18170 if (ports[id].need_reconfig_queues == 0)
18171 ports[id].need_reconfig_queues = queue;