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)strtoull(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);
9412 RTE_SET_USED(vf_rxmode);
9414 #ifdef RTE_NET_IXGBE
9415 if (ret == -ENOTSUP)
9416 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9417 vf_rxmode, (uint8_t)is_on);
9420 if (ret == -ENOTSUP)
9421 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9422 vf_rxmode, (uint8_t)is_on);
9426 "bad VF receive mode parameter, return code = %d\n",
9430 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9431 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9433 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9434 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9436 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9437 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9438 port_id, RTE_UINT16);
9439 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9440 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9442 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9443 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9445 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9446 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9448 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9449 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9450 mode, "AUPE#ROPE#BAM#MPE");
9451 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9452 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9455 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9456 .f = cmd_set_vf_rxmode_parsed,
9458 .help_str = "set port <port_id> vf <vf_id> rxmode "
9459 "AUPE|ROPE|BAM|MPE on|off",
9461 (void *)&cmd_set_vf_rxmode_set,
9462 (void *)&cmd_set_vf_rxmode_port,
9463 (void *)&cmd_set_vf_rxmode_portid,
9464 (void *)&cmd_set_vf_rxmode_vf,
9465 (void *)&cmd_set_vf_rxmode_vfid,
9466 (void *)&cmd_set_vf_rxmode_what,
9467 (void *)&cmd_set_vf_rxmode_mode,
9468 (void *)&cmd_set_vf_rxmode_on,
9473 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9474 struct cmd_vf_mac_addr_result {
9475 cmdline_fixed_string_t mac_addr_cmd;
9476 cmdline_fixed_string_t what;
9477 cmdline_fixed_string_t port;
9479 cmdline_fixed_string_t vf;
9481 struct rte_ether_addr address;
9484 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9485 __rte_unused struct cmdline *cl,
9486 __rte_unused void *data)
9488 struct cmd_vf_mac_addr_result *res = parsed_result;
9491 if (strcmp(res->what, "add") != 0)
9495 if (ret == -ENOTSUP)
9496 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9500 if (ret == -ENOTSUP)
9501 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9506 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9510 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9511 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9512 mac_addr_cmd,"mac_addr");
9513 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9514 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9516 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9517 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9519 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9520 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9521 port_num, RTE_UINT16);
9522 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9523 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9525 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9526 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9528 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9529 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9532 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9533 .f = cmd_vf_mac_addr_parsed,
9535 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9536 "Add MAC address filtering for a VF on port_id",
9538 (void *)&cmd_vf_mac_addr_cmd,
9539 (void *)&cmd_vf_mac_addr_what,
9540 (void *)&cmd_vf_mac_addr_port,
9541 (void *)&cmd_vf_mac_addr_portnum,
9542 (void *)&cmd_vf_mac_addr_vf,
9543 (void *)&cmd_vf_mac_addr_vfnum,
9544 (void *)&cmd_vf_mac_addr_addr,
9549 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9550 struct cmd_vf_rx_vlan_filter {
9551 cmdline_fixed_string_t rx_vlan;
9552 cmdline_fixed_string_t what;
9554 cmdline_fixed_string_t port;
9556 cmdline_fixed_string_t vf;
9561 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9562 __rte_unused struct cmdline *cl,
9563 __rte_unused void *data)
9565 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9568 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9570 #ifdef RTE_NET_IXGBE
9571 if (ret == -ENOTSUP)
9572 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9573 res->vlan_id, res->vf_mask, is_add);
9576 if (ret == -ENOTSUP)
9577 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9578 res->vlan_id, res->vf_mask, is_add);
9581 if (ret == -ENOTSUP)
9582 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9583 res->vlan_id, res->vf_mask, is_add);
9590 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9591 res->vlan_id, res->vf_mask);
9594 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9597 fprintf(stderr, "function not implemented or supported\n");
9600 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9604 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9605 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9606 rx_vlan, "rx_vlan");
9607 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9608 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9610 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9611 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9612 vlan_id, RTE_UINT16);
9613 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9614 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9616 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9617 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9618 port_id, RTE_UINT16);
9619 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9620 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9622 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9623 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9624 vf_mask, RTE_UINT64);
9626 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9627 .f = cmd_vf_rx_vlan_filter_parsed,
9629 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9630 "(vf_mask = hexadecimal VF mask)",
9632 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9633 (void *)&cmd_vf_rx_vlan_filter_what,
9634 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9635 (void *)&cmd_vf_rx_vlan_filter_port,
9636 (void *)&cmd_vf_rx_vlan_filter_portid,
9637 (void *)&cmd_vf_rx_vlan_filter_vf,
9638 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9643 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9644 struct cmd_queue_rate_limit_result {
9645 cmdline_fixed_string_t set;
9646 cmdline_fixed_string_t port;
9648 cmdline_fixed_string_t queue;
9650 cmdline_fixed_string_t rate;
9654 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9655 __rte_unused struct cmdline *cl,
9656 __rte_unused void *data)
9658 struct cmd_queue_rate_limit_result *res = parsed_result;
9661 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9662 && (strcmp(res->queue, "queue") == 0)
9663 && (strcmp(res->rate, "rate") == 0))
9664 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9667 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9672 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9673 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9675 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9676 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9678 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9679 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9680 port_num, RTE_UINT16);
9681 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9682 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9684 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9685 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9686 queue_num, RTE_UINT8);
9687 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9688 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9690 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9691 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9692 rate_num, RTE_UINT16);
9694 cmdline_parse_inst_t cmd_queue_rate_limit = {
9695 .f = cmd_queue_rate_limit_parsed,
9697 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9698 "Set rate limit for a queue on port_id",
9700 (void *)&cmd_queue_rate_limit_set,
9701 (void *)&cmd_queue_rate_limit_port,
9702 (void *)&cmd_queue_rate_limit_portnum,
9703 (void *)&cmd_queue_rate_limit_queue,
9704 (void *)&cmd_queue_rate_limit_queuenum,
9705 (void *)&cmd_queue_rate_limit_rate,
9706 (void *)&cmd_queue_rate_limit_ratenum,
9711 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9712 struct cmd_vf_rate_limit_result {
9713 cmdline_fixed_string_t set;
9714 cmdline_fixed_string_t port;
9716 cmdline_fixed_string_t vf;
9718 cmdline_fixed_string_t rate;
9720 cmdline_fixed_string_t q_msk;
9724 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9725 __rte_unused struct cmdline *cl,
9726 __rte_unused void *data)
9728 struct cmd_vf_rate_limit_result *res = parsed_result;
9731 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9732 && (strcmp(res->vf, "vf") == 0)
9733 && (strcmp(res->rate, "rate") == 0)
9734 && (strcmp(res->q_msk, "queue_mask") == 0))
9735 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9736 res->rate_num, res->q_msk_val);
9738 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9743 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9744 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9746 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9747 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9749 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9750 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9751 port_num, RTE_UINT16);
9752 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9753 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9755 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9756 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9758 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9759 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9761 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9762 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9763 rate_num, RTE_UINT16);
9764 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9765 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9766 q_msk, "queue_mask");
9767 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9768 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9769 q_msk_val, RTE_UINT64);
9771 cmdline_parse_inst_t cmd_vf_rate_limit = {
9772 .f = cmd_vf_rate_limit_parsed,
9774 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9775 "queue_mask <queue_mask_value>: "
9776 "Set rate limit for queues of VF on port_id",
9778 (void *)&cmd_vf_rate_limit_set,
9779 (void *)&cmd_vf_rate_limit_port,
9780 (void *)&cmd_vf_rate_limit_portnum,
9781 (void *)&cmd_vf_rate_limit_vf,
9782 (void *)&cmd_vf_rate_limit_vfnum,
9783 (void *)&cmd_vf_rate_limit_rate,
9784 (void *)&cmd_vf_rate_limit_ratenum,
9785 (void *)&cmd_vf_rate_limit_q_msk,
9786 (void *)&cmd_vf_rate_limit_q_msk_val,
9791 /* *** CONFIGURE TUNNEL UDP PORT *** */
9792 struct cmd_tunnel_udp_config {
9793 cmdline_fixed_string_t rx_vxlan_port;
9794 cmdline_fixed_string_t what;
9800 cmd_tunnel_udp_config_parsed(void *parsed_result,
9801 __rte_unused struct cmdline *cl,
9802 __rte_unused void *data)
9804 struct cmd_tunnel_udp_config *res = parsed_result;
9805 struct rte_eth_udp_tunnel tunnel_udp;
9808 tunnel_udp.udp_port = res->udp_port;
9809 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9811 if (!strcmp(res->what, "add"))
9812 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9815 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9819 fprintf(stderr, "udp tunneling add error: (%s)\n",
9823 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9824 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9825 rx_vxlan_port, "rx_vxlan_port");
9826 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9827 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9829 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9830 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9831 udp_port, RTE_UINT16);
9832 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9833 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9834 port_id, RTE_UINT16);
9836 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9837 .f = cmd_tunnel_udp_config_parsed,
9839 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9840 "Add/Remove a tunneling UDP port filter",
9842 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9843 (void *)&cmd_tunnel_udp_config_what,
9844 (void *)&cmd_tunnel_udp_config_udp_port,
9845 (void *)&cmd_tunnel_udp_config_port_id,
9850 struct cmd_config_tunnel_udp_port {
9851 cmdline_fixed_string_t port;
9852 cmdline_fixed_string_t config;
9854 cmdline_fixed_string_t udp_tunnel_port;
9855 cmdline_fixed_string_t action;
9856 cmdline_fixed_string_t tunnel_type;
9861 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9862 __rte_unused struct cmdline *cl,
9863 __rte_unused void *data)
9865 struct cmd_config_tunnel_udp_port *res = parsed_result;
9866 struct rte_eth_udp_tunnel tunnel_udp;
9869 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9872 tunnel_udp.udp_port = res->udp_port;
9874 if (!strcmp(res->tunnel_type, "vxlan")) {
9875 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9876 } else if (!strcmp(res->tunnel_type, "geneve")) {
9877 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9878 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9879 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9880 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9881 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9883 fprintf(stderr, "Invalid tunnel type\n");
9887 if (!strcmp(res->action, "add"))
9888 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9891 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9895 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9899 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9900 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9902 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9903 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9905 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9906 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9908 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9909 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9912 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9913 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9915 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9916 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9917 "vxlan#geneve#vxlan-gpe#ecpri");
9918 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9919 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9922 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9923 .f = cmd_cfg_tunnel_udp_port_parsed,
9925 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9926 "geneve|vxlan-gpe|ecpri <udp_port>",
9928 (void *)&cmd_config_tunnel_udp_port_port,
9929 (void *)&cmd_config_tunnel_udp_port_config,
9930 (void *)&cmd_config_tunnel_udp_port_port_id,
9931 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9932 (void *)&cmd_config_tunnel_udp_port_action,
9933 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9934 (void *)&cmd_config_tunnel_udp_port_value,
9939 /* ******************************************************************************** */
9941 struct cmd_dump_result {
9942 cmdline_fixed_string_t dump;
9946 dump_struct_sizes(void)
9948 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9949 DUMP_SIZE(struct rte_mbuf);
9950 DUMP_SIZE(struct rte_mempool);
9951 DUMP_SIZE(struct rte_ring);
9956 /* Dump the socket memory statistics on console */
9958 dump_socket_mem(FILE *f)
9960 struct rte_malloc_socket_stats socket_stats;
9965 unsigned int n_alloc = 0;
9966 unsigned int n_free = 0;
9967 static size_t last_allocs;
9968 static size_t last_total;
9971 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9972 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9973 !socket_stats.heap_totalsz_bytes)
9975 total += socket_stats.heap_totalsz_bytes;
9976 alloc += socket_stats.heap_allocsz_bytes;
9977 free += socket_stats.heap_freesz_bytes;
9978 n_alloc += socket_stats.alloc_count;
9979 n_free += socket_stats.free_count;
9981 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9983 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9984 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9985 (double)socket_stats.heap_allocsz_bytes * 100 /
9986 (double)socket_stats.heap_totalsz_bytes,
9987 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9988 socket_stats.alloc_count,
9989 socket_stats.free_count);
9992 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9993 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9994 total ? ((double)alloc * 100 / (double)total) : 0,
9995 (double)free / (1024 * 1024),
9998 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9999 ((double)total - (double)last_total) / (1024 * 1024),
10000 (double)(alloc - (double)last_allocs) / 1024 / 1024);
10001 last_allocs = alloc;
10002 last_total = total;
10005 static void cmd_dump_parsed(void *parsed_result,
10006 __rte_unused struct cmdline *cl,
10007 __rte_unused void *data)
10009 struct cmd_dump_result *res = parsed_result;
10011 if (!strcmp(res->dump, "dump_physmem"))
10012 rte_dump_physmem_layout(stdout);
10013 else if (!strcmp(res->dump, "dump_socket_mem"))
10014 dump_socket_mem(stdout);
10015 else if (!strcmp(res->dump, "dump_memzone"))
10016 rte_memzone_dump(stdout);
10017 else if (!strcmp(res->dump, "dump_struct_sizes"))
10018 dump_struct_sizes();
10019 else if (!strcmp(res->dump, "dump_ring"))
10020 rte_ring_list_dump(stdout);
10021 else if (!strcmp(res->dump, "dump_mempool"))
10022 rte_mempool_list_dump(stdout);
10023 else if (!strcmp(res->dump, "dump_devargs"))
10024 rte_devargs_dump(stdout);
10025 else if (!strcmp(res->dump, "dump_log_types"))
10026 rte_log_dump(stdout);
10029 cmdline_parse_token_string_t cmd_dump_dump =
10030 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
10034 "dump_struct_sizes#"
10040 cmdline_parse_inst_t cmd_dump = {
10041 .f = cmd_dump_parsed, /* function to call */
10042 .data = NULL, /* 2nd arg of func */
10043 .help_str = "Dump status",
10044 .tokens = { /* token list, NULL terminated */
10045 (void *)&cmd_dump_dump,
10050 /* ******************************************************************************** */
10052 struct cmd_dump_one_result {
10053 cmdline_fixed_string_t dump;
10054 cmdline_fixed_string_t name;
10057 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
10058 __rte_unused void *data)
10060 struct cmd_dump_one_result *res = parsed_result;
10062 if (!strcmp(res->dump, "dump_ring")) {
10063 struct rte_ring *r;
10064 r = rte_ring_lookup(res->name);
10066 cmdline_printf(cl, "Cannot find ring\n");
10069 rte_ring_dump(stdout, r);
10070 } else if (!strcmp(res->dump, "dump_mempool")) {
10071 struct rte_mempool *mp;
10072 mp = rte_mempool_lookup(res->name);
10074 cmdline_printf(cl, "Cannot find mempool\n");
10077 rte_mempool_dump(stdout, mp);
10081 cmdline_parse_token_string_t cmd_dump_one_dump =
10082 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
10083 "dump_ring#dump_mempool");
10085 cmdline_parse_token_string_t cmd_dump_one_name =
10086 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
10088 cmdline_parse_inst_t cmd_dump_one = {
10089 .f = cmd_dump_one_parsed, /* function to call */
10090 .data = NULL, /* 2nd arg of func */
10091 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
10092 .tokens = { /* token list, NULL terminated */
10093 (void *)&cmd_dump_one_dump,
10094 (void *)&cmd_dump_one_name,
10099 /* *** queue region set *** */
10100 struct cmd_queue_region_result {
10101 cmdline_fixed_string_t set;
10102 cmdline_fixed_string_t port;
10104 cmdline_fixed_string_t cmd;
10105 cmdline_fixed_string_t region;
10107 cmdline_fixed_string_t queue_start_index;
10109 cmdline_fixed_string_t queue_num;
10110 uint8_t queue_num_value;
10114 cmd_queue_region_parsed(void *parsed_result,
10115 __rte_unused struct cmdline *cl,
10116 __rte_unused void *data)
10118 struct cmd_queue_region_result *res = parsed_result;
10119 int ret = -ENOTSUP;
10120 #ifdef RTE_NET_I40E
10121 struct rte_pmd_i40e_queue_region_conf region_conf;
10122 enum rte_pmd_i40e_queue_region_op op_type;
10125 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10128 #ifdef RTE_NET_I40E
10129 memset(®ion_conf, 0, sizeof(region_conf));
10130 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10131 region_conf.region_id = res->region_id;
10132 region_conf.queue_num = res->queue_num_value;
10133 region_conf.queue_start_index = res->queue_id;
10135 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10136 op_type, ®ion_conf);
10143 fprintf(stderr, "function not implemented or supported\n");
10146 fprintf(stderr, "queue region config error: (%s)\n",
10151 cmdline_parse_token_string_t cmd_queue_region_set =
10152 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10154 cmdline_parse_token_string_t cmd_queue_region_port =
10155 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10156 cmdline_parse_token_num_t cmd_queue_region_port_id =
10157 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10158 port_id, RTE_UINT16);
10159 cmdline_parse_token_string_t cmd_queue_region_cmd =
10160 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10161 cmd, "queue-region");
10162 cmdline_parse_token_string_t cmd_queue_region_id =
10163 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10164 region, "region_id");
10165 cmdline_parse_token_num_t cmd_queue_region_index =
10166 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10167 region_id, RTE_UINT8);
10168 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10169 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10170 queue_start_index, "queue_start_index");
10171 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10172 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10173 queue_id, RTE_UINT8);
10174 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10175 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10176 queue_num, "queue_num");
10177 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10178 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10179 queue_num_value, RTE_UINT8);
10181 cmdline_parse_inst_t cmd_queue_region = {
10182 .f = cmd_queue_region_parsed,
10184 .help_str = "set port <port_id> queue-region region_id <value> "
10185 "queue_start_index <value> queue_num <value>: Set a queue region",
10187 (void *)&cmd_queue_region_set,
10188 (void *)&cmd_queue_region_port,
10189 (void *)&cmd_queue_region_port_id,
10190 (void *)&cmd_queue_region_cmd,
10191 (void *)&cmd_queue_region_id,
10192 (void *)&cmd_queue_region_index,
10193 (void *)&cmd_queue_region_queue_start_index,
10194 (void *)&cmd_queue_region_queue_id,
10195 (void *)&cmd_queue_region_queue_num,
10196 (void *)&cmd_queue_region_queue_num_value,
10201 /* *** queue region and flowtype set *** */
10202 struct cmd_region_flowtype_result {
10203 cmdline_fixed_string_t set;
10204 cmdline_fixed_string_t port;
10206 cmdline_fixed_string_t cmd;
10207 cmdline_fixed_string_t region;
10209 cmdline_fixed_string_t flowtype;
10210 uint8_t flowtype_id;
10214 cmd_region_flowtype_parsed(void *parsed_result,
10215 __rte_unused struct cmdline *cl,
10216 __rte_unused void *data)
10218 struct cmd_region_flowtype_result *res = parsed_result;
10219 int ret = -ENOTSUP;
10220 #ifdef RTE_NET_I40E
10221 struct rte_pmd_i40e_queue_region_conf region_conf;
10222 enum rte_pmd_i40e_queue_region_op op_type;
10225 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10228 #ifdef RTE_NET_I40E
10229 memset(®ion_conf, 0, sizeof(region_conf));
10231 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10232 region_conf.region_id = res->region_id;
10233 region_conf.hw_flowtype = res->flowtype_id;
10235 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10236 op_type, ®ion_conf);
10243 fprintf(stderr, "function not implemented or supported\n");
10246 fprintf(stderr, "region flowtype config error: (%s)\n",
10251 cmdline_parse_token_string_t cmd_region_flowtype_set =
10252 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10254 cmdline_parse_token_string_t cmd_region_flowtype_port =
10255 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10257 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10258 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10259 port_id, RTE_UINT16);
10260 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10261 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10262 cmd, "queue-region");
10263 cmdline_parse_token_string_t cmd_region_flowtype_index =
10264 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10265 region, "region_id");
10266 cmdline_parse_token_num_t cmd_region_flowtype_id =
10267 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10268 region_id, RTE_UINT8);
10269 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10270 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10271 flowtype, "flowtype");
10272 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10273 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10274 flowtype_id, RTE_UINT8);
10275 cmdline_parse_inst_t cmd_region_flowtype = {
10276 .f = cmd_region_flowtype_parsed,
10278 .help_str = "set port <port_id> queue-region region_id <value> "
10279 "flowtype <value>: Set a flowtype region index",
10281 (void *)&cmd_region_flowtype_set,
10282 (void *)&cmd_region_flowtype_port,
10283 (void *)&cmd_region_flowtype_port_index,
10284 (void *)&cmd_region_flowtype_cmd,
10285 (void *)&cmd_region_flowtype_index,
10286 (void *)&cmd_region_flowtype_id,
10287 (void *)&cmd_region_flowtype_flow_index,
10288 (void *)&cmd_region_flowtype_flow_id,
10293 /* *** User Priority (UP) to queue region (region_id) set *** */
10294 struct cmd_user_priority_region_result {
10295 cmdline_fixed_string_t set;
10296 cmdline_fixed_string_t port;
10298 cmdline_fixed_string_t cmd;
10299 cmdline_fixed_string_t user_priority;
10300 uint8_t user_priority_id;
10301 cmdline_fixed_string_t region;
10306 cmd_user_priority_region_parsed(void *parsed_result,
10307 __rte_unused struct cmdline *cl,
10308 __rte_unused void *data)
10310 struct cmd_user_priority_region_result *res = parsed_result;
10311 int ret = -ENOTSUP;
10312 #ifdef RTE_NET_I40E
10313 struct rte_pmd_i40e_queue_region_conf region_conf;
10314 enum rte_pmd_i40e_queue_region_op op_type;
10317 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10320 #ifdef RTE_NET_I40E
10321 memset(®ion_conf, 0, sizeof(region_conf));
10322 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10323 region_conf.user_priority = res->user_priority_id;
10324 region_conf.region_id = res->region_id;
10326 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10327 op_type, ®ion_conf);
10334 fprintf(stderr, "function not implemented or supported\n");
10337 fprintf(stderr, "user_priority region config error: (%s)\n",
10342 cmdline_parse_token_string_t cmd_user_priority_region_set =
10343 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10345 cmdline_parse_token_string_t cmd_user_priority_region_port =
10346 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10348 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10349 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10350 port_id, RTE_UINT16);
10351 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10352 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10353 cmd, "queue-region");
10354 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10355 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10356 user_priority, "UP");
10357 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10358 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10359 user_priority_id, RTE_UINT8);
10360 cmdline_parse_token_string_t cmd_user_priority_region_region =
10361 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10362 region, "region_id");
10363 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10364 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10365 region_id, RTE_UINT8);
10367 cmdline_parse_inst_t cmd_user_priority_region = {
10368 .f = cmd_user_priority_region_parsed,
10370 .help_str = "set port <port_id> queue-region UP <value> "
10371 "region_id <value>: Set the mapping of User Priority (UP) "
10372 "to queue region (region_id) ",
10374 (void *)&cmd_user_priority_region_set,
10375 (void *)&cmd_user_priority_region_port,
10376 (void *)&cmd_user_priority_region_port_index,
10377 (void *)&cmd_user_priority_region_cmd,
10378 (void *)&cmd_user_priority_region_UP,
10379 (void *)&cmd_user_priority_region_UP_id,
10380 (void *)&cmd_user_priority_region_region,
10381 (void *)&cmd_user_priority_region_region_id,
10386 /* *** flush all queue region related configuration *** */
10387 struct cmd_flush_queue_region_result {
10388 cmdline_fixed_string_t set;
10389 cmdline_fixed_string_t port;
10391 cmdline_fixed_string_t cmd;
10392 cmdline_fixed_string_t flush;
10393 cmdline_fixed_string_t what;
10397 cmd_flush_queue_region_parsed(void *parsed_result,
10398 __rte_unused struct cmdline *cl,
10399 __rte_unused void *data)
10401 struct cmd_flush_queue_region_result *res = parsed_result;
10402 int ret = -ENOTSUP;
10403 #ifdef RTE_NET_I40E
10404 struct rte_pmd_i40e_queue_region_conf region_conf;
10405 enum rte_pmd_i40e_queue_region_op op_type;
10408 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10411 #ifdef RTE_NET_I40E
10412 memset(®ion_conf, 0, sizeof(region_conf));
10414 if (strcmp(res->what, "on") == 0)
10415 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10417 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10419 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10420 op_type, ®ion_conf);
10427 fprintf(stderr, "function not implemented or supported\n");
10430 fprintf(stderr, "queue region config flush error: (%s)\n",
10435 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10436 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10438 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10439 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10441 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10442 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10443 port_id, RTE_UINT16);
10444 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10445 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10446 cmd, "queue-region");
10447 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10448 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10450 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10451 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10454 cmdline_parse_inst_t cmd_flush_queue_region = {
10455 .f = cmd_flush_queue_region_parsed,
10457 .help_str = "set port <port_id> queue-region flush on|off"
10458 ": flush all queue region related configuration",
10460 (void *)&cmd_flush_queue_region_set,
10461 (void *)&cmd_flush_queue_region_port,
10462 (void *)&cmd_flush_queue_region_port_index,
10463 (void *)&cmd_flush_queue_region_cmd,
10464 (void *)&cmd_flush_queue_region_flush,
10465 (void *)&cmd_flush_queue_region_what,
10470 /* *** get all queue region related configuration info *** */
10471 struct cmd_show_queue_region_info {
10472 cmdline_fixed_string_t show;
10473 cmdline_fixed_string_t port;
10475 cmdline_fixed_string_t cmd;
10479 cmd_show_queue_region_info_parsed(void *parsed_result,
10480 __rte_unused struct cmdline *cl,
10481 __rte_unused void *data)
10483 struct cmd_show_queue_region_info *res = parsed_result;
10484 int ret = -ENOTSUP;
10485 #ifdef RTE_NET_I40E
10486 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10487 enum rte_pmd_i40e_queue_region_op op_type;
10490 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10493 #ifdef RTE_NET_I40E
10494 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10496 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10498 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10499 op_type, &rte_pmd_regions);
10501 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10508 fprintf(stderr, "function not implemented or supported\n");
10511 fprintf(stderr, "queue region config info show error: (%s)\n",
10516 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10517 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10519 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10520 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10522 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10523 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10524 port_id, RTE_UINT16);
10525 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10526 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10527 cmd, "queue-region");
10529 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10530 .f = cmd_show_queue_region_info_parsed,
10532 .help_str = "show port <port_id> queue-region"
10533 ": show all queue region related configuration info",
10535 (void *)&cmd_show_queue_region_info_get,
10536 (void *)&cmd_show_queue_region_info_port,
10537 (void *)&cmd_show_queue_region_info_port_index,
10538 (void *)&cmd_show_queue_region_info_cmd,
10543 /* *** Filters Control *** */
10545 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10547 if ((ip_addr).family == AF_INET) \
10548 (ip) = (ip_addr).addr.ipv4.s_addr; \
10550 fprintf(stderr, "invalid parameter.\n"); \
10555 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10557 if ((ip_addr).family == AF_INET6) \
10558 rte_memcpy(&(ip), \
10559 &((ip_addr).addr.ipv6), \
10560 sizeof(struct in6_addr)); \
10562 fprintf(stderr, "invalid parameter.\n"); \
10567 #ifdef RTE_NET_I40E
10570 str2flowtype(char *string)
10573 static const struct {
10576 } flowtype_str[] = {
10577 {"raw", RTE_ETH_FLOW_RAW},
10578 {"ipv4", RTE_ETH_FLOW_IPV4},
10579 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10580 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10581 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10582 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10583 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10584 {"ipv6", RTE_ETH_FLOW_IPV6},
10585 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10586 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10587 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10588 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10589 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10590 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10591 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10592 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10593 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10594 {"gtpu", RTE_ETH_FLOW_GTPU},
10597 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10598 if (!strcmp(flowtype_str[i].str, string))
10599 return flowtype_str[i].type;
10602 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10603 return (uint16_t)atoi(string);
10605 return RTE_ETH_FLOW_UNKNOWN;
10608 /* *** deal with flow director filter *** */
10609 struct cmd_flow_director_result {
10610 cmdline_fixed_string_t flow_director_filter;
10612 cmdline_fixed_string_t mode;
10613 cmdline_fixed_string_t mode_value;
10614 cmdline_fixed_string_t ops;
10615 cmdline_fixed_string_t flow;
10616 cmdline_fixed_string_t flow_type;
10617 cmdline_fixed_string_t drop;
10618 cmdline_fixed_string_t queue;
10620 cmdline_fixed_string_t fd_id;
10621 uint32_t fd_id_value;
10622 cmdline_fixed_string_t packet;
10627 cmd_flow_director_filter_parsed(void *parsed_result,
10628 __rte_unused struct cmdline *cl,
10629 __rte_unused void *data)
10631 struct cmd_flow_director_result *res = parsed_result;
10633 struct rte_pmd_i40e_flow_type_mapping
10634 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10635 struct rte_pmd_i40e_pkt_template_conf conf;
10636 uint16_t flow_type = str2flowtype(res->flow_type);
10637 uint16_t i, port = res->port_id;
10640 memset(&conf, 0, sizeof(conf));
10642 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10643 fprintf(stderr, "Invalid flow type specified.\n");
10646 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10650 if (mapping[flow_type].pctype == 0ULL) {
10651 fprintf(stderr, "Invalid flow type specified.\n");
10654 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10655 if (mapping[flow_type].pctype & (1ULL << i)) {
10656 conf.input.pctype = i;
10661 conf.input.packet = open_file(res->filepath,
10662 &conf.input.length);
10663 if (!conf.input.packet)
10665 if (!strcmp(res->drop, "drop"))
10666 conf.action.behavior =
10667 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10669 conf.action.behavior =
10670 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10671 conf.action.report_status =
10672 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10673 conf.action.rx_queue = res->queue_id;
10674 conf.soft_id = res->fd_id_value;
10675 add = strcmp(res->ops, "del") ? 1 : 0;
10676 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10680 fprintf(stderr, "flow director config error: (%s)\n",
10682 close_file(conf.input.packet);
10685 cmdline_parse_token_string_t cmd_flow_director_filter =
10686 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10687 flow_director_filter, "flow_director_filter");
10688 cmdline_parse_token_num_t cmd_flow_director_port_id =
10689 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10690 port_id, RTE_UINT16);
10691 cmdline_parse_token_string_t cmd_flow_director_ops =
10692 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10693 ops, "add#del#update");
10694 cmdline_parse_token_string_t cmd_flow_director_flow =
10695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10697 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10698 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10700 cmdline_parse_token_string_t cmd_flow_director_drop =
10701 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10703 cmdline_parse_token_string_t cmd_flow_director_queue =
10704 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10706 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10707 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10708 queue_id, RTE_UINT16);
10709 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10710 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10712 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10713 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10714 fd_id_value, RTE_UINT32);
10716 cmdline_parse_token_string_t cmd_flow_director_mode =
10717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10719 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10720 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10721 mode_value, "raw");
10722 cmdline_parse_token_string_t cmd_flow_director_packet =
10723 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10725 cmdline_parse_token_string_t cmd_flow_director_filepath =
10726 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10729 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10730 .f = cmd_flow_director_filter_parsed,
10732 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10733 "director entry on NIC",
10735 (void *)&cmd_flow_director_filter,
10736 (void *)&cmd_flow_director_port_id,
10737 (void *)&cmd_flow_director_mode,
10738 (void *)&cmd_flow_director_mode_raw,
10739 (void *)&cmd_flow_director_ops,
10740 (void *)&cmd_flow_director_flow,
10741 (void *)&cmd_flow_director_flow_type,
10742 (void *)&cmd_flow_director_drop,
10743 (void *)&cmd_flow_director_queue,
10744 (void *)&cmd_flow_director_queue_id,
10745 (void *)&cmd_flow_director_fd_id,
10746 (void *)&cmd_flow_director_fd_id_value,
10747 (void *)&cmd_flow_director_packet,
10748 (void *)&cmd_flow_director_filepath,
10753 #endif /* RTE_NET_I40E */
10755 /* *** deal with flow director mask *** */
10756 struct cmd_flow_director_mask_result {
10757 cmdline_fixed_string_t flow_director_mask;
10759 cmdline_fixed_string_t mode;
10760 cmdline_fixed_string_t mode_value;
10761 cmdline_fixed_string_t vlan;
10762 uint16_t vlan_mask;
10763 cmdline_fixed_string_t src_mask;
10764 cmdline_ipaddr_t ipv4_src;
10765 cmdline_ipaddr_t ipv6_src;
10767 cmdline_fixed_string_t dst_mask;
10768 cmdline_ipaddr_t ipv4_dst;
10769 cmdline_ipaddr_t ipv6_dst;
10771 cmdline_fixed_string_t mac;
10772 uint8_t mac_addr_byte_mask;
10773 cmdline_fixed_string_t tunnel_id;
10774 uint32_t tunnel_id_mask;
10775 cmdline_fixed_string_t tunnel_type;
10776 uint8_t tunnel_type_mask;
10780 cmd_flow_director_mask_parsed(void *parsed_result,
10781 __rte_unused struct cmdline *cl,
10782 __rte_unused void *data)
10784 struct cmd_flow_director_mask_result *res = parsed_result;
10785 struct rte_eth_fdir_masks *mask;
10786 struct rte_port *port;
10788 port = &ports[res->port_id];
10789 /** Check if the port is not started **/
10790 if (port->port_status != RTE_PORT_STOPPED) {
10791 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10795 mask = &port->dev_conf.fdir_conf.mask;
10797 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10798 if (strcmp(res->mode_value, "MAC-VLAN")) {
10799 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10803 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10804 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10805 if (strcmp(res->mode_value, "Tunnel")) {
10806 fprintf(stderr, "Please set mode to Tunnel.\n");
10810 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10811 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10812 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10813 mask->tunnel_type_mask = res->tunnel_type_mask;
10815 if (strcmp(res->mode_value, "IP")) {
10816 fprintf(stderr, "Please set mode to IP.\n");
10820 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10821 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10822 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10823 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10824 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10825 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10826 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10829 cmd_reconfig_device_queue(res->port_id, 1, 1);
10832 cmdline_parse_token_string_t cmd_flow_director_mask =
10833 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10834 flow_director_mask, "flow_director_mask");
10835 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10836 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10837 port_id, RTE_UINT16);
10838 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10839 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10841 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10842 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10843 vlan_mask, RTE_UINT16);
10844 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10845 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10846 src_mask, "src_mask");
10847 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10848 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10850 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10851 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10853 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10854 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10855 port_src, RTE_UINT16);
10856 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10857 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10858 dst_mask, "dst_mask");
10859 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10860 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10862 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10863 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10865 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10866 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10867 port_dst, RTE_UINT16);
10869 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10872 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10875 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10877 mode_value, "MAC-VLAN");
10878 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10880 mode_value, "Tunnel");
10881 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10884 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10885 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10886 mac_addr_byte_mask, RTE_UINT8);
10887 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10888 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10889 tunnel_type, "tunnel-type");
10890 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10891 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10892 tunnel_type_mask, RTE_UINT8);
10893 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10894 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10895 tunnel_id, "tunnel-id");
10896 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10897 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10898 tunnel_id_mask, RTE_UINT32);
10900 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10901 .f = cmd_flow_director_mask_parsed,
10903 .help_str = "flow_director_mask ... : "
10904 "Set IP mode flow director's mask on NIC",
10906 (void *)&cmd_flow_director_mask,
10907 (void *)&cmd_flow_director_mask_port_id,
10908 (void *)&cmd_flow_director_mask_mode,
10909 (void *)&cmd_flow_director_mask_mode_ip,
10910 (void *)&cmd_flow_director_mask_vlan,
10911 (void *)&cmd_flow_director_mask_vlan_value,
10912 (void *)&cmd_flow_director_mask_src,
10913 (void *)&cmd_flow_director_mask_ipv4_src,
10914 (void *)&cmd_flow_director_mask_ipv6_src,
10915 (void *)&cmd_flow_director_mask_port_src,
10916 (void *)&cmd_flow_director_mask_dst,
10917 (void *)&cmd_flow_director_mask_ipv4_dst,
10918 (void *)&cmd_flow_director_mask_ipv6_dst,
10919 (void *)&cmd_flow_director_mask_port_dst,
10924 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10925 .f = cmd_flow_director_mask_parsed,
10927 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10928 "flow director's mask on NIC",
10930 (void *)&cmd_flow_director_mask,
10931 (void *)&cmd_flow_director_mask_port_id,
10932 (void *)&cmd_flow_director_mask_mode,
10933 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10934 (void *)&cmd_flow_director_mask_vlan,
10935 (void *)&cmd_flow_director_mask_vlan_value,
10940 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10941 .f = cmd_flow_director_mask_parsed,
10943 .help_str = "flow_director_mask ... : Set tunnel mode "
10944 "flow director's mask on NIC",
10946 (void *)&cmd_flow_director_mask,
10947 (void *)&cmd_flow_director_mask_port_id,
10948 (void *)&cmd_flow_director_mask_mode,
10949 (void *)&cmd_flow_director_mask_mode_tunnel,
10950 (void *)&cmd_flow_director_mask_vlan,
10951 (void *)&cmd_flow_director_mask_vlan_value,
10952 (void *)&cmd_flow_director_mask_mac,
10953 (void *)&cmd_flow_director_mask_mac_value,
10954 (void *)&cmd_flow_director_mask_tunnel_type,
10955 (void *)&cmd_flow_director_mask_tunnel_type_value,
10956 (void *)&cmd_flow_director_mask_tunnel_id,
10957 (void *)&cmd_flow_director_mask_tunnel_id_value,
10962 /* *** deal with flow director flexible payload configuration *** */
10963 struct cmd_flow_director_flexpayload_result {
10964 cmdline_fixed_string_t flow_director_flexpayload;
10966 cmdline_fixed_string_t payload_layer;
10967 cmdline_fixed_string_t payload_cfg;
10971 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10974 const char *p, *p0 = q_arg;
10976 unsigned long int_fld;
10977 char *str_fld[max_num];
10982 p = strchr(p0, '(');
10986 p0 = strchr(p, ')');
10991 if (size >= sizeof(s))
10994 snprintf(s, sizeof(s), "%.*s", size, p);
10995 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10996 if (ret < 0 || ret > max_num)
10998 for (i = 0; i < ret; i++) {
11000 int_fld = strtoul(str_fld[i], &end, 0);
11001 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11003 offsets[i] = (uint16_t)int_fld;
11009 cmd_flow_director_flxpld_parsed(void *parsed_result,
11010 __rte_unused struct cmdline *cl,
11011 __rte_unused void *data)
11013 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11014 struct rte_eth_flex_payload_cfg flex_cfg;
11015 struct rte_port *port;
11018 port = &ports[res->port_id];
11019 /** Check if the port is not started **/
11020 if (port->port_status != RTE_PORT_STOPPED) {
11021 fprintf(stderr, "Please stop port %d first\n", res->port_id);
11025 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11027 if (!strcmp(res->payload_layer, "raw"))
11028 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11029 else if (!strcmp(res->payload_layer, "l2"))
11030 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11031 else if (!strcmp(res->payload_layer, "l3"))
11032 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11033 else if (!strcmp(res->payload_layer, "l4"))
11034 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11036 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11037 RTE_ETH_FDIR_MAX_FLEXLEN);
11039 fprintf(stderr, "error: Cannot parse flex payload input.\n");
11043 fdir_set_flex_payload(res->port_id, &flex_cfg);
11044 cmd_reconfig_device_queue(res->port_id, 1, 1);
11047 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11048 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11049 flow_director_flexpayload,
11050 "flow_director_flex_payload");
11051 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11052 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11053 port_id, RTE_UINT16);
11054 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11055 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11056 payload_layer, "raw#l2#l3#l4");
11057 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11058 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11059 payload_cfg, NULL);
11061 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11062 .f = cmd_flow_director_flxpld_parsed,
11064 .help_str = "flow_director_flexpayload ... : "
11065 "Set flow director's flex payload on NIC",
11067 (void *)&cmd_flow_director_flexpayload,
11068 (void *)&cmd_flow_director_flexpayload_port_id,
11069 (void *)&cmd_flow_director_flexpayload_payload_layer,
11070 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11075 /* Generic flow interface command. */
11076 extern cmdline_parse_inst_t cmd_flow;
11078 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11079 struct cmd_mcast_addr_result {
11080 cmdline_fixed_string_t mcast_addr_cmd;
11081 cmdline_fixed_string_t what;
11083 struct rte_ether_addr mc_addr;
11086 static void cmd_mcast_addr_parsed(void *parsed_result,
11087 __rte_unused struct cmdline *cl,
11088 __rte_unused void *data)
11090 struct cmd_mcast_addr_result *res = parsed_result;
11092 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11094 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
11095 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
11098 if (strcmp(res->what, "add") == 0)
11099 mcast_addr_add(res->port_num, &res->mc_addr);
11101 mcast_addr_remove(res->port_num, &res->mc_addr);
11104 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11105 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11106 mcast_addr_cmd, "mcast_addr");
11107 cmdline_parse_token_string_t cmd_mcast_addr_what =
11108 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11110 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11111 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
11113 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11114 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11116 cmdline_parse_inst_t cmd_mcast_addr = {
11117 .f = cmd_mcast_addr_parsed,
11119 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11120 "Add/Remove multicast MAC address on port_id",
11122 (void *)&cmd_mcast_addr_cmd,
11123 (void *)&cmd_mcast_addr_what,
11124 (void *)&cmd_mcast_addr_portnum,
11125 (void *)&cmd_mcast_addr_addr,
11130 /* vf vlan anti spoof configuration */
11132 /* Common result structure for vf vlan anti spoof */
11133 struct cmd_vf_vlan_anti_spoof_result {
11134 cmdline_fixed_string_t set;
11135 cmdline_fixed_string_t vf;
11136 cmdline_fixed_string_t vlan;
11137 cmdline_fixed_string_t antispoof;
11140 cmdline_fixed_string_t on_off;
11143 /* Common CLI fields for vf vlan anti spoof enable disable */
11144 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11145 TOKEN_STRING_INITIALIZER
11146 (struct cmd_vf_vlan_anti_spoof_result,
11148 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11149 TOKEN_STRING_INITIALIZER
11150 (struct cmd_vf_vlan_anti_spoof_result,
11152 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11153 TOKEN_STRING_INITIALIZER
11154 (struct cmd_vf_vlan_anti_spoof_result,
11156 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11157 TOKEN_STRING_INITIALIZER
11158 (struct cmd_vf_vlan_anti_spoof_result,
11159 antispoof, "antispoof");
11160 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11161 TOKEN_NUM_INITIALIZER
11162 (struct cmd_vf_vlan_anti_spoof_result,
11163 port_id, RTE_UINT16);
11164 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11165 TOKEN_NUM_INITIALIZER
11166 (struct cmd_vf_vlan_anti_spoof_result,
11167 vf_id, RTE_UINT32);
11168 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11169 TOKEN_STRING_INITIALIZER
11170 (struct cmd_vf_vlan_anti_spoof_result,
11174 cmd_set_vf_vlan_anti_spoof_parsed(
11175 void *parsed_result,
11176 __rte_unused struct cmdline *cl,
11177 __rte_unused void *data)
11179 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11180 int ret = -ENOTSUP;
11182 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11184 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11187 #ifdef RTE_NET_IXGBE
11188 if (ret == -ENOTSUP)
11189 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11190 res->vf_id, is_on);
11192 #ifdef RTE_NET_I40E
11193 if (ret == -ENOTSUP)
11194 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11195 res->vf_id, is_on);
11197 #ifdef RTE_NET_BNXT
11198 if (ret == -ENOTSUP)
11199 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11200 res->vf_id, is_on);
11207 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11210 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11213 fprintf(stderr, "function not implemented\n");
11216 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11220 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11221 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11223 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11225 (void *)&cmd_vf_vlan_anti_spoof_set,
11226 (void *)&cmd_vf_vlan_anti_spoof_vf,
11227 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11228 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11229 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11230 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11231 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11236 /* vf mac anti spoof configuration */
11238 /* Common result structure for vf mac anti spoof */
11239 struct cmd_vf_mac_anti_spoof_result {
11240 cmdline_fixed_string_t set;
11241 cmdline_fixed_string_t vf;
11242 cmdline_fixed_string_t mac;
11243 cmdline_fixed_string_t antispoof;
11246 cmdline_fixed_string_t on_off;
11249 /* Common CLI fields for vf mac anti spoof enable disable */
11250 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11251 TOKEN_STRING_INITIALIZER
11252 (struct cmd_vf_mac_anti_spoof_result,
11254 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11255 TOKEN_STRING_INITIALIZER
11256 (struct cmd_vf_mac_anti_spoof_result,
11258 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11259 TOKEN_STRING_INITIALIZER
11260 (struct cmd_vf_mac_anti_spoof_result,
11262 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11263 TOKEN_STRING_INITIALIZER
11264 (struct cmd_vf_mac_anti_spoof_result,
11265 antispoof, "antispoof");
11266 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11267 TOKEN_NUM_INITIALIZER
11268 (struct cmd_vf_mac_anti_spoof_result,
11269 port_id, RTE_UINT16);
11270 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11271 TOKEN_NUM_INITIALIZER
11272 (struct cmd_vf_mac_anti_spoof_result,
11273 vf_id, RTE_UINT32);
11274 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11275 TOKEN_STRING_INITIALIZER
11276 (struct cmd_vf_mac_anti_spoof_result,
11280 cmd_set_vf_mac_anti_spoof_parsed(
11281 void *parsed_result,
11282 __rte_unused struct cmdline *cl,
11283 __rte_unused void *data)
11285 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11286 int ret = -ENOTSUP;
11288 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11290 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11293 #ifdef RTE_NET_IXGBE
11294 if (ret == -ENOTSUP)
11295 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11296 res->vf_id, is_on);
11298 #ifdef RTE_NET_I40E
11299 if (ret == -ENOTSUP)
11300 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11301 res->vf_id, is_on);
11303 #ifdef RTE_NET_BNXT
11304 if (ret == -ENOTSUP)
11305 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11306 res->vf_id, is_on);
11313 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11314 res->vf_id, is_on);
11317 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11320 fprintf(stderr, "function not implemented\n");
11323 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11327 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11328 .f = cmd_set_vf_mac_anti_spoof_parsed,
11330 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11332 (void *)&cmd_vf_mac_anti_spoof_set,
11333 (void *)&cmd_vf_mac_anti_spoof_vf,
11334 (void *)&cmd_vf_mac_anti_spoof_mac,
11335 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11336 (void *)&cmd_vf_mac_anti_spoof_port_id,
11337 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11338 (void *)&cmd_vf_mac_anti_spoof_on_off,
11343 /* vf vlan strip queue configuration */
11345 /* Common result structure for vf mac anti spoof */
11346 struct cmd_vf_vlan_stripq_result {
11347 cmdline_fixed_string_t set;
11348 cmdline_fixed_string_t vf;
11349 cmdline_fixed_string_t vlan;
11350 cmdline_fixed_string_t stripq;
11353 cmdline_fixed_string_t on_off;
11356 /* Common CLI fields for vf vlan strip enable disable */
11357 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11358 TOKEN_STRING_INITIALIZER
11359 (struct cmd_vf_vlan_stripq_result,
11361 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11362 TOKEN_STRING_INITIALIZER
11363 (struct cmd_vf_vlan_stripq_result,
11365 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11366 TOKEN_STRING_INITIALIZER
11367 (struct cmd_vf_vlan_stripq_result,
11369 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11370 TOKEN_STRING_INITIALIZER
11371 (struct cmd_vf_vlan_stripq_result,
11373 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11374 TOKEN_NUM_INITIALIZER
11375 (struct cmd_vf_vlan_stripq_result,
11376 port_id, RTE_UINT16);
11377 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11378 TOKEN_NUM_INITIALIZER
11379 (struct cmd_vf_vlan_stripq_result,
11380 vf_id, RTE_UINT16);
11381 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11382 TOKEN_STRING_INITIALIZER
11383 (struct cmd_vf_vlan_stripq_result,
11387 cmd_set_vf_vlan_stripq_parsed(
11388 void *parsed_result,
11389 __rte_unused struct cmdline *cl,
11390 __rte_unused void *data)
11392 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11393 int ret = -ENOTSUP;
11395 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11397 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11400 #ifdef RTE_NET_IXGBE
11401 if (ret == -ENOTSUP)
11402 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11403 res->vf_id, is_on);
11405 #ifdef RTE_NET_I40E
11406 if (ret == -ENOTSUP)
11407 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11408 res->vf_id, is_on);
11410 #ifdef RTE_NET_BNXT
11411 if (ret == -ENOTSUP)
11412 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11413 res->vf_id, is_on);
11420 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11421 res->vf_id, is_on);
11424 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11427 fprintf(stderr, "function not implemented\n");
11430 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11434 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11435 .f = cmd_set_vf_vlan_stripq_parsed,
11437 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11439 (void *)&cmd_vf_vlan_stripq_set,
11440 (void *)&cmd_vf_vlan_stripq_vf,
11441 (void *)&cmd_vf_vlan_stripq_vlan,
11442 (void *)&cmd_vf_vlan_stripq_stripq,
11443 (void *)&cmd_vf_vlan_stripq_port_id,
11444 (void *)&cmd_vf_vlan_stripq_vf_id,
11445 (void *)&cmd_vf_vlan_stripq_on_off,
11450 /* vf vlan insert configuration */
11452 /* Common result structure for vf vlan insert */
11453 struct cmd_vf_vlan_insert_result {
11454 cmdline_fixed_string_t set;
11455 cmdline_fixed_string_t vf;
11456 cmdline_fixed_string_t vlan;
11457 cmdline_fixed_string_t insert;
11463 /* Common CLI fields for vf vlan insert enable disable */
11464 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11465 TOKEN_STRING_INITIALIZER
11466 (struct cmd_vf_vlan_insert_result,
11468 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11469 TOKEN_STRING_INITIALIZER
11470 (struct cmd_vf_vlan_insert_result,
11472 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11473 TOKEN_STRING_INITIALIZER
11474 (struct cmd_vf_vlan_insert_result,
11476 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11477 TOKEN_STRING_INITIALIZER
11478 (struct cmd_vf_vlan_insert_result,
11480 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11481 TOKEN_NUM_INITIALIZER
11482 (struct cmd_vf_vlan_insert_result,
11483 port_id, RTE_UINT16);
11484 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11485 TOKEN_NUM_INITIALIZER
11486 (struct cmd_vf_vlan_insert_result,
11487 vf_id, RTE_UINT16);
11488 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11489 TOKEN_NUM_INITIALIZER
11490 (struct cmd_vf_vlan_insert_result,
11491 vlan_id, RTE_UINT16);
11494 cmd_set_vf_vlan_insert_parsed(
11495 void *parsed_result,
11496 __rte_unused struct cmdline *cl,
11497 __rte_unused void *data)
11499 struct cmd_vf_vlan_insert_result *res = parsed_result;
11500 int ret = -ENOTSUP;
11502 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11505 #ifdef RTE_NET_IXGBE
11506 if (ret == -ENOTSUP)
11507 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11510 #ifdef RTE_NET_I40E
11511 if (ret == -ENOTSUP)
11512 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11515 #ifdef RTE_NET_BNXT
11516 if (ret == -ENOTSUP)
11517 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11525 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11526 res->vf_id, res->vlan_id);
11529 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11532 fprintf(stderr, "function not implemented\n");
11535 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11539 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11540 .f = cmd_set_vf_vlan_insert_parsed,
11542 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11544 (void *)&cmd_vf_vlan_insert_set,
11545 (void *)&cmd_vf_vlan_insert_vf,
11546 (void *)&cmd_vf_vlan_insert_vlan,
11547 (void *)&cmd_vf_vlan_insert_insert,
11548 (void *)&cmd_vf_vlan_insert_port_id,
11549 (void *)&cmd_vf_vlan_insert_vf_id,
11550 (void *)&cmd_vf_vlan_insert_vlan_id,
11555 /* tx loopback configuration */
11557 /* Common result structure for tx loopback */
11558 struct cmd_tx_loopback_result {
11559 cmdline_fixed_string_t set;
11560 cmdline_fixed_string_t tx;
11561 cmdline_fixed_string_t loopback;
11563 cmdline_fixed_string_t on_off;
11566 /* Common CLI fields for tx loopback enable disable */
11567 cmdline_parse_token_string_t cmd_tx_loopback_set =
11568 TOKEN_STRING_INITIALIZER
11569 (struct cmd_tx_loopback_result,
11571 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11572 TOKEN_STRING_INITIALIZER
11573 (struct cmd_tx_loopback_result,
11575 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11576 TOKEN_STRING_INITIALIZER
11577 (struct cmd_tx_loopback_result,
11578 loopback, "loopback");
11579 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11580 TOKEN_NUM_INITIALIZER
11581 (struct cmd_tx_loopback_result,
11582 port_id, RTE_UINT16);
11583 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11584 TOKEN_STRING_INITIALIZER
11585 (struct cmd_tx_loopback_result,
11589 cmd_set_tx_loopback_parsed(
11590 void *parsed_result,
11591 __rte_unused struct cmdline *cl,
11592 __rte_unused void *data)
11594 struct cmd_tx_loopback_result *res = parsed_result;
11595 int ret = -ENOTSUP;
11597 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11599 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11602 #ifdef RTE_NET_IXGBE
11603 if (ret == -ENOTSUP)
11604 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11606 #ifdef RTE_NET_I40E
11607 if (ret == -ENOTSUP)
11608 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11610 #ifdef RTE_NET_BNXT
11611 if (ret == -ENOTSUP)
11612 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11614 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11615 if (ret == -ENOTSUP)
11616 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11623 fprintf(stderr, "invalid is_on %d\n", is_on);
11626 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11629 fprintf(stderr, "function not implemented\n");
11632 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11636 cmdline_parse_inst_t cmd_set_tx_loopback = {
11637 .f = cmd_set_tx_loopback_parsed,
11639 .help_str = "set tx loopback <port_id> on|off",
11641 (void *)&cmd_tx_loopback_set,
11642 (void *)&cmd_tx_loopback_tx,
11643 (void *)&cmd_tx_loopback_loopback,
11644 (void *)&cmd_tx_loopback_port_id,
11645 (void *)&cmd_tx_loopback_on_off,
11650 /* all queues drop enable configuration */
11652 /* Common result structure for all queues drop enable */
11653 struct cmd_all_queues_drop_en_result {
11654 cmdline_fixed_string_t set;
11655 cmdline_fixed_string_t all;
11656 cmdline_fixed_string_t queues;
11657 cmdline_fixed_string_t drop;
11659 cmdline_fixed_string_t on_off;
11662 /* Common CLI fields for tx loopback enable disable */
11663 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11664 TOKEN_STRING_INITIALIZER
11665 (struct cmd_all_queues_drop_en_result,
11667 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11668 TOKEN_STRING_INITIALIZER
11669 (struct cmd_all_queues_drop_en_result,
11671 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11672 TOKEN_STRING_INITIALIZER
11673 (struct cmd_all_queues_drop_en_result,
11675 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11676 TOKEN_STRING_INITIALIZER
11677 (struct cmd_all_queues_drop_en_result,
11679 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11680 TOKEN_NUM_INITIALIZER
11681 (struct cmd_all_queues_drop_en_result,
11682 port_id, RTE_UINT16);
11683 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11684 TOKEN_STRING_INITIALIZER
11685 (struct cmd_all_queues_drop_en_result,
11689 cmd_set_all_queues_drop_en_parsed(
11690 void *parsed_result,
11691 __rte_unused struct cmdline *cl,
11692 __rte_unused void *data)
11694 struct cmd_all_queues_drop_en_result *res = parsed_result;
11695 int ret = -ENOTSUP;
11696 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11698 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11701 #ifdef RTE_NET_IXGBE
11702 if (ret == -ENOTSUP)
11703 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11705 #ifdef RTE_NET_BNXT
11706 if (ret == -ENOTSUP)
11707 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11713 fprintf(stderr, "invalid is_on %d\n", is_on);
11716 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11719 fprintf(stderr, "function not implemented\n");
11722 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11726 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11727 .f = cmd_set_all_queues_drop_en_parsed,
11729 .help_str = "set all queues drop <port_id> on|off",
11731 (void *)&cmd_all_queues_drop_en_set,
11732 (void *)&cmd_all_queues_drop_en_all,
11733 (void *)&cmd_all_queues_drop_en_queues,
11734 (void *)&cmd_all_queues_drop_en_drop,
11735 (void *)&cmd_all_queues_drop_en_port_id,
11736 (void *)&cmd_all_queues_drop_en_on_off,
11741 /* vf split drop enable configuration */
11743 /* Common result structure for vf split drop enable */
11744 struct cmd_vf_split_drop_en_result {
11745 cmdline_fixed_string_t set;
11746 cmdline_fixed_string_t vf;
11747 cmdline_fixed_string_t split;
11748 cmdline_fixed_string_t drop;
11751 cmdline_fixed_string_t on_off;
11754 /* Common CLI fields for vf split drop enable disable */
11755 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11756 TOKEN_STRING_INITIALIZER
11757 (struct cmd_vf_split_drop_en_result,
11759 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11760 TOKEN_STRING_INITIALIZER
11761 (struct cmd_vf_split_drop_en_result,
11763 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11764 TOKEN_STRING_INITIALIZER
11765 (struct cmd_vf_split_drop_en_result,
11767 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11768 TOKEN_STRING_INITIALIZER
11769 (struct cmd_vf_split_drop_en_result,
11771 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11772 TOKEN_NUM_INITIALIZER
11773 (struct cmd_vf_split_drop_en_result,
11774 port_id, RTE_UINT16);
11775 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11776 TOKEN_NUM_INITIALIZER
11777 (struct cmd_vf_split_drop_en_result,
11778 vf_id, RTE_UINT16);
11779 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11780 TOKEN_STRING_INITIALIZER
11781 (struct cmd_vf_split_drop_en_result,
11785 cmd_set_vf_split_drop_en_parsed(
11786 void *parsed_result,
11787 __rte_unused struct cmdline *cl,
11788 __rte_unused void *data)
11790 struct cmd_vf_split_drop_en_result *res = parsed_result;
11791 int ret = -ENOTSUP;
11792 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11794 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11797 #ifdef RTE_NET_IXGBE
11798 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11805 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11806 res->vf_id, is_on);
11809 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11812 fprintf(stderr, "not supported on port %d\n", res->port_id);
11815 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11819 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11820 .f = cmd_set_vf_split_drop_en_parsed,
11822 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11824 (void *)&cmd_vf_split_drop_en_set,
11825 (void *)&cmd_vf_split_drop_en_vf,
11826 (void *)&cmd_vf_split_drop_en_split,
11827 (void *)&cmd_vf_split_drop_en_drop,
11828 (void *)&cmd_vf_split_drop_en_port_id,
11829 (void *)&cmd_vf_split_drop_en_vf_id,
11830 (void *)&cmd_vf_split_drop_en_on_off,
11835 /* vf mac address configuration */
11837 /* Common result structure for vf mac address */
11838 struct cmd_set_vf_mac_addr_result {
11839 cmdline_fixed_string_t set;
11840 cmdline_fixed_string_t vf;
11841 cmdline_fixed_string_t mac;
11842 cmdline_fixed_string_t addr;
11845 struct rte_ether_addr mac_addr;
11849 /* Common CLI fields for vf split drop enable disable */
11850 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11851 TOKEN_STRING_INITIALIZER
11852 (struct cmd_set_vf_mac_addr_result,
11854 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11855 TOKEN_STRING_INITIALIZER
11856 (struct cmd_set_vf_mac_addr_result,
11858 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11859 TOKEN_STRING_INITIALIZER
11860 (struct cmd_set_vf_mac_addr_result,
11862 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11863 TOKEN_STRING_INITIALIZER
11864 (struct cmd_set_vf_mac_addr_result,
11866 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11867 TOKEN_NUM_INITIALIZER
11868 (struct cmd_set_vf_mac_addr_result,
11869 port_id, RTE_UINT16);
11870 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11871 TOKEN_NUM_INITIALIZER
11872 (struct cmd_set_vf_mac_addr_result,
11873 vf_id, RTE_UINT16);
11874 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11875 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11879 cmd_set_vf_mac_addr_parsed(
11880 void *parsed_result,
11881 __rte_unused struct cmdline *cl,
11882 __rte_unused void *data)
11884 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11885 int ret = -ENOTSUP;
11887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11890 #ifdef RTE_NET_IXGBE
11891 if (ret == -ENOTSUP)
11892 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11895 #ifdef RTE_NET_I40E
11896 if (ret == -ENOTSUP)
11897 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11900 #ifdef RTE_NET_BNXT
11901 if (ret == -ENOTSUP)
11902 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11910 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11913 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11916 fprintf(stderr, "function not implemented\n");
11919 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11923 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11924 .f = cmd_set_vf_mac_addr_parsed,
11926 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11928 (void *)&cmd_set_vf_mac_addr_set,
11929 (void *)&cmd_set_vf_mac_addr_vf,
11930 (void *)&cmd_set_vf_mac_addr_mac,
11931 (void *)&cmd_set_vf_mac_addr_addr,
11932 (void *)&cmd_set_vf_mac_addr_port_id,
11933 (void *)&cmd_set_vf_mac_addr_vf_id,
11934 (void *)&cmd_set_vf_mac_addr_mac_addr,
11939 /* MACsec configuration */
11941 /* Common result structure for MACsec offload enable */
11942 struct cmd_macsec_offload_on_result {
11943 cmdline_fixed_string_t set;
11944 cmdline_fixed_string_t macsec;
11945 cmdline_fixed_string_t offload;
11947 cmdline_fixed_string_t on;
11948 cmdline_fixed_string_t encrypt;
11949 cmdline_fixed_string_t en_on_off;
11950 cmdline_fixed_string_t replay_protect;
11951 cmdline_fixed_string_t rp_on_off;
11954 /* Common CLI fields for MACsec offload disable */
11955 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11956 TOKEN_STRING_INITIALIZER
11957 (struct cmd_macsec_offload_on_result,
11959 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11960 TOKEN_STRING_INITIALIZER
11961 (struct cmd_macsec_offload_on_result,
11963 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11964 TOKEN_STRING_INITIALIZER
11965 (struct cmd_macsec_offload_on_result,
11966 offload, "offload");
11967 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11968 TOKEN_NUM_INITIALIZER
11969 (struct cmd_macsec_offload_on_result,
11970 port_id, RTE_UINT16);
11971 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11972 TOKEN_STRING_INITIALIZER
11973 (struct cmd_macsec_offload_on_result,
11975 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11976 TOKEN_STRING_INITIALIZER
11977 (struct cmd_macsec_offload_on_result,
11978 encrypt, "encrypt");
11979 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11980 TOKEN_STRING_INITIALIZER
11981 (struct cmd_macsec_offload_on_result,
11982 en_on_off, "on#off");
11983 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11984 TOKEN_STRING_INITIALIZER
11985 (struct cmd_macsec_offload_on_result,
11986 replay_protect, "replay-protect");
11987 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11988 TOKEN_STRING_INITIALIZER
11989 (struct cmd_macsec_offload_on_result,
11990 rp_on_off, "on#off");
11993 cmd_set_macsec_offload_on_parsed(
11994 void *parsed_result,
11995 __rte_unused struct cmdline *cl,
11996 __rte_unused void *data)
11998 struct cmd_macsec_offload_on_result *res = parsed_result;
11999 int ret = -ENOTSUP;
12000 portid_t port_id = res->port_id;
12001 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12002 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12003 struct rte_eth_dev_info dev_info;
12005 if (port_id_is_invalid(port_id, ENABLED_WARN))
12007 if (!port_is_stopped(port_id)) {
12008 fprintf(stderr, "Please stop port %d first\n", port_id);
12012 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12016 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12017 #ifdef RTE_NET_IXGBE
12018 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12026 ports[port_id].dev_conf.txmode.offloads |=
12027 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12028 cmd_reconfig_device_queue(port_id, 1, 1);
12031 fprintf(stderr, "invalid port_id %d\n", port_id);
12034 fprintf(stderr, "not supported on port %d\n", port_id);
12037 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12041 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12042 .f = cmd_set_macsec_offload_on_parsed,
12044 .help_str = "set macsec offload <port_id> on "
12045 "encrypt on|off replay-protect on|off",
12047 (void *)&cmd_macsec_offload_on_set,
12048 (void *)&cmd_macsec_offload_on_macsec,
12049 (void *)&cmd_macsec_offload_on_offload,
12050 (void *)&cmd_macsec_offload_on_port_id,
12051 (void *)&cmd_macsec_offload_on_on,
12052 (void *)&cmd_macsec_offload_on_encrypt,
12053 (void *)&cmd_macsec_offload_on_en_on_off,
12054 (void *)&cmd_macsec_offload_on_replay_protect,
12055 (void *)&cmd_macsec_offload_on_rp_on_off,
12060 /* Common result structure for MACsec offload disable */
12061 struct cmd_macsec_offload_off_result {
12062 cmdline_fixed_string_t set;
12063 cmdline_fixed_string_t macsec;
12064 cmdline_fixed_string_t offload;
12066 cmdline_fixed_string_t off;
12069 /* Common CLI fields for MACsec offload disable */
12070 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12071 TOKEN_STRING_INITIALIZER
12072 (struct cmd_macsec_offload_off_result,
12074 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12075 TOKEN_STRING_INITIALIZER
12076 (struct cmd_macsec_offload_off_result,
12078 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12079 TOKEN_STRING_INITIALIZER
12080 (struct cmd_macsec_offload_off_result,
12081 offload, "offload");
12082 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12083 TOKEN_NUM_INITIALIZER
12084 (struct cmd_macsec_offload_off_result,
12085 port_id, RTE_UINT16);
12086 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12087 TOKEN_STRING_INITIALIZER
12088 (struct cmd_macsec_offload_off_result,
12092 cmd_set_macsec_offload_off_parsed(
12093 void *parsed_result,
12094 __rte_unused struct cmdline *cl,
12095 __rte_unused void *data)
12097 struct cmd_macsec_offload_off_result *res = parsed_result;
12098 int ret = -ENOTSUP;
12099 struct rte_eth_dev_info dev_info;
12100 portid_t port_id = res->port_id;
12102 if (port_id_is_invalid(port_id, ENABLED_WARN))
12104 if (!port_is_stopped(port_id)) {
12105 fprintf(stderr, "Please stop port %d first\n", port_id);
12109 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12113 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12114 #ifdef RTE_NET_IXGBE
12115 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12120 ports[port_id].dev_conf.txmode.offloads &=
12121 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12122 cmd_reconfig_device_queue(port_id, 1, 1);
12125 fprintf(stderr, "invalid port_id %d\n", port_id);
12128 fprintf(stderr, "not supported on port %d\n", port_id);
12131 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12135 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12136 .f = cmd_set_macsec_offload_off_parsed,
12138 .help_str = "set macsec offload <port_id> off",
12140 (void *)&cmd_macsec_offload_off_set,
12141 (void *)&cmd_macsec_offload_off_macsec,
12142 (void *)&cmd_macsec_offload_off_offload,
12143 (void *)&cmd_macsec_offload_off_port_id,
12144 (void *)&cmd_macsec_offload_off_off,
12149 /* Common result structure for MACsec secure connection configure */
12150 struct cmd_macsec_sc_result {
12151 cmdline_fixed_string_t set;
12152 cmdline_fixed_string_t macsec;
12153 cmdline_fixed_string_t sc;
12154 cmdline_fixed_string_t tx_rx;
12156 struct rte_ether_addr mac;
12160 /* Common CLI fields for MACsec secure connection configure */
12161 cmdline_parse_token_string_t cmd_macsec_sc_set =
12162 TOKEN_STRING_INITIALIZER
12163 (struct cmd_macsec_sc_result,
12165 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12166 TOKEN_STRING_INITIALIZER
12167 (struct cmd_macsec_sc_result,
12169 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12170 TOKEN_STRING_INITIALIZER
12171 (struct cmd_macsec_sc_result,
12173 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12174 TOKEN_STRING_INITIALIZER
12175 (struct cmd_macsec_sc_result,
12177 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12178 TOKEN_NUM_INITIALIZER
12179 (struct cmd_macsec_sc_result,
12180 port_id, RTE_UINT16);
12181 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12182 TOKEN_ETHERADDR_INITIALIZER
12183 (struct cmd_macsec_sc_result,
12185 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12186 TOKEN_NUM_INITIALIZER
12187 (struct cmd_macsec_sc_result,
12191 cmd_set_macsec_sc_parsed(
12192 void *parsed_result,
12193 __rte_unused struct cmdline *cl,
12194 __rte_unused void *data)
12196 struct cmd_macsec_sc_result *res = parsed_result;
12197 int ret = -ENOTSUP;
12198 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12200 #ifdef RTE_NET_IXGBE
12202 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12203 res->mac.addr_bytes) :
12204 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12205 res->mac.addr_bytes, res->pi);
12207 RTE_SET_USED(is_tx);
12213 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12216 fprintf(stderr, "not supported on port %d\n", res->port_id);
12219 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12223 cmdline_parse_inst_t cmd_set_macsec_sc = {
12224 .f = cmd_set_macsec_sc_parsed,
12226 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12228 (void *)&cmd_macsec_sc_set,
12229 (void *)&cmd_macsec_sc_macsec,
12230 (void *)&cmd_macsec_sc_sc,
12231 (void *)&cmd_macsec_sc_tx_rx,
12232 (void *)&cmd_macsec_sc_port_id,
12233 (void *)&cmd_macsec_sc_mac,
12234 (void *)&cmd_macsec_sc_pi,
12239 /* Common result structure for MACsec secure connection configure */
12240 struct cmd_macsec_sa_result {
12241 cmdline_fixed_string_t set;
12242 cmdline_fixed_string_t macsec;
12243 cmdline_fixed_string_t sa;
12244 cmdline_fixed_string_t tx_rx;
12249 cmdline_fixed_string_t key;
12252 /* Common CLI fields for MACsec secure connection configure */
12253 cmdline_parse_token_string_t cmd_macsec_sa_set =
12254 TOKEN_STRING_INITIALIZER
12255 (struct cmd_macsec_sa_result,
12257 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12258 TOKEN_STRING_INITIALIZER
12259 (struct cmd_macsec_sa_result,
12261 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12262 TOKEN_STRING_INITIALIZER
12263 (struct cmd_macsec_sa_result,
12265 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12266 TOKEN_STRING_INITIALIZER
12267 (struct cmd_macsec_sa_result,
12269 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12270 TOKEN_NUM_INITIALIZER
12271 (struct cmd_macsec_sa_result,
12272 port_id, RTE_UINT16);
12273 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12274 TOKEN_NUM_INITIALIZER
12275 (struct cmd_macsec_sa_result,
12277 cmdline_parse_token_num_t cmd_macsec_sa_an =
12278 TOKEN_NUM_INITIALIZER
12279 (struct cmd_macsec_sa_result,
12281 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12282 TOKEN_NUM_INITIALIZER
12283 (struct cmd_macsec_sa_result,
12285 cmdline_parse_token_string_t cmd_macsec_sa_key =
12286 TOKEN_STRING_INITIALIZER
12287 (struct cmd_macsec_sa_result,
12291 cmd_set_macsec_sa_parsed(
12292 void *parsed_result,
12293 __rte_unused struct cmdline *cl,
12294 __rte_unused void *data)
12296 struct cmd_macsec_sa_result *res = parsed_result;
12297 int ret = -ENOTSUP;
12298 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12299 uint8_t key[16] = { 0 };
12305 key_len = strlen(res->key) / 2;
12309 for (i = 0; i < key_len; i++) {
12310 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12313 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12316 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12319 #ifdef RTE_NET_IXGBE
12321 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12322 res->idx, res->an, res->pn, key) :
12323 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12324 res->idx, res->an, res->pn, key);
12326 RTE_SET_USED(is_tx);
12333 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12336 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12339 fprintf(stderr, "not supported on port %d\n", res->port_id);
12342 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12346 cmdline_parse_inst_t cmd_set_macsec_sa = {
12347 .f = cmd_set_macsec_sa_parsed,
12349 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12351 (void *)&cmd_macsec_sa_set,
12352 (void *)&cmd_macsec_sa_macsec,
12353 (void *)&cmd_macsec_sa_sa,
12354 (void *)&cmd_macsec_sa_tx_rx,
12355 (void *)&cmd_macsec_sa_port_id,
12356 (void *)&cmd_macsec_sa_idx,
12357 (void *)&cmd_macsec_sa_an,
12358 (void *)&cmd_macsec_sa_pn,
12359 (void *)&cmd_macsec_sa_key,
12364 /* VF unicast promiscuous mode configuration */
12366 /* Common result structure for VF unicast promiscuous mode */
12367 struct cmd_vf_promisc_result {
12368 cmdline_fixed_string_t set;
12369 cmdline_fixed_string_t vf;
12370 cmdline_fixed_string_t promisc;
12373 cmdline_fixed_string_t on_off;
12376 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12377 cmdline_parse_token_string_t cmd_vf_promisc_set =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_vf_promisc_result,
12381 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12382 TOKEN_STRING_INITIALIZER
12383 (struct cmd_vf_promisc_result,
12385 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12386 TOKEN_STRING_INITIALIZER
12387 (struct cmd_vf_promisc_result,
12388 promisc, "promisc");
12389 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12390 TOKEN_NUM_INITIALIZER
12391 (struct cmd_vf_promisc_result,
12392 port_id, RTE_UINT16);
12393 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12394 TOKEN_NUM_INITIALIZER
12395 (struct cmd_vf_promisc_result,
12396 vf_id, RTE_UINT32);
12397 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12398 TOKEN_STRING_INITIALIZER
12399 (struct cmd_vf_promisc_result,
12403 cmd_set_vf_promisc_parsed(
12404 void *parsed_result,
12405 __rte_unused struct cmdline *cl,
12406 __rte_unused void *data)
12408 struct cmd_vf_promisc_result *res = parsed_result;
12409 int ret = -ENOTSUP;
12411 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12413 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12416 #ifdef RTE_NET_I40E
12417 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12418 res->vf_id, is_on);
12425 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12428 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12431 fprintf(stderr, "function not implemented\n");
12434 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12438 cmdline_parse_inst_t cmd_set_vf_promisc = {
12439 .f = cmd_set_vf_promisc_parsed,
12441 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12442 "Set unicast promiscuous mode for a VF from the PF",
12444 (void *)&cmd_vf_promisc_set,
12445 (void *)&cmd_vf_promisc_vf,
12446 (void *)&cmd_vf_promisc_promisc,
12447 (void *)&cmd_vf_promisc_port_id,
12448 (void *)&cmd_vf_promisc_vf_id,
12449 (void *)&cmd_vf_promisc_on_off,
12454 /* VF multicast promiscuous mode configuration */
12456 /* Common result structure for VF multicast promiscuous mode */
12457 struct cmd_vf_allmulti_result {
12458 cmdline_fixed_string_t set;
12459 cmdline_fixed_string_t vf;
12460 cmdline_fixed_string_t allmulti;
12463 cmdline_fixed_string_t on_off;
12466 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12467 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12468 TOKEN_STRING_INITIALIZER
12469 (struct cmd_vf_allmulti_result,
12471 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12472 TOKEN_STRING_INITIALIZER
12473 (struct cmd_vf_allmulti_result,
12475 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12476 TOKEN_STRING_INITIALIZER
12477 (struct cmd_vf_allmulti_result,
12478 allmulti, "allmulti");
12479 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12480 TOKEN_NUM_INITIALIZER
12481 (struct cmd_vf_allmulti_result,
12482 port_id, RTE_UINT16);
12483 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12484 TOKEN_NUM_INITIALIZER
12485 (struct cmd_vf_allmulti_result,
12486 vf_id, RTE_UINT32);
12487 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12488 TOKEN_STRING_INITIALIZER
12489 (struct cmd_vf_allmulti_result,
12493 cmd_set_vf_allmulti_parsed(
12494 void *parsed_result,
12495 __rte_unused struct cmdline *cl,
12496 __rte_unused void *data)
12498 struct cmd_vf_allmulti_result *res = parsed_result;
12499 int ret = -ENOTSUP;
12501 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12503 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12506 #ifdef RTE_NET_I40E
12507 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12508 res->vf_id, is_on);
12515 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12518 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12521 fprintf(stderr, "function not implemented\n");
12524 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12528 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12529 .f = cmd_set_vf_allmulti_parsed,
12531 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12532 "Set multicast promiscuous mode for a VF from the PF",
12534 (void *)&cmd_vf_allmulti_set,
12535 (void *)&cmd_vf_allmulti_vf,
12536 (void *)&cmd_vf_allmulti_allmulti,
12537 (void *)&cmd_vf_allmulti_port_id,
12538 (void *)&cmd_vf_allmulti_vf_id,
12539 (void *)&cmd_vf_allmulti_on_off,
12544 /* vf broadcast mode configuration */
12546 /* Common result structure for vf broadcast */
12547 struct cmd_set_vf_broadcast_result {
12548 cmdline_fixed_string_t set;
12549 cmdline_fixed_string_t vf;
12550 cmdline_fixed_string_t broadcast;
12553 cmdline_fixed_string_t on_off;
12556 /* Common CLI fields for vf broadcast enable disable */
12557 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12558 TOKEN_STRING_INITIALIZER
12559 (struct cmd_set_vf_broadcast_result,
12561 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12562 TOKEN_STRING_INITIALIZER
12563 (struct cmd_set_vf_broadcast_result,
12565 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12566 TOKEN_STRING_INITIALIZER
12567 (struct cmd_set_vf_broadcast_result,
12568 broadcast, "broadcast");
12569 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12570 TOKEN_NUM_INITIALIZER
12571 (struct cmd_set_vf_broadcast_result,
12572 port_id, RTE_UINT16);
12573 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12574 TOKEN_NUM_INITIALIZER
12575 (struct cmd_set_vf_broadcast_result,
12576 vf_id, RTE_UINT16);
12577 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12578 TOKEN_STRING_INITIALIZER
12579 (struct cmd_set_vf_broadcast_result,
12583 cmd_set_vf_broadcast_parsed(
12584 void *parsed_result,
12585 __rte_unused struct cmdline *cl,
12586 __rte_unused void *data)
12588 struct cmd_set_vf_broadcast_result *res = parsed_result;
12589 int ret = -ENOTSUP;
12591 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12596 #ifdef RTE_NET_I40E
12597 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12598 res->vf_id, is_on);
12605 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12606 res->vf_id, is_on);
12609 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12612 fprintf(stderr, "function not implemented\n");
12615 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12619 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12620 .f = cmd_set_vf_broadcast_parsed,
12622 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12624 (void *)&cmd_set_vf_broadcast_set,
12625 (void *)&cmd_set_vf_broadcast_vf,
12626 (void *)&cmd_set_vf_broadcast_broadcast,
12627 (void *)&cmd_set_vf_broadcast_port_id,
12628 (void *)&cmd_set_vf_broadcast_vf_id,
12629 (void *)&cmd_set_vf_broadcast_on_off,
12634 /* vf vlan tag configuration */
12636 /* Common result structure for vf vlan tag */
12637 struct cmd_set_vf_vlan_tag_result {
12638 cmdline_fixed_string_t set;
12639 cmdline_fixed_string_t vf;
12640 cmdline_fixed_string_t vlan;
12641 cmdline_fixed_string_t tag;
12644 cmdline_fixed_string_t on_off;
12647 /* Common CLI fields for vf vlan tag enable disable */
12648 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12649 TOKEN_STRING_INITIALIZER
12650 (struct cmd_set_vf_vlan_tag_result,
12652 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12653 TOKEN_STRING_INITIALIZER
12654 (struct cmd_set_vf_vlan_tag_result,
12656 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12657 TOKEN_STRING_INITIALIZER
12658 (struct cmd_set_vf_vlan_tag_result,
12660 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12661 TOKEN_STRING_INITIALIZER
12662 (struct cmd_set_vf_vlan_tag_result,
12664 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12665 TOKEN_NUM_INITIALIZER
12666 (struct cmd_set_vf_vlan_tag_result,
12667 port_id, RTE_UINT16);
12668 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12669 TOKEN_NUM_INITIALIZER
12670 (struct cmd_set_vf_vlan_tag_result,
12671 vf_id, RTE_UINT16);
12672 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12673 TOKEN_STRING_INITIALIZER
12674 (struct cmd_set_vf_vlan_tag_result,
12678 cmd_set_vf_vlan_tag_parsed(
12679 void *parsed_result,
12680 __rte_unused struct cmdline *cl,
12681 __rte_unused void *data)
12683 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12684 int ret = -ENOTSUP;
12686 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12688 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12691 #ifdef RTE_NET_I40E
12692 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12693 res->vf_id, is_on);
12700 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12701 res->vf_id, is_on);
12704 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12707 fprintf(stderr, "function not implemented\n");
12710 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12714 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12715 .f = cmd_set_vf_vlan_tag_parsed,
12717 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12719 (void *)&cmd_set_vf_vlan_tag_set,
12720 (void *)&cmd_set_vf_vlan_tag_vf,
12721 (void *)&cmd_set_vf_vlan_tag_vlan,
12722 (void *)&cmd_set_vf_vlan_tag_tag,
12723 (void *)&cmd_set_vf_vlan_tag_port_id,
12724 (void *)&cmd_set_vf_vlan_tag_vf_id,
12725 (void *)&cmd_set_vf_vlan_tag_on_off,
12730 /* Common definition of VF and TC TX bandwidth configuration */
12731 struct cmd_vf_tc_bw_result {
12732 cmdline_fixed_string_t set;
12733 cmdline_fixed_string_t vf;
12734 cmdline_fixed_string_t tc;
12735 cmdline_fixed_string_t tx;
12736 cmdline_fixed_string_t min_bw;
12737 cmdline_fixed_string_t max_bw;
12738 cmdline_fixed_string_t strict_link_prio;
12743 cmdline_fixed_string_t bw_list;
12747 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12748 TOKEN_STRING_INITIALIZER
12749 (struct cmd_vf_tc_bw_result,
12751 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12752 TOKEN_STRING_INITIALIZER
12753 (struct cmd_vf_tc_bw_result,
12755 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12756 TOKEN_STRING_INITIALIZER
12757 (struct cmd_vf_tc_bw_result,
12759 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12760 TOKEN_STRING_INITIALIZER
12761 (struct cmd_vf_tc_bw_result,
12763 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12764 TOKEN_STRING_INITIALIZER
12765 (struct cmd_vf_tc_bw_result,
12766 strict_link_prio, "strict-link-priority");
12767 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12768 TOKEN_STRING_INITIALIZER
12769 (struct cmd_vf_tc_bw_result,
12770 min_bw, "min-bandwidth");
12771 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12772 TOKEN_STRING_INITIALIZER
12773 (struct cmd_vf_tc_bw_result,
12774 max_bw, "max-bandwidth");
12775 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12776 TOKEN_NUM_INITIALIZER
12777 (struct cmd_vf_tc_bw_result,
12778 port_id, RTE_UINT16);
12779 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12780 TOKEN_NUM_INITIALIZER
12781 (struct cmd_vf_tc_bw_result,
12782 vf_id, RTE_UINT16);
12783 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12784 TOKEN_NUM_INITIALIZER
12785 (struct cmd_vf_tc_bw_result,
12787 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12788 TOKEN_NUM_INITIALIZER
12789 (struct cmd_vf_tc_bw_result,
12791 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12792 TOKEN_STRING_INITIALIZER
12793 (struct cmd_vf_tc_bw_result,
12795 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12796 TOKEN_NUM_INITIALIZER
12797 (struct cmd_vf_tc_bw_result,
12798 tc_map, RTE_UINT8);
12800 /* VF max bandwidth setting */
12802 cmd_vf_max_bw_parsed(
12803 void *parsed_result,
12804 __rte_unused struct cmdline *cl,
12805 __rte_unused void *data)
12807 struct cmd_vf_tc_bw_result *res = parsed_result;
12808 int ret = -ENOTSUP;
12810 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12813 #ifdef RTE_NET_I40E
12814 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12815 res->vf_id, res->bw);
12822 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12823 res->vf_id, res->bw);
12826 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12829 fprintf(stderr, "function not implemented\n");
12832 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12836 cmdline_parse_inst_t cmd_vf_max_bw = {
12837 .f = cmd_vf_max_bw_parsed,
12839 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12841 (void *)&cmd_vf_tc_bw_set,
12842 (void *)&cmd_vf_tc_bw_vf,
12843 (void *)&cmd_vf_tc_bw_tx,
12844 (void *)&cmd_vf_tc_bw_max_bw,
12845 (void *)&cmd_vf_tc_bw_port_id,
12846 (void *)&cmd_vf_tc_bw_vf_id,
12847 (void *)&cmd_vf_tc_bw_bw,
12853 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12858 const char *p, *p0 = str;
12865 p = strchr(p0, '(');
12868 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12872 p0 = strchr(p, ')');
12875 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12879 if (size >= sizeof(s)) {
12881 "The string size exceeds the internal buffer size\n");
12884 snprintf(s, sizeof(s), "%.*s", size, p);
12885 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12887 fprintf(stderr, "Failed to get the bandwidth list.\n");
12891 for (i = 0; i < ret; i++)
12892 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12897 /* TC min bandwidth setting */
12899 cmd_vf_tc_min_bw_parsed(
12900 void *parsed_result,
12901 __rte_unused struct cmdline *cl,
12902 __rte_unused void *data)
12904 struct cmd_vf_tc_bw_result *res = parsed_result;
12907 int ret = -ENOTSUP;
12909 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12912 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12916 #ifdef RTE_NET_I40E
12917 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12925 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12928 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12931 fprintf(stderr, "function not implemented\n");
12934 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12938 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12939 .f = cmd_vf_tc_min_bw_parsed,
12941 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12942 " <bw1, bw2, ...>",
12944 (void *)&cmd_vf_tc_bw_set,
12945 (void *)&cmd_vf_tc_bw_vf,
12946 (void *)&cmd_vf_tc_bw_tc,
12947 (void *)&cmd_vf_tc_bw_tx,
12948 (void *)&cmd_vf_tc_bw_min_bw,
12949 (void *)&cmd_vf_tc_bw_port_id,
12950 (void *)&cmd_vf_tc_bw_vf_id,
12951 (void *)&cmd_vf_tc_bw_bw_list,
12957 cmd_tc_min_bw_parsed(
12958 void *parsed_result,
12959 __rte_unused struct cmdline *cl,
12960 __rte_unused void *data)
12962 struct cmd_vf_tc_bw_result *res = parsed_result;
12963 struct rte_port *port;
12966 int ret = -ENOTSUP;
12968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12971 port = &ports[res->port_id];
12972 /** Check if the port is not started **/
12973 if (port->port_status != RTE_PORT_STOPPED) {
12974 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12978 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12982 #ifdef RTE_NET_IXGBE
12983 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12990 fprintf(stderr, "invalid bandwidth\n");
12993 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12996 fprintf(stderr, "function not implemented\n");
12999 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13003 cmdline_parse_inst_t cmd_tc_min_bw = {
13004 .f = cmd_tc_min_bw_parsed,
13006 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13008 (void *)&cmd_vf_tc_bw_set,
13009 (void *)&cmd_vf_tc_bw_tc,
13010 (void *)&cmd_vf_tc_bw_tx,
13011 (void *)&cmd_vf_tc_bw_min_bw,
13012 (void *)&cmd_vf_tc_bw_port_id,
13013 (void *)&cmd_vf_tc_bw_bw_list,
13018 /* TC max bandwidth setting */
13020 cmd_vf_tc_max_bw_parsed(
13021 void *parsed_result,
13022 __rte_unused struct cmdline *cl,
13023 __rte_unused void *data)
13025 struct cmd_vf_tc_bw_result *res = parsed_result;
13026 int ret = -ENOTSUP;
13028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13031 #ifdef RTE_NET_I40E
13032 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13033 res->tc_no, res->bw);
13041 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
13042 res->vf_id, res->tc_no, res->bw);
13045 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13048 fprintf(stderr, "function not implemented\n");
13051 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13055 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13056 .f = cmd_vf_tc_max_bw_parsed,
13058 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13061 (void *)&cmd_vf_tc_bw_set,
13062 (void *)&cmd_vf_tc_bw_vf,
13063 (void *)&cmd_vf_tc_bw_tc,
13064 (void *)&cmd_vf_tc_bw_tx,
13065 (void *)&cmd_vf_tc_bw_max_bw,
13066 (void *)&cmd_vf_tc_bw_port_id,
13067 (void *)&cmd_vf_tc_bw_vf_id,
13068 (void *)&cmd_vf_tc_bw_tc_no,
13069 (void *)&cmd_vf_tc_bw_bw,
13074 /** Set VXLAN encapsulation details */
13075 struct cmd_set_vxlan_result {
13076 cmdline_fixed_string_t set;
13077 cmdline_fixed_string_t vxlan;
13078 cmdline_fixed_string_t pos_token;
13079 cmdline_fixed_string_t ip_version;
13080 uint32_t vlan_present:1;
13084 cmdline_ipaddr_t ip_src;
13085 cmdline_ipaddr_t ip_dst;
13089 struct rte_ether_addr eth_src;
13090 struct rte_ether_addr eth_dst;
13093 cmdline_parse_token_string_t cmd_set_vxlan_set =
13094 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
13095 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
13096 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
13097 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
13098 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13100 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
13101 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13102 "vxlan-with-vlan");
13103 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
13104 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13106 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
13107 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
13109 cmdline_parse_token_string_t cmd_set_vxlan_vni =
13110 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13112 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
13113 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
13114 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
13115 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13117 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
13118 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
13119 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
13120 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13122 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
13123 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
13124 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13125 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13127 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13128 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
13129 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13130 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13132 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13133 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
13134 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13135 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13137 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13138 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13139 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13140 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13142 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13143 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13144 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13145 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13147 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13148 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13149 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13150 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13152 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13153 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13154 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13155 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13157 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13158 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13160 static void cmd_set_vxlan_parsed(void *parsed_result,
13161 __rte_unused struct cmdline *cl,
13162 __rte_unused void *data)
13164 struct cmd_set_vxlan_result *res = parsed_result;
13169 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13172 vxlan_encap_conf.select_tos_ttl = 0;
13173 if (strcmp(res->vxlan, "vxlan") == 0)
13174 vxlan_encap_conf.select_vlan = 0;
13175 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13176 vxlan_encap_conf.select_vlan = 1;
13177 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13178 vxlan_encap_conf.select_vlan = 0;
13179 vxlan_encap_conf.select_tos_ttl = 1;
13181 if (strcmp(res->ip_version, "ipv4") == 0)
13182 vxlan_encap_conf.select_ipv4 = 1;
13183 else if (strcmp(res->ip_version, "ipv6") == 0)
13184 vxlan_encap_conf.select_ipv4 = 0;
13187 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13188 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13189 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13190 vxlan_encap_conf.ip_tos = res->tos;
13191 vxlan_encap_conf.ip_ttl = res->ttl;
13192 if (vxlan_encap_conf.select_ipv4) {
13193 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13194 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13196 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13197 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13199 if (vxlan_encap_conf.select_vlan)
13200 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13201 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13202 RTE_ETHER_ADDR_LEN);
13203 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13204 RTE_ETHER_ADDR_LEN);
13207 cmdline_parse_inst_t cmd_set_vxlan = {
13208 .f = cmd_set_vxlan_parsed,
13210 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13211 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13212 " eth-src <eth-src> eth-dst <eth-dst>",
13214 (void *)&cmd_set_vxlan_set,
13215 (void *)&cmd_set_vxlan_vxlan,
13216 (void *)&cmd_set_vxlan_ip_version,
13217 (void *)&cmd_set_vxlan_ip_version_value,
13218 (void *)&cmd_set_vxlan_vni,
13219 (void *)&cmd_set_vxlan_vni_value,
13220 (void *)&cmd_set_vxlan_udp_src,
13221 (void *)&cmd_set_vxlan_udp_src_value,
13222 (void *)&cmd_set_vxlan_udp_dst,
13223 (void *)&cmd_set_vxlan_udp_dst_value,
13224 (void *)&cmd_set_vxlan_ip_src,
13225 (void *)&cmd_set_vxlan_ip_src_value,
13226 (void *)&cmd_set_vxlan_ip_dst,
13227 (void *)&cmd_set_vxlan_ip_dst_value,
13228 (void *)&cmd_set_vxlan_eth_src,
13229 (void *)&cmd_set_vxlan_eth_src_value,
13230 (void *)&cmd_set_vxlan_eth_dst,
13231 (void *)&cmd_set_vxlan_eth_dst_value,
13236 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13237 .f = cmd_set_vxlan_parsed,
13239 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13240 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13241 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13242 " eth-dst <eth-dst>",
13244 (void *)&cmd_set_vxlan_set,
13245 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13246 (void *)&cmd_set_vxlan_ip_version,
13247 (void *)&cmd_set_vxlan_ip_version_value,
13248 (void *)&cmd_set_vxlan_vni,
13249 (void *)&cmd_set_vxlan_vni_value,
13250 (void *)&cmd_set_vxlan_udp_src,
13251 (void *)&cmd_set_vxlan_udp_src_value,
13252 (void *)&cmd_set_vxlan_udp_dst,
13253 (void *)&cmd_set_vxlan_udp_dst_value,
13254 (void *)&cmd_set_vxlan_ip_tos,
13255 (void *)&cmd_set_vxlan_ip_tos_value,
13256 (void *)&cmd_set_vxlan_ip_ttl,
13257 (void *)&cmd_set_vxlan_ip_ttl_value,
13258 (void *)&cmd_set_vxlan_ip_src,
13259 (void *)&cmd_set_vxlan_ip_src_value,
13260 (void *)&cmd_set_vxlan_ip_dst,
13261 (void *)&cmd_set_vxlan_ip_dst_value,
13262 (void *)&cmd_set_vxlan_eth_src,
13263 (void *)&cmd_set_vxlan_eth_src_value,
13264 (void *)&cmd_set_vxlan_eth_dst,
13265 (void *)&cmd_set_vxlan_eth_dst_value,
13270 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13271 .f = cmd_set_vxlan_parsed,
13273 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13274 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13275 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13278 (void *)&cmd_set_vxlan_set,
13279 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13280 (void *)&cmd_set_vxlan_ip_version,
13281 (void *)&cmd_set_vxlan_ip_version_value,
13282 (void *)&cmd_set_vxlan_vni,
13283 (void *)&cmd_set_vxlan_vni_value,
13284 (void *)&cmd_set_vxlan_udp_src,
13285 (void *)&cmd_set_vxlan_udp_src_value,
13286 (void *)&cmd_set_vxlan_udp_dst,
13287 (void *)&cmd_set_vxlan_udp_dst_value,
13288 (void *)&cmd_set_vxlan_ip_src,
13289 (void *)&cmd_set_vxlan_ip_src_value,
13290 (void *)&cmd_set_vxlan_ip_dst,
13291 (void *)&cmd_set_vxlan_ip_dst_value,
13292 (void *)&cmd_set_vxlan_vlan,
13293 (void *)&cmd_set_vxlan_vlan_value,
13294 (void *)&cmd_set_vxlan_eth_src,
13295 (void *)&cmd_set_vxlan_eth_src_value,
13296 (void *)&cmd_set_vxlan_eth_dst,
13297 (void *)&cmd_set_vxlan_eth_dst_value,
13302 /** Set NVGRE encapsulation details */
13303 struct cmd_set_nvgre_result {
13304 cmdline_fixed_string_t set;
13305 cmdline_fixed_string_t nvgre;
13306 cmdline_fixed_string_t pos_token;
13307 cmdline_fixed_string_t ip_version;
13309 cmdline_ipaddr_t ip_src;
13310 cmdline_ipaddr_t ip_dst;
13312 struct rte_ether_addr eth_src;
13313 struct rte_ether_addr eth_dst;
13316 cmdline_parse_token_string_t cmd_set_nvgre_set =
13317 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13318 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13319 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13320 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13321 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13322 "nvgre-with-vlan");
13323 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13324 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13326 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13327 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13329 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13330 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13332 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13333 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13334 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13335 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13337 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13338 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13339 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13340 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13342 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13343 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13344 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13345 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13347 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13348 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13349 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13350 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13352 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13353 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13354 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13355 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13357 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13358 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13360 static void cmd_set_nvgre_parsed(void *parsed_result,
13361 __rte_unused struct cmdline *cl,
13362 __rte_unused void *data)
13364 struct cmd_set_nvgre_result *res = parsed_result;
13366 uint32_t nvgre_tni;
13369 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13372 if (strcmp(res->nvgre, "nvgre") == 0)
13373 nvgre_encap_conf.select_vlan = 0;
13374 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13375 nvgre_encap_conf.select_vlan = 1;
13376 if (strcmp(res->ip_version, "ipv4") == 0)
13377 nvgre_encap_conf.select_ipv4 = 1;
13378 else if (strcmp(res->ip_version, "ipv6") == 0)
13379 nvgre_encap_conf.select_ipv4 = 0;
13382 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13383 if (nvgre_encap_conf.select_ipv4) {
13384 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13385 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13387 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13388 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13390 if (nvgre_encap_conf.select_vlan)
13391 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13392 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13393 RTE_ETHER_ADDR_LEN);
13394 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13395 RTE_ETHER_ADDR_LEN);
13398 cmdline_parse_inst_t cmd_set_nvgre = {
13399 .f = cmd_set_nvgre_parsed,
13401 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13402 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13403 " eth-dst <eth-dst>",
13405 (void *)&cmd_set_nvgre_set,
13406 (void *)&cmd_set_nvgre_nvgre,
13407 (void *)&cmd_set_nvgre_ip_version,
13408 (void *)&cmd_set_nvgre_ip_version_value,
13409 (void *)&cmd_set_nvgre_tni,
13410 (void *)&cmd_set_nvgre_tni_value,
13411 (void *)&cmd_set_nvgre_ip_src,
13412 (void *)&cmd_set_nvgre_ip_src_value,
13413 (void *)&cmd_set_nvgre_ip_dst,
13414 (void *)&cmd_set_nvgre_ip_dst_value,
13415 (void *)&cmd_set_nvgre_eth_src,
13416 (void *)&cmd_set_nvgre_eth_src_value,
13417 (void *)&cmd_set_nvgre_eth_dst,
13418 (void *)&cmd_set_nvgre_eth_dst_value,
13423 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13424 .f = cmd_set_nvgre_parsed,
13426 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13427 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13428 " eth-src <eth-src> eth-dst <eth-dst>",
13430 (void *)&cmd_set_nvgre_set,
13431 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13432 (void *)&cmd_set_nvgre_ip_version,
13433 (void *)&cmd_set_nvgre_ip_version_value,
13434 (void *)&cmd_set_nvgre_tni,
13435 (void *)&cmd_set_nvgre_tni_value,
13436 (void *)&cmd_set_nvgre_ip_src,
13437 (void *)&cmd_set_nvgre_ip_src_value,
13438 (void *)&cmd_set_nvgre_ip_dst,
13439 (void *)&cmd_set_nvgre_ip_dst_value,
13440 (void *)&cmd_set_nvgre_vlan,
13441 (void *)&cmd_set_nvgre_vlan_value,
13442 (void *)&cmd_set_nvgre_eth_src,
13443 (void *)&cmd_set_nvgre_eth_src_value,
13444 (void *)&cmd_set_nvgre_eth_dst,
13445 (void *)&cmd_set_nvgre_eth_dst_value,
13450 /** Set L2 encapsulation details */
13451 struct cmd_set_l2_encap_result {
13452 cmdline_fixed_string_t set;
13453 cmdline_fixed_string_t l2_encap;
13454 cmdline_fixed_string_t pos_token;
13455 cmdline_fixed_string_t ip_version;
13456 uint32_t vlan_present:1;
13458 struct rte_ether_addr eth_src;
13459 struct rte_ether_addr eth_dst;
13462 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13463 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13464 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13465 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13466 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13467 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13468 "l2_encap-with-vlan");
13469 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13470 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13472 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13473 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13475 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13476 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13478 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13479 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13480 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13481 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13483 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13484 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13485 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13486 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13488 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13489 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13491 static void cmd_set_l2_encap_parsed(void *parsed_result,
13492 __rte_unused struct cmdline *cl,
13493 __rte_unused void *data)
13495 struct cmd_set_l2_encap_result *res = parsed_result;
13497 if (strcmp(res->l2_encap, "l2_encap") == 0)
13498 l2_encap_conf.select_vlan = 0;
13499 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13500 l2_encap_conf.select_vlan = 1;
13501 if (strcmp(res->ip_version, "ipv4") == 0)
13502 l2_encap_conf.select_ipv4 = 1;
13503 else if (strcmp(res->ip_version, "ipv6") == 0)
13504 l2_encap_conf.select_ipv4 = 0;
13507 if (l2_encap_conf.select_vlan)
13508 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13509 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13510 RTE_ETHER_ADDR_LEN);
13511 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13512 RTE_ETHER_ADDR_LEN);
13515 cmdline_parse_inst_t cmd_set_l2_encap = {
13516 .f = cmd_set_l2_encap_parsed,
13518 .help_str = "set l2_encap ip-version ipv4|ipv6"
13519 " eth-src <eth-src> eth-dst <eth-dst>",
13521 (void *)&cmd_set_l2_encap_set,
13522 (void *)&cmd_set_l2_encap_l2_encap,
13523 (void *)&cmd_set_l2_encap_ip_version,
13524 (void *)&cmd_set_l2_encap_ip_version_value,
13525 (void *)&cmd_set_l2_encap_eth_src,
13526 (void *)&cmd_set_l2_encap_eth_src_value,
13527 (void *)&cmd_set_l2_encap_eth_dst,
13528 (void *)&cmd_set_l2_encap_eth_dst_value,
13533 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13534 .f = cmd_set_l2_encap_parsed,
13536 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13537 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13539 (void *)&cmd_set_l2_encap_set,
13540 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13541 (void *)&cmd_set_l2_encap_ip_version,
13542 (void *)&cmd_set_l2_encap_ip_version_value,
13543 (void *)&cmd_set_l2_encap_vlan,
13544 (void *)&cmd_set_l2_encap_vlan_value,
13545 (void *)&cmd_set_l2_encap_eth_src,
13546 (void *)&cmd_set_l2_encap_eth_src_value,
13547 (void *)&cmd_set_l2_encap_eth_dst,
13548 (void *)&cmd_set_l2_encap_eth_dst_value,
13553 /** Set L2 decapsulation details */
13554 struct cmd_set_l2_decap_result {
13555 cmdline_fixed_string_t set;
13556 cmdline_fixed_string_t l2_decap;
13557 cmdline_fixed_string_t pos_token;
13558 uint32_t vlan_present:1;
13561 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13562 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13563 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13564 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13566 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13567 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13568 "l2_decap-with-vlan");
13570 static void cmd_set_l2_decap_parsed(void *parsed_result,
13571 __rte_unused struct cmdline *cl,
13572 __rte_unused void *data)
13574 struct cmd_set_l2_decap_result *res = parsed_result;
13576 if (strcmp(res->l2_decap, "l2_decap") == 0)
13577 l2_decap_conf.select_vlan = 0;
13578 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13579 l2_decap_conf.select_vlan = 1;
13582 cmdline_parse_inst_t cmd_set_l2_decap = {
13583 .f = cmd_set_l2_decap_parsed,
13585 .help_str = "set l2_decap",
13587 (void *)&cmd_set_l2_decap_set,
13588 (void *)&cmd_set_l2_decap_l2_decap,
13593 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13594 .f = cmd_set_l2_decap_parsed,
13596 .help_str = "set l2_decap-with-vlan",
13598 (void *)&cmd_set_l2_decap_set,
13599 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13604 /** Set MPLSoGRE encapsulation details */
13605 struct cmd_set_mplsogre_encap_result {
13606 cmdline_fixed_string_t set;
13607 cmdline_fixed_string_t mplsogre;
13608 cmdline_fixed_string_t pos_token;
13609 cmdline_fixed_string_t ip_version;
13610 uint32_t vlan_present:1;
13612 cmdline_ipaddr_t ip_src;
13613 cmdline_ipaddr_t ip_dst;
13615 struct rte_ether_addr eth_src;
13616 struct rte_ether_addr eth_dst;
13619 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13620 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13622 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13623 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13625 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13626 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13627 mplsogre, "mplsogre_encap-with-vlan");
13628 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13629 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13630 pos_token, "ip-version");
13631 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13632 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13633 ip_version, "ipv4#ipv6");
13634 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13635 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13636 pos_token, "label");
13637 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13638 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13640 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13641 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13642 pos_token, "ip-src");
13643 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13644 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13645 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13646 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13647 pos_token, "ip-dst");
13648 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13649 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13650 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13651 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13652 pos_token, "vlan-tci");
13653 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13654 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13656 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13657 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13658 pos_token, "eth-src");
13659 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13660 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13662 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13663 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13664 pos_token, "eth-dst");
13665 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13666 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13669 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13670 __rte_unused struct cmdline *cl,
13671 __rte_unused void *data)
13673 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13675 uint32_t mplsogre_label;
13678 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13681 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13682 mplsogre_encap_conf.select_vlan = 0;
13683 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13684 mplsogre_encap_conf.select_vlan = 1;
13685 if (strcmp(res->ip_version, "ipv4") == 0)
13686 mplsogre_encap_conf.select_ipv4 = 1;
13687 else if (strcmp(res->ip_version, "ipv6") == 0)
13688 mplsogre_encap_conf.select_ipv4 = 0;
13691 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13692 if (mplsogre_encap_conf.select_ipv4) {
13693 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13694 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13696 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13697 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13699 if (mplsogre_encap_conf.select_vlan)
13700 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13701 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13702 RTE_ETHER_ADDR_LEN);
13703 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13704 RTE_ETHER_ADDR_LEN);
13707 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13708 .f = cmd_set_mplsogre_encap_parsed,
13710 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13711 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13712 " eth-dst <eth-dst>",
13714 (void *)&cmd_set_mplsogre_encap_set,
13715 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13716 (void *)&cmd_set_mplsogre_encap_ip_version,
13717 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13718 (void *)&cmd_set_mplsogre_encap_label,
13719 (void *)&cmd_set_mplsogre_encap_label_value,
13720 (void *)&cmd_set_mplsogre_encap_ip_src,
13721 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13722 (void *)&cmd_set_mplsogre_encap_ip_dst,
13723 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13724 (void *)&cmd_set_mplsogre_encap_eth_src,
13725 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13726 (void *)&cmd_set_mplsogre_encap_eth_dst,
13727 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13732 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13733 .f = cmd_set_mplsogre_encap_parsed,
13735 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13736 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13737 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13739 (void *)&cmd_set_mplsogre_encap_set,
13740 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13741 (void *)&cmd_set_mplsogre_encap_ip_version,
13742 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13743 (void *)&cmd_set_mplsogre_encap_label,
13744 (void *)&cmd_set_mplsogre_encap_label_value,
13745 (void *)&cmd_set_mplsogre_encap_ip_src,
13746 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13747 (void *)&cmd_set_mplsogre_encap_ip_dst,
13748 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13749 (void *)&cmd_set_mplsogre_encap_vlan,
13750 (void *)&cmd_set_mplsogre_encap_vlan_value,
13751 (void *)&cmd_set_mplsogre_encap_eth_src,
13752 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13753 (void *)&cmd_set_mplsogre_encap_eth_dst,
13754 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13759 /** Set MPLSoGRE decapsulation details */
13760 struct cmd_set_mplsogre_decap_result {
13761 cmdline_fixed_string_t set;
13762 cmdline_fixed_string_t mplsogre;
13763 cmdline_fixed_string_t pos_token;
13764 cmdline_fixed_string_t ip_version;
13765 uint32_t vlan_present:1;
13768 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13769 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13771 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13772 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13774 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13775 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13776 mplsogre, "mplsogre_decap-with-vlan");
13777 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13778 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13779 pos_token, "ip-version");
13780 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13781 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13782 ip_version, "ipv4#ipv6");
13784 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13785 __rte_unused struct cmdline *cl,
13786 __rte_unused void *data)
13788 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13790 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13791 mplsogre_decap_conf.select_vlan = 0;
13792 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13793 mplsogre_decap_conf.select_vlan = 1;
13794 if (strcmp(res->ip_version, "ipv4") == 0)
13795 mplsogre_decap_conf.select_ipv4 = 1;
13796 else if (strcmp(res->ip_version, "ipv6") == 0)
13797 mplsogre_decap_conf.select_ipv4 = 0;
13800 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13801 .f = cmd_set_mplsogre_decap_parsed,
13803 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13805 (void *)&cmd_set_mplsogre_decap_set,
13806 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13807 (void *)&cmd_set_mplsogre_decap_ip_version,
13808 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13813 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13814 .f = cmd_set_mplsogre_decap_parsed,
13816 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13818 (void *)&cmd_set_mplsogre_decap_set,
13819 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13820 (void *)&cmd_set_mplsogre_decap_ip_version,
13821 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13826 /** Set MPLSoUDP encapsulation details */
13827 struct cmd_set_mplsoudp_encap_result {
13828 cmdline_fixed_string_t set;
13829 cmdline_fixed_string_t mplsoudp;
13830 cmdline_fixed_string_t pos_token;
13831 cmdline_fixed_string_t ip_version;
13832 uint32_t vlan_present:1;
13836 cmdline_ipaddr_t ip_src;
13837 cmdline_ipaddr_t ip_dst;
13839 struct rte_ether_addr eth_src;
13840 struct rte_ether_addr eth_dst;
13843 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13844 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13846 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13847 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13849 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13850 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13851 mplsoudp, "mplsoudp_encap-with-vlan");
13852 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13853 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13854 pos_token, "ip-version");
13855 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13856 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13857 ip_version, "ipv4#ipv6");
13858 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13859 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13860 pos_token, "label");
13861 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13862 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13864 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13865 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13866 pos_token, "udp-src");
13867 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13868 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13870 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13871 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13872 pos_token, "udp-dst");
13873 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13874 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13876 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13877 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13878 pos_token, "ip-src");
13879 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13880 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13881 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13882 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13883 pos_token, "ip-dst");
13884 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13885 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13886 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13887 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13888 pos_token, "vlan-tci");
13889 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13890 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13892 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13893 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13894 pos_token, "eth-src");
13895 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13896 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13898 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13899 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13900 pos_token, "eth-dst");
13901 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13902 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13905 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13906 __rte_unused struct cmdline *cl,
13907 __rte_unused void *data)
13909 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13911 uint32_t mplsoudp_label;
13914 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13917 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13918 mplsoudp_encap_conf.select_vlan = 0;
13919 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13920 mplsoudp_encap_conf.select_vlan = 1;
13921 if (strcmp(res->ip_version, "ipv4") == 0)
13922 mplsoudp_encap_conf.select_ipv4 = 1;
13923 else if (strcmp(res->ip_version, "ipv6") == 0)
13924 mplsoudp_encap_conf.select_ipv4 = 0;
13927 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13928 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13929 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13930 if (mplsoudp_encap_conf.select_ipv4) {
13931 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13932 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13934 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13935 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13937 if (mplsoudp_encap_conf.select_vlan)
13938 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13939 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13940 RTE_ETHER_ADDR_LEN);
13941 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13942 RTE_ETHER_ADDR_LEN);
13945 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13946 .f = cmd_set_mplsoudp_encap_parsed,
13948 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13949 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13950 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13952 (void *)&cmd_set_mplsoudp_encap_set,
13953 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13954 (void *)&cmd_set_mplsoudp_encap_ip_version,
13955 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13956 (void *)&cmd_set_mplsoudp_encap_label,
13957 (void *)&cmd_set_mplsoudp_encap_label_value,
13958 (void *)&cmd_set_mplsoudp_encap_udp_src,
13959 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13960 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13961 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13962 (void *)&cmd_set_mplsoudp_encap_ip_src,
13963 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13964 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13965 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13966 (void *)&cmd_set_mplsoudp_encap_eth_src,
13967 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13968 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13969 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13974 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13975 .f = cmd_set_mplsoudp_encap_parsed,
13977 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13978 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13979 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13980 " eth-src <eth-src> eth-dst <eth-dst>",
13982 (void *)&cmd_set_mplsoudp_encap_set,
13983 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13984 (void *)&cmd_set_mplsoudp_encap_ip_version,
13985 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13986 (void *)&cmd_set_mplsoudp_encap_label,
13987 (void *)&cmd_set_mplsoudp_encap_label_value,
13988 (void *)&cmd_set_mplsoudp_encap_udp_src,
13989 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13990 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13991 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13992 (void *)&cmd_set_mplsoudp_encap_ip_src,
13993 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13994 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13995 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13996 (void *)&cmd_set_mplsoudp_encap_vlan,
13997 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13998 (void *)&cmd_set_mplsoudp_encap_eth_src,
13999 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
14000 (void *)&cmd_set_mplsoudp_encap_eth_dst,
14001 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14006 /** Set MPLSoUDP decapsulation details */
14007 struct cmd_set_mplsoudp_decap_result {
14008 cmdline_fixed_string_t set;
14009 cmdline_fixed_string_t mplsoudp;
14010 cmdline_fixed_string_t pos_token;
14011 cmdline_fixed_string_t ip_version;
14012 uint32_t vlan_present:1;
14015 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
14016 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
14018 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
14019 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
14021 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
14022 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14023 mplsoudp, "mplsoudp_decap-with-vlan");
14024 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
14025 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14026 pos_token, "ip-version");
14027 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
14028 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14029 ip_version, "ipv4#ipv6");
14031 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
14032 __rte_unused struct cmdline *cl,
14033 __rte_unused void *data)
14035 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
14037 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
14038 mplsoudp_decap_conf.select_vlan = 0;
14039 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
14040 mplsoudp_decap_conf.select_vlan = 1;
14041 if (strcmp(res->ip_version, "ipv4") == 0)
14042 mplsoudp_decap_conf.select_ipv4 = 1;
14043 else if (strcmp(res->ip_version, "ipv6") == 0)
14044 mplsoudp_decap_conf.select_ipv4 = 0;
14047 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
14048 .f = cmd_set_mplsoudp_decap_parsed,
14050 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
14052 (void *)&cmd_set_mplsoudp_decap_set,
14053 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
14054 (void *)&cmd_set_mplsoudp_decap_ip_version,
14055 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14060 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
14061 .f = cmd_set_mplsoudp_decap_parsed,
14063 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
14065 (void *)&cmd_set_mplsoudp_decap_set,
14066 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
14067 (void *)&cmd_set_mplsoudp_decap_ip_version,
14068 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14073 /** Set connection tracking object common details */
14074 struct cmd_set_conntrack_common_result {
14075 cmdline_fixed_string_t set;
14076 cmdline_fixed_string_t conntrack;
14077 cmdline_fixed_string_t common;
14078 cmdline_fixed_string_t peer;
14079 cmdline_fixed_string_t is_orig;
14080 cmdline_fixed_string_t enable;
14081 cmdline_fixed_string_t live;
14082 cmdline_fixed_string_t sack;
14083 cmdline_fixed_string_t cack;
14084 cmdline_fixed_string_t last_dir;
14085 cmdline_fixed_string_t liberal;
14086 cmdline_fixed_string_t state;
14087 cmdline_fixed_string_t max_ack_win;
14088 cmdline_fixed_string_t retrans;
14089 cmdline_fixed_string_t last_win;
14090 cmdline_fixed_string_t last_seq;
14091 cmdline_fixed_string_t last_ack;
14092 cmdline_fixed_string_t last_end;
14093 cmdline_fixed_string_t last_index;
14096 uint16_t peer_port;
14097 uint32_t is_original;
14112 cmdline_parse_token_string_t cmd_set_conntrack_set =
14113 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14115 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
14116 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14117 conntrack, "conntrack");
14118 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
14119 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14121 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
14122 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14124 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
14125 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14126 peer_port, RTE_UINT16);
14127 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
14128 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14129 is_orig, "is_orig");
14130 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
14131 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14132 is_original, RTE_UINT32);
14133 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
14134 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14136 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14137 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14139 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14140 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14142 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14143 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14144 is_live, RTE_UINT32);
14145 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14146 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14148 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14149 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14150 s_ack, RTE_UINT32);
14151 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14152 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14154 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14155 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14156 c_ack, RTE_UINT32);
14157 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14158 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14159 last_dir, "last_dir");
14160 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14161 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14163 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14164 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14165 liberal, "liberal");
14166 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14167 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14169 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14170 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14172 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14173 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14175 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14176 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14177 max_ack_win, "max_ack_win");
14178 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14179 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14180 factor, RTE_UINT8);
14181 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14182 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14184 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14185 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14186 re_num, RTE_UINT8);
14187 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14188 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14189 last_win, "last_win");
14190 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14191 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14193 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14194 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14195 last_seq, "last_seq");
14196 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14197 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14199 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14200 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14201 last_ack, "last_ack");
14202 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14203 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14205 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14206 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14207 last_end, "last_end");
14208 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14209 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14211 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14212 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14213 last_index, "last_index");
14214 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14215 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14218 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14219 __rte_unused struct cmdline *cl,
14220 __rte_unused void *data)
14222 struct cmd_set_conntrack_common_result *res = parsed_result;
14224 /* No need to swap to big endian. */
14225 conntrack_context.peer_port = res->peer_port;
14226 conntrack_context.is_original_dir = res->is_original;
14227 conntrack_context.enable = res->en;
14228 conntrack_context.live_connection = res->is_live;
14229 conntrack_context.selective_ack = res->s_ack;
14230 conntrack_context.challenge_ack_passed = res->c_ack;
14231 conntrack_context.last_direction = res->ld;
14232 conntrack_context.liberal_mode = res->lb;
14233 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14234 conntrack_context.max_ack_window = res->factor;
14235 conntrack_context.retransmission_limit = res->re_num;
14236 conntrack_context.last_window = res->lw;
14237 conntrack_context.last_index =
14238 (enum rte_flow_conntrack_tcp_last_index)res->li;
14239 conntrack_context.last_seq = res->ls;
14240 conntrack_context.last_ack = res->la;
14241 conntrack_context.last_end = res->le;
14244 cmdline_parse_inst_t cmd_set_conntrack_common = {
14245 .f = cmd_set_conntrack_common_parsed,
14247 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14248 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14249 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14250 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14251 " last_index <flag>",
14253 (void *)&cmd_set_conntrack_set,
14254 (void *)&cmd_set_conntrack_conntrack,
14255 (void *)&cmd_set_conntrack_common_com,
14256 (void *)&cmd_set_conntrack_common_peer,
14257 (void *)&cmd_set_conntrack_common_peer_value,
14258 (void *)&cmd_set_conntrack_common_is_orig,
14259 (void *)&cmd_set_conntrack_common_is_orig_value,
14260 (void *)&cmd_set_conntrack_common_enable,
14261 (void *)&cmd_set_conntrack_common_enable_value,
14262 (void *)&cmd_set_conntrack_common_live,
14263 (void *)&cmd_set_conntrack_common_live_value,
14264 (void *)&cmd_set_conntrack_common_sack,
14265 (void *)&cmd_set_conntrack_common_sack_value,
14266 (void *)&cmd_set_conntrack_common_cack,
14267 (void *)&cmd_set_conntrack_common_cack_value,
14268 (void *)&cmd_set_conntrack_common_last_dir,
14269 (void *)&cmd_set_conntrack_common_last_dir_value,
14270 (void *)&cmd_set_conntrack_common_liberal,
14271 (void *)&cmd_set_conntrack_common_liberal_value,
14272 (void *)&cmd_set_conntrack_common_state,
14273 (void *)&cmd_set_conntrack_common_state_value,
14274 (void *)&cmd_set_conntrack_common_max_ackwin,
14275 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14276 (void *)&cmd_set_conntrack_common_retrans,
14277 (void *)&cmd_set_conntrack_common_retrans_value,
14278 (void *)&cmd_set_conntrack_common_last_win,
14279 (void *)&cmd_set_conntrack_common_last_win_value,
14280 (void *)&cmd_set_conntrack_common_last_seq,
14281 (void *)&cmd_set_conntrack_common_last_seq_value,
14282 (void *)&cmd_set_conntrack_common_last_ack,
14283 (void *)&cmd_set_conntrack_common_last_ack_value,
14284 (void *)&cmd_set_conntrack_common_last_end,
14285 (void *)&cmd_set_conntrack_common_last_end_value,
14286 (void *)&cmd_set_conntrack_common_last_index,
14287 (void *)&cmd_set_conntrack_common_last_index_value,
14292 /** Set connection tracking object both directions' details */
14293 struct cmd_set_conntrack_dir_result {
14294 cmdline_fixed_string_t set;
14295 cmdline_fixed_string_t conntrack;
14296 cmdline_fixed_string_t dir;
14297 cmdline_fixed_string_t scale;
14298 cmdline_fixed_string_t fin;
14299 cmdline_fixed_string_t ack_seen;
14300 cmdline_fixed_string_t unack;
14301 cmdline_fixed_string_t sent_end;
14302 cmdline_fixed_string_t reply_end;
14303 cmdline_fixed_string_t max_win;
14304 cmdline_fixed_string_t max_ack;
14315 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14316 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14318 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14319 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14320 conntrack, "conntrack");
14321 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14322 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14324 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14325 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14327 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14328 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14329 factor, RTE_UINT32);
14330 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14331 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14333 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14334 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14336 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14337 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14338 ack_seen, "acked");
14339 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14340 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14342 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14343 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14344 unack, "unack_data");
14345 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14346 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14348 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14349 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14350 sent_end, "sent_end");
14351 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14352 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14354 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14355 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14356 reply_end, "reply_end");
14357 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14358 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14360 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14361 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14362 max_win, "max_win");
14363 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14364 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14366 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14367 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14368 max_ack, "max_ack");
14369 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14370 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14373 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14374 __rte_unused struct cmdline *cl,
14375 __rte_unused void *data)
14377 struct cmd_set_conntrack_dir_result *res = parsed_result;
14378 struct rte_flow_tcp_dir_param *dir = NULL;
14380 if (strcmp(res->dir, "orig") == 0)
14381 dir = &conntrack_context.original_dir;
14382 else if (strcmp(res->dir, "rply") == 0)
14383 dir = &conntrack_context.reply_dir;
14386 dir->scale = res->factor;
14387 dir->close_initiated = res->f;
14388 dir->last_ack_seen = res->as;
14389 dir->data_unacked = res->un;
14390 dir->sent_end = res->se;
14391 dir->reply_end = res->re;
14392 dir->max_ack = res->ma;
14393 dir->max_win = res->mw;
14396 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14397 .f = cmd_set_conntrack_dir_parsed,
14399 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14400 " acked <seen> unack_data <unack> sent_end <sent>"
14401 " reply_end <reply> max_win <win> max_ack <ack>",
14403 (void *)&cmd_set_conntrack_set,
14404 (void *)&cmd_set_conntrack_conntrack,
14405 (void *)&cmd_set_conntrack_dir_dir,
14406 (void *)&cmd_set_conntrack_dir_scale,
14407 (void *)&cmd_set_conntrack_dir_scale_value,
14408 (void *)&cmd_set_conntrack_dir_fin,
14409 (void *)&cmd_set_conntrack_dir_fin_value,
14410 (void *)&cmd_set_conntrack_dir_ack,
14411 (void *)&cmd_set_conntrack_dir_ack_value,
14412 (void *)&cmd_set_conntrack_dir_unack_data,
14413 (void *)&cmd_set_conntrack_dir_unack_data_value,
14414 (void *)&cmd_set_conntrack_dir_sent_end,
14415 (void *)&cmd_set_conntrack_dir_sent_end_value,
14416 (void *)&cmd_set_conntrack_dir_reply_end,
14417 (void *)&cmd_set_conntrack_dir_reply_end_value,
14418 (void *)&cmd_set_conntrack_dir_max_win,
14419 (void *)&cmd_set_conntrack_dir_max_win_value,
14420 (void *)&cmd_set_conntrack_dir_max_ack,
14421 (void *)&cmd_set_conntrack_dir_max_ack_value,
14426 /* Strict link priority scheduling mode setting */
14428 cmd_strict_link_prio_parsed(
14429 void *parsed_result,
14430 __rte_unused struct cmdline *cl,
14431 __rte_unused void *data)
14433 struct cmd_vf_tc_bw_result *res = parsed_result;
14434 int ret = -ENOTSUP;
14436 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14439 #ifdef RTE_NET_I40E
14440 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14447 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14450 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14453 fprintf(stderr, "function not implemented\n");
14456 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14460 cmdline_parse_inst_t cmd_strict_link_prio = {
14461 .f = cmd_strict_link_prio_parsed,
14463 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14465 (void *)&cmd_vf_tc_bw_set,
14466 (void *)&cmd_vf_tc_bw_tx,
14467 (void *)&cmd_vf_tc_bw_strict_link_prio,
14468 (void *)&cmd_vf_tc_bw_port_id,
14469 (void *)&cmd_vf_tc_bw_tc_map,
14474 /* Load dynamic device personalization*/
14475 struct cmd_ddp_add_result {
14476 cmdline_fixed_string_t ddp;
14477 cmdline_fixed_string_t add;
14482 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14483 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14484 cmdline_parse_token_string_t cmd_ddp_add_add =
14485 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14486 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14487 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14489 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14490 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14493 cmd_ddp_add_parsed(
14494 void *parsed_result,
14495 __rte_unused struct cmdline *cl,
14496 __rte_unused void *data)
14498 struct cmd_ddp_add_result *res = parsed_result;
14504 int ret = -ENOTSUP;
14506 if (!all_ports_stopped()) {
14507 fprintf(stderr, "Please stop all ports first\n");
14511 filepath = strdup(res->filepath);
14512 if (filepath == NULL) {
14513 fprintf(stderr, "Failed to allocate memory\n");
14516 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14518 buff = open_file(file_fld[0], &size);
14520 free((void *)filepath);
14524 #ifdef RTE_NET_I40E
14525 if (ret == -ENOTSUP)
14526 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14528 RTE_PMD_I40E_PKG_OP_WR_ADD);
14531 if (ret == -EEXIST)
14532 fprintf(stderr, "Profile has already existed.\n");
14534 fprintf(stderr, "Failed to load profile.\n");
14535 else if (file_num == 2)
14536 save_file(file_fld[1], buff, size);
14539 free((void *)filepath);
14542 cmdline_parse_inst_t cmd_ddp_add = {
14543 .f = cmd_ddp_add_parsed,
14545 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14547 (void *)&cmd_ddp_add_ddp,
14548 (void *)&cmd_ddp_add_add,
14549 (void *)&cmd_ddp_add_port_id,
14550 (void *)&cmd_ddp_add_filepath,
14555 /* Delete dynamic device personalization*/
14556 struct cmd_ddp_del_result {
14557 cmdline_fixed_string_t ddp;
14558 cmdline_fixed_string_t del;
14563 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14564 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14565 cmdline_parse_token_string_t cmd_ddp_del_del =
14566 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14567 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14568 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14569 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14570 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14573 cmd_ddp_del_parsed(
14574 void *parsed_result,
14575 __rte_unused struct cmdline *cl,
14576 __rte_unused void *data)
14578 struct cmd_ddp_del_result *res = parsed_result;
14581 int ret = -ENOTSUP;
14583 if (!all_ports_stopped()) {
14584 fprintf(stderr, "Please stop all ports first\n");
14588 buff = open_file(res->filepath, &size);
14592 #ifdef RTE_NET_I40E
14593 if (ret == -ENOTSUP)
14594 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14596 RTE_PMD_I40E_PKG_OP_WR_DEL);
14599 if (ret == -EACCES)
14600 fprintf(stderr, "Profile does not exist.\n");
14602 fprintf(stderr, "Failed to delete profile.\n");
14607 cmdline_parse_inst_t cmd_ddp_del = {
14608 .f = cmd_ddp_del_parsed,
14610 .help_str = "ddp del <port_id> <backup_profile_path>",
14612 (void *)&cmd_ddp_del_ddp,
14613 (void *)&cmd_ddp_del_del,
14614 (void *)&cmd_ddp_del_port_id,
14615 (void *)&cmd_ddp_del_filepath,
14620 /* Get dynamic device personalization profile info */
14621 struct cmd_ddp_info_result {
14622 cmdline_fixed_string_t ddp;
14623 cmdline_fixed_string_t get;
14624 cmdline_fixed_string_t info;
14628 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14629 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14630 cmdline_parse_token_string_t cmd_ddp_info_get =
14631 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14632 cmdline_parse_token_string_t cmd_ddp_info_info =
14633 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14634 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14635 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14638 cmd_ddp_info_parsed(
14639 void *parsed_result,
14640 __rte_unused struct cmdline *cl,
14641 __rte_unused void *data)
14643 struct cmd_ddp_info_result *res = parsed_result;
14646 int ret = -ENOTSUP;
14647 #ifdef RTE_NET_I40E
14650 uint32_t buff_size = 0;
14651 struct rte_pmd_i40e_profile_info info;
14652 uint32_t dev_num = 0;
14653 struct rte_pmd_i40e_ddp_device_id *devs;
14654 uint32_t proto_num = 0;
14655 struct rte_pmd_i40e_proto_info *proto = NULL;
14656 uint32_t pctype_num = 0;
14657 struct rte_pmd_i40e_ptype_info *pctype;
14658 uint32_t ptype_num = 0;
14659 struct rte_pmd_i40e_ptype_info *ptype;
14664 pkg = open_file(res->filepath, &pkg_size);
14668 #ifdef RTE_NET_I40E
14669 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14670 (uint8_t *)&info, sizeof(info),
14671 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14673 printf("Global Track id: 0x%x\n", info.track_id);
14674 printf("Global Version: %d.%d.%d.%d\n",
14675 info.version.major,
14676 info.version.minor,
14677 info.version.update,
14678 info.version.draft);
14679 printf("Global Package name: %s\n\n", info.name);
14682 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14683 (uint8_t *)&info, sizeof(info),
14684 RTE_PMD_I40E_PKG_INFO_HEADER);
14686 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14687 printf("i40e Profile Version: %d.%d.%d.%d\n",
14688 info.version.major,
14689 info.version.minor,
14690 info.version.update,
14691 info.version.draft);
14692 printf("i40e Profile name: %s\n\n", info.name);
14695 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14696 (uint8_t *)&buff_size, sizeof(buff_size),
14697 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14698 if (!ret && buff_size) {
14699 buff = (uint8_t *)malloc(buff_size);
14701 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14703 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14705 printf("Package Notes:\n%s\n\n", buff);
14710 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14711 (uint8_t *)&dev_num, sizeof(dev_num),
14712 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14713 if (!ret && dev_num) {
14714 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14715 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14717 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14718 (uint8_t *)devs, buff_size,
14719 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14721 printf("List of supported devices:\n");
14722 for (i = 0; i < dev_num; i++) {
14723 printf(" %04X:%04X %04X:%04X\n",
14724 devs[i].vendor_dev_id >> 16,
14725 devs[i].vendor_dev_id & 0xFFFF,
14726 devs[i].sub_vendor_dev_id >> 16,
14727 devs[i].sub_vendor_dev_id & 0xFFFF);
14735 /* get information about protocols and packet types */
14736 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14737 (uint8_t *)&proto_num, sizeof(proto_num),
14738 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14739 if (ret || !proto_num)
14740 goto no_print_return;
14742 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14743 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14745 goto no_print_return;
14747 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14749 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14751 printf("List of used protocols:\n");
14752 for (i = 0; i < proto_num; i++)
14753 printf(" %2u: %s\n", proto[i].proto_id,
14757 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14758 (uint8_t *)&pctype_num, sizeof(pctype_num),
14759 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14760 if (ret || !pctype_num)
14761 goto no_print_pctypes;
14763 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14764 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14766 goto no_print_pctypes;
14768 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14770 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14773 goto no_print_pctypes;
14776 printf("List of defined packet classification types:\n");
14777 for (i = 0; i < pctype_num; i++) {
14778 printf(" %2u:", pctype[i].ptype_id);
14779 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14780 proto_id = pctype[i].protocols[j];
14781 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14782 for (n = 0; n < proto_num; n++) {
14783 if (proto[n].proto_id == proto_id) {
14784 printf(" %s", proto[n].name);
14797 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14799 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14800 if (ret || !ptype_num)
14801 goto no_print_return;
14803 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14804 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14806 goto no_print_return;
14808 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14810 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14813 goto no_print_return;
14815 printf("List of defined packet types:\n");
14816 for (i = 0; i < ptype_num; i++) {
14817 printf(" %2u:", ptype[i].ptype_id);
14818 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14819 proto_id = ptype[i].protocols[j];
14820 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14821 for (n = 0; n < proto_num; n++) {
14822 if (proto[n].proto_id == proto_id) {
14823 printf(" %s", proto[n].name);
14838 if (ret == -ENOTSUP)
14839 fprintf(stderr, "Function not supported in PMD\n");
14843 cmdline_parse_inst_t cmd_ddp_get_info = {
14844 .f = cmd_ddp_info_parsed,
14846 .help_str = "ddp get info <profile_path>",
14848 (void *)&cmd_ddp_info_ddp,
14849 (void *)&cmd_ddp_info_get,
14850 (void *)&cmd_ddp_info_info,
14851 (void *)&cmd_ddp_info_filepath,
14856 /* Get dynamic device personalization profile info list*/
14857 #define PROFILE_INFO_SIZE 48
14858 #define MAX_PROFILE_NUM 16
14860 struct cmd_ddp_get_list_result {
14861 cmdline_fixed_string_t ddp;
14862 cmdline_fixed_string_t get;
14863 cmdline_fixed_string_t list;
14867 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14868 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14869 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14870 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14871 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14872 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14873 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14874 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14878 cmd_ddp_get_list_parsed(
14879 __rte_unused void *parsed_result,
14880 __rte_unused struct cmdline *cl,
14881 __rte_unused void *data)
14883 #ifdef RTE_NET_I40E
14884 struct cmd_ddp_get_list_result *res = parsed_result;
14885 struct rte_pmd_i40e_profile_list *p_list;
14886 struct rte_pmd_i40e_profile_info *p_info;
14891 int ret = -ENOTSUP;
14893 #ifdef RTE_NET_I40E
14894 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14895 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14897 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14901 if (ret == -ENOTSUP)
14902 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14903 (uint8_t *)p_list, size);
14906 p_num = p_list->p_count;
14907 printf("Profile number is: %d\n\n", p_num);
14909 for (i = 0; i < p_num; i++) {
14910 p_info = &p_list->p_info[i];
14911 printf("Profile %d:\n", i);
14912 printf("Track id: 0x%x\n", p_info->track_id);
14913 printf("Version: %d.%d.%d.%d\n",
14914 p_info->version.major,
14915 p_info->version.minor,
14916 p_info->version.update,
14917 p_info->version.draft);
14918 printf("Profile name: %s\n\n", p_info->name);
14926 fprintf(stderr, "Failed to get ddp list\n");
14929 cmdline_parse_inst_t cmd_ddp_get_list = {
14930 .f = cmd_ddp_get_list_parsed,
14932 .help_str = "ddp get list <port_id>",
14934 (void *)&cmd_ddp_get_list_ddp,
14935 (void *)&cmd_ddp_get_list_get,
14936 (void *)&cmd_ddp_get_list_list,
14937 (void *)&cmd_ddp_get_list_port_id,
14942 /* Configure input set */
14943 struct cmd_cfg_input_set_result {
14944 cmdline_fixed_string_t port;
14945 cmdline_fixed_string_t cfg;
14947 cmdline_fixed_string_t pctype;
14949 cmdline_fixed_string_t inset_type;
14950 cmdline_fixed_string_t opt;
14951 cmdline_fixed_string_t field;
14956 cmd_cfg_input_set_parsed(
14957 __rte_unused void *parsed_result,
14958 __rte_unused struct cmdline *cl,
14959 __rte_unused void *data)
14961 #ifdef RTE_NET_I40E
14962 struct cmd_cfg_input_set_result *res = parsed_result;
14963 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14964 struct rte_pmd_i40e_inset inset;
14966 int ret = -ENOTSUP;
14968 if (!all_ports_stopped()) {
14969 fprintf(stderr, "Please stop all ports first\n");
14973 #ifdef RTE_NET_I40E
14974 if (!strcmp(res->inset_type, "hash_inset"))
14975 inset_type = INSET_HASH;
14976 else if (!strcmp(res->inset_type, "fdir_inset"))
14977 inset_type = INSET_FDIR;
14978 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14979 inset_type = INSET_FDIR_FLX;
14980 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14981 &inset, inset_type);
14983 fprintf(stderr, "Failed to get input set.\n");
14987 if (!strcmp(res->opt, "get")) {
14988 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14991 printf("Field index %d is enabled.\n", res->field_idx);
14993 printf("Field index %d is disabled.\n", res->field_idx);
14995 } else if (!strcmp(res->opt, "set"))
14996 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14998 else if (!strcmp(res->opt, "clear"))
14999 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15002 fprintf(stderr, "Failed to configure input set field.\n");
15006 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15007 &inset, inset_type);
15009 fprintf(stderr, "Failed to set input set.\n");
15014 if (ret == -ENOTSUP)
15015 fprintf(stderr, "Function not supported\n");
15018 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15019 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15021 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15022 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15024 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15025 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15026 port_id, RTE_UINT16);
15027 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15028 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15030 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15031 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15032 pctype_id, RTE_UINT8);
15033 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15034 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15036 "hash_inset#fdir_inset#fdir_flx_inset");
15037 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15038 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15039 opt, "get#set#clear");
15040 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15041 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15043 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15044 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15045 field_idx, RTE_UINT8);
15047 cmdline_parse_inst_t cmd_cfg_input_set = {
15048 .f = cmd_cfg_input_set_parsed,
15050 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15051 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15053 (void *)&cmd_cfg_input_set_port,
15054 (void *)&cmd_cfg_input_set_cfg,
15055 (void *)&cmd_cfg_input_set_port_id,
15056 (void *)&cmd_cfg_input_set_pctype,
15057 (void *)&cmd_cfg_input_set_pctype_id,
15058 (void *)&cmd_cfg_input_set_inset_type,
15059 (void *)&cmd_cfg_input_set_opt,
15060 (void *)&cmd_cfg_input_set_field,
15061 (void *)&cmd_cfg_input_set_field_idx,
15066 /* Clear input set */
15067 struct cmd_clear_input_set_result {
15068 cmdline_fixed_string_t port;
15069 cmdline_fixed_string_t cfg;
15071 cmdline_fixed_string_t pctype;
15073 cmdline_fixed_string_t inset_type;
15074 cmdline_fixed_string_t clear;
15075 cmdline_fixed_string_t all;
15079 cmd_clear_input_set_parsed(
15080 __rte_unused void *parsed_result,
15081 __rte_unused struct cmdline *cl,
15082 __rte_unused void *data)
15084 #ifdef RTE_NET_I40E
15085 struct cmd_clear_input_set_result *res = parsed_result;
15086 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15087 struct rte_pmd_i40e_inset inset;
15089 int ret = -ENOTSUP;
15091 if (!all_ports_stopped()) {
15092 fprintf(stderr, "Please stop all ports first\n");
15096 #ifdef RTE_NET_I40E
15097 if (!strcmp(res->inset_type, "hash_inset"))
15098 inset_type = INSET_HASH;
15099 else if (!strcmp(res->inset_type, "fdir_inset"))
15100 inset_type = INSET_FDIR;
15101 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15102 inset_type = INSET_FDIR_FLX;
15104 memset(&inset, 0, sizeof(inset));
15106 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15107 &inset, inset_type);
15109 fprintf(stderr, "Failed to clear input set.\n");
15115 if (ret == -ENOTSUP)
15116 fprintf(stderr, "Function not supported\n");
15119 cmdline_parse_token_string_t cmd_clear_input_set_port =
15120 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15122 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15123 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15125 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15126 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15127 port_id, RTE_UINT16);
15128 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15129 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15131 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15132 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15133 pctype_id, RTE_UINT8);
15134 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15135 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15137 "hash_inset#fdir_inset#fdir_flx_inset");
15138 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15139 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15141 cmdline_parse_token_string_t cmd_clear_input_set_all =
15142 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15145 cmdline_parse_inst_t cmd_clear_input_set = {
15146 .f = cmd_clear_input_set_parsed,
15148 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15149 "fdir_inset|fdir_flx_inset clear all",
15151 (void *)&cmd_clear_input_set_port,
15152 (void *)&cmd_clear_input_set_cfg,
15153 (void *)&cmd_clear_input_set_port_id,
15154 (void *)&cmd_clear_input_set_pctype,
15155 (void *)&cmd_clear_input_set_pctype_id,
15156 (void *)&cmd_clear_input_set_inset_type,
15157 (void *)&cmd_clear_input_set_clear,
15158 (void *)&cmd_clear_input_set_all,
15163 /* show vf stats */
15165 /* Common result structure for show vf stats */
15166 struct cmd_show_vf_stats_result {
15167 cmdline_fixed_string_t show;
15168 cmdline_fixed_string_t vf;
15169 cmdline_fixed_string_t stats;
15174 /* Common CLI fields show vf stats*/
15175 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15176 TOKEN_STRING_INITIALIZER
15177 (struct cmd_show_vf_stats_result,
15179 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15180 TOKEN_STRING_INITIALIZER
15181 (struct cmd_show_vf_stats_result,
15183 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15184 TOKEN_STRING_INITIALIZER
15185 (struct cmd_show_vf_stats_result,
15187 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15188 TOKEN_NUM_INITIALIZER
15189 (struct cmd_show_vf_stats_result,
15190 port_id, RTE_UINT16);
15191 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15192 TOKEN_NUM_INITIALIZER
15193 (struct cmd_show_vf_stats_result,
15194 vf_id, RTE_UINT16);
15197 cmd_show_vf_stats_parsed(
15198 void *parsed_result,
15199 __rte_unused struct cmdline *cl,
15200 __rte_unused void *data)
15202 struct cmd_show_vf_stats_result *res = parsed_result;
15203 struct rte_eth_stats stats;
15204 int ret = -ENOTSUP;
15205 static const char *nic_stats_border = "########################";
15207 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15210 memset(&stats, 0, sizeof(stats));
15212 #ifdef RTE_NET_I40E
15213 if (ret == -ENOTSUP)
15214 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15218 #ifdef RTE_NET_BNXT
15219 if (ret == -ENOTSUP)
15220 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15229 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15232 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15235 fprintf(stderr, "function not implemented\n");
15238 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15241 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15242 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15244 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15246 stats.ipackets, stats.imissed, stats.ibytes);
15247 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15248 printf(" RX-nombuf: %-10"PRIu64"\n",
15250 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15252 stats.opackets, stats.oerrors, stats.obytes);
15254 printf(" %s############################%s\n",
15255 nic_stats_border, nic_stats_border);
15258 cmdline_parse_inst_t cmd_show_vf_stats = {
15259 .f = cmd_show_vf_stats_parsed,
15261 .help_str = "show vf stats <port_id> <vf_id>",
15263 (void *)&cmd_show_vf_stats_show,
15264 (void *)&cmd_show_vf_stats_vf,
15265 (void *)&cmd_show_vf_stats_stats,
15266 (void *)&cmd_show_vf_stats_port_id,
15267 (void *)&cmd_show_vf_stats_vf_id,
15272 /* clear vf stats */
15274 /* Common result structure for clear vf stats */
15275 struct cmd_clear_vf_stats_result {
15276 cmdline_fixed_string_t clear;
15277 cmdline_fixed_string_t vf;
15278 cmdline_fixed_string_t stats;
15283 /* Common CLI fields clear vf stats*/
15284 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15285 TOKEN_STRING_INITIALIZER
15286 (struct cmd_clear_vf_stats_result,
15288 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15289 TOKEN_STRING_INITIALIZER
15290 (struct cmd_clear_vf_stats_result,
15292 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15293 TOKEN_STRING_INITIALIZER
15294 (struct cmd_clear_vf_stats_result,
15296 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15297 TOKEN_NUM_INITIALIZER
15298 (struct cmd_clear_vf_stats_result,
15299 port_id, RTE_UINT16);
15300 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15301 TOKEN_NUM_INITIALIZER
15302 (struct cmd_clear_vf_stats_result,
15303 vf_id, RTE_UINT16);
15306 cmd_clear_vf_stats_parsed(
15307 void *parsed_result,
15308 __rte_unused struct cmdline *cl,
15309 __rte_unused void *data)
15311 struct cmd_clear_vf_stats_result *res = parsed_result;
15312 int ret = -ENOTSUP;
15314 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15317 #ifdef RTE_NET_I40E
15318 if (ret == -ENOTSUP)
15319 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15322 #ifdef RTE_NET_BNXT
15323 if (ret == -ENOTSUP)
15324 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15332 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15335 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15338 fprintf(stderr, "function not implemented\n");
15341 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15345 cmdline_parse_inst_t cmd_clear_vf_stats = {
15346 .f = cmd_clear_vf_stats_parsed,
15348 .help_str = "clear vf stats <port_id> <vf_id>",
15350 (void *)&cmd_clear_vf_stats_clear,
15351 (void *)&cmd_clear_vf_stats_vf,
15352 (void *)&cmd_clear_vf_stats_stats,
15353 (void *)&cmd_clear_vf_stats_port_id,
15354 (void *)&cmd_clear_vf_stats_vf_id,
15359 /* port config pctype mapping reset */
15361 /* Common result structure for port config pctype mapping reset */
15362 struct cmd_pctype_mapping_reset_result {
15363 cmdline_fixed_string_t port;
15364 cmdline_fixed_string_t config;
15366 cmdline_fixed_string_t pctype;
15367 cmdline_fixed_string_t mapping;
15368 cmdline_fixed_string_t reset;
15371 /* Common CLI fields for port config pctype mapping reset*/
15372 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15373 TOKEN_STRING_INITIALIZER
15374 (struct cmd_pctype_mapping_reset_result,
15376 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15377 TOKEN_STRING_INITIALIZER
15378 (struct cmd_pctype_mapping_reset_result,
15380 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15381 TOKEN_NUM_INITIALIZER
15382 (struct cmd_pctype_mapping_reset_result,
15383 port_id, RTE_UINT16);
15384 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15385 TOKEN_STRING_INITIALIZER
15386 (struct cmd_pctype_mapping_reset_result,
15388 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15389 TOKEN_STRING_INITIALIZER
15390 (struct cmd_pctype_mapping_reset_result,
15391 mapping, "mapping");
15392 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15393 TOKEN_STRING_INITIALIZER
15394 (struct cmd_pctype_mapping_reset_result,
15398 cmd_pctype_mapping_reset_parsed(
15399 void *parsed_result,
15400 __rte_unused struct cmdline *cl,
15401 __rte_unused void *data)
15403 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15404 int ret = -ENOTSUP;
15406 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15409 #ifdef RTE_NET_I40E
15410 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15417 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15420 fprintf(stderr, "function not implemented\n");
15423 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15427 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15428 .f = cmd_pctype_mapping_reset_parsed,
15430 .help_str = "port config <port_id> pctype mapping reset",
15432 (void *)&cmd_pctype_mapping_reset_port,
15433 (void *)&cmd_pctype_mapping_reset_config,
15434 (void *)&cmd_pctype_mapping_reset_port_id,
15435 (void *)&cmd_pctype_mapping_reset_pctype,
15436 (void *)&cmd_pctype_mapping_reset_mapping,
15437 (void *)&cmd_pctype_mapping_reset_reset,
15442 /* show port pctype mapping */
15444 /* Common result structure for show port pctype mapping */
15445 struct cmd_pctype_mapping_get_result {
15446 cmdline_fixed_string_t show;
15447 cmdline_fixed_string_t port;
15449 cmdline_fixed_string_t pctype;
15450 cmdline_fixed_string_t mapping;
15453 /* Common CLI fields for pctype mapping get */
15454 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15455 TOKEN_STRING_INITIALIZER
15456 (struct cmd_pctype_mapping_get_result,
15458 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15459 TOKEN_STRING_INITIALIZER
15460 (struct cmd_pctype_mapping_get_result,
15462 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15463 TOKEN_NUM_INITIALIZER
15464 (struct cmd_pctype_mapping_get_result,
15465 port_id, RTE_UINT16);
15466 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15467 TOKEN_STRING_INITIALIZER
15468 (struct cmd_pctype_mapping_get_result,
15470 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15471 TOKEN_STRING_INITIALIZER
15472 (struct cmd_pctype_mapping_get_result,
15473 mapping, "mapping");
15476 cmd_pctype_mapping_get_parsed(
15477 void *parsed_result,
15478 __rte_unused struct cmdline *cl,
15479 __rte_unused void *data)
15481 struct cmd_pctype_mapping_get_result *res = parsed_result;
15482 int ret = -ENOTSUP;
15483 #ifdef RTE_NET_I40E
15484 struct rte_pmd_i40e_flow_type_mapping
15485 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15486 int i, j, first_pctype;
15489 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15492 #ifdef RTE_NET_I40E
15493 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15500 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15503 fprintf(stderr, "function not implemented\n");
15506 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15510 #ifdef RTE_NET_I40E
15511 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15512 if (mapping[i].pctype != 0ULL) {
15515 printf("pctype: ");
15516 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15517 if (mapping[i].pctype & (1ULL << j)) {
15518 printf(first_pctype ?
15519 "%02d" : ",%02d", j);
15523 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15529 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15530 .f = cmd_pctype_mapping_get_parsed,
15532 .help_str = "show port <port_id> pctype mapping",
15534 (void *)&cmd_pctype_mapping_get_show,
15535 (void *)&cmd_pctype_mapping_get_port,
15536 (void *)&cmd_pctype_mapping_get_port_id,
15537 (void *)&cmd_pctype_mapping_get_pctype,
15538 (void *)&cmd_pctype_mapping_get_mapping,
15543 /* port config pctype mapping update */
15545 /* Common result structure for port config pctype mapping update */
15546 struct cmd_pctype_mapping_update_result {
15547 cmdline_fixed_string_t port;
15548 cmdline_fixed_string_t config;
15550 cmdline_fixed_string_t pctype;
15551 cmdline_fixed_string_t mapping;
15552 cmdline_fixed_string_t update;
15553 cmdline_fixed_string_t pctype_list;
15554 uint16_t flow_type;
15557 /* Common CLI fields for pctype mapping update*/
15558 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15559 TOKEN_STRING_INITIALIZER
15560 (struct cmd_pctype_mapping_update_result,
15562 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15563 TOKEN_STRING_INITIALIZER
15564 (struct cmd_pctype_mapping_update_result,
15566 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15567 TOKEN_NUM_INITIALIZER
15568 (struct cmd_pctype_mapping_update_result,
15569 port_id, RTE_UINT16);
15570 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15571 TOKEN_STRING_INITIALIZER
15572 (struct cmd_pctype_mapping_update_result,
15574 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15575 TOKEN_STRING_INITIALIZER
15576 (struct cmd_pctype_mapping_update_result,
15577 mapping, "mapping");
15578 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15579 TOKEN_STRING_INITIALIZER
15580 (struct cmd_pctype_mapping_update_result,
15582 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15583 TOKEN_STRING_INITIALIZER
15584 (struct cmd_pctype_mapping_update_result,
15585 pctype_list, NULL);
15586 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15587 TOKEN_NUM_INITIALIZER
15588 (struct cmd_pctype_mapping_update_result,
15589 flow_type, RTE_UINT16);
15592 cmd_pctype_mapping_update_parsed(
15593 void *parsed_result,
15594 __rte_unused struct cmdline *cl,
15595 __rte_unused void *data)
15597 struct cmd_pctype_mapping_update_result *res = parsed_result;
15598 int ret = -ENOTSUP;
15599 #ifdef RTE_NET_I40E
15600 struct rte_pmd_i40e_flow_type_mapping mapping;
15602 unsigned int nb_item;
15603 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15606 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15609 #ifdef RTE_NET_I40E
15610 nb_item = parse_item_list(res->pctype_list, "pctypes",
15611 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15612 mapping.flow_type = res->flow_type;
15613 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15614 mapping.pctype |= (1ULL << pctype_list[i]);
15615 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15625 fprintf(stderr, "invalid pctype or flow type\n");
15628 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15631 fprintf(stderr, "function not implemented\n");
15634 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15638 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15639 .f = cmd_pctype_mapping_update_parsed,
15641 .help_str = "port config <port_id> pctype mapping update"
15642 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15644 (void *)&cmd_pctype_mapping_update_port,
15645 (void *)&cmd_pctype_mapping_update_config,
15646 (void *)&cmd_pctype_mapping_update_port_id,
15647 (void *)&cmd_pctype_mapping_update_pctype,
15648 (void *)&cmd_pctype_mapping_update_mapping,
15649 (void *)&cmd_pctype_mapping_update_update,
15650 (void *)&cmd_pctype_mapping_update_pc_type,
15651 (void *)&cmd_pctype_mapping_update_flow_type,
15656 /* ptype mapping get */
15658 /* Common result structure for ptype mapping get */
15659 struct cmd_ptype_mapping_get_result {
15660 cmdline_fixed_string_t ptype;
15661 cmdline_fixed_string_t mapping;
15662 cmdline_fixed_string_t get;
15664 uint8_t valid_only;
15667 /* Common CLI fields for ptype mapping get */
15668 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15669 TOKEN_STRING_INITIALIZER
15670 (struct cmd_ptype_mapping_get_result,
15672 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15673 TOKEN_STRING_INITIALIZER
15674 (struct cmd_ptype_mapping_get_result,
15675 mapping, "mapping");
15676 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15677 TOKEN_STRING_INITIALIZER
15678 (struct cmd_ptype_mapping_get_result,
15680 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15681 TOKEN_NUM_INITIALIZER
15682 (struct cmd_ptype_mapping_get_result,
15683 port_id, RTE_UINT16);
15684 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15685 TOKEN_NUM_INITIALIZER
15686 (struct cmd_ptype_mapping_get_result,
15687 valid_only, RTE_UINT8);
15690 cmd_ptype_mapping_get_parsed(
15691 void *parsed_result,
15692 __rte_unused struct cmdline *cl,
15693 __rte_unused void *data)
15695 struct cmd_ptype_mapping_get_result *res = parsed_result;
15696 int ret = -ENOTSUP;
15697 #ifdef RTE_NET_I40E
15698 int max_ptype_num = 256;
15699 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15704 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15707 #ifdef RTE_NET_I40E
15708 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15719 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15722 fprintf(stderr, "function not implemented\n");
15725 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15728 #ifdef RTE_NET_I40E
15730 for (i = 0; i < count; i++)
15731 printf("%3d\t0x%08x\n",
15732 mapping[i].hw_ptype, mapping[i].sw_ptype);
15737 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15738 .f = cmd_ptype_mapping_get_parsed,
15740 .help_str = "ptype mapping get <port_id> <valid_only>",
15742 (void *)&cmd_ptype_mapping_get_ptype,
15743 (void *)&cmd_ptype_mapping_get_mapping,
15744 (void *)&cmd_ptype_mapping_get_get,
15745 (void *)&cmd_ptype_mapping_get_port_id,
15746 (void *)&cmd_ptype_mapping_get_valid_only,
15751 /* ptype mapping replace */
15753 /* Common result structure for ptype mapping replace */
15754 struct cmd_ptype_mapping_replace_result {
15755 cmdline_fixed_string_t ptype;
15756 cmdline_fixed_string_t mapping;
15757 cmdline_fixed_string_t replace;
15764 /* Common CLI fields for ptype mapping replace */
15765 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15766 TOKEN_STRING_INITIALIZER
15767 (struct cmd_ptype_mapping_replace_result,
15769 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15770 TOKEN_STRING_INITIALIZER
15771 (struct cmd_ptype_mapping_replace_result,
15772 mapping, "mapping");
15773 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15774 TOKEN_STRING_INITIALIZER
15775 (struct cmd_ptype_mapping_replace_result,
15776 replace, "replace");
15777 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15778 TOKEN_NUM_INITIALIZER
15779 (struct cmd_ptype_mapping_replace_result,
15780 port_id, RTE_UINT16);
15781 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15782 TOKEN_NUM_INITIALIZER
15783 (struct cmd_ptype_mapping_replace_result,
15784 target, RTE_UINT32);
15785 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15786 TOKEN_NUM_INITIALIZER
15787 (struct cmd_ptype_mapping_replace_result,
15789 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15790 TOKEN_NUM_INITIALIZER
15791 (struct cmd_ptype_mapping_replace_result,
15792 pkt_type, RTE_UINT32);
15795 cmd_ptype_mapping_replace_parsed(
15796 void *parsed_result,
15797 __rte_unused struct cmdline *cl,
15798 __rte_unused void *data)
15800 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15801 int ret = -ENOTSUP;
15803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15806 #ifdef RTE_NET_I40E
15807 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15817 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15818 res->target, res->pkt_type);
15821 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15824 fprintf(stderr, "function not implemented\n");
15827 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15831 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15832 .f = cmd_ptype_mapping_replace_parsed,
15835 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15837 (void *)&cmd_ptype_mapping_replace_ptype,
15838 (void *)&cmd_ptype_mapping_replace_mapping,
15839 (void *)&cmd_ptype_mapping_replace_replace,
15840 (void *)&cmd_ptype_mapping_replace_port_id,
15841 (void *)&cmd_ptype_mapping_replace_target,
15842 (void *)&cmd_ptype_mapping_replace_mask,
15843 (void *)&cmd_ptype_mapping_replace_pkt_type,
15848 /* ptype mapping reset */
15850 /* Common result structure for ptype mapping reset */
15851 struct cmd_ptype_mapping_reset_result {
15852 cmdline_fixed_string_t ptype;
15853 cmdline_fixed_string_t mapping;
15854 cmdline_fixed_string_t reset;
15858 /* Common CLI fields for ptype mapping reset*/
15859 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15860 TOKEN_STRING_INITIALIZER
15861 (struct cmd_ptype_mapping_reset_result,
15863 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15864 TOKEN_STRING_INITIALIZER
15865 (struct cmd_ptype_mapping_reset_result,
15866 mapping, "mapping");
15867 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15868 TOKEN_STRING_INITIALIZER
15869 (struct cmd_ptype_mapping_reset_result,
15871 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15872 TOKEN_NUM_INITIALIZER
15873 (struct cmd_ptype_mapping_reset_result,
15874 port_id, RTE_UINT16);
15877 cmd_ptype_mapping_reset_parsed(
15878 void *parsed_result,
15879 __rte_unused struct cmdline *cl,
15880 __rte_unused void *data)
15882 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15883 int ret = -ENOTSUP;
15885 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15888 #ifdef RTE_NET_I40E
15889 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15896 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15899 fprintf(stderr, "function not implemented\n");
15902 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15906 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15907 .f = cmd_ptype_mapping_reset_parsed,
15909 .help_str = "ptype mapping reset <port_id>",
15911 (void *)&cmd_ptype_mapping_reset_ptype,
15912 (void *)&cmd_ptype_mapping_reset_mapping,
15913 (void *)&cmd_ptype_mapping_reset_reset,
15914 (void *)&cmd_ptype_mapping_reset_port_id,
15919 /* ptype mapping update */
15921 /* Common result structure for ptype mapping update */
15922 struct cmd_ptype_mapping_update_result {
15923 cmdline_fixed_string_t ptype;
15924 cmdline_fixed_string_t mapping;
15925 cmdline_fixed_string_t reset;
15931 /* Common CLI fields for ptype mapping update*/
15932 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15933 TOKEN_STRING_INITIALIZER
15934 (struct cmd_ptype_mapping_update_result,
15936 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15937 TOKEN_STRING_INITIALIZER
15938 (struct cmd_ptype_mapping_update_result,
15939 mapping, "mapping");
15940 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15941 TOKEN_STRING_INITIALIZER
15942 (struct cmd_ptype_mapping_update_result,
15944 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15945 TOKEN_NUM_INITIALIZER
15946 (struct cmd_ptype_mapping_update_result,
15947 port_id, RTE_UINT16);
15948 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15949 TOKEN_NUM_INITIALIZER
15950 (struct cmd_ptype_mapping_update_result,
15951 hw_ptype, RTE_UINT8);
15952 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15953 TOKEN_NUM_INITIALIZER
15954 (struct cmd_ptype_mapping_update_result,
15955 sw_ptype, RTE_UINT32);
15958 cmd_ptype_mapping_update_parsed(
15959 void *parsed_result,
15960 __rte_unused struct cmdline *cl,
15961 __rte_unused void *data)
15963 struct cmd_ptype_mapping_update_result *res = parsed_result;
15964 int ret = -ENOTSUP;
15965 #ifdef RTE_NET_I40E
15966 struct rte_pmd_i40e_ptype_mapping mapping;
15968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15971 #ifdef RTE_NET_I40E
15972 mapping.hw_ptype = res->hw_ptype;
15973 mapping.sw_ptype = res->sw_ptype;
15974 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15984 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15987 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15990 fprintf(stderr, "function not implemented\n");
15993 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15997 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15998 .f = cmd_ptype_mapping_update_parsed,
16000 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16002 (void *)&cmd_ptype_mapping_update_ptype,
16003 (void *)&cmd_ptype_mapping_update_mapping,
16004 (void *)&cmd_ptype_mapping_update_update,
16005 (void *)&cmd_ptype_mapping_update_port_id,
16006 (void *)&cmd_ptype_mapping_update_hw_ptype,
16007 (void *)&cmd_ptype_mapping_update_sw_ptype,
16012 /* Common result structure for file commands */
16013 struct cmd_cmdfile_result {
16014 cmdline_fixed_string_t load;
16015 cmdline_fixed_string_t filename;
16018 /* Common CLI fields for file commands */
16019 cmdline_parse_token_string_t cmd_load_cmdfile =
16020 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16021 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16022 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16025 cmd_load_from_file_parsed(
16026 void *parsed_result,
16027 __rte_unused struct cmdline *cl,
16028 __rte_unused void *data)
16030 struct cmd_cmdfile_result *res = parsed_result;
16032 cmdline_read_from_file(res->filename);
16035 cmdline_parse_inst_t cmd_load_from_file = {
16036 .f = cmd_load_from_file_parsed,
16038 .help_str = "load <filename>",
16040 (void *)&cmd_load_cmdfile,
16041 (void *)&cmd_load_cmdfile_filename,
16046 /* Get Rx offloads capabilities */
16047 struct cmd_rx_offload_get_capa_result {
16048 cmdline_fixed_string_t show;
16049 cmdline_fixed_string_t port;
16051 cmdline_fixed_string_t rx_offload;
16052 cmdline_fixed_string_t capabilities;
16055 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16056 TOKEN_STRING_INITIALIZER
16057 (struct cmd_rx_offload_get_capa_result,
16059 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16060 TOKEN_STRING_INITIALIZER
16061 (struct cmd_rx_offload_get_capa_result,
16063 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16064 TOKEN_NUM_INITIALIZER
16065 (struct cmd_rx_offload_get_capa_result,
16066 port_id, RTE_UINT16);
16067 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16068 TOKEN_STRING_INITIALIZER
16069 (struct cmd_rx_offload_get_capa_result,
16070 rx_offload, "rx_offload");
16071 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16072 TOKEN_STRING_INITIALIZER
16073 (struct cmd_rx_offload_get_capa_result,
16074 capabilities, "capabilities");
16077 print_rx_offloads(uint64_t offloads)
16079 uint64_t single_offload;
16087 begin = __builtin_ctzll(offloads);
16088 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16090 single_offload = 1ULL << begin;
16091 for (bit = begin; bit < end; bit++) {
16092 if (offloads & single_offload)
16094 rte_eth_dev_rx_offload_name(single_offload));
16095 single_offload <<= 1;
16100 cmd_rx_offload_get_capa_parsed(
16101 void *parsed_result,
16102 __rte_unused struct cmdline *cl,
16103 __rte_unused void *data)
16105 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16106 struct rte_eth_dev_info dev_info;
16107 portid_t port_id = res->port_id;
16108 uint64_t queue_offloads;
16109 uint64_t port_offloads;
16112 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16116 queue_offloads = dev_info.rx_queue_offload_capa;
16117 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16119 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16120 printf(" Per Queue :");
16121 print_rx_offloads(queue_offloads);
16124 printf(" Per Port :");
16125 print_rx_offloads(port_offloads);
16129 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16130 .f = cmd_rx_offload_get_capa_parsed,
16132 .help_str = "show port <port_id> rx_offload capabilities",
16134 (void *)&cmd_rx_offload_get_capa_show,
16135 (void *)&cmd_rx_offload_get_capa_port,
16136 (void *)&cmd_rx_offload_get_capa_port_id,
16137 (void *)&cmd_rx_offload_get_capa_rx_offload,
16138 (void *)&cmd_rx_offload_get_capa_capabilities,
16143 /* Get Rx offloads configuration */
16144 struct cmd_rx_offload_get_configuration_result {
16145 cmdline_fixed_string_t show;
16146 cmdline_fixed_string_t port;
16148 cmdline_fixed_string_t rx_offload;
16149 cmdline_fixed_string_t configuration;
16152 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16153 TOKEN_STRING_INITIALIZER
16154 (struct cmd_rx_offload_get_configuration_result,
16156 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16157 TOKEN_STRING_INITIALIZER
16158 (struct cmd_rx_offload_get_configuration_result,
16160 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16161 TOKEN_NUM_INITIALIZER
16162 (struct cmd_rx_offload_get_configuration_result,
16163 port_id, RTE_UINT16);
16164 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16165 TOKEN_STRING_INITIALIZER
16166 (struct cmd_rx_offload_get_configuration_result,
16167 rx_offload, "rx_offload");
16168 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16169 TOKEN_STRING_INITIALIZER
16170 (struct cmd_rx_offload_get_configuration_result,
16171 configuration, "configuration");
16174 cmd_rx_offload_get_configuration_parsed(
16175 void *parsed_result,
16176 __rte_unused struct cmdline *cl,
16177 __rte_unused void *data)
16179 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16180 struct rte_eth_dev_info dev_info;
16181 portid_t port_id = res->port_id;
16182 struct rte_port *port = &ports[port_id];
16183 struct rte_eth_conf dev_conf;
16184 uint64_t port_offloads;
16185 uint64_t queue_offloads;
16186 uint16_t nb_rx_queues;
16190 printf("Rx Offloading Configuration of port %d :\n", port_id);
16192 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16196 port_offloads = dev_conf.rxmode.offloads;
16198 print_rx_offloads(port_offloads);
16201 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16205 nb_rx_queues = dev_info.nb_rx_queues;
16206 for (q = 0; q < nb_rx_queues; q++) {
16207 queue_offloads = port->rx_conf[q].offloads;
16208 printf(" Queue[%2d] :", q);
16209 print_rx_offloads(queue_offloads);
16215 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16216 .f = cmd_rx_offload_get_configuration_parsed,
16218 .help_str = "show port <port_id> rx_offload configuration",
16220 (void *)&cmd_rx_offload_get_configuration_show,
16221 (void *)&cmd_rx_offload_get_configuration_port,
16222 (void *)&cmd_rx_offload_get_configuration_port_id,
16223 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16224 (void *)&cmd_rx_offload_get_configuration_configuration,
16229 /* Enable/Disable a per port offloading */
16230 struct cmd_config_per_port_rx_offload_result {
16231 cmdline_fixed_string_t port;
16232 cmdline_fixed_string_t config;
16234 cmdline_fixed_string_t rx_offload;
16235 cmdline_fixed_string_t offload;
16236 cmdline_fixed_string_t on_off;
16239 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16240 TOKEN_STRING_INITIALIZER
16241 (struct cmd_config_per_port_rx_offload_result,
16243 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16244 TOKEN_STRING_INITIALIZER
16245 (struct cmd_config_per_port_rx_offload_result,
16247 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16248 TOKEN_NUM_INITIALIZER
16249 (struct cmd_config_per_port_rx_offload_result,
16250 port_id, RTE_UINT16);
16251 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16252 TOKEN_STRING_INITIALIZER
16253 (struct cmd_config_per_port_rx_offload_result,
16254 rx_offload, "rx_offload");
16255 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16256 TOKEN_STRING_INITIALIZER
16257 (struct cmd_config_per_port_rx_offload_result,
16258 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16259 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16260 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16261 "scatter#buffer_split#timestamp#security#"
16262 "keep_crc#rss_hash");
16263 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16264 TOKEN_STRING_INITIALIZER
16265 (struct cmd_config_per_port_rx_offload_result,
16269 search_rx_offload(const char *name)
16271 uint64_t single_offload;
16272 const char *single_name;
16276 single_offload = 1;
16277 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16278 single_name = rte_eth_dev_rx_offload_name(single_offload);
16279 if (!strcasecmp(single_name, name)) {
16283 single_offload <<= 1;
16287 return single_offload;
16293 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16294 __rte_unused struct cmdline *cl,
16295 __rte_unused void *data)
16297 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16298 portid_t port_id = res->port_id;
16299 struct rte_eth_dev_info dev_info;
16300 struct rte_port *port = &ports[port_id];
16301 uint64_t single_offload;
16302 uint16_t nb_rx_queues;
16306 if (port->port_status != RTE_PORT_STOPPED) {
16308 "Error: Can't config offload when Port %d is not stopped\n",
16313 single_offload = search_rx_offload(res->offload);
16314 if (single_offload == 0) {
16315 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16319 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16323 nb_rx_queues = dev_info.nb_rx_queues;
16324 if (!strcmp(res->on_off, "on")) {
16325 port->dev_conf.rxmode.offloads |= single_offload;
16326 for (q = 0; q < nb_rx_queues; q++)
16327 port->rx_conf[q].offloads |= single_offload;
16329 port->dev_conf.rxmode.offloads &= ~single_offload;
16330 for (q = 0; q < nb_rx_queues; q++)
16331 port->rx_conf[q].offloads &= ~single_offload;
16334 cmd_reconfig_device_queue(port_id, 1, 1);
16337 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16338 .f = cmd_config_per_port_rx_offload_parsed,
16340 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16341 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16342 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16343 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16344 "keep_crc|rss_hash on|off",
16346 (void *)&cmd_config_per_port_rx_offload_result_port,
16347 (void *)&cmd_config_per_port_rx_offload_result_config,
16348 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16349 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16350 (void *)&cmd_config_per_port_rx_offload_result_offload,
16351 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16356 /* Enable/Disable a per queue offloading */
16357 struct cmd_config_per_queue_rx_offload_result {
16358 cmdline_fixed_string_t port;
16360 cmdline_fixed_string_t rxq;
16362 cmdline_fixed_string_t rx_offload;
16363 cmdline_fixed_string_t offload;
16364 cmdline_fixed_string_t on_off;
16367 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16368 TOKEN_STRING_INITIALIZER
16369 (struct cmd_config_per_queue_rx_offload_result,
16371 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16372 TOKEN_NUM_INITIALIZER
16373 (struct cmd_config_per_queue_rx_offload_result,
16374 port_id, RTE_UINT16);
16375 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16376 TOKEN_STRING_INITIALIZER
16377 (struct cmd_config_per_queue_rx_offload_result,
16379 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16380 TOKEN_NUM_INITIALIZER
16381 (struct cmd_config_per_queue_rx_offload_result,
16382 queue_id, RTE_UINT16);
16383 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16384 TOKEN_STRING_INITIALIZER
16385 (struct cmd_config_per_queue_rx_offload_result,
16386 rx_offload, "rx_offload");
16387 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16388 TOKEN_STRING_INITIALIZER
16389 (struct cmd_config_per_queue_rx_offload_result,
16390 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16391 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16392 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16393 "scatter#buffer_split#timestamp#security#keep_crc");
16394 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16395 TOKEN_STRING_INITIALIZER
16396 (struct cmd_config_per_queue_rx_offload_result,
16400 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16401 __rte_unused struct cmdline *cl,
16402 __rte_unused void *data)
16404 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16405 struct rte_eth_dev_info dev_info;
16406 portid_t port_id = res->port_id;
16407 uint16_t queue_id = res->queue_id;
16408 struct rte_port *port = &ports[port_id];
16409 uint64_t single_offload;
16412 if (port->port_status != RTE_PORT_STOPPED) {
16414 "Error: Can't config offload when Port %d is not stopped\n",
16419 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16423 if (queue_id >= dev_info.nb_rx_queues) {
16425 "Error: input queue_id should be 0 ... %d\n",
16426 dev_info.nb_rx_queues - 1);
16430 single_offload = search_rx_offload(res->offload);
16431 if (single_offload == 0) {
16432 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16436 if (!strcmp(res->on_off, "on"))
16437 port->rx_conf[queue_id].offloads |= single_offload;
16439 port->rx_conf[queue_id].offloads &= ~single_offload;
16441 cmd_reconfig_device_queue(port_id, 1, 1);
16444 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16445 .f = cmd_config_per_queue_rx_offload_parsed,
16447 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16448 "vlan_strip|ipv4_cksum|"
16449 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16450 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16451 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16454 (void *)&cmd_config_per_queue_rx_offload_result_port,
16455 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16456 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16457 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16458 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16459 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16460 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16465 /* Get Tx offloads capabilities */
16466 struct cmd_tx_offload_get_capa_result {
16467 cmdline_fixed_string_t show;
16468 cmdline_fixed_string_t port;
16470 cmdline_fixed_string_t tx_offload;
16471 cmdline_fixed_string_t capabilities;
16474 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16475 TOKEN_STRING_INITIALIZER
16476 (struct cmd_tx_offload_get_capa_result,
16478 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16479 TOKEN_STRING_INITIALIZER
16480 (struct cmd_tx_offload_get_capa_result,
16482 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16483 TOKEN_NUM_INITIALIZER
16484 (struct cmd_tx_offload_get_capa_result,
16485 port_id, RTE_UINT16);
16486 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16487 TOKEN_STRING_INITIALIZER
16488 (struct cmd_tx_offload_get_capa_result,
16489 tx_offload, "tx_offload");
16490 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16491 TOKEN_STRING_INITIALIZER
16492 (struct cmd_tx_offload_get_capa_result,
16493 capabilities, "capabilities");
16496 print_tx_offloads(uint64_t offloads)
16498 uint64_t single_offload;
16506 begin = __builtin_ctzll(offloads);
16507 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16509 single_offload = 1ULL << begin;
16510 for (bit = begin; bit < end; bit++) {
16511 if (offloads & single_offload)
16513 rte_eth_dev_tx_offload_name(single_offload));
16514 single_offload <<= 1;
16519 cmd_tx_offload_get_capa_parsed(
16520 void *parsed_result,
16521 __rte_unused struct cmdline *cl,
16522 __rte_unused void *data)
16524 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16525 struct rte_eth_dev_info dev_info;
16526 portid_t port_id = res->port_id;
16527 uint64_t queue_offloads;
16528 uint64_t port_offloads;
16531 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16535 queue_offloads = dev_info.tx_queue_offload_capa;
16536 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16538 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16539 printf(" Per Queue :");
16540 print_tx_offloads(queue_offloads);
16543 printf(" Per Port :");
16544 print_tx_offloads(port_offloads);
16548 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16549 .f = cmd_tx_offload_get_capa_parsed,
16551 .help_str = "show port <port_id> tx_offload capabilities",
16553 (void *)&cmd_tx_offload_get_capa_show,
16554 (void *)&cmd_tx_offload_get_capa_port,
16555 (void *)&cmd_tx_offload_get_capa_port_id,
16556 (void *)&cmd_tx_offload_get_capa_tx_offload,
16557 (void *)&cmd_tx_offload_get_capa_capabilities,
16562 /* Get Tx offloads configuration */
16563 struct cmd_tx_offload_get_configuration_result {
16564 cmdline_fixed_string_t show;
16565 cmdline_fixed_string_t port;
16567 cmdline_fixed_string_t tx_offload;
16568 cmdline_fixed_string_t configuration;
16571 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16572 TOKEN_STRING_INITIALIZER
16573 (struct cmd_tx_offload_get_configuration_result,
16575 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16576 TOKEN_STRING_INITIALIZER
16577 (struct cmd_tx_offload_get_configuration_result,
16579 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16580 TOKEN_NUM_INITIALIZER
16581 (struct cmd_tx_offload_get_configuration_result,
16582 port_id, RTE_UINT16);
16583 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16584 TOKEN_STRING_INITIALIZER
16585 (struct cmd_tx_offload_get_configuration_result,
16586 tx_offload, "tx_offload");
16587 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16588 TOKEN_STRING_INITIALIZER
16589 (struct cmd_tx_offload_get_configuration_result,
16590 configuration, "configuration");
16593 cmd_tx_offload_get_configuration_parsed(
16594 void *parsed_result,
16595 __rte_unused struct cmdline *cl,
16596 __rte_unused void *data)
16598 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16599 struct rte_eth_dev_info dev_info;
16600 portid_t port_id = res->port_id;
16601 struct rte_port *port = &ports[port_id];
16602 struct rte_eth_conf dev_conf;
16603 uint64_t port_offloads;
16604 uint64_t queue_offloads;
16605 uint16_t nb_tx_queues;
16609 printf("Tx Offloading Configuration of port %d :\n", port_id);
16611 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16615 port_offloads = dev_conf.txmode.offloads;
16617 print_tx_offloads(port_offloads);
16620 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16624 nb_tx_queues = dev_info.nb_tx_queues;
16625 for (q = 0; q < nb_tx_queues; q++) {
16626 queue_offloads = port->tx_conf[q].offloads;
16627 printf(" Queue[%2d] :", q);
16628 print_tx_offloads(queue_offloads);
16634 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16635 .f = cmd_tx_offload_get_configuration_parsed,
16637 .help_str = "show port <port_id> tx_offload configuration",
16639 (void *)&cmd_tx_offload_get_configuration_show,
16640 (void *)&cmd_tx_offload_get_configuration_port,
16641 (void *)&cmd_tx_offload_get_configuration_port_id,
16642 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16643 (void *)&cmd_tx_offload_get_configuration_configuration,
16648 /* Enable/Disable a per port offloading */
16649 struct cmd_config_per_port_tx_offload_result {
16650 cmdline_fixed_string_t port;
16651 cmdline_fixed_string_t config;
16653 cmdline_fixed_string_t tx_offload;
16654 cmdline_fixed_string_t offload;
16655 cmdline_fixed_string_t on_off;
16658 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16659 TOKEN_STRING_INITIALIZER
16660 (struct cmd_config_per_port_tx_offload_result,
16662 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16663 TOKEN_STRING_INITIALIZER
16664 (struct cmd_config_per_port_tx_offload_result,
16666 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16667 TOKEN_NUM_INITIALIZER
16668 (struct cmd_config_per_port_tx_offload_result,
16669 port_id, RTE_UINT16);
16670 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16671 TOKEN_STRING_INITIALIZER
16672 (struct cmd_config_per_port_tx_offload_result,
16673 tx_offload, "tx_offload");
16674 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16675 TOKEN_STRING_INITIALIZER
16676 (struct cmd_config_per_port_tx_offload_result,
16677 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16678 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16679 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16680 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16681 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16682 "send_on_timestamp");
16683 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16684 TOKEN_STRING_INITIALIZER
16685 (struct cmd_config_per_port_tx_offload_result,
16689 search_tx_offload(const char *name)
16691 uint64_t single_offload;
16692 const char *single_name;
16696 single_offload = 1;
16697 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16698 single_name = rte_eth_dev_tx_offload_name(single_offload);
16699 if (single_name == NULL)
16701 if (!strcasecmp(single_name, name)) {
16704 } else if (!strcasecmp(single_name, "UNKNOWN"))
16706 single_offload <<= 1;
16710 return single_offload;
16716 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16717 __rte_unused struct cmdline *cl,
16718 __rte_unused void *data)
16720 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16721 portid_t port_id = res->port_id;
16722 struct rte_eth_dev_info dev_info;
16723 struct rte_port *port = &ports[port_id];
16724 uint64_t single_offload;
16725 uint16_t nb_tx_queues;
16729 if (port->port_status != RTE_PORT_STOPPED) {
16731 "Error: Can't config offload when Port %d is not stopped\n",
16736 single_offload = search_tx_offload(res->offload);
16737 if (single_offload == 0) {
16738 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16742 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16746 nb_tx_queues = dev_info.nb_tx_queues;
16747 if (!strcmp(res->on_off, "on")) {
16748 port->dev_conf.txmode.offloads |= single_offload;
16749 for (q = 0; q < nb_tx_queues; q++)
16750 port->tx_conf[q].offloads |= single_offload;
16752 port->dev_conf.txmode.offloads &= ~single_offload;
16753 for (q = 0; q < nb_tx_queues; q++)
16754 port->tx_conf[q].offloads &= ~single_offload;
16757 cmd_reconfig_device_queue(port_id, 1, 1);
16760 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16761 .f = cmd_config_per_port_tx_offload_parsed,
16763 .help_str = "port config <port_id> tx_offload "
16764 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16765 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16766 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16767 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16768 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16769 "send_on_timestamp on|off",
16771 (void *)&cmd_config_per_port_tx_offload_result_port,
16772 (void *)&cmd_config_per_port_tx_offload_result_config,
16773 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16774 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16775 (void *)&cmd_config_per_port_tx_offload_result_offload,
16776 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16781 /* Enable/Disable a per queue offloading */
16782 struct cmd_config_per_queue_tx_offload_result {
16783 cmdline_fixed_string_t port;
16785 cmdline_fixed_string_t txq;
16787 cmdline_fixed_string_t tx_offload;
16788 cmdline_fixed_string_t offload;
16789 cmdline_fixed_string_t on_off;
16792 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16793 TOKEN_STRING_INITIALIZER
16794 (struct cmd_config_per_queue_tx_offload_result,
16796 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16797 TOKEN_NUM_INITIALIZER
16798 (struct cmd_config_per_queue_tx_offload_result,
16799 port_id, RTE_UINT16);
16800 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16801 TOKEN_STRING_INITIALIZER
16802 (struct cmd_config_per_queue_tx_offload_result,
16804 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16805 TOKEN_NUM_INITIALIZER
16806 (struct cmd_config_per_queue_tx_offload_result,
16807 queue_id, RTE_UINT16);
16808 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16809 TOKEN_STRING_INITIALIZER
16810 (struct cmd_config_per_queue_tx_offload_result,
16811 tx_offload, "tx_offload");
16812 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16813 TOKEN_STRING_INITIALIZER
16814 (struct cmd_config_per_queue_tx_offload_result,
16815 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16816 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16817 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16818 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16819 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16820 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16821 TOKEN_STRING_INITIALIZER
16822 (struct cmd_config_per_queue_tx_offload_result,
16826 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16827 __rte_unused struct cmdline *cl,
16828 __rte_unused void *data)
16830 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16831 struct rte_eth_dev_info dev_info;
16832 portid_t port_id = res->port_id;
16833 uint16_t queue_id = res->queue_id;
16834 struct rte_port *port = &ports[port_id];
16835 uint64_t single_offload;
16838 if (port->port_status != RTE_PORT_STOPPED) {
16840 "Error: Can't config offload when Port %d is not stopped\n",
16845 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16849 if (queue_id >= dev_info.nb_tx_queues) {
16851 "Error: input queue_id should be 0 ... %d\n",
16852 dev_info.nb_tx_queues - 1);
16856 single_offload = search_tx_offload(res->offload);
16857 if (single_offload == 0) {
16858 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16862 if (!strcmp(res->on_off, "on"))
16863 port->tx_conf[queue_id].offloads |= single_offload;
16865 port->tx_conf[queue_id].offloads &= ~single_offload;
16867 cmd_reconfig_device_queue(port_id, 1, 1);
16870 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16871 .f = cmd_config_per_queue_tx_offload_parsed,
16873 .help_str = "port <port_id> txq <queue_id> tx_offload "
16874 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16875 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16876 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16877 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16878 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16881 (void *)&cmd_config_per_queue_tx_offload_result_port,
16882 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16883 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16884 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16885 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16886 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16887 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16892 /* *** configure tx_metadata for specific port *** */
16893 struct cmd_config_tx_metadata_specific_result {
16894 cmdline_fixed_string_t port;
16895 cmdline_fixed_string_t keyword;
16897 cmdline_fixed_string_t item;
16902 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16903 __rte_unused struct cmdline *cl,
16904 __rte_unused void *data)
16906 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16908 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16910 ports[res->port_id].tx_metadata = res->value;
16911 /* Add/remove callback to insert valid metadata in every Tx packet. */
16912 if (ports[res->port_id].tx_metadata)
16913 add_tx_md_callback(res->port_id);
16915 remove_tx_md_callback(res->port_id);
16916 rte_flow_dynf_metadata_register();
16919 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16920 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16922 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16923 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16924 keyword, "config");
16925 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16926 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16927 port_id, RTE_UINT16);
16928 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16929 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16930 item, "tx_metadata");
16931 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16932 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16933 value, RTE_UINT32);
16935 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16936 .f = cmd_config_tx_metadata_specific_parsed,
16938 .help_str = "port config <port_id> tx_metadata <value>",
16940 (void *)&cmd_config_tx_metadata_specific_port,
16941 (void *)&cmd_config_tx_metadata_specific_keyword,
16942 (void *)&cmd_config_tx_metadata_specific_id,
16943 (void *)&cmd_config_tx_metadata_specific_item,
16944 (void *)&cmd_config_tx_metadata_specific_value,
16949 /* *** set dynf *** */
16950 struct cmd_config_tx_dynf_specific_result {
16951 cmdline_fixed_string_t port;
16952 cmdline_fixed_string_t keyword;
16954 cmdline_fixed_string_t item;
16955 cmdline_fixed_string_t name;
16956 cmdline_fixed_string_t value;
16960 cmd_config_dynf_specific_parsed(void *parsed_result,
16961 __rte_unused struct cmdline *cl,
16962 __rte_unused void *data)
16964 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16965 struct rte_mbuf_dynflag desc_flag;
16967 uint64_t old_port_flags;
16969 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16971 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16973 if (strlcpy(desc_flag.name, res->name,
16974 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16975 fprintf(stderr, "Flag name too long\n");
16978 desc_flag.flags = 0;
16979 flag = rte_mbuf_dynflag_register(&desc_flag);
16981 fprintf(stderr, "Can't register flag\n");
16984 strcpy(dynf_names[flag], desc_flag.name);
16986 old_port_flags = ports[res->port_id].mbuf_dynf;
16987 if (!strcmp(res->value, "set")) {
16988 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16989 if (old_port_flags == 0)
16990 add_tx_dynf_callback(res->port_id);
16992 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16993 if (ports[res->port_id].mbuf_dynf == 0)
16994 remove_tx_dynf_callback(res->port_id);
16998 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16999 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17001 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
17002 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17003 keyword, "config");
17004 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17005 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17006 port_id, RTE_UINT16);
17007 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17008 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17010 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17011 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17013 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17014 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17015 value, "set#clear");
17017 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17018 .f = cmd_config_dynf_specific_parsed,
17020 .help_str = "port config <port id> dynf <name> set|clear",
17022 (void *)&cmd_config_tx_dynf_specific_port,
17023 (void *)&cmd_config_tx_dynf_specific_keyword,
17024 (void *)&cmd_config_tx_dynf_specific_port_id,
17025 (void *)&cmd_config_tx_dynf_specific_item,
17026 (void *)&cmd_config_tx_dynf_specific_name,
17027 (void *)&cmd_config_tx_dynf_specific_value,
17032 /* *** display tx_metadata per port configuration *** */
17033 struct cmd_show_tx_metadata_result {
17034 cmdline_fixed_string_t cmd_show;
17035 cmdline_fixed_string_t cmd_port;
17036 cmdline_fixed_string_t cmd_keyword;
17041 cmd_show_tx_metadata_parsed(void *parsed_result,
17042 __rte_unused struct cmdline *cl,
17043 __rte_unused void *data)
17045 struct cmd_show_tx_metadata_result *res = parsed_result;
17047 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17048 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17051 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17052 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17053 ports[res->cmd_pid].tx_metadata);
17057 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17058 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17060 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17061 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17063 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17064 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17065 cmd_pid, RTE_UINT16);
17066 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17067 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17068 cmd_keyword, "tx_metadata");
17070 cmdline_parse_inst_t cmd_show_tx_metadata = {
17071 .f = cmd_show_tx_metadata_parsed,
17073 .help_str = "show port <port_id> tx_metadata",
17075 (void *)&cmd_show_tx_metadata_show,
17076 (void *)&cmd_show_tx_metadata_port,
17077 (void *)&cmd_show_tx_metadata_pid,
17078 (void *)&cmd_show_tx_metadata_keyword,
17083 /* *** show fec capability per port configuration *** */
17084 struct cmd_show_fec_capability_result {
17085 cmdline_fixed_string_t cmd_show;
17086 cmdline_fixed_string_t cmd_port;
17087 cmdline_fixed_string_t cmd_fec;
17088 cmdline_fixed_string_t cmd_keyword;
17093 cmd_show_fec_capability_parsed(void *parsed_result,
17094 __rte_unused struct cmdline *cl,
17095 __rte_unused void *data)
17097 struct cmd_show_fec_capability_result *res = parsed_result;
17098 struct rte_eth_fec_capa *speed_fec_capa;
17102 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17103 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17107 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
17108 if (ret == -ENOTSUP) {
17109 fprintf(stderr, "Function not implemented\n");
17111 } else if (ret < 0) {
17112 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
17116 num = (unsigned int)ret;
17117 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
17118 if (speed_fec_capa == NULL) {
17119 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
17123 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17125 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17129 show_fec_capability(num, speed_fec_capa);
17131 free(speed_fec_capa);
17134 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17135 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17137 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17138 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17140 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17141 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17142 cmd_pid, RTE_UINT16);
17143 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17144 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17146 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17147 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17148 cmd_keyword, "capabilities");
17150 cmdline_parse_inst_t cmd_show_capability = {
17151 .f = cmd_show_fec_capability_parsed,
17153 .help_str = "show port <port_id> fec capabilities",
17155 (void *)&cmd_show_fec_capability_show,
17156 (void *)&cmd_show_fec_capability_port,
17157 (void *)&cmd_show_fec_capability_pid,
17158 (void *)&cmd_show_fec_capability_fec,
17159 (void *)&cmd_show_fec_capability_keyword,
17164 /* *** show fec mode per port configuration *** */
17165 struct cmd_show_fec_metadata_result {
17166 cmdline_fixed_string_t cmd_show;
17167 cmdline_fixed_string_t cmd_port;
17168 cmdline_fixed_string_t cmd_keyword;
17173 cmd_show_fec_mode_parsed(void *parsed_result,
17174 __rte_unused struct cmdline *cl,
17175 __rte_unused void *data)
17177 #define FEC_NAME_SIZE 16
17178 struct cmd_show_fec_metadata_result *res = parsed_result;
17180 char buf[FEC_NAME_SIZE];
17183 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17184 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17187 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17188 if (ret == -ENOTSUP) {
17189 fprintf(stderr, "Function not implemented\n");
17191 } else if (ret < 0) {
17192 fprintf(stderr, "Get FEC mode failed\n");
17197 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17198 strlcpy(buf, "off", sizeof(buf));
17200 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17201 strlcpy(buf, "auto", sizeof(buf));
17203 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17204 strlcpy(buf, "baser", sizeof(buf));
17206 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17207 strlcpy(buf, "rs", sizeof(buf));
17213 printf("%s\n", buf);
17216 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17217 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17219 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17220 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17222 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17223 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17224 cmd_pid, RTE_UINT16);
17225 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17226 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17227 cmd_keyword, "fec_mode");
17229 cmdline_parse_inst_t cmd_show_fec_mode = {
17230 .f = cmd_show_fec_mode_parsed,
17232 .help_str = "show port <port_id> fec_mode",
17234 (void *)&cmd_show_fec_mode_show,
17235 (void *)&cmd_show_fec_mode_port,
17236 (void *)&cmd_show_fec_mode_pid,
17237 (void *)&cmd_show_fec_mode_keyword,
17242 /* *** set fec mode per port configuration *** */
17243 struct cmd_set_port_fec_mode {
17244 cmdline_fixed_string_t set;
17245 cmdline_fixed_string_t port;
17247 cmdline_fixed_string_t fec_mode;
17248 cmdline_fixed_string_t fec_value;
17251 /* Common CLI fields for set fec mode */
17252 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17253 TOKEN_STRING_INITIALIZER
17254 (struct cmd_set_port_fec_mode,
17256 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17257 TOKEN_STRING_INITIALIZER
17258 (struct cmd_set_port_fec_mode,
17260 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17261 TOKEN_NUM_INITIALIZER
17262 (struct cmd_set_port_fec_mode,
17263 port_id, RTE_UINT16);
17264 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17265 TOKEN_STRING_INITIALIZER
17266 (struct cmd_set_port_fec_mode,
17267 fec_mode, "fec_mode");
17268 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17269 TOKEN_STRING_INITIALIZER
17270 (struct cmd_set_port_fec_mode,
17274 cmd_set_port_fec_mode_parsed(
17275 void *parsed_result,
17276 __rte_unused struct cmdline *cl,
17277 __rte_unused void *data)
17279 struct cmd_set_port_fec_mode *res = parsed_result;
17280 uint16_t port_id = res->port_id;
17284 ret = parse_fec_mode(res->fec_value, &fec_capa);
17286 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17287 res->fec_value, port_id);
17291 ret = rte_eth_fec_set(port_id, fec_capa);
17292 if (ret == -ENOTSUP) {
17293 fprintf(stderr, "Function not implemented\n");
17295 } else if (ret < 0) {
17296 fprintf(stderr, "Set FEC mode failed\n");
17301 cmdline_parse_inst_t cmd_set_fec_mode = {
17302 .f = cmd_set_port_fec_mode_parsed,
17304 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17306 (void *)&cmd_set_port_fec_mode_set,
17307 (void *)&cmd_set_port_fec_mode_port,
17308 (void *)&cmd_set_port_fec_mode_port_id,
17309 (void *)&cmd_set_port_fec_mode_str,
17310 (void *)&cmd_set_port_fec_mode_value,
17315 /* show port supported ptypes */
17317 /* Common result structure for show port ptypes */
17318 struct cmd_show_port_supported_ptypes_result {
17319 cmdline_fixed_string_t show;
17320 cmdline_fixed_string_t port;
17322 cmdline_fixed_string_t ptypes;
17325 /* Common CLI fields for show port ptypes */
17326 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17327 TOKEN_STRING_INITIALIZER
17328 (struct cmd_show_port_supported_ptypes_result,
17330 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17331 TOKEN_STRING_INITIALIZER
17332 (struct cmd_show_port_supported_ptypes_result,
17334 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17335 TOKEN_NUM_INITIALIZER
17336 (struct cmd_show_port_supported_ptypes_result,
17337 port_id, RTE_UINT16);
17338 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17339 TOKEN_STRING_INITIALIZER
17340 (struct cmd_show_port_supported_ptypes_result,
17344 cmd_show_port_supported_ptypes_parsed(
17345 void *parsed_result,
17346 __rte_unused struct cmdline *cl,
17347 __rte_unused void *data)
17349 #define RSVD_PTYPE_MASK 0xf0000000
17350 #define MAX_PTYPES_PER_LAYER 16
17351 #define LTYPE_NAMESIZE 32
17352 #define PTYPE_NAMESIZE 256
17353 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17354 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17355 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17356 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17357 uint16_t port_id = res->port_id;
17360 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17364 while (ptype_mask != RSVD_PTYPE_MASK) {
17366 switch (ptype_mask) {
17367 case RTE_PTYPE_L2_MASK:
17368 strlcpy(ltype, "L2", sizeof(ltype));
17370 case RTE_PTYPE_L3_MASK:
17371 strlcpy(ltype, "L3", sizeof(ltype));
17373 case RTE_PTYPE_L4_MASK:
17374 strlcpy(ltype, "L4", sizeof(ltype));
17376 case RTE_PTYPE_TUNNEL_MASK:
17377 strlcpy(ltype, "Tunnel", sizeof(ltype));
17379 case RTE_PTYPE_INNER_L2_MASK:
17380 strlcpy(ltype, "Inner L2", sizeof(ltype));
17382 case RTE_PTYPE_INNER_L3_MASK:
17383 strlcpy(ltype, "Inner L3", sizeof(ltype));
17385 case RTE_PTYPE_INNER_L4_MASK:
17386 strlcpy(ltype, "Inner L4", sizeof(ltype));
17392 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17393 ptype_mask, ptypes,
17394 MAX_PTYPES_PER_LAYER);
17397 printf("Supported %s ptypes:\n", ltype);
17399 printf("%s ptypes unsupported\n", ltype);
17401 for (i = 0; i < ret; ++i) {
17402 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17403 printf("%s\n", buf);
17410 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17411 .f = cmd_show_port_supported_ptypes_parsed,
17413 .help_str = "show port <port_id> ptypes",
17415 (void *)&cmd_show_port_supported_ptypes_show,
17416 (void *)&cmd_show_port_supported_ptypes_port,
17417 (void *)&cmd_show_port_supported_ptypes_port_id,
17418 (void *)&cmd_show_port_supported_ptypes_ptypes,
17423 /* *** display rx/tx descriptor status *** */
17424 struct cmd_show_rx_tx_desc_status_result {
17425 cmdline_fixed_string_t cmd_show;
17426 cmdline_fixed_string_t cmd_port;
17427 cmdline_fixed_string_t cmd_keyword;
17428 cmdline_fixed_string_t cmd_desc;
17429 cmdline_fixed_string_t cmd_status;
17436 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17437 __rte_unused struct cmdline *cl,
17438 __rte_unused void *data)
17440 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17443 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17444 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17448 if (!strcmp(res->cmd_keyword, "rxq")) {
17449 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17453 "Invalid input: queue id = %d, desc id = %d\n",
17454 res->cmd_qid, res->cmd_did);
17457 if (rc == RTE_ETH_RX_DESC_AVAIL)
17458 printf("Desc status = AVAILABLE\n");
17459 else if (rc == RTE_ETH_RX_DESC_DONE)
17460 printf("Desc status = DONE\n");
17462 printf("Desc status = UNAVAILABLE\n");
17463 } else if (!strcmp(res->cmd_keyword, "txq")) {
17464 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17468 "Invalid input: queue id = %d, desc id = %d\n",
17469 res->cmd_qid, res->cmd_did);
17472 if (rc == RTE_ETH_TX_DESC_FULL)
17473 printf("Desc status = FULL\n");
17474 else if (rc == RTE_ETH_TX_DESC_DONE)
17475 printf("Desc status = DONE\n");
17477 printf("Desc status = UNAVAILABLE\n");
17481 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17482 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17484 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17485 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17487 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17488 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17489 cmd_pid, RTE_UINT16);
17490 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17491 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17492 cmd_keyword, "rxq#txq");
17493 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17494 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17495 cmd_qid, RTE_UINT16);
17496 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17497 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17499 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17500 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17501 cmd_did, RTE_UINT16);
17502 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17503 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17504 cmd_status, "status");
17505 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17506 .f = cmd_show_rx_tx_desc_status_parsed,
17508 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17511 (void *)&cmd_show_rx_tx_desc_status_show,
17512 (void *)&cmd_show_rx_tx_desc_status_port,
17513 (void *)&cmd_show_rx_tx_desc_status_pid,
17514 (void *)&cmd_show_rx_tx_desc_status_keyword,
17515 (void *)&cmd_show_rx_tx_desc_status_qid,
17516 (void *)&cmd_show_rx_tx_desc_status_desc,
17517 (void *)&cmd_show_rx_tx_desc_status_did,
17518 (void *)&cmd_show_rx_tx_desc_status_status,
17523 /* *** display rx queue desc used count *** */
17524 struct cmd_show_rx_queue_desc_used_count_result {
17525 cmdline_fixed_string_t cmd_show;
17526 cmdline_fixed_string_t cmd_port;
17527 cmdline_fixed_string_t cmd_rxq;
17528 cmdline_fixed_string_t cmd_desc;
17529 cmdline_fixed_string_t cmd_used;
17530 cmdline_fixed_string_t cmd_count;
17536 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17537 __rte_unused struct cmdline *cl,
17538 __rte_unused void *data)
17540 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17543 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17544 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17548 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17550 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17553 printf("Used desc count = %d\n", rc);
17556 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17557 TOKEN_STRING_INITIALIZER
17558 (struct cmd_show_rx_queue_desc_used_count_result,
17560 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17561 TOKEN_STRING_INITIALIZER
17562 (struct cmd_show_rx_queue_desc_used_count_result,
17564 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17565 TOKEN_NUM_INITIALIZER
17566 (struct cmd_show_rx_queue_desc_used_count_result,
17567 cmd_pid, RTE_UINT16);
17568 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17569 TOKEN_STRING_INITIALIZER
17570 (struct cmd_show_rx_queue_desc_used_count_result,
17572 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17573 TOKEN_NUM_INITIALIZER
17574 (struct cmd_show_rx_queue_desc_used_count_result,
17575 cmd_qid, RTE_UINT16);
17576 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17577 TOKEN_STRING_INITIALIZER
17578 (struct cmd_show_rx_queue_desc_used_count_result,
17579 cmd_count, "desc");
17580 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17581 TOKEN_STRING_INITIALIZER
17582 (struct cmd_show_rx_queue_desc_used_count_result,
17583 cmd_count, "used");
17584 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17585 TOKEN_STRING_INITIALIZER
17586 (struct cmd_show_rx_queue_desc_used_count_result,
17587 cmd_count, "count");
17588 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17589 .f = cmd_show_rx_queue_desc_used_count_parsed,
17591 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17593 (void *)&cmd_show_rx_queue_desc_used_count_show,
17594 (void *)&cmd_show_rx_queue_desc_used_count_port,
17595 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17596 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17597 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17598 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17599 (void *)&cmd_show_rx_queue_desc_used_count_used,
17600 (void *)&cmd_show_rx_queue_desc_used_count_count,
17605 /* Common result structure for set port ptypes */
17606 struct cmd_set_port_ptypes_result {
17607 cmdline_fixed_string_t set;
17608 cmdline_fixed_string_t port;
17610 cmdline_fixed_string_t ptype_mask;
17614 /* Common CLI fields for set port ptypes */
17615 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17616 TOKEN_STRING_INITIALIZER
17617 (struct cmd_set_port_ptypes_result,
17619 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17620 TOKEN_STRING_INITIALIZER
17621 (struct cmd_set_port_ptypes_result,
17623 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17624 TOKEN_NUM_INITIALIZER
17625 (struct cmd_set_port_ptypes_result,
17626 port_id, RTE_UINT16);
17627 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17628 TOKEN_STRING_INITIALIZER
17629 (struct cmd_set_port_ptypes_result,
17630 ptype_mask, "ptype_mask");
17631 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17632 TOKEN_NUM_INITIALIZER
17633 (struct cmd_set_port_ptypes_result,
17637 cmd_set_port_ptypes_parsed(
17638 void *parsed_result,
17639 __rte_unused struct cmdline *cl,
17640 __rte_unused void *data)
17642 struct cmd_set_port_ptypes_result *res = parsed_result;
17643 #define PTYPE_NAMESIZE 256
17644 char ptype_name[PTYPE_NAMESIZE];
17645 uint16_t port_id = res->port_id;
17646 uint32_t ptype_mask = res->mask;
17649 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17652 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17657 uint32_t ptypes[ret];
17659 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17661 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17666 printf("Successfully set following ptypes for Port %d\n", port_id);
17667 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17668 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17669 printf("%s\n", ptype_name);
17672 clear_ptypes = false;
17675 cmdline_parse_inst_t cmd_set_port_ptypes = {
17676 .f = cmd_set_port_ptypes_parsed,
17678 .help_str = "set port <port_id> ptype_mask <mask>",
17680 (void *)&cmd_set_port_ptypes_set,
17681 (void *)&cmd_set_port_ptypes_port,
17682 (void *)&cmd_set_port_ptypes_port_id,
17683 (void *)&cmd_set_port_ptypes_mask_str,
17684 (void *)&cmd_set_port_ptypes_mask_u32,
17689 /* *** display mac addresses added to a port *** */
17690 struct cmd_showport_macs_result {
17691 cmdline_fixed_string_t cmd_show;
17692 cmdline_fixed_string_t cmd_port;
17693 cmdline_fixed_string_t cmd_keyword;
17698 cmd_showport_macs_parsed(void *parsed_result,
17699 __rte_unused struct cmdline *cl,
17700 __rte_unused void *data)
17702 struct cmd_showport_macs_result *res = parsed_result;
17704 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17707 if (!strcmp(res->cmd_keyword, "macs"))
17708 show_macs(res->cmd_pid);
17709 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17710 show_mcast_macs(res->cmd_pid);
17713 cmdline_parse_token_string_t cmd_showport_macs_show =
17714 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17716 cmdline_parse_token_string_t cmd_showport_macs_port =
17717 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17719 cmdline_parse_token_num_t cmd_showport_macs_pid =
17720 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17721 cmd_pid, RTE_UINT16);
17722 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17723 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17724 cmd_keyword, "macs#mcast_macs");
17726 cmdline_parse_inst_t cmd_showport_macs = {
17727 .f = cmd_showport_macs_parsed,
17729 .help_str = "show port <port_id> macs|mcast_macs",
17731 (void *)&cmd_showport_macs_show,
17732 (void *)&cmd_showport_macs_port,
17733 (void *)&cmd_showport_macs_pid,
17734 (void *)&cmd_showport_macs_keyword,
17739 /* *** show flow transfer proxy port ID for the given port *** */
17740 struct cmd_show_port_flow_transfer_proxy_result {
17741 cmdline_fixed_string_t show;
17742 cmdline_fixed_string_t port;
17744 cmdline_fixed_string_t flow;
17745 cmdline_fixed_string_t transfer;
17746 cmdline_fixed_string_t proxy;
17749 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17750 TOKEN_STRING_INITIALIZER
17751 (struct cmd_show_port_flow_transfer_proxy_result,
17753 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17754 TOKEN_STRING_INITIALIZER
17755 (struct cmd_show_port_flow_transfer_proxy_result,
17757 cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17758 TOKEN_NUM_INITIALIZER
17759 (struct cmd_show_port_flow_transfer_proxy_result,
17760 port_id, RTE_UINT16);
17761 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17762 TOKEN_STRING_INITIALIZER
17763 (struct cmd_show_port_flow_transfer_proxy_result,
17765 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17766 TOKEN_STRING_INITIALIZER
17767 (struct cmd_show_port_flow_transfer_proxy_result,
17768 transfer, "transfer");
17769 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17770 TOKEN_STRING_INITIALIZER
17771 (struct cmd_show_port_flow_transfer_proxy_result,
17775 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17776 __rte_unused struct cmdline *cl,
17777 __rte_unused void *data)
17779 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17780 portid_t proxy_port_id;
17785 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17787 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17788 rte_strerror(-ret));
17792 printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17795 cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17796 .f = cmd_show_port_flow_transfer_proxy_parsed,
17798 .help_str = "show port <port_id> flow transfer proxy",
17800 (void *)&cmd_show_port_flow_transfer_proxy_show,
17801 (void *)&cmd_show_port_flow_transfer_proxy_port,
17802 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
17803 (void *)&cmd_show_port_flow_transfer_proxy_flow,
17804 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
17805 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
17810 /* ******************************************************************************** */
17812 /* list of instructions */
17813 cmdline_parse_ctx_t main_ctx[] = {
17814 (cmdline_parse_inst_t *)&cmd_help_brief,
17815 (cmdline_parse_inst_t *)&cmd_help_long,
17816 (cmdline_parse_inst_t *)&cmd_quit,
17817 (cmdline_parse_inst_t *)&cmd_load_from_file,
17818 (cmdline_parse_inst_t *)&cmd_showport,
17819 (cmdline_parse_inst_t *)&cmd_showqueue,
17820 (cmdline_parse_inst_t *)&cmd_showeeprom,
17821 (cmdline_parse_inst_t *)&cmd_showportall,
17822 (cmdline_parse_inst_t *)&cmd_representor_info,
17823 (cmdline_parse_inst_t *)&cmd_showdevice,
17824 (cmdline_parse_inst_t *)&cmd_showcfg,
17825 (cmdline_parse_inst_t *)&cmd_showfwdall,
17826 (cmdline_parse_inst_t *)&cmd_start,
17827 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17828 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17829 (cmdline_parse_inst_t *)&cmd_set_link_up,
17830 (cmdline_parse_inst_t *)&cmd_set_link_down,
17831 (cmdline_parse_inst_t *)&cmd_reset,
17832 (cmdline_parse_inst_t *)&cmd_set_numbers,
17833 (cmdline_parse_inst_t *)&cmd_set_log,
17834 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17835 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17836 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17837 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17838 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17839 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17840 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17841 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17842 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17843 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17844 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17845 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17846 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17847 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17848 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17849 (cmdline_parse_inst_t *)&cmd_set_link_check,
17850 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17851 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17852 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17853 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17854 #ifdef RTE_NET_BOND
17855 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17856 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17857 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17858 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17859 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17860 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17861 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17862 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17863 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17864 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17865 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17866 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17868 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17869 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17870 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17871 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17872 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17873 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17874 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17875 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17876 (cmdline_parse_inst_t *)&cmd_csum_set,
17877 (cmdline_parse_inst_t *)&cmd_csum_show,
17878 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17879 (cmdline_parse_inst_t *)&cmd_tso_set,
17880 (cmdline_parse_inst_t *)&cmd_tso_show,
17881 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17882 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17884 (cmdline_parse_inst_t *)&cmd_gro_enable,
17885 (cmdline_parse_inst_t *)&cmd_gro_flush,
17886 (cmdline_parse_inst_t *)&cmd_gro_show,
17889 (cmdline_parse_inst_t *)&cmd_gso_enable,
17890 (cmdline_parse_inst_t *)&cmd_gso_size,
17891 (cmdline_parse_inst_t *)&cmd_gso_show,
17893 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17894 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17895 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17896 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17897 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17898 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17899 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17900 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17901 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17902 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17903 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17904 (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
17905 (cmdline_parse_inst_t *)&cmd_config_dcb,
17906 (cmdline_parse_inst_t *)&cmd_read_reg,
17907 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17908 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17909 (cmdline_parse_inst_t *)&cmd_write_reg,
17910 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17911 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17912 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17913 (cmdline_parse_inst_t *)&cmd_stop,
17914 (cmdline_parse_inst_t *)&cmd_mac_addr,
17915 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17916 (cmdline_parse_inst_t *)&cmd_set_qmap,
17917 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17918 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17919 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17920 (cmdline_parse_inst_t *)&cmd_operate_port,
17921 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17922 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17923 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17924 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17925 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17926 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17927 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17928 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17929 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17930 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17931 (cmdline_parse_inst_t *)&cmd_config_mtu,
17932 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17933 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17934 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17935 (cmdline_parse_inst_t *)&cmd_config_rss,
17936 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17937 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17938 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17939 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17940 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17941 (cmdline_parse_inst_t *)&cmd_showport_reta,
17942 (cmdline_parse_inst_t *)&cmd_showport_macs,
17943 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17944 (cmdline_parse_inst_t *)&cmd_config_burst,
17945 (cmdline_parse_inst_t *)&cmd_config_thresh,
17946 (cmdline_parse_inst_t *)&cmd_config_threshold,
17947 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17948 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17949 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17950 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17951 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17952 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17953 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17954 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17955 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17956 (cmdline_parse_inst_t *)&cmd_dump,
17957 (cmdline_parse_inst_t *)&cmd_dump_one,
17958 #ifdef RTE_NET_I40E
17959 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17961 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17962 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17963 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17964 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17965 (cmdline_parse_inst_t *)&cmd_flow,
17966 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17967 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17968 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17969 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17970 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17971 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17972 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17973 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17974 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17975 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17976 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17977 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17978 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17979 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17980 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17981 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17982 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17983 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17984 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17985 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17986 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17987 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17988 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17989 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17990 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17991 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17992 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17993 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17994 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17995 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17996 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17997 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17998 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17999 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18000 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18001 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18002 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18003 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18004 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18005 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18006 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18007 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18008 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18009 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18010 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18011 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18012 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18013 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18014 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18015 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18016 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18017 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18018 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18019 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18020 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18021 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18022 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
18023 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
18024 (cmdline_parse_inst_t *)&cmd_ddp_add,
18025 (cmdline_parse_inst_t *)&cmd_ddp_del,
18026 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18027 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18028 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18029 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18030 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18031 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18032 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18033 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18034 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18035 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18036 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18037 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18039 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18040 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18041 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18042 (cmdline_parse_inst_t *)&cmd_queue_region,
18043 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18044 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18045 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18046 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18047 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18048 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18049 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18050 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18051 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18052 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18053 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18054 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18055 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18056 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18057 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18058 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18059 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18060 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18061 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18062 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18063 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18064 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18065 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18066 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18067 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18068 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18069 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18070 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18071 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18072 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18073 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18074 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18075 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18076 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18077 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18078 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18080 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18081 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18083 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18084 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18085 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18086 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
18087 (cmdline_parse_inst_t *)&cmd_set_raw,
18088 (cmdline_parse_inst_t *)&cmd_show_set_raw,
18089 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18090 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18091 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
18092 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
18093 (cmdline_parse_inst_t *)&cmd_show_capability,
18094 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
18095 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
18099 /* read cmdline commands from file */
18101 cmdline_read_from_file(const char *filename)
18103 struct cmdline *cl;
18105 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18108 "Failed to create file based cmdline context: %s\n",
18113 cmdline_interact(cl);
18118 printf("Read CLI commands from %s\n", filename);
18121 /* prompt function, called from main on MAIN lcore */
18126 /* initialize non-constant commands */
18127 cmd_set_fwd_mode_init();
18128 cmd_set_fwd_retry_mode_init();
18130 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18131 if (testpmd_cl == NULL)
18134 ret = atexit(prompt_exit);
18136 fprintf(stderr, "Cannot set exit function for cmdline\n");
18138 cmdline_interact(testpmd_cl);
18140 cmdline_stdin_exit(testpmd_cl);
18146 if (testpmd_cl != NULL) {
18147 cmdline_quit(testpmd_cl);
18148 cmdline_stdin_exit(testpmd_cl);
18153 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18155 if (id == (portid_t)RTE_PORT_ALL) {
18158 RTE_ETH_FOREACH_DEV(pid) {
18159 /* check if need_reconfig has been set to 1 */
18160 if (ports[pid].need_reconfig == 0)
18161 ports[pid].need_reconfig = dev;
18162 /* check if need_reconfig_queues has been set to 1 */
18163 if (ports[pid].need_reconfig_queues == 0)
18164 ports[pid].need_reconfig_queues = queue;
18166 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18167 /* check if need_reconfig has been set to 1 */
18168 if (ports[id].need_reconfig == 0)
18169 ports[id].need_reconfig = dev;
18170 /* check if need_reconfig_queues has been set to 1 */
18171 if (ports[id].need_reconfig_queues == 0)
18172 ports[id].need_reconfig_queues = queue;