1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
13 #include <sys/queue.h>
15 #include <rte_common.h>
16 #include <rte_byteorder.h>
18 #include <rte_debug.h>
19 #include <rte_cycles.h>
20 #include <rte_memory.h>
21 #include <rte_memzone.h>
22 #include <rte_malloc.h>
23 #include <rte_launch.h>
25 #include <rte_per_lcore.h>
26 #include <rte_lcore.h>
27 #include <rte_branch_prediction.h>
29 #include <rte_mempool.h>
30 #include <rte_interrupts.h>
32 #include <rte_ether.h>
33 #include <rte_ethdev.h>
34 #include <rte_string_fns.h>
35 #include <rte_devargs.h>
40 #include <rte_mbuf_dyn.h>
42 #include <cmdline_rdline.h>
43 #include <cmdline_parse.h>
44 #include <cmdline_parse_num.h>
45 #include <cmdline_parse_string.h>
46 #include <cmdline_parse_ipaddr.h>
47 #include <cmdline_parse_etheraddr.h>
48 #include <cmdline_socket.h>
51 #include <rte_eth_bond.h>
52 #include <rte_eth_bond_8023ad.h>
54 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
55 #include <rte_pmd_dpaa.h>
58 #include <rte_pmd_ixgbe.h>
61 #include <rte_pmd_i40e.h>
64 #include <rte_pmd_bnxt.h>
67 #include "cmdline_mtr.h"
68 #include "cmdline_tm.h"
71 static struct cmdline *testpmd_cl;
73 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
75 /* *** Help command with introduction. *** */
76 struct cmd_help_brief_result {
77 cmdline_fixed_string_t help;
80 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
82 __rte_unused void *data)
87 "Help is available for the following sections:\n\n"
88 " help control : Start and stop forwarding.\n"
89 " help display : Displaying port, stats and config "
91 " help config : Configuration information.\n"
92 " help ports : Configuring ports.\n"
93 " help registers : Reading and setting port registers.\n"
94 " help filters : Filters configuration help.\n"
95 " help traffic_management : Traffic Management commands.\n"
96 " help devices : Device related cmds.\n"
97 " help all : All of the above sections.\n\n"
102 cmdline_parse_token_string_t cmd_help_brief_help =
103 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
105 cmdline_parse_inst_t cmd_help_brief = {
106 .f = cmd_help_brief_parsed,
108 .help_str = "help: Show help",
110 (void *)&cmd_help_brief_help,
115 /* *** Help command with help sections. *** */
116 struct cmd_help_long_result {
117 cmdline_fixed_string_t help;
118 cmdline_fixed_string_t section;
121 static void cmd_help_long_parsed(void *parsed_result,
123 __rte_unused void *data)
126 struct cmd_help_long_result *res = parsed_result;
128 if (!strcmp(res->section, "all"))
131 if (show_all || !strcmp(res->section, "control")) {
136 "Control forwarding:\n"
137 "-------------------\n\n"
140 " Start packet forwarding with current configuration.\n\n"
143 " Start packet forwarding with current config"
144 " after sending one burst of packets.\n\n"
147 " Stop packet forwarding, and display accumulated"
151 " Quit to prompt.\n\n"
155 if (show_all || !strcmp(res->section, "display")) {
163 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
164 " Display information for port_id, or all.\n\n"
166 "show port info (port_id) representor\n"
167 " Show supported representors for a specific port\n\n"
169 "show port port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) rxq (queue_id) desc used count\n"
250 " Show current number of filled receive"
251 " packet descriptors.\n\n"
253 "show port (port_id) macs|mcast_macs"
254 " Display list of mac addresses added to port.\n\n"
256 "show port (port_id) flow transfer proxy\n"
257 " Display proxy port to manage transfer flows\n\n"
259 "show port (port_id) fec capabilities"
260 " Show fec capabilities of a port.\n\n"
262 "show port (port_id) fec_mode"
263 " Show fec mode of a port.\n\n"
265 "show port (port_id) flow_ctrl"
266 " Show flow control info of a port.\n\n"
270 if (show_all || !strcmp(res->section, "config")) {
276 "Configuration changes only become active when"
277 " forwarding is started/restarted.\n\n"
280 " Reset forwarding to the default configuration.\n\n"
282 "set verbose (level)\n"
283 " Set the debug verbosity level X.\n\n"
285 "set log global|(type) (level)\n"
286 " Set the log level.\n\n"
289 " Set number of ports.\n\n"
292 " Set number of cores.\n\n"
294 "set coremask (mask)\n"
295 " Set the forwarding cores hexadecimal mask.\n\n"
297 "set portmask (mask)\n"
298 " Set the forwarding ports hexadecimal mask.\n\n"
301 " Set number of packets per burst.\n\n"
303 "set burst tx delay (microseconds) retry (num)\n"
304 " Set the transmit delay time and number of retries,"
305 " effective when retry is enabled.\n\n"
307 "set rxoffs (x[,y]*)\n"
308 " Set the offset of each packet segment on"
309 " receiving if split feature is engaged."
310 " Affects only the queues configured with split"
313 "set rxpkts (x[,y]*)\n"
314 " Set the length of each segment to scatter"
315 " packets on receiving if split feature is engaged."
316 " Affects only the queues configured with split"
319 "set txpkts (x[,y]*)\n"
320 " Set the length of each segment of TXONLY"
321 " and optionally CSUM packets.\n\n"
323 "set txsplit (off|on|rand)\n"
324 " Set the split policy for the TX packets."
325 " Right now only applicable for CSUM and TXONLY"
328 "set txtimes (x, y)\n"
329 " Set the scheduling on timestamps"
330 " timings for the TXONLY mode\n\n"
332 "set corelist (x[,y]*)\n"
333 " Set the list of forwarding cores.\n\n"
335 "set portlist (x[,y]*)\n"
336 " Set the list of forwarding ports.\n\n"
338 "set port setup on (iterator|event)\n"
339 " Select how attached port is retrieved for setup.\n\n"
341 "set tx loopback (port_id) (on|off)\n"
342 " Enable or disable tx loopback.\n\n"
344 "set all queues drop (port_id) (on|off)\n"
345 " Set drop enable bit for all queues.\n\n"
347 "set vf split drop (port_id) (vf_id) (on|off)\n"
348 " Set split drop enable bit for a VF from the PF.\n\n"
350 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
351 " Set MAC antispoof for a VF from the PF.\n\n"
353 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
354 " Enable MACsec offload.\n\n"
356 "set macsec offload (port_id) off\n"
357 " Disable MACsec offload.\n\n"
359 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
360 " Configure MACsec secure connection (SC).\n\n"
362 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
363 " Configure MACsec secure association (SA).\n\n"
365 "set vf broadcast (port_id) (vf_id) (on|off)\n"
366 " Set VF broadcast for a VF from the PF.\n\n"
368 "vlan set stripq (on|off) (port_id,queue_id)\n"
369 " Set the VLAN strip for a queue on a port.\n\n"
371 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
372 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
374 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
375 " Set VLAN insert for a VF from the PF.\n\n"
377 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
378 " Set VLAN antispoof for a VF from the PF.\n\n"
380 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
381 " Set VLAN tag for a VF from the PF.\n\n"
383 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
384 " Set a VF's max bandwidth(Mbps).\n\n"
386 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
387 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
389 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
390 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
392 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
393 " Set some TCs' strict link priority mode on a physical port.\n\n"
395 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
396 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
398 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
399 " Set the VLAN strip or filter or qinq strip or extend\n\n"
401 "vlan set (inner|outer) tpid (value) (port_id)\n"
402 " Set the VLAN TPID for Packet Filtering on"
405 "rx_vlan add (vlan_id|all) (port_id)\n"
406 " Add a vlan_id, or all identifiers, to the set"
407 " of VLAN identifiers filtered by port_id.\n\n"
409 "rx_vlan rm (vlan_id|all) (port_id)\n"
410 " Remove a vlan_id, or all identifiers, from the set"
411 " of VLAN identifiers filtered by port_id.\n\n"
413 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
414 " Add a vlan_id, to the set of VLAN identifiers"
415 "filtered for VF(s) from port_id.\n\n"
417 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
418 " Remove a vlan_id, to the set of VLAN identifiers"
419 "filtered for VF(s) from port_id.\n\n"
421 "rx_vxlan_port add (udp_port) (port_id)\n"
422 " Add an UDP port for VXLAN packet filter on a port\n\n"
424 "rx_vxlan_port rm (udp_port) (port_id)\n"
425 " Remove an UDP port for VXLAN packet filter on a port\n\n"
427 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
428 " Set hardware insertion of VLAN IDs (single or double VLAN "
429 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
431 "tx_vlan set pvid port_id vlan_id (on|off)\n"
432 " Set port based TX VLAN insertion.\n\n"
434 "tx_vlan reset (port_id)\n"
435 " Disable hardware insertion of a VLAN header in"
436 " packets sent on a port.\n\n"
438 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
439 " Select hardware or software calculation of the"
440 " checksum when transmitting a packet using the"
441 " csum forward engine.\n"
442 " ip|udp|tcp|sctp always concern the inner layer.\n"
443 " outer-ip concerns the outer IP layer in"
444 " outer-udp concerns the outer UDP layer in"
445 " case the packet is recognized as a tunnel packet by"
446 " the forward engine (vxlan, gre and ipip are supported)\n"
447 " Please check the NIC datasheet for HW limits.\n\n"
449 "csum parse-tunnel (on|off) (tx_port_id)\n"
450 " If disabled, treat tunnel packets as non-tunneled"
451 " packets (treat inner headers as payload). The port\n"
452 " argument is the port used for TX in csum forward"
455 "csum show (port_id)\n"
456 " Display tx checksum offload configuration\n\n"
458 "tso set (segsize) (portid)\n"
459 " Enable TCP Segmentation Offload in csum forward"
461 " Please check the NIC datasheet for HW limits.\n\n"
464 " Display the status of TCP Segmentation Offload.\n\n"
467 "set port (port_id) gro on|off\n"
468 " Enable or disable Generic Receive Offload in"
469 " csum forwarding engine.\n\n"
471 "show port (port_id) gro\n"
472 " Display GRO configuration.\n\n"
474 "set gro flush (cycles)\n"
475 " Set the cycle to flush GROed packets from"
476 " reassembly tables.\n\n"
480 "set port (port_id) gso (on|off)"
481 " Enable or disable Generic Segmentation Offload in"
482 " csum forwarding engine.\n\n"
484 "set gso segsz (length)\n"
485 " Set max packet length for output GSO segments,"
486 " including packet header and payload.\n\n"
488 "show port (port_id) gso\n"
489 " Show GSO configuration.\n\n"
493 " Set packet forwarding mode.\n\n"
495 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
496 " Add a MAC address on port_id.\n\n"
498 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
499 " Remove a MAC address from port_id.\n\n"
501 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
502 " Set the default MAC address for port_id.\n\n"
504 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
505 " Add a MAC address for a VF on the port.\n\n"
507 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
508 " Set the MAC address for a VF from the PF.\n\n"
510 "set eth-peer (port_id) (peer_addr)\n"
511 " set the peer address for certain port.\n\n"
513 "set port (port_id) uta (mac_address|all) (on|off)\n"
514 " Add/Remove a or all unicast hash filter(s)"
517 "set promisc (port_id|all) (on|off)\n"
518 " Set the promiscuous mode on port_id, or all.\n\n"
520 "set allmulti (port_id|all) (on|off)\n"
521 " Set the allmulti mode on port_id, or all.\n\n"
523 "set vf promisc (port_id) (vf_id) (on|off)\n"
524 " Set unicast promiscuous mode for a VF from the PF.\n\n"
526 "set vf allmulti (port_id) (vf_id) (on|off)\n"
527 " Set multicast promiscuous mode for a VF from the PF.\n\n"
529 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
530 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
531 " (on|off) autoneg (on|off) (port_id)\n"
532 "set flow_ctrl rx (on|off) (portid)\n"
533 "set flow_ctrl tx (on|off) (portid)\n"
534 "set flow_ctrl high_water (high_water) (portid)\n"
535 "set flow_ctrl low_water (low_water) (portid)\n"
536 "set flow_ctrl pause_time (pause_time) (portid)\n"
537 "set flow_ctrl send_xon (send_xon) (portid)\n"
538 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
539 "set flow_ctrl autoneg (on|off) (port_id)\n"
540 " Set the link flow control parameter on a port.\n\n"
542 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
543 " (low_water) (pause_time) (priority) (port_id)\n"
544 " Set the priority flow control parameter on a"
547 "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
548 " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
549 " Set the queue priority flow control parameter on a"
550 " given Rx and Tx queues of a port.\n\n"
552 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
553 " Set statistics mapping (qmapping 0..15) for RX/TX"
555 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
556 " on port 0 to mapping 5.\n\n"
558 "set xstats-hide-zero on|off\n"
559 " Set the option to hide the zero values"
560 " for xstats display.\n"
562 "set record-core-cycles on|off\n"
563 " Set the option to enable measurement of CPU cycles.\n"
565 "set record-burst-stats on|off\n"
566 " Set the option to enable display of RX and TX bursts.\n"
568 "set port (port_id) vf (vf_id) rx|tx on|off\n"
569 " Enable/Disable a VF receive/transmit from a port\n\n"
571 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
573 " AUPE:accepts untagged VLAN;"
574 "ROPE:accept unicast hash\n\n"
575 " BAM:accepts broadcast packets;"
576 "MPE:accepts all multicast packets\n\n"
577 " Enable/Disable a VF receive mode of a port\n\n"
579 "set port (port_id) queue (queue_id) rate (rate_num)\n"
580 " Set rate limit for a queue of a port\n\n"
582 "set port (port_id) vf (vf_id) rate (rate_num) "
583 "queue_mask (queue_mask_value)\n"
584 " Set rate limit for queues in VF of a port\n\n"
586 "set flush_rx (on|off)\n"
587 " Flush (default) or don't flush RX streams before"
588 " forwarding. Mainly used with PCAP drivers.\n\n"
590 "set bypass mode (normal|bypass|isolate) (port_id)\n"
591 " Set the bypass mode for the lowest port on bypass enabled"
594 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
595 "mode (normal|bypass|isolate) (port_id)\n"
596 " Set the event required to initiate specified bypass mode for"
597 " the lowest port on a bypass enabled NIC where:\n"
598 " timeout = enable bypass after watchdog timeout.\n"
599 " os_on = enable bypass when OS/board is powered on.\n"
600 " os_off = enable bypass when OS/board is powered off.\n"
601 " power_on = enable bypass when power supply is turned on.\n"
602 " power_off = enable bypass when power supply is turned off."
605 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
606 " Set the bypass watchdog timeout to 'n' seconds"
607 " where 0 = instant.\n\n"
609 "show bypass config (port_id)\n"
610 " Show the bypass configuration for a bypass enabled NIC"
611 " using the lowest port on the NIC.\n\n"
614 "create bonded device (mode) (socket)\n"
615 " Create a new bonded device with specific bonding mode and socket.\n\n"
617 "add bonding slave (slave_id) (port_id)\n"
618 " Add a slave device to a bonded device.\n\n"
620 "remove bonding slave (slave_id) (port_id)\n"
621 " Remove a slave device from a bonded device.\n\n"
623 "set bonding mode (value) (port_id)\n"
624 " Set the bonding mode on a bonded device.\n\n"
626 "set bonding primary (slave_id) (port_id)\n"
627 " Set the primary slave for a bonded device.\n\n"
629 "show bonding config (port_id)\n"
630 " Show the bonding config for port_id.\n\n"
632 "show bonding lacp info (port_id)\n"
633 " Show the bonding lacp information for port_id.\n\n"
635 "set bonding mac_addr (port_id) (address)\n"
636 " Set the MAC address of a bonded device.\n\n"
638 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
639 " Set Aggregation mode for IEEE802.3AD (mode 4)"
641 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
642 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
644 "set bonding mon_period (port_id) (value)\n"
645 " Set the bonding link status monitoring polling period in ms.\n\n"
647 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
648 " Enable/disable dedicated queues for LACP control traffic.\n\n"
651 "set link-up port (port_id)\n"
652 " Set link up for a port.\n\n"
654 "set link-down port (port_id)\n"
655 " Set link down for a port.\n\n"
657 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
658 " Load a profile package on a port\n\n"
660 "ddp del (port_id) (backup_profile_path)\n"
661 " Delete a profile package from a port\n\n"
663 "ptype mapping get (port_id) (valid_only)\n"
664 " Get ptype mapping on a port\n\n"
666 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
667 " Replace target with the pkt_type in ptype mapping\n\n"
669 "ptype mapping reset (port_id)\n"
670 " Reset ptype mapping on a port\n\n"
672 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
673 " Update a ptype mapping item on a port\n\n"
675 "set port (port_id) ptype_mask (ptype_mask)\n"
676 " set packet types classification for a specific port\n\n"
678 "set port (port_id) queue-region region_id (value) "
679 "queue_start_index (value) queue_num (value)\n"
680 " Set a queue region on a port\n\n"
682 "set port (port_id) queue-region region_id (value) "
684 " Set a flowtype region index on a port\n\n"
686 "set port (port_id) queue-region UP (value) region_id (value)\n"
687 " Set the mapping of User Priority to "
688 "queue region on a port\n\n"
690 "set port (port_id) queue-region flush (on|off)\n"
691 " flush all queue region related configuration\n\n"
693 "show port meter cap (port_id)\n"
694 " Show port meter capability information\n\n"
696 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
697 " meter profile add - srtcm rfc 2697\n\n"
699 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
700 " meter profile add - trtcm rfc 2698\n\n"
702 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
703 " meter profile add - trtcm rfc 4115\n\n"
705 "del port meter profile (port_id) (profile_id)\n"
706 " meter profile delete\n\n"
708 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
709 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
710 "(dscp_tbl_entry63)]\n"
713 "enable port meter (port_id) (mtr_id)\n"
716 "disable port meter (port_id) (mtr_id)\n"
719 "del port meter (port_id) (mtr_id)\n"
722 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
723 "y_actions (actions) r_actions (actions)\n"
724 " meter policy add\n\n"
726 "del port meter policy (port_id) (policy_id)\n"
727 " meter policy delete\n\n"
729 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
730 " meter update meter profile\n\n"
732 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
733 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
734 " update meter dscp table entries\n\n"
736 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
737 "(action0) [(action1) (action2)]\n"
738 " meter update policer action\n\n"
740 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
741 " meter update stats\n\n"
743 "show port (port_id) queue-region\n"
744 " show all queue region related configuration info\n\n"
746 "set port (port_id) fec_mode auto|off|rs|baser\n"
747 " set fec mode for a specific port\n\n"
749 , list_pkt_forwarding_modes()
753 if (show_all || !strcmp(res->section, "ports")) {
759 "----------------\n\n"
761 "port start (port_id|all)\n"
762 " Start all ports or port_id.\n\n"
764 "port stop (port_id|all)\n"
765 " Stop all ports or port_id.\n\n"
767 "port close (port_id|all)\n"
768 " Close all ports or port_id.\n\n"
770 "port reset (port_id|all)\n"
771 " Reset all ports or port_id.\n\n"
773 "port attach (ident)\n"
774 " Attach physical or virtual dev by pci address or virtual device name\n\n"
776 "port detach (port_id)\n"
777 " Detach physical or virtual dev by port_id\n\n"
779 "port config (port_id|all)"
780 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
781 " duplex (half|full|auto)\n"
782 " Set speed and duplex for all ports or port_id\n\n"
784 "port config (port_id|all) loopback (mode)\n"
785 " Set loopback mode for all ports or port_id\n\n"
787 "port config all (rxq|txq|rxd|txd) (value)\n"
788 " Set number for rxq/txq/rxd/txd.\n\n"
790 "port config all max-pkt-len (value)\n"
791 " Set the max packet length.\n\n"
793 "port config all max-lro-pkt-size (value)\n"
794 " Set the max LRO aggregated packet size.\n\n"
796 "port config all drop-en (on|off)\n"
797 " Enable or disable packet drop on all RX queues of all ports when no "
798 "receive buffers available.\n\n"
800 "port config all rss (all|default|ip|tcp|udp|sctp|"
801 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|l2tpv2|"
802 "none|level-default|level-outer|level-inner|<flowtype_id>)\n"
803 " Set the RSS mode.\n\n"
805 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
806 " Set the RSS redirection table.\n\n"
808 "port config (port_id) dcb vt (on|off) (traffic_class)"
810 " Set the DCB mode.\n\n"
812 "port config all burst (value)\n"
813 " Set the number of packets per burst.\n\n"
815 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
817 " Set the ring prefetch/host/writeback threshold"
818 " for tx/rx queue.\n\n"
820 "port config all (txfreet|txrst|rxfreet) (value)\n"
821 " Set free threshold for rx/tx, or set"
822 " tx rs bit threshold.\n\n"
823 "port config mtu X value\n"
824 " Set the MTU of port X to a given value\n\n"
826 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
827 " Set a rx/tx queue's ring size configuration, the new"
828 " value will take effect after command that (re-)start the port"
829 " or command that setup the specific queue\n\n"
831 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
832 " Start/stop a rx/tx queue of port X. Only take effect"
833 " when port X is started\n\n"
835 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
836 " Switch on/off a deferred start of port X rx/tx queue. Only"
837 " take effect when port X is stopped.\n\n"
839 "port (port_id) (rxq|txq) (queue_id) setup\n"
840 " Setup a rx/tx queue of port X.\n\n"
842 "port config (port_id) pctype mapping reset\n"
843 " Reset flow type to pctype mapping on a port\n\n"
845 "port config (port_id) pctype mapping update"
846 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
847 " Update a flow type to pctype mapping item on a port\n\n"
849 "port config (port_id) pctype (pctype_id) hash_inset|"
850 "fdir_inset|fdir_flx_inset get|set|clear field\n"
852 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
854 "port config (port_id) pctype (pctype_id) hash_inset|"
855 "fdir_inset|fdir_flx_inset clear all"
856 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
858 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
859 " Add/remove UDP tunnel port for tunneling offload\n\n"
861 "port config <port_id> rx_offload vlan_strip|"
862 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
863 "outer_ipv4_cksum|macsec_strip|header_split|"
864 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
865 "buffer_split|timestamp|security|keep_crc on|off\n"
866 " Enable or disable a per port Rx offloading"
867 " on all Rx queues of a port\n\n"
869 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
870 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
871 "outer_ipv4_cksum|macsec_strip|header_split|"
872 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
873 "buffer_split|timestamp|security|keep_crc on|off\n"
874 " Enable or disable a per queue Rx offloading"
875 " only on a specific Rx queue\n\n"
877 "port config (port_id) tx_offload vlan_insert|"
878 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
879 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
880 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
881 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
883 " Enable or disable a per port Tx offloading"
884 " on all Tx queues of a port\n\n"
886 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
887 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
888 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
889 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
890 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
892 " Enable or disable a per queue Tx offloading"
893 " only on a specific Tx queue\n\n"
895 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
896 " Load an eBPF program as a callback"
897 " for particular RX/TX queue\n\n"
899 "bpf-unload rx|tx (port) (queue)\n"
900 " Unload previously loaded eBPF program"
901 " for particular RX/TX queue\n\n"
903 "port config (port_id) tx_metadata (value)\n"
904 " Set Tx metadata value per port. Testpmd will add this value"
905 " to any Tx packet sent from this port\n\n"
907 "port config (port_id) dynf (name) set|clear\n"
908 " Register a dynf and Set/clear this flag on Tx. "
909 "Testpmd will set this value to any Tx packet "
910 "sent from this port\n\n"
912 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
913 " Cleanup txq mbufs for a specific Tx queue\n\n"
917 if (show_all || !strcmp(res->section, "registers")) {
925 "read reg (port_id) (address)\n"
926 " Display value of a port register.\n\n"
928 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
929 " Display a port register bit field.\n\n"
931 "read regbit (port_id) (address) (bit_x)\n"
932 " Display a single port register bit.\n\n"
934 "write reg (port_id) (address) (value)\n"
935 " Set value of a port register.\n\n"
937 "write regfield (port_id) (address) (bit_x) (bit_y)"
939 " Set bit field of a port register.\n\n"
941 "write regbit (port_id) (address) (bit_x) (value)\n"
942 " Set single bit value of a port register.\n\n"
945 if (show_all || !strcmp(res->section, "filters")) {
954 "flow_director_filter (port_id) mode raw (add|del|update)"
955 " flow (flow_id) (drop|fwd) queue (queue_id)"
956 " fd_id (fd_id_value) packet (packet file name)\n"
957 " Add/Del a raw type flow director filter.\n\n"
960 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
961 " src_mask (ipv4_src) (ipv6_src) (src_port)"
962 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
963 " Set flow director IP mask.\n\n"
965 "flow_director_mask (port_id) mode MAC-VLAN"
966 " vlan (vlan_value)\n"
967 " Set flow director MAC-VLAN mask.\n\n"
969 "flow_director_mask (port_id) mode Tunnel"
970 " vlan (vlan_value) mac (mac_value)"
971 " tunnel-type (tunnel_type_value)"
972 " tunnel-id (tunnel_id_value)\n"
973 " Set flow director Tunnel mask.\n\n"
975 "flow_director_flex_payload (port_id)"
976 " (raw|l2|l3|l4) (config)\n"
977 " Configure flex payload selection.\n\n"
979 "flow validate {port_id}"
980 " [group {group_id}] [priority {level}]"
981 " [ingress] [egress]"
982 " pattern {item} [/ {item} [...]] / end"
983 " actions {action} [/ {action} [...]] / end\n"
984 " Check whether a flow rule can be created.\n\n"
986 "flow create {port_id}"
987 " [group {group_id}] [priority {level}]"
988 " [ingress] [egress]"
989 " pattern {item} [/ {item} [...]] / end"
990 " actions {action} [/ {action} [...]] / end\n"
991 " Create a flow rule.\n\n"
993 "flow destroy {port_id} rule {rule_id} [...]\n"
994 " Destroy specific flow rules.\n\n"
996 "flow flush {port_id}\n"
997 " Destroy all flow rules.\n\n"
999 "flow query {port_id} {rule_id} {action}\n"
1000 " Query an existing flow rule.\n\n"
1002 "flow list {port_id} [group {group_id}] [...]\n"
1003 " List existing flow rules sorted by priority,"
1004 " filtered by group identifiers.\n\n"
1006 "flow isolate {port_id} {boolean}\n"
1007 " Restrict ingress traffic to the defined"
1010 "flow aged {port_id} [destroy]\n"
1011 " List and destroy aged flows"
1014 "flow indirect_action {port_id} create"
1015 " [action_id {indirect_action_id}]"
1016 " [ingress] [egress]"
1017 " action {action} / end\n"
1018 " Create indirect action.\n\n"
1020 "flow indirect_action {port_id} update"
1021 " {indirect_action_id} action {action} / end\n"
1022 " Update indirect action.\n\n"
1024 "flow indirect_action {port_id} destroy"
1025 " action_id {indirect_action_id} [...]\n"
1026 " Destroy specific indirect actions.\n\n"
1028 "flow indirect_action {port_id} query"
1029 " {indirect_action_id}\n"
1030 " Query an existing indirect action.\n\n"
1032 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1033 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1034 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1035 " Configure the VXLAN encapsulation for flows.\n\n"
1037 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1038 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1039 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1040 " eth-dst (eth-dst)\n"
1041 " Configure the VXLAN encapsulation for flows.\n\n"
1043 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1044 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1045 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1046 " eth-dst (eth-dst)\n"
1047 " Configure the VXLAN encapsulation for flows.\n\n"
1049 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1050 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1052 " Configure the NVGRE encapsulation for flows.\n\n"
1054 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1055 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1056 " eth-src (eth-src) eth-dst (eth-dst)\n"
1057 " Configure the NVGRE encapsulation for flows.\n\n"
1059 "set raw_encap {flow items}\n"
1060 " Configure the encapsulation with raw data.\n\n"
1062 "set raw_decap {flow items}\n"
1063 " Configure the decapsulation with raw data.\n\n"
1068 if (show_all || !strcmp(res->section, "traffic_management")) {
1072 "Traffic Management:\n"
1074 "show port tm cap (port_id)\n"
1075 " Display the port TM capability.\n\n"
1077 "show port tm level cap (port_id) (level_id)\n"
1078 " Display the port TM hierarchical level capability.\n\n"
1080 "show port tm node cap (port_id) (node_id)\n"
1081 " Display the port TM node capability.\n\n"
1083 "show port tm node type (port_id) (node_id)\n"
1084 " Display the port TM node type.\n\n"
1086 "show port tm node stats (port_id) (node_id) (clear)\n"
1087 " Display the port TM node stats.\n\n"
1089 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1090 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1091 " (packet_length_adjust) (packet_mode)\n"
1092 " Add port tm node private shaper profile.\n\n"
1094 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1095 " Delete port tm node private shaper profile.\n\n"
1097 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1098 " (shaper_profile_id)\n"
1099 " Add/update port tm node shared shaper.\n\n"
1101 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1102 " Delete port tm node shared shaper.\n\n"
1104 "set port tm node shaper profile (port_id) (node_id)"
1105 " (shaper_profile_id)\n"
1106 " Set port tm node shaper profile.\n\n"
1108 "add port tm node wred profile (port_id) (wred_profile_id)"
1109 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1110 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1111 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1112 " Add port tm node wred profile.\n\n"
1114 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1115 " Delete port tm node wred profile.\n\n"
1117 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1118 " (priority) (weight) (level_id) (shaper_profile_id)"
1119 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1120 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1121 " Add port tm nonleaf node.\n\n"
1123 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1124 " (priority) (weight) (level_id) (shaper_profile_id)"
1125 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1126 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1127 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1129 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1130 " (priority) (weight) (level_id) (shaper_profile_id)"
1131 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1132 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1133 " Add port tm leaf node.\n\n"
1135 "del port tm node (port_id) (node_id)\n"
1136 " Delete port tm node.\n\n"
1138 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1139 " (priority) (weight)\n"
1140 " Set port tm node parent.\n\n"
1142 "suspend port tm node (port_id) (node_id)"
1143 " Suspend tm node.\n\n"
1145 "resume port tm node (port_id) (node_id)"
1146 " Resume tm node.\n\n"
1148 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1149 " Commit tm hierarchy.\n\n"
1151 "set port tm mark ip_ecn (port) (green) (yellow)"
1153 " Enables/Disables the traffic management marking"
1154 " for IP ECN (Explicit Congestion Notification)"
1155 " packets on a given port\n\n"
1157 "set port tm mark ip_dscp (port) (green) (yellow)"
1159 " Enables/Disables the traffic management marking"
1160 " on the port for IP dscp packets\n\n"
1162 "set port tm mark vlan_dei (port) (green) (yellow)"
1164 " Enables/Disables the traffic management marking"
1165 " on the port for VLAN packets with DEI enabled\n\n"
1169 if (show_all || !strcmp(res->section, "devices")) {
1173 "Device Operations:\n"
1175 "device detach (identifier)\n"
1176 " Detach device by identifier.\n\n"
1182 cmdline_parse_token_string_t cmd_help_long_help =
1183 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1185 cmdline_parse_token_string_t cmd_help_long_section =
1186 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1187 "all#control#display#config#"
1188 "ports#registers#filters#traffic_management#devices");
1190 cmdline_parse_inst_t cmd_help_long = {
1191 .f = cmd_help_long_parsed,
1193 .help_str = "help all|control|display|config|ports|register|"
1194 "filters|traffic_management|devices: "
1197 (void *)&cmd_help_long_help,
1198 (void *)&cmd_help_long_section,
1204 /* *** start/stop/close all ports *** */
1205 struct cmd_operate_port_result {
1206 cmdline_fixed_string_t keyword;
1207 cmdline_fixed_string_t name;
1208 cmdline_fixed_string_t value;
1211 static void cmd_operate_port_parsed(void *parsed_result,
1212 __rte_unused struct cmdline *cl,
1213 __rte_unused void *data)
1215 struct cmd_operate_port_result *res = parsed_result;
1217 if (!strcmp(res->name, "start"))
1218 start_port(RTE_PORT_ALL);
1219 else if (!strcmp(res->name, "stop"))
1220 stop_port(RTE_PORT_ALL);
1221 else if (!strcmp(res->name, "close"))
1222 close_port(RTE_PORT_ALL);
1223 else if (!strcmp(res->name, "reset"))
1224 reset_port(RTE_PORT_ALL);
1226 fprintf(stderr, "Unknown parameter\n");
1229 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1230 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1232 cmdline_parse_token_string_t cmd_operate_port_all_port =
1233 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1234 "start#stop#close#reset");
1235 cmdline_parse_token_string_t cmd_operate_port_all_all =
1236 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1238 cmdline_parse_inst_t cmd_operate_port = {
1239 .f = cmd_operate_port_parsed,
1241 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1243 (void *)&cmd_operate_port_all_cmd,
1244 (void *)&cmd_operate_port_all_port,
1245 (void *)&cmd_operate_port_all_all,
1250 /* *** start/stop/close specific port *** */
1251 struct cmd_operate_specific_port_result {
1252 cmdline_fixed_string_t keyword;
1253 cmdline_fixed_string_t name;
1257 static void cmd_operate_specific_port_parsed(void *parsed_result,
1258 __rte_unused struct cmdline *cl,
1259 __rte_unused void *data)
1261 struct cmd_operate_specific_port_result *res = parsed_result;
1263 if (!strcmp(res->name, "start"))
1264 start_port(res->value);
1265 else if (!strcmp(res->name, "stop"))
1266 stop_port(res->value);
1267 else if (!strcmp(res->name, "close"))
1268 close_port(res->value);
1269 else if (!strcmp(res->name, "reset"))
1270 reset_port(res->value);
1272 fprintf(stderr, "Unknown parameter\n");
1275 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1278 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1280 name, "start#stop#close#reset");
1281 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1282 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1285 cmdline_parse_inst_t cmd_operate_specific_port = {
1286 .f = cmd_operate_specific_port_parsed,
1288 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1290 (void *)&cmd_operate_specific_port_cmd,
1291 (void *)&cmd_operate_specific_port_port,
1292 (void *)&cmd_operate_specific_port_id,
1297 /* *** enable port setup (after attach) via iterator or event *** */
1298 struct cmd_set_port_setup_on_result {
1299 cmdline_fixed_string_t set;
1300 cmdline_fixed_string_t port;
1301 cmdline_fixed_string_t setup;
1302 cmdline_fixed_string_t on;
1303 cmdline_fixed_string_t mode;
1306 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1307 __rte_unused struct cmdline *cl,
1308 __rte_unused void *data)
1310 struct cmd_set_port_setup_on_result *res = parsed_result;
1312 if (strcmp(res->mode, "event") == 0)
1313 setup_on_probe_event = true;
1314 else if (strcmp(res->mode, "iterator") == 0)
1315 setup_on_probe_event = false;
1317 fprintf(stderr, "Unknown mode\n");
1320 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1321 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1323 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1324 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1326 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1327 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1329 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1330 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1332 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1333 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1334 mode, "iterator#event");
1336 cmdline_parse_inst_t cmd_set_port_setup_on = {
1337 .f = cmd_set_port_setup_on_parsed,
1339 .help_str = "set port setup on iterator|event",
1341 (void *)&cmd_set_port_setup_on_set,
1342 (void *)&cmd_set_port_setup_on_port,
1343 (void *)&cmd_set_port_setup_on_setup,
1344 (void *)&cmd_set_port_setup_on_on,
1345 (void *)&cmd_set_port_setup_on_mode,
1350 /* *** attach a specified port *** */
1351 struct cmd_operate_attach_port_result {
1352 cmdline_fixed_string_t port;
1353 cmdline_fixed_string_t keyword;
1354 cmdline_multi_string_t identifier;
1357 static void cmd_operate_attach_port_parsed(void *parsed_result,
1358 __rte_unused struct cmdline *cl,
1359 __rte_unused void *data)
1361 struct cmd_operate_attach_port_result *res = parsed_result;
1363 if (!strcmp(res->keyword, "attach"))
1364 attach_port(res->identifier);
1366 fprintf(stderr, "Unknown parameter\n");
1369 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1370 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1372 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1373 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1375 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1376 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1377 identifier, TOKEN_STRING_MULTI);
1379 cmdline_parse_inst_t cmd_operate_attach_port = {
1380 .f = cmd_operate_attach_port_parsed,
1382 .help_str = "port attach <identifier>: "
1383 "(identifier: pci address or virtual dev name)",
1385 (void *)&cmd_operate_attach_port_port,
1386 (void *)&cmd_operate_attach_port_keyword,
1387 (void *)&cmd_operate_attach_port_identifier,
1392 /* *** detach a specified port *** */
1393 struct cmd_operate_detach_port_result {
1394 cmdline_fixed_string_t port;
1395 cmdline_fixed_string_t keyword;
1399 static void cmd_operate_detach_port_parsed(void *parsed_result,
1400 __rte_unused struct cmdline *cl,
1401 __rte_unused void *data)
1403 struct cmd_operate_detach_port_result *res = parsed_result;
1405 if (!strcmp(res->keyword, "detach")) {
1406 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1407 detach_port_device(res->port_id);
1409 fprintf(stderr, "Unknown parameter\n");
1413 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1414 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1416 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1417 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1419 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1420 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1421 port_id, RTE_UINT16);
1423 cmdline_parse_inst_t cmd_operate_detach_port = {
1424 .f = cmd_operate_detach_port_parsed,
1426 .help_str = "port detach <port_id>",
1428 (void *)&cmd_operate_detach_port_port,
1429 (void *)&cmd_operate_detach_port_keyword,
1430 (void *)&cmd_operate_detach_port_port_id,
1435 /* *** detach device by identifier *** */
1436 struct cmd_operate_detach_device_result {
1437 cmdline_fixed_string_t device;
1438 cmdline_fixed_string_t keyword;
1439 cmdline_fixed_string_t identifier;
1442 static void cmd_operate_detach_device_parsed(void *parsed_result,
1443 __rte_unused struct cmdline *cl,
1444 __rte_unused void *data)
1446 struct cmd_operate_detach_device_result *res = parsed_result;
1448 if (!strcmp(res->keyword, "detach"))
1449 detach_devargs(res->identifier);
1451 fprintf(stderr, "Unknown parameter\n");
1454 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1457 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1460 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1461 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1464 cmdline_parse_inst_t cmd_operate_detach_device = {
1465 .f = cmd_operate_detach_device_parsed,
1467 .help_str = "device detach <identifier>:"
1468 "(identifier: pci address or virtual dev name)",
1470 (void *)&cmd_operate_detach_device_device,
1471 (void *)&cmd_operate_detach_device_keyword,
1472 (void *)&cmd_operate_detach_device_identifier,
1476 /* *** configure speed for all ports *** */
1477 struct cmd_config_speed_all {
1478 cmdline_fixed_string_t port;
1479 cmdline_fixed_string_t keyword;
1480 cmdline_fixed_string_t all;
1481 cmdline_fixed_string_t item1;
1482 cmdline_fixed_string_t item2;
1483 cmdline_fixed_string_t value1;
1484 cmdline_fixed_string_t value2;
1488 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1493 if (!strcmp(duplexstr, "half")) {
1494 duplex = RTE_ETH_LINK_HALF_DUPLEX;
1495 } else if (!strcmp(duplexstr, "full")) {
1496 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1497 } else if (!strcmp(duplexstr, "auto")) {
1498 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1500 fprintf(stderr, "Unknown duplex parameter\n");
1504 if (!strcmp(speedstr, "10")) {
1505 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1506 RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1507 } else if (!strcmp(speedstr, "100")) {
1508 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1509 RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1511 if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1512 fprintf(stderr, "Invalid speed/duplex parameters\n");
1515 if (!strcmp(speedstr, "1000")) {
1516 *speed = RTE_ETH_LINK_SPEED_1G;
1517 } else if (!strcmp(speedstr, "10000")) {
1518 *speed = RTE_ETH_LINK_SPEED_10G;
1519 } else if (!strcmp(speedstr, "25000")) {
1520 *speed = RTE_ETH_LINK_SPEED_25G;
1521 } else if (!strcmp(speedstr, "40000")) {
1522 *speed = RTE_ETH_LINK_SPEED_40G;
1523 } else if (!strcmp(speedstr, "50000")) {
1524 *speed = RTE_ETH_LINK_SPEED_50G;
1525 } else if (!strcmp(speedstr, "100000")) {
1526 *speed = RTE_ETH_LINK_SPEED_100G;
1527 } else if (!strcmp(speedstr, "200000")) {
1528 *speed = RTE_ETH_LINK_SPEED_200G;
1529 } else if (!strcmp(speedstr, "auto")) {
1530 *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1532 fprintf(stderr, "Unknown speed parameter\n");
1537 if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1538 *speed |= RTE_ETH_LINK_SPEED_FIXED;
1544 cmd_config_speed_all_parsed(void *parsed_result,
1545 __rte_unused struct cmdline *cl,
1546 __rte_unused void *data)
1548 struct cmd_config_speed_all *res = parsed_result;
1549 uint32_t link_speed;
1552 if (!all_ports_stopped()) {
1553 fprintf(stderr, "Please stop all ports first\n");
1557 if (parse_and_check_speed_duplex(res->value1, res->value2,
1561 RTE_ETH_FOREACH_DEV(pid) {
1562 ports[pid].dev_conf.link_speeds = link_speed;
1565 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1568 cmdline_parse_token_string_t cmd_config_speed_all_port =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1570 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1573 cmdline_parse_token_string_t cmd_config_speed_all_all =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1575 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1576 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1577 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1579 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1580 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1582 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1586 cmdline_parse_inst_t cmd_config_speed_all = {
1587 .f = cmd_config_speed_all_parsed,
1589 .help_str = "port config all speed "
1590 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1593 (void *)&cmd_config_speed_all_port,
1594 (void *)&cmd_config_speed_all_keyword,
1595 (void *)&cmd_config_speed_all_all,
1596 (void *)&cmd_config_speed_all_item1,
1597 (void *)&cmd_config_speed_all_value1,
1598 (void *)&cmd_config_speed_all_item2,
1599 (void *)&cmd_config_speed_all_value2,
1604 /* *** configure speed for specific port *** */
1605 struct cmd_config_speed_specific {
1606 cmdline_fixed_string_t port;
1607 cmdline_fixed_string_t keyword;
1609 cmdline_fixed_string_t item1;
1610 cmdline_fixed_string_t item2;
1611 cmdline_fixed_string_t value1;
1612 cmdline_fixed_string_t value2;
1616 cmd_config_speed_specific_parsed(void *parsed_result,
1617 __rte_unused struct cmdline *cl,
1618 __rte_unused void *data)
1620 struct cmd_config_speed_specific *res = parsed_result;
1621 uint32_t link_speed;
1623 if (port_id_is_invalid(res->id, ENABLED_WARN))
1626 if (!port_is_stopped(res->id)) {
1627 fprintf(stderr, "Please stop port %d first\n", res->id);
1631 if (parse_and_check_speed_duplex(res->value1, res->value2,
1635 ports[res->id].dev_conf.link_speeds = link_speed;
1637 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1641 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1644 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1647 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1648 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1649 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1652 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1654 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1655 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1658 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1662 cmdline_parse_inst_t cmd_config_speed_specific = {
1663 .f = cmd_config_speed_specific_parsed,
1665 .help_str = "port config <port_id> speed "
1666 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1669 (void *)&cmd_config_speed_specific_port,
1670 (void *)&cmd_config_speed_specific_keyword,
1671 (void *)&cmd_config_speed_specific_id,
1672 (void *)&cmd_config_speed_specific_item1,
1673 (void *)&cmd_config_speed_specific_value1,
1674 (void *)&cmd_config_speed_specific_item2,
1675 (void *)&cmd_config_speed_specific_value2,
1680 /* *** configure loopback for all ports *** */
1681 struct cmd_config_loopback_all {
1682 cmdline_fixed_string_t port;
1683 cmdline_fixed_string_t keyword;
1684 cmdline_fixed_string_t all;
1685 cmdline_fixed_string_t item;
1690 cmd_config_loopback_all_parsed(void *parsed_result,
1691 __rte_unused struct cmdline *cl,
1692 __rte_unused void *data)
1694 struct cmd_config_loopback_all *res = parsed_result;
1697 if (!all_ports_stopped()) {
1698 fprintf(stderr, "Please stop all ports first\n");
1702 RTE_ETH_FOREACH_DEV(pid) {
1703 ports[pid].dev_conf.lpbk_mode = res->mode;
1706 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1709 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1711 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1714 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1716 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1719 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1720 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1722 cmdline_parse_inst_t cmd_config_loopback_all = {
1723 .f = cmd_config_loopback_all_parsed,
1725 .help_str = "port config all loopback <mode>",
1727 (void *)&cmd_config_loopback_all_port,
1728 (void *)&cmd_config_loopback_all_keyword,
1729 (void *)&cmd_config_loopback_all_all,
1730 (void *)&cmd_config_loopback_all_item,
1731 (void *)&cmd_config_loopback_all_mode,
1736 /* *** configure loopback for specific port *** */
1737 struct cmd_config_loopback_specific {
1738 cmdline_fixed_string_t port;
1739 cmdline_fixed_string_t keyword;
1741 cmdline_fixed_string_t item;
1746 cmd_config_loopback_specific_parsed(void *parsed_result,
1747 __rte_unused struct cmdline *cl,
1748 __rte_unused void *data)
1750 struct cmd_config_loopback_specific *res = parsed_result;
1752 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1755 if (!port_is_stopped(res->port_id)) {
1756 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1760 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1762 cmd_reconfig_device_queue(res->port_id, 1, 1);
1766 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1767 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1769 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1772 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1773 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1775 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1778 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1779 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1782 cmdline_parse_inst_t cmd_config_loopback_specific = {
1783 .f = cmd_config_loopback_specific_parsed,
1785 .help_str = "port config <port_id> loopback <mode>",
1787 (void *)&cmd_config_loopback_specific_port,
1788 (void *)&cmd_config_loopback_specific_keyword,
1789 (void *)&cmd_config_loopback_specific_id,
1790 (void *)&cmd_config_loopback_specific_item,
1791 (void *)&cmd_config_loopback_specific_mode,
1796 /* *** configure txq/rxq, txd/rxd *** */
1797 struct cmd_config_rx_tx {
1798 cmdline_fixed_string_t port;
1799 cmdline_fixed_string_t keyword;
1800 cmdline_fixed_string_t all;
1801 cmdline_fixed_string_t name;
1806 cmd_config_rx_tx_parsed(void *parsed_result,
1807 __rte_unused struct cmdline *cl,
1808 __rte_unused void *data)
1810 struct cmd_config_rx_tx *res = parsed_result;
1812 if (!all_ports_stopped()) {
1813 fprintf(stderr, "Please stop all ports first\n");
1816 if (!strcmp(res->name, "rxq")) {
1817 if (!res->value && !nb_txq) {
1818 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1821 if (check_nb_rxq(res->value) != 0)
1823 nb_rxq = res->value;
1825 else if (!strcmp(res->name, "txq")) {
1826 if (!res->value && !nb_rxq) {
1827 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1830 if (check_nb_txq(res->value) != 0)
1832 nb_txq = res->value;
1834 else if (!strcmp(res->name, "rxd")) {
1835 if (check_nb_rxd(res->value) != 0)
1837 nb_rxd = res->value;
1838 } else if (!strcmp(res->name, "txd")) {
1839 if (check_nb_txd(res->value) != 0)
1842 nb_txd = res->value;
1844 fprintf(stderr, "Unknown parameter\n");
1852 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1855 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1856 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1857 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1859 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1861 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1864 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1865 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1867 cmdline_parse_inst_t cmd_config_rx_tx = {
1868 .f = cmd_config_rx_tx_parsed,
1870 .help_str = "port config all rxq|txq|rxd|txd <value>",
1872 (void *)&cmd_config_rx_tx_port,
1873 (void *)&cmd_config_rx_tx_keyword,
1874 (void *)&cmd_config_rx_tx_all,
1875 (void *)&cmd_config_rx_tx_name,
1876 (void *)&cmd_config_rx_tx_value,
1881 /* *** config max packet length *** */
1882 struct cmd_config_max_pkt_len_result {
1883 cmdline_fixed_string_t port;
1884 cmdline_fixed_string_t keyword;
1885 cmdline_fixed_string_t all;
1886 cmdline_fixed_string_t name;
1891 cmd_config_max_pkt_len_parsed(void *parsed_result,
1892 __rte_unused struct cmdline *cl,
1893 __rte_unused void *data)
1895 struct cmd_config_max_pkt_len_result *res = parsed_result;
1899 if (strcmp(res->name, "max-pkt-len") != 0) {
1900 printf("Unknown parameter\n");
1904 if (!all_ports_stopped()) {
1905 fprintf(stderr, "Please stop all ports first\n");
1909 RTE_ETH_FOREACH_DEV(port_id) {
1910 struct rte_port *port = &ports[port_id];
1912 if (res->value < RTE_ETHER_MIN_LEN) {
1914 "max-pkt-len can not be less than %d\n",
1919 ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1922 "rte_eth_dev_info_get() failed for port %u\n",
1927 update_mtu_from_frame_size(port_id, res->value);
1932 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1935 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1938 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1941 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1944 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1947 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1948 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1951 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1952 .f = cmd_config_max_pkt_len_parsed,
1954 .help_str = "port config all max-pkt-len <value>",
1956 (void *)&cmd_config_max_pkt_len_port,
1957 (void *)&cmd_config_max_pkt_len_keyword,
1958 (void *)&cmd_config_max_pkt_len_all,
1959 (void *)&cmd_config_max_pkt_len_name,
1960 (void *)&cmd_config_max_pkt_len_value,
1965 /* *** config max LRO aggregated packet size *** */
1966 struct cmd_config_max_lro_pkt_size_result {
1967 cmdline_fixed_string_t port;
1968 cmdline_fixed_string_t keyword;
1969 cmdline_fixed_string_t all;
1970 cmdline_fixed_string_t name;
1975 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1976 __rte_unused struct cmdline *cl,
1977 __rte_unused void *data)
1979 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1982 if (!all_ports_stopped()) {
1983 fprintf(stderr, "Please stop all ports first\n");
1987 RTE_ETH_FOREACH_DEV(pid) {
1988 struct rte_port *port = &ports[pid];
1990 if (!strcmp(res->name, "max-lro-pkt-size")) {
1992 port->dev_conf.rxmode.max_lro_pkt_size)
1995 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1997 fprintf(stderr, "Unknown parameter\n");
2004 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2007 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2010 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2011 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2013 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2016 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2018 name, "max-lro-pkt-size");
2019 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2020 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2023 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2024 .f = cmd_config_max_lro_pkt_size_parsed,
2026 .help_str = "port config all max-lro-pkt-size <value>",
2028 (void *)&cmd_config_max_lro_pkt_size_port,
2029 (void *)&cmd_config_max_lro_pkt_size_keyword,
2030 (void *)&cmd_config_max_lro_pkt_size_all,
2031 (void *)&cmd_config_max_lro_pkt_size_name,
2032 (void *)&cmd_config_max_lro_pkt_size_value,
2037 /* *** configure port MTU *** */
2038 struct cmd_config_mtu_result {
2039 cmdline_fixed_string_t port;
2040 cmdline_fixed_string_t keyword;
2041 cmdline_fixed_string_t mtu;
2047 cmd_config_mtu_parsed(void *parsed_result,
2048 __rte_unused struct cmdline *cl,
2049 __rte_unused void *data)
2051 struct cmd_config_mtu_result *res = parsed_result;
2053 port_mtu_set(res->port_id, res->value);
2056 cmdline_parse_token_string_t cmd_config_mtu_port =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2059 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2060 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2062 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2063 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2065 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2066 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2068 cmdline_parse_token_num_t cmd_config_mtu_value =
2069 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2072 cmdline_parse_inst_t cmd_config_mtu = {
2073 .f = cmd_config_mtu_parsed,
2075 .help_str = "port config mtu <port_id> <value>",
2077 (void *)&cmd_config_mtu_port,
2078 (void *)&cmd_config_mtu_keyword,
2079 (void *)&cmd_config_mtu_mtu,
2080 (void *)&cmd_config_mtu_port_id,
2081 (void *)&cmd_config_mtu_value,
2086 /* *** configure rx mode *** */
2087 struct cmd_config_rx_mode_flag {
2088 cmdline_fixed_string_t port;
2089 cmdline_fixed_string_t keyword;
2090 cmdline_fixed_string_t all;
2091 cmdline_fixed_string_t name;
2092 cmdline_fixed_string_t value;
2096 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2097 __rte_unused struct cmdline *cl,
2098 __rte_unused void *data)
2100 struct cmd_config_rx_mode_flag *res = parsed_result;
2102 if (!all_ports_stopped()) {
2103 fprintf(stderr, "Please stop all ports first\n");
2107 if (!strcmp(res->name, "drop-en")) {
2108 if (!strcmp(res->value, "on"))
2110 else if (!strcmp(res->value, "off"))
2113 fprintf(stderr, "Unknown parameter\n");
2117 fprintf(stderr, "Unknown parameter\n");
2123 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2126 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2127 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2128 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2129 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2131 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2133 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2134 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2140 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2141 .f = cmd_config_rx_mode_flag_parsed,
2143 .help_str = "port config all drop-en on|off",
2145 (void *)&cmd_config_rx_mode_flag_port,
2146 (void *)&cmd_config_rx_mode_flag_keyword,
2147 (void *)&cmd_config_rx_mode_flag_all,
2148 (void *)&cmd_config_rx_mode_flag_name,
2149 (void *)&cmd_config_rx_mode_flag_value,
2154 /* *** configure rss *** */
2155 struct cmd_config_rss {
2156 cmdline_fixed_string_t port;
2157 cmdline_fixed_string_t keyword;
2158 cmdline_fixed_string_t all;
2159 cmdline_fixed_string_t name;
2160 cmdline_fixed_string_t value;
2164 cmd_config_rss_parsed(void *parsed_result,
2165 __rte_unused struct cmdline *cl,
2166 __rte_unused void *data)
2168 struct cmd_config_rss *res = parsed_result;
2169 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2170 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2171 int use_default = 0;
2172 int all_updated = 1;
2177 if (!strcmp(res->value, "all"))
2178 rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2179 RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2180 RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2181 RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2182 RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_L2TPV2;
2183 else if (!strcmp(res->value, "eth"))
2184 rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2185 else if (!strcmp(res->value, "vlan"))
2186 rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2187 else if (!strcmp(res->value, "ip"))
2188 rss_conf.rss_hf = RTE_ETH_RSS_IP;
2189 else if (!strcmp(res->value, "udp"))
2190 rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2191 else if (!strcmp(res->value, "tcp"))
2192 rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2193 else if (!strcmp(res->value, "sctp"))
2194 rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2195 else if (!strcmp(res->value, "ether"))
2196 rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2197 else if (!strcmp(res->value, "port"))
2198 rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2199 else if (!strcmp(res->value, "vxlan"))
2200 rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2201 else if (!strcmp(res->value, "geneve"))
2202 rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2203 else if (!strcmp(res->value, "nvgre"))
2204 rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2205 else if (!strcmp(res->value, "l3-pre32"))
2206 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2207 else if (!strcmp(res->value, "l3-pre40"))
2208 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2209 else if (!strcmp(res->value, "l3-pre48"))
2210 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2211 else if (!strcmp(res->value, "l3-pre56"))
2212 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2213 else if (!strcmp(res->value, "l3-pre64"))
2214 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2215 else if (!strcmp(res->value, "l3-pre96"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2217 else if (!strcmp(res->value, "l3-src-only"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2219 else if (!strcmp(res->value, "l3-dst-only"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2221 else if (!strcmp(res->value, "l4-src-only"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2223 else if (!strcmp(res->value, "l4-dst-only"))
2224 rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2225 else if (!strcmp(res->value, "l2-src-only"))
2226 rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2227 else if (!strcmp(res->value, "l2-dst-only"))
2228 rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2229 else if (!strcmp(res->value, "l2tpv3"))
2230 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2231 else if (!strcmp(res->value, "esp"))
2232 rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2233 else if (!strcmp(res->value, "ah"))
2234 rss_conf.rss_hf = RTE_ETH_RSS_AH;
2235 else if (!strcmp(res->value, "pfcp"))
2236 rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2237 else if (!strcmp(res->value, "pppoe"))
2238 rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2239 else if (!strcmp(res->value, "gtpu"))
2240 rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2241 else if (!strcmp(res->value, "ecpri"))
2242 rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2243 else if (!strcmp(res->value, "mpls"))
2244 rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2245 else if (!strcmp(res->value, "ipv4-chksum"))
2246 rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2247 else if (!strcmp(res->value, "l2tpv2"))
2248 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV2;
2249 else if (!strcmp(res->value, "none"))
2250 rss_conf.rss_hf = 0;
2251 else if (!strcmp(res->value, "level-default")) {
2252 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2253 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2254 } else if (!strcmp(res->value, "level-outer")) {
2255 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2256 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2257 } else if (!strcmp(res->value, "level-inner")) {
2258 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2259 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2260 } else if (!strcmp(res->value, "default"))
2262 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2263 atoi(res->value) < 64)
2264 rss_conf.rss_hf = 1ULL << atoi(res->value);
2266 fprintf(stderr, "Unknown parameter\n");
2269 rss_conf.rss_key = NULL;
2270 /* Update global configuration for RSS types. */
2271 RTE_ETH_FOREACH_DEV(i) {
2272 struct rte_eth_rss_conf local_rss_conf;
2274 ret = eth_dev_info_get_print_err(i, &dev_info);
2279 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2281 local_rss_conf = rss_conf;
2282 local_rss_conf.rss_hf = rss_conf.rss_hf &
2283 dev_info.flow_type_rss_offloads;
2284 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2285 printf("Port %u modified RSS hash function based on hardware support,"
2286 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2287 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2289 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2293 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2294 i, -diag, strerror(-diag));
2297 if (all_updated && !use_default) {
2298 rss_hf = rss_conf.rss_hf;
2299 printf("rss_hf %#"PRIx64"\n", rss_hf);
2303 cmdline_parse_token_string_t cmd_config_rss_port =
2304 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2305 cmdline_parse_token_string_t cmd_config_rss_keyword =
2306 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2307 cmdline_parse_token_string_t cmd_config_rss_all =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2309 cmdline_parse_token_string_t cmd_config_rss_name =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2311 cmdline_parse_token_string_t cmd_config_rss_value =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2314 cmdline_parse_inst_t cmd_config_rss = {
2315 .f = cmd_config_rss_parsed,
2317 .help_str = "port config all rss "
2318 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2319 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|l2tpv2|"
2320 "none|level-default|level-outer|level-inner|<flowtype_id>",
2322 (void *)&cmd_config_rss_port,
2323 (void *)&cmd_config_rss_keyword,
2324 (void *)&cmd_config_rss_all,
2325 (void *)&cmd_config_rss_name,
2326 (void *)&cmd_config_rss_value,
2331 /* *** configure rss hash key *** */
2332 struct cmd_config_rss_hash_key {
2333 cmdline_fixed_string_t port;
2334 cmdline_fixed_string_t config;
2336 cmdline_fixed_string_t rss_hash_key;
2337 cmdline_fixed_string_t rss_type;
2338 cmdline_fixed_string_t key;
2342 hexa_digit_to_value(char hexa_digit)
2344 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2345 return (uint8_t) (hexa_digit - '0');
2346 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2347 return (uint8_t) ((hexa_digit - 'a') + 10);
2348 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2349 return (uint8_t) ((hexa_digit - 'A') + 10);
2350 /* Invalid hexa digit */
2355 parse_and_check_key_hexa_digit(char *key, int idx)
2359 hexa_v = hexa_digit_to_value(key[idx]);
2362 "invalid key: character %c at position %d is not a valid hexa digit\n",
2368 cmd_config_rss_hash_key_parsed(void *parsed_result,
2369 __rte_unused struct cmdline *cl,
2370 __rte_unused void *data)
2372 struct cmd_config_rss_hash_key *res = parsed_result;
2373 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2377 struct rte_eth_dev_info dev_info;
2378 uint8_t hash_key_size;
2382 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2386 if (dev_info.hash_key_size > 0 &&
2387 dev_info.hash_key_size <= sizeof(hash_key))
2388 hash_key_size = dev_info.hash_key_size;
2391 "dev_info did not provide a valid hash key size\n");
2394 /* Check the length of the RSS hash key */
2395 key_len = strlen(res->key);
2396 if (key_len != (hash_key_size * 2)) {
2398 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2399 (int)key_len, hash_key_size * 2);
2402 /* Translate RSS hash key into binary representation */
2403 for (i = 0; i < hash_key_size; i++) {
2404 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2407 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2410 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2412 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2416 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2417 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2418 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2421 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2422 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2425 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2426 rss_hash_key, "rss-hash-key");
2427 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2428 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2429 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2430 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2431 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2432 "ipv6-tcp-ex#ipv6-udp-ex#"
2433 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2434 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2435 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2436 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2437 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2439 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2440 .f = cmd_config_rss_hash_key_parsed,
2442 .help_str = "port config <port_id> rss-hash-key "
2443 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2444 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2445 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2446 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2447 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2448 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2449 "<string of hex digits (variable length, NIC dependent)>",
2451 (void *)&cmd_config_rss_hash_key_port,
2452 (void *)&cmd_config_rss_hash_key_config,
2453 (void *)&cmd_config_rss_hash_key_port_id,
2454 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2455 (void *)&cmd_config_rss_hash_key_rss_type,
2456 (void *)&cmd_config_rss_hash_key_value,
2461 /* *** cleanup txq mbufs *** */
2462 struct cmd_cleanup_txq_mbufs_result {
2463 cmdline_fixed_string_t port;
2464 cmdline_fixed_string_t keyword;
2465 cmdline_fixed_string_t name;
2472 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2473 __rte_unused struct cmdline *cl,
2474 __rte_unused void *data)
2476 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2477 uint16_t port_id = res->port_id;
2478 uint16_t queue_id = res->queue_id;
2479 uint32_t free_cnt = res->free_cnt;
2480 struct rte_eth_txq_info qinfo;
2483 if (test_done == 0) {
2484 fprintf(stderr, "Please stop forwarding first\n");
2488 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2489 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2494 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2495 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2499 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2502 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2503 port_id, queue_id, strerror(-ret), ret);
2507 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2508 port_id, queue_id, ret);
2511 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2512 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2514 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2515 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2517 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2518 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2520 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2521 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2523 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2524 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2526 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2527 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2530 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2531 .f = cmd_cleanup_txq_mbufs_parsed,
2533 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2535 (void *)&cmd_cleanup_txq_mbufs_port,
2536 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2537 (void *)&cmd_cleanup_txq_mbufs_port_id,
2538 (void *)&cmd_cleanup_txq_mbufs_txq,
2539 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2540 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2545 /* *** configure port rxq/txq ring size *** */
2546 struct cmd_config_rxtx_ring_size {
2547 cmdline_fixed_string_t port;
2548 cmdline_fixed_string_t config;
2550 cmdline_fixed_string_t rxtxq;
2552 cmdline_fixed_string_t rsize;
2557 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2558 __rte_unused struct cmdline *cl,
2559 __rte_unused void *data)
2561 struct cmd_config_rxtx_ring_size *res = parsed_result;
2562 struct rte_port *port;
2565 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2568 if (res->portid == (portid_t)RTE_PORT_ALL) {
2569 fprintf(stderr, "Invalid port id\n");
2573 port = &ports[res->portid];
2575 if (!strcmp(res->rxtxq, "rxq"))
2577 else if (!strcmp(res->rxtxq, "txq"))
2580 fprintf(stderr, "Unknown parameter\n");
2584 if (isrx && rx_queue_id_is_invalid(res->qid))
2586 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2589 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2591 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2597 port->nb_rx_desc[res->qid] = res->size;
2599 port->nb_tx_desc[res->qid] = res->size;
2601 cmd_reconfig_device_queue(res->portid, 0, 1);
2604 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2605 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2607 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2608 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2611 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2612 portid, RTE_UINT16);
2613 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2614 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2616 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2617 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2619 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2621 rsize, "ring_size");
2622 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2623 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2626 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2627 .f = cmd_config_rxtx_ring_size_parsed,
2629 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2631 (void *)&cmd_config_rxtx_ring_size_port,
2632 (void *)&cmd_config_rxtx_ring_size_config,
2633 (void *)&cmd_config_rxtx_ring_size_portid,
2634 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2635 (void *)&cmd_config_rxtx_ring_size_qid,
2636 (void *)&cmd_config_rxtx_ring_size_rsize,
2637 (void *)&cmd_config_rxtx_ring_size_size,
2642 /* *** configure port rxq/txq start/stop *** */
2643 struct cmd_config_rxtx_queue {
2644 cmdline_fixed_string_t port;
2646 cmdline_fixed_string_t rxtxq;
2648 cmdline_fixed_string_t opname;
2652 cmd_config_rxtx_queue_parsed(void *parsed_result,
2653 __rte_unused struct cmdline *cl,
2654 __rte_unused void *data)
2656 struct cmd_config_rxtx_queue *res = parsed_result;
2657 struct rte_port *port;
2663 if (test_done == 0) {
2664 fprintf(stderr, "Please stop forwarding first\n");
2668 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2671 if (port_is_started(res->portid) != 1) {
2672 fprintf(stderr, "Please start port %u first\n", res->portid);
2676 if (!strcmp(res->rxtxq, "rxq"))
2678 else if (!strcmp(res->rxtxq, "txq"))
2681 fprintf(stderr, "Unknown parameter\n");
2685 if (isrx && rx_queue_id_is_invalid(res->qid))
2687 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2690 if (!strcmp(res->opname, "start"))
2692 else if (!strcmp(res->opname, "stop"))
2695 fprintf(stderr, "Unknown parameter\n");
2699 if (isstart && isrx)
2700 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2701 else if (!isstart && isrx)
2702 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2703 else if (isstart && !isrx)
2704 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2706 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2708 if (ret == -ENOTSUP) {
2709 fprintf(stderr, "Function not supported in PMD\n");
2713 port = &ports[res->portid];
2714 state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2715 *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2716 RTE_ETH_QUEUE_STATE_STOPPED;
2719 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2720 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2721 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2722 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2723 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2724 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2725 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2726 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2727 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2728 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2731 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2732 .f = cmd_config_rxtx_queue_parsed,
2734 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2736 (void *)&cmd_config_rxtx_queue_port,
2737 (void *)&cmd_config_rxtx_queue_portid,
2738 (void *)&cmd_config_rxtx_queue_rxtxq,
2739 (void *)&cmd_config_rxtx_queue_qid,
2740 (void *)&cmd_config_rxtx_queue_opname,
2745 /* *** configure port rxq/txq deferred start on/off *** */
2746 struct cmd_config_deferred_start_rxtx_queue {
2747 cmdline_fixed_string_t port;
2749 cmdline_fixed_string_t rxtxq;
2751 cmdline_fixed_string_t opname;
2752 cmdline_fixed_string_t state;
2756 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2757 __rte_unused struct cmdline *cl,
2758 __rte_unused void *data)
2760 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2761 struct rte_port *port;
2764 uint8_t needreconfig = 0;
2766 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2769 if (port_is_started(res->port_id) != 0) {
2770 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2774 port = &ports[res->port_id];
2776 isrx = !strcmp(res->rxtxq, "rxq");
2778 if (isrx && rx_queue_id_is_invalid(res->qid))
2780 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2783 ison = !strcmp(res->state, "on");
2785 if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2786 port->rxq[res->qid].conf.rx_deferred_start = ison;
2788 } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2789 port->txq[res->qid].conf.tx_deferred_start = ison;
2794 cmd_reconfig_device_queue(res->port_id, 0, 1);
2797 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2798 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2800 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2801 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2802 port_id, RTE_UINT16);
2803 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2804 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2806 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2807 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2809 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2810 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2811 opname, "deferred_start");
2812 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2813 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2816 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2817 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2819 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2821 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2822 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2823 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2824 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2825 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2826 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2831 /* *** configure port rxq/txq setup *** */
2832 struct cmd_setup_rxtx_queue {
2833 cmdline_fixed_string_t port;
2835 cmdline_fixed_string_t rxtxq;
2837 cmdline_fixed_string_t setup;
2840 /* Common CLI fields for queue setup */
2841 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2842 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2843 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2844 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2845 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2846 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2847 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2848 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2849 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2850 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2853 cmd_setup_rxtx_queue_parsed(
2854 void *parsed_result,
2855 __rte_unused struct cmdline *cl,
2856 __rte_unused void *data)
2858 struct cmd_setup_rxtx_queue *res = parsed_result;
2859 struct rte_port *port;
2860 struct rte_mempool *mp;
2861 unsigned int socket_id;
2865 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2868 if (res->portid == (portid_t)RTE_PORT_ALL) {
2869 fprintf(stderr, "Invalid port id\n");
2873 if (!strcmp(res->rxtxq, "rxq"))
2875 else if (!strcmp(res->rxtxq, "txq"))
2878 fprintf(stderr, "Unknown parameter\n");
2882 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2883 fprintf(stderr, "Invalid rx queue\n");
2885 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2886 fprintf(stderr, "Invalid tx queue\n");
2890 port = &ports[res->portid];
2892 socket_id = rxring_numa[res->portid];
2893 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2894 socket_id = port->socket_id;
2896 mp = mbuf_pool_find(socket_id, 0);
2899 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2900 rxring_numa[res->portid]);
2903 ret = rx_queue_setup(res->portid,
2905 port->nb_rx_desc[res->qid],
2907 &port->rxq[res->qid].conf,
2910 fprintf(stderr, "Failed to setup RX queue\n");
2912 socket_id = txring_numa[res->portid];
2913 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2914 socket_id = port->socket_id;
2916 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2918 "Failed to setup TX queue: not enough descriptors\n");
2921 ret = rte_eth_tx_queue_setup(res->portid,
2923 port->nb_tx_desc[res->qid],
2925 &port->txq[res->qid].conf);
2927 fprintf(stderr, "Failed to setup TX queue\n");
2931 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2932 .f = cmd_setup_rxtx_queue_parsed,
2934 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2936 (void *)&cmd_setup_rxtx_queue_port,
2937 (void *)&cmd_setup_rxtx_queue_portid,
2938 (void *)&cmd_setup_rxtx_queue_rxtxq,
2939 (void *)&cmd_setup_rxtx_queue_qid,
2940 (void *)&cmd_setup_rxtx_queue_setup,
2946 /* *** Configure RSS RETA *** */
2947 struct cmd_config_rss_reta {
2948 cmdline_fixed_string_t port;
2949 cmdline_fixed_string_t keyword;
2951 cmdline_fixed_string_t name;
2952 cmdline_fixed_string_t list_name;
2953 cmdline_fixed_string_t list_of_items;
2957 parse_reta_config(const char *str,
2958 struct rte_eth_rss_reta_entry64 *reta_conf,
2959 uint16_t nb_entries)
2963 uint16_t hash_index, idx, shift;
2966 const char *p, *p0 = str;
2973 unsigned long int_fld[_NUM_FLD];
2974 char *str_fld[_NUM_FLD];
2976 while ((p = strchr(p0,'(')) != NULL) {
2978 if((p0 = strchr(p,')')) == NULL)
2982 if(size >= sizeof(s))
2985 snprintf(s, sizeof(s), "%.*s", size, p);
2986 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2988 for (i = 0; i < _NUM_FLD; i++) {
2990 int_fld[i] = strtoul(str_fld[i], &end, 0);
2991 if (errno != 0 || end == str_fld[i] ||
2996 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2997 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2999 if (hash_index >= nb_entries) {
3000 fprintf(stderr, "Invalid RETA hash index=%d\n",
3005 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3006 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3007 reta_conf[idx].mask |= (1ULL << shift);
3008 reta_conf[idx].reta[shift] = nb_queue;
3015 cmd_set_rss_reta_parsed(void *parsed_result,
3016 __rte_unused struct cmdline *cl,
3017 __rte_unused void *data)
3020 struct rte_eth_dev_info dev_info;
3021 struct rte_eth_rss_reta_entry64 reta_conf[8];
3022 struct cmd_config_rss_reta *res = parsed_result;
3024 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3028 if (dev_info.reta_size == 0) {
3030 "Redirection table size is 0 which is invalid for RSS\n");
3033 printf("The reta size of port %d is %u\n",
3034 res->port_id, dev_info.reta_size);
3035 if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3037 "Currently do not support more than %u entries of redirection table\n",
3038 RTE_ETH_RSS_RETA_SIZE_512);
3042 memset(reta_conf, 0, sizeof(reta_conf));
3043 if (!strcmp(res->list_name, "reta")) {
3044 if (parse_reta_config(res->list_of_items, reta_conf,
3045 dev_info.reta_size)) {
3047 "Invalid RSS Redirection Table config entered\n");
3050 ret = rte_eth_dev_rss_reta_update(res->port_id,
3051 reta_conf, dev_info.reta_size);
3054 "Bad redirection table parameter, return code = %d\n",
3059 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3060 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3061 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3062 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3063 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3064 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3065 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3066 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3067 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3068 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3069 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3070 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3072 cmdline_parse_inst_t cmd_config_rss_reta = {
3073 .f = cmd_set_rss_reta_parsed,
3075 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3077 (void *)&cmd_config_rss_reta_port,
3078 (void *)&cmd_config_rss_reta_keyword,
3079 (void *)&cmd_config_rss_reta_port_id,
3080 (void *)&cmd_config_rss_reta_name,
3081 (void *)&cmd_config_rss_reta_list_name,
3082 (void *)&cmd_config_rss_reta_list_of_items,
3087 /* *** SHOW PORT RETA INFO *** */
3088 struct cmd_showport_reta {
3089 cmdline_fixed_string_t show;
3090 cmdline_fixed_string_t port;
3092 cmdline_fixed_string_t rss;
3093 cmdline_fixed_string_t reta;
3095 cmdline_fixed_string_t list_of_items;
3099 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3100 uint16_t nb_entries,
3104 const char *p, *p0 = str;
3109 uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3110 RTE_ETH_RETA_GROUP_SIZE;
3113 p = strchr(p0, '(');
3117 p0 = strchr(p, ')');
3121 if (size >= sizeof(s)) {
3123 "The string size exceeds the internal buffer size\n");
3126 snprintf(s, sizeof(s), "%.*s", size, p);
3127 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3128 if (ret <= 0 || ret != num) {
3130 "The bits of masks do not match the number of reta entries: %u\n",
3134 for (i = 0; i < ret; i++)
3135 conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3141 cmd_showport_reta_parsed(void *parsed_result,
3142 __rte_unused struct cmdline *cl,
3143 __rte_unused void *data)
3145 struct cmd_showport_reta *res = parsed_result;
3146 struct rte_eth_rss_reta_entry64 reta_conf[8];
3147 struct rte_eth_dev_info dev_info;
3148 uint16_t max_reta_size;
3151 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3155 max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3156 if (res->size == 0 || res->size > max_reta_size) {
3157 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3158 res->size, max_reta_size);
3162 memset(reta_conf, 0, sizeof(reta_conf));
3163 if (showport_parse_reta_config(reta_conf, res->size,
3164 res->list_of_items) < 0) {
3165 fprintf(stderr, "Invalid string: %s for reta masks\n",
3166 res->list_of_items);
3169 port_rss_reta_info(res->port_id, reta_conf, res->size);
3172 cmdline_parse_token_string_t cmd_showport_reta_show =
3173 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3174 cmdline_parse_token_string_t cmd_showport_reta_port =
3175 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3176 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3177 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3178 cmdline_parse_token_string_t cmd_showport_reta_rss =
3179 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3180 cmdline_parse_token_string_t cmd_showport_reta_reta =
3181 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3182 cmdline_parse_token_num_t cmd_showport_reta_size =
3183 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3184 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3185 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3186 list_of_items, NULL);
3188 cmdline_parse_inst_t cmd_showport_reta = {
3189 .f = cmd_showport_reta_parsed,
3191 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3193 (void *)&cmd_showport_reta_show,
3194 (void *)&cmd_showport_reta_port,
3195 (void *)&cmd_showport_reta_port_id,
3196 (void *)&cmd_showport_reta_rss,
3197 (void *)&cmd_showport_reta_reta,
3198 (void *)&cmd_showport_reta_size,
3199 (void *)&cmd_showport_reta_list_of_items,
3204 /* *** Show RSS hash configuration *** */
3205 struct cmd_showport_rss_hash {
3206 cmdline_fixed_string_t show;
3207 cmdline_fixed_string_t port;
3209 cmdline_fixed_string_t rss_hash;
3210 cmdline_fixed_string_t rss_type;
3211 cmdline_fixed_string_t key; /* optional argument */
3214 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3215 __rte_unused struct cmdline *cl,
3218 struct cmd_showport_rss_hash *res = parsed_result;
3220 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3223 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3224 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3225 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3226 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3227 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3228 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3230 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3231 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3233 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3234 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3236 cmdline_parse_inst_t cmd_showport_rss_hash = {
3237 .f = cmd_showport_rss_hash_parsed,
3239 .help_str = "show port <port_id> rss-hash",
3241 (void *)&cmd_showport_rss_hash_show,
3242 (void *)&cmd_showport_rss_hash_port,
3243 (void *)&cmd_showport_rss_hash_port_id,
3244 (void *)&cmd_showport_rss_hash_rss_hash,
3249 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3250 .f = cmd_showport_rss_hash_parsed,
3252 .help_str = "show port <port_id> rss-hash key",
3254 (void *)&cmd_showport_rss_hash_show,
3255 (void *)&cmd_showport_rss_hash_port,
3256 (void *)&cmd_showport_rss_hash_port_id,
3257 (void *)&cmd_showport_rss_hash_rss_hash,
3258 (void *)&cmd_showport_rss_hash_rss_key,
3263 /* *** Configure DCB *** */
3264 struct cmd_config_dcb {
3265 cmdline_fixed_string_t port;
3266 cmdline_fixed_string_t config;
3268 cmdline_fixed_string_t dcb;
3269 cmdline_fixed_string_t vt;
3270 cmdline_fixed_string_t vt_en;
3272 cmdline_fixed_string_t pfc;
3273 cmdline_fixed_string_t pfc_en;
3277 cmd_config_dcb_parsed(void *parsed_result,
3278 __rte_unused struct cmdline *cl,
3279 __rte_unused void *data)
3281 struct cmd_config_dcb *res = parsed_result;
3282 struct rte_eth_dcb_info dcb_info;
3283 portid_t port_id = res->port_id;
3284 struct rte_port *port;
3288 port = &ports[port_id];
3289 /** Check if the port is not started **/
3290 if (port->port_status != RTE_PORT_STOPPED) {
3291 fprintf(stderr, "Please stop port %d first\n", port_id);
3295 if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3297 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3301 if (nb_fwd_lcores < res->num_tcs) {
3303 "nb_cores shouldn't be less than number of TCs.\n");
3307 /* Check whether the port supports the report of DCB info. */
3308 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3309 if (ret == -ENOTSUP) {
3310 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3314 if (!strncmp(res->pfc_en, "on", 2))
3319 /* DCB in VT mode */
3320 if (!strncmp(res->vt_en, "on", 2))
3321 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3322 (enum rte_eth_nb_tcs)res->num_tcs,
3325 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3326 (enum rte_eth_nb_tcs)res->num_tcs,
3329 fprintf(stderr, "Cannot initialize network ports.\n");
3335 cmd_reconfig_device_queue(port_id, 1, 1);
3338 cmdline_parse_token_string_t cmd_config_dcb_port =
3339 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3340 cmdline_parse_token_string_t cmd_config_dcb_config =
3341 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3342 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3343 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3344 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3345 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3346 cmdline_parse_token_string_t cmd_config_dcb_vt =
3347 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3348 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3349 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3350 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3351 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3352 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3353 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3354 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3355 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3357 cmdline_parse_inst_t cmd_config_dcb = {
3358 .f = cmd_config_dcb_parsed,
3360 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3362 (void *)&cmd_config_dcb_port,
3363 (void *)&cmd_config_dcb_config,
3364 (void *)&cmd_config_dcb_port_id,
3365 (void *)&cmd_config_dcb_dcb,
3366 (void *)&cmd_config_dcb_vt,
3367 (void *)&cmd_config_dcb_vt_en,
3368 (void *)&cmd_config_dcb_num_tcs,
3369 (void *)&cmd_config_dcb_pfc,
3370 (void *)&cmd_config_dcb_pfc_en,
3375 /* *** configure number of packets per burst *** */
3376 struct cmd_config_burst {
3377 cmdline_fixed_string_t port;
3378 cmdline_fixed_string_t keyword;
3379 cmdline_fixed_string_t all;
3380 cmdline_fixed_string_t name;
3385 cmd_config_burst_parsed(void *parsed_result,
3386 __rte_unused struct cmdline *cl,
3387 __rte_unused void *data)
3389 struct cmd_config_burst *res = parsed_result;
3390 struct rte_eth_dev_info dev_info;
3391 uint16_t rec_nb_pkts;
3394 if (!all_ports_stopped()) {
3395 fprintf(stderr, "Please stop all ports first\n");
3399 if (!strcmp(res->name, "burst")) {
3400 if (res->value == 0) {
3401 /* If user gives a value of zero, query the PMD for
3402 * its recommended Rx burst size. Testpmd uses a single
3403 * size for all ports, so assume all ports are the same
3404 * NIC model and use the values from Port 0.
3406 ret = eth_dev_info_get_print_err(0, &dev_info);
3410 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3412 if (rec_nb_pkts == 0) {
3413 printf("PMD does not recommend a burst size.\n"
3414 "User provided value must be between"
3415 " 1 and %d\n", MAX_PKT_BURST);
3417 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3418 printf("PMD recommended burst size of %d"
3419 " exceeds maximum value of %d\n",
3420 rec_nb_pkts, MAX_PKT_BURST);
3423 printf("Using PMD-provided burst value of %d\n",
3425 nb_pkt_per_burst = rec_nb_pkts;
3426 } else if (res->value > MAX_PKT_BURST) {
3427 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3431 nb_pkt_per_burst = res->value;
3433 fprintf(stderr, "Unknown parameter\n");
3439 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3442 cmdline_parse_token_string_t cmd_config_burst_port =
3443 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3444 cmdline_parse_token_string_t cmd_config_burst_keyword =
3445 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3446 cmdline_parse_token_string_t cmd_config_burst_all =
3447 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3448 cmdline_parse_token_string_t cmd_config_burst_name =
3449 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3450 cmdline_parse_token_num_t cmd_config_burst_value =
3451 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3453 cmdline_parse_inst_t cmd_config_burst = {
3454 .f = cmd_config_burst_parsed,
3456 .help_str = "port config all burst <value>",
3458 (void *)&cmd_config_burst_port,
3459 (void *)&cmd_config_burst_keyword,
3460 (void *)&cmd_config_burst_all,
3461 (void *)&cmd_config_burst_name,
3462 (void *)&cmd_config_burst_value,
3467 /* *** configure rx/tx queues *** */
3468 struct cmd_config_thresh {
3469 cmdline_fixed_string_t port;
3470 cmdline_fixed_string_t keyword;
3471 cmdline_fixed_string_t all;
3472 cmdline_fixed_string_t name;
3477 cmd_config_thresh_parsed(void *parsed_result,
3478 __rte_unused struct cmdline *cl,
3479 __rte_unused void *data)
3481 struct cmd_config_thresh *res = parsed_result;
3483 if (!all_ports_stopped()) {
3484 fprintf(stderr, "Please stop all ports first\n");
3488 if (!strcmp(res->name, "txpt"))
3489 tx_pthresh = res->value;
3490 else if(!strcmp(res->name, "txht"))
3491 tx_hthresh = res->value;
3492 else if(!strcmp(res->name, "txwt"))
3493 tx_wthresh = res->value;
3494 else if(!strcmp(res->name, "rxpt"))
3495 rx_pthresh = res->value;
3496 else if(!strcmp(res->name, "rxht"))
3497 rx_hthresh = res->value;
3498 else if(!strcmp(res->name, "rxwt"))
3499 rx_wthresh = res->value;
3501 fprintf(stderr, "Unknown parameter\n");
3507 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3510 cmdline_parse_token_string_t cmd_config_thresh_port =
3511 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3512 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3513 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3514 cmdline_parse_token_string_t cmd_config_thresh_all =
3515 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3516 cmdline_parse_token_string_t cmd_config_thresh_name =
3517 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3518 "txpt#txht#txwt#rxpt#rxht#rxwt");
3519 cmdline_parse_token_num_t cmd_config_thresh_value =
3520 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3522 cmdline_parse_inst_t cmd_config_thresh = {
3523 .f = cmd_config_thresh_parsed,
3525 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3527 (void *)&cmd_config_thresh_port,
3528 (void *)&cmd_config_thresh_keyword,
3529 (void *)&cmd_config_thresh_all,
3530 (void *)&cmd_config_thresh_name,
3531 (void *)&cmd_config_thresh_value,
3536 /* *** configure free/rs threshold *** */
3537 struct cmd_config_threshold {
3538 cmdline_fixed_string_t port;
3539 cmdline_fixed_string_t keyword;
3540 cmdline_fixed_string_t all;
3541 cmdline_fixed_string_t name;
3546 cmd_config_threshold_parsed(void *parsed_result,
3547 __rte_unused struct cmdline *cl,
3548 __rte_unused void *data)
3550 struct cmd_config_threshold *res = parsed_result;
3552 if (!all_ports_stopped()) {
3553 fprintf(stderr, "Please stop all ports first\n");
3557 if (!strcmp(res->name, "txfreet"))
3558 tx_free_thresh = res->value;
3559 else if (!strcmp(res->name, "txrst"))
3560 tx_rs_thresh = res->value;
3561 else if (!strcmp(res->name, "rxfreet"))
3562 rx_free_thresh = res->value;
3564 fprintf(stderr, "Unknown parameter\n");
3570 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3573 cmdline_parse_token_string_t cmd_config_threshold_port =
3574 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3575 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3576 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3578 cmdline_parse_token_string_t cmd_config_threshold_all =
3579 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3580 cmdline_parse_token_string_t cmd_config_threshold_name =
3581 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3582 "txfreet#txrst#rxfreet");
3583 cmdline_parse_token_num_t cmd_config_threshold_value =
3584 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3586 cmdline_parse_inst_t cmd_config_threshold = {
3587 .f = cmd_config_threshold_parsed,
3589 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3591 (void *)&cmd_config_threshold_port,
3592 (void *)&cmd_config_threshold_keyword,
3593 (void *)&cmd_config_threshold_all,
3594 (void *)&cmd_config_threshold_name,
3595 (void *)&cmd_config_threshold_value,
3601 struct cmd_stop_result {
3602 cmdline_fixed_string_t stop;
3605 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3606 __rte_unused struct cmdline *cl,
3607 __rte_unused void *data)
3609 stop_packet_forwarding();
3612 cmdline_parse_token_string_t cmd_stop_stop =
3613 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3615 cmdline_parse_inst_t cmd_stop = {
3616 .f = cmd_stop_parsed,
3618 .help_str = "stop: Stop packet forwarding",
3620 (void *)&cmd_stop_stop,
3625 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3628 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3629 unsigned int *parsed_items, int check_unique_values)
3631 unsigned int nb_item;
3639 * First parse all items in the list and store their value.
3644 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3646 if ((c >= '0') && (c <= '9')) {
3647 value = (unsigned int) (value * 10 + (c - '0'));
3652 fprintf(stderr, "character %c is not a decimal digit\n", c);
3656 fprintf(stderr, "No valid value before comma\n");
3659 if (nb_item < max_items) {
3660 parsed_items[nb_item] = value;
3666 if (nb_item >= max_items) {
3667 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3668 item_name, nb_item + 1, max_items);
3671 parsed_items[nb_item++] = value;
3672 if (! check_unique_values)
3676 * Then, check that all values in the list are different.
3677 * No optimization here...
3679 for (i = 0; i < nb_item; i++) {
3680 for (j = i + 1; j < nb_item; j++) {
3681 if (parsed_items[j] == parsed_items[i]) {
3683 "duplicated %s %u at index %u and %u\n",
3684 item_name, parsed_items[i], i, j);
3692 struct cmd_set_list_result {
3693 cmdline_fixed_string_t cmd_keyword;
3694 cmdline_fixed_string_t list_name;
3695 cmdline_fixed_string_t list_of_items;
3698 static void cmd_set_list_parsed(void *parsed_result,
3699 __rte_unused struct cmdline *cl,
3700 __rte_unused void *data)
3702 struct cmd_set_list_result *res;
3704 unsigned int lcorelist[RTE_MAX_LCORE];
3705 unsigned int portlist[RTE_MAX_ETHPORTS];
3707 unsigned int nb_item;
3709 if (test_done == 0) {
3710 fprintf(stderr, "Please stop forwarding first\n");
3714 res = parsed_result;
3715 if (!strcmp(res->list_name, "corelist")) {
3716 nb_item = parse_item_list(res->list_of_items, "core",
3718 parsed_items.lcorelist, 1);
3720 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3725 if (!strcmp(res->list_name, "portlist")) {
3726 nb_item = parse_item_list(res->list_of_items, "port",
3728 parsed_items.portlist, 1);
3730 set_fwd_ports_list(parsed_items.portlist, nb_item);
3736 cmdline_parse_token_string_t cmd_set_list_keyword =
3737 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3739 cmdline_parse_token_string_t cmd_set_list_name =
3740 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3741 "corelist#portlist");
3742 cmdline_parse_token_string_t cmd_set_list_of_items =
3743 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3746 cmdline_parse_inst_t cmd_set_fwd_list = {
3747 .f = cmd_set_list_parsed,
3749 .help_str = "set corelist|portlist <list0[,list1]*>",
3751 (void *)&cmd_set_list_keyword,
3752 (void *)&cmd_set_list_name,
3753 (void *)&cmd_set_list_of_items,
3758 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3760 struct cmd_setmask_result {
3761 cmdline_fixed_string_t set;
3762 cmdline_fixed_string_t mask;
3766 static void cmd_set_mask_parsed(void *parsed_result,
3767 __rte_unused struct cmdline *cl,
3768 __rte_unused void *data)
3770 struct cmd_setmask_result *res = parsed_result;
3772 if (test_done == 0) {
3773 fprintf(stderr, "Please stop forwarding first\n");
3776 if (!strcmp(res->mask, "coremask")) {
3777 set_fwd_lcores_mask(res->hexavalue);
3779 } else if (!strcmp(res->mask, "portmask")) {
3780 set_fwd_ports_mask(res->hexavalue);
3785 cmdline_parse_token_string_t cmd_setmask_set =
3786 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3787 cmdline_parse_token_string_t cmd_setmask_mask =
3788 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3789 "coremask#portmask");
3790 cmdline_parse_token_num_t cmd_setmask_value =
3791 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3793 cmdline_parse_inst_t cmd_set_fwd_mask = {
3794 .f = cmd_set_mask_parsed,
3796 .help_str = "set coremask|portmask <hexadecimal value>",
3798 (void *)&cmd_setmask_set,
3799 (void *)&cmd_setmask_mask,
3800 (void *)&cmd_setmask_value,
3806 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3808 struct cmd_set_result {
3809 cmdline_fixed_string_t set;
3810 cmdline_fixed_string_t what;
3814 static void cmd_set_parsed(void *parsed_result,
3815 __rte_unused struct cmdline *cl,
3816 __rte_unused void *data)
3818 struct cmd_set_result *res = parsed_result;
3819 if (!strcmp(res->what, "nbport")) {
3820 set_fwd_ports_number(res->value);
3822 } else if (!strcmp(res->what, "nbcore")) {
3823 set_fwd_lcores_number(res->value);
3825 } else if (!strcmp(res->what, "burst"))
3826 set_nb_pkt_per_burst(res->value);
3827 else if (!strcmp(res->what, "verbose"))
3828 set_verbose_level(res->value);
3831 cmdline_parse_token_string_t cmd_set_set =
3832 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3833 cmdline_parse_token_string_t cmd_set_what =
3834 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3835 "nbport#nbcore#burst#verbose");
3836 cmdline_parse_token_num_t cmd_set_value =
3837 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3839 cmdline_parse_inst_t cmd_set_numbers = {
3840 .f = cmd_set_parsed,
3842 .help_str = "set nbport|nbcore|burst|verbose <value>",
3844 (void *)&cmd_set_set,
3845 (void *)&cmd_set_what,
3846 (void *)&cmd_set_value,
3851 /* *** SET LOG LEVEL CONFIGURATION *** */
3853 struct cmd_set_log_result {
3854 cmdline_fixed_string_t set;
3855 cmdline_fixed_string_t log;
3856 cmdline_fixed_string_t type;
3861 cmd_set_log_parsed(void *parsed_result,
3862 __rte_unused struct cmdline *cl,
3863 __rte_unused void *data)
3865 struct cmd_set_log_result *res;
3868 res = parsed_result;
3869 if (!strcmp(res->type, "global"))
3870 rte_log_set_global_level(res->level);
3872 ret = rte_log_set_level_regexp(res->type, res->level);
3874 fprintf(stderr, "Unable to set log level\n");
3878 cmdline_parse_token_string_t cmd_set_log_set =
3879 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3880 cmdline_parse_token_string_t cmd_set_log_log =
3881 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3882 cmdline_parse_token_string_t cmd_set_log_type =
3883 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3884 cmdline_parse_token_num_t cmd_set_log_level =
3885 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3887 cmdline_parse_inst_t cmd_set_log = {
3888 .f = cmd_set_log_parsed,
3890 .help_str = "set log global|<type> <level>",
3892 (void *)&cmd_set_log_set,
3893 (void *)&cmd_set_log_log,
3894 (void *)&cmd_set_log_type,
3895 (void *)&cmd_set_log_level,
3900 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3902 struct cmd_set_rxoffs_result {
3903 cmdline_fixed_string_t cmd_keyword;
3904 cmdline_fixed_string_t rxoffs;
3905 cmdline_fixed_string_t seg_offsets;
3909 cmd_set_rxoffs_parsed(void *parsed_result,
3910 __rte_unused struct cmdline *cl,
3911 __rte_unused void *data)
3913 struct cmd_set_rxoffs_result *res;
3914 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3915 unsigned int nb_segs;
3917 res = parsed_result;
3918 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3919 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3921 set_rx_pkt_offsets(seg_offsets, nb_segs);
3922 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3925 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3926 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3927 cmd_keyword, "set");
3928 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3929 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3931 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3932 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3935 cmdline_parse_inst_t cmd_set_rxoffs = {
3936 .f = cmd_set_rxoffs_parsed,
3938 .help_str = "set rxoffs <len0[,len1]*>",
3940 (void *)&cmd_set_rxoffs_keyword,
3941 (void *)&cmd_set_rxoffs_name,
3942 (void *)&cmd_set_rxoffs_offsets,
3947 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3949 struct cmd_set_rxpkts_result {
3950 cmdline_fixed_string_t cmd_keyword;
3951 cmdline_fixed_string_t rxpkts;
3952 cmdline_fixed_string_t seg_lengths;
3956 cmd_set_rxpkts_parsed(void *parsed_result,
3957 __rte_unused struct cmdline *cl,
3958 __rte_unused void *data)
3960 struct cmd_set_rxpkts_result *res;
3961 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3962 unsigned int nb_segs;
3964 res = parsed_result;
3965 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3966 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3968 set_rx_pkt_segments(seg_lengths, nb_segs);
3969 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3972 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3973 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3974 cmd_keyword, "set");
3975 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3976 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3978 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3979 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3982 cmdline_parse_inst_t cmd_set_rxpkts = {
3983 .f = cmd_set_rxpkts_parsed,
3985 .help_str = "set rxpkts <len0[,len1]*>",
3987 (void *)&cmd_set_rxpkts_keyword,
3988 (void *)&cmd_set_rxpkts_name,
3989 (void *)&cmd_set_rxpkts_lengths,
3994 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3996 struct cmd_set_txpkts_result {
3997 cmdline_fixed_string_t cmd_keyword;
3998 cmdline_fixed_string_t txpkts;
3999 cmdline_fixed_string_t seg_lengths;
4003 cmd_set_txpkts_parsed(void *parsed_result,
4004 __rte_unused struct cmdline *cl,
4005 __rte_unused void *data)
4007 struct cmd_set_txpkts_result *res;
4008 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4009 unsigned int nb_segs;
4011 res = parsed_result;
4012 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4013 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4015 set_tx_pkt_segments(seg_lengths, nb_segs);
4018 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4019 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4020 cmd_keyword, "set");
4021 cmdline_parse_token_string_t cmd_set_txpkts_name =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4024 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4025 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4028 cmdline_parse_inst_t cmd_set_txpkts = {
4029 .f = cmd_set_txpkts_parsed,
4031 .help_str = "set txpkts <len0[,len1]*>",
4033 (void *)&cmd_set_txpkts_keyword,
4034 (void *)&cmd_set_txpkts_name,
4035 (void *)&cmd_set_txpkts_lengths,
4040 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4042 struct cmd_set_txsplit_result {
4043 cmdline_fixed_string_t cmd_keyword;
4044 cmdline_fixed_string_t txsplit;
4045 cmdline_fixed_string_t mode;
4049 cmd_set_txsplit_parsed(void *parsed_result,
4050 __rte_unused struct cmdline *cl,
4051 __rte_unused void *data)
4053 struct cmd_set_txsplit_result *res;
4055 res = parsed_result;
4056 set_tx_pkt_split(res->mode);
4059 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4060 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4061 cmd_keyword, "set");
4062 cmdline_parse_token_string_t cmd_set_txsplit_name =
4063 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4064 txsplit, "txsplit");
4065 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4066 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4069 cmdline_parse_inst_t cmd_set_txsplit = {
4070 .f = cmd_set_txsplit_parsed,
4072 .help_str = "set txsplit on|off|rand",
4074 (void *)&cmd_set_txsplit_keyword,
4075 (void *)&cmd_set_txsplit_name,
4076 (void *)&cmd_set_txsplit_mode,
4081 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4083 struct cmd_set_txtimes_result {
4084 cmdline_fixed_string_t cmd_keyword;
4085 cmdline_fixed_string_t txtimes;
4086 cmdline_fixed_string_t tx_times;
4090 cmd_set_txtimes_parsed(void *parsed_result,
4091 __rte_unused struct cmdline *cl,
4092 __rte_unused void *data)
4094 struct cmd_set_txtimes_result *res;
4095 unsigned int tx_times[2] = {0, 0};
4096 unsigned int n_times;
4098 res = parsed_result;
4099 n_times = parse_item_list(res->tx_times, "tx times",
4102 set_tx_pkt_times(tx_times);
4105 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4106 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4107 cmd_keyword, "set");
4108 cmdline_parse_token_string_t cmd_set_txtimes_name =
4109 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4110 txtimes, "txtimes");
4111 cmdline_parse_token_string_t cmd_set_txtimes_value =
4112 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4115 cmdline_parse_inst_t cmd_set_txtimes = {
4116 .f = cmd_set_txtimes_parsed,
4118 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4120 (void *)&cmd_set_txtimes_keyword,
4121 (void *)&cmd_set_txtimes_name,
4122 (void *)&cmd_set_txtimes_value,
4127 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4128 struct cmd_rx_vlan_filter_all_result {
4129 cmdline_fixed_string_t rx_vlan;
4130 cmdline_fixed_string_t what;
4131 cmdline_fixed_string_t all;
4136 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4137 __rte_unused struct cmdline *cl,
4138 __rte_unused void *data)
4140 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4142 if (!strcmp(res->what, "add"))
4143 rx_vlan_all_filter_set(res->port_id, 1);
4145 rx_vlan_all_filter_set(res->port_id, 0);
4148 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4149 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4150 rx_vlan, "rx_vlan");
4151 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4152 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4154 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4155 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4157 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4158 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4159 port_id, RTE_UINT16);
4161 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4162 .f = cmd_rx_vlan_filter_all_parsed,
4164 .help_str = "rx_vlan add|rm all <port_id>: "
4165 "Add/Remove all identifiers to/from the set of VLAN "
4166 "identifiers filtered by a port",
4168 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4169 (void *)&cmd_rx_vlan_filter_all_what,
4170 (void *)&cmd_rx_vlan_filter_all_all,
4171 (void *)&cmd_rx_vlan_filter_all_portid,
4176 /* *** VLAN OFFLOAD SET ON A PORT *** */
4177 struct cmd_vlan_offload_result {
4178 cmdline_fixed_string_t vlan;
4179 cmdline_fixed_string_t set;
4180 cmdline_fixed_string_t vlan_type;
4181 cmdline_fixed_string_t what;
4182 cmdline_fixed_string_t on;
4183 cmdline_fixed_string_t port_id;
4187 cmd_vlan_offload_parsed(void *parsed_result,
4188 __rte_unused struct cmdline *cl,
4189 __rte_unused void *data)
4192 struct cmd_vlan_offload_result *res = parsed_result;
4195 portid_t port_id = 0;
4199 len = strnlen(str, STR_TOKEN_SIZE);
4201 /* Get port_id first */
4209 tmp = strtoul(str, NULL, 0);
4210 /* If port_id greater that what portid_t can represent, return */
4211 if(tmp >= RTE_MAX_ETHPORTS)
4213 port_id = (portid_t)tmp;
4215 if (!strcmp(res->on, "on"))
4220 if (!strcmp(res->what, "strip"))
4221 rx_vlan_strip_set(port_id, on);
4222 else if(!strcmp(res->what, "stripq")){
4223 uint16_t queue_id = 0;
4225 /* No queue_id, return */
4227 fprintf(stderr, "must specify (port,queue_id)\n");
4230 tmp = strtoul(str + i + 1, NULL, 0);
4231 /* If queue_id greater that what 16-bits can represent, return */
4235 queue_id = (uint16_t)tmp;
4236 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4238 else if (!strcmp(res->what, "filter"))
4239 rx_vlan_filter_set(port_id, on);
4240 else if (!strcmp(res->what, "qinq_strip"))
4241 rx_vlan_qinq_strip_set(port_id, on);
4243 vlan_extend_set(port_id, on);
4248 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4249 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4251 cmdline_parse_token_string_t cmd_vlan_offload_set =
4252 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4254 cmdline_parse_token_string_t cmd_vlan_offload_what =
4255 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4256 what, "strip#filter#qinq_strip#extend#stripq");
4257 cmdline_parse_token_string_t cmd_vlan_offload_on =
4258 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4260 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4261 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4264 cmdline_parse_inst_t cmd_vlan_offload = {
4265 .f = cmd_vlan_offload_parsed,
4267 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4268 "<port_id[,queue_id]>: "
4269 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4271 (void *)&cmd_vlan_offload_vlan,
4272 (void *)&cmd_vlan_offload_set,
4273 (void *)&cmd_vlan_offload_what,
4274 (void *)&cmd_vlan_offload_on,
4275 (void *)&cmd_vlan_offload_portid,
4280 /* *** VLAN TPID SET ON A PORT *** */
4281 struct cmd_vlan_tpid_result {
4282 cmdline_fixed_string_t vlan;
4283 cmdline_fixed_string_t set;
4284 cmdline_fixed_string_t vlan_type;
4285 cmdline_fixed_string_t what;
4291 cmd_vlan_tpid_parsed(void *parsed_result,
4292 __rte_unused struct cmdline *cl,
4293 __rte_unused void *data)
4295 struct cmd_vlan_tpid_result *res = parsed_result;
4296 enum rte_vlan_type vlan_type;
4298 if (!strcmp(res->vlan_type, "inner"))
4299 vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4300 else if (!strcmp(res->vlan_type, "outer"))
4301 vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4303 fprintf(stderr, "Unknown vlan type\n");
4306 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4309 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4310 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4312 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4313 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4315 cmdline_parse_token_string_t cmd_vlan_type =
4316 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4317 vlan_type, "inner#outer");
4318 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4319 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4321 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4322 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4324 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4325 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4326 port_id, RTE_UINT16);
4328 cmdline_parse_inst_t cmd_vlan_tpid = {
4329 .f = cmd_vlan_tpid_parsed,
4331 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4332 "Set the VLAN Ether type",
4334 (void *)&cmd_vlan_tpid_vlan,
4335 (void *)&cmd_vlan_tpid_set,
4336 (void *)&cmd_vlan_type,
4337 (void *)&cmd_vlan_tpid_what,
4338 (void *)&cmd_vlan_tpid_tpid,
4339 (void *)&cmd_vlan_tpid_portid,
4344 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4345 struct cmd_rx_vlan_filter_result {
4346 cmdline_fixed_string_t rx_vlan;
4347 cmdline_fixed_string_t what;
4353 cmd_rx_vlan_filter_parsed(void *parsed_result,
4354 __rte_unused struct cmdline *cl,
4355 __rte_unused void *data)
4357 struct cmd_rx_vlan_filter_result *res = parsed_result;
4359 if (!strcmp(res->what, "add"))
4360 rx_vft_set(res->port_id, res->vlan_id, 1);
4362 rx_vft_set(res->port_id, res->vlan_id, 0);
4365 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4366 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4367 rx_vlan, "rx_vlan");
4368 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4369 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4371 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4372 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4373 vlan_id, RTE_UINT16);
4374 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4375 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4376 port_id, RTE_UINT16);
4378 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4379 .f = cmd_rx_vlan_filter_parsed,
4381 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4382 "Add/Remove a VLAN identifier to/from the set of VLAN "
4383 "identifiers filtered by a port",
4385 (void *)&cmd_rx_vlan_filter_rx_vlan,
4386 (void *)&cmd_rx_vlan_filter_what,
4387 (void *)&cmd_rx_vlan_filter_vlanid,
4388 (void *)&cmd_rx_vlan_filter_portid,
4393 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4394 struct cmd_tx_vlan_set_result {
4395 cmdline_fixed_string_t tx_vlan;
4396 cmdline_fixed_string_t set;
4402 cmd_tx_vlan_set_parsed(void *parsed_result,
4403 __rte_unused struct cmdline *cl,
4404 __rte_unused void *data)
4406 struct cmd_tx_vlan_set_result *res = parsed_result;
4408 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4411 if (!port_is_stopped(res->port_id)) {
4412 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4416 tx_vlan_set(res->port_id, res->vlan_id);
4418 cmd_reconfig_device_queue(res->port_id, 1, 1);
4421 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4422 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4423 tx_vlan, "tx_vlan");
4424 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4425 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4427 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4428 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4429 port_id, RTE_UINT16);
4430 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4431 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4432 vlan_id, RTE_UINT16);
4434 cmdline_parse_inst_t cmd_tx_vlan_set = {
4435 .f = cmd_tx_vlan_set_parsed,
4437 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4438 "Enable hardware insertion of a single VLAN header "
4439 "with a given TAG Identifier in packets sent on a port",
4441 (void *)&cmd_tx_vlan_set_tx_vlan,
4442 (void *)&cmd_tx_vlan_set_set,
4443 (void *)&cmd_tx_vlan_set_portid,
4444 (void *)&cmd_tx_vlan_set_vlanid,
4449 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4450 struct cmd_tx_vlan_set_qinq_result {
4451 cmdline_fixed_string_t tx_vlan;
4452 cmdline_fixed_string_t set;
4455 uint16_t vlan_id_outer;
4459 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4460 __rte_unused struct cmdline *cl,
4461 __rte_unused void *data)
4463 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4465 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4468 if (!port_is_stopped(res->port_id)) {
4469 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4473 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4475 cmd_reconfig_device_queue(res->port_id, 1, 1);
4478 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4479 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4480 tx_vlan, "tx_vlan");
4481 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4482 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4484 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4485 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4486 port_id, RTE_UINT16);
4487 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4488 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4489 vlan_id, RTE_UINT16);
4490 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4491 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4492 vlan_id_outer, RTE_UINT16);
4494 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4495 .f = cmd_tx_vlan_set_qinq_parsed,
4497 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4498 "Enable hardware insertion of double VLAN header "
4499 "with given TAG Identifiers in packets sent on a port",
4501 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4502 (void *)&cmd_tx_vlan_set_qinq_set,
4503 (void *)&cmd_tx_vlan_set_qinq_portid,
4504 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4505 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4510 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4511 struct cmd_tx_vlan_set_pvid_result {
4512 cmdline_fixed_string_t tx_vlan;
4513 cmdline_fixed_string_t set;
4514 cmdline_fixed_string_t pvid;
4517 cmdline_fixed_string_t mode;
4521 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4522 __rte_unused struct cmdline *cl,
4523 __rte_unused void *data)
4525 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4527 if (strcmp(res->mode, "on") == 0)
4528 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4530 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4533 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4534 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4535 tx_vlan, "tx_vlan");
4536 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4537 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4539 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4540 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4542 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4543 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4544 port_id, RTE_UINT16);
4545 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4546 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4547 vlan_id, RTE_UINT16);
4548 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4549 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4552 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4553 .f = cmd_tx_vlan_set_pvid_parsed,
4555 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4557 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4558 (void *)&cmd_tx_vlan_set_pvid_set,
4559 (void *)&cmd_tx_vlan_set_pvid_pvid,
4560 (void *)&cmd_tx_vlan_set_pvid_port_id,
4561 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4562 (void *)&cmd_tx_vlan_set_pvid_mode,
4567 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4568 struct cmd_tx_vlan_reset_result {
4569 cmdline_fixed_string_t tx_vlan;
4570 cmdline_fixed_string_t reset;
4575 cmd_tx_vlan_reset_parsed(void *parsed_result,
4576 __rte_unused struct cmdline *cl,
4577 __rte_unused void *data)
4579 struct cmd_tx_vlan_reset_result *res = parsed_result;
4581 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4584 if (!port_is_stopped(res->port_id)) {
4585 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4589 tx_vlan_reset(res->port_id);
4591 cmd_reconfig_device_queue(res->port_id, 1, 1);
4594 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4595 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4596 tx_vlan, "tx_vlan");
4597 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4598 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4600 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4601 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4602 port_id, RTE_UINT16);
4604 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4605 .f = cmd_tx_vlan_reset_parsed,
4607 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4608 "VLAN header in packets sent on a port",
4610 (void *)&cmd_tx_vlan_reset_tx_vlan,
4611 (void *)&cmd_tx_vlan_reset_reset,
4612 (void *)&cmd_tx_vlan_reset_portid,
4618 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4619 struct cmd_csum_result {
4620 cmdline_fixed_string_t csum;
4621 cmdline_fixed_string_t mode;
4622 cmdline_fixed_string_t proto;
4623 cmdline_fixed_string_t hwsw;
4628 csum_show(int port_id)
4630 struct rte_eth_dev_info dev_info;
4631 uint64_t tx_offloads;
4634 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4635 printf("Parse tunnel is %s\n",
4636 (ports[port_id].parse_tunnel) ? "on" : "off");
4637 printf("IP checksum offload is %s\n",
4638 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4639 printf("UDP checksum offload is %s\n",
4640 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4641 printf("TCP checksum offload is %s\n",
4642 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4643 printf("SCTP checksum offload is %s\n",
4644 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4645 printf("Outer-Ip checksum offload is %s\n",
4646 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4647 printf("Outer-Udp checksum offload is %s\n",
4648 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4650 /* display warnings if configuration is not supported by the NIC */
4651 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4655 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4656 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4658 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4661 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4662 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4664 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4667 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4668 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4670 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4673 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4674 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4676 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4679 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4680 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4682 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4685 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4686 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4689 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4695 cmd_config_queue_tx_offloads(struct rte_port *port)
4699 /* Apply queue tx offloads configuration */
4700 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4701 port->txq[k].conf.offloads =
4702 port->dev_conf.txmode.offloads;
4706 cmd_csum_parsed(void *parsed_result,
4707 __rte_unused struct cmdline *cl,
4708 __rte_unused void *data)
4710 struct cmd_csum_result *res = parsed_result;
4712 uint64_t csum_offloads = 0;
4713 struct rte_eth_dev_info dev_info;
4716 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4717 fprintf(stderr, "invalid port %d\n", res->port_id);
4720 if (!port_is_stopped(res->port_id)) {
4721 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4725 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4729 if (!strcmp(res->mode, "set")) {
4731 if (!strcmp(res->hwsw, "hw"))
4734 if (!strcmp(res->proto, "ip")) {
4735 if (hw == 0 || (dev_info.tx_offload_capa &
4736 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4737 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4740 "IP checksum offload is not supported by port %u\n",
4743 } else if (!strcmp(res->proto, "udp")) {
4744 if (hw == 0 || (dev_info.tx_offload_capa &
4745 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4746 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4749 "UDP checksum offload is not supported by port %u\n",
4752 } else if (!strcmp(res->proto, "tcp")) {
4753 if (hw == 0 || (dev_info.tx_offload_capa &
4754 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4755 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4758 "TCP checksum offload is not supported by port %u\n",
4761 } else if (!strcmp(res->proto, "sctp")) {
4762 if (hw == 0 || (dev_info.tx_offload_capa &
4763 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4764 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4767 "SCTP checksum offload is not supported by port %u\n",
4770 } else if (!strcmp(res->proto, "outer-ip")) {
4771 if (hw == 0 || (dev_info.tx_offload_capa &
4772 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4774 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4777 "Outer IP checksum offload is not supported by port %u\n",
4780 } else if (!strcmp(res->proto, "outer-udp")) {
4781 if (hw == 0 || (dev_info.tx_offload_capa &
4782 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4784 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4787 "Outer UDP checksum offload is not supported by port %u\n",
4793 ports[res->port_id].dev_conf.txmode.offloads |=
4796 ports[res->port_id].dev_conf.txmode.offloads &=
4799 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4801 csum_show(res->port_id);
4803 cmd_reconfig_device_queue(res->port_id, 1, 1);
4806 cmdline_parse_token_string_t cmd_csum_csum =
4807 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4809 cmdline_parse_token_string_t cmd_csum_mode =
4810 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4812 cmdline_parse_token_string_t cmd_csum_proto =
4813 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4814 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4815 cmdline_parse_token_string_t cmd_csum_hwsw =
4816 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4818 cmdline_parse_token_num_t cmd_csum_portid =
4819 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4820 port_id, RTE_UINT16);
4822 cmdline_parse_inst_t cmd_csum_set = {
4823 .f = cmd_csum_parsed,
4825 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4826 "Enable/Disable hardware calculation of L3/L4 checksum when "
4827 "using csum forward engine",
4829 (void *)&cmd_csum_csum,
4830 (void *)&cmd_csum_mode,
4831 (void *)&cmd_csum_proto,
4832 (void *)&cmd_csum_hwsw,
4833 (void *)&cmd_csum_portid,
4838 cmdline_parse_token_string_t cmd_csum_mode_show =
4839 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4842 cmdline_parse_inst_t cmd_csum_show = {
4843 .f = cmd_csum_parsed,
4845 .help_str = "csum show <port_id>: Show checksum offload configuration",
4847 (void *)&cmd_csum_csum,
4848 (void *)&cmd_csum_mode_show,
4849 (void *)&cmd_csum_portid,
4854 /* Enable/disable tunnel parsing */
4855 struct cmd_csum_tunnel_result {
4856 cmdline_fixed_string_t csum;
4857 cmdline_fixed_string_t parse;
4858 cmdline_fixed_string_t onoff;
4863 cmd_csum_tunnel_parsed(void *parsed_result,
4864 __rte_unused struct cmdline *cl,
4865 __rte_unused void *data)
4867 struct cmd_csum_tunnel_result *res = parsed_result;
4869 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4872 if (!strcmp(res->onoff, "on"))
4873 ports[res->port_id].parse_tunnel = 1;
4875 ports[res->port_id].parse_tunnel = 0;
4877 csum_show(res->port_id);
4880 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4881 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4883 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4884 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4885 parse, "parse-tunnel");
4886 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4887 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4889 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4890 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4891 port_id, RTE_UINT16);
4893 cmdline_parse_inst_t cmd_csum_tunnel = {
4894 .f = cmd_csum_tunnel_parsed,
4896 .help_str = "csum parse-tunnel on|off <port_id>: "
4897 "Enable/Disable parsing of tunnels for csum engine",
4899 (void *)&cmd_csum_tunnel_csum,
4900 (void *)&cmd_csum_tunnel_parse,
4901 (void *)&cmd_csum_tunnel_onoff,
4902 (void *)&cmd_csum_tunnel_portid,
4907 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4908 struct cmd_tso_set_result {
4909 cmdline_fixed_string_t tso;
4910 cmdline_fixed_string_t mode;
4916 cmd_tso_set_parsed(void *parsed_result,
4917 __rte_unused struct cmdline *cl,
4918 __rte_unused void *data)
4920 struct cmd_tso_set_result *res = parsed_result;
4921 struct rte_eth_dev_info dev_info;
4924 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4926 if (!port_is_stopped(res->port_id)) {
4927 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4931 if (!strcmp(res->mode, "set"))
4932 ports[res->port_id].tso_segsz = res->tso_segsz;
4934 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4938 if ((ports[res->port_id].tso_segsz != 0) &&
4939 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4940 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4945 if (ports[res->port_id].tso_segsz == 0) {
4946 ports[res->port_id].dev_conf.txmode.offloads &=
4947 ~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4948 printf("TSO for non-tunneled packets is disabled\n");
4950 ports[res->port_id].dev_conf.txmode.offloads |=
4951 RTE_ETH_TX_OFFLOAD_TCP_TSO;
4952 printf("TSO segment size for non-tunneled packets is %d\n",
4953 ports[res->port_id].tso_segsz);
4955 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4957 /* display warnings if configuration is not supported by the NIC */
4958 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4962 if ((ports[res->port_id].tso_segsz != 0) &&
4963 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4965 "Warning: TSO enabled but not supported by port %d\n",
4969 cmd_reconfig_device_queue(res->port_id, 1, 1);
4972 cmdline_parse_token_string_t cmd_tso_set_tso =
4973 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4975 cmdline_parse_token_string_t cmd_tso_set_mode =
4976 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4978 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4979 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4980 tso_segsz, RTE_UINT16);
4981 cmdline_parse_token_num_t cmd_tso_set_portid =
4982 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4983 port_id, RTE_UINT16);
4985 cmdline_parse_inst_t cmd_tso_set = {
4986 .f = cmd_tso_set_parsed,
4988 .help_str = "tso set <tso_segsz> <port_id>: "
4989 "Set TSO segment size of non-tunneled packets for csum engine "
4992 (void *)&cmd_tso_set_tso,
4993 (void *)&cmd_tso_set_mode,
4994 (void *)&cmd_tso_set_tso_segsz,
4995 (void *)&cmd_tso_set_portid,
5000 cmdline_parse_token_string_t cmd_tso_show_mode =
5001 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5005 cmdline_parse_inst_t cmd_tso_show = {
5006 .f = cmd_tso_set_parsed,
5008 .help_str = "tso show <port_id>: "
5009 "Show TSO segment size of non-tunneled packets for csum engine",
5011 (void *)&cmd_tso_set_tso,
5012 (void *)&cmd_tso_show_mode,
5013 (void *)&cmd_tso_set_portid,
5018 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5019 struct cmd_tunnel_tso_set_result {
5020 cmdline_fixed_string_t tso;
5021 cmdline_fixed_string_t mode;
5026 static struct rte_eth_dev_info
5027 check_tunnel_tso_nic_support(portid_t port_id)
5029 struct rte_eth_dev_info dev_info;
5031 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5034 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5036 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5038 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5040 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5042 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5044 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5046 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5048 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5050 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5052 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5054 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5056 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5062 cmd_tunnel_tso_set_parsed(void *parsed_result,
5063 __rte_unused struct cmdline *cl,
5064 __rte_unused void *data)
5066 struct cmd_tunnel_tso_set_result *res = parsed_result;
5067 struct rte_eth_dev_info dev_info;
5069 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5071 if (!port_is_stopped(res->port_id)) {
5072 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5076 if (!strcmp(res->mode, "set"))
5077 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5079 dev_info = check_tunnel_tso_nic_support(res->port_id);
5080 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5081 ports[res->port_id].dev_conf.txmode.offloads &=
5082 ~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5083 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5084 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5085 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5086 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5087 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5088 printf("TSO for tunneled packets is disabled\n");
5090 uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5091 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5092 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5093 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5094 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5095 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5097 ports[res->port_id].dev_conf.txmode.offloads |=
5098 (tso_offloads & dev_info.tx_offload_capa);
5099 printf("TSO segment size for tunneled packets is %d\n",
5100 ports[res->port_id].tunnel_tso_segsz);
5102 /* Below conditions are needed to make it work:
5103 * (1) tunnel TSO is supported by the NIC;
5104 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5106 * (3) for tunneled pkts with outer L3 of IPv4,
5107 * "csum set outer-ip" must be set to hw, because after tso,
5108 * total_len of outer IP header is changed, and the checksum
5109 * of outer IP header calculated by sw should be wrong; that
5110 * is not necessary for IPv6 tunneled pkts because there's no
5111 * checksum in IP header anymore.
5114 if (!ports[res->port_id].parse_tunnel)
5116 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5117 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5118 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5120 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5123 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5124 cmd_reconfig_device_queue(res->port_id, 1, 1);
5127 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5128 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5130 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5131 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5133 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5134 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5135 tso_segsz, RTE_UINT16);
5136 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5137 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5138 port_id, RTE_UINT16);
5140 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5141 .f = cmd_tunnel_tso_set_parsed,
5143 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5144 "Set TSO segment size of tunneled packets for csum engine "
5147 (void *)&cmd_tunnel_tso_set_tso,
5148 (void *)&cmd_tunnel_tso_set_mode,
5149 (void *)&cmd_tunnel_tso_set_tso_segsz,
5150 (void *)&cmd_tunnel_tso_set_portid,
5155 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5156 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5160 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5161 .f = cmd_tunnel_tso_set_parsed,
5163 .help_str = "tunnel_tso show <port_id> "
5164 "Show TSO segment size of tunneled packets for csum engine",
5166 (void *)&cmd_tunnel_tso_set_tso,
5167 (void *)&cmd_tunnel_tso_show_mode,
5168 (void *)&cmd_tunnel_tso_set_portid,
5174 /* *** SET GRO FOR A PORT *** */
5175 struct cmd_gro_enable_result {
5176 cmdline_fixed_string_t cmd_set;
5177 cmdline_fixed_string_t cmd_port;
5178 cmdline_fixed_string_t cmd_keyword;
5179 cmdline_fixed_string_t cmd_onoff;
5184 cmd_gro_enable_parsed(void *parsed_result,
5185 __rte_unused struct cmdline *cl,
5186 __rte_unused void *data)
5188 struct cmd_gro_enable_result *res;
5190 res = parsed_result;
5191 if (!strcmp(res->cmd_keyword, "gro"))
5192 setup_gro(res->cmd_onoff, res->cmd_pid);
5195 cmdline_parse_token_string_t cmd_gro_enable_set =
5196 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5198 cmdline_parse_token_string_t cmd_gro_enable_port =
5199 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5200 cmd_keyword, "port");
5201 cmdline_parse_token_num_t cmd_gro_enable_pid =
5202 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5203 cmd_pid, RTE_UINT16);
5204 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5205 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5206 cmd_keyword, "gro");
5207 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5208 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5209 cmd_onoff, "on#off");
5211 cmdline_parse_inst_t cmd_gro_enable = {
5212 .f = cmd_gro_enable_parsed,
5214 .help_str = "set port <port_id> gro on|off",
5216 (void *)&cmd_gro_enable_set,
5217 (void *)&cmd_gro_enable_port,
5218 (void *)&cmd_gro_enable_pid,
5219 (void *)&cmd_gro_enable_keyword,
5220 (void *)&cmd_gro_enable_onoff,
5225 /* *** DISPLAY GRO CONFIGURATION *** */
5226 struct cmd_gro_show_result {
5227 cmdline_fixed_string_t cmd_show;
5228 cmdline_fixed_string_t cmd_port;
5229 cmdline_fixed_string_t cmd_keyword;
5234 cmd_gro_show_parsed(void *parsed_result,
5235 __rte_unused struct cmdline *cl,
5236 __rte_unused void *data)
5238 struct cmd_gro_show_result *res;
5240 res = parsed_result;
5241 if (!strcmp(res->cmd_keyword, "gro"))
5242 show_gro(res->cmd_pid);
5245 cmdline_parse_token_string_t cmd_gro_show_show =
5246 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5248 cmdline_parse_token_string_t cmd_gro_show_port =
5249 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5251 cmdline_parse_token_num_t cmd_gro_show_pid =
5252 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5253 cmd_pid, RTE_UINT16);
5254 cmdline_parse_token_string_t cmd_gro_show_keyword =
5255 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5256 cmd_keyword, "gro");
5258 cmdline_parse_inst_t cmd_gro_show = {
5259 .f = cmd_gro_show_parsed,
5261 .help_str = "show port <port_id> gro",
5263 (void *)&cmd_gro_show_show,
5264 (void *)&cmd_gro_show_port,
5265 (void *)&cmd_gro_show_pid,
5266 (void *)&cmd_gro_show_keyword,
5271 /* *** SET FLUSH CYCLES FOR GRO *** */
5272 struct cmd_gro_flush_result {
5273 cmdline_fixed_string_t cmd_set;
5274 cmdline_fixed_string_t cmd_keyword;
5275 cmdline_fixed_string_t cmd_flush;
5280 cmd_gro_flush_parsed(void *parsed_result,
5281 __rte_unused struct cmdline *cl,
5282 __rte_unused void *data)
5284 struct cmd_gro_flush_result *res;
5286 res = parsed_result;
5287 if ((!strcmp(res->cmd_keyword, "gro")) &&
5288 (!strcmp(res->cmd_flush, "flush")))
5289 setup_gro_flush_cycles(res->cmd_cycles);
5292 cmdline_parse_token_string_t cmd_gro_flush_set =
5293 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5295 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5296 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5297 cmd_keyword, "gro");
5298 cmdline_parse_token_string_t cmd_gro_flush_flush =
5299 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5300 cmd_flush, "flush");
5301 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5302 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5303 cmd_cycles, RTE_UINT8);
5305 cmdline_parse_inst_t cmd_gro_flush = {
5306 .f = cmd_gro_flush_parsed,
5308 .help_str = "set gro flush <cycles>",
5310 (void *)&cmd_gro_flush_set,
5311 (void *)&cmd_gro_flush_keyword,
5312 (void *)&cmd_gro_flush_flush,
5313 (void *)&cmd_gro_flush_cycles,
5317 #endif /* RTE_LIB_GRO */
5320 /* *** ENABLE/DISABLE GSO *** */
5321 struct cmd_gso_enable_result {
5322 cmdline_fixed_string_t cmd_set;
5323 cmdline_fixed_string_t cmd_port;
5324 cmdline_fixed_string_t cmd_keyword;
5325 cmdline_fixed_string_t cmd_mode;
5330 cmd_gso_enable_parsed(void *parsed_result,
5331 __rte_unused struct cmdline *cl,
5332 __rte_unused void *data)
5334 struct cmd_gso_enable_result *res;
5336 res = parsed_result;
5337 if (!strcmp(res->cmd_keyword, "gso"))
5338 setup_gso(res->cmd_mode, res->cmd_pid);
5341 cmdline_parse_token_string_t cmd_gso_enable_set =
5342 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5344 cmdline_parse_token_string_t cmd_gso_enable_port =
5345 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5347 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5348 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5349 cmd_keyword, "gso");
5350 cmdline_parse_token_string_t cmd_gso_enable_mode =
5351 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5352 cmd_mode, "on#off");
5353 cmdline_parse_token_num_t cmd_gso_enable_pid =
5354 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5355 cmd_pid, RTE_UINT16);
5357 cmdline_parse_inst_t cmd_gso_enable = {
5358 .f = cmd_gso_enable_parsed,
5360 .help_str = "set port <port_id> gso on|off",
5362 (void *)&cmd_gso_enable_set,
5363 (void *)&cmd_gso_enable_port,
5364 (void *)&cmd_gso_enable_pid,
5365 (void *)&cmd_gso_enable_keyword,
5366 (void *)&cmd_gso_enable_mode,
5371 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5372 struct cmd_gso_size_result {
5373 cmdline_fixed_string_t cmd_set;
5374 cmdline_fixed_string_t cmd_keyword;
5375 cmdline_fixed_string_t cmd_segsz;
5380 cmd_gso_size_parsed(void *parsed_result,
5381 __rte_unused struct cmdline *cl,
5382 __rte_unused void *data)
5384 struct cmd_gso_size_result *res = parsed_result;
5386 if (test_done == 0) {
5388 "Before setting GSO segsz, please first stop forwarding\n");
5392 if (!strcmp(res->cmd_keyword, "gso") &&
5393 !strcmp(res->cmd_segsz, "segsz")) {
5394 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5396 "gso_size should be larger than %zu. Please input a legal value\n",
5397 RTE_GSO_SEG_SIZE_MIN);
5399 gso_max_segment_size = res->cmd_size;
5403 cmdline_parse_token_string_t cmd_gso_size_set =
5404 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5406 cmdline_parse_token_string_t cmd_gso_size_keyword =
5407 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5408 cmd_keyword, "gso");
5409 cmdline_parse_token_string_t cmd_gso_size_segsz =
5410 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5411 cmd_segsz, "segsz");
5412 cmdline_parse_token_num_t cmd_gso_size_size =
5413 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5414 cmd_size, RTE_UINT16);
5416 cmdline_parse_inst_t cmd_gso_size = {
5417 .f = cmd_gso_size_parsed,
5419 .help_str = "set gso segsz <length>",
5421 (void *)&cmd_gso_size_set,
5422 (void *)&cmd_gso_size_keyword,
5423 (void *)&cmd_gso_size_segsz,
5424 (void *)&cmd_gso_size_size,
5429 /* *** SHOW GSO CONFIGURATION *** */
5430 struct cmd_gso_show_result {
5431 cmdline_fixed_string_t cmd_show;
5432 cmdline_fixed_string_t cmd_port;
5433 cmdline_fixed_string_t cmd_keyword;
5438 cmd_gso_show_parsed(void *parsed_result,
5439 __rte_unused struct cmdline *cl,
5440 __rte_unused void *data)
5442 struct cmd_gso_show_result *res = parsed_result;
5444 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5445 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5448 if (!strcmp(res->cmd_keyword, "gso")) {
5449 if (gso_ports[res->cmd_pid].enable) {
5450 printf("Max GSO'd packet size: %uB\n"
5451 "Supported GSO types: TCP/IPv4, "
5452 "UDP/IPv4, VxLAN with inner "
5453 "TCP/IPv4 packet, GRE with inner "
5454 "TCP/IPv4 packet\n",
5455 gso_max_segment_size);
5457 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5461 cmdline_parse_token_string_t cmd_gso_show_show =
5462 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5464 cmdline_parse_token_string_t cmd_gso_show_port =
5465 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5467 cmdline_parse_token_string_t cmd_gso_show_keyword =
5468 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5469 cmd_keyword, "gso");
5470 cmdline_parse_token_num_t cmd_gso_show_pid =
5471 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5472 cmd_pid, RTE_UINT16);
5474 cmdline_parse_inst_t cmd_gso_show = {
5475 .f = cmd_gso_show_parsed,
5477 .help_str = "show port <port_id> gso",
5479 (void *)&cmd_gso_show_show,
5480 (void *)&cmd_gso_show_port,
5481 (void *)&cmd_gso_show_pid,
5482 (void *)&cmd_gso_show_keyword,
5486 #endif /* RTE_LIB_GSO */
5488 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5489 struct cmd_set_flush_rx {
5490 cmdline_fixed_string_t set;
5491 cmdline_fixed_string_t flush_rx;
5492 cmdline_fixed_string_t mode;
5496 cmd_set_flush_rx_parsed(void *parsed_result,
5497 __rte_unused struct cmdline *cl,
5498 __rte_unused void *data)
5500 struct cmd_set_flush_rx *res = parsed_result;
5502 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5503 printf("multi-process doesn't support to flush Rx queues.\n");
5507 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5510 cmdline_parse_token_string_t cmd_setflushrx_set =
5511 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5513 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5514 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5515 flush_rx, "flush_rx");
5516 cmdline_parse_token_string_t cmd_setflushrx_mode =
5517 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5521 cmdline_parse_inst_t cmd_set_flush_rx = {
5522 .f = cmd_set_flush_rx_parsed,
5523 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5526 (void *)&cmd_setflushrx_set,
5527 (void *)&cmd_setflushrx_flush_rx,
5528 (void *)&cmd_setflushrx_mode,
5533 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5534 struct cmd_set_link_check {
5535 cmdline_fixed_string_t set;
5536 cmdline_fixed_string_t link_check;
5537 cmdline_fixed_string_t mode;
5541 cmd_set_link_check_parsed(void *parsed_result,
5542 __rte_unused struct cmdline *cl,
5543 __rte_unused void *data)
5545 struct cmd_set_link_check *res = parsed_result;
5546 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5549 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5550 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5552 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5553 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5554 link_check, "link_check");
5555 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5556 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5560 cmdline_parse_inst_t cmd_set_link_check = {
5561 .f = cmd_set_link_check_parsed,
5562 .help_str = "set link_check on|off: Enable/Disable link status check "
5563 "when starting/stopping a port",
5566 (void *)&cmd_setlinkcheck_set,
5567 (void *)&cmd_setlinkcheck_link_check,
5568 (void *)&cmd_setlinkcheck_mode,
5573 /* *** SET NIC BYPASS MODE *** */
5574 struct cmd_set_bypass_mode_result {
5575 cmdline_fixed_string_t set;
5576 cmdline_fixed_string_t bypass;
5577 cmdline_fixed_string_t mode;
5578 cmdline_fixed_string_t value;
5583 cmd_set_bypass_mode_parsed(void *parsed_result,
5584 __rte_unused struct cmdline *cl,
5585 __rte_unused void *data)
5587 struct cmd_set_bypass_mode_result *res = parsed_result;
5588 portid_t port_id = res->port_id;
5589 int32_t rc = -EINVAL;
5591 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5592 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5594 if (!strcmp(res->value, "bypass"))
5595 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5596 else if (!strcmp(res->value, "isolate"))
5597 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5599 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5601 /* Set the bypass mode for the relevant port. */
5602 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5605 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5609 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5610 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5612 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5613 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5615 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5618 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5620 value, "normal#bypass#isolate");
5621 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5622 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5623 port_id, RTE_UINT16);
5625 cmdline_parse_inst_t cmd_set_bypass_mode = {
5626 .f = cmd_set_bypass_mode_parsed,
5627 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5628 "Set the NIC bypass mode for port_id",
5631 (void *)&cmd_setbypass_mode_set,
5632 (void *)&cmd_setbypass_mode_bypass,
5633 (void *)&cmd_setbypass_mode_mode,
5634 (void *)&cmd_setbypass_mode_value,
5635 (void *)&cmd_setbypass_mode_port,
5640 /* *** SET NIC BYPASS EVENT *** */
5641 struct cmd_set_bypass_event_result {
5642 cmdline_fixed_string_t set;
5643 cmdline_fixed_string_t bypass;
5644 cmdline_fixed_string_t event;
5645 cmdline_fixed_string_t event_value;
5646 cmdline_fixed_string_t mode;
5647 cmdline_fixed_string_t mode_value;
5652 cmd_set_bypass_event_parsed(void *parsed_result,
5653 __rte_unused struct cmdline *cl,
5654 __rte_unused void *data)
5656 int32_t rc = -EINVAL;
5657 struct cmd_set_bypass_event_result *res = parsed_result;
5658 portid_t port_id = res->port_id;
5660 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5661 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5662 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5664 if (!strcmp(res->event_value, "timeout"))
5665 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5666 else if (!strcmp(res->event_value, "os_on"))
5667 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5668 else if (!strcmp(res->event_value, "os_off"))
5669 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5670 else if (!strcmp(res->event_value, "power_on"))
5671 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5672 else if (!strcmp(res->event_value, "power_off"))
5673 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5675 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5677 if (!strcmp(res->mode_value, "bypass"))
5678 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5679 else if (!strcmp(res->mode_value, "isolate"))
5680 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5682 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5684 /* Set the watchdog timeout. */
5685 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5688 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5689 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5694 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5695 bypass_timeout, port_id, rc);
5699 /* Set the bypass event to transition to bypass mode. */
5700 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5705 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5709 cmdline_parse_token_string_t cmd_setbypass_event_set =
5710 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5712 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5713 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5715 cmdline_parse_token_string_t cmd_setbypass_event_event =
5716 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5718 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5719 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5720 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5721 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5722 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5724 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5725 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5726 mode_value, "normal#bypass#isolate");
5727 cmdline_parse_token_num_t cmd_setbypass_event_port =
5728 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5729 port_id, RTE_UINT16);
5731 cmdline_parse_inst_t cmd_set_bypass_event = {
5732 .f = cmd_set_bypass_event_parsed,
5733 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5734 "power_off mode normal|bypass|isolate <port_id>: "
5735 "Set the NIC bypass event mode for port_id",
5738 (void *)&cmd_setbypass_event_set,
5739 (void *)&cmd_setbypass_event_bypass,
5740 (void *)&cmd_setbypass_event_event,
5741 (void *)&cmd_setbypass_event_event_value,
5742 (void *)&cmd_setbypass_event_mode,
5743 (void *)&cmd_setbypass_event_mode_value,
5744 (void *)&cmd_setbypass_event_port,
5750 /* *** SET NIC BYPASS TIMEOUT *** */
5751 struct cmd_set_bypass_timeout_result {
5752 cmdline_fixed_string_t set;
5753 cmdline_fixed_string_t bypass;
5754 cmdline_fixed_string_t timeout;
5755 cmdline_fixed_string_t value;
5759 cmd_set_bypass_timeout_parsed(void *parsed_result,
5760 __rte_unused struct cmdline *cl,
5761 __rte_unused void *data)
5763 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5765 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5766 if (!strcmp(res->value, "1.5"))
5767 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5768 else if (!strcmp(res->value, "2"))
5769 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5770 else if (!strcmp(res->value, "3"))
5771 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5772 else if (!strcmp(res->value, "4"))
5773 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5774 else if (!strcmp(res->value, "8"))
5775 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5776 else if (!strcmp(res->value, "16"))
5777 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5778 else if (!strcmp(res->value, "32"))
5779 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5781 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5785 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5786 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5788 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5789 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5791 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5792 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5793 timeout, "timeout");
5794 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5795 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5796 value, "0#1.5#2#3#4#8#16#32");
5798 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5799 .f = cmd_set_bypass_timeout_parsed,
5800 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5801 "Set the NIC bypass watchdog timeout in seconds",
5804 (void *)&cmd_setbypass_timeout_set,
5805 (void *)&cmd_setbypass_timeout_bypass,
5806 (void *)&cmd_setbypass_timeout_timeout,
5807 (void *)&cmd_setbypass_timeout_value,
5812 /* *** SHOW NIC BYPASS MODE *** */
5813 struct cmd_show_bypass_config_result {
5814 cmdline_fixed_string_t show;
5815 cmdline_fixed_string_t bypass;
5816 cmdline_fixed_string_t config;
5821 cmd_show_bypass_config_parsed(void *parsed_result,
5822 __rte_unused struct cmdline *cl,
5823 __rte_unused void *data)
5825 struct cmd_show_bypass_config_result *res = parsed_result;
5826 portid_t port_id = res->port_id;
5828 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5829 uint32_t event_mode;
5830 uint32_t bypass_mode;
5831 uint32_t timeout = bypass_timeout;
5834 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5835 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5836 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5837 {"UNKNOWN", "normal", "bypass", "isolate"};
5838 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5846 /* Display the bypass mode.*/
5847 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5848 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5853 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5854 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5856 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5859 /* Display the bypass timeout.*/
5860 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5861 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5863 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5865 /* Display the bypass events and associated modes. */
5866 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5868 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5870 "\tFailed to get bypass mode for event = %s\n",
5873 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5874 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5876 printf("\tbypass event: %-16s = %s\n", events[i],
5883 "\tFailed to get bypass configuration for port = %d\n",
5887 cmdline_parse_token_string_t cmd_showbypass_config_show =
5888 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5890 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5891 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5893 cmdline_parse_token_string_t cmd_showbypass_config_config =
5894 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5896 cmdline_parse_token_num_t cmd_showbypass_config_port =
5897 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5898 port_id, RTE_UINT16);
5900 cmdline_parse_inst_t cmd_show_bypass_config = {
5901 .f = cmd_show_bypass_config_parsed,
5902 .help_str = "show bypass config <port_id>: "
5903 "Show the NIC bypass config for port_id",
5906 (void *)&cmd_showbypass_config_show,
5907 (void *)&cmd_showbypass_config_bypass,
5908 (void *)&cmd_showbypass_config_config,
5909 (void *)&cmd_showbypass_config_port,
5915 /* *** SET BONDING MODE *** */
5916 struct cmd_set_bonding_mode_result {
5917 cmdline_fixed_string_t set;
5918 cmdline_fixed_string_t bonding;
5919 cmdline_fixed_string_t mode;
5924 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5925 __rte_unused struct cmdline *cl,
5926 __rte_unused void *data)
5928 struct cmd_set_bonding_mode_result *res = parsed_result;
5929 portid_t port_id = res->port_id;
5930 struct rte_port *port = &ports[port_id];
5933 * Bonding mode changed means resources of device changed, like whether
5934 * started rte timer or not. Device should be restarted when resources
5935 * of device changed.
5937 if (port->port_status != RTE_PORT_STOPPED) {
5939 "\t Error: Can't set bonding mode when port %d is not stopped\n",
5944 /* Set the bonding mode for the relevant port. */
5945 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5946 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5950 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5951 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5953 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5954 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5955 bonding, "bonding");
5956 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5957 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5959 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5960 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5962 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5963 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5964 port_id, RTE_UINT16);
5966 cmdline_parse_inst_t cmd_set_bonding_mode = {
5967 .f = cmd_set_bonding_mode_parsed,
5968 .help_str = "set bonding mode <mode_value> <port_id>: "
5969 "Set the bonding mode for port_id",
5972 (void *) &cmd_setbonding_mode_set,
5973 (void *) &cmd_setbonding_mode_bonding,
5974 (void *) &cmd_setbonding_mode_mode,
5975 (void *) &cmd_setbonding_mode_value,
5976 (void *) &cmd_setbonding_mode_port,
5981 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5982 struct cmd_set_bonding_lacp_dedicated_queues_result {
5983 cmdline_fixed_string_t set;
5984 cmdline_fixed_string_t bonding;
5985 cmdline_fixed_string_t lacp;
5986 cmdline_fixed_string_t dedicated_queues;
5988 cmdline_fixed_string_t mode;
5991 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5992 __rte_unused struct cmdline *cl,
5993 __rte_unused void *data)
5995 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5996 portid_t port_id = res->port_id;
5997 struct rte_port *port;
5999 port = &ports[port_id];
6001 /** Check if the port is not started **/
6002 if (port->port_status != RTE_PORT_STOPPED) {
6003 fprintf(stderr, "Please stop port %d first\n", port_id);
6007 if (!strcmp(res->mode, "enable")) {
6008 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
6009 printf("Dedicate queues for LACP control packets"
6012 printf("Enabling dedicate queues for LACP control "
6013 "packets on port %d failed\n", port_id);
6014 } else if (!strcmp(res->mode, "disable")) {
6015 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
6016 printf("Dedicated queues for LACP control packets "
6019 printf("Disabling dedicated queues for LACP control "
6020 "traffic on port %d failed\n", port_id);
6024 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6025 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6027 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6028 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6029 bonding, "bonding");
6030 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6031 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6033 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6034 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6035 dedicated_queues, "dedicated_queues");
6036 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6037 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6038 port_id, RTE_UINT16);
6039 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6040 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6041 mode, "enable#disable");
6043 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6044 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6045 .help_str = "set bonding lacp dedicated_queues <port_id> "
6047 "Enable/disable dedicated queues for LACP control traffic for port_id",
6050 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6051 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6052 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6053 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6054 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6055 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6060 /* *** SET BALANCE XMIT POLICY *** */
6061 struct cmd_set_bonding_balance_xmit_policy_result {
6062 cmdline_fixed_string_t set;
6063 cmdline_fixed_string_t bonding;
6064 cmdline_fixed_string_t balance_xmit_policy;
6066 cmdline_fixed_string_t policy;
6069 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6070 __rte_unused struct cmdline *cl,
6071 __rte_unused void *data)
6073 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6074 portid_t port_id = res->port_id;
6077 if (!strcmp(res->policy, "l2")) {
6078 policy = BALANCE_XMIT_POLICY_LAYER2;
6079 } else if (!strcmp(res->policy, "l23")) {
6080 policy = BALANCE_XMIT_POLICY_LAYER23;
6081 } else if (!strcmp(res->policy, "l34")) {
6082 policy = BALANCE_XMIT_POLICY_LAYER34;
6084 fprintf(stderr, "\t Invalid xmit policy selection");
6088 /* Set the bonding mode for the relevant port. */
6089 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6091 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6096 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6097 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6099 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6100 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6101 bonding, "bonding");
6102 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6103 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6104 balance_xmit_policy, "balance_xmit_policy");
6105 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6106 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6107 port_id, RTE_UINT16);
6108 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6109 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6110 policy, "l2#l23#l34");
6112 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6113 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6114 .help_str = "set bonding balance_xmit_policy <port_id> "
6116 "Set the bonding balance_xmit_policy for port_id",
6119 (void *)&cmd_setbonding_balance_xmit_policy_set,
6120 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6121 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6122 (void *)&cmd_setbonding_balance_xmit_policy_port,
6123 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6128 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6129 struct cmd_show_bonding_lacp_info_result {
6130 cmdline_fixed_string_t show;
6131 cmdline_fixed_string_t bonding;
6132 cmdline_fixed_string_t lacp;
6133 cmdline_fixed_string_t info;
6137 static void port_param_show(struct port_params *params)
6139 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6141 printf("\t\tsystem priority: %u\n", params->system_priority);
6142 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6143 printf("\t\tsystem mac address: %s\n", buf);
6144 printf("\t\tport key: %u\n", params->key);
6145 printf("\t\tport priority: %u\n", params->port_priority);
6146 printf("\t\tport number: %u\n", params->port_number);
6149 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6151 char a_state[256] = { 0 };
6152 char p_state[256] = { 0 };
6157 static const char * const state[] = {
6167 static const char * const selection[] = {
6173 for (i = 0; i < RTE_DIM(state); i++) {
6174 if ((info->actor_state >> i) & 1)
6175 a_len += snprintf(&a_state[a_len],
6176 RTE_DIM(a_state) - a_len, "%s ",
6179 if ((info->partner_state >> i) & 1)
6180 p_len += snprintf(&p_state[p_len],
6181 RTE_DIM(p_state) - p_len, "%s ",
6184 printf("\tAggregator port id: %u\n", info->agg_port_id);
6185 printf("\tselection: %s\n", selection[info->selected]);
6186 printf("\tActor detail info:\n");
6187 port_param_show(&info->actor);
6188 printf("\t\tport state: %s\n", a_state);
6189 printf("\tPartner detail info:\n");
6190 port_param_show(&info->partner);
6191 printf("\t\tport state: %s\n", p_state);
6195 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6197 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6198 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6199 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6200 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6201 printf("\taggregate wait timeout: %u ms\n",
6202 conf->aggregate_wait_timeout_ms);
6203 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6204 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6205 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6206 switch (conf->agg_selection) {
6208 printf("\taggregation mode: bandwidth\n");
6211 printf("\taggregation mode: stable\n");
6214 printf("\taggregation mode: count\n");
6217 printf("\taggregation mode: invalid\n");
6224 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6225 __rte_unused struct cmdline *cl,
6226 __rte_unused void *data)
6228 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6229 struct rte_eth_bond_8023ad_slave_info slave_info;
6230 struct rte_eth_bond_8023ad_conf port_conf;
6231 portid_t slaves[RTE_MAX_ETHPORTS];
6232 portid_t port_id = res->port_id;
6233 int num_active_slaves;
6238 bonding_mode = rte_eth_bond_mode_get(port_id);
6239 if (bonding_mode != BONDING_MODE_8023AD) {
6240 fprintf(stderr, "\tBonding mode is not mode 4\n");
6244 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6246 if (num_active_slaves < 0) {
6247 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6251 if (num_active_slaves == 0)
6252 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6255 printf("\tIEEE802.3 port: %u\n", port_id);
6256 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6258 fprintf(stderr, "\tGet bonded device %u info failed\n",
6262 lacp_conf_show(&port_conf);
6264 for (i = 0; i < num_active_slaves; i++) {
6265 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6268 fprintf(stderr, "\tGet slave device %u info failed\n",
6272 printf("\tSlave Port: %u\n", slaves[i]);
6273 lacp_slave_info_show(&slave_info);
6277 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6278 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6280 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6281 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6282 bonding, "bonding");
6283 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6284 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6286 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6287 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6289 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6290 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6291 port_id, RTE_UINT16);
6293 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6294 .f = cmd_show_bonding_lacp_info_parsed,
6295 .help_str = "show bonding lacp info <port_id> : "
6296 "Show bonding IEEE802.3 information for port_id",
6299 (void *)&cmd_show_bonding_lacp_info_show,
6300 (void *)&cmd_show_bonding_lacp_info_bonding,
6301 (void *)&cmd_show_bonding_lacp_info_lacp,
6302 (void *)&cmd_show_bonding_lacp_info_info,
6303 (void *)&cmd_show_bonding_lacp_info_port_id,
6308 /* *** SHOW NIC BONDING CONFIGURATION *** */
6309 struct cmd_show_bonding_config_result {
6310 cmdline_fixed_string_t show;
6311 cmdline_fixed_string_t bonding;
6312 cmdline_fixed_string_t config;
6316 static void cmd_show_bonding_config_parsed(void *parsed_result,
6317 __rte_unused struct cmdline *cl,
6318 __rte_unused void *data)
6320 struct cmd_show_bonding_config_result *res = parsed_result;
6321 int bonding_mode, agg_mode;
6322 portid_t slaves[RTE_MAX_ETHPORTS];
6323 int num_slaves, num_active_slaves;
6326 portid_t port_id = res->port_id;
6328 /* Display the bonding mode.*/
6329 bonding_mode = rte_eth_bond_mode_get(port_id);
6330 if (bonding_mode < 0) {
6331 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6335 printf("\tBonding mode: %d\n", bonding_mode);
6337 if (bonding_mode == BONDING_MODE_BALANCE ||
6338 bonding_mode == BONDING_MODE_8023AD) {
6339 int balance_xmit_policy;
6341 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6342 if (balance_xmit_policy < 0) {
6344 "\tFailed to get balance xmit policy for port = %d\n",
6348 printf("\tBalance Xmit Policy: ");
6350 switch (balance_xmit_policy) {
6351 case BALANCE_XMIT_POLICY_LAYER2:
6352 printf("BALANCE_XMIT_POLICY_LAYER2");
6354 case BALANCE_XMIT_POLICY_LAYER23:
6355 printf("BALANCE_XMIT_POLICY_LAYER23");
6357 case BALANCE_XMIT_POLICY_LAYER34:
6358 printf("BALANCE_XMIT_POLICY_LAYER34");
6365 if (bonding_mode == BONDING_MODE_8023AD) {
6366 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6367 printf("\tIEEE802.3AD Aggregator Mode: ");
6370 printf("bandwidth");
6382 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6384 if (num_slaves < 0) {
6385 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6389 if (num_slaves > 0) {
6390 printf("\tSlaves (%d): [", num_slaves);
6391 for (i = 0; i < num_slaves - 1; i++)
6392 printf("%d ", slaves[i]);
6394 printf("%d]\n", slaves[num_slaves - 1]);
6396 printf("\tSlaves: []\n");
6400 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6403 if (num_active_slaves < 0) {
6405 "\tFailed to get active slave list for port = %d\n",
6409 if (num_active_slaves > 0) {
6410 printf("\tActive Slaves (%d): [", num_active_slaves);
6411 for (i = 0; i < num_active_slaves - 1; i++)
6412 printf("%d ", slaves[i]);
6414 printf("%d]\n", slaves[num_active_slaves - 1]);
6417 printf("\tActive Slaves: []\n");
6421 primary_id = rte_eth_bond_primary_get(port_id);
6422 if (primary_id < 0) {
6423 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6427 printf("\tPrimary: [%d]\n", primary_id);
6431 cmdline_parse_token_string_t cmd_showbonding_config_show =
6432 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6434 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6435 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6436 bonding, "bonding");
6437 cmdline_parse_token_string_t cmd_showbonding_config_config =
6438 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6440 cmdline_parse_token_num_t cmd_showbonding_config_port =
6441 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6442 port_id, RTE_UINT16);
6444 cmdline_parse_inst_t cmd_show_bonding_config = {
6445 .f = cmd_show_bonding_config_parsed,
6446 .help_str = "show bonding config <port_id>: "
6447 "Show the bonding config for port_id",
6450 (void *)&cmd_showbonding_config_show,
6451 (void *)&cmd_showbonding_config_bonding,
6452 (void *)&cmd_showbonding_config_config,
6453 (void *)&cmd_showbonding_config_port,
6458 /* *** SET BONDING PRIMARY *** */
6459 struct cmd_set_bonding_primary_result {
6460 cmdline_fixed_string_t set;
6461 cmdline_fixed_string_t bonding;
6462 cmdline_fixed_string_t primary;
6467 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6468 __rte_unused struct cmdline *cl,
6469 __rte_unused void *data)
6471 struct cmd_set_bonding_primary_result *res = parsed_result;
6472 portid_t master_port_id = res->port_id;
6473 portid_t slave_port_id = res->slave_id;
6475 /* Set the primary slave for a bonded device. */
6476 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6477 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6484 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6485 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6487 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6488 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6489 bonding, "bonding");
6490 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6491 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6492 primary, "primary");
6493 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6494 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6495 slave_id, RTE_UINT16);
6496 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6497 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6498 port_id, RTE_UINT16);
6500 cmdline_parse_inst_t cmd_set_bonding_primary = {
6501 .f = cmd_set_bonding_primary_parsed,
6502 .help_str = "set bonding primary <slave_id> <port_id>: "
6503 "Set the primary slave for port_id",
6506 (void *)&cmd_setbonding_primary_set,
6507 (void *)&cmd_setbonding_primary_bonding,
6508 (void *)&cmd_setbonding_primary_primary,
6509 (void *)&cmd_setbonding_primary_slave,
6510 (void *)&cmd_setbonding_primary_port,
6515 /* *** ADD SLAVE *** */
6516 struct cmd_add_bonding_slave_result {
6517 cmdline_fixed_string_t add;
6518 cmdline_fixed_string_t bonding;
6519 cmdline_fixed_string_t slave;
6524 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6525 __rte_unused struct cmdline *cl,
6526 __rte_unused void *data)
6528 struct cmd_add_bonding_slave_result *res = parsed_result;
6529 portid_t master_port_id = res->port_id;
6530 portid_t slave_port_id = res->slave_id;
6532 /* add the slave for a bonded device. */
6533 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6535 "\t Failed to add slave %d to master port = %d.\n",
6536 slave_port_id, master_port_id);
6540 set_port_slave_flag(slave_port_id);
6543 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6544 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6546 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6547 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6548 bonding, "bonding");
6549 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6550 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6552 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6553 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6554 slave_id, RTE_UINT16);
6555 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6556 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6557 port_id, RTE_UINT16);
6559 cmdline_parse_inst_t cmd_add_bonding_slave = {
6560 .f = cmd_add_bonding_slave_parsed,
6561 .help_str = "add bonding slave <slave_id> <port_id>: "
6562 "Add a slave device to a bonded device",
6565 (void *)&cmd_addbonding_slave_add,
6566 (void *)&cmd_addbonding_slave_bonding,
6567 (void *)&cmd_addbonding_slave_slave,
6568 (void *)&cmd_addbonding_slave_slaveid,
6569 (void *)&cmd_addbonding_slave_port,
6574 /* *** REMOVE SLAVE *** */
6575 struct cmd_remove_bonding_slave_result {
6576 cmdline_fixed_string_t remove;
6577 cmdline_fixed_string_t bonding;
6578 cmdline_fixed_string_t slave;
6583 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6584 __rte_unused struct cmdline *cl,
6585 __rte_unused void *data)
6587 struct cmd_remove_bonding_slave_result *res = parsed_result;
6588 portid_t master_port_id = res->port_id;
6589 portid_t slave_port_id = res->slave_id;
6591 /* remove the slave from a bonded device. */
6592 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6594 "\t Failed to remove slave %d from master port = %d.\n",
6595 slave_port_id, master_port_id);
6599 clear_port_slave_flag(slave_port_id);
6602 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6603 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6605 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6606 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6607 bonding, "bonding");
6608 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6609 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6611 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6612 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6613 slave_id, RTE_UINT16);
6614 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6615 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6616 port_id, RTE_UINT16);
6618 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6619 .f = cmd_remove_bonding_slave_parsed,
6620 .help_str = "remove bonding slave <slave_id> <port_id>: "
6621 "Remove a slave device from a bonded device",
6624 (void *)&cmd_removebonding_slave_remove,
6625 (void *)&cmd_removebonding_slave_bonding,
6626 (void *)&cmd_removebonding_slave_slave,
6627 (void *)&cmd_removebonding_slave_slaveid,
6628 (void *)&cmd_removebonding_slave_port,
6633 /* *** CREATE BONDED DEVICE *** */
6634 struct cmd_create_bonded_device_result {
6635 cmdline_fixed_string_t create;
6636 cmdline_fixed_string_t bonded;
6637 cmdline_fixed_string_t device;
6642 static int bond_dev_num = 0;
6644 static void cmd_create_bonded_device_parsed(void *parsed_result,
6645 __rte_unused struct cmdline *cl,
6646 __rte_unused void *data)
6648 struct cmd_create_bonded_device_result *res = parsed_result;
6649 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6653 if (test_done == 0) {
6654 fprintf(stderr, "Please stop forwarding first\n");
6658 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6661 /* Create a new bonded device. */
6662 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6664 fprintf(stderr, "\t Failed to create bonded device.\n");
6667 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6670 /* Update number of ports */
6671 nb_ports = rte_eth_dev_count_avail();
6672 reconfig(port_id, res->socket);
6673 ret = rte_eth_promiscuous_enable(port_id);
6676 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6677 port_id, rte_strerror(-ret));
6679 ports[port_id].bond_flag = 1;
6680 ports[port_id].need_setup = 0;
6681 ports[port_id].port_status = RTE_PORT_STOPPED;
6686 cmdline_parse_token_string_t cmd_createbonded_device_create =
6687 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6689 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6690 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6692 cmdline_parse_token_string_t cmd_createbonded_device_device =
6693 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6695 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6696 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6698 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6699 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6702 cmdline_parse_inst_t cmd_create_bonded_device = {
6703 .f = cmd_create_bonded_device_parsed,
6704 .help_str = "create bonded device <mode> <socket>: "
6705 "Create a new bonded device with specific bonding mode and socket",
6708 (void *)&cmd_createbonded_device_create,
6709 (void *)&cmd_createbonded_device_bonded,
6710 (void *)&cmd_createbonded_device_device,
6711 (void *)&cmd_createbonded_device_mode,
6712 (void *)&cmd_createbonded_device_socket,
6717 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6718 struct cmd_set_bond_mac_addr_result {
6719 cmdline_fixed_string_t set;
6720 cmdline_fixed_string_t bonding;
6721 cmdline_fixed_string_t mac_addr;
6723 struct rte_ether_addr address;
6726 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6727 __rte_unused struct cmdline *cl,
6728 __rte_unused void *data)
6730 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6733 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6736 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6738 /* check the return value and print it if is < 0 */
6740 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6744 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6745 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6746 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6747 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6749 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6750 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6752 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6753 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6754 port_num, RTE_UINT16);
6755 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6756 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6758 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6759 .f = cmd_set_bond_mac_addr_parsed,
6761 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6763 (void *)&cmd_set_bond_mac_addr_set,
6764 (void *)&cmd_set_bond_mac_addr_bonding,
6765 (void *)&cmd_set_bond_mac_addr_mac,
6766 (void *)&cmd_set_bond_mac_addr_portnum,
6767 (void *)&cmd_set_bond_mac_addr_addr,
6773 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6774 struct cmd_set_bond_mon_period_result {
6775 cmdline_fixed_string_t set;
6776 cmdline_fixed_string_t bonding;
6777 cmdline_fixed_string_t mon_period;
6782 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6783 __rte_unused struct cmdline *cl,
6784 __rte_unused void *data)
6786 struct cmd_set_bond_mon_period_result *res = parsed_result;
6789 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6791 /* check the return value and print it if is < 0 */
6793 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6797 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6798 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6800 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6801 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6802 bonding, "bonding");
6803 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6804 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6805 mon_period, "mon_period");
6806 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6807 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6808 port_num, RTE_UINT16);
6809 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6810 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6811 period_ms, RTE_UINT32);
6813 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6814 .f = cmd_set_bond_mon_period_parsed,
6816 .help_str = "set bonding mon_period <port_id> <period_ms>",
6818 (void *)&cmd_set_bond_mon_period_set,
6819 (void *)&cmd_set_bond_mon_period_bonding,
6820 (void *)&cmd_set_bond_mon_period_mon_period,
6821 (void *)&cmd_set_bond_mon_period_portnum,
6822 (void *)&cmd_set_bond_mon_period_period_ms,
6829 struct cmd_set_bonding_agg_mode_policy_result {
6830 cmdline_fixed_string_t set;
6831 cmdline_fixed_string_t bonding;
6832 cmdline_fixed_string_t agg_mode;
6834 cmdline_fixed_string_t policy;
6839 cmd_set_bonding_agg_mode(void *parsed_result,
6840 __rte_unused struct cmdline *cl,
6841 __rte_unused void *data)
6843 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6844 uint8_t policy = AGG_BANDWIDTH;
6846 if (!strcmp(res->policy, "bandwidth"))
6847 policy = AGG_BANDWIDTH;
6848 else if (!strcmp(res->policy, "stable"))
6849 policy = AGG_STABLE;
6850 else if (!strcmp(res->policy, "count"))
6853 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6857 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6858 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6860 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6861 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6862 bonding, "bonding");
6864 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6865 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6866 agg_mode, "agg_mode");
6868 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6869 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6870 port_num, RTE_UINT16);
6872 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6873 TOKEN_STRING_INITIALIZER(
6874 struct cmd_set_bonding_balance_xmit_policy_result,
6875 policy, "stable#bandwidth#count");
6877 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6878 .f = cmd_set_bonding_agg_mode,
6880 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6882 (void *)&cmd_set_bonding_agg_mode_set,
6883 (void *)&cmd_set_bonding_agg_mode_bonding,
6884 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6885 (void *)&cmd_set_bonding_agg_mode_portnum,
6886 (void *)&cmd_set_bonding_agg_mode_policy_string,
6892 #endif /* RTE_NET_BOND */
6894 /* *** SET FORWARDING MODE *** */
6895 struct cmd_set_fwd_mode_result {
6896 cmdline_fixed_string_t set;
6897 cmdline_fixed_string_t fwd;
6898 cmdline_fixed_string_t mode;
6901 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6902 __rte_unused struct cmdline *cl,
6903 __rte_unused void *data)
6905 struct cmd_set_fwd_mode_result *res = parsed_result;
6908 set_pkt_forwarding_mode(res->mode);
6911 cmdline_parse_token_string_t cmd_setfwd_set =
6912 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6913 cmdline_parse_token_string_t cmd_setfwd_fwd =
6914 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6915 cmdline_parse_token_string_t cmd_setfwd_mode =
6916 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6917 "" /* defined at init */);
6919 cmdline_parse_inst_t cmd_set_fwd_mode = {
6920 .f = cmd_set_fwd_mode_parsed,
6922 .help_str = NULL, /* defined at init */
6924 (void *)&cmd_setfwd_set,
6925 (void *)&cmd_setfwd_fwd,
6926 (void *)&cmd_setfwd_mode,
6931 static void cmd_set_fwd_mode_init(void)
6934 static char token[128];
6935 static char help[256];
6936 cmdline_parse_token_string_t *token_struct;
6938 modes = list_pkt_forwarding_modes();
6939 snprintf(help, sizeof(help), "set fwd %s: "
6940 "Set packet forwarding mode", modes);
6941 cmd_set_fwd_mode.help_str = help;
6943 /* string token separator is # */
6944 for (c = token; *modes != '\0'; modes++)
6949 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6950 token_struct->string_data.str = token;
6953 /* *** SET RETRY FORWARDING MODE *** */
6954 struct cmd_set_fwd_retry_mode_result {
6955 cmdline_fixed_string_t set;
6956 cmdline_fixed_string_t fwd;
6957 cmdline_fixed_string_t mode;
6958 cmdline_fixed_string_t retry;
6961 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6962 __rte_unused struct cmdline *cl,
6963 __rte_unused void *data)
6965 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6968 set_pkt_forwarding_mode(res->mode);
6971 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6972 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6974 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6975 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6977 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6978 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6980 "" /* defined at init */);
6981 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6982 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6985 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6986 .f = cmd_set_fwd_retry_mode_parsed,
6988 .help_str = NULL, /* defined at init */
6990 (void *)&cmd_setfwd_retry_set,
6991 (void *)&cmd_setfwd_retry_fwd,
6992 (void *)&cmd_setfwd_retry_mode,
6993 (void *)&cmd_setfwd_retry_retry,
6998 static void cmd_set_fwd_retry_mode_init(void)
7001 static char token[128];
7002 static char help[256];
7003 cmdline_parse_token_string_t *token_struct;
7005 modes = list_pkt_forwarding_retry_modes();
7006 snprintf(help, sizeof(help), "set fwd %s retry: "
7007 "Set packet forwarding mode with retry", modes);
7008 cmd_set_fwd_retry_mode.help_str = help;
7010 /* string token separator is # */
7011 for (c = token; *modes != '\0'; modes++)
7016 token_struct = (cmdline_parse_token_string_t *)
7017 cmd_set_fwd_retry_mode.tokens[2];
7018 token_struct->string_data.str = token;
7021 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
7022 struct cmd_set_burst_tx_retry_result {
7023 cmdline_fixed_string_t set;
7024 cmdline_fixed_string_t burst;
7025 cmdline_fixed_string_t tx;
7026 cmdline_fixed_string_t delay;
7028 cmdline_fixed_string_t retry;
7032 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7033 __rte_unused struct cmdline *cl,
7034 __rte_unused void *data)
7036 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7038 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7039 && !strcmp(res->tx, "tx")) {
7040 if (!strcmp(res->delay, "delay"))
7041 burst_tx_delay_time = res->time;
7042 if (!strcmp(res->retry, "retry"))
7043 burst_tx_retry_num = res->retry_num;
7048 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7049 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7050 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7051 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7053 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7054 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7055 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7056 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7057 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7058 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7060 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7061 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7062 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7063 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7066 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7067 .f = cmd_set_burst_tx_retry_parsed,
7068 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7070 (void *)&cmd_set_burst_tx_retry_set,
7071 (void *)&cmd_set_burst_tx_retry_burst,
7072 (void *)&cmd_set_burst_tx_retry_tx,
7073 (void *)&cmd_set_burst_tx_retry_delay,
7074 (void *)&cmd_set_burst_tx_retry_time,
7075 (void *)&cmd_set_burst_tx_retry_retry,
7076 (void *)&cmd_set_burst_tx_retry_retry_num,
7081 /* *** SET PROMISC MODE *** */
7082 struct cmd_set_promisc_mode_result {
7083 cmdline_fixed_string_t set;
7084 cmdline_fixed_string_t promisc;
7085 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7086 uint16_t port_num; /* valid if "allports" argument == 0 */
7087 cmdline_fixed_string_t mode;
7090 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7091 __rte_unused struct cmdline *cl,
7094 struct cmd_set_promisc_mode_result *res = parsed_result;
7098 if (!strcmp(res->mode, "on"))
7105 RTE_ETH_FOREACH_DEV(i)
7106 eth_set_promisc_mode(i, enable);
7108 eth_set_promisc_mode(res->port_num, enable);
7112 cmdline_parse_token_string_t cmd_setpromisc_set =
7113 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7114 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7115 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7117 cmdline_parse_token_string_t cmd_setpromisc_portall =
7118 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7120 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7121 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7123 cmdline_parse_token_string_t cmd_setpromisc_mode =
7124 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7127 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7128 .f = cmd_set_promisc_mode_parsed,
7130 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7132 (void *)&cmd_setpromisc_set,
7133 (void *)&cmd_setpromisc_promisc,
7134 (void *)&cmd_setpromisc_portall,
7135 (void *)&cmd_setpromisc_mode,
7140 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7141 .f = cmd_set_promisc_mode_parsed,
7143 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7145 (void *)&cmd_setpromisc_set,
7146 (void *)&cmd_setpromisc_promisc,
7147 (void *)&cmd_setpromisc_portnum,
7148 (void *)&cmd_setpromisc_mode,
7153 /* *** SET ALLMULTI MODE *** */
7154 struct cmd_set_allmulti_mode_result {
7155 cmdline_fixed_string_t set;
7156 cmdline_fixed_string_t allmulti;
7157 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7158 uint16_t port_num; /* valid if "allports" argument == 0 */
7159 cmdline_fixed_string_t mode;
7162 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7163 __rte_unused struct cmdline *cl,
7166 struct cmd_set_allmulti_mode_result *res = parsed_result;
7170 if (!strcmp(res->mode, "on"))
7177 RTE_ETH_FOREACH_DEV(i) {
7178 eth_set_allmulticast_mode(i, enable);
7182 eth_set_allmulticast_mode(res->port_num, enable);
7186 cmdline_parse_token_string_t cmd_setallmulti_set =
7187 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7188 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7189 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7191 cmdline_parse_token_string_t cmd_setallmulti_portall =
7192 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7194 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7195 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7197 cmdline_parse_token_string_t cmd_setallmulti_mode =
7198 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7201 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7202 .f = cmd_set_allmulti_mode_parsed,
7204 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7206 (void *)&cmd_setallmulti_set,
7207 (void *)&cmd_setallmulti_allmulti,
7208 (void *)&cmd_setallmulti_portall,
7209 (void *)&cmd_setallmulti_mode,
7214 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7215 .f = cmd_set_allmulti_mode_parsed,
7217 .help_str = "set allmulti <port_id> on|off: "
7218 "Set allmulti mode on port_id",
7220 (void *)&cmd_setallmulti_set,
7221 (void *)&cmd_setallmulti_allmulti,
7222 (void *)&cmd_setallmulti_portnum,
7223 (void *)&cmd_setallmulti_mode,
7228 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7229 struct cmd_link_flow_ctrl_show {
7230 cmdline_fixed_string_t show;
7231 cmdline_fixed_string_t port;
7233 cmdline_fixed_string_t flow_ctrl;
7236 cmdline_parse_token_string_t cmd_lfc_show_show =
7237 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7239 cmdline_parse_token_string_t cmd_lfc_show_port =
7240 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7242 cmdline_parse_token_num_t cmd_lfc_show_portid =
7243 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7244 port_id, RTE_UINT16);
7245 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7246 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7247 flow_ctrl, "flow_ctrl");
7250 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7251 __rte_unused struct cmdline *cl,
7252 __rte_unused void *data)
7254 struct cmd_link_flow_ctrl_show *res = parsed_result;
7255 static const char *info_border = "*********************";
7256 struct rte_eth_fc_conf fc_conf;
7257 bool rx_fc_en = false;
7258 bool tx_fc_en = false;
7261 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7264 "Failed to get current flow ctrl information: err = %d\n",
7269 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7271 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7274 printf("\n%s Flow control infos for port %-2d %s\n",
7275 info_border, res->port_id, info_border);
7276 printf("FC mode:\n");
7277 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7278 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7279 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7280 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7281 printf("High waterline: 0x%x\n", fc_conf.high_water);
7282 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7283 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7284 printf("Forward MAC control frames: %s\n",
7285 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7286 printf("\n%s************** End ***********%s\n",
7287 info_border, info_border);
7290 cmdline_parse_inst_t cmd_link_flow_control_show = {
7291 .f = cmd_link_flow_ctrl_show_parsed,
7293 .help_str = "show port <port_id> flow_ctrl",
7295 (void *)&cmd_lfc_show_show,
7296 (void *)&cmd_lfc_show_port,
7297 (void *)&cmd_lfc_show_portid,
7298 (void *)&cmd_lfc_show_flow_ctrl,
7303 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7304 struct cmd_link_flow_ctrl_set_result {
7305 cmdline_fixed_string_t set;
7306 cmdline_fixed_string_t flow_ctrl;
7307 cmdline_fixed_string_t rx;
7308 cmdline_fixed_string_t rx_lfc_mode;
7309 cmdline_fixed_string_t tx;
7310 cmdline_fixed_string_t tx_lfc_mode;
7311 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7312 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7313 cmdline_fixed_string_t autoneg_str;
7314 cmdline_fixed_string_t autoneg;
7315 cmdline_fixed_string_t hw_str;
7316 uint32_t high_water;
7317 cmdline_fixed_string_t lw_str;
7319 cmdline_fixed_string_t pt_str;
7320 uint16_t pause_time;
7321 cmdline_fixed_string_t xon_str;
7326 cmdline_parse_token_string_t cmd_lfc_set_set =
7327 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7329 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7330 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7331 flow_ctrl, "flow_ctrl");
7332 cmdline_parse_token_string_t cmd_lfc_set_rx =
7333 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7335 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7336 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7337 rx_lfc_mode, "on#off");
7338 cmdline_parse_token_string_t cmd_lfc_set_tx =
7339 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7341 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7342 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7343 tx_lfc_mode, "on#off");
7344 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7345 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7346 hw_str, "high_water");
7347 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7348 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7349 high_water, RTE_UINT32);
7350 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7351 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7352 lw_str, "low_water");
7353 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7354 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7355 low_water, RTE_UINT32);
7356 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7357 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7358 pt_str, "pause_time");
7359 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7360 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7361 pause_time, RTE_UINT16);
7362 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7363 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7364 xon_str, "send_xon");
7365 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7366 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7367 send_xon, RTE_UINT16);
7368 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7369 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7370 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7371 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7372 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7373 mac_ctrl_frame_fwd_mode, "on#off");
7374 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7375 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7376 autoneg_str, "autoneg");
7377 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7378 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7380 cmdline_parse_token_num_t cmd_lfc_set_portid =
7381 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7382 port_id, RTE_UINT16);
7384 /* forward declaration */
7386 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7389 cmdline_parse_inst_t cmd_link_flow_control_set = {
7390 .f = cmd_link_flow_ctrl_set_parsed,
7392 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7393 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7394 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7396 (void *)&cmd_lfc_set_set,
7397 (void *)&cmd_lfc_set_flow_ctrl,
7398 (void *)&cmd_lfc_set_rx,
7399 (void *)&cmd_lfc_set_rx_mode,
7400 (void *)&cmd_lfc_set_tx,
7401 (void *)&cmd_lfc_set_tx_mode,
7402 (void *)&cmd_lfc_set_high_water,
7403 (void *)&cmd_lfc_set_low_water,
7404 (void *)&cmd_lfc_set_pause_time,
7405 (void *)&cmd_lfc_set_send_xon,
7406 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7407 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7408 (void *)&cmd_lfc_set_autoneg_str,
7409 (void *)&cmd_lfc_set_autoneg,
7410 (void *)&cmd_lfc_set_portid,
7415 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7416 .f = cmd_link_flow_ctrl_set_parsed,
7417 .data = (void *)&cmd_link_flow_control_set_rx,
7418 .help_str = "set flow_ctrl rx on|off <port_id>: "
7419 "Change rx flow control parameter",
7421 (void *)&cmd_lfc_set_set,
7422 (void *)&cmd_lfc_set_flow_ctrl,
7423 (void *)&cmd_lfc_set_rx,
7424 (void *)&cmd_lfc_set_rx_mode,
7425 (void *)&cmd_lfc_set_portid,
7430 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7431 .f = cmd_link_flow_ctrl_set_parsed,
7432 .data = (void *)&cmd_link_flow_control_set_tx,
7433 .help_str = "set flow_ctrl tx on|off <port_id>: "
7434 "Change tx flow control parameter",
7436 (void *)&cmd_lfc_set_set,
7437 (void *)&cmd_lfc_set_flow_ctrl,
7438 (void *)&cmd_lfc_set_tx,
7439 (void *)&cmd_lfc_set_tx_mode,
7440 (void *)&cmd_lfc_set_portid,
7445 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7446 .f = cmd_link_flow_ctrl_set_parsed,
7447 .data = (void *)&cmd_link_flow_control_set_hw,
7448 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7449 "Change high water flow control parameter",
7451 (void *)&cmd_lfc_set_set,
7452 (void *)&cmd_lfc_set_flow_ctrl,
7453 (void *)&cmd_lfc_set_high_water_str,
7454 (void *)&cmd_lfc_set_high_water,
7455 (void *)&cmd_lfc_set_portid,
7460 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7461 .f = cmd_link_flow_ctrl_set_parsed,
7462 .data = (void *)&cmd_link_flow_control_set_lw,
7463 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7464 "Change low water flow control parameter",
7466 (void *)&cmd_lfc_set_set,
7467 (void *)&cmd_lfc_set_flow_ctrl,
7468 (void *)&cmd_lfc_set_low_water_str,
7469 (void *)&cmd_lfc_set_low_water,
7470 (void *)&cmd_lfc_set_portid,
7475 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7476 .f = cmd_link_flow_ctrl_set_parsed,
7477 .data = (void *)&cmd_link_flow_control_set_pt,
7478 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7479 "Change pause time flow control parameter",
7481 (void *)&cmd_lfc_set_set,
7482 (void *)&cmd_lfc_set_flow_ctrl,
7483 (void *)&cmd_lfc_set_pause_time_str,
7484 (void *)&cmd_lfc_set_pause_time,
7485 (void *)&cmd_lfc_set_portid,
7490 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7491 .f = cmd_link_flow_ctrl_set_parsed,
7492 .data = (void *)&cmd_link_flow_control_set_xon,
7493 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7494 "Change send_xon flow control parameter",
7496 (void *)&cmd_lfc_set_set,
7497 (void *)&cmd_lfc_set_flow_ctrl,
7498 (void *)&cmd_lfc_set_send_xon_str,
7499 (void *)&cmd_lfc_set_send_xon,
7500 (void *)&cmd_lfc_set_portid,
7505 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7506 .f = cmd_link_flow_ctrl_set_parsed,
7507 .data = (void *)&cmd_link_flow_control_set_macfwd,
7508 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7509 "Change mac ctrl fwd flow control parameter",
7511 (void *)&cmd_lfc_set_set,
7512 (void *)&cmd_lfc_set_flow_ctrl,
7513 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7514 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7515 (void *)&cmd_lfc_set_portid,
7520 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7521 .f = cmd_link_flow_ctrl_set_parsed,
7522 .data = (void *)&cmd_link_flow_control_set_autoneg,
7523 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7524 "Change autoneg flow control parameter",
7526 (void *)&cmd_lfc_set_set,
7527 (void *)&cmd_lfc_set_flow_ctrl,
7528 (void *)&cmd_lfc_set_autoneg_str,
7529 (void *)&cmd_lfc_set_autoneg,
7530 (void *)&cmd_lfc_set_portid,
7536 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7537 __rte_unused struct cmdline *cl,
7540 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7541 cmdline_parse_inst_t *cmd = data;
7542 struct rte_eth_fc_conf fc_conf;
7548 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7549 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7550 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7551 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7553 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7554 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7557 /* Partial command line, retrieve current configuration */
7559 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7562 "cannot get current flow ctrl parameters, return code = %d\n",
7567 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7568 (fc_conf.mode == RTE_ETH_FC_FULL))
7570 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7571 (fc_conf.mode == RTE_ETH_FC_FULL))
7575 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7576 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7578 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7579 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7581 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7583 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7584 fc_conf.high_water = res->high_water;
7586 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7587 fc_conf.low_water = res->low_water;
7589 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7590 fc_conf.pause_time = res->pause_time;
7592 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7593 fc_conf.send_xon = res->send_xon;
7595 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7596 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7597 fc_conf.mac_ctrl_frame_fwd = 1;
7599 fc_conf.mac_ctrl_frame_fwd = 0;
7602 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7603 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7605 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7608 "bad flow control parameter, return code = %d\n",
7612 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7613 struct cmd_priority_flow_ctrl_set_result {
7614 cmdline_fixed_string_t set;
7615 cmdline_fixed_string_t pfc_ctrl;
7616 cmdline_fixed_string_t rx;
7617 cmdline_fixed_string_t rx_pfc_mode;
7618 cmdline_fixed_string_t tx;
7619 cmdline_fixed_string_t tx_pfc_mode;
7620 uint32_t high_water;
7622 uint16_t pause_time;
7628 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7629 __rte_unused struct cmdline *cl,
7630 __rte_unused void *data)
7632 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7633 struct rte_eth_pfc_conf pfc_conf;
7634 int rx_fc_enable, tx_fc_enable;
7638 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7639 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7640 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7641 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7643 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7644 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7647 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7648 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7649 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7650 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7651 pfc_conf.fc.high_water = res->high_water;
7652 pfc_conf.fc.low_water = res->low_water;
7653 pfc_conf.fc.pause_time = res->pause_time;
7654 pfc_conf.priority = res->priority;
7656 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7659 "bad priority flow control parameter, return code = %d\n",
7663 cmdline_parse_token_string_t cmd_pfc_set_set =
7664 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7666 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7667 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7668 pfc_ctrl, "pfc_ctrl");
7669 cmdline_parse_token_string_t cmd_pfc_set_rx =
7670 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7672 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7673 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7674 rx_pfc_mode, "on#off");
7675 cmdline_parse_token_string_t cmd_pfc_set_tx =
7676 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7678 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7679 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7680 tx_pfc_mode, "on#off");
7681 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7682 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7683 high_water, RTE_UINT32);
7684 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7685 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7686 low_water, RTE_UINT32);
7687 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7688 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7689 pause_time, RTE_UINT16);
7690 cmdline_parse_token_num_t cmd_pfc_set_priority =
7691 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7692 priority, RTE_UINT8);
7693 cmdline_parse_token_num_t cmd_pfc_set_portid =
7694 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7695 port_id, RTE_UINT16);
7697 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7698 .f = cmd_priority_flow_ctrl_set_parsed,
7700 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7701 "<pause_time> <priority> <port_id>: "
7702 "Configure the Ethernet priority flow control",
7704 (void *)&cmd_pfc_set_set,
7705 (void *)&cmd_pfc_set_flow_ctrl,
7706 (void *)&cmd_pfc_set_rx,
7707 (void *)&cmd_pfc_set_rx_mode,
7708 (void *)&cmd_pfc_set_tx,
7709 (void *)&cmd_pfc_set_tx_mode,
7710 (void *)&cmd_pfc_set_high_water,
7711 (void *)&cmd_pfc_set_low_water,
7712 (void *)&cmd_pfc_set_pause_time,
7713 (void *)&cmd_pfc_set_priority,
7714 (void *)&cmd_pfc_set_portid,
7719 struct cmd_queue_priority_flow_ctrl_set_result {
7720 cmdline_fixed_string_t set;
7721 cmdline_fixed_string_t pfc_queue_ctrl;
7723 cmdline_fixed_string_t rx;
7724 cmdline_fixed_string_t rx_pfc_mode;
7727 cmdline_fixed_string_t tx;
7728 cmdline_fixed_string_t tx_pfc_mode;
7731 uint16_t pause_time;
7735 cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7736 __rte_unused struct cmdline *cl,
7737 __rte_unused void *data)
7739 struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7740 struct rte_eth_pfc_queue_conf pfc_queue_conf;
7741 int rx_fc_enable, tx_fc_enable;
7745 * Rx on/off, flow control is enabled/disabled on RX side. This can
7746 * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7747 * side. Tx on/off, flow control is enabled/disabled on TX side. This
7748 * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7751 static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7752 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7753 {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7756 memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7757 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7758 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7759 pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7760 pfc_queue_conf.rx_pause.tc = res->tx_tc;
7761 pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7762 pfc_queue_conf.tx_pause.tc = res->rx_tc;
7763 pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7764 pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7766 ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7770 "bad queue priority flow control parameter, rc = %d\n",
7775 cmdline_parse_token_string_t cmd_q_pfc_set_set =
7776 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7778 cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7779 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7780 pfc_queue_ctrl, "pfc_queue_ctrl");
7781 cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7782 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7783 port_id, RTE_UINT16);
7784 cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7785 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7787 cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7788 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7789 rx_pfc_mode, "on#off");
7790 cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7791 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7792 tx_qid, RTE_UINT16);
7793 cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7794 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7796 cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7797 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7799 cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7800 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7801 tx_pfc_mode, "on#off");
7802 cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7803 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7804 rx_qid, RTE_UINT16);
7805 cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7806 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7808 cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7809 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7810 pause_time, RTE_UINT16);
7812 cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7813 .f = cmd_queue_priority_flow_ctrl_set_parsed,
7815 .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7816 "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7817 "Configure the Ethernet queue priority flow control",
7819 (void *)&cmd_q_pfc_set_set,
7820 (void *)&cmd_q_pfc_set_flow_ctrl,
7821 (void *)&cmd_q_pfc_set_portid,
7822 (void *)&cmd_q_pfc_set_rx,
7823 (void *)&cmd_q_pfc_set_rx_mode,
7824 (void *)&cmd_q_pfc_set_tx_qid,
7825 (void *)&cmd_q_pfc_set_tx_tc,
7826 (void *)&cmd_q_pfc_set_tx,
7827 (void *)&cmd_q_pfc_set_tx_mode,
7828 (void *)&cmd_q_pfc_set_rx_qid,
7829 (void *)&cmd_q_pfc_set_rx_tc,
7830 (void *)&cmd_q_pfc_set_pause_time,
7835 /* *** RESET CONFIGURATION *** */
7836 struct cmd_reset_result {
7837 cmdline_fixed_string_t reset;
7838 cmdline_fixed_string_t def;
7841 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7843 __rte_unused void *data)
7845 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7846 set_def_fwd_config();
7849 cmdline_parse_token_string_t cmd_reset_set =
7850 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7851 cmdline_parse_token_string_t cmd_reset_def =
7852 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7855 cmdline_parse_inst_t cmd_reset = {
7856 .f = cmd_reset_parsed,
7858 .help_str = "set default: Reset default forwarding configuration",
7860 (void *)&cmd_reset_set,
7861 (void *)&cmd_reset_def,
7866 /* *** START FORWARDING *** */
7867 struct cmd_start_result {
7868 cmdline_fixed_string_t start;
7871 cmdline_parse_token_string_t cmd_start_start =
7872 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7874 static void cmd_start_parsed(__rte_unused void *parsed_result,
7875 __rte_unused struct cmdline *cl,
7876 __rte_unused void *data)
7878 start_packet_forwarding(0);
7881 cmdline_parse_inst_t cmd_start = {
7882 .f = cmd_start_parsed,
7884 .help_str = "start: Start packet forwarding",
7886 (void *)&cmd_start_start,
7891 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7892 struct cmd_start_tx_first_result {
7893 cmdline_fixed_string_t start;
7894 cmdline_fixed_string_t tx_first;
7898 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7899 __rte_unused struct cmdline *cl,
7900 __rte_unused void *data)
7902 start_packet_forwarding(1);
7905 cmdline_parse_token_string_t cmd_start_tx_first_start =
7906 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7908 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7909 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7910 tx_first, "tx_first");
7912 cmdline_parse_inst_t cmd_start_tx_first = {
7913 .f = cmd_start_tx_first_parsed,
7915 .help_str = "start tx_first: Start packet forwarding, "
7916 "after sending 1 burst of packets",
7918 (void *)&cmd_start_tx_first_start,
7919 (void *)&cmd_start_tx_first_tx_first,
7924 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7925 struct cmd_start_tx_first_n_result {
7926 cmdline_fixed_string_t start;
7927 cmdline_fixed_string_t tx_first;
7932 cmd_start_tx_first_n_parsed(void *parsed_result,
7933 __rte_unused struct cmdline *cl,
7934 __rte_unused void *data)
7936 struct cmd_start_tx_first_n_result *res = parsed_result;
7938 start_packet_forwarding(res->tx_num);
7941 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7942 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7944 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7945 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7946 tx_first, "tx_first");
7947 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7948 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7949 tx_num, RTE_UINT32);
7951 cmdline_parse_inst_t cmd_start_tx_first_n = {
7952 .f = cmd_start_tx_first_n_parsed,
7954 .help_str = "start tx_first <num>: "
7955 "packet forwarding, after sending <num> bursts of packets",
7957 (void *)&cmd_start_tx_first_n_start,
7958 (void *)&cmd_start_tx_first_n_tx_first,
7959 (void *)&cmd_start_tx_first_n_tx_num,
7964 /* *** SET LINK UP *** */
7965 struct cmd_set_link_up_result {
7966 cmdline_fixed_string_t set;
7967 cmdline_fixed_string_t link_up;
7968 cmdline_fixed_string_t port;
7972 cmdline_parse_token_string_t cmd_set_link_up_set =
7973 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7974 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7975 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7977 cmdline_parse_token_string_t cmd_set_link_up_port =
7978 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7979 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7980 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7983 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7984 __rte_unused struct cmdline *cl,
7985 __rte_unused void *data)
7987 struct cmd_set_link_up_result *res = parsed_result;
7988 dev_set_link_up(res->port_id);
7991 cmdline_parse_inst_t cmd_set_link_up = {
7992 .f = cmd_set_link_up_parsed,
7994 .help_str = "set link-up port <port id>",
7996 (void *)&cmd_set_link_up_set,
7997 (void *)&cmd_set_link_up_link_up,
7998 (void *)&cmd_set_link_up_port,
7999 (void *)&cmd_set_link_up_port_id,
8004 /* *** SET LINK DOWN *** */
8005 struct cmd_set_link_down_result {
8006 cmdline_fixed_string_t set;
8007 cmdline_fixed_string_t link_down;
8008 cmdline_fixed_string_t port;
8012 cmdline_parse_token_string_t cmd_set_link_down_set =
8013 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
8014 cmdline_parse_token_string_t cmd_set_link_down_link_down =
8015 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
8017 cmdline_parse_token_string_t cmd_set_link_down_port =
8018 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
8019 cmdline_parse_token_num_t cmd_set_link_down_port_id =
8020 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
8023 static void cmd_set_link_down_parsed(
8024 __rte_unused void *parsed_result,
8025 __rte_unused struct cmdline *cl,
8026 __rte_unused void *data)
8028 struct cmd_set_link_down_result *res = parsed_result;
8029 dev_set_link_down(res->port_id);
8032 cmdline_parse_inst_t cmd_set_link_down = {
8033 .f = cmd_set_link_down_parsed,
8035 .help_str = "set link-down port <port id>",
8037 (void *)&cmd_set_link_down_set,
8038 (void *)&cmd_set_link_down_link_down,
8039 (void *)&cmd_set_link_down_port,
8040 (void *)&cmd_set_link_down_port_id,
8045 /* *** SHOW CFG *** */
8046 struct cmd_showcfg_result {
8047 cmdline_fixed_string_t show;
8048 cmdline_fixed_string_t cfg;
8049 cmdline_fixed_string_t what;
8052 static void cmd_showcfg_parsed(void *parsed_result,
8053 __rte_unused struct cmdline *cl,
8054 __rte_unused void *data)
8056 struct cmd_showcfg_result *res = parsed_result;
8057 if (!strcmp(res->what, "rxtx"))
8058 rxtx_config_display();
8059 else if (!strcmp(res->what, "cores"))
8060 fwd_lcores_config_display();
8061 else if (!strcmp(res->what, "fwd"))
8062 pkt_fwd_config_display(&cur_fwd_config);
8063 else if (!strcmp(res->what, "rxoffs"))
8064 show_rx_pkt_offsets();
8065 else if (!strcmp(res->what, "rxpkts"))
8066 show_rx_pkt_segments();
8067 else if (!strcmp(res->what, "txpkts"))
8068 show_tx_pkt_segments();
8069 else if (!strcmp(res->what, "txtimes"))
8070 show_tx_pkt_times();
8073 cmdline_parse_token_string_t cmd_showcfg_show =
8074 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
8075 cmdline_parse_token_string_t cmd_showcfg_port =
8076 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
8077 cmdline_parse_token_string_t cmd_showcfg_what =
8078 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
8079 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
8081 cmdline_parse_inst_t cmd_showcfg = {
8082 .f = cmd_showcfg_parsed,
8084 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
8086 (void *)&cmd_showcfg_show,
8087 (void *)&cmd_showcfg_port,
8088 (void *)&cmd_showcfg_what,
8093 /* *** SHOW ALL PORT INFO *** */
8094 struct cmd_showportall_result {
8095 cmdline_fixed_string_t show;
8096 cmdline_fixed_string_t port;
8097 cmdline_fixed_string_t what;
8098 cmdline_fixed_string_t all;
8101 static void cmd_showportall_parsed(void *parsed_result,
8102 __rte_unused struct cmdline *cl,
8103 __rte_unused void *data)
8107 struct cmd_showportall_result *res = parsed_result;
8108 if (!strcmp(res->show, "clear")) {
8109 if (!strcmp(res->what, "stats"))
8110 RTE_ETH_FOREACH_DEV(i)
8112 else if (!strcmp(res->what, "xstats"))
8113 RTE_ETH_FOREACH_DEV(i)
8114 nic_xstats_clear(i);
8115 } else if (!strcmp(res->what, "info"))
8116 RTE_ETH_FOREACH_DEV(i)
8117 port_infos_display(i);
8118 else if (!strcmp(res->what, "summary")) {
8119 port_summary_header_display();
8120 RTE_ETH_FOREACH_DEV(i)
8121 port_summary_display(i);
8123 else if (!strcmp(res->what, "stats"))
8124 RTE_ETH_FOREACH_DEV(i)
8125 nic_stats_display(i);
8126 else if (!strcmp(res->what, "xstats"))
8127 RTE_ETH_FOREACH_DEV(i)
8128 nic_xstats_display(i);
8129 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8130 else if (!strcmp(res->what, "fdir"))
8131 RTE_ETH_FOREACH_DEV(i)
8134 else if (!strcmp(res->what, "dcb_tc"))
8135 RTE_ETH_FOREACH_DEV(i)
8136 port_dcb_info_display(i);
8139 cmdline_parse_token_string_t cmd_showportall_show =
8140 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
8142 cmdline_parse_token_string_t cmd_showportall_port =
8143 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8144 cmdline_parse_token_string_t cmd_showportall_what =
8145 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8146 "info#summary#stats#xstats#fdir#dcb_tc");
8147 cmdline_parse_token_string_t cmd_showportall_all =
8148 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8149 cmdline_parse_inst_t cmd_showportall = {
8150 .f = cmd_showportall_parsed,
8152 .help_str = "show|clear port "
8153 "info|summary|stats|xstats|fdir|dcb_tc all",
8155 (void *)&cmd_showportall_show,
8156 (void *)&cmd_showportall_port,
8157 (void *)&cmd_showportall_what,
8158 (void *)&cmd_showportall_all,
8163 /* *** SHOW PORT INFO *** */
8164 struct cmd_showport_result {
8165 cmdline_fixed_string_t show;
8166 cmdline_fixed_string_t port;
8167 cmdline_fixed_string_t what;
8171 static void cmd_showport_parsed(void *parsed_result,
8172 __rte_unused struct cmdline *cl,
8173 __rte_unused void *data)
8175 struct cmd_showport_result *res = parsed_result;
8176 if (!strcmp(res->show, "clear")) {
8177 if (!strcmp(res->what, "stats"))
8178 nic_stats_clear(res->portnum);
8179 else if (!strcmp(res->what, "xstats"))
8180 nic_xstats_clear(res->portnum);
8181 } else if (!strcmp(res->what, "info"))
8182 port_infos_display(res->portnum);
8183 else if (!strcmp(res->what, "summary")) {
8184 port_summary_header_display();
8185 port_summary_display(res->portnum);
8187 else if (!strcmp(res->what, "stats"))
8188 nic_stats_display(res->portnum);
8189 else if (!strcmp(res->what, "xstats"))
8190 nic_xstats_display(res->portnum);
8191 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8192 else if (!strcmp(res->what, "fdir"))
8193 fdir_get_infos(res->portnum);
8195 else if (!strcmp(res->what, "dcb_tc"))
8196 port_dcb_info_display(res->portnum);
8199 cmdline_parse_token_string_t cmd_showport_show =
8200 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8202 cmdline_parse_token_string_t cmd_showport_port =
8203 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8204 cmdline_parse_token_string_t cmd_showport_what =
8205 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8206 "info#summary#stats#xstats#fdir#dcb_tc");
8207 cmdline_parse_token_num_t cmd_showport_portnum =
8208 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8210 cmdline_parse_inst_t cmd_showport = {
8211 .f = cmd_showport_parsed,
8213 .help_str = "show|clear port "
8214 "info|summary|stats|xstats|fdir|dcb_tc "
8217 (void *)&cmd_showport_show,
8218 (void *)&cmd_showport_port,
8219 (void *)&cmd_showport_what,
8220 (void *)&cmd_showport_portnum,
8225 /* *** show port representors information *** */
8226 struct cmd_representor_info_result {
8227 cmdline_fixed_string_t cmd_show;
8228 cmdline_fixed_string_t cmd_port;
8229 cmdline_fixed_string_t cmd_info;
8230 cmdline_fixed_string_t cmd_keyword;
8235 cmd_representor_info_parsed(void *parsed_result,
8236 __rte_unused struct cmdline *cl,
8237 __rte_unused void *data)
8239 struct cmd_representor_info_result *res = parsed_result;
8240 struct rte_eth_representor_info *info;
8241 struct rte_eth_representor_range *range;
8242 uint32_t range_diff;
8247 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8248 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8252 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8255 "Failed to get the number of representor info ranges for port %hu: %s\n",
8256 res->cmd_pid, rte_strerror(-ret));
8261 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8264 "Failed to allocate memory for representor info for port %hu\n",
8268 info->nb_ranges_alloc = num;
8270 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8273 "Failed to get the representor info for port %hu: %s\n",
8274 res->cmd_pid, rte_strerror(-ret));
8279 printf("Port controller: %hu\n", info->controller);
8280 printf("Port PF: %hu\n", info->pf);
8282 printf("Ranges: %u\n", info->nb_ranges);
8283 for (i = 0; i < info->nb_ranges; i++) {
8284 range = &info->ranges[i];
8285 range_diff = range->id_end - range->id_base;
8287 printf("%u. ", i + 1);
8288 printf("'%s' ", range->name);
8290 printf("[%u-%u]: ", range->id_base, range->id_end);
8292 printf("[%u]: ", range->id_base);
8294 printf("Controller %d, PF %d", range->controller, range->pf);
8296 switch (range->type) {
8297 case RTE_ETH_REPRESENTOR_NONE:
8300 case RTE_ETH_REPRESENTOR_VF:
8302 printf(", VF %d..%d\n", range->vf,
8303 range->vf + range_diff);
8305 printf(", VF %d\n", range->vf);
8307 case RTE_ETH_REPRESENTOR_SF:
8308 printf(", SF %d\n", range->sf);
8310 case RTE_ETH_REPRESENTOR_PF:
8312 printf("..%d\n", range->pf + range_diff);
8317 printf(", UNKNOWN TYPE %d\n", range->type);
8325 cmdline_parse_token_string_t cmd_representor_info_show =
8326 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8328 cmdline_parse_token_string_t cmd_representor_info_port =
8329 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8331 cmdline_parse_token_string_t cmd_representor_info_info =
8332 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8334 cmdline_parse_token_num_t cmd_representor_info_pid =
8335 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8336 cmd_pid, RTE_UINT16);
8337 cmdline_parse_token_string_t cmd_representor_info_keyword =
8338 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8339 cmd_keyword, "representor");
8341 cmdline_parse_inst_t cmd_representor_info = {
8342 .f = cmd_representor_info_parsed,
8344 .help_str = "show port info <port_id> representor",
8346 (void *)&cmd_representor_info_show,
8347 (void *)&cmd_representor_info_port,
8348 (void *)&cmd_representor_info_info,
8349 (void *)&cmd_representor_info_pid,
8350 (void *)&cmd_representor_info_keyword,
8356 /* *** SHOW DEVICE INFO *** */
8357 struct cmd_showdevice_result {
8358 cmdline_fixed_string_t show;
8359 cmdline_fixed_string_t device;
8360 cmdline_fixed_string_t what;
8361 cmdline_fixed_string_t identifier;
8364 static void cmd_showdevice_parsed(void *parsed_result,
8365 __rte_unused struct cmdline *cl,
8366 __rte_unused void *data)
8368 struct cmd_showdevice_result *res = parsed_result;
8369 if (!strcmp(res->what, "info")) {
8370 if (!strcmp(res->identifier, "all"))
8371 device_infos_display(NULL);
8373 device_infos_display(res->identifier);
8377 cmdline_parse_token_string_t cmd_showdevice_show =
8378 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8380 cmdline_parse_token_string_t cmd_showdevice_device =
8381 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8382 cmdline_parse_token_string_t cmd_showdevice_what =
8383 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8385 cmdline_parse_token_string_t cmd_showdevice_identifier =
8386 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8389 cmdline_parse_inst_t cmd_showdevice = {
8390 .f = cmd_showdevice_parsed,
8392 .help_str = "show device info <identifier>|all",
8394 (void *)&cmd_showdevice_show,
8395 (void *)&cmd_showdevice_device,
8396 (void *)&cmd_showdevice_what,
8397 (void *)&cmd_showdevice_identifier,
8402 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8403 struct cmd_showeeprom_result {
8404 cmdline_fixed_string_t show;
8405 cmdline_fixed_string_t port;
8407 cmdline_fixed_string_t type;
8410 static void cmd_showeeprom_parsed(void *parsed_result,
8411 __rte_unused struct cmdline *cl,
8412 __rte_unused void *data)
8414 struct cmd_showeeprom_result *res = parsed_result;
8416 if (!strcmp(res->type, "eeprom"))
8417 port_eeprom_display(res->portnum);
8418 else if (!strcmp(res->type, "module_eeprom"))
8419 port_module_eeprom_display(res->portnum);
8421 fprintf(stderr, "Unknown argument\n");
8424 cmdline_parse_token_string_t cmd_showeeprom_show =
8425 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8426 cmdline_parse_token_string_t cmd_showeeprom_port =
8427 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8428 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8429 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8431 cmdline_parse_token_string_t cmd_showeeprom_type =
8432 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8434 cmdline_parse_inst_t cmd_showeeprom = {
8435 .f = cmd_showeeprom_parsed,
8437 .help_str = "show port <port_id> module_eeprom|eeprom",
8439 (void *)&cmd_showeeprom_show,
8440 (void *)&cmd_showeeprom_port,
8441 (void *)&cmd_showeeprom_portnum,
8442 (void *)&cmd_showeeprom_type,
8447 /* *** SHOW QUEUE INFO *** */
8448 struct cmd_showqueue_result {
8449 cmdline_fixed_string_t show;
8450 cmdline_fixed_string_t type;
8451 cmdline_fixed_string_t what;
8457 cmd_showqueue_parsed(void *parsed_result,
8458 __rte_unused struct cmdline *cl,
8459 __rte_unused void *data)
8461 struct cmd_showqueue_result *res = parsed_result;
8463 if (!strcmp(res->type, "rxq"))
8464 rx_queue_infos_display(res->portnum, res->queuenum);
8465 else if (!strcmp(res->type, "txq"))
8466 tx_queue_infos_display(res->portnum, res->queuenum);
8469 cmdline_parse_token_string_t cmd_showqueue_show =
8470 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8471 cmdline_parse_token_string_t cmd_showqueue_type =
8472 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8473 cmdline_parse_token_string_t cmd_showqueue_what =
8474 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8475 cmdline_parse_token_num_t cmd_showqueue_portnum =
8476 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8478 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8479 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8482 cmdline_parse_inst_t cmd_showqueue = {
8483 .f = cmd_showqueue_parsed,
8485 .help_str = "show rxq|txq info <port_id> <queue_id>",
8487 (void *)&cmd_showqueue_show,
8488 (void *)&cmd_showqueue_type,
8489 (void *)&cmd_showqueue_what,
8490 (void *)&cmd_showqueue_portnum,
8491 (void *)&cmd_showqueue_queuenum,
8496 /* show/clear fwd engine statistics */
8498 cmdline_fixed_string_t action;
8499 cmdline_fixed_string_t fwd;
8500 cmdline_fixed_string_t stats;
8501 cmdline_fixed_string_t all;
8504 cmdline_parse_token_string_t cmd_fwd_action =
8505 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8506 cmdline_parse_token_string_t cmd_fwd_fwd =
8507 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8508 cmdline_parse_token_string_t cmd_fwd_stats =
8509 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8510 cmdline_parse_token_string_t cmd_fwd_all =
8511 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8514 cmd_showfwdall_parsed(void *parsed_result,
8515 __rte_unused struct cmdline *cl,
8516 __rte_unused void *data)
8518 struct fwd_result *res = parsed_result;
8520 if (!strcmp(res->action, "show"))
8521 fwd_stats_display();
8526 static cmdline_parse_inst_t cmd_showfwdall = {
8527 .f = cmd_showfwdall_parsed,
8529 .help_str = "show|clear fwd stats all",
8531 (void *)&cmd_fwd_action,
8532 (void *)&cmd_fwd_fwd,
8533 (void *)&cmd_fwd_stats,
8534 (void *)&cmd_fwd_all,
8539 /* *** READ PORT REGISTER *** */
8540 struct cmd_read_reg_result {
8541 cmdline_fixed_string_t read;
8542 cmdline_fixed_string_t reg;
8548 cmd_read_reg_parsed(void *parsed_result,
8549 __rte_unused struct cmdline *cl,
8550 __rte_unused void *data)
8552 struct cmd_read_reg_result *res = parsed_result;
8553 port_reg_display(res->port_id, res->reg_off);
8556 cmdline_parse_token_string_t cmd_read_reg_read =
8557 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8558 cmdline_parse_token_string_t cmd_read_reg_reg =
8559 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8560 cmdline_parse_token_num_t cmd_read_reg_port_id =
8561 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8562 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8563 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8565 cmdline_parse_inst_t cmd_read_reg = {
8566 .f = cmd_read_reg_parsed,
8568 .help_str = "read reg <port_id> <reg_off>",
8570 (void *)&cmd_read_reg_read,
8571 (void *)&cmd_read_reg_reg,
8572 (void *)&cmd_read_reg_port_id,
8573 (void *)&cmd_read_reg_reg_off,
8578 /* *** READ PORT REGISTER BIT FIELD *** */
8579 struct cmd_read_reg_bit_field_result {
8580 cmdline_fixed_string_t read;
8581 cmdline_fixed_string_t regfield;
8589 cmd_read_reg_bit_field_parsed(void *parsed_result,
8590 __rte_unused struct cmdline *cl,
8591 __rte_unused void *data)
8593 struct cmd_read_reg_bit_field_result *res = parsed_result;
8594 port_reg_bit_field_display(res->port_id, res->reg_off,
8595 res->bit1_pos, res->bit2_pos);
8598 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8599 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8601 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8602 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8603 regfield, "regfield");
8604 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8605 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8607 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8608 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8610 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8611 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8613 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8614 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8617 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8618 .f = cmd_read_reg_bit_field_parsed,
8620 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8621 "Read register bit field between bit_x and bit_y included",
8623 (void *)&cmd_read_reg_bit_field_read,
8624 (void *)&cmd_read_reg_bit_field_regfield,
8625 (void *)&cmd_read_reg_bit_field_port_id,
8626 (void *)&cmd_read_reg_bit_field_reg_off,
8627 (void *)&cmd_read_reg_bit_field_bit1_pos,
8628 (void *)&cmd_read_reg_bit_field_bit2_pos,
8633 /* *** READ PORT REGISTER BIT *** */
8634 struct cmd_read_reg_bit_result {
8635 cmdline_fixed_string_t read;
8636 cmdline_fixed_string_t regbit;
8643 cmd_read_reg_bit_parsed(void *parsed_result,
8644 __rte_unused struct cmdline *cl,
8645 __rte_unused void *data)
8647 struct cmd_read_reg_bit_result *res = parsed_result;
8648 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8651 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8652 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8653 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8654 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8656 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8657 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8659 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8660 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8662 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8663 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8666 cmdline_parse_inst_t cmd_read_reg_bit = {
8667 .f = cmd_read_reg_bit_parsed,
8669 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8671 (void *)&cmd_read_reg_bit_read,
8672 (void *)&cmd_read_reg_bit_regbit,
8673 (void *)&cmd_read_reg_bit_port_id,
8674 (void *)&cmd_read_reg_bit_reg_off,
8675 (void *)&cmd_read_reg_bit_bit_pos,
8680 /* *** WRITE PORT REGISTER *** */
8681 struct cmd_write_reg_result {
8682 cmdline_fixed_string_t write;
8683 cmdline_fixed_string_t reg;
8690 cmd_write_reg_parsed(void *parsed_result,
8691 __rte_unused struct cmdline *cl,
8692 __rte_unused void *data)
8694 struct cmd_write_reg_result *res = parsed_result;
8695 port_reg_set(res->port_id, res->reg_off, res->value);
8698 cmdline_parse_token_string_t cmd_write_reg_write =
8699 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8700 cmdline_parse_token_string_t cmd_write_reg_reg =
8701 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8702 cmdline_parse_token_num_t cmd_write_reg_port_id =
8703 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8704 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8705 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8706 cmdline_parse_token_num_t cmd_write_reg_value =
8707 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8709 cmdline_parse_inst_t cmd_write_reg = {
8710 .f = cmd_write_reg_parsed,
8712 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8714 (void *)&cmd_write_reg_write,
8715 (void *)&cmd_write_reg_reg,
8716 (void *)&cmd_write_reg_port_id,
8717 (void *)&cmd_write_reg_reg_off,
8718 (void *)&cmd_write_reg_value,
8723 /* *** WRITE PORT REGISTER BIT FIELD *** */
8724 struct cmd_write_reg_bit_field_result {
8725 cmdline_fixed_string_t write;
8726 cmdline_fixed_string_t regfield;
8735 cmd_write_reg_bit_field_parsed(void *parsed_result,
8736 __rte_unused struct cmdline *cl,
8737 __rte_unused void *data)
8739 struct cmd_write_reg_bit_field_result *res = parsed_result;
8740 port_reg_bit_field_set(res->port_id, res->reg_off,
8741 res->bit1_pos, res->bit2_pos, res->value);
8744 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8745 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8747 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8748 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8749 regfield, "regfield");
8750 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8751 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8753 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8754 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8756 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8757 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8759 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8760 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8762 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8763 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8766 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8767 .f = cmd_write_reg_bit_field_parsed,
8769 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8771 "Set register bit field between bit_x and bit_y included",
8773 (void *)&cmd_write_reg_bit_field_write,
8774 (void *)&cmd_write_reg_bit_field_regfield,
8775 (void *)&cmd_write_reg_bit_field_port_id,
8776 (void *)&cmd_write_reg_bit_field_reg_off,
8777 (void *)&cmd_write_reg_bit_field_bit1_pos,
8778 (void *)&cmd_write_reg_bit_field_bit2_pos,
8779 (void *)&cmd_write_reg_bit_field_value,
8784 /* *** WRITE PORT REGISTER BIT *** */
8785 struct cmd_write_reg_bit_result {
8786 cmdline_fixed_string_t write;
8787 cmdline_fixed_string_t regbit;
8795 cmd_write_reg_bit_parsed(void *parsed_result,
8796 __rte_unused struct cmdline *cl,
8797 __rte_unused void *data)
8799 struct cmd_write_reg_bit_result *res = parsed_result;
8800 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8803 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8804 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8806 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8807 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8809 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8810 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8812 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8813 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8815 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8816 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8818 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8819 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8822 cmdline_parse_inst_t cmd_write_reg_bit = {
8823 .f = cmd_write_reg_bit_parsed,
8825 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8828 (void *)&cmd_write_reg_bit_write,
8829 (void *)&cmd_write_reg_bit_regbit,
8830 (void *)&cmd_write_reg_bit_port_id,
8831 (void *)&cmd_write_reg_bit_reg_off,
8832 (void *)&cmd_write_reg_bit_bit_pos,
8833 (void *)&cmd_write_reg_bit_value,
8838 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8839 struct cmd_read_rxd_txd_result {
8840 cmdline_fixed_string_t read;
8841 cmdline_fixed_string_t rxd_txd;
8848 cmd_read_rxd_txd_parsed(void *parsed_result,
8849 __rte_unused struct cmdline *cl,
8850 __rte_unused void *data)
8852 struct cmd_read_rxd_txd_result *res = parsed_result;
8854 if (!strcmp(res->rxd_txd, "rxd"))
8855 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8856 else if (!strcmp(res->rxd_txd, "txd"))
8857 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8860 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8861 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8862 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8863 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8865 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8866 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8868 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8869 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8871 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8872 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8875 cmdline_parse_inst_t cmd_read_rxd_txd = {
8876 .f = cmd_read_rxd_txd_parsed,
8878 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8880 (void *)&cmd_read_rxd_txd_read,
8881 (void *)&cmd_read_rxd_txd_rxd_txd,
8882 (void *)&cmd_read_rxd_txd_port_id,
8883 (void *)&cmd_read_rxd_txd_queue_id,
8884 (void *)&cmd_read_rxd_txd_desc_id,
8890 struct cmd_quit_result {
8891 cmdline_fixed_string_t quit;
8894 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8896 __rte_unused void *data)
8901 cmdline_parse_token_string_t cmd_quit_quit =
8902 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8904 cmdline_parse_inst_t cmd_quit = {
8905 .f = cmd_quit_parsed,
8907 .help_str = "quit: Exit application",
8909 (void *)&cmd_quit_quit,
8914 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8915 struct cmd_mac_addr_result {
8916 cmdline_fixed_string_t mac_addr_cmd;
8917 cmdline_fixed_string_t what;
8919 struct rte_ether_addr address;
8922 static void cmd_mac_addr_parsed(void *parsed_result,
8923 __rte_unused struct cmdline *cl,
8924 __rte_unused void *data)
8926 struct cmd_mac_addr_result *res = parsed_result;
8929 if (strcmp(res->what, "add") == 0)
8930 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8931 else if (strcmp(res->what, "set") == 0)
8932 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8935 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8937 /* check the return value and print it if is < 0 */
8939 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8943 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8944 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8946 cmdline_parse_token_string_t cmd_mac_addr_what =
8947 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8949 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8950 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8952 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8953 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8955 cmdline_parse_inst_t cmd_mac_addr = {
8956 .f = cmd_mac_addr_parsed,
8958 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8959 "Add/Remove/Set MAC address on port_id",
8961 (void *)&cmd_mac_addr_cmd,
8962 (void *)&cmd_mac_addr_what,
8963 (void *)&cmd_mac_addr_portnum,
8964 (void *)&cmd_mac_addr_addr,
8969 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8970 struct cmd_eth_peer_result {
8971 cmdline_fixed_string_t set;
8972 cmdline_fixed_string_t eth_peer;
8974 cmdline_fixed_string_t peer_addr;
8977 static void cmd_set_eth_peer_parsed(void *parsed_result,
8978 __rte_unused struct cmdline *cl,
8979 __rte_unused void *data)
8981 struct cmd_eth_peer_result *res = parsed_result;
8983 if (test_done == 0) {
8984 fprintf(stderr, "Please stop forwarding first\n");
8987 if (!strcmp(res->eth_peer, "eth-peer")) {
8988 set_fwd_eth_peer(res->port_id, res->peer_addr);
8992 cmdline_parse_token_string_t cmd_eth_peer_set =
8993 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8994 cmdline_parse_token_string_t cmd_eth_peer =
8995 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8996 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8997 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8999 cmdline_parse_token_string_t cmd_eth_peer_addr =
9000 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
9002 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
9003 .f = cmd_set_eth_peer_parsed,
9005 .help_str = "set eth-peer <port_id> <peer_mac>",
9007 (void *)&cmd_eth_peer_set,
9008 (void *)&cmd_eth_peer,
9009 (void *)&cmd_eth_peer_port_id,
9010 (void *)&cmd_eth_peer_addr,
9015 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
9016 struct cmd_set_qmap_result {
9017 cmdline_fixed_string_t set;
9018 cmdline_fixed_string_t qmap;
9019 cmdline_fixed_string_t what;
9026 cmd_set_qmap_parsed(void *parsed_result,
9027 __rte_unused struct cmdline *cl,
9028 __rte_unused void *data)
9030 struct cmd_set_qmap_result *res = parsed_result;
9031 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
9033 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
9036 cmdline_parse_token_string_t cmd_setqmap_set =
9037 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9039 cmdline_parse_token_string_t cmd_setqmap_qmap =
9040 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9042 cmdline_parse_token_string_t cmd_setqmap_what =
9043 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9045 cmdline_parse_token_num_t cmd_setqmap_portid =
9046 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9047 port_id, RTE_UINT16);
9048 cmdline_parse_token_num_t cmd_setqmap_queueid =
9049 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9050 queue_id, RTE_UINT16);
9051 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
9052 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9053 map_value, RTE_UINT8);
9055 cmdline_parse_inst_t cmd_set_qmap = {
9056 .f = cmd_set_qmap_parsed,
9058 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
9059 "Set statistics mapping value on tx|rx queue_id of port_id",
9061 (void *)&cmd_setqmap_set,
9062 (void *)&cmd_setqmap_qmap,
9063 (void *)&cmd_setqmap_what,
9064 (void *)&cmd_setqmap_portid,
9065 (void *)&cmd_setqmap_queueid,
9066 (void *)&cmd_setqmap_mapvalue,
9071 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
9072 struct cmd_set_xstats_hide_zero_result {
9073 cmdline_fixed_string_t keyword;
9074 cmdline_fixed_string_t name;
9075 cmdline_fixed_string_t on_off;
9079 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
9080 __rte_unused struct cmdline *cl,
9081 __rte_unused void *data)
9083 struct cmd_set_xstats_hide_zero_result *res;
9084 uint16_t on_off = 0;
9086 res = parsed_result;
9087 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9088 set_xstats_hide_zero(on_off);
9091 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
9092 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9094 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
9095 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9096 name, "xstats-hide-zero");
9097 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
9098 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9101 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
9102 .f = cmd_set_xstats_hide_zero_parsed,
9104 .help_str = "set xstats-hide-zero on|off",
9106 (void *)&cmd_set_xstats_hide_zero_keyword,
9107 (void *)&cmd_set_xstats_hide_zero_name,
9108 (void *)&cmd_set_xstats_hide_zero_on_off,
9113 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
9114 struct cmd_set_record_core_cycles_result {
9115 cmdline_fixed_string_t keyword;
9116 cmdline_fixed_string_t name;
9117 cmdline_fixed_string_t on_off;
9121 cmd_set_record_core_cycles_parsed(void *parsed_result,
9122 __rte_unused struct cmdline *cl,
9123 __rte_unused void *data)
9125 struct cmd_set_record_core_cycles_result *res;
9126 uint16_t on_off = 0;
9128 res = parsed_result;
9129 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9130 set_record_core_cycles(on_off);
9133 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
9134 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9136 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
9137 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9138 name, "record-core-cycles");
9139 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
9140 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9143 cmdline_parse_inst_t cmd_set_record_core_cycles = {
9144 .f = cmd_set_record_core_cycles_parsed,
9146 .help_str = "set record-core-cycles on|off",
9148 (void *)&cmd_set_record_core_cycles_keyword,
9149 (void *)&cmd_set_record_core_cycles_name,
9150 (void *)&cmd_set_record_core_cycles_on_off,
9155 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9156 struct cmd_set_record_burst_stats_result {
9157 cmdline_fixed_string_t keyword;
9158 cmdline_fixed_string_t name;
9159 cmdline_fixed_string_t on_off;
9163 cmd_set_record_burst_stats_parsed(void *parsed_result,
9164 __rte_unused struct cmdline *cl,
9165 __rte_unused void *data)
9167 struct cmd_set_record_burst_stats_result *res;
9168 uint16_t on_off = 0;
9170 res = parsed_result;
9171 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9172 set_record_burst_stats(on_off);
9175 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9176 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9178 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9179 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9180 name, "record-burst-stats");
9181 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9182 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9185 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9186 .f = cmd_set_record_burst_stats_parsed,
9188 .help_str = "set record-burst-stats on|off",
9190 (void *)&cmd_set_record_burst_stats_keyword,
9191 (void *)&cmd_set_record_burst_stats_name,
9192 (void *)&cmd_set_record_burst_stats_on_off,
9197 /* *** CONFIGURE UNICAST HASH TABLE *** */
9198 struct cmd_set_uc_hash_table {
9199 cmdline_fixed_string_t set;
9200 cmdline_fixed_string_t port;
9202 cmdline_fixed_string_t what;
9203 struct rte_ether_addr address;
9204 cmdline_fixed_string_t mode;
9208 cmd_set_uc_hash_parsed(void *parsed_result,
9209 __rte_unused struct cmdline *cl,
9210 __rte_unused void *data)
9213 struct cmd_set_uc_hash_table *res = parsed_result;
9215 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9217 if (strcmp(res->what, "uta") == 0)
9218 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9219 &res->address,(uint8_t)is_on);
9222 "bad unicast hash table parameter, return code = %d\n",
9227 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9228 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9230 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9231 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9233 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9234 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9235 port_id, RTE_UINT16);
9236 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9237 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9239 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9240 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9242 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9243 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9246 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9247 .f = cmd_set_uc_hash_parsed,
9249 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9251 (void *)&cmd_set_uc_hash_set,
9252 (void *)&cmd_set_uc_hash_port,
9253 (void *)&cmd_set_uc_hash_portid,
9254 (void *)&cmd_set_uc_hash_what,
9255 (void *)&cmd_set_uc_hash_mac,
9256 (void *)&cmd_set_uc_hash_mode,
9261 struct cmd_set_uc_all_hash_table {
9262 cmdline_fixed_string_t set;
9263 cmdline_fixed_string_t port;
9265 cmdline_fixed_string_t what;
9266 cmdline_fixed_string_t value;
9267 cmdline_fixed_string_t mode;
9271 cmd_set_uc_all_hash_parsed(void *parsed_result,
9272 __rte_unused struct cmdline *cl,
9273 __rte_unused void *data)
9276 struct cmd_set_uc_all_hash_table *res = parsed_result;
9278 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9280 if ((strcmp(res->what, "uta") == 0) &&
9281 (strcmp(res->value, "all") == 0))
9282 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9285 "bad unicast hash table parameter, return code = %d\n",
9289 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9290 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9292 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9293 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9295 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9296 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9297 port_id, RTE_UINT16);
9298 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9299 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9301 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9302 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9304 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9305 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9308 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9309 .f = cmd_set_uc_all_hash_parsed,
9311 .help_str = "set port <port_id> uta all on|off",
9313 (void *)&cmd_set_uc_all_hash_set,
9314 (void *)&cmd_set_uc_all_hash_port,
9315 (void *)&cmd_set_uc_all_hash_portid,
9316 (void *)&cmd_set_uc_all_hash_what,
9317 (void *)&cmd_set_uc_all_hash_value,
9318 (void *)&cmd_set_uc_all_hash_mode,
9323 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9324 struct cmd_set_vf_traffic {
9325 cmdline_fixed_string_t set;
9326 cmdline_fixed_string_t port;
9328 cmdline_fixed_string_t vf;
9330 cmdline_fixed_string_t what;
9331 cmdline_fixed_string_t mode;
9335 cmd_set_vf_traffic_parsed(void *parsed_result,
9336 __rte_unused struct cmdline *cl,
9337 __rte_unused void *data)
9339 struct cmd_set_vf_traffic *res = parsed_result;
9340 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9341 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9343 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9346 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9347 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9349 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9350 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9352 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9353 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9354 port_id, RTE_UINT16);
9355 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9356 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9358 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9359 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9361 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9362 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9364 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9365 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9368 cmdline_parse_inst_t cmd_set_vf_traffic = {
9369 .f = cmd_set_vf_traffic_parsed,
9371 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9373 (void *)&cmd_setvf_traffic_set,
9374 (void *)&cmd_setvf_traffic_port,
9375 (void *)&cmd_setvf_traffic_portid,
9376 (void *)&cmd_setvf_traffic_vf,
9377 (void *)&cmd_setvf_traffic_vfid,
9378 (void *)&cmd_setvf_traffic_what,
9379 (void *)&cmd_setvf_traffic_mode,
9384 /* *** CONFIGURE VF RECEIVE MODE *** */
9385 struct cmd_set_vf_rxmode {
9386 cmdline_fixed_string_t set;
9387 cmdline_fixed_string_t port;
9389 cmdline_fixed_string_t vf;
9391 cmdline_fixed_string_t what;
9392 cmdline_fixed_string_t mode;
9393 cmdline_fixed_string_t on;
9397 cmd_set_vf_rxmode_parsed(void *parsed_result,
9398 __rte_unused struct cmdline *cl,
9399 __rte_unused void *data)
9402 uint16_t vf_rxmode = 0;
9403 struct cmd_set_vf_rxmode *res = parsed_result;
9405 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9406 if (!strcmp(res->what,"rxmode")) {
9407 if (!strcmp(res->mode, "AUPE"))
9408 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9409 else if (!strcmp(res->mode, "ROPE"))
9410 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9411 else if (!strcmp(res->mode, "BAM"))
9412 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9413 else if (!strncmp(res->mode, "MPE",3))
9414 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9417 RTE_SET_USED(is_on);
9418 RTE_SET_USED(vf_rxmode);
9420 #ifdef RTE_NET_IXGBE
9421 if (ret == -ENOTSUP)
9422 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9423 vf_rxmode, (uint8_t)is_on);
9426 if (ret == -ENOTSUP)
9427 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9428 vf_rxmode, (uint8_t)is_on);
9432 "bad VF receive mode parameter, return code = %d\n",
9436 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9437 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9439 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9440 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9442 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9443 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9444 port_id, RTE_UINT16);
9445 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9446 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9448 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9449 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9451 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9452 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9454 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9455 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9456 mode, "AUPE#ROPE#BAM#MPE");
9457 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9458 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9461 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9462 .f = cmd_set_vf_rxmode_parsed,
9464 .help_str = "set port <port_id> vf <vf_id> rxmode "
9465 "AUPE|ROPE|BAM|MPE on|off",
9467 (void *)&cmd_set_vf_rxmode_set,
9468 (void *)&cmd_set_vf_rxmode_port,
9469 (void *)&cmd_set_vf_rxmode_portid,
9470 (void *)&cmd_set_vf_rxmode_vf,
9471 (void *)&cmd_set_vf_rxmode_vfid,
9472 (void *)&cmd_set_vf_rxmode_what,
9473 (void *)&cmd_set_vf_rxmode_mode,
9474 (void *)&cmd_set_vf_rxmode_on,
9479 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9480 struct cmd_vf_mac_addr_result {
9481 cmdline_fixed_string_t mac_addr_cmd;
9482 cmdline_fixed_string_t what;
9483 cmdline_fixed_string_t port;
9485 cmdline_fixed_string_t vf;
9487 struct rte_ether_addr address;
9490 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9491 __rte_unused struct cmdline *cl,
9492 __rte_unused void *data)
9494 struct cmd_vf_mac_addr_result *res = parsed_result;
9497 if (strcmp(res->what, "add") != 0)
9501 if (ret == -ENOTSUP)
9502 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9506 if (ret == -ENOTSUP)
9507 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9512 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9516 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9517 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9518 mac_addr_cmd,"mac_addr");
9519 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9520 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9522 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9523 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9525 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9526 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9527 port_num, RTE_UINT16);
9528 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9529 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9531 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9532 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9534 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9535 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9538 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9539 .f = cmd_vf_mac_addr_parsed,
9541 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9542 "Add MAC address filtering for a VF on port_id",
9544 (void *)&cmd_vf_mac_addr_cmd,
9545 (void *)&cmd_vf_mac_addr_what,
9546 (void *)&cmd_vf_mac_addr_port,
9547 (void *)&cmd_vf_mac_addr_portnum,
9548 (void *)&cmd_vf_mac_addr_vf,
9549 (void *)&cmd_vf_mac_addr_vfnum,
9550 (void *)&cmd_vf_mac_addr_addr,
9555 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9556 struct cmd_vf_rx_vlan_filter {
9557 cmdline_fixed_string_t rx_vlan;
9558 cmdline_fixed_string_t what;
9560 cmdline_fixed_string_t port;
9562 cmdline_fixed_string_t vf;
9567 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9568 __rte_unused struct cmdline *cl,
9569 __rte_unused void *data)
9571 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9574 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9576 #ifdef RTE_NET_IXGBE
9577 if (ret == -ENOTSUP)
9578 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9579 res->vlan_id, res->vf_mask, is_add);
9582 if (ret == -ENOTSUP)
9583 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9584 res->vlan_id, res->vf_mask, is_add);
9587 if (ret == -ENOTSUP)
9588 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9589 res->vlan_id, res->vf_mask, is_add);
9596 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9597 res->vlan_id, res->vf_mask);
9600 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9603 fprintf(stderr, "function not implemented or supported\n");
9606 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9610 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9611 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9612 rx_vlan, "rx_vlan");
9613 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9614 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9616 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9617 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9618 vlan_id, RTE_UINT16);
9619 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9620 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9622 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9623 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9624 port_id, RTE_UINT16);
9625 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9626 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9628 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9629 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9630 vf_mask, RTE_UINT64);
9632 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9633 .f = cmd_vf_rx_vlan_filter_parsed,
9635 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9636 "(vf_mask = hexadecimal VF mask)",
9638 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9639 (void *)&cmd_vf_rx_vlan_filter_what,
9640 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9641 (void *)&cmd_vf_rx_vlan_filter_port,
9642 (void *)&cmd_vf_rx_vlan_filter_portid,
9643 (void *)&cmd_vf_rx_vlan_filter_vf,
9644 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9649 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9650 struct cmd_queue_rate_limit_result {
9651 cmdline_fixed_string_t set;
9652 cmdline_fixed_string_t port;
9654 cmdline_fixed_string_t queue;
9656 cmdline_fixed_string_t rate;
9660 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9661 __rte_unused struct cmdline *cl,
9662 __rte_unused void *data)
9664 struct cmd_queue_rate_limit_result *res = parsed_result;
9667 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9668 && (strcmp(res->queue, "queue") == 0)
9669 && (strcmp(res->rate, "rate") == 0))
9670 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9673 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9678 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9679 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9681 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9682 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9684 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9685 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9686 port_num, RTE_UINT16);
9687 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9688 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9690 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9691 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9692 queue_num, RTE_UINT8);
9693 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9694 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9696 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9697 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9698 rate_num, RTE_UINT16);
9700 cmdline_parse_inst_t cmd_queue_rate_limit = {
9701 .f = cmd_queue_rate_limit_parsed,
9703 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9704 "Set rate limit for a queue on port_id",
9706 (void *)&cmd_queue_rate_limit_set,
9707 (void *)&cmd_queue_rate_limit_port,
9708 (void *)&cmd_queue_rate_limit_portnum,
9709 (void *)&cmd_queue_rate_limit_queue,
9710 (void *)&cmd_queue_rate_limit_queuenum,
9711 (void *)&cmd_queue_rate_limit_rate,
9712 (void *)&cmd_queue_rate_limit_ratenum,
9717 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9718 struct cmd_vf_rate_limit_result {
9719 cmdline_fixed_string_t set;
9720 cmdline_fixed_string_t port;
9722 cmdline_fixed_string_t vf;
9724 cmdline_fixed_string_t rate;
9726 cmdline_fixed_string_t q_msk;
9730 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9731 __rte_unused struct cmdline *cl,
9732 __rte_unused void *data)
9734 struct cmd_vf_rate_limit_result *res = parsed_result;
9737 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9738 && (strcmp(res->vf, "vf") == 0)
9739 && (strcmp(res->rate, "rate") == 0)
9740 && (strcmp(res->q_msk, "queue_mask") == 0))
9741 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9742 res->rate_num, res->q_msk_val);
9744 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9749 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9750 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9752 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9753 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9755 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9756 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9757 port_num, RTE_UINT16);
9758 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9759 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9761 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9762 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9764 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9765 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9767 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9768 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9769 rate_num, RTE_UINT16);
9770 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9771 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9772 q_msk, "queue_mask");
9773 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9774 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9775 q_msk_val, RTE_UINT64);
9777 cmdline_parse_inst_t cmd_vf_rate_limit = {
9778 .f = cmd_vf_rate_limit_parsed,
9780 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9781 "queue_mask <queue_mask_value>: "
9782 "Set rate limit for queues of VF on port_id",
9784 (void *)&cmd_vf_rate_limit_set,
9785 (void *)&cmd_vf_rate_limit_port,
9786 (void *)&cmd_vf_rate_limit_portnum,
9787 (void *)&cmd_vf_rate_limit_vf,
9788 (void *)&cmd_vf_rate_limit_vfnum,
9789 (void *)&cmd_vf_rate_limit_rate,
9790 (void *)&cmd_vf_rate_limit_ratenum,
9791 (void *)&cmd_vf_rate_limit_q_msk,
9792 (void *)&cmd_vf_rate_limit_q_msk_val,
9797 /* *** CONFIGURE TUNNEL UDP PORT *** */
9798 struct cmd_tunnel_udp_config {
9799 cmdline_fixed_string_t rx_vxlan_port;
9800 cmdline_fixed_string_t what;
9806 cmd_tunnel_udp_config_parsed(void *parsed_result,
9807 __rte_unused struct cmdline *cl,
9808 __rte_unused void *data)
9810 struct cmd_tunnel_udp_config *res = parsed_result;
9811 struct rte_eth_udp_tunnel tunnel_udp;
9814 tunnel_udp.udp_port = res->udp_port;
9815 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9817 if (!strcmp(res->what, "add"))
9818 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9821 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9825 fprintf(stderr, "udp tunneling add error: (%s)\n",
9829 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9830 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9831 rx_vxlan_port, "rx_vxlan_port");
9832 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9833 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9835 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9836 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9837 udp_port, RTE_UINT16);
9838 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9839 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9840 port_id, RTE_UINT16);
9842 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9843 .f = cmd_tunnel_udp_config_parsed,
9845 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9846 "Add/Remove a tunneling UDP port filter",
9848 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9849 (void *)&cmd_tunnel_udp_config_what,
9850 (void *)&cmd_tunnel_udp_config_udp_port,
9851 (void *)&cmd_tunnel_udp_config_port_id,
9856 struct cmd_config_tunnel_udp_port {
9857 cmdline_fixed_string_t port;
9858 cmdline_fixed_string_t config;
9860 cmdline_fixed_string_t udp_tunnel_port;
9861 cmdline_fixed_string_t action;
9862 cmdline_fixed_string_t tunnel_type;
9867 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9868 __rte_unused struct cmdline *cl,
9869 __rte_unused void *data)
9871 struct cmd_config_tunnel_udp_port *res = parsed_result;
9872 struct rte_eth_udp_tunnel tunnel_udp;
9875 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9878 tunnel_udp.udp_port = res->udp_port;
9880 if (!strcmp(res->tunnel_type, "vxlan")) {
9881 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9882 } else if (!strcmp(res->tunnel_type, "geneve")) {
9883 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9884 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9885 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9886 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9887 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9889 fprintf(stderr, "Invalid tunnel type\n");
9893 if (!strcmp(res->action, "add"))
9894 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9897 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9901 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9905 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9906 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9908 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9909 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9911 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9912 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9914 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9915 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9918 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9919 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9921 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9922 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9923 "vxlan#geneve#vxlan-gpe#ecpri");
9924 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9925 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9928 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9929 .f = cmd_cfg_tunnel_udp_port_parsed,
9931 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9932 "geneve|vxlan-gpe|ecpri <udp_port>",
9934 (void *)&cmd_config_tunnel_udp_port_port,
9935 (void *)&cmd_config_tunnel_udp_port_config,
9936 (void *)&cmd_config_tunnel_udp_port_port_id,
9937 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9938 (void *)&cmd_config_tunnel_udp_port_action,
9939 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9940 (void *)&cmd_config_tunnel_udp_port_value,
9945 /* ******************************************************************************** */
9947 struct cmd_dump_result {
9948 cmdline_fixed_string_t dump;
9952 dump_struct_sizes(void)
9954 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9955 DUMP_SIZE(struct rte_mbuf);
9956 DUMP_SIZE(struct rte_mempool);
9957 DUMP_SIZE(struct rte_ring);
9962 /* Dump the socket memory statistics on console */
9964 dump_socket_mem(FILE *f)
9966 struct rte_malloc_socket_stats socket_stats;
9971 unsigned int n_alloc = 0;
9972 unsigned int n_free = 0;
9973 static size_t last_allocs;
9974 static size_t last_total;
9977 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9978 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9979 !socket_stats.heap_totalsz_bytes)
9981 total += socket_stats.heap_totalsz_bytes;
9982 alloc += socket_stats.heap_allocsz_bytes;
9983 free += socket_stats.heap_freesz_bytes;
9984 n_alloc += socket_stats.alloc_count;
9985 n_free += socket_stats.free_count;
9987 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9989 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9990 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9991 (double)socket_stats.heap_allocsz_bytes * 100 /
9992 (double)socket_stats.heap_totalsz_bytes,
9993 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9994 socket_stats.alloc_count,
9995 socket_stats.free_count);
9998 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9999 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
10000 total ? ((double)alloc * 100 / (double)total) : 0,
10001 (double)free / (1024 * 1024),
10004 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
10005 ((double)total - (double)last_total) / (1024 * 1024),
10006 (double)(alloc - (double)last_allocs) / 1024 / 1024);
10007 last_allocs = alloc;
10008 last_total = total;
10011 static void cmd_dump_parsed(void *parsed_result,
10012 __rte_unused struct cmdline *cl,
10013 __rte_unused void *data)
10015 struct cmd_dump_result *res = parsed_result;
10017 if (!strcmp(res->dump, "dump_physmem"))
10018 rte_dump_physmem_layout(stdout);
10019 else if (!strcmp(res->dump, "dump_socket_mem"))
10020 dump_socket_mem(stdout);
10021 else if (!strcmp(res->dump, "dump_memzone"))
10022 rte_memzone_dump(stdout);
10023 else if (!strcmp(res->dump, "dump_struct_sizes"))
10024 dump_struct_sizes();
10025 else if (!strcmp(res->dump, "dump_ring"))
10026 rte_ring_list_dump(stdout);
10027 else if (!strcmp(res->dump, "dump_mempool"))
10028 rte_mempool_list_dump(stdout);
10029 else if (!strcmp(res->dump, "dump_devargs"))
10030 rte_devargs_dump(stdout);
10031 else if (!strcmp(res->dump, "dump_log_types"))
10032 rte_log_dump(stdout);
10035 cmdline_parse_token_string_t cmd_dump_dump =
10036 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
10040 "dump_struct_sizes#"
10046 cmdline_parse_inst_t cmd_dump = {
10047 .f = cmd_dump_parsed, /* function to call */
10048 .data = NULL, /* 2nd arg of func */
10049 .help_str = "Dump status",
10050 .tokens = { /* token list, NULL terminated */
10051 (void *)&cmd_dump_dump,
10056 /* ******************************************************************************** */
10058 struct cmd_dump_one_result {
10059 cmdline_fixed_string_t dump;
10060 cmdline_fixed_string_t name;
10063 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
10064 __rte_unused void *data)
10066 struct cmd_dump_one_result *res = parsed_result;
10068 if (!strcmp(res->dump, "dump_ring")) {
10069 struct rte_ring *r;
10070 r = rte_ring_lookup(res->name);
10072 cmdline_printf(cl, "Cannot find ring\n");
10075 rte_ring_dump(stdout, r);
10076 } else if (!strcmp(res->dump, "dump_mempool")) {
10077 struct rte_mempool *mp;
10078 mp = rte_mempool_lookup(res->name);
10080 cmdline_printf(cl, "Cannot find mempool\n");
10083 rte_mempool_dump(stdout, mp);
10087 cmdline_parse_token_string_t cmd_dump_one_dump =
10088 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
10089 "dump_ring#dump_mempool");
10091 cmdline_parse_token_string_t cmd_dump_one_name =
10092 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
10094 cmdline_parse_inst_t cmd_dump_one = {
10095 .f = cmd_dump_one_parsed, /* function to call */
10096 .data = NULL, /* 2nd arg of func */
10097 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
10098 .tokens = { /* token list, NULL terminated */
10099 (void *)&cmd_dump_one_dump,
10100 (void *)&cmd_dump_one_name,
10105 /* *** queue region set *** */
10106 struct cmd_queue_region_result {
10107 cmdline_fixed_string_t set;
10108 cmdline_fixed_string_t port;
10110 cmdline_fixed_string_t cmd;
10111 cmdline_fixed_string_t region;
10113 cmdline_fixed_string_t queue_start_index;
10115 cmdline_fixed_string_t queue_num;
10116 uint8_t queue_num_value;
10120 cmd_queue_region_parsed(void *parsed_result,
10121 __rte_unused struct cmdline *cl,
10122 __rte_unused void *data)
10124 struct cmd_queue_region_result *res = parsed_result;
10125 int ret = -ENOTSUP;
10126 #ifdef RTE_NET_I40E
10127 struct rte_pmd_i40e_queue_region_conf region_conf;
10128 enum rte_pmd_i40e_queue_region_op op_type;
10131 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10134 #ifdef RTE_NET_I40E
10135 memset(®ion_conf, 0, sizeof(region_conf));
10136 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10137 region_conf.region_id = res->region_id;
10138 region_conf.queue_num = res->queue_num_value;
10139 region_conf.queue_start_index = res->queue_id;
10141 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10142 op_type, ®ion_conf);
10149 fprintf(stderr, "function not implemented or supported\n");
10152 fprintf(stderr, "queue region config error: (%s)\n",
10157 cmdline_parse_token_string_t cmd_queue_region_set =
10158 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10160 cmdline_parse_token_string_t cmd_queue_region_port =
10161 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10162 cmdline_parse_token_num_t cmd_queue_region_port_id =
10163 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10164 port_id, RTE_UINT16);
10165 cmdline_parse_token_string_t cmd_queue_region_cmd =
10166 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10167 cmd, "queue-region");
10168 cmdline_parse_token_string_t cmd_queue_region_id =
10169 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10170 region, "region_id");
10171 cmdline_parse_token_num_t cmd_queue_region_index =
10172 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10173 region_id, RTE_UINT8);
10174 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10175 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10176 queue_start_index, "queue_start_index");
10177 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10178 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10179 queue_id, RTE_UINT8);
10180 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10181 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10182 queue_num, "queue_num");
10183 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10184 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10185 queue_num_value, RTE_UINT8);
10187 cmdline_parse_inst_t cmd_queue_region = {
10188 .f = cmd_queue_region_parsed,
10190 .help_str = "set port <port_id> queue-region region_id <value> "
10191 "queue_start_index <value> queue_num <value>: Set a queue region",
10193 (void *)&cmd_queue_region_set,
10194 (void *)&cmd_queue_region_port,
10195 (void *)&cmd_queue_region_port_id,
10196 (void *)&cmd_queue_region_cmd,
10197 (void *)&cmd_queue_region_id,
10198 (void *)&cmd_queue_region_index,
10199 (void *)&cmd_queue_region_queue_start_index,
10200 (void *)&cmd_queue_region_queue_id,
10201 (void *)&cmd_queue_region_queue_num,
10202 (void *)&cmd_queue_region_queue_num_value,
10207 /* *** queue region and flowtype set *** */
10208 struct cmd_region_flowtype_result {
10209 cmdline_fixed_string_t set;
10210 cmdline_fixed_string_t port;
10212 cmdline_fixed_string_t cmd;
10213 cmdline_fixed_string_t region;
10215 cmdline_fixed_string_t flowtype;
10216 uint8_t flowtype_id;
10220 cmd_region_flowtype_parsed(void *parsed_result,
10221 __rte_unused struct cmdline *cl,
10222 __rte_unused void *data)
10224 struct cmd_region_flowtype_result *res = parsed_result;
10225 int ret = -ENOTSUP;
10226 #ifdef RTE_NET_I40E
10227 struct rte_pmd_i40e_queue_region_conf region_conf;
10228 enum rte_pmd_i40e_queue_region_op op_type;
10231 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10234 #ifdef RTE_NET_I40E
10235 memset(®ion_conf, 0, sizeof(region_conf));
10237 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10238 region_conf.region_id = res->region_id;
10239 region_conf.hw_flowtype = res->flowtype_id;
10241 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10242 op_type, ®ion_conf);
10249 fprintf(stderr, "function not implemented or supported\n");
10252 fprintf(stderr, "region flowtype config error: (%s)\n",
10257 cmdline_parse_token_string_t cmd_region_flowtype_set =
10258 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10260 cmdline_parse_token_string_t cmd_region_flowtype_port =
10261 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10263 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10264 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10265 port_id, RTE_UINT16);
10266 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10267 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10268 cmd, "queue-region");
10269 cmdline_parse_token_string_t cmd_region_flowtype_index =
10270 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10271 region, "region_id");
10272 cmdline_parse_token_num_t cmd_region_flowtype_id =
10273 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10274 region_id, RTE_UINT8);
10275 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10276 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10277 flowtype, "flowtype");
10278 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10279 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10280 flowtype_id, RTE_UINT8);
10281 cmdline_parse_inst_t cmd_region_flowtype = {
10282 .f = cmd_region_flowtype_parsed,
10284 .help_str = "set port <port_id> queue-region region_id <value> "
10285 "flowtype <value>: Set a flowtype region index",
10287 (void *)&cmd_region_flowtype_set,
10288 (void *)&cmd_region_flowtype_port,
10289 (void *)&cmd_region_flowtype_port_index,
10290 (void *)&cmd_region_flowtype_cmd,
10291 (void *)&cmd_region_flowtype_index,
10292 (void *)&cmd_region_flowtype_id,
10293 (void *)&cmd_region_flowtype_flow_index,
10294 (void *)&cmd_region_flowtype_flow_id,
10299 /* *** User Priority (UP) to queue region (region_id) set *** */
10300 struct cmd_user_priority_region_result {
10301 cmdline_fixed_string_t set;
10302 cmdline_fixed_string_t port;
10304 cmdline_fixed_string_t cmd;
10305 cmdline_fixed_string_t user_priority;
10306 uint8_t user_priority_id;
10307 cmdline_fixed_string_t region;
10312 cmd_user_priority_region_parsed(void *parsed_result,
10313 __rte_unused struct cmdline *cl,
10314 __rte_unused void *data)
10316 struct cmd_user_priority_region_result *res = parsed_result;
10317 int ret = -ENOTSUP;
10318 #ifdef RTE_NET_I40E
10319 struct rte_pmd_i40e_queue_region_conf region_conf;
10320 enum rte_pmd_i40e_queue_region_op op_type;
10323 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10326 #ifdef RTE_NET_I40E
10327 memset(®ion_conf, 0, sizeof(region_conf));
10328 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10329 region_conf.user_priority = res->user_priority_id;
10330 region_conf.region_id = res->region_id;
10332 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10333 op_type, ®ion_conf);
10340 fprintf(stderr, "function not implemented or supported\n");
10343 fprintf(stderr, "user_priority region config error: (%s)\n",
10348 cmdline_parse_token_string_t cmd_user_priority_region_set =
10349 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10351 cmdline_parse_token_string_t cmd_user_priority_region_port =
10352 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10354 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10355 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10356 port_id, RTE_UINT16);
10357 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10358 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10359 cmd, "queue-region");
10360 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10361 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10362 user_priority, "UP");
10363 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10364 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10365 user_priority_id, RTE_UINT8);
10366 cmdline_parse_token_string_t cmd_user_priority_region_region =
10367 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10368 region, "region_id");
10369 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10370 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10371 region_id, RTE_UINT8);
10373 cmdline_parse_inst_t cmd_user_priority_region = {
10374 .f = cmd_user_priority_region_parsed,
10376 .help_str = "set port <port_id> queue-region UP <value> "
10377 "region_id <value>: Set the mapping of User Priority (UP) "
10378 "to queue region (region_id) ",
10380 (void *)&cmd_user_priority_region_set,
10381 (void *)&cmd_user_priority_region_port,
10382 (void *)&cmd_user_priority_region_port_index,
10383 (void *)&cmd_user_priority_region_cmd,
10384 (void *)&cmd_user_priority_region_UP,
10385 (void *)&cmd_user_priority_region_UP_id,
10386 (void *)&cmd_user_priority_region_region,
10387 (void *)&cmd_user_priority_region_region_id,
10392 /* *** flush all queue region related configuration *** */
10393 struct cmd_flush_queue_region_result {
10394 cmdline_fixed_string_t set;
10395 cmdline_fixed_string_t port;
10397 cmdline_fixed_string_t cmd;
10398 cmdline_fixed_string_t flush;
10399 cmdline_fixed_string_t what;
10403 cmd_flush_queue_region_parsed(void *parsed_result,
10404 __rte_unused struct cmdline *cl,
10405 __rte_unused void *data)
10407 struct cmd_flush_queue_region_result *res = parsed_result;
10408 int ret = -ENOTSUP;
10409 #ifdef RTE_NET_I40E
10410 struct rte_pmd_i40e_queue_region_conf region_conf;
10411 enum rte_pmd_i40e_queue_region_op op_type;
10414 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10417 #ifdef RTE_NET_I40E
10418 memset(®ion_conf, 0, sizeof(region_conf));
10420 if (strcmp(res->what, "on") == 0)
10421 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10423 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10425 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10426 op_type, ®ion_conf);
10433 fprintf(stderr, "function not implemented or supported\n");
10436 fprintf(stderr, "queue region config flush error: (%s)\n",
10441 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10442 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10444 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10445 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10447 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10448 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10449 port_id, RTE_UINT16);
10450 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10451 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10452 cmd, "queue-region");
10453 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10454 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10456 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10457 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10460 cmdline_parse_inst_t cmd_flush_queue_region = {
10461 .f = cmd_flush_queue_region_parsed,
10463 .help_str = "set port <port_id> queue-region flush on|off"
10464 ": flush all queue region related configuration",
10466 (void *)&cmd_flush_queue_region_set,
10467 (void *)&cmd_flush_queue_region_port,
10468 (void *)&cmd_flush_queue_region_port_index,
10469 (void *)&cmd_flush_queue_region_cmd,
10470 (void *)&cmd_flush_queue_region_flush,
10471 (void *)&cmd_flush_queue_region_what,
10476 /* *** get all queue region related configuration info *** */
10477 struct cmd_show_queue_region_info {
10478 cmdline_fixed_string_t show;
10479 cmdline_fixed_string_t port;
10481 cmdline_fixed_string_t cmd;
10485 cmd_show_queue_region_info_parsed(void *parsed_result,
10486 __rte_unused struct cmdline *cl,
10487 __rte_unused void *data)
10489 struct cmd_show_queue_region_info *res = parsed_result;
10490 int ret = -ENOTSUP;
10491 #ifdef RTE_NET_I40E
10492 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10493 enum rte_pmd_i40e_queue_region_op op_type;
10496 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10499 #ifdef RTE_NET_I40E
10500 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10502 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10504 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10505 op_type, &rte_pmd_regions);
10507 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10514 fprintf(stderr, "function not implemented or supported\n");
10517 fprintf(stderr, "queue region config info show error: (%s)\n",
10522 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10523 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10525 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10526 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10528 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10529 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10530 port_id, RTE_UINT16);
10531 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10532 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10533 cmd, "queue-region");
10535 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10536 .f = cmd_show_queue_region_info_parsed,
10538 .help_str = "show port <port_id> queue-region"
10539 ": show all queue region related configuration info",
10541 (void *)&cmd_show_queue_region_info_get,
10542 (void *)&cmd_show_queue_region_info_port,
10543 (void *)&cmd_show_queue_region_info_port_index,
10544 (void *)&cmd_show_queue_region_info_cmd,
10549 /* *** Filters Control *** */
10551 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10553 if ((ip_addr).family == AF_INET) \
10554 (ip) = (ip_addr).addr.ipv4.s_addr; \
10556 fprintf(stderr, "invalid parameter.\n"); \
10561 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10563 if ((ip_addr).family == AF_INET6) \
10564 rte_memcpy(&(ip), \
10565 &((ip_addr).addr.ipv6), \
10566 sizeof(struct in6_addr)); \
10568 fprintf(stderr, "invalid parameter.\n"); \
10573 #ifdef RTE_NET_I40E
10576 str2flowtype(char *string)
10579 static const struct {
10582 } flowtype_str[] = {
10583 {"raw", RTE_ETH_FLOW_RAW},
10584 {"ipv4", RTE_ETH_FLOW_IPV4},
10585 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10586 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10587 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10588 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10589 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10590 {"ipv6", RTE_ETH_FLOW_IPV6},
10591 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10592 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10593 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10594 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10595 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10596 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10597 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10598 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10599 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10600 {"gtpu", RTE_ETH_FLOW_GTPU},
10603 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10604 if (!strcmp(flowtype_str[i].str, string))
10605 return flowtype_str[i].type;
10608 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10609 return (uint16_t)atoi(string);
10611 return RTE_ETH_FLOW_UNKNOWN;
10614 /* *** deal with flow director filter *** */
10615 struct cmd_flow_director_result {
10616 cmdline_fixed_string_t flow_director_filter;
10618 cmdline_fixed_string_t mode;
10619 cmdline_fixed_string_t mode_value;
10620 cmdline_fixed_string_t ops;
10621 cmdline_fixed_string_t flow;
10622 cmdline_fixed_string_t flow_type;
10623 cmdline_fixed_string_t drop;
10624 cmdline_fixed_string_t queue;
10626 cmdline_fixed_string_t fd_id;
10627 uint32_t fd_id_value;
10628 cmdline_fixed_string_t packet;
10633 cmd_flow_director_filter_parsed(void *parsed_result,
10634 __rte_unused struct cmdline *cl,
10635 __rte_unused void *data)
10637 struct cmd_flow_director_result *res = parsed_result;
10639 struct rte_pmd_i40e_flow_type_mapping
10640 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10641 struct rte_pmd_i40e_pkt_template_conf conf;
10642 uint16_t flow_type = str2flowtype(res->flow_type);
10643 uint16_t i, port = res->port_id;
10646 memset(&conf, 0, sizeof(conf));
10648 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10649 fprintf(stderr, "Invalid flow type specified.\n");
10652 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10656 if (mapping[flow_type].pctype == 0ULL) {
10657 fprintf(stderr, "Invalid flow type specified.\n");
10660 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10661 if (mapping[flow_type].pctype & (1ULL << i)) {
10662 conf.input.pctype = i;
10667 conf.input.packet = open_file(res->filepath,
10668 &conf.input.length);
10669 if (!conf.input.packet)
10671 if (!strcmp(res->drop, "drop"))
10672 conf.action.behavior =
10673 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10675 conf.action.behavior =
10676 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10677 conf.action.report_status =
10678 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10679 conf.action.rx_queue = res->queue_id;
10680 conf.soft_id = res->fd_id_value;
10681 add = strcmp(res->ops, "del") ? 1 : 0;
10682 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10686 fprintf(stderr, "flow director config error: (%s)\n",
10688 close_file(conf.input.packet);
10691 cmdline_parse_token_string_t cmd_flow_director_filter =
10692 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10693 flow_director_filter, "flow_director_filter");
10694 cmdline_parse_token_num_t cmd_flow_director_port_id =
10695 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10696 port_id, RTE_UINT16);
10697 cmdline_parse_token_string_t cmd_flow_director_ops =
10698 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10699 ops, "add#del#update");
10700 cmdline_parse_token_string_t cmd_flow_director_flow =
10701 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10703 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10704 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10706 cmdline_parse_token_string_t cmd_flow_director_drop =
10707 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10709 cmdline_parse_token_string_t cmd_flow_director_queue =
10710 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10712 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10713 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10714 queue_id, RTE_UINT16);
10715 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10716 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10718 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10719 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10720 fd_id_value, RTE_UINT32);
10722 cmdline_parse_token_string_t cmd_flow_director_mode =
10723 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10725 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10726 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10727 mode_value, "raw");
10728 cmdline_parse_token_string_t cmd_flow_director_packet =
10729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10731 cmdline_parse_token_string_t cmd_flow_director_filepath =
10732 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10735 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10736 .f = cmd_flow_director_filter_parsed,
10738 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10739 "director entry on NIC",
10741 (void *)&cmd_flow_director_filter,
10742 (void *)&cmd_flow_director_port_id,
10743 (void *)&cmd_flow_director_mode,
10744 (void *)&cmd_flow_director_mode_raw,
10745 (void *)&cmd_flow_director_ops,
10746 (void *)&cmd_flow_director_flow,
10747 (void *)&cmd_flow_director_flow_type,
10748 (void *)&cmd_flow_director_drop,
10749 (void *)&cmd_flow_director_queue,
10750 (void *)&cmd_flow_director_queue_id,
10751 (void *)&cmd_flow_director_fd_id,
10752 (void *)&cmd_flow_director_fd_id_value,
10753 (void *)&cmd_flow_director_packet,
10754 (void *)&cmd_flow_director_filepath,
10759 #endif /* RTE_NET_I40E */
10761 /* *** deal with flow director mask *** */
10762 struct cmd_flow_director_mask_result {
10763 cmdline_fixed_string_t flow_director_mask;
10765 cmdline_fixed_string_t mode;
10766 cmdline_fixed_string_t mode_value;
10767 cmdline_fixed_string_t vlan;
10768 uint16_t vlan_mask;
10769 cmdline_fixed_string_t src_mask;
10770 cmdline_ipaddr_t ipv4_src;
10771 cmdline_ipaddr_t ipv6_src;
10773 cmdline_fixed_string_t dst_mask;
10774 cmdline_ipaddr_t ipv4_dst;
10775 cmdline_ipaddr_t ipv6_dst;
10777 cmdline_fixed_string_t mac;
10778 uint8_t mac_addr_byte_mask;
10779 cmdline_fixed_string_t tunnel_id;
10780 uint32_t tunnel_id_mask;
10781 cmdline_fixed_string_t tunnel_type;
10782 uint8_t tunnel_type_mask;
10786 cmd_flow_director_mask_parsed(void *parsed_result,
10787 __rte_unused struct cmdline *cl,
10788 __rte_unused void *data)
10790 struct cmd_flow_director_mask_result *res = parsed_result;
10791 struct rte_eth_fdir_masks *mask;
10792 struct rte_port *port;
10794 port = &ports[res->port_id];
10795 /** Check if the port is not started **/
10796 if (port->port_status != RTE_PORT_STOPPED) {
10797 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10801 mask = &port->dev_conf.fdir_conf.mask;
10803 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10804 if (strcmp(res->mode_value, "MAC-VLAN")) {
10805 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10809 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10810 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10811 if (strcmp(res->mode_value, "Tunnel")) {
10812 fprintf(stderr, "Please set mode to Tunnel.\n");
10816 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10817 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10818 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10819 mask->tunnel_type_mask = res->tunnel_type_mask;
10821 if (strcmp(res->mode_value, "IP")) {
10822 fprintf(stderr, "Please set mode to IP.\n");
10826 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10827 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10828 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10829 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10830 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10831 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10832 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10835 cmd_reconfig_device_queue(res->port_id, 1, 1);
10838 cmdline_parse_token_string_t cmd_flow_director_mask =
10839 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10840 flow_director_mask, "flow_director_mask");
10841 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10842 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10843 port_id, RTE_UINT16);
10844 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10845 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10847 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10848 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10849 vlan_mask, RTE_UINT16);
10850 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10851 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10852 src_mask, "src_mask");
10853 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10854 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10856 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10857 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10859 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10860 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10861 port_src, RTE_UINT16);
10862 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10864 dst_mask, "dst_mask");
10865 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10866 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10868 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10869 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10871 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10872 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10873 port_dst, RTE_UINT16);
10875 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10878 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10881 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10883 mode_value, "MAC-VLAN");
10884 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10886 mode_value, "Tunnel");
10887 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10888 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10890 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10891 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10892 mac_addr_byte_mask, RTE_UINT8);
10893 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10894 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10895 tunnel_type, "tunnel-type");
10896 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10897 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10898 tunnel_type_mask, RTE_UINT8);
10899 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10900 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10901 tunnel_id, "tunnel-id");
10902 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10903 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10904 tunnel_id_mask, RTE_UINT32);
10906 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10907 .f = cmd_flow_director_mask_parsed,
10909 .help_str = "flow_director_mask ... : "
10910 "Set IP mode flow director's mask on NIC",
10912 (void *)&cmd_flow_director_mask,
10913 (void *)&cmd_flow_director_mask_port_id,
10914 (void *)&cmd_flow_director_mask_mode,
10915 (void *)&cmd_flow_director_mask_mode_ip,
10916 (void *)&cmd_flow_director_mask_vlan,
10917 (void *)&cmd_flow_director_mask_vlan_value,
10918 (void *)&cmd_flow_director_mask_src,
10919 (void *)&cmd_flow_director_mask_ipv4_src,
10920 (void *)&cmd_flow_director_mask_ipv6_src,
10921 (void *)&cmd_flow_director_mask_port_src,
10922 (void *)&cmd_flow_director_mask_dst,
10923 (void *)&cmd_flow_director_mask_ipv4_dst,
10924 (void *)&cmd_flow_director_mask_ipv6_dst,
10925 (void *)&cmd_flow_director_mask_port_dst,
10930 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10931 .f = cmd_flow_director_mask_parsed,
10933 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10934 "flow director's mask on NIC",
10936 (void *)&cmd_flow_director_mask,
10937 (void *)&cmd_flow_director_mask_port_id,
10938 (void *)&cmd_flow_director_mask_mode,
10939 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10940 (void *)&cmd_flow_director_mask_vlan,
10941 (void *)&cmd_flow_director_mask_vlan_value,
10946 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10947 .f = cmd_flow_director_mask_parsed,
10949 .help_str = "flow_director_mask ... : Set tunnel mode "
10950 "flow director's mask on NIC",
10952 (void *)&cmd_flow_director_mask,
10953 (void *)&cmd_flow_director_mask_port_id,
10954 (void *)&cmd_flow_director_mask_mode,
10955 (void *)&cmd_flow_director_mask_mode_tunnel,
10956 (void *)&cmd_flow_director_mask_vlan,
10957 (void *)&cmd_flow_director_mask_vlan_value,
10958 (void *)&cmd_flow_director_mask_mac,
10959 (void *)&cmd_flow_director_mask_mac_value,
10960 (void *)&cmd_flow_director_mask_tunnel_type,
10961 (void *)&cmd_flow_director_mask_tunnel_type_value,
10962 (void *)&cmd_flow_director_mask_tunnel_id,
10963 (void *)&cmd_flow_director_mask_tunnel_id_value,
10968 /* *** deal with flow director flexible payload configuration *** */
10969 struct cmd_flow_director_flexpayload_result {
10970 cmdline_fixed_string_t flow_director_flexpayload;
10972 cmdline_fixed_string_t payload_layer;
10973 cmdline_fixed_string_t payload_cfg;
10977 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10980 const char *p, *p0 = q_arg;
10982 unsigned long int_fld;
10983 char *str_fld[max_num];
10988 p = strchr(p0, '(');
10992 p0 = strchr(p, ')');
10997 if (size >= sizeof(s))
11000 snprintf(s, sizeof(s), "%.*s", size, p);
11001 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11002 if (ret < 0 || ret > max_num)
11004 for (i = 0; i < ret; i++) {
11006 int_fld = strtoul(str_fld[i], &end, 0);
11007 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11009 offsets[i] = (uint16_t)int_fld;
11015 cmd_flow_director_flxpld_parsed(void *parsed_result,
11016 __rte_unused struct cmdline *cl,
11017 __rte_unused void *data)
11019 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11020 struct rte_eth_flex_payload_cfg flex_cfg;
11021 struct rte_port *port;
11024 port = &ports[res->port_id];
11025 /** Check if the port is not started **/
11026 if (port->port_status != RTE_PORT_STOPPED) {
11027 fprintf(stderr, "Please stop port %d first\n", res->port_id);
11031 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11033 if (!strcmp(res->payload_layer, "raw"))
11034 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11035 else if (!strcmp(res->payload_layer, "l2"))
11036 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11037 else if (!strcmp(res->payload_layer, "l3"))
11038 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11039 else if (!strcmp(res->payload_layer, "l4"))
11040 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11042 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11043 RTE_ETH_FDIR_MAX_FLEXLEN);
11045 fprintf(stderr, "error: Cannot parse flex payload input.\n");
11049 fdir_set_flex_payload(res->port_id, &flex_cfg);
11050 cmd_reconfig_device_queue(res->port_id, 1, 1);
11053 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11054 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11055 flow_director_flexpayload,
11056 "flow_director_flex_payload");
11057 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11058 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11059 port_id, RTE_UINT16);
11060 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11061 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11062 payload_layer, "raw#l2#l3#l4");
11063 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11064 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11065 payload_cfg, NULL);
11067 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11068 .f = cmd_flow_director_flxpld_parsed,
11070 .help_str = "flow_director_flexpayload ... : "
11071 "Set flow director's flex payload on NIC",
11073 (void *)&cmd_flow_director_flexpayload,
11074 (void *)&cmd_flow_director_flexpayload_port_id,
11075 (void *)&cmd_flow_director_flexpayload_payload_layer,
11076 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11081 /* Generic flow interface command. */
11082 extern cmdline_parse_inst_t cmd_flow;
11084 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11085 struct cmd_mcast_addr_result {
11086 cmdline_fixed_string_t mcast_addr_cmd;
11087 cmdline_fixed_string_t what;
11089 struct rte_ether_addr mc_addr;
11092 static void cmd_mcast_addr_parsed(void *parsed_result,
11093 __rte_unused struct cmdline *cl,
11094 __rte_unused void *data)
11096 struct cmd_mcast_addr_result *res = parsed_result;
11098 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11100 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
11101 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
11104 if (strcmp(res->what, "add") == 0)
11105 mcast_addr_add(res->port_num, &res->mc_addr);
11107 mcast_addr_remove(res->port_num, &res->mc_addr);
11110 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11111 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11112 mcast_addr_cmd, "mcast_addr");
11113 cmdline_parse_token_string_t cmd_mcast_addr_what =
11114 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11116 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11117 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
11119 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11120 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11122 cmdline_parse_inst_t cmd_mcast_addr = {
11123 .f = cmd_mcast_addr_parsed,
11125 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11126 "Add/Remove multicast MAC address on port_id",
11128 (void *)&cmd_mcast_addr_cmd,
11129 (void *)&cmd_mcast_addr_what,
11130 (void *)&cmd_mcast_addr_portnum,
11131 (void *)&cmd_mcast_addr_addr,
11136 /* vf vlan anti spoof configuration */
11138 /* Common result structure for vf vlan anti spoof */
11139 struct cmd_vf_vlan_anti_spoof_result {
11140 cmdline_fixed_string_t set;
11141 cmdline_fixed_string_t vf;
11142 cmdline_fixed_string_t vlan;
11143 cmdline_fixed_string_t antispoof;
11146 cmdline_fixed_string_t on_off;
11149 /* Common CLI fields for vf vlan anti spoof enable disable */
11150 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11151 TOKEN_STRING_INITIALIZER
11152 (struct cmd_vf_vlan_anti_spoof_result,
11154 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11155 TOKEN_STRING_INITIALIZER
11156 (struct cmd_vf_vlan_anti_spoof_result,
11158 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11159 TOKEN_STRING_INITIALIZER
11160 (struct cmd_vf_vlan_anti_spoof_result,
11162 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11163 TOKEN_STRING_INITIALIZER
11164 (struct cmd_vf_vlan_anti_spoof_result,
11165 antispoof, "antispoof");
11166 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11167 TOKEN_NUM_INITIALIZER
11168 (struct cmd_vf_vlan_anti_spoof_result,
11169 port_id, RTE_UINT16);
11170 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11171 TOKEN_NUM_INITIALIZER
11172 (struct cmd_vf_vlan_anti_spoof_result,
11173 vf_id, RTE_UINT32);
11174 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11175 TOKEN_STRING_INITIALIZER
11176 (struct cmd_vf_vlan_anti_spoof_result,
11180 cmd_set_vf_vlan_anti_spoof_parsed(
11181 void *parsed_result,
11182 __rte_unused struct cmdline *cl,
11183 __rte_unused void *data)
11185 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11186 int ret = -ENOTSUP;
11188 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11190 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11193 #ifdef RTE_NET_IXGBE
11194 if (ret == -ENOTSUP)
11195 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11196 res->vf_id, is_on);
11198 #ifdef RTE_NET_I40E
11199 if (ret == -ENOTSUP)
11200 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11201 res->vf_id, is_on);
11203 #ifdef RTE_NET_BNXT
11204 if (ret == -ENOTSUP)
11205 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11206 res->vf_id, is_on);
11213 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11216 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11219 fprintf(stderr, "function not implemented\n");
11222 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11226 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11227 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11229 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11231 (void *)&cmd_vf_vlan_anti_spoof_set,
11232 (void *)&cmd_vf_vlan_anti_spoof_vf,
11233 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11234 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11235 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11236 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11237 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11242 /* vf mac anti spoof configuration */
11244 /* Common result structure for vf mac anti spoof */
11245 struct cmd_vf_mac_anti_spoof_result {
11246 cmdline_fixed_string_t set;
11247 cmdline_fixed_string_t vf;
11248 cmdline_fixed_string_t mac;
11249 cmdline_fixed_string_t antispoof;
11252 cmdline_fixed_string_t on_off;
11255 /* Common CLI fields for vf mac anti spoof enable disable */
11256 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11257 TOKEN_STRING_INITIALIZER
11258 (struct cmd_vf_mac_anti_spoof_result,
11260 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11261 TOKEN_STRING_INITIALIZER
11262 (struct cmd_vf_mac_anti_spoof_result,
11264 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11265 TOKEN_STRING_INITIALIZER
11266 (struct cmd_vf_mac_anti_spoof_result,
11268 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11269 TOKEN_STRING_INITIALIZER
11270 (struct cmd_vf_mac_anti_spoof_result,
11271 antispoof, "antispoof");
11272 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11273 TOKEN_NUM_INITIALIZER
11274 (struct cmd_vf_mac_anti_spoof_result,
11275 port_id, RTE_UINT16);
11276 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11277 TOKEN_NUM_INITIALIZER
11278 (struct cmd_vf_mac_anti_spoof_result,
11279 vf_id, RTE_UINT32);
11280 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11281 TOKEN_STRING_INITIALIZER
11282 (struct cmd_vf_mac_anti_spoof_result,
11286 cmd_set_vf_mac_anti_spoof_parsed(
11287 void *parsed_result,
11288 __rte_unused struct cmdline *cl,
11289 __rte_unused void *data)
11291 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11292 int ret = -ENOTSUP;
11294 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11296 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11299 #ifdef RTE_NET_IXGBE
11300 if (ret == -ENOTSUP)
11301 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11302 res->vf_id, is_on);
11304 #ifdef RTE_NET_I40E
11305 if (ret == -ENOTSUP)
11306 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11307 res->vf_id, is_on);
11309 #ifdef RTE_NET_BNXT
11310 if (ret == -ENOTSUP)
11311 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11312 res->vf_id, is_on);
11319 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11320 res->vf_id, is_on);
11323 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11326 fprintf(stderr, "function not implemented\n");
11329 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11333 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11334 .f = cmd_set_vf_mac_anti_spoof_parsed,
11336 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11338 (void *)&cmd_vf_mac_anti_spoof_set,
11339 (void *)&cmd_vf_mac_anti_spoof_vf,
11340 (void *)&cmd_vf_mac_anti_spoof_mac,
11341 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11342 (void *)&cmd_vf_mac_anti_spoof_port_id,
11343 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11344 (void *)&cmd_vf_mac_anti_spoof_on_off,
11349 /* vf vlan strip queue configuration */
11351 /* Common result structure for vf mac anti spoof */
11352 struct cmd_vf_vlan_stripq_result {
11353 cmdline_fixed_string_t set;
11354 cmdline_fixed_string_t vf;
11355 cmdline_fixed_string_t vlan;
11356 cmdline_fixed_string_t stripq;
11359 cmdline_fixed_string_t on_off;
11362 /* Common CLI fields for vf vlan strip enable disable */
11363 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11364 TOKEN_STRING_INITIALIZER
11365 (struct cmd_vf_vlan_stripq_result,
11367 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11368 TOKEN_STRING_INITIALIZER
11369 (struct cmd_vf_vlan_stripq_result,
11371 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11372 TOKEN_STRING_INITIALIZER
11373 (struct cmd_vf_vlan_stripq_result,
11375 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11376 TOKEN_STRING_INITIALIZER
11377 (struct cmd_vf_vlan_stripq_result,
11379 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11380 TOKEN_NUM_INITIALIZER
11381 (struct cmd_vf_vlan_stripq_result,
11382 port_id, RTE_UINT16);
11383 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11384 TOKEN_NUM_INITIALIZER
11385 (struct cmd_vf_vlan_stripq_result,
11386 vf_id, RTE_UINT16);
11387 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11388 TOKEN_STRING_INITIALIZER
11389 (struct cmd_vf_vlan_stripq_result,
11393 cmd_set_vf_vlan_stripq_parsed(
11394 void *parsed_result,
11395 __rte_unused struct cmdline *cl,
11396 __rte_unused void *data)
11398 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11399 int ret = -ENOTSUP;
11401 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11403 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11406 #ifdef RTE_NET_IXGBE
11407 if (ret == -ENOTSUP)
11408 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11409 res->vf_id, is_on);
11411 #ifdef RTE_NET_I40E
11412 if (ret == -ENOTSUP)
11413 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11414 res->vf_id, is_on);
11416 #ifdef RTE_NET_BNXT
11417 if (ret == -ENOTSUP)
11418 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11419 res->vf_id, is_on);
11426 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11427 res->vf_id, is_on);
11430 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11433 fprintf(stderr, "function not implemented\n");
11436 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11440 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11441 .f = cmd_set_vf_vlan_stripq_parsed,
11443 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11445 (void *)&cmd_vf_vlan_stripq_set,
11446 (void *)&cmd_vf_vlan_stripq_vf,
11447 (void *)&cmd_vf_vlan_stripq_vlan,
11448 (void *)&cmd_vf_vlan_stripq_stripq,
11449 (void *)&cmd_vf_vlan_stripq_port_id,
11450 (void *)&cmd_vf_vlan_stripq_vf_id,
11451 (void *)&cmd_vf_vlan_stripq_on_off,
11456 /* vf vlan insert configuration */
11458 /* Common result structure for vf vlan insert */
11459 struct cmd_vf_vlan_insert_result {
11460 cmdline_fixed_string_t set;
11461 cmdline_fixed_string_t vf;
11462 cmdline_fixed_string_t vlan;
11463 cmdline_fixed_string_t insert;
11469 /* Common CLI fields for vf vlan insert enable disable */
11470 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11471 TOKEN_STRING_INITIALIZER
11472 (struct cmd_vf_vlan_insert_result,
11474 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11475 TOKEN_STRING_INITIALIZER
11476 (struct cmd_vf_vlan_insert_result,
11478 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11479 TOKEN_STRING_INITIALIZER
11480 (struct cmd_vf_vlan_insert_result,
11482 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11483 TOKEN_STRING_INITIALIZER
11484 (struct cmd_vf_vlan_insert_result,
11486 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11487 TOKEN_NUM_INITIALIZER
11488 (struct cmd_vf_vlan_insert_result,
11489 port_id, RTE_UINT16);
11490 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11491 TOKEN_NUM_INITIALIZER
11492 (struct cmd_vf_vlan_insert_result,
11493 vf_id, RTE_UINT16);
11494 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11495 TOKEN_NUM_INITIALIZER
11496 (struct cmd_vf_vlan_insert_result,
11497 vlan_id, RTE_UINT16);
11500 cmd_set_vf_vlan_insert_parsed(
11501 void *parsed_result,
11502 __rte_unused struct cmdline *cl,
11503 __rte_unused void *data)
11505 struct cmd_vf_vlan_insert_result *res = parsed_result;
11506 int ret = -ENOTSUP;
11508 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11511 #ifdef RTE_NET_IXGBE
11512 if (ret == -ENOTSUP)
11513 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11516 #ifdef RTE_NET_I40E
11517 if (ret == -ENOTSUP)
11518 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11521 #ifdef RTE_NET_BNXT
11522 if (ret == -ENOTSUP)
11523 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11531 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11532 res->vf_id, res->vlan_id);
11535 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11538 fprintf(stderr, "function not implemented\n");
11541 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11545 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11546 .f = cmd_set_vf_vlan_insert_parsed,
11548 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11550 (void *)&cmd_vf_vlan_insert_set,
11551 (void *)&cmd_vf_vlan_insert_vf,
11552 (void *)&cmd_vf_vlan_insert_vlan,
11553 (void *)&cmd_vf_vlan_insert_insert,
11554 (void *)&cmd_vf_vlan_insert_port_id,
11555 (void *)&cmd_vf_vlan_insert_vf_id,
11556 (void *)&cmd_vf_vlan_insert_vlan_id,
11561 /* tx loopback configuration */
11563 /* Common result structure for tx loopback */
11564 struct cmd_tx_loopback_result {
11565 cmdline_fixed_string_t set;
11566 cmdline_fixed_string_t tx;
11567 cmdline_fixed_string_t loopback;
11569 cmdline_fixed_string_t on_off;
11572 /* Common CLI fields for tx loopback enable disable */
11573 cmdline_parse_token_string_t cmd_tx_loopback_set =
11574 TOKEN_STRING_INITIALIZER
11575 (struct cmd_tx_loopback_result,
11577 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11578 TOKEN_STRING_INITIALIZER
11579 (struct cmd_tx_loopback_result,
11581 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11582 TOKEN_STRING_INITIALIZER
11583 (struct cmd_tx_loopback_result,
11584 loopback, "loopback");
11585 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11586 TOKEN_NUM_INITIALIZER
11587 (struct cmd_tx_loopback_result,
11588 port_id, RTE_UINT16);
11589 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11590 TOKEN_STRING_INITIALIZER
11591 (struct cmd_tx_loopback_result,
11595 cmd_set_tx_loopback_parsed(
11596 void *parsed_result,
11597 __rte_unused struct cmdline *cl,
11598 __rte_unused void *data)
11600 struct cmd_tx_loopback_result *res = parsed_result;
11601 int ret = -ENOTSUP;
11603 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11608 #ifdef RTE_NET_IXGBE
11609 if (ret == -ENOTSUP)
11610 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11612 #ifdef RTE_NET_I40E
11613 if (ret == -ENOTSUP)
11614 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11616 #ifdef RTE_NET_BNXT
11617 if (ret == -ENOTSUP)
11618 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11620 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11621 if (ret == -ENOTSUP)
11622 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11629 fprintf(stderr, "invalid is_on %d\n", is_on);
11632 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11635 fprintf(stderr, "function not implemented\n");
11638 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11642 cmdline_parse_inst_t cmd_set_tx_loopback = {
11643 .f = cmd_set_tx_loopback_parsed,
11645 .help_str = "set tx loopback <port_id> on|off",
11647 (void *)&cmd_tx_loopback_set,
11648 (void *)&cmd_tx_loopback_tx,
11649 (void *)&cmd_tx_loopback_loopback,
11650 (void *)&cmd_tx_loopback_port_id,
11651 (void *)&cmd_tx_loopback_on_off,
11656 /* all queues drop enable configuration */
11658 /* Common result structure for all queues drop enable */
11659 struct cmd_all_queues_drop_en_result {
11660 cmdline_fixed_string_t set;
11661 cmdline_fixed_string_t all;
11662 cmdline_fixed_string_t queues;
11663 cmdline_fixed_string_t drop;
11665 cmdline_fixed_string_t on_off;
11668 /* Common CLI fields for tx loopback enable disable */
11669 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11670 TOKEN_STRING_INITIALIZER
11671 (struct cmd_all_queues_drop_en_result,
11673 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11674 TOKEN_STRING_INITIALIZER
11675 (struct cmd_all_queues_drop_en_result,
11677 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11678 TOKEN_STRING_INITIALIZER
11679 (struct cmd_all_queues_drop_en_result,
11681 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11682 TOKEN_STRING_INITIALIZER
11683 (struct cmd_all_queues_drop_en_result,
11685 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11686 TOKEN_NUM_INITIALIZER
11687 (struct cmd_all_queues_drop_en_result,
11688 port_id, RTE_UINT16);
11689 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11690 TOKEN_STRING_INITIALIZER
11691 (struct cmd_all_queues_drop_en_result,
11695 cmd_set_all_queues_drop_en_parsed(
11696 void *parsed_result,
11697 __rte_unused struct cmdline *cl,
11698 __rte_unused void *data)
11700 struct cmd_all_queues_drop_en_result *res = parsed_result;
11701 int ret = -ENOTSUP;
11702 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11704 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11707 #ifdef RTE_NET_IXGBE
11708 if (ret == -ENOTSUP)
11709 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11711 #ifdef RTE_NET_BNXT
11712 if (ret == -ENOTSUP)
11713 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11719 fprintf(stderr, "invalid is_on %d\n", is_on);
11722 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11725 fprintf(stderr, "function not implemented\n");
11728 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11732 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11733 .f = cmd_set_all_queues_drop_en_parsed,
11735 .help_str = "set all queues drop <port_id> on|off",
11737 (void *)&cmd_all_queues_drop_en_set,
11738 (void *)&cmd_all_queues_drop_en_all,
11739 (void *)&cmd_all_queues_drop_en_queues,
11740 (void *)&cmd_all_queues_drop_en_drop,
11741 (void *)&cmd_all_queues_drop_en_port_id,
11742 (void *)&cmd_all_queues_drop_en_on_off,
11747 /* vf split drop enable configuration */
11749 /* Common result structure for vf split drop enable */
11750 struct cmd_vf_split_drop_en_result {
11751 cmdline_fixed_string_t set;
11752 cmdline_fixed_string_t vf;
11753 cmdline_fixed_string_t split;
11754 cmdline_fixed_string_t drop;
11757 cmdline_fixed_string_t on_off;
11760 /* Common CLI fields for vf split drop enable disable */
11761 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11762 TOKEN_STRING_INITIALIZER
11763 (struct cmd_vf_split_drop_en_result,
11765 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11766 TOKEN_STRING_INITIALIZER
11767 (struct cmd_vf_split_drop_en_result,
11769 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11770 TOKEN_STRING_INITIALIZER
11771 (struct cmd_vf_split_drop_en_result,
11773 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11774 TOKEN_STRING_INITIALIZER
11775 (struct cmd_vf_split_drop_en_result,
11777 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11778 TOKEN_NUM_INITIALIZER
11779 (struct cmd_vf_split_drop_en_result,
11780 port_id, RTE_UINT16);
11781 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11782 TOKEN_NUM_INITIALIZER
11783 (struct cmd_vf_split_drop_en_result,
11784 vf_id, RTE_UINT16);
11785 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11786 TOKEN_STRING_INITIALIZER
11787 (struct cmd_vf_split_drop_en_result,
11791 cmd_set_vf_split_drop_en_parsed(
11792 void *parsed_result,
11793 __rte_unused struct cmdline *cl,
11794 __rte_unused void *data)
11796 struct cmd_vf_split_drop_en_result *res = parsed_result;
11797 int ret = -ENOTSUP;
11798 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11803 #ifdef RTE_NET_IXGBE
11804 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11811 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11812 res->vf_id, is_on);
11815 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11818 fprintf(stderr, "not supported on port %d\n", res->port_id);
11821 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11825 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11826 .f = cmd_set_vf_split_drop_en_parsed,
11828 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11830 (void *)&cmd_vf_split_drop_en_set,
11831 (void *)&cmd_vf_split_drop_en_vf,
11832 (void *)&cmd_vf_split_drop_en_split,
11833 (void *)&cmd_vf_split_drop_en_drop,
11834 (void *)&cmd_vf_split_drop_en_port_id,
11835 (void *)&cmd_vf_split_drop_en_vf_id,
11836 (void *)&cmd_vf_split_drop_en_on_off,
11841 /* vf mac address configuration */
11843 /* Common result structure for vf mac address */
11844 struct cmd_set_vf_mac_addr_result {
11845 cmdline_fixed_string_t set;
11846 cmdline_fixed_string_t vf;
11847 cmdline_fixed_string_t mac;
11848 cmdline_fixed_string_t addr;
11851 struct rte_ether_addr mac_addr;
11855 /* Common CLI fields for vf split drop enable disable */
11856 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11857 TOKEN_STRING_INITIALIZER
11858 (struct cmd_set_vf_mac_addr_result,
11860 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11861 TOKEN_STRING_INITIALIZER
11862 (struct cmd_set_vf_mac_addr_result,
11864 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11865 TOKEN_STRING_INITIALIZER
11866 (struct cmd_set_vf_mac_addr_result,
11868 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11869 TOKEN_STRING_INITIALIZER
11870 (struct cmd_set_vf_mac_addr_result,
11872 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11873 TOKEN_NUM_INITIALIZER
11874 (struct cmd_set_vf_mac_addr_result,
11875 port_id, RTE_UINT16);
11876 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11877 TOKEN_NUM_INITIALIZER
11878 (struct cmd_set_vf_mac_addr_result,
11879 vf_id, RTE_UINT16);
11880 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11881 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11885 cmd_set_vf_mac_addr_parsed(
11886 void *parsed_result,
11887 __rte_unused struct cmdline *cl,
11888 __rte_unused void *data)
11890 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11891 int ret = -ENOTSUP;
11893 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11896 #ifdef RTE_NET_IXGBE
11897 if (ret == -ENOTSUP)
11898 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11901 #ifdef RTE_NET_I40E
11902 if (ret == -ENOTSUP)
11903 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11906 #ifdef RTE_NET_BNXT
11907 if (ret == -ENOTSUP)
11908 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11916 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11919 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11922 fprintf(stderr, "function not implemented\n");
11925 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11929 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11930 .f = cmd_set_vf_mac_addr_parsed,
11932 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11934 (void *)&cmd_set_vf_mac_addr_set,
11935 (void *)&cmd_set_vf_mac_addr_vf,
11936 (void *)&cmd_set_vf_mac_addr_mac,
11937 (void *)&cmd_set_vf_mac_addr_addr,
11938 (void *)&cmd_set_vf_mac_addr_port_id,
11939 (void *)&cmd_set_vf_mac_addr_vf_id,
11940 (void *)&cmd_set_vf_mac_addr_mac_addr,
11945 /* MACsec configuration */
11947 /* Common result structure for MACsec offload enable */
11948 struct cmd_macsec_offload_on_result {
11949 cmdline_fixed_string_t set;
11950 cmdline_fixed_string_t macsec;
11951 cmdline_fixed_string_t offload;
11953 cmdline_fixed_string_t on;
11954 cmdline_fixed_string_t encrypt;
11955 cmdline_fixed_string_t en_on_off;
11956 cmdline_fixed_string_t replay_protect;
11957 cmdline_fixed_string_t rp_on_off;
11960 /* Common CLI fields for MACsec offload disable */
11961 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11962 TOKEN_STRING_INITIALIZER
11963 (struct cmd_macsec_offload_on_result,
11965 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11966 TOKEN_STRING_INITIALIZER
11967 (struct cmd_macsec_offload_on_result,
11969 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11970 TOKEN_STRING_INITIALIZER
11971 (struct cmd_macsec_offload_on_result,
11972 offload, "offload");
11973 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11974 TOKEN_NUM_INITIALIZER
11975 (struct cmd_macsec_offload_on_result,
11976 port_id, RTE_UINT16);
11977 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11978 TOKEN_STRING_INITIALIZER
11979 (struct cmd_macsec_offload_on_result,
11981 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11982 TOKEN_STRING_INITIALIZER
11983 (struct cmd_macsec_offload_on_result,
11984 encrypt, "encrypt");
11985 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11986 TOKEN_STRING_INITIALIZER
11987 (struct cmd_macsec_offload_on_result,
11988 en_on_off, "on#off");
11989 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11990 TOKEN_STRING_INITIALIZER
11991 (struct cmd_macsec_offload_on_result,
11992 replay_protect, "replay-protect");
11993 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11994 TOKEN_STRING_INITIALIZER
11995 (struct cmd_macsec_offload_on_result,
11996 rp_on_off, "on#off");
11999 cmd_set_macsec_offload_on_parsed(
12000 void *parsed_result,
12001 __rte_unused struct cmdline *cl,
12002 __rte_unused void *data)
12004 struct cmd_macsec_offload_on_result *res = parsed_result;
12005 int ret = -ENOTSUP;
12006 portid_t port_id = res->port_id;
12007 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12008 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12009 struct rte_eth_dev_info dev_info;
12011 if (port_id_is_invalid(port_id, ENABLED_WARN))
12013 if (!port_is_stopped(port_id)) {
12014 fprintf(stderr, "Please stop port %d first\n", port_id);
12018 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12022 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12023 #ifdef RTE_NET_IXGBE
12024 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12032 ports[port_id].dev_conf.txmode.offloads |=
12033 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12034 cmd_reconfig_device_queue(port_id, 1, 1);
12037 fprintf(stderr, "invalid port_id %d\n", port_id);
12040 fprintf(stderr, "not supported on port %d\n", port_id);
12043 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12047 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12048 .f = cmd_set_macsec_offload_on_parsed,
12050 .help_str = "set macsec offload <port_id> on "
12051 "encrypt on|off replay-protect on|off",
12053 (void *)&cmd_macsec_offload_on_set,
12054 (void *)&cmd_macsec_offload_on_macsec,
12055 (void *)&cmd_macsec_offload_on_offload,
12056 (void *)&cmd_macsec_offload_on_port_id,
12057 (void *)&cmd_macsec_offload_on_on,
12058 (void *)&cmd_macsec_offload_on_encrypt,
12059 (void *)&cmd_macsec_offload_on_en_on_off,
12060 (void *)&cmd_macsec_offload_on_replay_protect,
12061 (void *)&cmd_macsec_offload_on_rp_on_off,
12066 /* Common result structure for MACsec offload disable */
12067 struct cmd_macsec_offload_off_result {
12068 cmdline_fixed_string_t set;
12069 cmdline_fixed_string_t macsec;
12070 cmdline_fixed_string_t offload;
12072 cmdline_fixed_string_t off;
12075 /* Common CLI fields for MACsec offload disable */
12076 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12077 TOKEN_STRING_INITIALIZER
12078 (struct cmd_macsec_offload_off_result,
12080 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12081 TOKEN_STRING_INITIALIZER
12082 (struct cmd_macsec_offload_off_result,
12084 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12085 TOKEN_STRING_INITIALIZER
12086 (struct cmd_macsec_offload_off_result,
12087 offload, "offload");
12088 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12089 TOKEN_NUM_INITIALIZER
12090 (struct cmd_macsec_offload_off_result,
12091 port_id, RTE_UINT16);
12092 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12093 TOKEN_STRING_INITIALIZER
12094 (struct cmd_macsec_offload_off_result,
12098 cmd_set_macsec_offload_off_parsed(
12099 void *parsed_result,
12100 __rte_unused struct cmdline *cl,
12101 __rte_unused void *data)
12103 struct cmd_macsec_offload_off_result *res = parsed_result;
12104 int ret = -ENOTSUP;
12105 struct rte_eth_dev_info dev_info;
12106 portid_t port_id = res->port_id;
12108 if (port_id_is_invalid(port_id, ENABLED_WARN))
12110 if (!port_is_stopped(port_id)) {
12111 fprintf(stderr, "Please stop port %d first\n", port_id);
12115 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12119 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12120 #ifdef RTE_NET_IXGBE
12121 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12126 ports[port_id].dev_conf.txmode.offloads &=
12127 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12128 cmd_reconfig_device_queue(port_id, 1, 1);
12131 fprintf(stderr, "invalid port_id %d\n", port_id);
12134 fprintf(stderr, "not supported on port %d\n", port_id);
12137 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12141 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12142 .f = cmd_set_macsec_offload_off_parsed,
12144 .help_str = "set macsec offload <port_id> off",
12146 (void *)&cmd_macsec_offload_off_set,
12147 (void *)&cmd_macsec_offload_off_macsec,
12148 (void *)&cmd_macsec_offload_off_offload,
12149 (void *)&cmd_macsec_offload_off_port_id,
12150 (void *)&cmd_macsec_offload_off_off,
12155 /* Common result structure for MACsec secure connection configure */
12156 struct cmd_macsec_sc_result {
12157 cmdline_fixed_string_t set;
12158 cmdline_fixed_string_t macsec;
12159 cmdline_fixed_string_t sc;
12160 cmdline_fixed_string_t tx_rx;
12162 struct rte_ether_addr mac;
12166 /* Common CLI fields for MACsec secure connection configure */
12167 cmdline_parse_token_string_t cmd_macsec_sc_set =
12168 TOKEN_STRING_INITIALIZER
12169 (struct cmd_macsec_sc_result,
12171 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12172 TOKEN_STRING_INITIALIZER
12173 (struct cmd_macsec_sc_result,
12175 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12176 TOKEN_STRING_INITIALIZER
12177 (struct cmd_macsec_sc_result,
12179 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12180 TOKEN_STRING_INITIALIZER
12181 (struct cmd_macsec_sc_result,
12183 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12184 TOKEN_NUM_INITIALIZER
12185 (struct cmd_macsec_sc_result,
12186 port_id, RTE_UINT16);
12187 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12188 TOKEN_ETHERADDR_INITIALIZER
12189 (struct cmd_macsec_sc_result,
12191 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12192 TOKEN_NUM_INITIALIZER
12193 (struct cmd_macsec_sc_result,
12197 cmd_set_macsec_sc_parsed(
12198 void *parsed_result,
12199 __rte_unused struct cmdline *cl,
12200 __rte_unused void *data)
12202 struct cmd_macsec_sc_result *res = parsed_result;
12203 int ret = -ENOTSUP;
12204 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12206 #ifdef RTE_NET_IXGBE
12208 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12209 res->mac.addr_bytes) :
12210 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12211 res->mac.addr_bytes, res->pi);
12213 RTE_SET_USED(is_tx);
12219 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12222 fprintf(stderr, "not supported on port %d\n", res->port_id);
12225 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12229 cmdline_parse_inst_t cmd_set_macsec_sc = {
12230 .f = cmd_set_macsec_sc_parsed,
12232 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12234 (void *)&cmd_macsec_sc_set,
12235 (void *)&cmd_macsec_sc_macsec,
12236 (void *)&cmd_macsec_sc_sc,
12237 (void *)&cmd_macsec_sc_tx_rx,
12238 (void *)&cmd_macsec_sc_port_id,
12239 (void *)&cmd_macsec_sc_mac,
12240 (void *)&cmd_macsec_sc_pi,
12245 /* Common result structure for MACsec secure connection configure */
12246 struct cmd_macsec_sa_result {
12247 cmdline_fixed_string_t set;
12248 cmdline_fixed_string_t macsec;
12249 cmdline_fixed_string_t sa;
12250 cmdline_fixed_string_t tx_rx;
12255 cmdline_fixed_string_t key;
12258 /* Common CLI fields for MACsec secure connection configure */
12259 cmdline_parse_token_string_t cmd_macsec_sa_set =
12260 TOKEN_STRING_INITIALIZER
12261 (struct cmd_macsec_sa_result,
12263 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12264 TOKEN_STRING_INITIALIZER
12265 (struct cmd_macsec_sa_result,
12267 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12268 TOKEN_STRING_INITIALIZER
12269 (struct cmd_macsec_sa_result,
12271 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12272 TOKEN_STRING_INITIALIZER
12273 (struct cmd_macsec_sa_result,
12275 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12276 TOKEN_NUM_INITIALIZER
12277 (struct cmd_macsec_sa_result,
12278 port_id, RTE_UINT16);
12279 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12280 TOKEN_NUM_INITIALIZER
12281 (struct cmd_macsec_sa_result,
12283 cmdline_parse_token_num_t cmd_macsec_sa_an =
12284 TOKEN_NUM_INITIALIZER
12285 (struct cmd_macsec_sa_result,
12287 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12288 TOKEN_NUM_INITIALIZER
12289 (struct cmd_macsec_sa_result,
12291 cmdline_parse_token_string_t cmd_macsec_sa_key =
12292 TOKEN_STRING_INITIALIZER
12293 (struct cmd_macsec_sa_result,
12297 cmd_set_macsec_sa_parsed(
12298 void *parsed_result,
12299 __rte_unused struct cmdline *cl,
12300 __rte_unused void *data)
12302 struct cmd_macsec_sa_result *res = parsed_result;
12303 int ret = -ENOTSUP;
12304 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12305 uint8_t key[16] = { 0 };
12311 key_len = strlen(res->key) / 2;
12315 for (i = 0; i < key_len; i++) {
12316 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12319 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12322 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12325 #ifdef RTE_NET_IXGBE
12327 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12328 res->idx, res->an, res->pn, key) :
12329 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12330 res->idx, res->an, res->pn, key);
12332 RTE_SET_USED(is_tx);
12339 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12342 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12345 fprintf(stderr, "not supported on port %d\n", res->port_id);
12348 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12352 cmdline_parse_inst_t cmd_set_macsec_sa = {
12353 .f = cmd_set_macsec_sa_parsed,
12355 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12357 (void *)&cmd_macsec_sa_set,
12358 (void *)&cmd_macsec_sa_macsec,
12359 (void *)&cmd_macsec_sa_sa,
12360 (void *)&cmd_macsec_sa_tx_rx,
12361 (void *)&cmd_macsec_sa_port_id,
12362 (void *)&cmd_macsec_sa_idx,
12363 (void *)&cmd_macsec_sa_an,
12364 (void *)&cmd_macsec_sa_pn,
12365 (void *)&cmd_macsec_sa_key,
12370 /* VF unicast promiscuous mode configuration */
12372 /* Common result structure for VF unicast promiscuous mode */
12373 struct cmd_vf_promisc_result {
12374 cmdline_fixed_string_t set;
12375 cmdline_fixed_string_t vf;
12376 cmdline_fixed_string_t promisc;
12379 cmdline_fixed_string_t on_off;
12382 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12383 cmdline_parse_token_string_t cmd_vf_promisc_set =
12384 TOKEN_STRING_INITIALIZER
12385 (struct cmd_vf_promisc_result,
12387 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12388 TOKEN_STRING_INITIALIZER
12389 (struct cmd_vf_promisc_result,
12391 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12392 TOKEN_STRING_INITIALIZER
12393 (struct cmd_vf_promisc_result,
12394 promisc, "promisc");
12395 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12396 TOKEN_NUM_INITIALIZER
12397 (struct cmd_vf_promisc_result,
12398 port_id, RTE_UINT16);
12399 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12400 TOKEN_NUM_INITIALIZER
12401 (struct cmd_vf_promisc_result,
12402 vf_id, RTE_UINT32);
12403 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12404 TOKEN_STRING_INITIALIZER
12405 (struct cmd_vf_promisc_result,
12409 cmd_set_vf_promisc_parsed(
12410 void *parsed_result,
12411 __rte_unused struct cmdline *cl,
12412 __rte_unused void *data)
12414 struct cmd_vf_promisc_result *res = parsed_result;
12415 int ret = -ENOTSUP;
12417 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12419 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12422 #ifdef RTE_NET_I40E
12423 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12424 res->vf_id, is_on);
12431 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12434 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12437 fprintf(stderr, "function not implemented\n");
12440 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12444 cmdline_parse_inst_t cmd_set_vf_promisc = {
12445 .f = cmd_set_vf_promisc_parsed,
12447 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12448 "Set unicast promiscuous mode for a VF from the PF",
12450 (void *)&cmd_vf_promisc_set,
12451 (void *)&cmd_vf_promisc_vf,
12452 (void *)&cmd_vf_promisc_promisc,
12453 (void *)&cmd_vf_promisc_port_id,
12454 (void *)&cmd_vf_promisc_vf_id,
12455 (void *)&cmd_vf_promisc_on_off,
12460 /* VF multicast promiscuous mode configuration */
12462 /* Common result structure for VF multicast promiscuous mode */
12463 struct cmd_vf_allmulti_result {
12464 cmdline_fixed_string_t set;
12465 cmdline_fixed_string_t vf;
12466 cmdline_fixed_string_t allmulti;
12469 cmdline_fixed_string_t on_off;
12472 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12473 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12474 TOKEN_STRING_INITIALIZER
12475 (struct cmd_vf_allmulti_result,
12477 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12478 TOKEN_STRING_INITIALIZER
12479 (struct cmd_vf_allmulti_result,
12481 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12482 TOKEN_STRING_INITIALIZER
12483 (struct cmd_vf_allmulti_result,
12484 allmulti, "allmulti");
12485 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12486 TOKEN_NUM_INITIALIZER
12487 (struct cmd_vf_allmulti_result,
12488 port_id, RTE_UINT16);
12489 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12490 TOKEN_NUM_INITIALIZER
12491 (struct cmd_vf_allmulti_result,
12492 vf_id, RTE_UINT32);
12493 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12494 TOKEN_STRING_INITIALIZER
12495 (struct cmd_vf_allmulti_result,
12499 cmd_set_vf_allmulti_parsed(
12500 void *parsed_result,
12501 __rte_unused struct cmdline *cl,
12502 __rte_unused void *data)
12504 struct cmd_vf_allmulti_result *res = parsed_result;
12505 int ret = -ENOTSUP;
12507 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12509 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12512 #ifdef RTE_NET_I40E
12513 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12514 res->vf_id, is_on);
12521 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12524 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12527 fprintf(stderr, "function not implemented\n");
12530 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12534 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12535 .f = cmd_set_vf_allmulti_parsed,
12537 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12538 "Set multicast promiscuous mode for a VF from the PF",
12540 (void *)&cmd_vf_allmulti_set,
12541 (void *)&cmd_vf_allmulti_vf,
12542 (void *)&cmd_vf_allmulti_allmulti,
12543 (void *)&cmd_vf_allmulti_port_id,
12544 (void *)&cmd_vf_allmulti_vf_id,
12545 (void *)&cmd_vf_allmulti_on_off,
12550 /* vf broadcast mode configuration */
12552 /* Common result structure for vf broadcast */
12553 struct cmd_set_vf_broadcast_result {
12554 cmdline_fixed_string_t set;
12555 cmdline_fixed_string_t vf;
12556 cmdline_fixed_string_t broadcast;
12559 cmdline_fixed_string_t on_off;
12562 /* Common CLI fields for vf broadcast enable disable */
12563 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12564 TOKEN_STRING_INITIALIZER
12565 (struct cmd_set_vf_broadcast_result,
12567 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12568 TOKEN_STRING_INITIALIZER
12569 (struct cmd_set_vf_broadcast_result,
12571 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12572 TOKEN_STRING_INITIALIZER
12573 (struct cmd_set_vf_broadcast_result,
12574 broadcast, "broadcast");
12575 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12576 TOKEN_NUM_INITIALIZER
12577 (struct cmd_set_vf_broadcast_result,
12578 port_id, RTE_UINT16);
12579 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12580 TOKEN_NUM_INITIALIZER
12581 (struct cmd_set_vf_broadcast_result,
12582 vf_id, RTE_UINT16);
12583 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12584 TOKEN_STRING_INITIALIZER
12585 (struct cmd_set_vf_broadcast_result,
12589 cmd_set_vf_broadcast_parsed(
12590 void *parsed_result,
12591 __rte_unused struct cmdline *cl,
12592 __rte_unused void *data)
12594 struct cmd_set_vf_broadcast_result *res = parsed_result;
12595 int ret = -ENOTSUP;
12597 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12599 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12602 #ifdef RTE_NET_I40E
12603 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12604 res->vf_id, is_on);
12611 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12612 res->vf_id, is_on);
12615 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12618 fprintf(stderr, "function not implemented\n");
12621 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12625 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12626 .f = cmd_set_vf_broadcast_parsed,
12628 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12630 (void *)&cmd_set_vf_broadcast_set,
12631 (void *)&cmd_set_vf_broadcast_vf,
12632 (void *)&cmd_set_vf_broadcast_broadcast,
12633 (void *)&cmd_set_vf_broadcast_port_id,
12634 (void *)&cmd_set_vf_broadcast_vf_id,
12635 (void *)&cmd_set_vf_broadcast_on_off,
12640 /* vf vlan tag configuration */
12642 /* Common result structure for vf vlan tag */
12643 struct cmd_set_vf_vlan_tag_result {
12644 cmdline_fixed_string_t set;
12645 cmdline_fixed_string_t vf;
12646 cmdline_fixed_string_t vlan;
12647 cmdline_fixed_string_t tag;
12650 cmdline_fixed_string_t on_off;
12653 /* Common CLI fields for vf vlan tag enable disable */
12654 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12655 TOKEN_STRING_INITIALIZER
12656 (struct cmd_set_vf_vlan_tag_result,
12658 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12659 TOKEN_STRING_INITIALIZER
12660 (struct cmd_set_vf_vlan_tag_result,
12662 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12663 TOKEN_STRING_INITIALIZER
12664 (struct cmd_set_vf_vlan_tag_result,
12666 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12667 TOKEN_STRING_INITIALIZER
12668 (struct cmd_set_vf_vlan_tag_result,
12670 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12671 TOKEN_NUM_INITIALIZER
12672 (struct cmd_set_vf_vlan_tag_result,
12673 port_id, RTE_UINT16);
12674 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12675 TOKEN_NUM_INITIALIZER
12676 (struct cmd_set_vf_vlan_tag_result,
12677 vf_id, RTE_UINT16);
12678 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12679 TOKEN_STRING_INITIALIZER
12680 (struct cmd_set_vf_vlan_tag_result,
12684 cmd_set_vf_vlan_tag_parsed(
12685 void *parsed_result,
12686 __rte_unused struct cmdline *cl,
12687 __rte_unused void *data)
12689 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12690 int ret = -ENOTSUP;
12692 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12694 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12697 #ifdef RTE_NET_I40E
12698 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12699 res->vf_id, is_on);
12706 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12707 res->vf_id, is_on);
12710 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12713 fprintf(stderr, "function not implemented\n");
12716 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12720 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12721 .f = cmd_set_vf_vlan_tag_parsed,
12723 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12725 (void *)&cmd_set_vf_vlan_tag_set,
12726 (void *)&cmd_set_vf_vlan_tag_vf,
12727 (void *)&cmd_set_vf_vlan_tag_vlan,
12728 (void *)&cmd_set_vf_vlan_tag_tag,
12729 (void *)&cmd_set_vf_vlan_tag_port_id,
12730 (void *)&cmd_set_vf_vlan_tag_vf_id,
12731 (void *)&cmd_set_vf_vlan_tag_on_off,
12736 /* Common definition of VF and TC TX bandwidth configuration */
12737 struct cmd_vf_tc_bw_result {
12738 cmdline_fixed_string_t set;
12739 cmdline_fixed_string_t vf;
12740 cmdline_fixed_string_t tc;
12741 cmdline_fixed_string_t tx;
12742 cmdline_fixed_string_t min_bw;
12743 cmdline_fixed_string_t max_bw;
12744 cmdline_fixed_string_t strict_link_prio;
12749 cmdline_fixed_string_t bw_list;
12753 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12754 TOKEN_STRING_INITIALIZER
12755 (struct cmd_vf_tc_bw_result,
12757 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12758 TOKEN_STRING_INITIALIZER
12759 (struct cmd_vf_tc_bw_result,
12761 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12762 TOKEN_STRING_INITIALIZER
12763 (struct cmd_vf_tc_bw_result,
12765 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12766 TOKEN_STRING_INITIALIZER
12767 (struct cmd_vf_tc_bw_result,
12769 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12770 TOKEN_STRING_INITIALIZER
12771 (struct cmd_vf_tc_bw_result,
12772 strict_link_prio, "strict-link-priority");
12773 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12774 TOKEN_STRING_INITIALIZER
12775 (struct cmd_vf_tc_bw_result,
12776 min_bw, "min-bandwidth");
12777 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12778 TOKEN_STRING_INITIALIZER
12779 (struct cmd_vf_tc_bw_result,
12780 max_bw, "max-bandwidth");
12781 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12782 TOKEN_NUM_INITIALIZER
12783 (struct cmd_vf_tc_bw_result,
12784 port_id, RTE_UINT16);
12785 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12786 TOKEN_NUM_INITIALIZER
12787 (struct cmd_vf_tc_bw_result,
12788 vf_id, RTE_UINT16);
12789 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12790 TOKEN_NUM_INITIALIZER
12791 (struct cmd_vf_tc_bw_result,
12793 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12794 TOKEN_NUM_INITIALIZER
12795 (struct cmd_vf_tc_bw_result,
12797 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12798 TOKEN_STRING_INITIALIZER
12799 (struct cmd_vf_tc_bw_result,
12801 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12802 TOKEN_NUM_INITIALIZER
12803 (struct cmd_vf_tc_bw_result,
12804 tc_map, RTE_UINT8);
12806 /* VF max bandwidth setting */
12808 cmd_vf_max_bw_parsed(
12809 void *parsed_result,
12810 __rte_unused struct cmdline *cl,
12811 __rte_unused void *data)
12813 struct cmd_vf_tc_bw_result *res = parsed_result;
12814 int ret = -ENOTSUP;
12816 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12819 #ifdef RTE_NET_I40E
12820 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12821 res->vf_id, res->bw);
12828 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12829 res->vf_id, res->bw);
12832 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12835 fprintf(stderr, "function not implemented\n");
12838 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12842 cmdline_parse_inst_t cmd_vf_max_bw = {
12843 .f = cmd_vf_max_bw_parsed,
12845 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12847 (void *)&cmd_vf_tc_bw_set,
12848 (void *)&cmd_vf_tc_bw_vf,
12849 (void *)&cmd_vf_tc_bw_tx,
12850 (void *)&cmd_vf_tc_bw_max_bw,
12851 (void *)&cmd_vf_tc_bw_port_id,
12852 (void *)&cmd_vf_tc_bw_vf_id,
12853 (void *)&cmd_vf_tc_bw_bw,
12859 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12864 const char *p, *p0 = str;
12871 p = strchr(p0, '(');
12874 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12878 p0 = strchr(p, ')');
12881 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12885 if (size >= sizeof(s)) {
12887 "The string size exceeds the internal buffer size\n");
12890 snprintf(s, sizeof(s), "%.*s", size, p);
12891 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12893 fprintf(stderr, "Failed to get the bandwidth list.\n");
12897 for (i = 0; i < ret; i++)
12898 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12903 /* TC min bandwidth setting */
12905 cmd_vf_tc_min_bw_parsed(
12906 void *parsed_result,
12907 __rte_unused struct cmdline *cl,
12908 __rte_unused void *data)
12910 struct cmd_vf_tc_bw_result *res = parsed_result;
12913 int ret = -ENOTSUP;
12915 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12918 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12922 #ifdef RTE_NET_I40E
12923 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12931 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12934 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12937 fprintf(stderr, "function not implemented\n");
12940 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12944 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12945 .f = cmd_vf_tc_min_bw_parsed,
12947 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12948 " <bw1, bw2, ...>",
12950 (void *)&cmd_vf_tc_bw_set,
12951 (void *)&cmd_vf_tc_bw_vf,
12952 (void *)&cmd_vf_tc_bw_tc,
12953 (void *)&cmd_vf_tc_bw_tx,
12954 (void *)&cmd_vf_tc_bw_min_bw,
12955 (void *)&cmd_vf_tc_bw_port_id,
12956 (void *)&cmd_vf_tc_bw_vf_id,
12957 (void *)&cmd_vf_tc_bw_bw_list,
12963 cmd_tc_min_bw_parsed(
12964 void *parsed_result,
12965 __rte_unused struct cmdline *cl,
12966 __rte_unused void *data)
12968 struct cmd_vf_tc_bw_result *res = parsed_result;
12969 struct rte_port *port;
12972 int ret = -ENOTSUP;
12974 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12977 port = &ports[res->port_id];
12978 /** Check if the port is not started **/
12979 if (port->port_status != RTE_PORT_STOPPED) {
12980 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12984 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12988 #ifdef RTE_NET_IXGBE
12989 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12996 fprintf(stderr, "invalid bandwidth\n");
12999 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13002 fprintf(stderr, "function not implemented\n");
13005 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13009 cmdline_parse_inst_t cmd_tc_min_bw = {
13010 .f = cmd_tc_min_bw_parsed,
13012 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13014 (void *)&cmd_vf_tc_bw_set,
13015 (void *)&cmd_vf_tc_bw_tc,
13016 (void *)&cmd_vf_tc_bw_tx,
13017 (void *)&cmd_vf_tc_bw_min_bw,
13018 (void *)&cmd_vf_tc_bw_port_id,
13019 (void *)&cmd_vf_tc_bw_bw_list,
13024 /* TC max bandwidth setting */
13026 cmd_vf_tc_max_bw_parsed(
13027 void *parsed_result,
13028 __rte_unused struct cmdline *cl,
13029 __rte_unused void *data)
13031 struct cmd_vf_tc_bw_result *res = parsed_result;
13032 int ret = -ENOTSUP;
13034 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13037 #ifdef RTE_NET_I40E
13038 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13039 res->tc_no, res->bw);
13047 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
13048 res->vf_id, res->tc_no, res->bw);
13051 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13054 fprintf(stderr, "function not implemented\n");
13057 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13061 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13062 .f = cmd_vf_tc_max_bw_parsed,
13064 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13067 (void *)&cmd_vf_tc_bw_set,
13068 (void *)&cmd_vf_tc_bw_vf,
13069 (void *)&cmd_vf_tc_bw_tc,
13070 (void *)&cmd_vf_tc_bw_tx,
13071 (void *)&cmd_vf_tc_bw_max_bw,
13072 (void *)&cmd_vf_tc_bw_port_id,
13073 (void *)&cmd_vf_tc_bw_vf_id,
13074 (void *)&cmd_vf_tc_bw_tc_no,
13075 (void *)&cmd_vf_tc_bw_bw,
13080 /** Set VXLAN encapsulation details */
13081 struct cmd_set_vxlan_result {
13082 cmdline_fixed_string_t set;
13083 cmdline_fixed_string_t vxlan;
13084 cmdline_fixed_string_t pos_token;
13085 cmdline_fixed_string_t ip_version;
13086 uint32_t vlan_present:1;
13090 cmdline_ipaddr_t ip_src;
13091 cmdline_ipaddr_t ip_dst;
13095 struct rte_ether_addr eth_src;
13096 struct rte_ether_addr eth_dst;
13099 cmdline_parse_token_string_t cmd_set_vxlan_set =
13100 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
13101 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
13102 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
13103 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
13104 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13106 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
13107 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13108 "vxlan-with-vlan");
13109 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
13110 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13112 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
13113 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
13115 cmdline_parse_token_string_t cmd_set_vxlan_vni =
13116 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13118 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
13119 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
13120 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
13121 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13123 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
13124 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
13125 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
13126 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13128 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
13129 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
13130 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13131 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13133 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13134 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
13135 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13136 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13138 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13139 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
13140 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13141 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13143 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13144 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13145 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13146 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13148 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13149 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13150 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13151 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13153 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13154 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13155 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13156 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13158 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13159 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13160 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13161 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13163 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13164 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13166 static void cmd_set_vxlan_parsed(void *parsed_result,
13167 __rte_unused struct cmdline *cl,
13168 __rte_unused void *data)
13170 struct cmd_set_vxlan_result *res = parsed_result;
13175 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13178 vxlan_encap_conf.select_tos_ttl = 0;
13179 if (strcmp(res->vxlan, "vxlan") == 0)
13180 vxlan_encap_conf.select_vlan = 0;
13181 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13182 vxlan_encap_conf.select_vlan = 1;
13183 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13184 vxlan_encap_conf.select_vlan = 0;
13185 vxlan_encap_conf.select_tos_ttl = 1;
13187 if (strcmp(res->ip_version, "ipv4") == 0)
13188 vxlan_encap_conf.select_ipv4 = 1;
13189 else if (strcmp(res->ip_version, "ipv6") == 0)
13190 vxlan_encap_conf.select_ipv4 = 0;
13193 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13194 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13195 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13196 vxlan_encap_conf.ip_tos = res->tos;
13197 vxlan_encap_conf.ip_ttl = res->ttl;
13198 if (vxlan_encap_conf.select_ipv4) {
13199 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13200 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13202 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13203 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13205 if (vxlan_encap_conf.select_vlan)
13206 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13207 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13208 RTE_ETHER_ADDR_LEN);
13209 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13210 RTE_ETHER_ADDR_LEN);
13213 cmdline_parse_inst_t cmd_set_vxlan = {
13214 .f = cmd_set_vxlan_parsed,
13216 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13217 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13218 " eth-src <eth-src> eth-dst <eth-dst>",
13220 (void *)&cmd_set_vxlan_set,
13221 (void *)&cmd_set_vxlan_vxlan,
13222 (void *)&cmd_set_vxlan_ip_version,
13223 (void *)&cmd_set_vxlan_ip_version_value,
13224 (void *)&cmd_set_vxlan_vni,
13225 (void *)&cmd_set_vxlan_vni_value,
13226 (void *)&cmd_set_vxlan_udp_src,
13227 (void *)&cmd_set_vxlan_udp_src_value,
13228 (void *)&cmd_set_vxlan_udp_dst,
13229 (void *)&cmd_set_vxlan_udp_dst_value,
13230 (void *)&cmd_set_vxlan_ip_src,
13231 (void *)&cmd_set_vxlan_ip_src_value,
13232 (void *)&cmd_set_vxlan_ip_dst,
13233 (void *)&cmd_set_vxlan_ip_dst_value,
13234 (void *)&cmd_set_vxlan_eth_src,
13235 (void *)&cmd_set_vxlan_eth_src_value,
13236 (void *)&cmd_set_vxlan_eth_dst,
13237 (void *)&cmd_set_vxlan_eth_dst_value,
13242 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13243 .f = cmd_set_vxlan_parsed,
13245 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13246 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13247 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13248 " eth-dst <eth-dst>",
13250 (void *)&cmd_set_vxlan_set,
13251 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13252 (void *)&cmd_set_vxlan_ip_version,
13253 (void *)&cmd_set_vxlan_ip_version_value,
13254 (void *)&cmd_set_vxlan_vni,
13255 (void *)&cmd_set_vxlan_vni_value,
13256 (void *)&cmd_set_vxlan_udp_src,
13257 (void *)&cmd_set_vxlan_udp_src_value,
13258 (void *)&cmd_set_vxlan_udp_dst,
13259 (void *)&cmd_set_vxlan_udp_dst_value,
13260 (void *)&cmd_set_vxlan_ip_tos,
13261 (void *)&cmd_set_vxlan_ip_tos_value,
13262 (void *)&cmd_set_vxlan_ip_ttl,
13263 (void *)&cmd_set_vxlan_ip_ttl_value,
13264 (void *)&cmd_set_vxlan_ip_src,
13265 (void *)&cmd_set_vxlan_ip_src_value,
13266 (void *)&cmd_set_vxlan_ip_dst,
13267 (void *)&cmd_set_vxlan_ip_dst_value,
13268 (void *)&cmd_set_vxlan_eth_src,
13269 (void *)&cmd_set_vxlan_eth_src_value,
13270 (void *)&cmd_set_vxlan_eth_dst,
13271 (void *)&cmd_set_vxlan_eth_dst_value,
13276 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13277 .f = cmd_set_vxlan_parsed,
13279 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13280 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13281 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13284 (void *)&cmd_set_vxlan_set,
13285 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13286 (void *)&cmd_set_vxlan_ip_version,
13287 (void *)&cmd_set_vxlan_ip_version_value,
13288 (void *)&cmd_set_vxlan_vni,
13289 (void *)&cmd_set_vxlan_vni_value,
13290 (void *)&cmd_set_vxlan_udp_src,
13291 (void *)&cmd_set_vxlan_udp_src_value,
13292 (void *)&cmd_set_vxlan_udp_dst,
13293 (void *)&cmd_set_vxlan_udp_dst_value,
13294 (void *)&cmd_set_vxlan_ip_src,
13295 (void *)&cmd_set_vxlan_ip_src_value,
13296 (void *)&cmd_set_vxlan_ip_dst,
13297 (void *)&cmd_set_vxlan_ip_dst_value,
13298 (void *)&cmd_set_vxlan_vlan,
13299 (void *)&cmd_set_vxlan_vlan_value,
13300 (void *)&cmd_set_vxlan_eth_src,
13301 (void *)&cmd_set_vxlan_eth_src_value,
13302 (void *)&cmd_set_vxlan_eth_dst,
13303 (void *)&cmd_set_vxlan_eth_dst_value,
13308 /** Set NVGRE encapsulation details */
13309 struct cmd_set_nvgre_result {
13310 cmdline_fixed_string_t set;
13311 cmdline_fixed_string_t nvgre;
13312 cmdline_fixed_string_t pos_token;
13313 cmdline_fixed_string_t ip_version;
13315 cmdline_ipaddr_t ip_src;
13316 cmdline_ipaddr_t ip_dst;
13318 struct rte_ether_addr eth_src;
13319 struct rte_ether_addr eth_dst;
13322 cmdline_parse_token_string_t cmd_set_nvgre_set =
13323 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13324 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13325 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13326 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13327 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13328 "nvgre-with-vlan");
13329 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13330 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13332 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13333 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13335 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13336 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13338 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13339 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13340 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13341 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13343 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13344 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13345 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13346 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13348 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13349 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13350 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13351 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13353 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13354 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13355 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13356 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13358 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13359 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13360 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13361 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13363 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13364 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13366 static void cmd_set_nvgre_parsed(void *parsed_result,
13367 __rte_unused struct cmdline *cl,
13368 __rte_unused void *data)
13370 struct cmd_set_nvgre_result *res = parsed_result;
13372 uint32_t nvgre_tni;
13375 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13378 if (strcmp(res->nvgre, "nvgre") == 0)
13379 nvgre_encap_conf.select_vlan = 0;
13380 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13381 nvgre_encap_conf.select_vlan = 1;
13382 if (strcmp(res->ip_version, "ipv4") == 0)
13383 nvgre_encap_conf.select_ipv4 = 1;
13384 else if (strcmp(res->ip_version, "ipv6") == 0)
13385 nvgre_encap_conf.select_ipv4 = 0;
13388 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13389 if (nvgre_encap_conf.select_ipv4) {
13390 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13391 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13393 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13394 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13396 if (nvgre_encap_conf.select_vlan)
13397 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13398 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13399 RTE_ETHER_ADDR_LEN);
13400 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13401 RTE_ETHER_ADDR_LEN);
13404 cmdline_parse_inst_t cmd_set_nvgre = {
13405 .f = cmd_set_nvgre_parsed,
13407 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13408 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13409 " eth-dst <eth-dst>",
13411 (void *)&cmd_set_nvgre_set,
13412 (void *)&cmd_set_nvgre_nvgre,
13413 (void *)&cmd_set_nvgre_ip_version,
13414 (void *)&cmd_set_nvgre_ip_version_value,
13415 (void *)&cmd_set_nvgre_tni,
13416 (void *)&cmd_set_nvgre_tni_value,
13417 (void *)&cmd_set_nvgre_ip_src,
13418 (void *)&cmd_set_nvgre_ip_src_value,
13419 (void *)&cmd_set_nvgre_ip_dst,
13420 (void *)&cmd_set_nvgre_ip_dst_value,
13421 (void *)&cmd_set_nvgre_eth_src,
13422 (void *)&cmd_set_nvgre_eth_src_value,
13423 (void *)&cmd_set_nvgre_eth_dst,
13424 (void *)&cmd_set_nvgre_eth_dst_value,
13429 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13430 .f = cmd_set_nvgre_parsed,
13432 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13433 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13434 " eth-src <eth-src> eth-dst <eth-dst>",
13436 (void *)&cmd_set_nvgre_set,
13437 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13438 (void *)&cmd_set_nvgre_ip_version,
13439 (void *)&cmd_set_nvgre_ip_version_value,
13440 (void *)&cmd_set_nvgre_tni,
13441 (void *)&cmd_set_nvgre_tni_value,
13442 (void *)&cmd_set_nvgre_ip_src,
13443 (void *)&cmd_set_nvgre_ip_src_value,
13444 (void *)&cmd_set_nvgre_ip_dst,
13445 (void *)&cmd_set_nvgre_ip_dst_value,
13446 (void *)&cmd_set_nvgre_vlan,
13447 (void *)&cmd_set_nvgre_vlan_value,
13448 (void *)&cmd_set_nvgre_eth_src,
13449 (void *)&cmd_set_nvgre_eth_src_value,
13450 (void *)&cmd_set_nvgre_eth_dst,
13451 (void *)&cmd_set_nvgre_eth_dst_value,
13456 /** Set L2 encapsulation details */
13457 struct cmd_set_l2_encap_result {
13458 cmdline_fixed_string_t set;
13459 cmdline_fixed_string_t l2_encap;
13460 cmdline_fixed_string_t pos_token;
13461 cmdline_fixed_string_t ip_version;
13462 uint32_t vlan_present:1;
13464 struct rte_ether_addr eth_src;
13465 struct rte_ether_addr eth_dst;
13468 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13469 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13470 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13471 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13472 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13473 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13474 "l2_encap-with-vlan");
13475 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13476 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13478 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13479 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13481 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13482 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13484 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13485 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13486 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13487 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13489 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13490 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13491 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13492 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13494 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13495 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13497 static void cmd_set_l2_encap_parsed(void *parsed_result,
13498 __rte_unused struct cmdline *cl,
13499 __rte_unused void *data)
13501 struct cmd_set_l2_encap_result *res = parsed_result;
13503 if (strcmp(res->l2_encap, "l2_encap") == 0)
13504 l2_encap_conf.select_vlan = 0;
13505 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13506 l2_encap_conf.select_vlan = 1;
13507 if (strcmp(res->ip_version, "ipv4") == 0)
13508 l2_encap_conf.select_ipv4 = 1;
13509 else if (strcmp(res->ip_version, "ipv6") == 0)
13510 l2_encap_conf.select_ipv4 = 0;
13513 if (l2_encap_conf.select_vlan)
13514 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13515 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13516 RTE_ETHER_ADDR_LEN);
13517 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13518 RTE_ETHER_ADDR_LEN);
13521 cmdline_parse_inst_t cmd_set_l2_encap = {
13522 .f = cmd_set_l2_encap_parsed,
13524 .help_str = "set l2_encap ip-version ipv4|ipv6"
13525 " eth-src <eth-src> eth-dst <eth-dst>",
13527 (void *)&cmd_set_l2_encap_set,
13528 (void *)&cmd_set_l2_encap_l2_encap,
13529 (void *)&cmd_set_l2_encap_ip_version,
13530 (void *)&cmd_set_l2_encap_ip_version_value,
13531 (void *)&cmd_set_l2_encap_eth_src,
13532 (void *)&cmd_set_l2_encap_eth_src_value,
13533 (void *)&cmd_set_l2_encap_eth_dst,
13534 (void *)&cmd_set_l2_encap_eth_dst_value,
13539 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13540 .f = cmd_set_l2_encap_parsed,
13542 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13543 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13545 (void *)&cmd_set_l2_encap_set,
13546 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13547 (void *)&cmd_set_l2_encap_ip_version,
13548 (void *)&cmd_set_l2_encap_ip_version_value,
13549 (void *)&cmd_set_l2_encap_vlan,
13550 (void *)&cmd_set_l2_encap_vlan_value,
13551 (void *)&cmd_set_l2_encap_eth_src,
13552 (void *)&cmd_set_l2_encap_eth_src_value,
13553 (void *)&cmd_set_l2_encap_eth_dst,
13554 (void *)&cmd_set_l2_encap_eth_dst_value,
13559 /** Set L2 decapsulation details */
13560 struct cmd_set_l2_decap_result {
13561 cmdline_fixed_string_t set;
13562 cmdline_fixed_string_t l2_decap;
13563 cmdline_fixed_string_t pos_token;
13564 uint32_t vlan_present:1;
13567 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13568 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13569 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13570 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13572 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13573 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13574 "l2_decap-with-vlan");
13576 static void cmd_set_l2_decap_parsed(void *parsed_result,
13577 __rte_unused struct cmdline *cl,
13578 __rte_unused void *data)
13580 struct cmd_set_l2_decap_result *res = parsed_result;
13582 if (strcmp(res->l2_decap, "l2_decap") == 0)
13583 l2_decap_conf.select_vlan = 0;
13584 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13585 l2_decap_conf.select_vlan = 1;
13588 cmdline_parse_inst_t cmd_set_l2_decap = {
13589 .f = cmd_set_l2_decap_parsed,
13591 .help_str = "set l2_decap",
13593 (void *)&cmd_set_l2_decap_set,
13594 (void *)&cmd_set_l2_decap_l2_decap,
13599 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13600 .f = cmd_set_l2_decap_parsed,
13602 .help_str = "set l2_decap-with-vlan",
13604 (void *)&cmd_set_l2_decap_set,
13605 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13610 /** Set MPLSoGRE encapsulation details */
13611 struct cmd_set_mplsogre_encap_result {
13612 cmdline_fixed_string_t set;
13613 cmdline_fixed_string_t mplsogre;
13614 cmdline_fixed_string_t pos_token;
13615 cmdline_fixed_string_t ip_version;
13616 uint32_t vlan_present:1;
13618 cmdline_ipaddr_t ip_src;
13619 cmdline_ipaddr_t ip_dst;
13621 struct rte_ether_addr eth_src;
13622 struct rte_ether_addr eth_dst;
13625 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13626 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13628 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13629 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13631 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13632 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13633 mplsogre, "mplsogre_encap-with-vlan");
13634 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13635 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13636 pos_token, "ip-version");
13637 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13638 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13639 ip_version, "ipv4#ipv6");
13640 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13641 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13642 pos_token, "label");
13643 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13644 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13646 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13647 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13648 pos_token, "ip-src");
13649 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13650 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13651 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13652 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13653 pos_token, "ip-dst");
13654 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13655 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13656 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13657 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13658 pos_token, "vlan-tci");
13659 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13660 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13662 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13663 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13664 pos_token, "eth-src");
13665 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13666 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13668 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13669 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13670 pos_token, "eth-dst");
13671 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13672 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13675 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13676 __rte_unused struct cmdline *cl,
13677 __rte_unused void *data)
13679 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13681 uint32_t mplsogre_label;
13684 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13687 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13688 mplsogre_encap_conf.select_vlan = 0;
13689 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13690 mplsogre_encap_conf.select_vlan = 1;
13691 if (strcmp(res->ip_version, "ipv4") == 0)
13692 mplsogre_encap_conf.select_ipv4 = 1;
13693 else if (strcmp(res->ip_version, "ipv6") == 0)
13694 mplsogre_encap_conf.select_ipv4 = 0;
13697 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13698 if (mplsogre_encap_conf.select_ipv4) {
13699 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13700 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13702 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13703 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13705 if (mplsogre_encap_conf.select_vlan)
13706 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13707 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13708 RTE_ETHER_ADDR_LEN);
13709 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13710 RTE_ETHER_ADDR_LEN);
13713 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13714 .f = cmd_set_mplsogre_encap_parsed,
13716 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13717 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13718 " eth-dst <eth-dst>",
13720 (void *)&cmd_set_mplsogre_encap_set,
13721 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13722 (void *)&cmd_set_mplsogre_encap_ip_version,
13723 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13724 (void *)&cmd_set_mplsogre_encap_label,
13725 (void *)&cmd_set_mplsogre_encap_label_value,
13726 (void *)&cmd_set_mplsogre_encap_ip_src,
13727 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13728 (void *)&cmd_set_mplsogre_encap_ip_dst,
13729 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13730 (void *)&cmd_set_mplsogre_encap_eth_src,
13731 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13732 (void *)&cmd_set_mplsogre_encap_eth_dst,
13733 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13738 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13739 .f = cmd_set_mplsogre_encap_parsed,
13741 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13742 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13743 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13745 (void *)&cmd_set_mplsogre_encap_set,
13746 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13747 (void *)&cmd_set_mplsogre_encap_ip_version,
13748 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13749 (void *)&cmd_set_mplsogre_encap_label,
13750 (void *)&cmd_set_mplsogre_encap_label_value,
13751 (void *)&cmd_set_mplsogre_encap_ip_src,
13752 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13753 (void *)&cmd_set_mplsogre_encap_ip_dst,
13754 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13755 (void *)&cmd_set_mplsogre_encap_vlan,
13756 (void *)&cmd_set_mplsogre_encap_vlan_value,
13757 (void *)&cmd_set_mplsogre_encap_eth_src,
13758 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13759 (void *)&cmd_set_mplsogre_encap_eth_dst,
13760 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13765 /** Set MPLSoGRE decapsulation details */
13766 struct cmd_set_mplsogre_decap_result {
13767 cmdline_fixed_string_t set;
13768 cmdline_fixed_string_t mplsogre;
13769 cmdline_fixed_string_t pos_token;
13770 cmdline_fixed_string_t ip_version;
13771 uint32_t vlan_present:1;
13774 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13775 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13777 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13778 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13780 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13781 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13782 mplsogre, "mplsogre_decap-with-vlan");
13783 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13784 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13785 pos_token, "ip-version");
13786 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13787 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13788 ip_version, "ipv4#ipv6");
13790 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13791 __rte_unused struct cmdline *cl,
13792 __rte_unused void *data)
13794 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13796 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13797 mplsogre_decap_conf.select_vlan = 0;
13798 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13799 mplsogre_decap_conf.select_vlan = 1;
13800 if (strcmp(res->ip_version, "ipv4") == 0)
13801 mplsogre_decap_conf.select_ipv4 = 1;
13802 else if (strcmp(res->ip_version, "ipv6") == 0)
13803 mplsogre_decap_conf.select_ipv4 = 0;
13806 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13807 .f = cmd_set_mplsogre_decap_parsed,
13809 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13811 (void *)&cmd_set_mplsogre_decap_set,
13812 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13813 (void *)&cmd_set_mplsogre_decap_ip_version,
13814 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13819 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13820 .f = cmd_set_mplsogre_decap_parsed,
13822 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13824 (void *)&cmd_set_mplsogre_decap_set,
13825 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13826 (void *)&cmd_set_mplsogre_decap_ip_version,
13827 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13832 /** Set MPLSoUDP encapsulation details */
13833 struct cmd_set_mplsoudp_encap_result {
13834 cmdline_fixed_string_t set;
13835 cmdline_fixed_string_t mplsoudp;
13836 cmdline_fixed_string_t pos_token;
13837 cmdline_fixed_string_t ip_version;
13838 uint32_t vlan_present:1;
13842 cmdline_ipaddr_t ip_src;
13843 cmdline_ipaddr_t ip_dst;
13845 struct rte_ether_addr eth_src;
13846 struct rte_ether_addr eth_dst;
13849 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13850 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13852 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13853 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13855 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13856 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13857 mplsoudp, "mplsoudp_encap-with-vlan");
13858 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13859 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13860 pos_token, "ip-version");
13861 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13862 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13863 ip_version, "ipv4#ipv6");
13864 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13865 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13866 pos_token, "label");
13867 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13868 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13870 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13871 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13872 pos_token, "udp-src");
13873 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13874 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13876 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13877 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13878 pos_token, "udp-dst");
13879 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13880 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13882 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13883 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13884 pos_token, "ip-src");
13885 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13886 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13887 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13888 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13889 pos_token, "ip-dst");
13890 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13891 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13892 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13893 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13894 pos_token, "vlan-tci");
13895 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13896 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13898 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13899 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13900 pos_token, "eth-src");
13901 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13902 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13904 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13905 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13906 pos_token, "eth-dst");
13907 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13908 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13911 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13912 __rte_unused struct cmdline *cl,
13913 __rte_unused void *data)
13915 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13917 uint32_t mplsoudp_label;
13920 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13923 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13924 mplsoudp_encap_conf.select_vlan = 0;
13925 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13926 mplsoudp_encap_conf.select_vlan = 1;
13927 if (strcmp(res->ip_version, "ipv4") == 0)
13928 mplsoudp_encap_conf.select_ipv4 = 1;
13929 else if (strcmp(res->ip_version, "ipv6") == 0)
13930 mplsoudp_encap_conf.select_ipv4 = 0;
13933 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13934 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13935 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13936 if (mplsoudp_encap_conf.select_ipv4) {
13937 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13938 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13940 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13941 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13943 if (mplsoudp_encap_conf.select_vlan)
13944 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13945 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13946 RTE_ETHER_ADDR_LEN);
13947 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13948 RTE_ETHER_ADDR_LEN);
13951 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13952 .f = cmd_set_mplsoudp_encap_parsed,
13954 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13955 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13956 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13958 (void *)&cmd_set_mplsoudp_encap_set,
13959 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13960 (void *)&cmd_set_mplsoudp_encap_ip_version,
13961 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13962 (void *)&cmd_set_mplsoudp_encap_label,
13963 (void *)&cmd_set_mplsoudp_encap_label_value,
13964 (void *)&cmd_set_mplsoudp_encap_udp_src,
13965 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13966 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13967 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13968 (void *)&cmd_set_mplsoudp_encap_ip_src,
13969 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13970 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13971 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13972 (void *)&cmd_set_mplsoudp_encap_eth_src,
13973 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13974 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13975 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13980 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13981 .f = cmd_set_mplsoudp_encap_parsed,
13983 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13984 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13985 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13986 " eth-src <eth-src> eth-dst <eth-dst>",
13988 (void *)&cmd_set_mplsoudp_encap_set,
13989 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13990 (void *)&cmd_set_mplsoudp_encap_ip_version,
13991 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13992 (void *)&cmd_set_mplsoudp_encap_label,
13993 (void *)&cmd_set_mplsoudp_encap_label_value,
13994 (void *)&cmd_set_mplsoudp_encap_udp_src,
13995 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13996 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13997 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13998 (void *)&cmd_set_mplsoudp_encap_ip_src,
13999 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
14000 (void *)&cmd_set_mplsoudp_encap_ip_dst,
14001 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
14002 (void *)&cmd_set_mplsoudp_encap_vlan,
14003 (void *)&cmd_set_mplsoudp_encap_vlan_value,
14004 (void *)&cmd_set_mplsoudp_encap_eth_src,
14005 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
14006 (void *)&cmd_set_mplsoudp_encap_eth_dst,
14007 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14012 /** Set MPLSoUDP decapsulation details */
14013 struct cmd_set_mplsoudp_decap_result {
14014 cmdline_fixed_string_t set;
14015 cmdline_fixed_string_t mplsoudp;
14016 cmdline_fixed_string_t pos_token;
14017 cmdline_fixed_string_t ip_version;
14018 uint32_t vlan_present:1;
14021 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
14022 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
14024 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
14025 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
14027 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
14028 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14029 mplsoudp, "mplsoudp_decap-with-vlan");
14030 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
14031 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14032 pos_token, "ip-version");
14033 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
14034 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14035 ip_version, "ipv4#ipv6");
14037 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
14038 __rte_unused struct cmdline *cl,
14039 __rte_unused void *data)
14041 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
14043 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
14044 mplsoudp_decap_conf.select_vlan = 0;
14045 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
14046 mplsoudp_decap_conf.select_vlan = 1;
14047 if (strcmp(res->ip_version, "ipv4") == 0)
14048 mplsoudp_decap_conf.select_ipv4 = 1;
14049 else if (strcmp(res->ip_version, "ipv6") == 0)
14050 mplsoudp_decap_conf.select_ipv4 = 0;
14053 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
14054 .f = cmd_set_mplsoudp_decap_parsed,
14056 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
14058 (void *)&cmd_set_mplsoudp_decap_set,
14059 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
14060 (void *)&cmd_set_mplsoudp_decap_ip_version,
14061 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14066 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
14067 .f = cmd_set_mplsoudp_decap_parsed,
14069 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
14071 (void *)&cmd_set_mplsoudp_decap_set,
14072 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
14073 (void *)&cmd_set_mplsoudp_decap_ip_version,
14074 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14079 /** Set connection tracking object common details */
14080 struct cmd_set_conntrack_common_result {
14081 cmdline_fixed_string_t set;
14082 cmdline_fixed_string_t conntrack;
14083 cmdline_fixed_string_t common;
14084 cmdline_fixed_string_t peer;
14085 cmdline_fixed_string_t is_orig;
14086 cmdline_fixed_string_t enable;
14087 cmdline_fixed_string_t live;
14088 cmdline_fixed_string_t sack;
14089 cmdline_fixed_string_t cack;
14090 cmdline_fixed_string_t last_dir;
14091 cmdline_fixed_string_t liberal;
14092 cmdline_fixed_string_t state;
14093 cmdline_fixed_string_t max_ack_win;
14094 cmdline_fixed_string_t retrans;
14095 cmdline_fixed_string_t last_win;
14096 cmdline_fixed_string_t last_seq;
14097 cmdline_fixed_string_t last_ack;
14098 cmdline_fixed_string_t last_end;
14099 cmdline_fixed_string_t last_index;
14102 uint16_t peer_port;
14103 uint32_t is_original;
14118 cmdline_parse_token_string_t cmd_set_conntrack_set =
14119 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14121 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
14122 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14123 conntrack, "conntrack");
14124 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
14125 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14127 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
14128 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14130 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
14131 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14132 peer_port, RTE_UINT16);
14133 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
14134 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14135 is_orig, "is_orig");
14136 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
14137 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14138 is_original, RTE_UINT32);
14139 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
14140 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14142 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14143 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14145 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14146 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14148 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14149 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14150 is_live, RTE_UINT32);
14151 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14152 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14154 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14155 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14156 s_ack, RTE_UINT32);
14157 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14158 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14160 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14161 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14162 c_ack, RTE_UINT32);
14163 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14164 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14165 last_dir, "last_dir");
14166 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14167 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14169 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14170 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14171 liberal, "liberal");
14172 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14173 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14175 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14176 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14178 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14179 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14181 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14182 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14183 max_ack_win, "max_ack_win");
14184 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14185 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14186 factor, RTE_UINT8);
14187 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14188 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14190 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14191 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14192 re_num, RTE_UINT8);
14193 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14194 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14195 last_win, "last_win");
14196 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14197 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14199 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14200 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14201 last_seq, "last_seq");
14202 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14203 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14205 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14206 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14207 last_ack, "last_ack");
14208 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14209 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14211 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14212 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14213 last_end, "last_end");
14214 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14215 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14217 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14218 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14219 last_index, "last_index");
14220 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14221 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14224 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14225 __rte_unused struct cmdline *cl,
14226 __rte_unused void *data)
14228 struct cmd_set_conntrack_common_result *res = parsed_result;
14230 /* No need to swap to big endian. */
14231 conntrack_context.peer_port = res->peer_port;
14232 conntrack_context.is_original_dir = res->is_original;
14233 conntrack_context.enable = res->en;
14234 conntrack_context.live_connection = res->is_live;
14235 conntrack_context.selective_ack = res->s_ack;
14236 conntrack_context.challenge_ack_passed = res->c_ack;
14237 conntrack_context.last_direction = res->ld;
14238 conntrack_context.liberal_mode = res->lb;
14239 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14240 conntrack_context.max_ack_window = res->factor;
14241 conntrack_context.retransmission_limit = res->re_num;
14242 conntrack_context.last_window = res->lw;
14243 conntrack_context.last_index =
14244 (enum rte_flow_conntrack_tcp_last_index)res->li;
14245 conntrack_context.last_seq = res->ls;
14246 conntrack_context.last_ack = res->la;
14247 conntrack_context.last_end = res->le;
14250 cmdline_parse_inst_t cmd_set_conntrack_common = {
14251 .f = cmd_set_conntrack_common_parsed,
14253 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14254 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14255 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14256 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14257 " last_index <flag>",
14259 (void *)&cmd_set_conntrack_set,
14260 (void *)&cmd_set_conntrack_conntrack,
14261 (void *)&cmd_set_conntrack_common_com,
14262 (void *)&cmd_set_conntrack_common_peer,
14263 (void *)&cmd_set_conntrack_common_peer_value,
14264 (void *)&cmd_set_conntrack_common_is_orig,
14265 (void *)&cmd_set_conntrack_common_is_orig_value,
14266 (void *)&cmd_set_conntrack_common_enable,
14267 (void *)&cmd_set_conntrack_common_enable_value,
14268 (void *)&cmd_set_conntrack_common_live,
14269 (void *)&cmd_set_conntrack_common_live_value,
14270 (void *)&cmd_set_conntrack_common_sack,
14271 (void *)&cmd_set_conntrack_common_sack_value,
14272 (void *)&cmd_set_conntrack_common_cack,
14273 (void *)&cmd_set_conntrack_common_cack_value,
14274 (void *)&cmd_set_conntrack_common_last_dir,
14275 (void *)&cmd_set_conntrack_common_last_dir_value,
14276 (void *)&cmd_set_conntrack_common_liberal,
14277 (void *)&cmd_set_conntrack_common_liberal_value,
14278 (void *)&cmd_set_conntrack_common_state,
14279 (void *)&cmd_set_conntrack_common_state_value,
14280 (void *)&cmd_set_conntrack_common_max_ackwin,
14281 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14282 (void *)&cmd_set_conntrack_common_retrans,
14283 (void *)&cmd_set_conntrack_common_retrans_value,
14284 (void *)&cmd_set_conntrack_common_last_win,
14285 (void *)&cmd_set_conntrack_common_last_win_value,
14286 (void *)&cmd_set_conntrack_common_last_seq,
14287 (void *)&cmd_set_conntrack_common_last_seq_value,
14288 (void *)&cmd_set_conntrack_common_last_ack,
14289 (void *)&cmd_set_conntrack_common_last_ack_value,
14290 (void *)&cmd_set_conntrack_common_last_end,
14291 (void *)&cmd_set_conntrack_common_last_end_value,
14292 (void *)&cmd_set_conntrack_common_last_index,
14293 (void *)&cmd_set_conntrack_common_last_index_value,
14298 /** Set connection tracking object both directions' details */
14299 struct cmd_set_conntrack_dir_result {
14300 cmdline_fixed_string_t set;
14301 cmdline_fixed_string_t conntrack;
14302 cmdline_fixed_string_t dir;
14303 cmdline_fixed_string_t scale;
14304 cmdline_fixed_string_t fin;
14305 cmdline_fixed_string_t ack_seen;
14306 cmdline_fixed_string_t unack;
14307 cmdline_fixed_string_t sent_end;
14308 cmdline_fixed_string_t reply_end;
14309 cmdline_fixed_string_t max_win;
14310 cmdline_fixed_string_t max_ack;
14321 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14322 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14324 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14325 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14326 conntrack, "conntrack");
14327 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14328 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14330 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14331 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14333 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14334 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14335 factor, RTE_UINT32);
14336 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14337 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14339 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14340 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14342 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14343 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14344 ack_seen, "acked");
14345 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14346 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14348 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14349 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14350 unack, "unack_data");
14351 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14352 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14354 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14355 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14356 sent_end, "sent_end");
14357 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14358 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14360 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14361 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14362 reply_end, "reply_end");
14363 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14364 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14366 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14367 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14368 max_win, "max_win");
14369 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14370 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14372 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14373 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14374 max_ack, "max_ack");
14375 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14376 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14379 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14380 __rte_unused struct cmdline *cl,
14381 __rte_unused void *data)
14383 struct cmd_set_conntrack_dir_result *res = parsed_result;
14384 struct rte_flow_tcp_dir_param *dir = NULL;
14386 if (strcmp(res->dir, "orig") == 0)
14387 dir = &conntrack_context.original_dir;
14388 else if (strcmp(res->dir, "rply") == 0)
14389 dir = &conntrack_context.reply_dir;
14392 dir->scale = res->factor;
14393 dir->close_initiated = res->f;
14394 dir->last_ack_seen = res->as;
14395 dir->data_unacked = res->un;
14396 dir->sent_end = res->se;
14397 dir->reply_end = res->re;
14398 dir->max_ack = res->ma;
14399 dir->max_win = res->mw;
14402 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14403 .f = cmd_set_conntrack_dir_parsed,
14405 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14406 " acked <seen> unack_data <unack> sent_end <sent>"
14407 " reply_end <reply> max_win <win> max_ack <ack>",
14409 (void *)&cmd_set_conntrack_set,
14410 (void *)&cmd_set_conntrack_conntrack,
14411 (void *)&cmd_set_conntrack_dir_dir,
14412 (void *)&cmd_set_conntrack_dir_scale,
14413 (void *)&cmd_set_conntrack_dir_scale_value,
14414 (void *)&cmd_set_conntrack_dir_fin,
14415 (void *)&cmd_set_conntrack_dir_fin_value,
14416 (void *)&cmd_set_conntrack_dir_ack,
14417 (void *)&cmd_set_conntrack_dir_ack_value,
14418 (void *)&cmd_set_conntrack_dir_unack_data,
14419 (void *)&cmd_set_conntrack_dir_unack_data_value,
14420 (void *)&cmd_set_conntrack_dir_sent_end,
14421 (void *)&cmd_set_conntrack_dir_sent_end_value,
14422 (void *)&cmd_set_conntrack_dir_reply_end,
14423 (void *)&cmd_set_conntrack_dir_reply_end_value,
14424 (void *)&cmd_set_conntrack_dir_max_win,
14425 (void *)&cmd_set_conntrack_dir_max_win_value,
14426 (void *)&cmd_set_conntrack_dir_max_ack,
14427 (void *)&cmd_set_conntrack_dir_max_ack_value,
14432 /* Strict link priority scheduling mode setting */
14434 cmd_strict_link_prio_parsed(
14435 void *parsed_result,
14436 __rte_unused struct cmdline *cl,
14437 __rte_unused void *data)
14439 struct cmd_vf_tc_bw_result *res = parsed_result;
14440 int ret = -ENOTSUP;
14442 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14445 #ifdef RTE_NET_I40E
14446 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14453 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14456 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14459 fprintf(stderr, "function not implemented\n");
14462 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14466 cmdline_parse_inst_t cmd_strict_link_prio = {
14467 .f = cmd_strict_link_prio_parsed,
14469 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14471 (void *)&cmd_vf_tc_bw_set,
14472 (void *)&cmd_vf_tc_bw_tx,
14473 (void *)&cmd_vf_tc_bw_strict_link_prio,
14474 (void *)&cmd_vf_tc_bw_port_id,
14475 (void *)&cmd_vf_tc_bw_tc_map,
14480 /* Load dynamic device personalization*/
14481 struct cmd_ddp_add_result {
14482 cmdline_fixed_string_t ddp;
14483 cmdline_fixed_string_t add;
14488 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14489 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14490 cmdline_parse_token_string_t cmd_ddp_add_add =
14491 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14492 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14493 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14495 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14496 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14499 cmd_ddp_add_parsed(
14500 void *parsed_result,
14501 __rte_unused struct cmdline *cl,
14502 __rte_unused void *data)
14504 struct cmd_ddp_add_result *res = parsed_result;
14510 int ret = -ENOTSUP;
14512 if (!all_ports_stopped()) {
14513 fprintf(stderr, "Please stop all ports first\n");
14517 filepath = strdup(res->filepath);
14518 if (filepath == NULL) {
14519 fprintf(stderr, "Failed to allocate memory\n");
14522 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14524 buff = open_file(file_fld[0], &size);
14526 free((void *)filepath);
14530 #ifdef RTE_NET_I40E
14531 if (ret == -ENOTSUP)
14532 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14534 RTE_PMD_I40E_PKG_OP_WR_ADD);
14537 if (ret == -EEXIST)
14538 fprintf(stderr, "Profile has already existed.\n");
14540 fprintf(stderr, "Failed to load profile.\n");
14541 else if (file_num == 2)
14542 save_file(file_fld[1], buff, size);
14545 free((void *)filepath);
14548 cmdline_parse_inst_t cmd_ddp_add = {
14549 .f = cmd_ddp_add_parsed,
14551 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14553 (void *)&cmd_ddp_add_ddp,
14554 (void *)&cmd_ddp_add_add,
14555 (void *)&cmd_ddp_add_port_id,
14556 (void *)&cmd_ddp_add_filepath,
14561 /* Delete dynamic device personalization*/
14562 struct cmd_ddp_del_result {
14563 cmdline_fixed_string_t ddp;
14564 cmdline_fixed_string_t del;
14569 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14570 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14571 cmdline_parse_token_string_t cmd_ddp_del_del =
14572 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14573 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14574 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14575 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14576 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14579 cmd_ddp_del_parsed(
14580 void *parsed_result,
14581 __rte_unused struct cmdline *cl,
14582 __rte_unused void *data)
14584 struct cmd_ddp_del_result *res = parsed_result;
14587 int ret = -ENOTSUP;
14589 if (!all_ports_stopped()) {
14590 fprintf(stderr, "Please stop all ports first\n");
14594 buff = open_file(res->filepath, &size);
14598 #ifdef RTE_NET_I40E
14599 if (ret == -ENOTSUP)
14600 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14602 RTE_PMD_I40E_PKG_OP_WR_DEL);
14605 if (ret == -EACCES)
14606 fprintf(stderr, "Profile does not exist.\n");
14608 fprintf(stderr, "Failed to delete profile.\n");
14613 cmdline_parse_inst_t cmd_ddp_del = {
14614 .f = cmd_ddp_del_parsed,
14616 .help_str = "ddp del <port_id> <backup_profile_path>",
14618 (void *)&cmd_ddp_del_ddp,
14619 (void *)&cmd_ddp_del_del,
14620 (void *)&cmd_ddp_del_port_id,
14621 (void *)&cmd_ddp_del_filepath,
14626 /* Get dynamic device personalization profile info */
14627 struct cmd_ddp_info_result {
14628 cmdline_fixed_string_t ddp;
14629 cmdline_fixed_string_t get;
14630 cmdline_fixed_string_t info;
14634 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14635 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14636 cmdline_parse_token_string_t cmd_ddp_info_get =
14637 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14638 cmdline_parse_token_string_t cmd_ddp_info_info =
14639 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14640 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14641 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14644 cmd_ddp_info_parsed(
14645 void *parsed_result,
14646 __rte_unused struct cmdline *cl,
14647 __rte_unused void *data)
14649 struct cmd_ddp_info_result *res = parsed_result;
14652 int ret = -ENOTSUP;
14653 #ifdef RTE_NET_I40E
14656 uint32_t buff_size = 0;
14657 struct rte_pmd_i40e_profile_info info;
14658 uint32_t dev_num = 0;
14659 struct rte_pmd_i40e_ddp_device_id *devs;
14660 uint32_t proto_num = 0;
14661 struct rte_pmd_i40e_proto_info *proto = NULL;
14662 uint32_t pctype_num = 0;
14663 struct rte_pmd_i40e_ptype_info *pctype;
14664 uint32_t ptype_num = 0;
14665 struct rte_pmd_i40e_ptype_info *ptype;
14670 pkg = open_file(res->filepath, &pkg_size);
14674 #ifdef RTE_NET_I40E
14675 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14676 (uint8_t *)&info, sizeof(info),
14677 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14679 printf("Global Track id: 0x%x\n", info.track_id);
14680 printf("Global Version: %d.%d.%d.%d\n",
14681 info.version.major,
14682 info.version.minor,
14683 info.version.update,
14684 info.version.draft);
14685 printf("Global Package name: %s\n\n", info.name);
14688 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14689 (uint8_t *)&info, sizeof(info),
14690 RTE_PMD_I40E_PKG_INFO_HEADER);
14692 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14693 printf("i40e Profile Version: %d.%d.%d.%d\n",
14694 info.version.major,
14695 info.version.minor,
14696 info.version.update,
14697 info.version.draft);
14698 printf("i40e Profile name: %s\n\n", info.name);
14701 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14702 (uint8_t *)&buff_size, sizeof(buff_size),
14703 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14704 if (!ret && buff_size) {
14705 buff = (uint8_t *)malloc(buff_size);
14707 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14709 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14711 printf("Package Notes:\n%s\n\n", buff);
14716 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14717 (uint8_t *)&dev_num, sizeof(dev_num),
14718 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14719 if (!ret && dev_num) {
14720 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14721 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14723 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14724 (uint8_t *)devs, buff_size,
14725 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14727 printf("List of supported devices:\n");
14728 for (i = 0; i < dev_num; i++) {
14729 printf(" %04X:%04X %04X:%04X\n",
14730 devs[i].vendor_dev_id >> 16,
14731 devs[i].vendor_dev_id & 0xFFFF,
14732 devs[i].sub_vendor_dev_id >> 16,
14733 devs[i].sub_vendor_dev_id & 0xFFFF);
14741 /* get information about protocols and packet types */
14742 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14743 (uint8_t *)&proto_num, sizeof(proto_num),
14744 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14745 if (ret || !proto_num)
14746 goto no_print_return;
14748 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14749 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14751 goto no_print_return;
14753 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14755 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14757 printf("List of used protocols:\n");
14758 for (i = 0; i < proto_num; i++)
14759 printf(" %2u: %s\n", proto[i].proto_id,
14763 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14764 (uint8_t *)&pctype_num, sizeof(pctype_num),
14765 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14766 if (ret || !pctype_num)
14767 goto no_print_pctypes;
14769 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14770 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14772 goto no_print_pctypes;
14774 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14776 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14779 goto no_print_pctypes;
14782 printf("List of defined packet classification types:\n");
14783 for (i = 0; i < pctype_num; i++) {
14784 printf(" %2u:", pctype[i].ptype_id);
14785 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14786 proto_id = pctype[i].protocols[j];
14787 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14788 for (n = 0; n < proto_num; n++) {
14789 if (proto[n].proto_id == proto_id) {
14790 printf(" %s", proto[n].name);
14803 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14805 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14806 if (ret || !ptype_num)
14807 goto no_print_return;
14809 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14810 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14812 goto no_print_return;
14814 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14816 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14819 goto no_print_return;
14821 printf("List of defined packet types:\n");
14822 for (i = 0; i < ptype_num; i++) {
14823 printf(" %2u:", ptype[i].ptype_id);
14824 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14825 proto_id = ptype[i].protocols[j];
14826 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14827 for (n = 0; n < proto_num; n++) {
14828 if (proto[n].proto_id == proto_id) {
14829 printf(" %s", proto[n].name);
14844 if (ret == -ENOTSUP)
14845 fprintf(stderr, "Function not supported in PMD\n");
14849 cmdline_parse_inst_t cmd_ddp_get_info = {
14850 .f = cmd_ddp_info_parsed,
14852 .help_str = "ddp get info <profile_path>",
14854 (void *)&cmd_ddp_info_ddp,
14855 (void *)&cmd_ddp_info_get,
14856 (void *)&cmd_ddp_info_info,
14857 (void *)&cmd_ddp_info_filepath,
14862 /* Get dynamic device personalization profile info list*/
14863 #define PROFILE_INFO_SIZE 48
14864 #define MAX_PROFILE_NUM 16
14866 struct cmd_ddp_get_list_result {
14867 cmdline_fixed_string_t ddp;
14868 cmdline_fixed_string_t get;
14869 cmdline_fixed_string_t list;
14873 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14874 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14875 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14876 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14877 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14878 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14879 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14880 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14884 cmd_ddp_get_list_parsed(
14885 __rte_unused void *parsed_result,
14886 __rte_unused struct cmdline *cl,
14887 __rte_unused void *data)
14889 #ifdef RTE_NET_I40E
14890 struct cmd_ddp_get_list_result *res = parsed_result;
14891 struct rte_pmd_i40e_profile_list *p_list;
14892 struct rte_pmd_i40e_profile_info *p_info;
14897 int ret = -ENOTSUP;
14899 #ifdef RTE_NET_I40E
14900 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14901 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14903 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14907 if (ret == -ENOTSUP)
14908 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14909 (uint8_t *)p_list, size);
14912 p_num = p_list->p_count;
14913 printf("Profile number is: %d\n\n", p_num);
14915 for (i = 0; i < p_num; i++) {
14916 p_info = &p_list->p_info[i];
14917 printf("Profile %d:\n", i);
14918 printf("Track id: 0x%x\n", p_info->track_id);
14919 printf("Version: %d.%d.%d.%d\n",
14920 p_info->version.major,
14921 p_info->version.minor,
14922 p_info->version.update,
14923 p_info->version.draft);
14924 printf("Profile name: %s\n\n", p_info->name);
14932 fprintf(stderr, "Failed to get ddp list\n");
14935 cmdline_parse_inst_t cmd_ddp_get_list = {
14936 .f = cmd_ddp_get_list_parsed,
14938 .help_str = "ddp get list <port_id>",
14940 (void *)&cmd_ddp_get_list_ddp,
14941 (void *)&cmd_ddp_get_list_get,
14942 (void *)&cmd_ddp_get_list_list,
14943 (void *)&cmd_ddp_get_list_port_id,
14948 /* Configure input set */
14949 struct cmd_cfg_input_set_result {
14950 cmdline_fixed_string_t port;
14951 cmdline_fixed_string_t cfg;
14953 cmdline_fixed_string_t pctype;
14955 cmdline_fixed_string_t inset_type;
14956 cmdline_fixed_string_t opt;
14957 cmdline_fixed_string_t field;
14962 cmd_cfg_input_set_parsed(
14963 __rte_unused void *parsed_result,
14964 __rte_unused struct cmdline *cl,
14965 __rte_unused void *data)
14967 #ifdef RTE_NET_I40E
14968 struct cmd_cfg_input_set_result *res = parsed_result;
14969 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14970 struct rte_pmd_i40e_inset inset;
14972 int ret = -ENOTSUP;
14974 if (!all_ports_stopped()) {
14975 fprintf(stderr, "Please stop all ports first\n");
14979 #ifdef RTE_NET_I40E
14980 if (!strcmp(res->inset_type, "hash_inset"))
14981 inset_type = INSET_HASH;
14982 else if (!strcmp(res->inset_type, "fdir_inset"))
14983 inset_type = INSET_FDIR;
14984 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14985 inset_type = INSET_FDIR_FLX;
14986 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14987 &inset, inset_type);
14989 fprintf(stderr, "Failed to get input set.\n");
14993 if (!strcmp(res->opt, "get")) {
14994 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14997 printf("Field index %d is enabled.\n", res->field_idx);
14999 printf("Field index %d is disabled.\n", res->field_idx);
15001 } else if (!strcmp(res->opt, "set"))
15002 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15004 else if (!strcmp(res->opt, "clear"))
15005 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15008 fprintf(stderr, "Failed to configure input set field.\n");
15012 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15013 &inset, inset_type);
15015 fprintf(stderr, "Failed to set input set.\n");
15020 if (ret == -ENOTSUP)
15021 fprintf(stderr, "Function not supported\n");
15024 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15025 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15027 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15028 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15030 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15031 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15032 port_id, RTE_UINT16);
15033 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15034 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15036 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15037 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15038 pctype_id, RTE_UINT8);
15039 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15040 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15042 "hash_inset#fdir_inset#fdir_flx_inset");
15043 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15044 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15045 opt, "get#set#clear");
15046 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15047 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15049 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15050 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15051 field_idx, RTE_UINT8);
15053 cmdline_parse_inst_t cmd_cfg_input_set = {
15054 .f = cmd_cfg_input_set_parsed,
15056 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15057 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15059 (void *)&cmd_cfg_input_set_port,
15060 (void *)&cmd_cfg_input_set_cfg,
15061 (void *)&cmd_cfg_input_set_port_id,
15062 (void *)&cmd_cfg_input_set_pctype,
15063 (void *)&cmd_cfg_input_set_pctype_id,
15064 (void *)&cmd_cfg_input_set_inset_type,
15065 (void *)&cmd_cfg_input_set_opt,
15066 (void *)&cmd_cfg_input_set_field,
15067 (void *)&cmd_cfg_input_set_field_idx,
15072 /* Clear input set */
15073 struct cmd_clear_input_set_result {
15074 cmdline_fixed_string_t port;
15075 cmdline_fixed_string_t cfg;
15077 cmdline_fixed_string_t pctype;
15079 cmdline_fixed_string_t inset_type;
15080 cmdline_fixed_string_t clear;
15081 cmdline_fixed_string_t all;
15085 cmd_clear_input_set_parsed(
15086 __rte_unused void *parsed_result,
15087 __rte_unused struct cmdline *cl,
15088 __rte_unused void *data)
15090 #ifdef RTE_NET_I40E
15091 struct cmd_clear_input_set_result *res = parsed_result;
15092 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15093 struct rte_pmd_i40e_inset inset;
15095 int ret = -ENOTSUP;
15097 if (!all_ports_stopped()) {
15098 fprintf(stderr, "Please stop all ports first\n");
15102 #ifdef RTE_NET_I40E
15103 if (!strcmp(res->inset_type, "hash_inset"))
15104 inset_type = INSET_HASH;
15105 else if (!strcmp(res->inset_type, "fdir_inset"))
15106 inset_type = INSET_FDIR;
15107 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15108 inset_type = INSET_FDIR_FLX;
15110 memset(&inset, 0, sizeof(inset));
15112 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15113 &inset, inset_type);
15115 fprintf(stderr, "Failed to clear input set.\n");
15121 if (ret == -ENOTSUP)
15122 fprintf(stderr, "Function not supported\n");
15125 cmdline_parse_token_string_t cmd_clear_input_set_port =
15126 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15128 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15129 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15131 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15132 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15133 port_id, RTE_UINT16);
15134 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15135 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15137 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15138 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15139 pctype_id, RTE_UINT8);
15140 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15141 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15143 "hash_inset#fdir_inset#fdir_flx_inset");
15144 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15145 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15147 cmdline_parse_token_string_t cmd_clear_input_set_all =
15148 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15151 cmdline_parse_inst_t cmd_clear_input_set = {
15152 .f = cmd_clear_input_set_parsed,
15154 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15155 "fdir_inset|fdir_flx_inset clear all",
15157 (void *)&cmd_clear_input_set_port,
15158 (void *)&cmd_clear_input_set_cfg,
15159 (void *)&cmd_clear_input_set_port_id,
15160 (void *)&cmd_clear_input_set_pctype,
15161 (void *)&cmd_clear_input_set_pctype_id,
15162 (void *)&cmd_clear_input_set_inset_type,
15163 (void *)&cmd_clear_input_set_clear,
15164 (void *)&cmd_clear_input_set_all,
15169 /* show vf stats */
15171 /* Common result structure for show vf stats */
15172 struct cmd_show_vf_stats_result {
15173 cmdline_fixed_string_t show;
15174 cmdline_fixed_string_t vf;
15175 cmdline_fixed_string_t stats;
15180 /* Common CLI fields show vf stats*/
15181 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15182 TOKEN_STRING_INITIALIZER
15183 (struct cmd_show_vf_stats_result,
15185 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15186 TOKEN_STRING_INITIALIZER
15187 (struct cmd_show_vf_stats_result,
15189 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15190 TOKEN_STRING_INITIALIZER
15191 (struct cmd_show_vf_stats_result,
15193 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15194 TOKEN_NUM_INITIALIZER
15195 (struct cmd_show_vf_stats_result,
15196 port_id, RTE_UINT16);
15197 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15198 TOKEN_NUM_INITIALIZER
15199 (struct cmd_show_vf_stats_result,
15200 vf_id, RTE_UINT16);
15203 cmd_show_vf_stats_parsed(
15204 void *parsed_result,
15205 __rte_unused struct cmdline *cl,
15206 __rte_unused void *data)
15208 struct cmd_show_vf_stats_result *res = parsed_result;
15209 struct rte_eth_stats stats;
15210 int ret = -ENOTSUP;
15211 static const char *nic_stats_border = "########################";
15213 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15216 memset(&stats, 0, sizeof(stats));
15218 #ifdef RTE_NET_I40E
15219 if (ret == -ENOTSUP)
15220 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15224 #ifdef RTE_NET_BNXT
15225 if (ret == -ENOTSUP)
15226 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15235 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15238 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15241 fprintf(stderr, "function not implemented\n");
15244 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15247 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15248 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15250 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15252 stats.ipackets, stats.imissed, stats.ibytes);
15253 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15254 printf(" RX-nombuf: %-10"PRIu64"\n",
15256 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15258 stats.opackets, stats.oerrors, stats.obytes);
15260 printf(" %s############################%s\n",
15261 nic_stats_border, nic_stats_border);
15264 cmdline_parse_inst_t cmd_show_vf_stats = {
15265 .f = cmd_show_vf_stats_parsed,
15267 .help_str = "show vf stats <port_id> <vf_id>",
15269 (void *)&cmd_show_vf_stats_show,
15270 (void *)&cmd_show_vf_stats_vf,
15271 (void *)&cmd_show_vf_stats_stats,
15272 (void *)&cmd_show_vf_stats_port_id,
15273 (void *)&cmd_show_vf_stats_vf_id,
15278 /* clear vf stats */
15280 /* Common result structure for clear vf stats */
15281 struct cmd_clear_vf_stats_result {
15282 cmdline_fixed_string_t clear;
15283 cmdline_fixed_string_t vf;
15284 cmdline_fixed_string_t stats;
15289 /* Common CLI fields clear vf stats*/
15290 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15291 TOKEN_STRING_INITIALIZER
15292 (struct cmd_clear_vf_stats_result,
15294 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15295 TOKEN_STRING_INITIALIZER
15296 (struct cmd_clear_vf_stats_result,
15298 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15299 TOKEN_STRING_INITIALIZER
15300 (struct cmd_clear_vf_stats_result,
15302 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15303 TOKEN_NUM_INITIALIZER
15304 (struct cmd_clear_vf_stats_result,
15305 port_id, RTE_UINT16);
15306 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15307 TOKEN_NUM_INITIALIZER
15308 (struct cmd_clear_vf_stats_result,
15309 vf_id, RTE_UINT16);
15312 cmd_clear_vf_stats_parsed(
15313 void *parsed_result,
15314 __rte_unused struct cmdline *cl,
15315 __rte_unused void *data)
15317 struct cmd_clear_vf_stats_result *res = parsed_result;
15318 int ret = -ENOTSUP;
15320 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15323 #ifdef RTE_NET_I40E
15324 if (ret == -ENOTSUP)
15325 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15328 #ifdef RTE_NET_BNXT
15329 if (ret == -ENOTSUP)
15330 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15338 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15341 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15344 fprintf(stderr, "function not implemented\n");
15347 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15351 cmdline_parse_inst_t cmd_clear_vf_stats = {
15352 .f = cmd_clear_vf_stats_parsed,
15354 .help_str = "clear vf stats <port_id> <vf_id>",
15356 (void *)&cmd_clear_vf_stats_clear,
15357 (void *)&cmd_clear_vf_stats_vf,
15358 (void *)&cmd_clear_vf_stats_stats,
15359 (void *)&cmd_clear_vf_stats_port_id,
15360 (void *)&cmd_clear_vf_stats_vf_id,
15365 /* port config pctype mapping reset */
15367 /* Common result structure for port config pctype mapping reset */
15368 struct cmd_pctype_mapping_reset_result {
15369 cmdline_fixed_string_t port;
15370 cmdline_fixed_string_t config;
15372 cmdline_fixed_string_t pctype;
15373 cmdline_fixed_string_t mapping;
15374 cmdline_fixed_string_t reset;
15377 /* Common CLI fields for port config pctype mapping reset*/
15378 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15379 TOKEN_STRING_INITIALIZER
15380 (struct cmd_pctype_mapping_reset_result,
15382 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15383 TOKEN_STRING_INITIALIZER
15384 (struct cmd_pctype_mapping_reset_result,
15386 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15387 TOKEN_NUM_INITIALIZER
15388 (struct cmd_pctype_mapping_reset_result,
15389 port_id, RTE_UINT16);
15390 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15391 TOKEN_STRING_INITIALIZER
15392 (struct cmd_pctype_mapping_reset_result,
15394 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15395 TOKEN_STRING_INITIALIZER
15396 (struct cmd_pctype_mapping_reset_result,
15397 mapping, "mapping");
15398 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15399 TOKEN_STRING_INITIALIZER
15400 (struct cmd_pctype_mapping_reset_result,
15404 cmd_pctype_mapping_reset_parsed(
15405 void *parsed_result,
15406 __rte_unused struct cmdline *cl,
15407 __rte_unused void *data)
15409 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15410 int ret = -ENOTSUP;
15412 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15415 #ifdef RTE_NET_I40E
15416 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15423 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15426 fprintf(stderr, "function not implemented\n");
15429 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15433 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15434 .f = cmd_pctype_mapping_reset_parsed,
15436 .help_str = "port config <port_id> pctype mapping reset",
15438 (void *)&cmd_pctype_mapping_reset_port,
15439 (void *)&cmd_pctype_mapping_reset_config,
15440 (void *)&cmd_pctype_mapping_reset_port_id,
15441 (void *)&cmd_pctype_mapping_reset_pctype,
15442 (void *)&cmd_pctype_mapping_reset_mapping,
15443 (void *)&cmd_pctype_mapping_reset_reset,
15448 /* show port pctype mapping */
15450 /* Common result structure for show port pctype mapping */
15451 struct cmd_pctype_mapping_get_result {
15452 cmdline_fixed_string_t show;
15453 cmdline_fixed_string_t port;
15455 cmdline_fixed_string_t pctype;
15456 cmdline_fixed_string_t mapping;
15459 /* Common CLI fields for pctype mapping get */
15460 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15461 TOKEN_STRING_INITIALIZER
15462 (struct cmd_pctype_mapping_get_result,
15464 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15465 TOKEN_STRING_INITIALIZER
15466 (struct cmd_pctype_mapping_get_result,
15468 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15469 TOKEN_NUM_INITIALIZER
15470 (struct cmd_pctype_mapping_get_result,
15471 port_id, RTE_UINT16);
15472 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15473 TOKEN_STRING_INITIALIZER
15474 (struct cmd_pctype_mapping_get_result,
15476 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15477 TOKEN_STRING_INITIALIZER
15478 (struct cmd_pctype_mapping_get_result,
15479 mapping, "mapping");
15482 cmd_pctype_mapping_get_parsed(
15483 void *parsed_result,
15484 __rte_unused struct cmdline *cl,
15485 __rte_unused void *data)
15487 struct cmd_pctype_mapping_get_result *res = parsed_result;
15488 int ret = -ENOTSUP;
15489 #ifdef RTE_NET_I40E
15490 struct rte_pmd_i40e_flow_type_mapping
15491 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15492 int i, j, first_pctype;
15495 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15498 #ifdef RTE_NET_I40E
15499 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15506 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15509 fprintf(stderr, "function not implemented\n");
15512 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15516 #ifdef RTE_NET_I40E
15517 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15518 if (mapping[i].pctype != 0ULL) {
15521 printf("pctype: ");
15522 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15523 if (mapping[i].pctype & (1ULL << j)) {
15524 printf(first_pctype ?
15525 "%02d" : ",%02d", j);
15529 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15535 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15536 .f = cmd_pctype_mapping_get_parsed,
15538 .help_str = "show port <port_id> pctype mapping",
15540 (void *)&cmd_pctype_mapping_get_show,
15541 (void *)&cmd_pctype_mapping_get_port,
15542 (void *)&cmd_pctype_mapping_get_port_id,
15543 (void *)&cmd_pctype_mapping_get_pctype,
15544 (void *)&cmd_pctype_mapping_get_mapping,
15549 /* port config pctype mapping update */
15551 /* Common result structure for port config pctype mapping update */
15552 struct cmd_pctype_mapping_update_result {
15553 cmdline_fixed_string_t port;
15554 cmdline_fixed_string_t config;
15556 cmdline_fixed_string_t pctype;
15557 cmdline_fixed_string_t mapping;
15558 cmdline_fixed_string_t update;
15559 cmdline_fixed_string_t pctype_list;
15560 uint16_t flow_type;
15563 /* Common CLI fields for pctype mapping update*/
15564 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15565 TOKEN_STRING_INITIALIZER
15566 (struct cmd_pctype_mapping_update_result,
15568 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15569 TOKEN_STRING_INITIALIZER
15570 (struct cmd_pctype_mapping_update_result,
15572 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15573 TOKEN_NUM_INITIALIZER
15574 (struct cmd_pctype_mapping_update_result,
15575 port_id, RTE_UINT16);
15576 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15577 TOKEN_STRING_INITIALIZER
15578 (struct cmd_pctype_mapping_update_result,
15580 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15581 TOKEN_STRING_INITIALIZER
15582 (struct cmd_pctype_mapping_update_result,
15583 mapping, "mapping");
15584 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15585 TOKEN_STRING_INITIALIZER
15586 (struct cmd_pctype_mapping_update_result,
15588 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15589 TOKEN_STRING_INITIALIZER
15590 (struct cmd_pctype_mapping_update_result,
15591 pctype_list, NULL);
15592 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15593 TOKEN_NUM_INITIALIZER
15594 (struct cmd_pctype_mapping_update_result,
15595 flow_type, RTE_UINT16);
15598 cmd_pctype_mapping_update_parsed(
15599 void *parsed_result,
15600 __rte_unused struct cmdline *cl,
15601 __rte_unused void *data)
15603 struct cmd_pctype_mapping_update_result *res = parsed_result;
15604 int ret = -ENOTSUP;
15605 #ifdef RTE_NET_I40E
15606 struct rte_pmd_i40e_flow_type_mapping mapping;
15608 unsigned int nb_item;
15609 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15612 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15615 #ifdef RTE_NET_I40E
15616 nb_item = parse_item_list(res->pctype_list, "pctypes",
15617 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15618 mapping.flow_type = res->flow_type;
15619 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15620 mapping.pctype |= (1ULL << pctype_list[i]);
15621 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15631 fprintf(stderr, "invalid pctype or flow type\n");
15634 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15637 fprintf(stderr, "function not implemented\n");
15640 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15644 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15645 .f = cmd_pctype_mapping_update_parsed,
15647 .help_str = "port config <port_id> pctype mapping update"
15648 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15650 (void *)&cmd_pctype_mapping_update_port,
15651 (void *)&cmd_pctype_mapping_update_config,
15652 (void *)&cmd_pctype_mapping_update_port_id,
15653 (void *)&cmd_pctype_mapping_update_pctype,
15654 (void *)&cmd_pctype_mapping_update_mapping,
15655 (void *)&cmd_pctype_mapping_update_update,
15656 (void *)&cmd_pctype_mapping_update_pc_type,
15657 (void *)&cmd_pctype_mapping_update_flow_type,
15662 /* ptype mapping get */
15664 /* Common result structure for ptype mapping get */
15665 struct cmd_ptype_mapping_get_result {
15666 cmdline_fixed_string_t ptype;
15667 cmdline_fixed_string_t mapping;
15668 cmdline_fixed_string_t get;
15670 uint8_t valid_only;
15673 /* Common CLI fields for ptype mapping get */
15674 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15675 TOKEN_STRING_INITIALIZER
15676 (struct cmd_ptype_mapping_get_result,
15678 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15679 TOKEN_STRING_INITIALIZER
15680 (struct cmd_ptype_mapping_get_result,
15681 mapping, "mapping");
15682 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15683 TOKEN_STRING_INITIALIZER
15684 (struct cmd_ptype_mapping_get_result,
15686 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15687 TOKEN_NUM_INITIALIZER
15688 (struct cmd_ptype_mapping_get_result,
15689 port_id, RTE_UINT16);
15690 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15691 TOKEN_NUM_INITIALIZER
15692 (struct cmd_ptype_mapping_get_result,
15693 valid_only, RTE_UINT8);
15696 cmd_ptype_mapping_get_parsed(
15697 void *parsed_result,
15698 __rte_unused struct cmdline *cl,
15699 __rte_unused void *data)
15701 struct cmd_ptype_mapping_get_result *res = parsed_result;
15702 int ret = -ENOTSUP;
15703 #ifdef RTE_NET_I40E
15704 int max_ptype_num = 256;
15705 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15710 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15713 #ifdef RTE_NET_I40E
15714 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15725 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15728 fprintf(stderr, "function not implemented\n");
15731 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15734 #ifdef RTE_NET_I40E
15736 for (i = 0; i < count; i++)
15737 printf("%3d\t0x%08x\n",
15738 mapping[i].hw_ptype, mapping[i].sw_ptype);
15743 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15744 .f = cmd_ptype_mapping_get_parsed,
15746 .help_str = "ptype mapping get <port_id> <valid_only>",
15748 (void *)&cmd_ptype_mapping_get_ptype,
15749 (void *)&cmd_ptype_mapping_get_mapping,
15750 (void *)&cmd_ptype_mapping_get_get,
15751 (void *)&cmd_ptype_mapping_get_port_id,
15752 (void *)&cmd_ptype_mapping_get_valid_only,
15757 /* ptype mapping replace */
15759 /* Common result structure for ptype mapping replace */
15760 struct cmd_ptype_mapping_replace_result {
15761 cmdline_fixed_string_t ptype;
15762 cmdline_fixed_string_t mapping;
15763 cmdline_fixed_string_t replace;
15770 /* Common CLI fields for ptype mapping replace */
15771 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15772 TOKEN_STRING_INITIALIZER
15773 (struct cmd_ptype_mapping_replace_result,
15775 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15776 TOKEN_STRING_INITIALIZER
15777 (struct cmd_ptype_mapping_replace_result,
15778 mapping, "mapping");
15779 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15780 TOKEN_STRING_INITIALIZER
15781 (struct cmd_ptype_mapping_replace_result,
15782 replace, "replace");
15783 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15784 TOKEN_NUM_INITIALIZER
15785 (struct cmd_ptype_mapping_replace_result,
15786 port_id, RTE_UINT16);
15787 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15788 TOKEN_NUM_INITIALIZER
15789 (struct cmd_ptype_mapping_replace_result,
15790 target, RTE_UINT32);
15791 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15792 TOKEN_NUM_INITIALIZER
15793 (struct cmd_ptype_mapping_replace_result,
15795 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15796 TOKEN_NUM_INITIALIZER
15797 (struct cmd_ptype_mapping_replace_result,
15798 pkt_type, RTE_UINT32);
15801 cmd_ptype_mapping_replace_parsed(
15802 void *parsed_result,
15803 __rte_unused struct cmdline *cl,
15804 __rte_unused void *data)
15806 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15807 int ret = -ENOTSUP;
15809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15812 #ifdef RTE_NET_I40E
15813 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15823 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15824 res->target, res->pkt_type);
15827 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15830 fprintf(stderr, "function not implemented\n");
15833 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15837 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15838 .f = cmd_ptype_mapping_replace_parsed,
15841 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15843 (void *)&cmd_ptype_mapping_replace_ptype,
15844 (void *)&cmd_ptype_mapping_replace_mapping,
15845 (void *)&cmd_ptype_mapping_replace_replace,
15846 (void *)&cmd_ptype_mapping_replace_port_id,
15847 (void *)&cmd_ptype_mapping_replace_target,
15848 (void *)&cmd_ptype_mapping_replace_mask,
15849 (void *)&cmd_ptype_mapping_replace_pkt_type,
15854 /* ptype mapping reset */
15856 /* Common result structure for ptype mapping reset */
15857 struct cmd_ptype_mapping_reset_result {
15858 cmdline_fixed_string_t ptype;
15859 cmdline_fixed_string_t mapping;
15860 cmdline_fixed_string_t reset;
15864 /* Common CLI fields for ptype mapping reset*/
15865 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15866 TOKEN_STRING_INITIALIZER
15867 (struct cmd_ptype_mapping_reset_result,
15869 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15870 TOKEN_STRING_INITIALIZER
15871 (struct cmd_ptype_mapping_reset_result,
15872 mapping, "mapping");
15873 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15874 TOKEN_STRING_INITIALIZER
15875 (struct cmd_ptype_mapping_reset_result,
15877 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15878 TOKEN_NUM_INITIALIZER
15879 (struct cmd_ptype_mapping_reset_result,
15880 port_id, RTE_UINT16);
15883 cmd_ptype_mapping_reset_parsed(
15884 void *parsed_result,
15885 __rte_unused struct cmdline *cl,
15886 __rte_unused void *data)
15888 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15889 int ret = -ENOTSUP;
15891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15894 #ifdef RTE_NET_I40E
15895 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15902 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15905 fprintf(stderr, "function not implemented\n");
15908 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15912 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15913 .f = cmd_ptype_mapping_reset_parsed,
15915 .help_str = "ptype mapping reset <port_id>",
15917 (void *)&cmd_ptype_mapping_reset_ptype,
15918 (void *)&cmd_ptype_mapping_reset_mapping,
15919 (void *)&cmd_ptype_mapping_reset_reset,
15920 (void *)&cmd_ptype_mapping_reset_port_id,
15925 /* ptype mapping update */
15927 /* Common result structure for ptype mapping update */
15928 struct cmd_ptype_mapping_update_result {
15929 cmdline_fixed_string_t ptype;
15930 cmdline_fixed_string_t mapping;
15931 cmdline_fixed_string_t reset;
15937 /* Common CLI fields for ptype mapping update*/
15938 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15939 TOKEN_STRING_INITIALIZER
15940 (struct cmd_ptype_mapping_update_result,
15942 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15943 TOKEN_STRING_INITIALIZER
15944 (struct cmd_ptype_mapping_update_result,
15945 mapping, "mapping");
15946 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15947 TOKEN_STRING_INITIALIZER
15948 (struct cmd_ptype_mapping_update_result,
15950 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15951 TOKEN_NUM_INITIALIZER
15952 (struct cmd_ptype_mapping_update_result,
15953 port_id, RTE_UINT16);
15954 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15955 TOKEN_NUM_INITIALIZER
15956 (struct cmd_ptype_mapping_update_result,
15957 hw_ptype, RTE_UINT8);
15958 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15959 TOKEN_NUM_INITIALIZER
15960 (struct cmd_ptype_mapping_update_result,
15961 sw_ptype, RTE_UINT32);
15964 cmd_ptype_mapping_update_parsed(
15965 void *parsed_result,
15966 __rte_unused struct cmdline *cl,
15967 __rte_unused void *data)
15969 struct cmd_ptype_mapping_update_result *res = parsed_result;
15970 int ret = -ENOTSUP;
15971 #ifdef RTE_NET_I40E
15972 struct rte_pmd_i40e_ptype_mapping mapping;
15974 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15977 #ifdef RTE_NET_I40E
15978 mapping.hw_ptype = res->hw_ptype;
15979 mapping.sw_ptype = res->sw_ptype;
15980 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15990 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15993 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15996 fprintf(stderr, "function not implemented\n");
15999 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
16003 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16004 .f = cmd_ptype_mapping_update_parsed,
16006 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16008 (void *)&cmd_ptype_mapping_update_ptype,
16009 (void *)&cmd_ptype_mapping_update_mapping,
16010 (void *)&cmd_ptype_mapping_update_update,
16011 (void *)&cmd_ptype_mapping_update_port_id,
16012 (void *)&cmd_ptype_mapping_update_hw_ptype,
16013 (void *)&cmd_ptype_mapping_update_sw_ptype,
16018 /* Common result structure for file commands */
16019 struct cmd_cmdfile_result {
16020 cmdline_fixed_string_t load;
16021 cmdline_fixed_string_t filename;
16024 /* Common CLI fields for file commands */
16025 cmdline_parse_token_string_t cmd_load_cmdfile =
16026 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16027 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16028 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16031 cmd_load_from_file_parsed(
16032 void *parsed_result,
16033 __rte_unused struct cmdline *cl,
16034 __rte_unused void *data)
16036 struct cmd_cmdfile_result *res = parsed_result;
16038 cmdline_read_from_file(res->filename);
16041 cmdline_parse_inst_t cmd_load_from_file = {
16042 .f = cmd_load_from_file_parsed,
16044 .help_str = "load <filename>",
16046 (void *)&cmd_load_cmdfile,
16047 (void *)&cmd_load_cmdfile_filename,
16052 /* Get Rx offloads capabilities */
16053 struct cmd_rx_offload_get_capa_result {
16054 cmdline_fixed_string_t show;
16055 cmdline_fixed_string_t port;
16057 cmdline_fixed_string_t rx_offload;
16058 cmdline_fixed_string_t capabilities;
16061 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16062 TOKEN_STRING_INITIALIZER
16063 (struct cmd_rx_offload_get_capa_result,
16065 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16066 TOKEN_STRING_INITIALIZER
16067 (struct cmd_rx_offload_get_capa_result,
16069 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16070 TOKEN_NUM_INITIALIZER
16071 (struct cmd_rx_offload_get_capa_result,
16072 port_id, RTE_UINT16);
16073 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16074 TOKEN_STRING_INITIALIZER
16075 (struct cmd_rx_offload_get_capa_result,
16076 rx_offload, "rx_offload");
16077 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16078 TOKEN_STRING_INITIALIZER
16079 (struct cmd_rx_offload_get_capa_result,
16080 capabilities, "capabilities");
16083 print_rx_offloads(uint64_t offloads)
16085 uint64_t single_offload;
16093 begin = __builtin_ctzll(offloads);
16094 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16096 single_offload = 1ULL << begin;
16097 for (bit = begin; bit < end; bit++) {
16098 if (offloads & single_offload)
16100 rte_eth_dev_rx_offload_name(single_offload));
16101 single_offload <<= 1;
16106 cmd_rx_offload_get_capa_parsed(
16107 void *parsed_result,
16108 __rte_unused struct cmdline *cl,
16109 __rte_unused void *data)
16111 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16112 struct rte_eth_dev_info dev_info;
16113 portid_t port_id = res->port_id;
16114 uint64_t queue_offloads;
16115 uint64_t port_offloads;
16118 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16122 queue_offloads = dev_info.rx_queue_offload_capa;
16123 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16125 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16126 printf(" Per Queue :");
16127 print_rx_offloads(queue_offloads);
16130 printf(" Per Port :");
16131 print_rx_offloads(port_offloads);
16135 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16136 .f = cmd_rx_offload_get_capa_parsed,
16138 .help_str = "show port <port_id> rx_offload capabilities",
16140 (void *)&cmd_rx_offload_get_capa_show,
16141 (void *)&cmd_rx_offload_get_capa_port,
16142 (void *)&cmd_rx_offload_get_capa_port_id,
16143 (void *)&cmd_rx_offload_get_capa_rx_offload,
16144 (void *)&cmd_rx_offload_get_capa_capabilities,
16149 /* Get Rx offloads configuration */
16150 struct cmd_rx_offload_get_configuration_result {
16151 cmdline_fixed_string_t show;
16152 cmdline_fixed_string_t port;
16154 cmdline_fixed_string_t rx_offload;
16155 cmdline_fixed_string_t configuration;
16158 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16159 TOKEN_STRING_INITIALIZER
16160 (struct cmd_rx_offload_get_configuration_result,
16162 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16163 TOKEN_STRING_INITIALIZER
16164 (struct cmd_rx_offload_get_configuration_result,
16166 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16167 TOKEN_NUM_INITIALIZER
16168 (struct cmd_rx_offload_get_configuration_result,
16169 port_id, RTE_UINT16);
16170 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16171 TOKEN_STRING_INITIALIZER
16172 (struct cmd_rx_offload_get_configuration_result,
16173 rx_offload, "rx_offload");
16174 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16175 TOKEN_STRING_INITIALIZER
16176 (struct cmd_rx_offload_get_configuration_result,
16177 configuration, "configuration");
16180 cmd_rx_offload_get_configuration_parsed(
16181 void *parsed_result,
16182 __rte_unused struct cmdline *cl,
16183 __rte_unused void *data)
16185 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16186 struct rte_eth_dev_info dev_info;
16187 portid_t port_id = res->port_id;
16188 struct rte_port *port = &ports[port_id];
16189 struct rte_eth_conf dev_conf;
16190 uint64_t port_offloads;
16191 uint64_t queue_offloads;
16192 uint16_t nb_rx_queues;
16196 printf("Rx Offloading Configuration of port %d :\n", port_id);
16198 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16202 port_offloads = dev_conf.rxmode.offloads;
16204 print_rx_offloads(port_offloads);
16207 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16211 nb_rx_queues = dev_info.nb_rx_queues;
16212 for (q = 0; q < nb_rx_queues; q++) {
16213 queue_offloads = port->rxq[q].conf.offloads;
16214 printf(" Queue[%2d] :", q);
16215 print_rx_offloads(queue_offloads);
16221 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16222 .f = cmd_rx_offload_get_configuration_parsed,
16224 .help_str = "show port <port_id> rx_offload configuration",
16226 (void *)&cmd_rx_offload_get_configuration_show,
16227 (void *)&cmd_rx_offload_get_configuration_port,
16228 (void *)&cmd_rx_offload_get_configuration_port_id,
16229 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16230 (void *)&cmd_rx_offload_get_configuration_configuration,
16235 /* Enable/Disable a per port offloading */
16236 struct cmd_config_per_port_rx_offload_result {
16237 cmdline_fixed_string_t port;
16238 cmdline_fixed_string_t config;
16240 cmdline_fixed_string_t rx_offload;
16241 cmdline_fixed_string_t offload;
16242 cmdline_fixed_string_t on_off;
16245 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16246 TOKEN_STRING_INITIALIZER
16247 (struct cmd_config_per_port_rx_offload_result,
16249 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16250 TOKEN_STRING_INITIALIZER
16251 (struct cmd_config_per_port_rx_offload_result,
16253 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16254 TOKEN_NUM_INITIALIZER
16255 (struct cmd_config_per_port_rx_offload_result,
16256 port_id, RTE_UINT16);
16257 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16258 TOKEN_STRING_INITIALIZER
16259 (struct cmd_config_per_port_rx_offload_result,
16260 rx_offload, "rx_offload");
16261 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16262 TOKEN_STRING_INITIALIZER
16263 (struct cmd_config_per_port_rx_offload_result,
16264 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16265 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16266 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16267 "scatter#buffer_split#timestamp#security#"
16268 "keep_crc#rss_hash");
16269 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16270 TOKEN_STRING_INITIALIZER
16271 (struct cmd_config_per_port_rx_offload_result,
16275 search_rx_offload(const char *name)
16277 uint64_t single_offload;
16278 const char *single_name;
16282 single_offload = 1;
16283 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16284 single_name = rte_eth_dev_rx_offload_name(single_offload);
16285 if (!strcasecmp(single_name, name)) {
16289 single_offload <<= 1;
16293 return single_offload;
16299 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16300 __rte_unused struct cmdline *cl,
16301 __rte_unused void *data)
16303 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16304 portid_t port_id = res->port_id;
16305 struct rte_eth_dev_info dev_info;
16306 struct rte_port *port = &ports[port_id];
16307 uint64_t single_offload;
16308 uint16_t nb_rx_queues;
16312 if (port->port_status != RTE_PORT_STOPPED) {
16314 "Error: Can't config offload when Port %d is not stopped\n",
16319 single_offload = search_rx_offload(res->offload);
16320 if (single_offload == 0) {
16321 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16325 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16329 nb_rx_queues = dev_info.nb_rx_queues;
16330 if (!strcmp(res->on_off, "on")) {
16331 port->dev_conf.rxmode.offloads |= single_offload;
16332 for (q = 0; q < nb_rx_queues; q++)
16333 port->rxq[q].conf.offloads |= single_offload;
16335 port->dev_conf.rxmode.offloads &= ~single_offload;
16336 for (q = 0; q < nb_rx_queues; q++)
16337 port->rxq[q].conf.offloads &= ~single_offload;
16340 cmd_reconfig_device_queue(port_id, 1, 1);
16343 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16344 .f = cmd_config_per_port_rx_offload_parsed,
16346 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16347 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16348 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16349 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16350 "keep_crc|rss_hash on|off",
16352 (void *)&cmd_config_per_port_rx_offload_result_port,
16353 (void *)&cmd_config_per_port_rx_offload_result_config,
16354 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16355 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16356 (void *)&cmd_config_per_port_rx_offload_result_offload,
16357 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16362 /* Enable/Disable a per queue offloading */
16363 struct cmd_config_per_queue_rx_offload_result {
16364 cmdline_fixed_string_t port;
16366 cmdline_fixed_string_t rxq;
16368 cmdline_fixed_string_t rx_offload;
16369 cmdline_fixed_string_t offload;
16370 cmdline_fixed_string_t on_off;
16373 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16374 TOKEN_STRING_INITIALIZER
16375 (struct cmd_config_per_queue_rx_offload_result,
16377 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16378 TOKEN_NUM_INITIALIZER
16379 (struct cmd_config_per_queue_rx_offload_result,
16380 port_id, RTE_UINT16);
16381 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16382 TOKEN_STRING_INITIALIZER
16383 (struct cmd_config_per_queue_rx_offload_result,
16385 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16386 TOKEN_NUM_INITIALIZER
16387 (struct cmd_config_per_queue_rx_offload_result,
16388 queue_id, RTE_UINT16);
16389 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16390 TOKEN_STRING_INITIALIZER
16391 (struct cmd_config_per_queue_rx_offload_result,
16392 rx_offload, "rx_offload");
16393 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16394 TOKEN_STRING_INITIALIZER
16395 (struct cmd_config_per_queue_rx_offload_result,
16396 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16397 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16398 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16399 "scatter#buffer_split#timestamp#security#keep_crc");
16400 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16401 TOKEN_STRING_INITIALIZER
16402 (struct cmd_config_per_queue_rx_offload_result,
16406 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16407 __rte_unused struct cmdline *cl,
16408 __rte_unused void *data)
16410 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16411 struct rte_eth_dev_info dev_info;
16412 portid_t port_id = res->port_id;
16413 uint16_t queue_id = res->queue_id;
16414 struct rte_port *port = &ports[port_id];
16415 uint64_t single_offload;
16418 if (port->port_status != RTE_PORT_STOPPED) {
16420 "Error: Can't config offload when Port %d is not stopped\n",
16425 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16429 if (queue_id >= dev_info.nb_rx_queues) {
16431 "Error: input queue_id should be 0 ... %d\n",
16432 dev_info.nb_rx_queues - 1);
16436 single_offload = search_rx_offload(res->offload);
16437 if (single_offload == 0) {
16438 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16442 if (!strcmp(res->on_off, "on"))
16443 port->rxq[queue_id].conf.offloads |= single_offload;
16445 port->rxq[queue_id].conf.offloads &= ~single_offload;
16447 cmd_reconfig_device_queue(port_id, 1, 1);
16450 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16451 .f = cmd_config_per_queue_rx_offload_parsed,
16453 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16454 "vlan_strip|ipv4_cksum|"
16455 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16456 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16457 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16460 (void *)&cmd_config_per_queue_rx_offload_result_port,
16461 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16462 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16463 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16464 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16465 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16466 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16471 /* Get Tx offloads capabilities */
16472 struct cmd_tx_offload_get_capa_result {
16473 cmdline_fixed_string_t show;
16474 cmdline_fixed_string_t port;
16476 cmdline_fixed_string_t tx_offload;
16477 cmdline_fixed_string_t capabilities;
16480 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16481 TOKEN_STRING_INITIALIZER
16482 (struct cmd_tx_offload_get_capa_result,
16484 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16485 TOKEN_STRING_INITIALIZER
16486 (struct cmd_tx_offload_get_capa_result,
16488 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16489 TOKEN_NUM_INITIALIZER
16490 (struct cmd_tx_offload_get_capa_result,
16491 port_id, RTE_UINT16);
16492 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16493 TOKEN_STRING_INITIALIZER
16494 (struct cmd_tx_offload_get_capa_result,
16495 tx_offload, "tx_offload");
16496 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16497 TOKEN_STRING_INITIALIZER
16498 (struct cmd_tx_offload_get_capa_result,
16499 capabilities, "capabilities");
16502 print_tx_offloads(uint64_t offloads)
16504 uint64_t single_offload;
16512 begin = __builtin_ctzll(offloads);
16513 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16515 single_offload = 1ULL << begin;
16516 for (bit = begin; bit < end; bit++) {
16517 if (offloads & single_offload)
16519 rte_eth_dev_tx_offload_name(single_offload));
16520 single_offload <<= 1;
16525 cmd_tx_offload_get_capa_parsed(
16526 void *parsed_result,
16527 __rte_unused struct cmdline *cl,
16528 __rte_unused void *data)
16530 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16531 struct rte_eth_dev_info dev_info;
16532 portid_t port_id = res->port_id;
16533 uint64_t queue_offloads;
16534 uint64_t port_offloads;
16537 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16541 queue_offloads = dev_info.tx_queue_offload_capa;
16542 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16544 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16545 printf(" Per Queue :");
16546 print_tx_offloads(queue_offloads);
16549 printf(" Per Port :");
16550 print_tx_offloads(port_offloads);
16554 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16555 .f = cmd_tx_offload_get_capa_parsed,
16557 .help_str = "show port <port_id> tx_offload capabilities",
16559 (void *)&cmd_tx_offload_get_capa_show,
16560 (void *)&cmd_tx_offload_get_capa_port,
16561 (void *)&cmd_tx_offload_get_capa_port_id,
16562 (void *)&cmd_tx_offload_get_capa_tx_offload,
16563 (void *)&cmd_tx_offload_get_capa_capabilities,
16568 /* Get Tx offloads configuration */
16569 struct cmd_tx_offload_get_configuration_result {
16570 cmdline_fixed_string_t show;
16571 cmdline_fixed_string_t port;
16573 cmdline_fixed_string_t tx_offload;
16574 cmdline_fixed_string_t configuration;
16577 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16578 TOKEN_STRING_INITIALIZER
16579 (struct cmd_tx_offload_get_configuration_result,
16581 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16582 TOKEN_STRING_INITIALIZER
16583 (struct cmd_tx_offload_get_configuration_result,
16585 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16586 TOKEN_NUM_INITIALIZER
16587 (struct cmd_tx_offload_get_configuration_result,
16588 port_id, RTE_UINT16);
16589 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16590 TOKEN_STRING_INITIALIZER
16591 (struct cmd_tx_offload_get_configuration_result,
16592 tx_offload, "tx_offload");
16593 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16594 TOKEN_STRING_INITIALIZER
16595 (struct cmd_tx_offload_get_configuration_result,
16596 configuration, "configuration");
16599 cmd_tx_offload_get_configuration_parsed(
16600 void *parsed_result,
16601 __rte_unused struct cmdline *cl,
16602 __rte_unused void *data)
16604 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16605 struct rte_eth_dev_info dev_info;
16606 portid_t port_id = res->port_id;
16607 struct rte_port *port = &ports[port_id];
16608 struct rte_eth_conf dev_conf;
16609 uint64_t port_offloads;
16610 uint64_t queue_offloads;
16611 uint16_t nb_tx_queues;
16615 printf("Tx Offloading Configuration of port %d :\n", port_id);
16617 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16621 port_offloads = dev_conf.txmode.offloads;
16623 print_tx_offloads(port_offloads);
16626 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16630 nb_tx_queues = dev_info.nb_tx_queues;
16631 for (q = 0; q < nb_tx_queues; q++) {
16632 queue_offloads = port->txq[q].conf.offloads;
16633 printf(" Queue[%2d] :", q);
16634 print_tx_offloads(queue_offloads);
16640 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16641 .f = cmd_tx_offload_get_configuration_parsed,
16643 .help_str = "show port <port_id> tx_offload configuration",
16645 (void *)&cmd_tx_offload_get_configuration_show,
16646 (void *)&cmd_tx_offload_get_configuration_port,
16647 (void *)&cmd_tx_offload_get_configuration_port_id,
16648 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16649 (void *)&cmd_tx_offload_get_configuration_configuration,
16654 /* Enable/Disable a per port offloading */
16655 struct cmd_config_per_port_tx_offload_result {
16656 cmdline_fixed_string_t port;
16657 cmdline_fixed_string_t config;
16659 cmdline_fixed_string_t tx_offload;
16660 cmdline_fixed_string_t offload;
16661 cmdline_fixed_string_t on_off;
16664 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16665 TOKEN_STRING_INITIALIZER
16666 (struct cmd_config_per_port_tx_offload_result,
16668 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16669 TOKEN_STRING_INITIALIZER
16670 (struct cmd_config_per_port_tx_offload_result,
16672 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16673 TOKEN_NUM_INITIALIZER
16674 (struct cmd_config_per_port_tx_offload_result,
16675 port_id, RTE_UINT16);
16676 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16677 TOKEN_STRING_INITIALIZER
16678 (struct cmd_config_per_port_tx_offload_result,
16679 tx_offload, "tx_offload");
16680 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16681 TOKEN_STRING_INITIALIZER
16682 (struct cmd_config_per_port_tx_offload_result,
16683 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16684 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16685 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16686 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16687 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16688 "send_on_timestamp");
16689 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16690 TOKEN_STRING_INITIALIZER
16691 (struct cmd_config_per_port_tx_offload_result,
16695 search_tx_offload(const char *name)
16697 uint64_t single_offload;
16698 const char *single_name;
16702 single_offload = 1;
16703 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16704 single_name = rte_eth_dev_tx_offload_name(single_offload);
16705 if (single_name == NULL)
16707 if (!strcasecmp(single_name, name)) {
16710 } else if (!strcasecmp(single_name, "UNKNOWN"))
16712 single_offload <<= 1;
16716 return single_offload;
16722 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16723 __rte_unused struct cmdline *cl,
16724 __rte_unused void *data)
16726 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16727 portid_t port_id = res->port_id;
16728 struct rte_eth_dev_info dev_info;
16729 struct rte_port *port = &ports[port_id];
16730 uint64_t single_offload;
16731 uint16_t nb_tx_queues;
16735 if (port->port_status != RTE_PORT_STOPPED) {
16737 "Error: Can't config offload when Port %d is not stopped\n",
16742 single_offload = search_tx_offload(res->offload);
16743 if (single_offload == 0) {
16744 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16748 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16752 nb_tx_queues = dev_info.nb_tx_queues;
16753 if (!strcmp(res->on_off, "on")) {
16754 port->dev_conf.txmode.offloads |= single_offload;
16755 for (q = 0; q < nb_tx_queues; q++)
16756 port->txq[q].conf.offloads |= single_offload;
16758 port->dev_conf.txmode.offloads &= ~single_offload;
16759 for (q = 0; q < nb_tx_queues; q++)
16760 port->txq[q].conf.offloads &= ~single_offload;
16763 cmd_reconfig_device_queue(port_id, 1, 1);
16766 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16767 .f = cmd_config_per_port_tx_offload_parsed,
16769 .help_str = "port config <port_id> tx_offload "
16770 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16771 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16772 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16773 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16774 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16775 "send_on_timestamp on|off",
16777 (void *)&cmd_config_per_port_tx_offload_result_port,
16778 (void *)&cmd_config_per_port_tx_offload_result_config,
16779 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16780 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16781 (void *)&cmd_config_per_port_tx_offload_result_offload,
16782 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16787 /* Enable/Disable a per queue offloading */
16788 struct cmd_config_per_queue_tx_offload_result {
16789 cmdline_fixed_string_t port;
16791 cmdline_fixed_string_t txq;
16793 cmdline_fixed_string_t tx_offload;
16794 cmdline_fixed_string_t offload;
16795 cmdline_fixed_string_t on_off;
16798 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16799 TOKEN_STRING_INITIALIZER
16800 (struct cmd_config_per_queue_tx_offload_result,
16802 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16803 TOKEN_NUM_INITIALIZER
16804 (struct cmd_config_per_queue_tx_offload_result,
16805 port_id, RTE_UINT16);
16806 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16807 TOKEN_STRING_INITIALIZER
16808 (struct cmd_config_per_queue_tx_offload_result,
16810 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16811 TOKEN_NUM_INITIALIZER
16812 (struct cmd_config_per_queue_tx_offload_result,
16813 queue_id, RTE_UINT16);
16814 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16815 TOKEN_STRING_INITIALIZER
16816 (struct cmd_config_per_queue_tx_offload_result,
16817 tx_offload, "tx_offload");
16818 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16819 TOKEN_STRING_INITIALIZER
16820 (struct cmd_config_per_queue_tx_offload_result,
16821 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16822 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16823 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16824 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16825 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16826 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16827 TOKEN_STRING_INITIALIZER
16828 (struct cmd_config_per_queue_tx_offload_result,
16832 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16833 __rte_unused struct cmdline *cl,
16834 __rte_unused void *data)
16836 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16837 struct rte_eth_dev_info dev_info;
16838 portid_t port_id = res->port_id;
16839 uint16_t queue_id = res->queue_id;
16840 struct rte_port *port = &ports[port_id];
16841 uint64_t single_offload;
16844 if (port->port_status != RTE_PORT_STOPPED) {
16846 "Error: Can't config offload when Port %d is not stopped\n",
16851 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16855 if (queue_id >= dev_info.nb_tx_queues) {
16857 "Error: input queue_id should be 0 ... %d\n",
16858 dev_info.nb_tx_queues - 1);
16862 single_offload = search_tx_offload(res->offload);
16863 if (single_offload == 0) {
16864 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16868 if (!strcmp(res->on_off, "on"))
16869 port->txq[queue_id].conf.offloads |= single_offload;
16871 port->txq[queue_id].conf.offloads &= ~single_offload;
16873 cmd_reconfig_device_queue(port_id, 1, 1);
16876 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16877 .f = cmd_config_per_queue_tx_offload_parsed,
16879 .help_str = "port <port_id> txq <queue_id> tx_offload "
16880 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16881 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16882 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16883 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16884 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16887 (void *)&cmd_config_per_queue_tx_offload_result_port,
16888 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16889 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16890 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16891 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16892 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16893 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16898 /* *** configure tx_metadata for specific port *** */
16899 struct cmd_config_tx_metadata_specific_result {
16900 cmdline_fixed_string_t port;
16901 cmdline_fixed_string_t keyword;
16903 cmdline_fixed_string_t item;
16908 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16909 __rte_unused struct cmdline *cl,
16910 __rte_unused void *data)
16912 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16914 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16916 ports[res->port_id].tx_metadata = res->value;
16917 /* Add/remove callback to insert valid metadata in every Tx packet. */
16918 if (ports[res->port_id].tx_metadata)
16919 add_tx_md_callback(res->port_id);
16921 remove_tx_md_callback(res->port_id);
16922 rte_flow_dynf_metadata_register();
16925 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16926 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16928 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16929 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16930 keyword, "config");
16931 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16932 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16933 port_id, RTE_UINT16);
16934 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16935 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16936 item, "tx_metadata");
16937 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16938 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16939 value, RTE_UINT32);
16941 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16942 .f = cmd_config_tx_metadata_specific_parsed,
16944 .help_str = "port config <port_id> tx_metadata <value>",
16946 (void *)&cmd_config_tx_metadata_specific_port,
16947 (void *)&cmd_config_tx_metadata_specific_keyword,
16948 (void *)&cmd_config_tx_metadata_specific_id,
16949 (void *)&cmd_config_tx_metadata_specific_item,
16950 (void *)&cmd_config_tx_metadata_specific_value,
16955 /* *** set dynf *** */
16956 struct cmd_config_tx_dynf_specific_result {
16957 cmdline_fixed_string_t port;
16958 cmdline_fixed_string_t keyword;
16960 cmdline_fixed_string_t item;
16961 cmdline_fixed_string_t name;
16962 cmdline_fixed_string_t value;
16966 cmd_config_dynf_specific_parsed(void *parsed_result,
16967 __rte_unused struct cmdline *cl,
16968 __rte_unused void *data)
16970 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16971 struct rte_mbuf_dynflag desc_flag;
16973 uint64_t old_port_flags;
16975 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16977 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16979 if (strlcpy(desc_flag.name, res->name,
16980 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16981 fprintf(stderr, "Flag name too long\n");
16984 desc_flag.flags = 0;
16985 flag = rte_mbuf_dynflag_register(&desc_flag);
16987 fprintf(stderr, "Can't register flag\n");
16990 strcpy(dynf_names[flag], desc_flag.name);
16992 old_port_flags = ports[res->port_id].mbuf_dynf;
16993 if (!strcmp(res->value, "set")) {
16994 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16995 if (old_port_flags == 0)
16996 add_tx_dynf_callback(res->port_id);
16998 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16999 if (ports[res->port_id].mbuf_dynf == 0)
17000 remove_tx_dynf_callback(res->port_id);
17004 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
17005 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17007 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
17008 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17009 keyword, "config");
17010 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17011 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17012 port_id, RTE_UINT16);
17013 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17014 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17016 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17017 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17019 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17020 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17021 value, "set#clear");
17023 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17024 .f = cmd_config_dynf_specific_parsed,
17026 .help_str = "port config <port id> dynf <name> set|clear",
17028 (void *)&cmd_config_tx_dynf_specific_port,
17029 (void *)&cmd_config_tx_dynf_specific_keyword,
17030 (void *)&cmd_config_tx_dynf_specific_port_id,
17031 (void *)&cmd_config_tx_dynf_specific_item,
17032 (void *)&cmd_config_tx_dynf_specific_name,
17033 (void *)&cmd_config_tx_dynf_specific_value,
17038 /* *** display tx_metadata per port configuration *** */
17039 struct cmd_show_tx_metadata_result {
17040 cmdline_fixed_string_t cmd_show;
17041 cmdline_fixed_string_t cmd_port;
17042 cmdline_fixed_string_t cmd_keyword;
17047 cmd_show_tx_metadata_parsed(void *parsed_result,
17048 __rte_unused struct cmdline *cl,
17049 __rte_unused void *data)
17051 struct cmd_show_tx_metadata_result *res = parsed_result;
17053 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17054 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17057 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17058 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17059 ports[res->cmd_pid].tx_metadata);
17063 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17064 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17066 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17067 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17069 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17070 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17071 cmd_pid, RTE_UINT16);
17072 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17073 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17074 cmd_keyword, "tx_metadata");
17076 cmdline_parse_inst_t cmd_show_tx_metadata = {
17077 .f = cmd_show_tx_metadata_parsed,
17079 .help_str = "show port <port_id> tx_metadata",
17081 (void *)&cmd_show_tx_metadata_show,
17082 (void *)&cmd_show_tx_metadata_port,
17083 (void *)&cmd_show_tx_metadata_pid,
17084 (void *)&cmd_show_tx_metadata_keyword,
17089 /* *** show fec capability per port configuration *** */
17090 struct cmd_show_fec_capability_result {
17091 cmdline_fixed_string_t cmd_show;
17092 cmdline_fixed_string_t cmd_port;
17093 cmdline_fixed_string_t cmd_fec;
17094 cmdline_fixed_string_t cmd_keyword;
17099 cmd_show_fec_capability_parsed(void *parsed_result,
17100 __rte_unused struct cmdline *cl,
17101 __rte_unused void *data)
17103 struct cmd_show_fec_capability_result *res = parsed_result;
17104 struct rte_eth_fec_capa *speed_fec_capa;
17108 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17109 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17113 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
17114 if (ret == -ENOTSUP) {
17115 fprintf(stderr, "Function not implemented\n");
17117 } else if (ret < 0) {
17118 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
17122 num = (unsigned int)ret;
17123 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
17124 if (speed_fec_capa == NULL) {
17125 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
17129 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17131 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17135 show_fec_capability(num, speed_fec_capa);
17137 free(speed_fec_capa);
17140 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17141 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17143 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17144 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17146 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17147 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17148 cmd_pid, RTE_UINT16);
17149 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17150 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17152 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17153 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17154 cmd_keyword, "capabilities");
17156 cmdline_parse_inst_t cmd_show_capability = {
17157 .f = cmd_show_fec_capability_parsed,
17159 .help_str = "show port <port_id> fec capabilities",
17161 (void *)&cmd_show_fec_capability_show,
17162 (void *)&cmd_show_fec_capability_port,
17163 (void *)&cmd_show_fec_capability_pid,
17164 (void *)&cmd_show_fec_capability_fec,
17165 (void *)&cmd_show_fec_capability_keyword,
17170 /* *** show fec mode per port configuration *** */
17171 struct cmd_show_fec_metadata_result {
17172 cmdline_fixed_string_t cmd_show;
17173 cmdline_fixed_string_t cmd_port;
17174 cmdline_fixed_string_t cmd_keyword;
17179 cmd_show_fec_mode_parsed(void *parsed_result,
17180 __rte_unused struct cmdline *cl,
17181 __rte_unused void *data)
17183 #define FEC_NAME_SIZE 16
17184 struct cmd_show_fec_metadata_result *res = parsed_result;
17186 char buf[FEC_NAME_SIZE];
17189 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17190 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17193 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17194 if (ret == -ENOTSUP) {
17195 fprintf(stderr, "Function not implemented\n");
17197 } else if (ret < 0) {
17198 fprintf(stderr, "Get FEC mode failed\n");
17203 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17204 strlcpy(buf, "off", sizeof(buf));
17206 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17207 strlcpy(buf, "auto", sizeof(buf));
17209 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17210 strlcpy(buf, "baser", sizeof(buf));
17212 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17213 strlcpy(buf, "rs", sizeof(buf));
17219 printf("%s\n", buf);
17222 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17223 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17225 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17226 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17228 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17229 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17230 cmd_pid, RTE_UINT16);
17231 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17232 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17233 cmd_keyword, "fec_mode");
17235 cmdline_parse_inst_t cmd_show_fec_mode = {
17236 .f = cmd_show_fec_mode_parsed,
17238 .help_str = "show port <port_id> fec_mode",
17240 (void *)&cmd_show_fec_mode_show,
17241 (void *)&cmd_show_fec_mode_port,
17242 (void *)&cmd_show_fec_mode_pid,
17243 (void *)&cmd_show_fec_mode_keyword,
17248 /* *** set fec mode per port configuration *** */
17249 struct cmd_set_port_fec_mode {
17250 cmdline_fixed_string_t set;
17251 cmdline_fixed_string_t port;
17253 cmdline_fixed_string_t fec_mode;
17254 cmdline_fixed_string_t fec_value;
17257 /* Common CLI fields for set fec mode */
17258 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17259 TOKEN_STRING_INITIALIZER
17260 (struct cmd_set_port_fec_mode,
17262 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17263 TOKEN_STRING_INITIALIZER
17264 (struct cmd_set_port_fec_mode,
17266 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17267 TOKEN_NUM_INITIALIZER
17268 (struct cmd_set_port_fec_mode,
17269 port_id, RTE_UINT16);
17270 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17271 TOKEN_STRING_INITIALIZER
17272 (struct cmd_set_port_fec_mode,
17273 fec_mode, "fec_mode");
17274 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17275 TOKEN_STRING_INITIALIZER
17276 (struct cmd_set_port_fec_mode,
17280 cmd_set_port_fec_mode_parsed(
17281 void *parsed_result,
17282 __rte_unused struct cmdline *cl,
17283 __rte_unused void *data)
17285 struct cmd_set_port_fec_mode *res = parsed_result;
17286 uint16_t port_id = res->port_id;
17290 ret = parse_fec_mode(res->fec_value, &fec_capa);
17292 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17293 res->fec_value, port_id);
17297 ret = rte_eth_fec_set(port_id, fec_capa);
17298 if (ret == -ENOTSUP) {
17299 fprintf(stderr, "Function not implemented\n");
17301 } else if (ret < 0) {
17302 fprintf(stderr, "Set FEC mode failed\n");
17307 cmdline_parse_inst_t cmd_set_fec_mode = {
17308 .f = cmd_set_port_fec_mode_parsed,
17310 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17312 (void *)&cmd_set_port_fec_mode_set,
17313 (void *)&cmd_set_port_fec_mode_port,
17314 (void *)&cmd_set_port_fec_mode_port_id,
17315 (void *)&cmd_set_port_fec_mode_str,
17316 (void *)&cmd_set_port_fec_mode_value,
17321 /* show port supported ptypes */
17323 /* Common result structure for show port ptypes */
17324 struct cmd_show_port_supported_ptypes_result {
17325 cmdline_fixed_string_t show;
17326 cmdline_fixed_string_t port;
17328 cmdline_fixed_string_t ptypes;
17331 /* Common CLI fields for show port ptypes */
17332 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17333 TOKEN_STRING_INITIALIZER
17334 (struct cmd_show_port_supported_ptypes_result,
17336 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17337 TOKEN_STRING_INITIALIZER
17338 (struct cmd_show_port_supported_ptypes_result,
17340 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17341 TOKEN_NUM_INITIALIZER
17342 (struct cmd_show_port_supported_ptypes_result,
17343 port_id, RTE_UINT16);
17344 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17345 TOKEN_STRING_INITIALIZER
17346 (struct cmd_show_port_supported_ptypes_result,
17350 cmd_show_port_supported_ptypes_parsed(
17351 void *parsed_result,
17352 __rte_unused struct cmdline *cl,
17353 __rte_unused void *data)
17355 #define RSVD_PTYPE_MASK 0xf0000000
17356 #define MAX_PTYPES_PER_LAYER 16
17357 #define LTYPE_NAMESIZE 32
17358 #define PTYPE_NAMESIZE 256
17359 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17360 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17361 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17362 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17363 uint16_t port_id = res->port_id;
17366 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17370 while (ptype_mask != RSVD_PTYPE_MASK) {
17372 switch (ptype_mask) {
17373 case RTE_PTYPE_L2_MASK:
17374 strlcpy(ltype, "L2", sizeof(ltype));
17376 case RTE_PTYPE_L3_MASK:
17377 strlcpy(ltype, "L3", sizeof(ltype));
17379 case RTE_PTYPE_L4_MASK:
17380 strlcpy(ltype, "L4", sizeof(ltype));
17382 case RTE_PTYPE_TUNNEL_MASK:
17383 strlcpy(ltype, "Tunnel", sizeof(ltype));
17385 case RTE_PTYPE_INNER_L2_MASK:
17386 strlcpy(ltype, "Inner L2", sizeof(ltype));
17388 case RTE_PTYPE_INNER_L3_MASK:
17389 strlcpy(ltype, "Inner L3", sizeof(ltype));
17391 case RTE_PTYPE_INNER_L4_MASK:
17392 strlcpy(ltype, "Inner L4", sizeof(ltype));
17398 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17399 ptype_mask, ptypes,
17400 MAX_PTYPES_PER_LAYER);
17403 printf("Supported %s ptypes:\n", ltype);
17405 printf("%s ptypes unsupported\n", ltype);
17407 for (i = 0; i < ret; ++i) {
17408 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17409 printf("%s\n", buf);
17416 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17417 .f = cmd_show_port_supported_ptypes_parsed,
17419 .help_str = "show port <port_id> ptypes",
17421 (void *)&cmd_show_port_supported_ptypes_show,
17422 (void *)&cmd_show_port_supported_ptypes_port,
17423 (void *)&cmd_show_port_supported_ptypes_port_id,
17424 (void *)&cmd_show_port_supported_ptypes_ptypes,
17429 /* *** display rx/tx descriptor status *** */
17430 struct cmd_show_rx_tx_desc_status_result {
17431 cmdline_fixed_string_t cmd_show;
17432 cmdline_fixed_string_t cmd_port;
17433 cmdline_fixed_string_t cmd_keyword;
17434 cmdline_fixed_string_t cmd_desc;
17435 cmdline_fixed_string_t cmd_status;
17442 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17443 __rte_unused struct cmdline *cl,
17444 __rte_unused void *data)
17446 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17449 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17450 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17454 if (!strcmp(res->cmd_keyword, "rxq")) {
17455 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17459 "Invalid input: queue id = %d, desc id = %d\n",
17460 res->cmd_qid, res->cmd_did);
17463 if (rc == RTE_ETH_RX_DESC_AVAIL)
17464 printf("Desc status = AVAILABLE\n");
17465 else if (rc == RTE_ETH_RX_DESC_DONE)
17466 printf("Desc status = DONE\n");
17468 printf("Desc status = UNAVAILABLE\n");
17469 } else if (!strcmp(res->cmd_keyword, "txq")) {
17470 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17474 "Invalid input: queue id = %d, desc id = %d\n",
17475 res->cmd_qid, res->cmd_did);
17478 if (rc == RTE_ETH_TX_DESC_FULL)
17479 printf("Desc status = FULL\n");
17480 else if (rc == RTE_ETH_TX_DESC_DONE)
17481 printf("Desc status = DONE\n");
17483 printf("Desc status = UNAVAILABLE\n");
17487 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17488 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17490 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17491 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17493 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17494 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17495 cmd_pid, RTE_UINT16);
17496 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17497 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17498 cmd_keyword, "rxq#txq");
17499 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17500 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17501 cmd_qid, RTE_UINT16);
17502 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17503 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17505 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17506 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17507 cmd_did, RTE_UINT16);
17508 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17509 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17510 cmd_status, "status");
17511 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17512 .f = cmd_show_rx_tx_desc_status_parsed,
17514 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17517 (void *)&cmd_show_rx_tx_desc_status_show,
17518 (void *)&cmd_show_rx_tx_desc_status_port,
17519 (void *)&cmd_show_rx_tx_desc_status_pid,
17520 (void *)&cmd_show_rx_tx_desc_status_keyword,
17521 (void *)&cmd_show_rx_tx_desc_status_qid,
17522 (void *)&cmd_show_rx_tx_desc_status_desc,
17523 (void *)&cmd_show_rx_tx_desc_status_did,
17524 (void *)&cmd_show_rx_tx_desc_status_status,
17529 /* *** display rx queue desc used count *** */
17530 struct cmd_show_rx_queue_desc_used_count_result {
17531 cmdline_fixed_string_t cmd_show;
17532 cmdline_fixed_string_t cmd_port;
17533 cmdline_fixed_string_t cmd_rxq;
17534 cmdline_fixed_string_t cmd_desc;
17535 cmdline_fixed_string_t cmd_used;
17536 cmdline_fixed_string_t cmd_count;
17542 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17543 __rte_unused struct cmdline *cl,
17544 __rte_unused void *data)
17546 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17549 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17550 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17554 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17556 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17559 printf("Used desc count = %d\n", rc);
17562 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17563 TOKEN_STRING_INITIALIZER
17564 (struct cmd_show_rx_queue_desc_used_count_result,
17566 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17567 TOKEN_STRING_INITIALIZER
17568 (struct cmd_show_rx_queue_desc_used_count_result,
17570 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17571 TOKEN_NUM_INITIALIZER
17572 (struct cmd_show_rx_queue_desc_used_count_result,
17573 cmd_pid, RTE_UINT16);
17574 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17575 TOKEN_STRING_INITIALIZER
17576 (struct cmd_show_rx_queue_desc_used_count_result,
17578 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17579 TOKEN_NUM_INITIALIZER
17580 (struct cmd_show_rx_queue_desc_used_count_result,
17581 cmd_qid, RTE_UINT16);
17582 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17583 TOKEN_STRING_INITIALIZER
17584 (struct cmd_show_rx_queue_desc_used_count_result,
17585 cmd_count, "desc");
17586 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17587 TOKEN_STRING_INITIALIZER
17588 (struct cmd_show_rx_queue_desc_used_count_result,
17589 cmd_count, "used");
17590 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17591 TOKEN_STRING_INITIALIZER
17592 (struct cmd_show_rx_queue_desc_used_count_result,
17593 cmd_count, "count");
17594 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17595 .f = cmd_show_rx_queue_desc_used_count_parsed,
17597 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17599 (void *)&cmd_show_rx_queue_desc_used_count_show,
17600 (void *)&cmd_show_rx_queue_desc_used_count_port,
17601 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17602 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17603 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17604 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17605 (void *)&cmd_show_rx_queue_desc_used_count_used,
17606 (void *)&cmd_show_rx_queue_desc_used_count_count,
17611 /* Common result structure for set port ptypes */
17612 struct cmd_set_port_ptypes_result {
17613 cmdline_fixed_string_t set;
17614 cmdline_fixed_string_t port;
17616 cmdline_fixed_string_t ptype_mask;
17620 /* Common CLI fields for set port ptypes */
17621 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17622 TOKEN_STRING_INITIALIZER
17623 (struct cmd_set_port_ptypes_result,
17625 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17626 TOKEN_STRING_INITIALIZER
17627 (struct cmd_set_port_ptypes_result,
17629 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17630 TOKEN_NUM_INITIALIZER
17631 (struct cmd_set_port_ptypes_result,
17632 port_id, RTE_UINT16);
17633 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17634 TOKEN_STRING_INITIALIZER
17635 (struct cmd_set_port_ptypes_result,
17636 ptype_mask, "ptype_mask");
17637 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17638 TOKEN_NUM_INITIALIZER
17639 (struct cmd_set_port_ptypes_result,
17643 cmd_set_port_ptypes_parsed(
17644 void *parsed_result,
17645 __rte_unused struct cmdline *cl,
17646 __rte_unused void *data)
17648 struct cmd_set_port_ptypes_result *res = parsed_result;
17649 #define PTYPE_NAMESIZE 256
17650 char ptype_name[PTYPE_NAMESIZE];
17651 uint16_t port_id = res->port_id;
17652 uint32_t ptype_mask = res->mask;
17655 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17658 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17663 uint32_t ptypes[ret];
17665 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17667 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17672 printf("Successfully set following ptypes for Port %d\n", port_id);
17673 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17674 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17675 printf("%s\n", ptype_name);
17678 clear_ptypes = false;
17681 cmdline_parse_inst_t cmd_set_port_ptypes = {
17682 .f = cmd_set_port_ptypes_parsed,
17684 .help_str = "set port <port_id> ptype_mask <mask>",
17686 (void *)&cmd_set_port_ptypes_set,
17687 (void *)&cmd_set_port_ptypes_port,
17688 (void *)&cmd_set_port_ptypes_port_id,
17689 (void *)&cmd_set_port_ptypes_mask_str,
17690 (void *)&cmd_set_port_ptypes_mask_u32,
17695 /* *** display mac addresses added to a port *** */
17696 struct cmd_showport_macs_result {
17697 cmdline_fixed_string_t cmd_show;
17698 cmdline_fixed_string_t cmd_port;
17699 cmdline_fixed_string_t cmd_keyword;
17704 cmd_showport_macs_parsed(void *parsed_result,
17705 __rte_unused struct cmdline *cl,
17706 __rte_unused void *data)
17708 struct cmd_showport_macs_result *res = parsed_result;
17710 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17713 if (!strcmp(res->cmd_keyword, "macs"))
17714 show_macs(res->cmd_pid);
17715 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17716 show_mcast_macs(res->cmd_pid);
17719 cmdline_parse_token_string_t cmd_showport_macs_show =
17720 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17722 cmdline_parse_token_string_t cmd_showport_macs_port =
17723 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17725 cmdline_parse_token_num_t cmd_showport_macs_pid =
17726 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17727 cmd_pid, RTE_UINT16);
17728 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17729 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17730 cmd_keyword, "macs#mcast_macs");
17732 cmdline_parse_inst_t cmd_showport_macs = {
17733 .f = cmd_showport_macs_parsed,
17735 .help_str = "show port <port_id> macs|mcast_macs",
17737 (void *)&cmd_showport_macs_show,
17738 (void *)&cmd_showport_macs_port,
17739 (void *)&cmd_showport_macs_pid,
17740 (void *)&cmd_showport_macs_keyword,
17745 /* *** show flow transfer proxy port ID for the given port *** */
17746 struct cmd_show_port_flow_transfer_proxy_result {
17747 cmdline_fixed_string_t show;
17748 cmdline_fixed_string_t port;
17750 cmdline_fixed_string_t flow;
17751 cmdline_fixed_string_t transfer;
17752 cmdline_fixed_string_t proxy;
17755 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17756 TOKEN_STRING_INITIALIZER
17757 (struct cmd_show_port_flow_transfer_proxy_result,
17759 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17760 TOKEN_STRING_INITIALIZER
17761 (struct cmd_show_port_flow_transfer_proxy_result,
17763 cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17764 TOKEN_NUM_INITIALIZER
17765 (struct cmd_show_port_flow_transfer_proxy_result,
17766 port_id, RTE_UINT16);
17767 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17768 TOKEN_STRING_INITIALIZER
17769 (struct cmd_show_port_flow_transfer_proxy_result,
17771 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17772 TOKEN_STRING_INITIALIZER
17773 (struct cmd_show_port_flow_transfer_proxy_result,
17774 transfer, "transfer");
17775 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17776 TOKEN_STRING_INITIALIZER
17777 (struct cmd_show_port_flow_transfer_proxy_result,
17781 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17782 __rte_unused struct cmdline *cl,
17783 __rte_unused void *data)
17785 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17786 portid_t proxy_port_id;
17791 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17793 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17794 rte_strerror(-ret));
17798 printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17801 cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17802 .f = cmd_show_port_flow_transfer_proxy_parsed,
17804 .help_str = "show port <port_id> flow transfer proxy",
17806 (void *)&cmd_show_port_flow_transfer_proxy_show,
17807 (void *)&cmd_show_port_flow_transfer_proxy_port,
17808 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
17809 (void *)&cmd_show_port_flow_transfer_proxy_flow,
17810 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
17811 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
17816 /* ******************************************************************************** */
17818 /* list of instructions */
17819 cmdline_parse_ctx_t main_ctx[] = {
17820 (cmdline_parse_inst_t *)&cmd_help_brief,
17821 (cmdline_parse_inst_t *)&cmd_help_long,
17822 (cmdline_parse_inst_t *)&cmd_quit,
17823 (cmdline_parse_inst_t *)&cmd_load_from_file,
17824 (cmdline_parse_inst_t *)&cmd_showport,
17825 (cmdline_parse_inst_t *)&cmd_showqueue,
17826 (cmdline_parse_inst_t *)&cmd_showeeprom,
17827 (cmdline_parse_inst_t *)&cmd_showportall,
17828 (cmdline_parse_inst_t *)&cmd_representor_info,
17829 (cmdline_parse_inst_t *)&cmd_showdevice,
17830 (cmdline_parse_inst_t *)&cmd_showcfg,
17831 (cmdline_parse_inst_t *)&cmd_showfwdall,
17832 (cmdline_parse_inst_t *)&cmd_start,
17833 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17834 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17835 (cmdline_parse_inst_t *)&cmd_set_link_up,
17836 (cmdline_parse_inst_t *)&cmd_set_link_down,
17837 (cmdline_parse_inst_t *)&cmd_reset,
17838 (cmdline_parse_inst_t *)&cmd_set_numbers,
17839 (cmdline_parse_inst_t *)&cmd_set_log,
17840 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17841 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17842 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17843 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17844 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17845 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17846 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17847 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17848 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17849 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17850 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17851 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17852 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17853 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17854 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17855 (cmdline_parse_inst_t *)&cmd_set_link_check,
17856 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17857 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17858 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17859 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17860 #ifdef RTE_NET_BOND
17861 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17862 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17863 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17864 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17865 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17866 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17867 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17868 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17869 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17870 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17871 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17872 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17874 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17875 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17876 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17877 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17878 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17879 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17880 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17881 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17882 (cmdline_parse_inst_t *)&cmd_csum_set,
17883 (cmdline_parse_inst_t *)&cmd_csum_show,
17884 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17885 (cmdline_parse_inst_t *)&cmd_tso_set,
17886 (cmdline_parse_inst_t *)&cmd_tso_show,
17887 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17888 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17890 (cmdline_parse_inst_t *)&cmd_gro_enable,
17891 (cmdline_parse_inst_t *)&cmd_gro_flush,
17892 (cmdline_parse_inst_t *)&cmd_gro_show,
17895 (cmdline_parse_inst_t *)&cmd_gso_enable,
17896 (cmdline_parse_inst_t *)&cmd_gso_size,
17897 (cmdline_parse_inst_t *)&cmd_gso_show,
17899 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17900 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17901 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17902 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17903 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17904 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17905 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17906 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17907 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17908 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17909 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17910 (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
17911 (cmdline_parse_inst_t *)&cmd_config_dcb,
17912 (cmdline_parse_inst_t *)&cmd_read_reg,
17913 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17914 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17915 (cmdline_parse_inst_t *)&cmd_write_reg,
17916 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17917 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17918 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17919 (cmdline_parse_inst_t *)&cmd_stop,
17920 (cmdline_parse_inst_t *)&cmd_mac_addr,
17921 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17922 (cmdline_parse_inst_t *)&cmd_set_qmap,
17923 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17924 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17925 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17926 (cmdline_parse_inst_t *)&cmd_operate_port,
17927 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17928 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17929 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17930 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17931 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17932 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17933 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17934 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17935 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17936 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17937 (cmdline_parse_inst_t *)&cmd_config_mtu,
17938 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17939 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17940 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17941 (cmdline_parse_inst_t *)&cmd_config_rss,
17942 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17943 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17944 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17945 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17946 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17947 (cmdline_parse_inst_t *)&cmd_showport_reta,
17948 (cmdline_parse_inst_t *)&cmd_showport_macs,
17949 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17950 (cmdline_parse_inst_t *)&cmd_config_burst,
17951 (cmdline_parse_inst_t *)&cmd_config_thresh,
17952 (cmdline_parse_inst_t *)&cmd_config_threshold,
17953 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17954 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17955 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17956 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17957 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17958 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17959 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17960 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17961 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17962 (cmdline_parse_inst_t *)&cmd_dump,
17963 (cmdline_parse_inst_t *)&cmd_dump_one,
17964 #ifdef RTE_NET_I40E
17965 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17967 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17968 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17969 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17970 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17971 (cmdline_parse_inst_t *)&cmd_flow,
17972 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17973 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17974 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17975 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm_rfc4115,
17976 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17977 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17978 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17979 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17980 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17981 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17982 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17983 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17984 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17985 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17986 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17987 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17988 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17989 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17990 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17991 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17992 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17993 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17994 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17995 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17996 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17997 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17998 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17999 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18000 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18001 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18002 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18003 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18004 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18005 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18006 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18007 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18008 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18009 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18010 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18011 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18012 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18013 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18014 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18015 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18016 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18017 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18018 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18019 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18020 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18021 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18022 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18023 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18024 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18025 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18026 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18027 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18028 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18029 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
18030 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
18031 (cmdline_parse_inst_t *)&cmd_ddp_add,
18032 (cmdline_parse_inst_t *)&cmd_ddp_del,
18033 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18034 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18035 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18036 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18037 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18038 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18039 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18040 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18041 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18042 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18043 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18044 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18046 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18047 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18048 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18049 (cmdline_parse_inst_t *)&cmd_queue_region,
18050 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18051 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18052 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18053 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18054 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18055 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18056 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18057 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18058 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18059 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18060 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18061 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18062 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18063 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18064 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18065 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18066 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18067 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18068 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18069 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18070 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18071 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18072 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18073 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18074 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18075 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18076 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18077 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18078 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18079 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18080 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18081 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18082 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18083 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18084 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18085 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18087 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18088 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18090 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18091 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18092 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18093 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
18094 (cmdline_parse_inst_t *)&cmd_set_raw,
18095 (cmdline_parse_inst_t *)&cmd_show_set_raw,
18096 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18097 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18098 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
18099 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
18100 (cmdline_parse_inst_t *)&cmd_show_capability,
18101 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
18102 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
18106 /* read cmdline commands from file */
18108 cmdline_read_from_file(const char *filename)
18110 struct cmdline *cl;
18112 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18115 "Failed to create file based cmdline context: %s\n",
18120 cmdline_interact(cl);
18125 printf("Read CLI commands from %s\n", filename);
18128 /* prompt function, called from main on MAIN lcore */
18133 /* initialize non-constant commands */
18134 cmd_set_fwd_mode_init();
18135 cmd_set_fwd_retry_mode_init();
18137 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18138 if (testpmd_cl == NULL)
18141 ret = atexit(prompt_exit);
18143 fprintf(stderr, "Cannot set exit function for cmdline\n");
18145 cmdline_interact(testpmd_cl);
18147 cmdline_stdin_exit(testpmd_cl);
18153 if (testpmd_cl != NULL) {
18154 cmdline_quit(testpmd_cl);
18155 cmdline_stdin_exit(testpmd_cl);
18160 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18162 if (id == (portid_t)RTE_PORT_ALL) {
18165 RTE_ETH_FOREACH_DEV(pid) {
18166 /* check if need_reconfig has been set to 1 */
18167 if (ports[pid].need_reconfig == 0)
18168 ports[pid].need_reconfig = dev;
18169 /* check if need_reconfig_queues has been set to 1 */
18170 if (ports[pid].need_reconfig_queues == 0)
18171 ports[pid].need_reconfig_queues = queue;
18173 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18174 /* check if need_reconfig has been set to 1 */
18175 if (ports[id].need_reconfig == 0)
18176 ports[id].need_reconfig = dev;
18177 /* check if need_reconfig_queues has been set to 1 */
18178 if (ports[id].need_reconfig_queues == 0)
18179 ports[id].need_reconfig_queues = queue;