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_atomic.h>
28 #include <rte_branch_prediction.h>
30 #include <rte_mempool.h>
31 #include <rte_interrupts.h>
33 #include <rte_ether.h>
34 #include <rte_ethdev.h>
35 #include <rte_string_fns.h>
36 #include <rte_devargs.h>
39 #include <rte_mbuf_dyn.h>
41 #include <cmdline_rdline.h>
42 #include <cmdline_parse.h>
43 #include <cmdline_parse_num.h>
44 #include <cmdline_parse_string.h>
45 #include <cmdline_parse_ipaddr.h>
46 #include <cmdline_parse_etheraddr.h>
47 #include <cmdline_socket.h>
50 #include <rte_eth_bond.h>
51 #include <rte_eth_bond_8023ad.h>
53 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
54 #include <rte_pmd_dpaa.h>
57 #include <rte_pmd_ixgbe.h>
60 #include <rte_pmd_i40e.h>
63 #include <rte_pmd_bnxt.h>
66 #include "cmdline_mtr.h"
67 #include "cmdline_tm.h"
70 static struct cmdline *testpmd_cl;
72 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
74 /* *** Help command with introduction. *** */
75 struct cmd_help_brief_result {
76 cmdline_fixed_string_t help;
79 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
81 __rte_unused void *data)
86 "Help is available for the following sections:\n\n"
87 " help control : Start and stop forwarding.\n"
88 " help display : Displaying port, stats and config "
90 " help config : Configuration information.\n"
91 " help ports : Configuring ports.\n"
92 " help registers : Reading and setting port registers.\n"
93 " help filters : Filters configuration help.\n"
94 " help traffic_management : Traffic Management commands.\n"
95 " help devices : Device related cmds.\n"
96 " help all : All of the above sections.\n\n"
101 cmdline_parse_token_string_t cmd_help_brief_help =
102 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
104 cmdline_parse_inst_t cmd_help_brief = {
105 .f = cmd_help_brief_parsed,
107 .help_str = "help: Show help",
109 (void *)&cmd_help_brief_help,
114 /* *** Help command with help sections. *** */
115 struct cmd_help_long_result {
116 cmdline_fixed_string_t help;
117 cmdline_fixed_string_t section;
120 static void cmd_help_long_parsed(void *parsed_result,
122 __rte_unused void *data)
125 struct cmd_help_long_result *res = parsed_result;
127 if (!strcmp(res->section, "all"))
130 if (show_all || !strcmp(res->section, "control")) {
135 "Control forwarding:\n"
136 "-------------------\n\n"
139 " Start packet forwarding with current configuration.\n\n"
142 " Start packet forwarding with current config"
143 " after sending one burst of packets.\n\n"
146 " Stop packet forwarding, and display accumulated"
150 " Quit to prompt.\n\n"
154 if (show_all || !strcmp(res->section, "display")) {
162 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
163 " Display information for port_id, or all.\n\n"
165 "show port info (port_id) representor\n"
166 " Show supported representors for a specific port\n\n"
168 "show port port_id (module_eeprom|eeprom)\n"
169 " Display the module EEPROM or EEPROM information for port_id.\n\n"
171 "show port X rss reta (size) (mask0,mask1,...)\n"
172 " Display the rss redirection table entry indicated"
173 " by masks on port X. size is used to indicate the"
174 " hardware supported reta size\n\n"
176 "show port (port_id) rss-hash [key]\n"
177 " Display the RSS hash functions and RSS hash key of port\n\n"
179 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
180 " Clear information for port_id, or all.\n\n"
182 "show (rxq|txq) info (port_id) (queue_id)\n"
183 " Display information for configured RX/TX queue.\n\n"
185 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
186 " Display the given configuration.\n\n"
188 "read rxd (port_id) (queue_id) (rxd_id)\n"
189 " Display an RX descriptor of a port RX queue.\n\n"
191 "read txd (port_id) (queue_id) (txd_id)\n"
192 " Display a TX descriptor of a port TX queue.\n\n"
194 "ddp get list (port_id)\n"
195 " Get ddp profile info list\n\n"
197 "ddp get info (profile_path)\n"
198 " Get ddp profile information.\n\n"
200 "show vf stats (port_id) (vf_id)\n"
201 " Display a VF's statistics.\n\n"
203 "clear vf stats (port_id) (vf_id)\n"
204 " Reset a VF's statistics.\n\n"
206 "show port (port_id) pctype mapping\n"
207 " Get flow ptype to pctype mapping on a port\n\n"
209 "show port meter stats (port_id) (meter_id) (clear)\n"
210 " Get meter stats on a port\n\n"
212 "show fwd stats all\n"
213 " Display statistics for all fwd engines.\n\n"
215 "clear fwd stats all\n"
216 " Clear statistics for all fwd engines.\n\n"
218 "show port (port_id) rx_offload capabilities\n"
219 " List all per queue and per port Rx offloading"
220 " capabilities of a port\n\n"
222 "show port (port_id) rx_offload configuration\n"
223 " List port level and all queue level"
224 " Rx offloading configuration\n\n"
226 "show port (port_id) tx_offload capabilities\n"
227 " List all per queue and per port"
228 " Tx offloading capabilities of a port\n\n"
230 "show port (port_id) tx_offload configuration\n"
231 " List port level and all queue level"
232 " Tx offloading configuration\n\n"
234 "show port (port_id) tx_metadata\n"
235 " Show Tx metadata value set"
236 " for a specific port\n\n"
238 "show port (port_id) ptypes\n"
239 " Show port supported ptypes"
240 " for a specific port\n\n"
242 "show device info (<identifier>|all)"
243 " Show general information about devices probed.\n\n"
245 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
246 " Show status of rx|tx descriptor.\n\n"
248 "show port (port_id) rxq (queue_id) desc used count\n"
249 " Show current number of filled receive"
250 " packet descriptors.\n\n"
252 "show port (port_id) macs|mcast_macs"
253 " Display list of mac addresses added to port.\n\n"
255 "show port (port_id) fec capabilities"
256 " Show fec capabilities of a port.\n\n"
258 "show port (port_id) fec_mode"
259 " Show fec mode of a port.\n\n"
261 "show port (port_id) flow_ctrl"
262 " Show flow control info of a port.\n\n"
266 if (show_all || !strcmp(res->section, "config")) {
272 "Configuration changes only become active when"
273 " forwarding is started/restarted.\n\n"
276 " Reset forwarding to the default configuration.\n\n"
278 "set verbose (level)\n"
279 " Set the debug verbosity level X.\n\n"
281 "set log global|(type) (level)\n"
282 " Set the log level.\n\n"
285 " Set number of ports.\n\n"
288 " Set number of cores.\n\n"
290 "set coremask (mask)\n"
291 " Set the forwarding cores hexadecimal mask.\n\n"
293 "set portmask (mask)\n"
294 " Set the forwarding ports hexadecimal mask.\n\n"
297 " Set number of packets per burst.\n\n"
299 "set burst tx delay (microseconds) retry (num)\n"
300 " Set the transmit delay time and number of retries,"
301 " effective when retry is enabled.\n\n"
303 "set rxoffs (x[,y]*)\n"
304 " Set the offset of each packet segment on"
305 " receiving if split feature is engaged."
306 " Affects only the queues configured with split"
309 "set rxpkts (x[,y]*)\n"
310 " Set the length of each segment to scatter"
311 " packets on receiving if split feature is engaged."
312 " Affects only the queues configured with split"
315 "set txpkts (x[,y]*)\n"
316 " Set the length of each segment of TXONLY"
317 " and optionally CSUM packets.\n\n"
319 "set txsplit (off|on|rand)\n"
320 " Set the split policy for the TX packets."
321 " Right now only applicable for CSUM and TXONLY"
324 "set txtimes (x, y)\n"
325 " Set the scheduling on timestamps"
326 " timings for the TXONLY mode\n\n"
328 "set corelist (x[,y]*)\n"
329 " Set the list of forwarding cores.\n\n"
331 "set portlist (x[,y]*)\n"
332 " Set the list of forwarding ports.\n\n"
334 "set port setup on (iterator|event)\n"
335 " Select how attached port is retrieved for setup.\n\n"
337 "set tx loopback (port_id) (on|off)\n"
338 " Enable or disable tx loopback.\n\n"
340 "set all queues drop (port_id) (on|off)\n"
341 " Set drop enable bit for all queues.\n\n"
343 "set vf split drop (port_id) (vf_id) (on|off)\n"
344 " Set split drop enable bit for a VF from the PF.\n\n"
346 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
347 " Set MAC antispoof for a VF from the PF.\n\n"
349 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
350 " Enable MACsec offload.\n\n"
352 "set macsec offload (port_id) off\n"
353 " Disable MACsec offload.\n\n"
355 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
356 " Configure MACsec secure connection (SC).\n\n"
358 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
359 " Configure MACsec secure association (SA).\n\n"
361 "set vf broadcast (port_id) (vf_id) (on|off)\n"
362 " Set VF broadcast for a VF from the PF.\n\n"
364 "vlan set stripq (on|off) (port_id,queue_id)\n"
365 " Set the VLAN strip for a queue on a port.\n\n"
367 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
368 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
370 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
371 " Set VLAN insert for a VF from the PF.\n\n"
373 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
374 " Set VLAN antispoof for a VF from the PF.\n\n"
376 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
377 " Set VLAN tag for a VF from the PF.\n\n"
379 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
380 " Set a VF's max bandwidth(Mbps).\n\n"
382 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
383 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
385 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
386 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
388 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
389 " Set some TCs' strict link priority mode on a physical port.\n\n"
391 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
392 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
394 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
395 " Set the VLAN strip or filter or qinq strip or extend\n\n"
397 "vlan set (inner|outer) tpid (value) (port_id)\n"
398 " Set the VLAN TPID for Packet Filtering on"
401 "rx_vlan add (vlan_id|all) (port_id)\n"
402 " Add a vlan_id, or all identifiers, to the set"
403 " of VLAN identifiers filtered by port_id.\n\n"
405 "rx_vlan rm (vlan_id|all) (port_id)\n"
406 " Remove a vlan_id, or all identifiers, from the set"
407 " of VLAN identifiers filtered by port_id.\n\n"
409 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
410 " Add a vlan_id, to the set of VLAN identifiers"
411 "filtered for VF(s) from port_id.\n\n"
413 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
414 " Remove a vlan_id, to the set of VLAN identifiers"
415 "filtered for VF(s) from port_id.\n\n"
417 "rx_vxlan_port add (udp_port) (port_id)\n"
418 " Add an UDP port for VXLAN packet filter on a port\n\n"
420 "rx_vxlan_port rm (udp_port) (port_id)\n"
421 " Remove an UDP port for VXLAN packet filter on a port\n\n"
423 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
424 " Set hardware insertion of VLAN IDs (single or double VLAN "
425 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
427 "tx_vlan set pvid port_id vlan_id (on|off)\n"
428 " Set port based TX VLAN insertion.\n\n"
430 "tx_vlan reset (port_id)\n"
431 " Disable hardware insertion of a VLAN header in"
432 " packets sent on a port.\n\n"
434 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
435 " Select hardware or software calculation of the"
436 " checksum when transmitting a packet using the"
437 " csum forward engine.\n"
438 " ip|udp|tcp|sctp always concern the inner layer.\n"
439 " outer-ip concerns the outer IP layer in"
440 " outer-udp concerns the outer UDP layer in"
441 " case the packet is recognized as a tunnel packet by"
442 " the forward engine (vxlan, gre and ipip are supported)\n"
443 " Please check the NIC datasheet for HW limits.\n\n"
445 "csum parse-tunnel (on|off) (tx_port_id)\n"
446 " If disabled, treat tunnel packets as non-tunneled"
447 " packets (treat inner headers as payload). The port\n"
448 " argument is the port used for TX in csum forward"
451 "csum show (port_id)\n"
452 " Display tx checksum offload configuration\n\n"
454 "tso set (segsize) (portid)\n"
455 " Enable TCP Segmentation Offload in csum forward"
457 " Please check the NIC datasheet for HW limits.\n\n"
460 " Display the status of TCP Segmentation Offload.\n\n"
462 "set port (port_id) gro on|off\n"
463 " Enable or disable Generic Receive Offload in"
464 " csum forwarding engine.\n\n"
466 "show port (port_id) gro\n"
467 " Display GRO configuration.\n\n"
469 "set gro flush (cycles)\n"
470 " Set the cycle to flush GROed packets from"
471 " reassembly tables.\n\n"
473 "set port (port_id) gso (on|off)"
474 " Enable or disable Generic Segmentation Offload in"
475 " csum forwarding engine.\n\n"
477 "set gso segsz (length)\n"
478 " Set max packet length for output GSO segments,"
479 " including packet header and payload.\n\n"
481 "show port (port_id) gso\n"
482 " Show GSO configuration.\n\n"
485 " Set packet forwarding mode.\n\n"
487 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 " Add a MAC address on port_id.\n\n"
490 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
491 " Remove a MAC address from port_id.\n\n"
493 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
494 " Set the default MAC address for port_id.\n\n"
496 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
497 " Add a MAC address for a VF on the port.\n\n"
499 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
500 " Set the MAC address for a VF from the PF.\n\n"
502 "set eth-peer (port_id) (peer_addr)\n"
503 " set the peer address for certain port.\n\n"
505 "set port (port_id) uta (mac_address|all) (on|off)\n"
506 " Add/Remove a or all unicast hash filter(s)"
509 "set promisc (port_id|all) (on|off)\n"
510 " Set the promiscuous mode on port_id, or all.\n\n"
512 "set allmulti (port_id|all) (on|off)\n"
513 " Set the allmulti mode on port_id, or all.\n\n"
515 "set vf promisc (port_id) (vf_id) (on|off)\n"
516 " Set unicast promiscuous mode for a VF from the PF.\n\n"
518 "set vf allmulti (port_id) (vf_id) (on|off)\n"
519 " Set multicast promiscuous mode for a VF from the PF.\n\n"
521 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
522 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
523 " (on|off) autoneg (on|off) (port_id)\n"
524 "set flow_ctrl rx (on|off) (portid)\n"
525 "set flow_ctrl tx (on|off) (portid)\n"
526 "set flow_ctrl high_water (high_water) (portid)\n"
527 "set flow_ctrl low_water (low_water) (portid)\n"
528 "set flow_ctrl pause_time (pause_time) (portid)\n"
529 "set flow_ctrl send_xon (send_xon) (portid)\n"
530 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
531 "set flow_ctrl autoneg (on|off) (port_id)\n"
532 " Set the link flow control parameter on a port.\n\n"
534 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
535 " (low_water) (pause_time) (priority) (port_id)\n"
536 " Set the priority flow control parameter on a"
539 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
540 " Set statistics mapping (qmapping 0..15) for RX/TX"
542 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
543 " on port 0 to mapping 5.\n\n"
545 "set xstats-hide-zero on|off\n"
546 " Set the option to hide the zero values"
547 " for xstats display.\n"
549 "set record-core-cycles on|off\n"
550 " Set the option to enable measurement of CPU cycles.\n"
552 "set record-burst-stats on|off\n"
553 " Set the option to enable display of RX and TX bursts.\n"
555 "set port (port_id) vf (vf_id) rx|tx on|off\n"
556 " Enable/Disable a VF receive/tranmit from a port\n\n"
558 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
560 " AUPE:accepts untagged VLAN;"
561 "ROPE:accept unicast hash\n\n"
562 " BAM:accepts broadcast packets;"
563 "MPE:accepts all multicast packets\n\n"
564 " Enable/Disable a VF receive mode of a port\n\n"
566 "set port (port_id) queue (queue_id) rate (rate_num)\n"
567 " Set rate limit for a queue of a port\n\n"
569 "set port (port_id) vf (vf_id) rate (rate_num) "
570 "queue_mask (queue_mask_value)\n"
571 " Set rate limit for queues in VF of a port\n\n"
573 "set flush_rx (on|off)\n"
574 " Flush (default) or don't flush RX streams before"
575 " forwarding. Mainly used with PCAP drivers.\n\n"
577 "set bypass mode (normal|bypass|isolate) (port_id)\n"
578 " Set the bypass mode for the lowest port on bypass enabled"
581 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
582 "mode (normal|bypass|isolate) (port_id)\n"
583 " Set the event required to initiate specified bypass mode for"
584 " the lowest port on a bypass enabled NIC where:\n"
585 " timeout = enable bypass after watchdog timeout.\n"
586 " os_on = enable bypass when OS/board is powered on.\n"
587 " os_off = enable bypass when OS/board is powered off.\n"
588 " power_on = enable bypass when power supply is turned on.\n"
589 " power_off = enable bypass when power supply is turned off."
592 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
593 " Set the bypass watchdog timeout to 'n' seconds"
594 " where 0 = instant.\n\n"
596 "show bypass config (port_id)\n"
597 " Show the bypass configuration for a bypass enabled NIC"
598 " using the lowest port on the NIC.\n\n"
601 "create bonded device (mode) (socket)\n"
602 " Create a new bonded device with specific bonding mode and socket.\n\n"
604 "add bonding slave (slave_id) (port_id)\n"
605 " Add a slave device to a bonded device.\n\n"
607 "remove bonding slave (slave_id) (port_id)\n"
608 " Remove a slave device from a bonded device.\n\n"
610 "set bonding mode (value) (port_id)\n"
611 " Set the bonding mode on a bonded device.\n\n"
613 "set bonding primary (slave_id) (port_id)\n"
614 " Set the primary slave for a bonded device.\n\n"
616 "show bonding config (port_id)\n"
617 " Show the bonding config for port_id.\n\n"
619 "show bonding lacp info (port_id)\n"
620 " Show the bonding lacp information for port_id.\n\n"
622 "set bonding mac_addr (port_id) (address)\n"
623 " Set the MAC address of a bonded device.\n\n"
625 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
626 " Set Aggregation mode for IEEE802.3AD (mode 4)"
628 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
629 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
631 "set bonding mon_period (port_id) (value)\n"
632 " Set the bonding link status monitoring polling period in ms.\n\n"
634 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
635 " Enable/disable dedicated queues for LACP control traffic.\n\n"
638 "set link-up port (port_id)\n"
639 " Set link up for a port.\n\n"
641 "set link-down port (port_id)\n"
642 " Set link down for a port.\n\n"
644 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
645 " Load a profile package on a port\n\n"
647 "ddp del (port_id) (backup_profile_path)\n"
648 " Delete a profile package from a port\n\n"
650 "ptype mapping get (port_id) (valid_only)\n"
651 " Get ptype mapping on a port\n\n"
653 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
654 " Replace target with the pkt_type in ptype mapping\n\n"
656 "ptype mapping reset (port_id)\n"
657 " Reset ptype mapping on a port\n\n"
659 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
660 " Update a ptype mapping item on a port\n\n"
662 "set port (port_id) ptype_mask (ptype_mask)\n"
663 " set packet types classification for a specific port\n\n"
665 "set port (port_id) queue-region region_id (value) "
666 "queue_start_index (value) queue_num (value)\n"
667 " Set a queue region on a port\n\n"
669 "set port (port_id) queue-region region_id (value) "
671 " Set a flowtype region index on a port\n\n"
673 "set port (port_id) queue-region UP (value) region_id (value)\n"
674 " Set the mapping of User Priority to "
675 "queue region on a port\n\n"
677 "set port (port_id) queue-region flush (on|off)\n"
678 " flush all queue region related configuration\n\n"
680 "show port meter cap (port_id)\n"
681 " Show port meter capability information\n\n"
683 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
684 " meter profile add - srtcm rfc 2697\n\n"
686 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
687 " meter profile add - trtcm rfc 2698\n\n"
689 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
690 " meter profile add - trtcm rfc 4115\n\n"
692 "del port meter profile (port_id) (profile_id)\n"
693 " meter profile delete\n\n"
695 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
696 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
697 "(dscp_tbl_entry63)]\n"
700 "enable port meter (port_id) (mtr_id)\n"
703 "disable port meter (port_id) (mtr_id)\n"
706 "del port meter (port_id) (mtr_id)\n"
709 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
710 "y_actions (actions) r_actions (actions)\n"
711 " meter policy add\n\n"
713 "del port meter policy (port_id) (policy_id)\n"
714 " meter policy delete\n\n"
716 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
717 " meter update meter profile\n\n"
719 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
720 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
721 " update meter dscp table entries\n\n"
723 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
724 "(action0) [(action1) (action2)]\n"
725 " meter update policer action\n\n"
727 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
728 " meter update stats\n\n"
730 "show port (port_id) queue-region\n"
731 " show all queue region related configuration info\n\n"
733 "set port (port_id) fec_mode auto|off|rs|baser\n"
734 " set fec mode for a specific port\n\n"
736 , list_pkt_forwarding_modes()
740 if (show_all || !strcmp(res->section, "ports")) {
746 "----------------\n\n"
748 "port start (port_id|all)\n"
749 " Start all ports or port_id.\n\n"
751 "port stop (port_id|all)\n"
752 " Stop all ports or port_id.\n\n"
754 "port close (port_id|all)\n"
755 " Close all ports or port_id.\n\n"
757 "port reset (port_id|all)\n"
758 " Reset all ports or port_id.\n\n"
760 "port attach (ident)\n"
761 " Attach physical or virtual dev by pci address or virtual device name\n\n"
763 "port detach (port_id)\n"
764 " Detach physical or virtual dev by port_id\n\n"
766 "port config (port_id|all)"
767 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
768 " duplex (half|full|auto)\n"
769 " Set speed and duplex for all ports or port_id\n\n"
771 "port config (port_id|all) loopback (mode)\n"
772 " Set loopback mode for all ports or port_id\n\n"
774 "port config all (rxq|txq|rxd|txd) (value)\n"
775 " Set number for rxq/txq/rxd/txd.\n\n"
777 "port config all max-pkt-len (value)\n"
778 " Set the max packet length.\n\n"
780 "port config all max-lro-pkt-size (value)\n"
781 " Set the max LRO aggregated packet size.\n\n"
783 "port config all drop-en (on|off)\n"
784 " Enable or disable packet drop on all RX queues of all ports when no "
785 "receive buffers available.\n\n"
787 "port config all rss (all|default|ip|tcp|udp|sctp|"
788 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
789 "level-outer|level-inner|<flowtype_id>)\n"
790 " Set the RSS mode.\n\n"
792 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
793 " Set the RSS redirection table.\n\n"
795 "port config (port_id) dcb vt (on|off) (traffic_class)"
797 " Set the DCB mode.\n\n"
799 "port config all burst (value)\n"
800 " Set the number of packets per burst.\n\n"
802 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
804 " Set the ring prefetch/host/writeback threshold"
805 " for tx/rx queue.\n\n"
807 "port config all (txfreet|txrst|rxfreet) (value)\n"
808 " Set free threshold for rx/tx, or set"
809 " tx rs bit threshold.\n\n"
810 "port config mtu X value\n"
811 " Set the MTU of port X to a given value\n\n"
813 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
814 " Set a rx/tx queue's ring size configuration, the new"
815 " value will take effect after command that (re-)start the port"
816 " or command that setup the specific queue\n\n"
818 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
819 " Start/stop a rx/tx queue of port X. Only take effect"
820 " when port X is started\n\n"
822 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
823 " Switch on/off a deferred start of port X rx/tx queue. Only"
824 " take effect when port X is stopped.\n\n"
826 "port (port_id) (rxq|txq) (queue_id) setup\n"
827 " Setup a rx/tx queue of port X.\n\n"
829 "port config (port_id) pctype mapping reset\n"
830 " Reset flow type to pctype mapping on a port\n\n"
832 "port config (port_id) pctype mapping update"
833 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
834 " Update a flow type to pctype mapping item on a port\n\n"
836 "port config (port_id) pctype (pctype_id) hash_inset|"
837 "fdir_inset|fdir_flx_inset get|set|clear field\n"
839 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
841 "port config (port_id) pctype (pctype_id) hash_inset|"
842 "fdir_inset|fdir_flx_inset clear all"
843 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
845 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
846 " Add/remove UDP tunnel port for tunneling offload\n\n"
848 "port config <port_id> rx_offload vlan_strip|"
849 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
850 "outer_ipv4_cksum|macsec_strip|header_split|"
851 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
852 "buffer_split|timestamp|security|keep_crc on|off\n"
853 " Enable or disable a per port Rx offloading"
854 " on all Rx queues of a port\n\n"
856 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
857 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
858 "outer_ipv4_cksum|macsec_strip|header_split|"
859 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
860 "buffer_split|timestamp|security|keep_crc on|off\n"
861 " Enable or disable a per queue Rx offloading"
862 " only on a specific Rx queue\n\n"
864 "port config (port_id) tx_offload vlan_insert|"
865 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
866 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
867 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
868 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
870 " Enable or disable a per port Tx offloading"
871 " on all Tx queues of a port\n\n"
873 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
874 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
875 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
876 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
877 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
879 " Enable or disable a per queue Tx offloading"
880 " only on a specific Tx queue\n\n"
882 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
883 " Load an eBPF program as a callback"
884 " for particular RX/TX queue\n\n"
886 "bpf-unload rx|tx (port) (queue)\n"
887 " Unload previously loaded eBPF program"
888 " for particular RX/TX queue\n\n"
890 "port config (port_id) tx_metadata (value)\n"
891 " Set Tx metadata value per port. Testpmd will add this value"
892 " to any Tx packet sent from this port\n\n"
894 "port config (port_id) dynf (name) set|clear\n"
895 " Register a dynf and Set/clear this flag on Tx. "
896 "Testpmd will set this value to any Tx packet "
897 "sent from this port\n\n"
899 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
900 " Cleanup txq mbufs for a specific Tx queue\n\n"
904 if (show_all || !strcmp(res->section, "registers")) {
912 "read reg (port_id) (address)\n"
913 " Display value of a port register.\n\n"
915 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
916 " Display a port register bit field.\n\n"
918 "read regbit (port_id) (address) (bit_x)\n"
919 " Display a single port register bit.\n\n"
921 "write reg (port_id) (address) (value)\n"
922 " Set value of a port register.\n\n"
924 "write regfield (port_id) (address) (bit_x) (bit_y)"
926 " Set bit field of a port register.\n\n"
928 "write regbit (port_id) (address) (bit_x) (value)\n"
929 " Set single bit value of a port register.\n\n"
932 if (show_all || !strcmp(res->section, "filters")) {
941 "flow_director_filter (port_id) mode raw (add|del|update)"
942 " flow (flow_id) (drop|fwd) queue (queue_id)"
943 " fd_id (fd_id_value) packet (packet file name)\n"
944 " Add/Del a raw type flow director filter.\n\n"
947 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
948 " src_mask (ipv4_src) (ipv6_src) (src_port)"
949 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
950 " Set flow director IP mask.\n\n"
952 "flow_director_mask (port_id) mode MAC-VLAN"
953 " vlan (vlan_value)\n"
954 " Set flow director MAC-VLAN mask.\n\n"
956 "flow_director_mask (port_id) mode Tunnel"
957 " vlan (vlan_value) mac (mac_value)"
958 " tunnel-type (tunnel_type_value)"
959 " tunnel-id (tunnel_id_value)\n"
960 " Set flow director Tunnel mask.\n\n"
962 "flow_director_flex_payload (port_id)"
963 " (raw|l2|l3|l4) (config)\n"
964 " Configure flex payload selection.\n\n"
966 "flow validate {port_id}"
967 " [group {group_id}] [priority {level}]"
968 " [ingress] [egress]"
969 " pattern {item} [/ {item} [...]] / end"
970 " actions {action} [/ {action} [...]] / end\n"
971 " Check whether a flow rule can be created.\n\n"
973 "flow create {port_id}"
974 " [group {group_id}] [priority {level}]"
975 " [ingress] [egress]"
976 " pattern {item} [/ {item} [...]] / end"
977 " actions {action} [/ {action} [...]] / end\n"
978 " Create a flow rule.\n\n"
980 "flow destroy {port_id} rule {rule_id} [...]\n"
981 " Destroy specific flow rules.\n\n"
983 "flow flush {port_id}\n"
984 " Destroy all flow rules.\n\n"
986 "flow query {port_id} {rule_id} {action}\n"
987 " Query an existing flow rule.\n\n"
989 "flow list {port_id} [group {group_id}] [...]\n"
990 " List existing flow rules sorted by priority,"
991 " filtered by group identifiers.\n\n"
993 "flow isolate {port_id} {boolean}\n"
994 " Restrict ingress traffic to the defined"
997 "flow aged {port_id} [destroy]\n"
998 " List and destroy aged flows"
1001 "flow indirect_action {port_id} create"
1002 " [action_id {indirect_action_id}]"
1003 " [ingress] [egress]"
1004 " action {action} / end\n"
1005 " Create indirect action.\n\n"
1007 "flow indirect_action {port_id} update"
1008 " {indirect_action_id} action {action} / end\n"
1009 " Update indirect action.\n\n"
1011 "flow indirect_action {port_id} destroy"
1012 " action_id {indirect_action_id} [...]\n"
1013 " Destroy specific indirect actions.\n\n"
1015 "flow indirect_action {port_id} query"
1016 " {indirect_action_id}\n"
1017 " Query an existing indirect action.\n\n"
1019 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1020 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1021 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1022 " Configure the VXLAN encapsulation for flows.\n\n"
1024 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1025 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1026 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1027 " eth-dst (eth-dst)\n"
1028 " Configure the VXLAN encapsulation for flows.\n\n"
1030 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1031 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1032 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1033 " eth-dst (eth-dst)\n"
1034 " Configure the VXLAN encapsulation for flows.\n\n"
1036 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1037 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1039 " Configure the NVGRE encapsulation for flows.\n\n"
1041 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1042 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1043 " eth-src (eth-src) eth-dst (eth-dst)\n"
1044 " Configure the NVGRE encapsulation for flows.\n\n"
1046 "set raw_encap {flow items}\n"
1047 " Configure the encapsulation with raw data.\n\n"
1049 "set raw_decap {flow items}\n"
1050 " Configure the decapsulation with raw data.\n\n"
1055 if (show_all || !strcmp(res->section, "traffic_management")) {
1059 "Traffic Management:\n"
1061 "show port tm cap (port_id)\n"
1062 " Display the port TM capability.\n\n"
1064 "show port tm level cap (port_id) (level_id)\n"
1065 " Display the port TM hierarchical level capability.\n\n"
1067 "show port tm node cap (port_id) (node_id)\n"
1068 " Display the port TM node capability.\n\n"
1070 "show port tm node type (port_id) (node_id)\n"
1071 " Display the port TM node type.\n\n"
1073 "show port tm node stats (port_id) (node_id) (clear)\n"
1074 " Display the port TM node stats.\n\n"
1076 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1077 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1078 " (packet_length_adjust) (packet_mode)\n"
1079 " Add port tm node private shaper profile.\n\n"
1081 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1082 " Delete port tm node private shaper profile.\n\n"
1084 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1085 " (shaper_profile_id)\n"
1086 " Add/update port tm node shared shaper.\n\n"
1088 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1089 " Delete port tm node shared shaper.\n\n"
1091 "set port tm node shaper profile (port_id) (node_id)"
1092 " (shaper_profile_id)\n"
1093 " Set port tm node shaper profile.\n\n"
1095 "add port tm node wred profile (port_id) (wred_profile_id)"
1096 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1097 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1098 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1099 " Add port tm node wred profile.\n\n"
1101 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1102 " Delete port tm node wred profile.\n\n"
1104 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1105 " (priority) (weight) (level_id) (shaper_profile_id)"
1106 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1107 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1108 " Add port tm nonleaf node.\n\n"
1110 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1111 " (priority) (weight) (level_id) (shaper_profile_id)"
1112 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1113 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1114 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1116 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1117 " (priority) (weight) (level_id) (shaper_profile_id)"
1118 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1119 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1120 " Add port tm leaf node.\n\n"
1122 "del port tm node (port_id) (node_id)\n"
1123 " Delete port tm node.\n\n"
1125 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1126 " (priority) (weight)\n"
1127 " Set port tm node parent.\n\n"
1129 "suspend port tm node (port_id) (node_id)"
1130 " Suspend tm node.\n\n"
1132 "resume port tm node (port_id) (node_id)"
1133 " Resume tm node.\n\n"
1135 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1136 " Commit tm hierarchy.\n\n"
1138 "set port tm mark ip_ecn (port) (green) (yellow)"
1140 " Enables/Disables the traffic management marking"
1141 " for IP ECN (Explicit Congestion Notification)"
1142 " packets on a given port\n\n"
1144 "set port tm mark ip_dscp (port) (green) (yellow)"
1146 " Enables/Disables the traffic management marking"
1147 " on the port for IP dscp packets\n\n"
1149 "set port tm mark vlan_dei (port) (green) (yellow)"
1151 " Enables/Disables the traffic management marking"
1152 " on the port for VLAN packets with DEI enabled\n\n"
1156 if (show_all || !strcmp(res->section, "devices")) {
1160 "Device Operations:\n"
1162 "device detach (identifier)\n"
1163 " Detach device by identifier.\n\n"
1169 cmdline_parse_token_string_t cmd_help_long_help =
1170 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1172 cmdline_parse_token_string_t cmd_help_long_section =
1173 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1174 "all#control#display#config#"
1175 "ports#registers#filters#traffic_management#devices");
1177 cmdline_parse_inst_t cmd_help_long = {
1178 .f = cmd_help_long_parsed,
1180 .help_str = "help all|control|display|config|ports|register|"
1181 "filters|traffic_management|devices: "
1184 (void *)&cmd_help_long_help,
1185 (void *)&cmd_help_long_section,
1191 /* *** start/stop/close all ports *** */
1192 struct cmd_operate_port_result {
1193 cmdline_fixed_string_t keyword;
1194 cmdline_fixed_string_t name;
1195 cmdline_fixed_string_t value;
1198 static void cmd_operate_port_parsed(void *parsed_result,
1199 __rte_unused struct cmdline *cl,
1200 __rte_unused void *data)
1202 struct cmd_operate_port_result *res = parsed_result;
1204 if (!strcmp(res->name, "start"))
1205 start_port(RTE_PORT_ALL);
1206 else if (!strcmp(res->name, "stop"))
1207 stop_port(RTE_PORT_ALL);
1208 else if (!strcmp(res->name, "close"))
1209 close_port(RTE_PORT_ALL);
1210 else if (!strcmp(res->name, "reset"))
1211 reset_port(RTE_PORT_ALL);
1213 fprintf(stderr, "Unknown parameter\n");
1216 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1217 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1219 cmdline_parse_token_string_t cmd_operate_port_all_port =
1220 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1221 "start#stop#close#reset");
1222 cmdline_parse_token_string_t cmd_operate_port_all_all =
1223 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1225 cmdline_parse_inst_t cmd_operate_port = {
1226 .f = cmd_operate_port_parsed,
1228 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1230 (void *)&cmd_operate_port_all_cmd,
1231 (void *)&cmd_operate_port_all_port,
1232 (void *)&cmd_operate_port_all_all,
1237 /* *** start/stop/close specific port *** */
1238 struct cmd_operate_specific_port_result {
1239 cmdline_fixed_string_t keyword;
1240 cmdline_fixed_string_t name;
1244 static void cmd_operate_specific_port_parsed(void *parsed_result,
1245 __rte_unused struct cmdline *cl,
1246 __rte_unused void *data)
1248 struct cmd_operate_specific_port_result *res = parsed_result;
1250 if (!strcmp(res->name, "start"))
1251 start_port(res->value);
1252 else if (!strcmp(res->name, "stop"))
1253 stop_port(res->value);
1254 else if (!strcmp(res->name, "close"))
1255 close_port(res->value);
1256 else if (!strcmp(res->name, "reset"))
1257 reset_port(res->value);
1259 fprintf(stderr, "Unknown parameter\n");
1262 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1263 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1265 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1266 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1267 name, "start#stop#close#reset");
1268 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1269 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1272 cmdline_parse_inst_t cmd_operate_specific_port = {
1273 .f = cmd_operate_specific_port_parsed,
1275 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1277 (void *)&cmd_operate_specific_port_cmd,
1278 (void *)&cmd_operate_specific_port_port,
1279 (void *)&cmd_operate_specific_port_id,
1284 /* *** enable port setup (after attach) via iterator or event *** */
1285 struct cmd_set_port_setup_on_result {
1286 cmdline_fixed_string_t set;
1287 cmdline_fixed_string_t port;
1288 cmdline_fixed_string_t setup;
1289 cmdline_fixed_string_t on;
1290 cmdline_fixed_string_t mode;
1293 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1294 __rte_unused struct cmdline *cl,
1295 __rte_unused void *data)
1297 struct cmd_set_port_setup_on_result *res = parsed_result;
1299 if (strcmp(res->mode, "event") == 0)
1300 setup_on_probe_event = true;
1301 else if (strcmp(res->mode, "iterator") == 0)
1302 setup_on_probe_event = false;
1304 fprintf(stderr, "Unknown mode\n");
1307 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1308 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1310 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1311 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1313 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1314 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1316 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1317 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1319 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1320 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1321 mode, "iterator#event");
1323 cmdline_parse_inst_t cmd_set_port_setup_on = {
1324 .f = cmd_set_port_setup_on_parsed,
1326 .help_str = "set port setup on iterator|event",
1328 (void *)&cmd_set_port_setup_on_set,
1329 (void *)&cmd_set_port_setup_on_port,
1330 (void *)&cmd_set_port_setup_on_setup,
1331 (void *)&cmd_set_port_setup_on_on,
1332 (void *)&cmd_set_port_setup_on_mode,
1337 /* *** attach a specified port *** */
1338 struct cmd_operate_attach_port_result {
1339 cmdline_fixed_string_t port;
1340 cmdline_fixed_string_t keyword;
1341 cmdline_multi_string_t identifier;
1344 static void cmd_operate_attach_port_parsed(void *parsed_result,
1345 __rte_unused struct cmdline *cl,
1346 __rte_unused void *data)
1348 struct cmd_operate_attach_port_result *res = parsed_result;
1350 if (!strcmp(res->keyword, "attach"))
1351 attach_port(res->identifier);
1353 fprintf(stderr, "Unknown parameter\n");
1356 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1357 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1359 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1360 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1362 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1363 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1364 identifier, TOKEN_STRING_MULTI);
1366 cmdline_parse_inst_t cmd_operate_attach_port = {
1367 .f = cmd_operate_attach_port_parsed,
1369 .help_str = "port attach <identifier>: "
1370 "(identifier: pci address or virtual dev name)",
1372 (void *)&cmd_operate_attach_port_port,
1373 (void *)&cmd_operate_attach_port_keyword,
1374 (void *)&cmd_operate_attach_port_identifier,
1379 /* *** detach a specified port *** */
1380 struct cmd_operate_detach_port_result {
1381 cmdline_fixed_string_t port;
1382 cmdline_fixed_string_t keyword;
1386 static void cmd_operate_detach_port_parsed(void *parsed_result,
1387 __rte_unused struct cmdline *cl,
1388 __rte_unused void *data)
1390 struct cmd_operate_detach_port_result *res = parsed_result;
1392 if (!strcmp(res->keyword, "detach")) {
1393 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1394 detach_port_device(res->port_id);
1396 fprintf(stderr, "Unknown parameter\n");
1400 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1401 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1403 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1404 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1406 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1407 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1408 port_id, RTE_UINT16);
1410 cmdline_parse_inst_t cmd_operate_detach_port = {
1411 .f = cmd_operate_detach_port_parsed,
1413 .help_str = "port detach <port_id>",
1415 (void *)&cmd_operate_detach_port_port,
1416 (void *)&cmd_operate_detach_port_keyword,
1417 (void *)&cmd_operate_detach_port_port_id,
1422 /* *** detach device by identifier *** */
1423 struct cmd_operate_detach_device_result {
1424 cmdline_fixed_string_t device;
1425 cmdline_fixed_string_t keyword;
1426 cmdline_fixed_string_t identifier;
1429 static void cmd_operate_detach_device_parsed(void *parsed_result,
1430 __rte_unused struct cmdline *cl,
1431 __rte_unused void *data)
1433 struct cmd_operate_detach_device_result *res = parsed_result;
1435 if (!strcmp(res->keyword, "detach"))
1436 detach_devargs(res->identifier);
1438 fprintf(stderr, "Unknown parameter\n");
1441 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1442 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1444 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1445 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1447 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1448 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1451 cmdline_parse_inst_t cmd_operate_detach_device = {
1452 .f = cmd_operate_detach_device_parsed,
1454 .help_str = "device detach <identifier>:"
1455 "(identifier: pci address or virtual dev name)",
1457 (void *)&cmd_operate_detach_device_device,
1458 (void *)&cmd_operate_detach_device_keyword,
1459 (void *)&cmd_operate_detach_device_identifier,
1463 /* *** configure speed for all ports *** */
1464 struct cmd_config_speed_all {
1465 cmdline_fixed_string_t port;
1466 cmdline_fixed_string_t keyword;
1467 cmdline_fixed_string_t all;
1468 cmdline_fixed_string_t item1;
1469 cmdline_fixed_string_t item2;
1470 cmdline_fixed_string_t value1;
1471 cmdline_fixed_string_t value2;
1475 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1480 if (!strcmp(duplexstr, "half")) {
1481 duplex = ETH_LINK_HALF_DUPLEX;
1482 } else if (!strcmp(duplexstr, "full")) {
1483 duplex = ETH_LINK_FULL_DUPLEX;
1484 } else if (!strcmp(duplexstr, "auto")) {
1485 duplex = ETH_LINK_FULL_DUPLEX;
1487 fprintf(stderr, "Unknown duplex parameter\n");
1491 if (!strcmp(speedstr, "10")) {
1492 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1493 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1494 } else if (!strcmp(speedstr, "100")) {
1495 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1496 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1498 if (duplex != ETH_LINK_FULL_DUPLEX) {
1499 fprintf(stderr, "Invalid speed/duplex parameters\n");
1502 if (!strcmp(speedstr, "1000")) {
1503 *speed = ETH_LINK_SPEED_1G;
1504 } else if (!strcmp(speedstr, "10000")) {
1505 *speed = ETH_LINK_SPEED_10G;
1506 } else if (!strcmp(speedstr, "25000")) {
1507 *speed = ETH_LINK_SPEED_25G;
1508 } else if (!strcmp(speedstr, "40000")) {
1509 *speed = ETH_LINK_SPEED_40G;
1510 } else if (!strcmp(speedstr, "50000")) {
1511 *speed = ETH_LINK_SPEED_50G;
1512 } else if (!strcmp(speedstr, "100000")) {
1513 *speed = ETH_LINK_SPEED_100G;
1514 } else if (!strcmp(speedstr, "200000")) {
1515 *speed = ETH_LINK_SPEED_200G;
1516 } else if (!strcmp(speedstr, "auto")) {
1517 *speed = ETH_LINK_SPEED_AUTONEG;
1519 fprintf(stderr, "Unknown speed parameter\n");
1524 if (*speed != ETH_LINK_SPEED_AUTONEG)
1525 *speed |= ETH_LINK_SPEED_FIXED;
1531 cmd_config_speed_all_parsed(void *parsed_result,
1532 __rte_unused struct cmdline *cl,
1533 __rte_unused void *data)
1535 struct cmd_config_speed_all *res = parsed_result;
1536 uint32_t link_speed;
1539 if (!all_ports_stopped()) {
1540 fprintf(stderr, "Please stop all ports first\n");
1544 if (parse_and_check_speed_duplex(res->value1, res->value2,
1548 RTE_ETH_FOREACH_DEV(pid) {
1549 ports[pid].dev_conf.link_speeds = link_speed;
1552 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1555 cmdline_parse_token_string_t cmd_config_speed_all_port =
1556 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1557 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1560 cmdline_parse_token_string_t cmd_config_speed_all_all =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1562 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1564 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1565 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1566 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1567 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1569 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1573 cmdline_parse_inst_t cmd_config_speed_all = {
1574 .f = cmd_config_speed_all_parsed,
1576 .help_str = "port config all speed "
1577 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1580 (void *)&cmd_config_speed_all_port,
1581 (void *)&cmd_config_speed_all_keyword,
1582 (void *)&cmd_config_speed_all_all,
1583 (void *)&cmd_config_speed_all_item1,
1584 (void *)&cmd_config_speed_all_value1,
1585 (void *)&cmd_config_speed_all_item2,
1586 (void *)&cmd_config_speed_all_value2,
1591 /* *** configure speed for specific port *** */
1592 struct cmd_config_speed_specific {
1593 cmdline_fixed_string_t port;
1594 cmdline_fixed_string_t keyword;
1596 cmdline_fixed_string_t item1;
1597 cmdline_fixed_string_t item2;
1598 cmdline_fixed_string_t value1;
1599 cmdline_fixed_string_t value2;
1603 cmd_config_speed_specific_parsed(void *parsed_result,
1604 __rte_unused struct cmdline *cl,
1605 __rte_unused void *data)
1607 struct cmd_config_speed_specific *res = parsed_result;
1608 uint32_t link_speed;
1610 if (port_id_is_invalid(res->id, ENABLED_WARN))
1613 if (!port_is_stopped(res->id)) {
1614 fprintf(stderr, "Please stop port %d first\n", res->id);
1618 if (parse_and_check_speed_duplex(res->value1, res->value2,
1622 ports[res->id].dev_conf.link_speeds = link_speed;
1624 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1628 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1631 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1632 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1634 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1635 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1636 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1639 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1641 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1642 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1645 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1646 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1649 cmdline_parse_inst_t cmd_config_speed_specific = {
1650 .f = cmd_config_speed_specific_parsed,
1652 .help_str = "port config <port_id> speed "
1653 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1656 (void *)&cmd_config_speed_specific_port,
1657 (void *)&cmd_config_speed_specific_keyword,
1658 (void *)&cmd_config_speed_specific_id,
1659 (void *)&cmd_config_speed_specific_item1,
1660 (void *)&cmd_config_speed_specific_value1,
1661 (void *)&cmd_config_speed_specific_item2,
1662 (void *)&cmd_config_speed_specific_value2,
1667 /* *** configure loopback for all ports *** */
1668 struct cmd_config_loopback_all {
1669 cmdline_fixed_string_t port;
1670 cmdline_fixed_string_t keyword;
1671 cmdline_fixed_string_t all;
1672 cmdline_fixed_string_t item;
1677 cmd_config_loopback_all_parsed(void *parsed_result,
1678 __rte_unused struct cmdline *cl,
1679 __rte_unused void *data)
1681 struct cmd_config_loopback_all *res = parsed_result;
1684 if (!all_ports_stopped()) {
1685 fprintf(stderr, "Please stop all ports first\n");
1689 RTE_ETH_FOREACH_DEV(pid) {
1690 ports[pid].dev_conf.lpbk_mode = res->mode;
1693 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1696 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1697 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1698 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1699 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1701 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1702 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1703 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1704 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1706 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1707 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1709 cmdline_parse_inst_t cmd_config_loopback_all = {
1710 .f = cmd_config_loopback_all_parsed,
1712 .help_str = "port config all loopback <mode>",
1714 (void *)&cmd_config_loopback_all_port,
1715 (void *)&cmd_config_loopback_all_keyword,
1716 (void *)&cmd_config_loopback_all_all,
1717 (void *)&cmd_config_loopback_all_item,
1718 (void *)&cmd_config_loopback_all_mode,
1723 /* *** configure loopback for specific port *** */
1724 struct cmd_config_loopback_specific {
1725 cmdline_fixed_string_t port;
1726 cmdline_fixed_string_t keyword;
1728 cmdline_fixed_string_t item;
1733 cmd_config_loopback_specific_parsed(void *parsed_result,
1734 __rte_unused struct cmdline *cl,
1735 __rte_unused void *data)
1737 struct cmd_config_loopback_specific *res = parsed_result;
1739 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1742 if (!port_is_stopped(res->port_id)) {
1743 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1747 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1749 cmd_reconfig_device_queue(res->port_id, 1, 1);
1753 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1754 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1756 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1757 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1759 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1760 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1762 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1763 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1765 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1766 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1769 cmdline_parse_inst_t cmd_config_loopback_specific = {
1770 .f = cmd_config_loopback_specific_parsed,
1772 .help_str = "port config <port_id> loopback <mode>",
1774 (void *)&cmd_config_loopback_specific_port,
1775 (void *)&cmd_config_loopback_specific_keyword,
1776 (void *)&cmd_config_loopback_specific_id,
1777 (void *)&cmd_config_loopback_specific_item,
1778 (void *)&cmd_config_loopback_specific_mode,
1783 /* *** configure txq/rxq, txd/rxd *** */
1784 struct cmd_config_rx_tx {
1785 cmdline_fixed_string_t port;
1786 cmdline_fixed_string_t keyword;
1787 cmdline_fixed_string_t all;
1788 cmdline_fixed_string_t name;
1793 cmd_config_rx_tx_parsed(void *parsed_result,
1794 __rte_unused struct cmdline *cl,
1795 __rte_unused void *data)
1797 struct cmd_config_rx_tx *res = parsed_result;
1799 if (!all_ports_stopped()) {
1800 fprintf(stderr, "Please stop all ports first\n");
1803 if (!strcmp(res->name, "rxq")) {
1804 if (!res->value && !nb_txq) {
1805 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1808 if (check_nb_rxq(res->value) != 0)
1810 nb_rxq = res->value;
1812 else if (!strcmp(res->name, "txq")) {
1813 if (!res->value && !nb_rxq) {
1814 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1817 if (check_nb_txq(res->value) != 0)
1819 nb_txq = res->value;
1821 else if (!strcmp(res->name, "rxd")) {
1822 if (check_nb_rxd(res->value) != 0)
1824 nb_rxd = res->value;
1825 } else if (!strcmp(res->name, "txd")) {
1826 if (check_nb_txd(res->value) != 0)
1829 nb_txd = res->value;
1831 fprintf(stderr, "Unknown parameter\n");
1839 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1842 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1843 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1844 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1846 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1848 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1851 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1852 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1854 cmdline_parse_inst_t cmd_config_rx_tx = {
1855 .f = cmd_config_rx_tx_parsed,
1857 .help_str = "port config all rxq|txq|rxd|txd <value>",
1859 (void *)&cmd_config_rx_tx_port,
1860 (void *)&cmd_config_rx_tx_keyword,
1861 (void *)&cmd_config_rx_tx_all,
1862 (void *)&cmd_config_rx_tx_name,
1863 (void *)&cmd_config_rx_tx_value,
1868 /* *** config max packet length *** */
1869 struct cmd_config_max_pkt_len_result {
1870 cmdline_fixed_string_t port;
1871 cmdline_fixed_string_t keyword;
1872 cmdline_fixed_string_t all;
1873 cmdline_fixed_string_t name;
1878 cmd_config_max_pkt_len_parsed(void *parsed_result,
1879 __rte_unused struct cmdline *cl,
1880 __rte_unused void *data)
1882 struct cmd_config_max_pkt_len_result *res = parsed_result;
1883 uint32_t max_rx_pkt_len_backup = 0;
1887 if (!all_ports_stopped()) {
1888 fprintf(stderr, "Please stop all ports first\n");
1892 RTE_ETH_FOREACH_DEV(pid) {
1893 struct rte_port *port = &ports[pid];
1895 if (!strcmp(res->name, "max-pkt-len")) {
1896 if (res->value < RTE_ETHER_MIN_LEN) {
1898 "max-pkt-len can not be less than %d\n",
1902 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1905 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1908 "rte_eth_dev_info_get() failed for port %u\n",
1913 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1915 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1916 if (update_jumbo_frame_offload(pid) != 0)
1917 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1919 fprintf(stderr, "Unknown parameter\n");
1926 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1929 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1930 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1932 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1935 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1938 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1941 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1942 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1945 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1946 .f = cmd_config_max_pkt_len_parsed,
1948 .help_str = "port config all max-pkt-len <value>",
1950 (void *)&cmd_config_max_pkt_len_port,
1951 (void *)&cmd_config_max_pkt_len_keyword,
1952 (void *)&cmd_config_max_pkt_len_all,
1953 (void *)&cmd_config_max_pkt_len_name,
1954 (void *)&cmd_config_max_pkt_len_value,
1959 /* *** config max LRO aggregated packet size *** */
1960 struct cmd_config_max_lro_pkt_size_result {
1961 cmdline_fixed_string_t port;
1962 cmdline_fixed_string_t keyword;
1963 cmdline_fixed_string_t all;
1964 cmdline_fixed_string_t name;
1969 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1970 __rte_unused struct cmdline *cl,
1971 __rte_unused void *data)
1973 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1976 if (!all_ports_stopped()) {
1977 fprintf(stderr, "Please stop all ports first\n");
1981 RTE_ETH_FOREACH_DEV(pid) {
1982 struct rte_port *port = &ports[pid];
1984 if (!strcmp(res->name, "max-lro-pkt-size")) {
1986 port->dev_conf.rxmode.max_lro_pkt_size)
1989 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1991 fprintf(stderr, "Unknown parameter\n");
1998 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2001 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2004 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2005 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2007 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2010 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2011 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2012 name, "max-lro-pkt-size");
2013 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2014 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2017 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2018 .f = cmd_config_max_lro_pkt_size_parsed,
2020 .help_str = "port config all max-lro-pkt-size <value>",
2022 (void *)&cmd_config_max_lro_pkt_size_port,
2023 (void *)&cmd_config_max_lro_pkt_size_keyword,
2024 (void *)&cmd_config_max_lro_pkt_size_all,
2025 (void *)&cmd_config_max_lro_pkt_size_name,
2026 (void *)&cmd_config_max_lro_pkt_size_value,
2031 /* *** configure port MTU *** */
2032 struct cmd_config_mtu_result {
2033 cmdline_fixed_string_t port;
2034 cmdline_fixed_string_t keyword;
2035 cmdline_fixed_string_t mtu;
2041 cmd_config_mtu_parsed(void *parsed_result,
2042 __rte_unused struct cmdline *cl,
2043 __rte_unused void *data)
2045 struct cmd_config_mtu_result *res = parsed_result;
2047 if (res->value < RTE_ETHER_MIN_LEN) {
2048 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2051 port_mtu_set(res->port_id, res->value);
2054 cmdline_parse_token_string_t cmd_config_mtu_port =
2055 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2057 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2058 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2060 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2063 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2064 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2066 cmdline_parse_token_num_t cmd_config_mtu_value =
2067 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2070 cmdline_parse_inst_t cmd_config_mtu = {
2071 .f = cmd_config_mtu_parsed,
2073 .help_str = "port config mtu <port_id> <value>",
2075 (void *)&cmd_config_mtu_port,
2076 (void *)&cmd_config_mtu_keyword,
2077 (void *)&cmd_config_mtu_mtu,
2078 (void *)&cmd_config_mtu_port_id,
2079 (void *)&cmd_config_mtu_value,
2084 /* *** configure rx mode *** */
2085 struct cmd_config_rx_mode_flag {
2086 cmdline_fixed_string_t port;
2087 cmdline_fixed_string_t keyword;
2088 cmdline_fixed_string_t all;
2089 cmdline_fixed_string_t name;
2090 cmdline_fixed_string_t value;
2094 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2095 __rte_unused struct cmdline *cl,
2096 __rte_unused void *data)
2098 struct cmd_config_rx_mode_flag *res = parsed_result;
2100 if (!all_ports_stopped()) {
2101 fprintf(stderr, "Please stop all ports first\n");
2105 if (!strcmp(res->name, "drop-en")) {
2106 if (!strcmp(res->value, "on"))
2108 else if (!strcmp(res->value, "off"))
2111 fprintf(stderr, "Unknown parameter\n");
2115 fprintf(stderr, "Unknown parameter\n");
2121 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2124 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2125 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2126 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2127 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2129 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2130 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2131 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2134 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2135 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2138 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2139 .f = cmd_config_rx_mode_flag_parsed,
2141 .help_str = "port config all drop-en on|off",
2143 (void *)&cmd_config_rx_mode_flag_port,
2144 (void *)&cmd_config_rx_mode_flag_keyword,
2145 (void *)&cmd_config_rx_mode_flag_all,
2146 (void *)&cmd_config_rx_mode_flag_name,
2147 (void *)&cmd_config_rx_mode_flag_value,
2152 /* *** configure rss *** */
2153 struct cmd_config_rss {
2154 cmdline_fixed_string_t port;
2155 cmdline_fixed_string_t keyword;
2156 cmdline_fixed_string_t all;
2157 cmdline_fixed_string_t name;
2158 cmdline_fixed_string_t value;
2162 cmd_config_rss_parsed(void *parsed_result,
2163 __rte_unused struct cmdline *cl,
2164 __rte_unused void *data)
2166 struct cmd_config_rss *res = parsed_result;
2167 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2168 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2169 int use_default = 0;
2170 int all_updated = 1;
2175 if (!strcmp(res->value, "all"))
2176 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2177 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2178 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2179 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2181 else if (!strcmp(res->value, "eth"))
2182 rss_conf.rss_hf = ETH_RSS_ETH;
2183 else if (!strcmp(res->value, "vlan"))
2184 rss_conf.rss_hf = ETH_RSS_VLAN;
2185 else if (!strcmp(res->value, "ip"))
2186 rss_conf.rss_hf = ETH_RSS_IP;
2187 else if (!strcmp(res->value, "udp"))
2188 rss_conf.rss_hf = ETH_RSS_UDP;
2189 else if (!strcmp(res->value, "tcp"))
2190 rss_conf.rss_hf = ETH_RSS_TCP;
2191 else if (!strcmp(res->value, "sctp"))
2192 rss_conf.rss_hf = ETH_RSS_SCTP;
2193 else if (!strcmp(res->value, "ether"))
2194 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2195 else if (!strcmp(res->value, "port"))
2196 rss_conf.rss_hf = ETH_RSS_PORT;
2197 else if (!strcmp(res->value, "vxlan"))
2198 rss_conf.rss_hf = ETH_RSS_VXLAN;
2199 else if (!strcmp(res->value, "geneve"))
2200 rss_conf.rss_hf = ETH_RSS_GENEVE;
2201 else if (!strcmp(res->value, "nvgre"))
2202 rss_conf.rss_hf = ETH_RSS_NVGRE;
2203 else if (!strcmp(res->value, "l3-pre32"))
2204 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2205 else if (!strcmp(res->value, "l3-pre40"))
2206 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2207 else if (!strcmp(res->value, "l3-pre48"))
2208 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2209 else if (!strcmp(res->value, "l3-pre56"))
2210 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2211 else if (!strcmp(res->value, "l3-pre64"))
2212 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2213 else if (!strcmp(res->value, "l3-pre96"))
2214 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2215 else if (!strcmp(res->value, "l3-src-only"))
2216 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2217 else if (!strcmp(res->value, "l3-dst-only"))
2218 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2219 else if (!strcmp(res->value, "l4-src-only"))
2220 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2221 else if (!strcmp(res->value, "l4-dst-only"))
2222 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2223 else if (!strcmp(res->value, "l2-src-only"))
2224 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2225 else if (!strcmp(res->value, "l2-dst-only"))
2226 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2227 else if (!strcmp(res->value, "l2tpv3"))
2228 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2229 else if (!strcmp(res->value, "esp"))
2230 rss_conf.rss_hf = ETH_RSS_ESP;
2231 else if (!strcmp(res->value, "ah"))
2232 rss_conf.rss_hf = ETH_RSS_AH;
2233 else if (!strcmp(res->value, "pfcp"))
2234 rss_conf.rss_hf = ETH_RSS_PFCP;
2235 else if (!strcmp(res->value, "pppoe"))
2236 rss_conf.rss_hf = ETH_RSS_PPPOE;
2237 else if (!strcmp(res->value, "gtpu"))
2238 rss_conf.rss_hf = ETH_RSS_GTPU;
2239 else if (!strcmp(res->value, "ecpri"))
2240 rss_conf.rss_hf = ETH_RSS_ECPRI;
2241 else if (!strcmp(res->value, "mpls"))
2242 rss_conf.rss_hf = ETH_RSS_MPLS;
2243 else if (!strcmp(res->value, "ipv4-chksum"))
2244 rss_conf.rss_hf = ETH_RSS_IPV4_CHKSUM;
2245 else if (!strcmp(res->value, "none"))
2246 rss_conf.rss_hf = 0;
2247 else if (!strcmp(res->value, "level-default")) {
2248 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2249 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2250 } else if (!strcmp(res->value, "level-outer")) {
2251 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2252 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2253 } else if (!strcmp(res->value, "level-inner")) {
2254 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2255 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2256 } else if (!strcmp(res->value, "default"))
2258 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2259 atoi(res->value) < 64)
2260 rss_conf.rss_hf = 1ULL << atoi(res->value);
2262 fprintf(stderr, "Unknown parameter\n");
2265 rss_conf.rss_key = NULL;
2266 /* Update global configuration for RSS types. */
2267 RTE_ETH_FOREACH_DEV(i) {
2268 struct rte_eth_rss_conf local_rss_conf;
2270 ret = eth_dev_info_get_print_err(i, &dev_info);
2275 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2277 local_rss_conf = rss_conf;
2278 local_rss_conf.rss_hf = rss_conf.rss_hf &
2279 dev_info.flow_type_rss_offloads;
2280 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2281 printf("Port %u modified RSS hash function based on hardware support,"
2282 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2283 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2285 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2289 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2290 i, -diag, strerror(-diag));
2293 if (all_updated && !use_default) {
2294 rss_hf = rss_conf.rss_hf;
2295 printf("rss_hf %#"PRIx64"\n", rss_hf);
2299 cmdline_parse_token_string_t cmd_config_rss_port =
2300 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2301 cmdline_parse_token_string_t cmd_config_rss_keyword =
2302 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2303 cmdline_parse_token_string_t cmd_config_rss_all =
2304 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2305 cmdline_parse_token_string_t cmd_config_rss_name =
2306 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2307 cmdline_parse_token_string_t cmd_config_rss_value =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2310 cmdline_parse_inst_t cmd_config_rss = {
2311 .f = cmd_config_rss_parsed,
2313 .help_str = "port config all rss "
2314 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2315 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2316 "level-outer|level-inner|ipv4-chksum|<flowtype_id>",
2318 (void *)&cmd_config_rss_port,
2319 (void *)&cmd_config_rss_keyword,
2320 (void *)&cmd_config_rss_all,
2321 (void *)&cmd_config_rss_name,
2322 (void *)&cmd_config_rss_value,
2327 /* *** configure rss hash key *** */
2328 struct cmd_config_rss_hash_key {
2329 cmdline_fixed_string_t port;
2330 cmdline_fixed_string_t config;
2332 cmdline_fixed_string_t rss_hash_key;
2333 cmdline_fixed_string_t rss_type;
2334 cmdline_fixed_string_t key;
2338 hexa_digit_to_value(char hexa_digit)
2340 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2341 return (uint8_t) (hexa_digit - '0');
2342 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2343 return (uint8_t) ((hexa_digit - 'a') + 10);
2344 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2345 return (uint8_t) ((hexa_digit - 'A') + 10);
2346 /* Invalid hexa digit */
2351 parse_and_check_key_hexa_digit(char *key, int idx)
2355 hexa_v = hexa_digit_to_value(key[idx]);
2358 "invalid key: character %c at position %d is not a valid hexa digit\n",
2364 cmd_config_rss_hash_key_parsed(void *parsed_result,
2365 __rte_unused struct cmdline *cl,
2366 __rte_unused void *data)
2368 struct cmd_config_rss_hash_key *res = parsed_result;
2369 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2373 struct rte_eth_dev_info dev_info;
2374 uint8_t hash_key_size;
2378 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2382 if (dev_info.hash_key_size > 0 &&
2383 dev_info.hash_key_size <= sizeof(hash_key))
2384 hash_key_size = dev_info.hash_key_size;
2387 "dev_info did not provide a valid hash key size\n");
2390 /* Check the length of the RSS hash key */
2391 key_len = strlen(res->key);
2392 if (key_len != (hash_key_size * 2)) {
2394 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2395 (int)key_len, hash_key_size * 2);
2398 /* Translate RSS hash key into binary representation */
2399 for (i = 0; i < hash_key_size; i++) {
2400 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2403 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2406 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2408 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2412 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2413 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2414 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2415 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2417 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2418 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2420 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2421 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2422 rss_hash_key, "rss-hash-key");
2423 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2424 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2425 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2426 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2427 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2428 "ipv6-tcp-ex#ipv6-udp-ex#"
2429 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2430 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2431 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2432 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2433 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2435 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2436 .f = cmd_config_rss_hash_key_parsed,
2438 .help_str = "port config <port_id> rss-hash-key "
2439 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2440 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2441 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2442 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2443 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2444 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2445 "<string of hex digits (variable length, NIC dependent)>",
2447 (void *)&cmd_config_rss_hash_key_port,
2448 (void *)&cmd_config_rss_hash_key_config,
2449 (void *)&cmd_config_rss_hash_key_port_id,
2450 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2451 (void *)&cmd_config_rss_hash_key_rss_type,
2452 (void *)&cmd_config_rss_hash_key_value,
2457 /* *** cleanup txq mbufs *** */
2458 struct cmd_cleanup_txq_mbufs_result {
2459 cmdline_fixed_string_t port;
2460 cmdline_fixed_string_t keyword;
2461 cmdline_fixed_string_t name;
2468 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2469 __rte_unused struct cmdline *cl,
2470 __rte_unused void *data)
2472 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2473 uint16_t port_id = res->port_id;
2474 uint16_t queue_id = res->queue_id;
2475 uint32_t free_cnt = res->free_cnt;
2476 struct rte_eth_txq_info qinfo;
2479 if (test_done == 0) {
2480 fprintf(stderr, "Please stop forwarding first\n");
2484 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2485 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2490 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2491 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2495 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2498 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2499 port_id, queue_id, strerror(-ret), ret);
2503 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2504 port_id, queue_id, ret);
2507 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2508 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2510 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2511 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2513 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2514 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2516 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2517 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2519 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2520 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2522 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2523 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2526 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2527 .f = cmd_cleanup_txq_mbufs_parsed,
2529 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2531 (void *)&cmd_cleanup_txq_mbufs_port,
2532 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2533 (void *)&cmd_cleanup_txq_mbufs_port_id,
2534 (void *)&cmd_cleanup_txq_mbufs_txq,
2535 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2536 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2541 /* *** configure port rxq/txq ring size *** */
2542 struct cmd_config_rxtx_ring_size {
2543 cmdline_fixed_string_t port;
2544 cmdline_fixed_string_t config;
2546 cmdline_fixed_string_t rxtxq;
2548 cmdline_fixed_string_t rsize;
2553 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2554 __rte_unused struct cmdline *cl,
2555 __rte_unused void *data)
2557 struct cmd_config_rxtx_ring_size *res = parsed_result;
2558 struct rte_port *port;
2561 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2564 if (res->portid == (portid_t)RTE_PORT_ALL) {
2565 fprintf(stderr, "Invalid port id\n");
2569 port = &ports[res->portid];
2571 if (!strcmp(res->rxtxq, "rxq"))
2573 else if (!strcmp(res->rxtxq, "txq"))
2576 fprintf(stderr, "Unknown parameter\n");
2580 if (isrx && rx_queue_id_is_invalid(res->qid))
2582 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2585 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2587 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2593 port->nb_rx_desc[res->qid] = res->size;
2595 port->nb_tx_desc[res->qid] = res->size;
2597 cmd_reconfig_device_queue(res->portid, 0, 1);
2600 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2601 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2603 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2604 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2606 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2607 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2608 portid, RTE_UINT16);
2609 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2610 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2612 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2613 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2615 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2616 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2617 rsize, "ring_size");
2618 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2619 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2622 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2623 .f = cmd_config_rxtx_ring_size_parsed,
2625 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2627 (void *)&cmd_config_rxtx_ring_size_port,
2628 (void *)&cmd_config_rxtx_ring_size_config,
2629 (void *)&cmd_config_rxtx_ring_size_portid,
2630 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2631 (void *)&cmd_config_rxtx_ring_size_qid,
2632 (void *)&cmd_config_rxtx_ring_size_rsize,
2633 (void *)&cmd_config_rxtx_ring_size_size,
2638 /* *** configure port rxq/txq start/stop *** */
2639 struct cmd_config_rxtx_queue {
2640 cmdline_fixed_string_t port;
2642 cmdline_fixed_string_t rxtxq;
2644 cmdline_fixed_string_t opname;
2648 cmd_config_rxtx_queue_parsed(void *parsed_result,
2649 __rte_unused struct cmdline *cl,
2650 __rte_unused void *data)
2652 struct cmd_config_rxtx_queue *res = parsed_result;
2657 if (test_done == 0) {
2658 fprintf(stderr, "Please stop forwarding first\n");
2662 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2665 if (port_is_started(res->portid) != 1) {
2666 fprintf(stderr, "Please start port %u first\n", res->portid);
2670 if (!strcmp(res->rxtxq, "rxq"))
2672 else if (!strcmp(res->rxtxq, "txq"))
2675 fprintf(stderr, "Unknown parameter\n");
2679 if (isrx && rx_queue_id_is_invalid(res->qid))
2681 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2684 if (!strcmp(res->opname, "start"))
2686 else if (!strcmp(res->opname, "stop"))
2689 fprintf(stderr, "Unknown parameter\n");
2693 if (isstart && isrx)
2694 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2695 else if (!isstart && isrx)
2696 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2697 else if (isstart && !isrx)
2698 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2700 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2702 if (ret == -ENOTSUP)
2703 fprintf(stderr, "Function not supported in PMD driver\n");
2706 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2707 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2708 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2709 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2710 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2711 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2712 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2713 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2714 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2715 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2718 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2719 .f = cmd_config_rxtx_queue_parsed,
2721 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2723 (void *)&cmd_config_rxtx_queue_port,
2724 (void *)&cmd_config_rxtx_queue_portid,
2725 (void *)&cmd_config_rxtx_queue_rxtxq,
2726 (void *)&cmd_config_rxtx_queue_qid,
2727 (void *)&cmd_config_rxtx_queue_opname,
2732 /* *** configure port rxq/txq deferred start on/off *** */
2733 struct cmd_config_deferred_start_rxtx_queue {
2734 cmdline_fixed_string_t port;
2736 cmdline_fixed_string_t rxtxq;
2738 cmdline_fixed_string_t opname;
2739 cmdline_fixed_string_t state;
2743 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2744 __rte_unused struct cmdline *cl,
2745 __rte_unused void *data)
2747 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2748 struct rte_port *port;
2751 uint8_t needreconfig = 0;
2753 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2756 if (port_is_started(res->port_id) != 0) {
2757 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2761 port = &ports[res->port_id];
2763 isrx = !strcmp(res->rxtxq, "rxq");
2765 if (isrx && rx_queue_id_is_invalid(res->qid))
2767 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2770 ison = !strcmp(res->state, "on");
2772 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2773 port->rx_conf[res->qid].rx_deferred_start = ison;
2775 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2776 port->tx_conf[res->qid].tx_deferred_start = ison;
2781 cmd_reconfig_device_queue(res->port_id, 0, 1);
2784 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2785 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2787 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2788 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2789 port_id, RTE_UINT16);
2790 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2791 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2793 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2794 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2796 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2797 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2798 opname, "deferred_start");
2799 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2800 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2803 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2804 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2806 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2808 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2809 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2810 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2811 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2812 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2813 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2818 /* *** configure port rxq/txq setup *** */
2819 struct cmd_setup_rxtx_queue {
2820 cmdline_fixed_string_t port;
2822 cmdline_fixed_string_t rxtxq;
2824 cmdline_fixed_string_t setup;
2827 /* Common CLI fields for queue setup */
2828 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2829 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2830 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2831 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2832 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2833 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2834 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2835 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2836 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2837 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2840 cmd_setup_rxtx_queue_parsed(
2841 void *parsed_result,
2842 __rte_unused struct cmdline *cl,
2843 __rte_unused void *data)
2845 struct cmd_setup_rxtx_queue *res = parsed_result;
2846 struct rte_port *port;
2847 struct rte_mempool *mp;
2848 unsigned int socket_id;
2852 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2855 if (res->portid == (portid_t)RTE_PORT_ALL) {
2856 fprintf(stderr, "Invalid port id\n");
2860 if (!strcmp(res->rxtxq, "rxq"))
2862 else if (!strcmp(res->rxtxq, "txq"))
2865 fprintf(stderr, "Unknown parameter\n");
2869 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2870 fprintf(stderr, "Invalid rx queue\n");
2872 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2873 fprintf(stderr, "Invalid tx queue\n");
2877 port = &ports[res->portid];
2879 socket_id = rxring_numa[res->portid];
2880 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2881 socket_id = port->socket_id;
2883 mp = mbuf_pool_find(socket_id, 0);
2886 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2887 rxring_numa[res->portid]);
2890 ret = rx_queue_setup(res->portid,
2892 port->nb_rx_desc[res->qid],
2894 &port->rx_conf[res->qid],
2897 fprintf(stderr, "Failed to setup RX queue\n");
2899 socket_id = txring_numa[res->portid];
2900 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2901 socket_id = port->socket_id;
2903 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2905 "Failed to setup TX queue: not enough descriptors\n");
2908 ret = rte_eth_tx_queue_setup(res->portid,
2910 port->nb_tx_desc[res->qid],
2912 &port->tx_conf[res->qid]);
2914 fprintf(stderr, "Failed to setup TX queue\n");
2918 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2919 .f = cmd_setup_rxtx_queue_parsed,
2921 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2923 (void *)&cmd_setup_rxtx_queue_port,
2924 (void *)&cmd_setup_rxtx_queue_portid,
2925 (void *)&cmd_setup_rxtx_queue_rxtxq,
2926 (void *)&cmd_setup_rxtx_queue_qid,
2927 (void *)&cmd_setup_rxtx_queue_setup,
2933 /* *** Configure RSS RETA *** */
2934 struct cmd_config_rss_reta {
2935 cmdline_fixed_string_t port;
2936 cmdline_fixed_string_t keyword;
2938 cmdline_fixed_string_t name;
2939 cmdline_fixed_string_t list_name;
2940 cmdline_fixed_string_t list_of_items;
2944 parse_reta_config(const char *str,
2945 struct rte_eth_rss_reta_entry64 *reta_conf,
2946 uint16_t nb_entries)
2950 uint16_t hash_index, idx, shift;
2953 const char *p, *p0 = str;
2960 unsigned long int_fld[_NUM_FLD];
2961 char *str_fld[_NUM_FLD];
2963 while ((p = strchr(p0,'(')) != NULL) {
2965 if((p0 = strchr(p,')')) == NULL)
2969 if(size >= sizeof(s))
2972 snprintf(s, sizeof(s), "%.*s", size, p);
2973 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2975 for (i = 0; i < _NUM_FLD; i++) {
2977 int_fld[i] = strtoul(str_fld[i], &end, 0);
2978 if (errno != 0 || end == str_fld[i] ||
2983 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2984 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2986 if (hash_index >= nb_entries) {
2987 fprintf(stderr, "Invalid RETA hash index=%d\n",
2992 idx = hash_index / RTE_RETA_GROUP_SIZE;
2993 shift = hash_index % RTE_RETA_GROUP_SIZE;
2994 reta_conf[idx].mask |= (1ULL << shift);
2995 reta_conf[idx].reta[shift] = nb_queue;
3002 cmd_set_rss_reta_parsed(void *parsed_result,
3003 __rte_unused struct cmdline *cl,
3004 __rte_unused void *data)
3007 struct rte_eth_dev_info dev_info;
3008 struct rte_eth_rss_reta_entry64 reta_conf[8];
3009 struct cmd_config_rss_reta *res = parsed_result;
3011 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3015 if (dev_info.reta_size == 0) {
3017 "Redirection table size is 0 which is invalid for RSS\n");
3020 printf("The reta size of port %d is %u\n",
3021 res->port_id, dev_info.reta_size);
3022 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3024 "Currently do not support more than %u entries of redirection table\n",
3025 ETH_RSS_RETA_SIZE_512);
3029 memset(reta_conf, 0, sizeof(reta_conf));
3030 if (!strcmp(res->list_name, "reta")) {
3031 if (parse_reta_config(res->list_of_items, reta_conf,
3032 dev_info.reta_size)) {
3034 "Invalid RSS Redirection Table config entered\n");
3037 ret = rte_eth_dev_rss_reta_update(res->port_id,
3038 reta_conf, dev_info.reta_size);
3041 "Bad redirection table parameter, return code = %d\n",
3046 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3047 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3048 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3049 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3050 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3051 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3052 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3054 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3056 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3059 cmdline_parse_inst_t cmd_config_rss_reta = {
3060 .f = cmd_set_rss_reta_parsed,
3062 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3064 (void *)&cmd_config_rss_reta_port,
3065 (void *)&cmd_config_rss_reta_keyword,
3066 (void *)&cmd_config_rss_reta_port_id,
3067 (void *)&cmd_config_rss_reta_name,
3068 (void *)&cmd_config_rss_reta_list_name,
3069 (void *)&cmd_config_rss_reta_list_of_items,
3074 /* *** SHOW PORT RETA INFO *** */
3075 struct cmd_showport_reta {
3076 cmdline_fixed_string_t show;
3077 cmdline_fixed_string_t port;
3079 cmdline_fixed_string_t rss;
3080 cmdline_fixed_string_t reta;
3082 cmdline_fixed_string_t list_of_items;
3086 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3087 uint16_t nb_entries,
3091 const char *p, *p0 = str;
3096 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3097 RTE_RETA_GROUP_SIZE;
3100 p = strchr(p0, '(');
3104 p0 = strchr(p, ')');
3108 if (size >= sizeof(s)) {
3110 "The string size exceeds the internal buffer size\n");
3113 snprintf(s, sizeof(s), "%.*s", size, p);
3114 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3115 if (ret <= 0 || ret != num) {
3117 "The bits of masks do not match the number of reta entries: %u\n",
3121 for (i = 0; i < ret; i++)
3122 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3128 cmd_showport_reta_parsed(void *parsed_result,
3129 __rte_unused struct cmdline *cl,
3130 __rte_unused void *data)
3132 struct cmd_showport_reta *res = parsed_result;
3133 struct rte_eth_rss_reta_entry64 reta_conf[8];
3134 struct rte_eth_dev_info dev_info;
3135 uint16_t max_reta_size;
3138 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3142 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3143 if (res->size == 0 || res->size > max_reta_size) {
3144 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3145 res->size, max_reta_size);
3149 memset(reta_conf, 0, sizeof(reta_conf));
3150 if (showport_parse_reta_config(reta_conf, res->size,
3151 res->list_of_items) < 0) {
3152 fprintf(stderr, "Invalid string: %s for reta masks\n",
3153 res->list_of_items);
3156 port_rss_reta_info(res->port_id, reta_conf, res->size);
3159 cmdline_parse_token_string_t cmd_showport_reta_show =
3160 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3161 cmdline_parse_token_string_t cmd_showport_reta_port =
3162 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3163 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3164 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3165 cmdline_parse_token_string_t cmd_showport_reta_rss =
3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3167 cmdline_parse_token_string_t cmd_showport_reta_reta =
3168 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3169 cmdline_parse_token_num_t cmd_showport_reta_size =
3170 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3171 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3173 list_of_items, NULL);
3175 cmdline_parse_inst_t cmd_showport_reta = {
3176 .f = cmd_showport_reta_parsed,
3178 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3180 (void *)&cmd_showport_reta_show,
3181 (void *)&cmd_showport_reta_port,
3182 (void *)&cmd_showport_reta_port_id,
3183 (void *)&cmd_showport_reta_rss,
3184 (void *)&cmd_showport_reta_reta,
3185 (void *)&cmd_showport_reta_size,
3186 (void *)&cmd_showport_reta_list_of_items,
3191 /* *** Show RSS hash configuration *** */
3192 struct cmd_showport_rss_hash {
3193 cmdline_fixed_string_t show;
3194 cmdline_fixed_string_t port;
3196 cmdline_fixed_string_t rss_hash;
3197 cmdline_fixed_string_t rss_type;
3198 cmdline_fixed_string_t key; /* optional argument */
3201 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3202 __rte_unused struct cmdline *cl,
3205 struct cmd_showport_rss_hash *res = parsed_result;
3207 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3210 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3211 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3212 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3213 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3214 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3215 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3217 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3218 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3220 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3221 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3223 cmdline_parse_inst_t cmd_showport_rss_hash = {
3224 .f = cmd_showport_rss_hash_parsed,
3226 .help_str = "show port <port_id> rss-hash",
3228 (void *)&cmd_showport_rss_hash_show,
3229 (void *)&cmd_showport_rss_hash_port,
3230 (void *)&cmd_showport_rss_hash_port_id,
3231 (void *)&cmd_showport_rss_hash_rss_hash,
3236 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3237 .f = cmd_showport_rss_hash_parsed,
3239 .help_str = "show port <port_id> rss-hash key",
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,
3245 (void *)&cmd_showport_rss_hash_rss_key,
3250 /* *** Configure DCB *** */
3251 struct cmd_config_dcb {
3252 cmdline_fixed_string_t port;
3253 cmdline_fixed_string_t config;
3255 cmdline_fixed_string_t dcb;
3256 cmdline_fixed_string_t vt;
3257 cmdline_fixed_string_t vt_en;
3259 cmdline_fixed_string_t pfc;
3260 cmdline_fixed_string_t pfc_en;
3264 cmd_config_dcb_parsed(void *parsed_result,
3265 __rte_unused struct cmdline *cl,
3266 __rte_unused void *data)
3268 struct cmd_config_dcb *res = parsed_result;
3269 struct rte_eth_dcb_info dcb_info;
3270 portid_t port_id = res->port_id;
3271 struct rte_port *port;
3275 port = &ports[port_id];
3276 /** Check if the port is not started **/
3277 if (port->port_status != RTE_PORT_STOPPED) {
3278 fprintf(stderr, "Please stop port %d first\n", port_id);
3282 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3284 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3288 if (nb_fwd_lcores < res->num_tcs) {
3290 "nb_cores shouldn't be less than number of TCs.\n");
3294 /* Check whether the port supports the report of DCB info. */
3295 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3296 if (ret == -ENOTSUP) {
3297 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3301 if (!strncmp(res->pfc_en, "on", 2))
3306 /* DCB in VT mode */
3307 if (!strncmp(res->vt_en, "on", 2))
3308 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3309 (enum rte_eth_nb_tcs)res->num_tcs,
3312 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3313 (enum rte_eth_nb_tcs)res->num_tcs,
3316 fprintf(stderr, "Cannot initialize network ports.\n");
3322 cmd_reconfig_device_queue(port_id, 1, 1);
3325 cmdline_parse_token_string_t cmd_config_dcb_port =
3326 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3327 cmdline_parse_token_string_t cmd_config_dcb_config =
3328 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3329 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3330 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3331 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3332 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3333 cmdline_parse_token_string_t cmd_config_dcb_vt =
3334 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3335 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3336 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3337 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3338 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3339 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3340 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3341 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3342 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3344 cmdline_parse_inst_t cmd_config_dcb = {
3345 .f = cmd_config_dcb_parsed,
3347 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3349 (void *)&cmd_config_dcb_port,
3350 (void *)&cmd_config_dcb_config,
3351 (void *)&cmd_config_dcb_port_id,
3352 (void *)&cmd_config_dcb_dcb,
3353 (void *)&cmd_config_dcb_vt,
3354 (void *)&cmd_config_dcb_vt_en,
3355 (void *)&cmd_config_dcb_num_tcs,
3356 (void *)&cmd_config_dcb_pfc,
3357 (void *)&cmd_config_dcb_pfc_en,
3362 /* *** configure number of packets per burst *** */
3363 struct cmd_config_burst {
3364 cmdline_fixed_string_t port;
3365 cmdline_fixed_string_t keyword;
3366 cmdline_fixed_string_t all;
3367 cmdline_fixed_string_t name;
3372 cmd_config_burst_parsed(void *parsed_result,
3373 __rte_unused struct cmdline *cl,
3374 __rte_unused void *data)
3376 struct cmd_config_burst *res = parsed_result;
3377 struct rte_eth_dev_info dev_info;
3378 uint16_t rec_nb_pkts;
3381 if (!all_ports_stopped()) {
3382 fprintf(stderr, "Please stop all ports first\n");
3386 if (!strcmp(res->name, "burst")) {
3387 if (res->value == 0) {
3388 /* If user gives a value of zero, query the PMD for
3389 * its recommended Rx burst size. Testpmd uses a single
3390 * size for all ports, so assume all ports are the same
3391 * NIC model and use the values from Port 0.
3393 ret = eth_dev_info_get_print_err(0, &dev_info);
3397 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3399 if (rec_nb_pkts == 0) {
3400 printf("PMD does not recommend a burst size.\n"
3401 "User provided value must be between"
3402 " 1 and %d\n", MAX_PKT_BURST);
3404 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3405 printf("PMD recommended burst size of %d"
3406 " exceeds maximum value of %d\n",
3407 rec_nb_pkts, MAX_PKT_BURST);
3410 printf("Using PMD-provided burst value of %d\n",
3412 nb_pkt_per_burst = rec_nb_pkts;
3413 } else if (res->value > MAX_PKT_BURST) {
3414 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3418 nb_pkt_per_burst = res->value;
3420 fprintf(stderr, "Unknown parameter\n");
3426 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3429 cmdline_parse_token_string_t cmd_config_burst_port =
3430 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3431 cmdline_parse_token_string_t cmd_config_burst_keyword =
3432 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3433 cmdline_parse_token_string_t cmd_config_burst_all =
3434 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3435 cmdline_parse_token_string_t cmd_config_burst_name =
3436 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3437 cmdline_parse_token_num_t cmd_config_burst_value =
3438 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3440 cmdline_parse_inst_t cmd_config_burst = {
3441 .f = cmd_config_burst_parsed,
3443 .help_str = "port config all burst <value>",
3445 (void *)&cmd_config_burst_port,
3446 (void *)&cmd_config_burst_keyword,
3447 (void *)&cmd_config_burst_all,
3448 (void *)&cmd_config_burst_name,
3449 (void *)&cmd_config_burst_value,
3454 /* *** configure rx/tx queues *** */
3455 struct cmd_config_thresh {
3456 cmdline_fixed_string_t port;
3457 cmdline_fixed_string_t keyword;
3458 cmdline_fixed_string_t all;
3459 cmdline_fixed_string_t name;
3464 cmd_config_thresh_parsed(void *parsed_result,
3465 __rte_unused struct cmdline *cl,
3466 __rte_unused void *data)
3468 struct cmd_config_thresh *res = parsed_result;
3470 if (!all_ports_stopped()) {
3471 fprintf(stderr, "Please stop all ports first\n");
3475 if (!strcmp(res->name, "txpt"))
3476 tx_pthresh = res->value;
3477 else if(!strcmp(res->name, "txht"))
3478 tx_hthresh = res->value;
3479 else if(!strcmp(res->name, "txwt"))
3480 tx_wthresh = res->value;
3481 else if(!strcmp(res->name, "rxpt"))
3482 rx_pthresh = res->value;
3483 else if(!strcmp(res->name, "rxht"))
3484 rx_hthresh = res->value;
3485 else if(!strcmp(res->name, "rxwt"))
3486 rx_wthresh = res->value;
3488 fprintf(stderr, "Unknown parameter\n");
3494 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3497 cmdline_parse_token_string_t cmd_config_thresh_port =
3498 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3499 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3500 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3501 cmdline_parse_token_string_t cmd_config_thresh_all =
3502 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3503 cmdline_parse_token_string_t cmd_config_thresh_name =
3504 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3505 "txpt#txht#txwt#rxpt#rxht#rxwt");
3506 cmdline_parse_token_num_t cmd_config_thresh_value =
3507 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3509 cmdline_parse_inst_t cmd_config_thresh = {
3510 .f = cmd_config_thresh_parsed,
3512 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3514 (void *)&cmd_config_thresh_port,
3515 (void *)&cmd_config_thresh_keyword,
3516 (void *)&cmd_config_thresh_all,
3517 (void *)&cmd_config_thresh_name,
3518 (void *)&cmd_config_thresh_value,
3523 /* *** configure free/rs threshold *** */
3524 struct cmd_config_threshold {
3525 cmdline_fixed_string_t port;
3526 cmdline_fixed_string_t keyword;
3527 cmdline_fixed_string_t all;
3528 cmdline_fixed_string_t name;
3533 cmd_config_threshold_parsed(void *parsed_result,
3534 __rte_unused struct cmdline *cl,
3535 __rte_unused void *data)
3537 struct cmd_config_threshold *res = parsed_result;
3539 if (!all_ports_stopped()) {
3540 fprintf(stderr, "Please stop all ports first\n");
3544 if (!strcmp(res->name, "txfreet"))
3545 tx_free_thresh = res->value;
3546 else if (!strcmp(res->name, "txrst"))
3547 tx_rs_thresh = res->value;
3548 else if (!strcmp(res->name, "rxfreet"))
3549 rx_free_thresh = res->value;
3551 fprintf(stderr, "Unknown parameter\n");
3557 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3560 cmdline_parse_token_string_t cmd_config_threshold_port =
3561 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3562 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3563 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3565 cmdline_parse_token_string_t cmd_config_threshold_all =
3566 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3567 cmdline_parse_token_string_t cmd_config_threshold_name =
3568 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3569 "txfreet#txrst#rxfreet");
3570 cmdline_parse_token_num_t cmd_config_threshold_value =
3571 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3573 cmdline_parse_inst_t cmd_config_threshold = {
3574 .f = cmd_config_threshold_parsed,
3576 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3578 (void *)&cmd_config_threshold_port,
3579 (void *)&cmd_config_threshold_keyword,
3580 (void *)&cmd_config_threshold_all,
3581 (void *)&cmd_config_threshold_name,
3582 (void *)&cmd_config_threshold_value,
3588 struct cmd_stop_result {
3589 cmdline_fixed_string_t stop;
3592 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3593 __rte_unused struct cmdline *cl,
3594 __rte_unused void *data)
3596 stop_packet_forwarding();
3599 cmdline_parse_token_string_t cmd_stop_stop =
3600 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3602 cmdline_parse_inst_t cmd_stop = {
3603 .f = cmd_stop_parsed,
3605 .help_str = "stop: Stop packet forwarding",
3607 (void *)&cmd_stop_stop,
3612 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3615 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3616 unsigned int *parsed_items, int check_unique_values)
3618 unsigned int nb_item;
3626 * First parse all items in the list and store their value.
3631 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3633 if ((c >= '0') && (c <= '9')) {
3634 value = (unsigned int) (value * 10 + (c - '0'));
3639 fprintf(stderr, "character %c is not a decimal digit\n", c);
3643 fprintf(stderr, "No valid value before comma\n");
3646 if (nb_item < max_items) {
3647 parsed_items[nb_item] = value;
3653 if (nb_item >= max_items) {
3654 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3655 item_name, nb_item + 1, max_items);
3658 parsed_items[nb_item++] = value;
3659 if (! check_unique_values)
3663 * Then, check that all values in the list are differents.
3664 * No optimization here...
3666 for (i = 0; i < nb_item; i++) {
3667 for (j = i + 1; j < nb_item; j++) {
3668 if (parsed_items[j] == parsed_items[i]) {
3670 "duplicated %s %u at index %u and %u\n",
3671 item_name, parsed_items[i], i, j);
3679 struct cmd_set_list_result {
3680 cmdline_fixed_string_t cmd_keyword;
3681 cmdline_fixed_string_t list_name;
3682 cmdline_fixed_string_t list_of_items;
3685 static void cmd_set_list_parsed(void *parsed_result,
3686 __rte_unused struct cmdline *cl,
3687 __rte_unused void *data)
3689 struct cmd_set_list_result *res;
3691 unsigned int lcorelist[RTE_MAX_LCORE];
3692 unsigned int portlist[RTE_MAX_ETHPORTS];
3694 unsigned int nb_item;
3696 if (test_done == 0) {
3697 fprintf(stderr, "Please stop forwarding first\n");
3701 res = parsed_result;
3702 if (!strcmp(res->list_name, "corelist")) {
3703 nb_item = parse_item_list(res->list_of_items, "core",
3705 parsed_items.lcorelist, 1);
3707 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3712 if (!strcmp(res->list_name, "portlist")) {
3713 nb_item = parse_item_list(res->list_of_items, "port",
3715 parsed_items.portlist, 1);
3717 set_fwd_ports_list(parsed_items.portlist, nb_item);
3723 cmdline_parse_token_string_t cmd_set_list_keyword =
3724 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3726 cmdline_parse_token_string_t cmd_set_list_name =
3727 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3728 "corelist#portlist");
3729 cmdline_parse_token_string_t cmd_set_list_of_items =
3730 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3733 cmdline_parse_inst_t cmd_set_fwd_list = {
3734 .f = cmd_set_list_parsed,
3736 .help_str = "set corelist|portlist <list0[,list1]*>",
3738 (void *)&cmd_set_list_keyword,
3739 (void *)&cmd_set_list_name,
3740 (void *)&cmd_set_list_of_items,
3745 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3747 struct cmd_setmask_result {
3748 cmdline_fixed_string_t set;
3749 cmdline_fixed_string_t mask;
3753 static void cmd_set_mask_parsed(void *parsed_result,
3754 __rte_unused struct cmdline *cl,
3755 __rte_unused void *data)
3757 struct cmd_setmask_result *res = parsed_result;
3759 if (test_done == 0) {
3760 fprintf(stderr, "Please stop forwarding first\n");
3763 if (!strcmp(res->mask, "coremask")) {
3764 set_fwd_lcores_mask(res->hexavalue);
3766 } else if (!strcmp(res->mask, "portmask")) {
3767 set_fwd_ports_mask(res->hexavalue);
3772 cmdline_parse_token_string_t cmd_setmask_set =
3773 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3774 cmdline_parse_token_string_t cmd_setmask_mask =
3775 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3776 "coremask#portmask");
3777 cmdline_parse_token_num_t cmd_setmask_value =
3778 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3780 cmdline_parse_inst_t cmd_set_fwd_mask = {
3781 .f = cmd_set_mask_parsed,
3783 .help_str = "set coremask|portmask <hexadecimal value>",
3785 (void *)&cmd_setmask_set,
3786 (void *)&cmd_setmask_mask,
3787 (void *)&cmd_setmask_value,
3793 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3795 struct cmd_set_result {
3796 cmdline_fixed_string_t set;
3797 cmdline_fixed_string_t what;
3801 static void cmd_set_parsed(void *parsed_result,
3802 __rte_unused struct cmdline *cl,
3803 __rte_unused void *data)
3805 struct cmd_set_result *res = parsed_result;
3806 if (!strcmp(res->what, "nbport")) {
3807 set_fwd_ports_number(res->value);
3809 } else if (!strcmp(res->what, "nbcore")) {
3810 set_fwd_lcores_number(res->value);
3812 } else if (!strcmp(res->what, "burst"))
3813 set_nb_pkt_per_burst(res->value);
3814 else if (!strcmp(res->what, "verbose"))
3815 set_verbose_level(res->value);
3818 cmdline_parse_token_string_t cmd_set_set =
3819 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3820 cmdline_parse_token_string_t cmd_set_what =
3821 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3822 "nbport#nbcore#burst#verbose");
3823 cmdline_parse_token_num_t cmd_set_value =
3824 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3826 cmdline_parse_inst_t cmd_set_numbers = {
3827 .f = cmd_set_parsed,
3829 .help_str = "set nbport|nbcore|burst|verbose <value>",
3831 (void *)&cmd_set_set,
3832 (void *)&cmd_set_what,
3833 (void *)&cmd_set_value,
3838 /* *** SET LOG LEVEL CONFIGURATION *** */
3840 struct cmd_set_log_result {
3841 cmdline_fixed_string_t set;
3842 cmdline_fixed_string_t log;
3843 cmdline_fixed_string_t type;
3848 cmd_set_log_parsed(void *parsed_result,
3849 __rte_unused struct cmdline *cl,
3850 __rte_unused void *data)
3852 struct cmd_set_log_result *res;
3855 res = parsed_result;
3856 if (!strcmp(res->type, "global"))
3857 rte_log_set_global_level(res->level);
3859 ret = rte_log_set_level_regexp(res->type, res->level);
3861 fprintf(stderr, "Unable to set log level\n");
3865 cmdline_parse_token_string_t cmd_set_log_set =
3866 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3867 cmdline_parse_token_string_t cmd_set_log_log =
3868 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3869 cmdline_parse_token_string_t cmd_set_log_type =
3870 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3871 cmdline_parse_token_num_t cmd_set_log_level =
3872 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3874 cmdline_parse_inst_t cmd_set_log = {
3875 .f = cmd_set_log_parsed,
3877 .help_str = "set log global|<type> <level>",
3879 (void *)&cmd_set_log_set,
3880 (void *)&cmd_set_log_log,
3881 (void *)&cmd_set_log_type,
3882 (void *)&cmd_set_log_level,
3887 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3889 struct cmd_set_rxoffs_result {
3890 cmdline_fixed_string_t cmd_keyword;
3891 cmdline_fixed_string_t rxoffs;
3892 cmdline_fixed_string_t seg_offsets;
3896 cmd_set_rxoffs_parsed(void *parsed_result,
3897 __rte_unused struct cmdline *cl,
3898 __rte_unused void *data)
3900 struct cmd_set_rxoffs_result *res;
3901 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3902 unsigned int nb_segs;
3904 res = parsed_result;
3905 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3906 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3908 set_rx_pkt_offsets(seg_offsets, nb_segs);
3909 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3912 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3913 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3914 cmd_keyword, "set");
3915 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3916 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3918 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3919 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3922 cmdline_parse_inst_t cmd_set_rxoffs = {
3923 .f = cmd_set_rxoffs_parsed,
3925 .help_str = "set rxoffs <len0[,len1]*>",
3927 (void *)&cmd_set_rxoffs_keyword,
3928 (void *)&cmd_set_rxoffs_name,
3929 (void *)&cmd_set_rxoffs_offsets,
3934 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3936 struct cmd_set_rxpkts_result {
3937 cmdline_fixed_string_t cmd_keyword;
3938 cmdline_fixed_string_t rxpkts;
3939 cmdline_fixed_string_t seg_lengths;
3943 cmd_set_rxpkts_parsed(void *parsed_result,
3944 __rte_unused struct cmdline *cl,
3945 __rte_unused void *data)
3947 struct cmd_set_rxpkts_result *res;
3948 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3949 unsigned int nb_segs;
3951 res = parsed_result;
3952 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3953 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3955 set_rx_pkt_segments(seg_lengths, nb_segs);
3956 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3959 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3960 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3961 cmd_keyword, "set");
3962 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3963 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3965 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3966 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3969 cmdline_parse_inst_t cmd_set_rxpkts = {
3970 .f = cmd_set_rxpkts_parsed,
3972 .help_str = "set rxpkts <len0[,len1]*>",
3974 (void *)&cmd_set_rxpkts_keyword,
3975 (void *)&cmd_set_rxpkts_name,
3976 (void *)&cmd_set_rxpkts_lengths,
3981 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3983 struct cmd_set_txpkts_result {
3984 cmdline_fixed_string_t cmd_keyword;
3985 cmdline_fixed_string_t txpkts;
3986 cmdline_fixed_string_t seg_lengths;
3990 cmd_set_txpkts_parsed(void *parsed_result,
3991 __rte_unused struct cmdline *cl,
3992 __rte_unused void *data)
3994 struct cmd_set_txpkts_result *res;
3995 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3996 unsigned int nb_segs;
3998 res = parsed_result;
3999 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4000 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4002 set_tx_pkt_segments(seg_lengths, nb_segs);
4005 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4006 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4007 cmd_keyword, "set");
4008 cmdline_parse_token_string_t cmd_set_txpkts_name =
4009 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4011 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4012 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4015 cmdline_parse_inst_t cmd_set_txpkts = {
4016 .f = cmd_set_txpkts_parsed,
4018 .help_str = "set txpkts <len0[,len1]*>",
4020 (void *)&cmd_set_txpkts_keyword,
4021 (void *)&cmd_set_txpkts_name,
4022 (void *)&cmd_set_txpkts_lengths,
4027 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4029 struct cmd_set_txsplit_result {
4030 cmdline_fixed_string_t cmd_keyword;
4031 cmdline_fixed_string_t txsplit;
4032 cmdline_fixed_string_t mode;
4036 cmd_set_txsplit_parsed(void *parsed_result,
4037 __rte_unused struct cmdline *cl,
4038 __rte_unused void *data)
4040 struct cmd_set_txsplit_result *res;
4042 res = parsed_result;
4043 set_tx_pkt_split(res->mode);
4046 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4047 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4048 cmd_keyword, "set");
4049 cmdline_parse_token_string_t cmd_set_txsplit_name =
4050 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4051 txsplit, "txsplit");
4052 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4053 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4056 cmdline_parse_inst_t cmd_set_txsplit = {
4057 .f = cmd_set_txsplit_parsed,
4059 .help_str = "set txsplit on|off|rand",
4061 (void *)&cmd_set_txsplit_keyword,
4062 (void *)&cmd_set_txsplit_name,
4063 (void *)&cmd_set_txsplit_mode,
4068 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4070 struct cmd_set_txtimes_result {
4071 cmdline_fixed_string_t cmd_keyword;
4072 cmdline_fixed_string_t txtimes;
4073 cmdline_fixed_string_t tx_times;
4077 cmd_set_txtimes_parsed(void *parsed_result,
4078 __rte_unused struct cmdline *cl,
4079 __rte_unused void *data)
4081 struct cmd_set_txtimes_result *res;
4082 unsigned int tx_times[2] = {0, 0};
4083 unsigned int n_times;
4085 res = parsed_result;
4086 n_times = parse_item_list(res->tx_times, "tx times",
4089 set_tx_pkt_times(tx_times);
4092 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4093 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4094 cmd_keyword, "set");
4095 cmdline_parse_token_string_t cmd_set_txtimes_name =
4096 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4097 txtimes, "txtimes");
4098 cmdline_parse_token_string_t cmd_set_txtimes_value =
4099 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4102 cmdline_parse_inst_t cmd_set_txtimes = {
4103 .f = cmd_set_txtimes_parsed,
4105 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4107 (void *)&cmd_set_txtimes_keyword,
4108 (void *)&cmd_set_txtimes_name,
4109 (void *)&cmd_set_txtimes_value,
4114 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4115 struct cmd_rx_vlan_filter_all_result {
4116 cmdline_fixed_string_t rx_vlan;
4117 cmdline_fixed_string_t what;
4118 cmdline_fixed_string_t all;
4123 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4124 __rte_unused struct cmdline *cl,
4125 __rte_unused void *data)
4127 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4129 if (!strcmp(res->what, "add"))
4130 rx_vlan_all_filter_set(res->port_id, 1);
4132 rx_vlan_all_filter_set(res->port_id, 0);
4135 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4136 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4137 rx_vlan, "rx_vlan");
4138 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4139 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4141 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4142 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4144 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4145 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4146 port_id, RTE_UINT16);
4148 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4149 .f = cmd_rx_vlan_filter_all_parsed,
4151 .help_str = "rx_vlan add|rm all <port_id>: "
4152 "Add/Remove all identifiers to/from the set of VLAN "
4153 "identifiers filtered by a port",
4155 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4156 (void *)&cmd_rx_vlan_filter_all_what,
4157 (void *)&cmd_rx_vlan_filter_all_all,
4158 (void *)&cmd_rx_vlan_filter_all_portid,
4163 /* *** VLAN OFFLOAD SET ON A PORT *** */
4164 struct cmd_vlan_offload_result {
4165 cmdline_fixed_string_t vlan;
4166 cmdline_fixed_string_t set;
4167 cmdline_fixed_string_t vlan_type;
4168 cmdline_fixed_string_t what;
4169 cmdline_fixed_string_t on;
4170 cmdline_fixed_string_t port_id;
4174 cmd_vlan_offload_parsed(void *parsed_result,
4175 __rte_unused struct cmdline *cl,
4176 __rte_unused void *data)
4179 struct cmd_vlan_offload_result *res = parsed_result;
4182 portid_t port_id = 0;
4186 len = strnlen(str, STR_TOKEN_SIZE);
4188 /* Get port_id first */
4196 tmp = strtoul(str, NULL, 0);
4197 /* If port_id greater that what portid_t can represent, return */
4198 if(tmp >= RTE_MAX_ETHPORTS)
4200 port_id = (portid_t)tmp;
4202 if (!strcmp(res->on, "on"))
4207 if (!strcmp(res->what, "strip"))
4208 rx_vlan_strip_set(port_id, on);
4209 else if(!strcmp(res->what, "stripq")){
4210 uint16_t queue_id = 0;
4212 /* No queue_id, return */
4214 fprintf(stderr, "must specify (port,queue_id)\n");
4217 tmp = strtoul(str + i + 1, NULL, 0);
4218 /* If queue_id greater that what 16-bits can represent, return */
4222 queue_id = (uint16_t)tmp;
4223 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4225 else if (!strcmp(res->what, "filter"))
4226 rx_vlan_filter_set(port_id, on);
4227 else if (!strcmp(res->what, "qinq_strip"))
4228 rx_vlan_qinq_strip_set(port_id, on);
4230 vlan_extend_set(port_id, on);
4235 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4236 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4238 cmdline_parse_token_string_t cmd_vlan_offload_set =
4239 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4241 cmdline_parse_token_string_t cmd_vlan_offload_what =
4242 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4243 what, "strip#filter#qinq_strip#extend#stripq");
4244 cmdline_parse_token_string_t cmd_vlan_offload_on =
4245 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4247 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4248 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4251 cmdline_parse_inst_t cmd_vlan_offload = {
4252 .f = cmd_vlan_offload_parsed,
4254 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4255 "<port_id[,queue_id]>: "
4256 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4258 (void *)&cmd_vlan_offload_vlan,
4259 (void *)&cmd_vlan_offload_set,
4260 (void *)&cmd_vlan_offload_what,
4261 (void *)&cmd_vlan_offload_on,
4262 (void *)&cmd_vlan_offload_portid,
4267 /* *** VLAN TPID SET ON A PORT *** */
4268 struct cmd_vlan_tpid_result {
4269 cmdline_fixed_string_t vlan;
4270 cmdline_fixed_string_t set;
4271 cmdline_fixed_string_t vlan_type;
4272 cmdline_fixed_string_t what;
4278 cmd_vlan_tpid_parsed(void *parsed_result,
4279 __rte_unused struct cmdline *cl,
4280 __rte_unused void *data)
4282 struct cmd_vlan_tpid_result *res = parsed_result;
4283 enum rte_vlan_type vlan_type;
4285 if (!strcmp(res->vlan_type, "inner"))
4286 vlan_type = ETH_VLAN_TYPE_INNER;
4287 else if (!strcmp(res->vlan_type, "outer"))
4288 vlan_type = ETH_VLAN_TYPE_OUTER;
4290 fprintf(stderr, "Unknown vlan type\n");
4293 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4296 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4297 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4299 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4300 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4302 cmdline_parse_token_string_t cmd_vlan_type =
4303 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4304 vlan_type, "inner#outer");
4305 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4306 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4308 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4309 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4311 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4312 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4313 port_id, RTE_UINT16);
4315 cmdline_parse_inst_t cmd_vlan_tpid = {
4316 .f = cmd_vlan_tpid_parsed,
4318 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4319 "Set the VLAN Ether type",
4321 (void *)&cmd_vlan_tpid_vlan,
4322 (void *)&cmd_vlan_tpid_set,
4323 (void *)&cmd_vlan_type,
4324 (void *)&cmd_vlan_tpid_what,
4325 (void *)&cmd_vlan_tpid_tpid,
4326 (void *)&cmd_vlan_tpid_portid,
4331 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4332 struct cmd_rx_vlan_filter_result {
4333 cmdline_fixed_string_t rx_vlan;
4334 cmdline_fixed_string_t what;
4340 cmd_rx_vlan_filter_parsed(void *parsed_result,
4341 __rte_unused struct cmdline *cl,
4342 __rte_unused void *data)
4344 struct cmd_rx_vlan_filter_result *res = parsed_result;
4346 if (!strcmp(res->what, "add"))
4347 rx_vft_set(res->port_id, res->vlan_id, 1);
4349 rx_vft_set(res->port_id, res->vlan_id, 0);
4352 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4353 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4354 rx_vlan, "rx_vlan");
4355 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4356 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4358 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4359 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4360 vlan_id, RTE_UINT16);
4361 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4362 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4363 port_id, RTE_UINT16);
4365 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4366 .f = cmd_rx_vlan_filter_parsed,
4368 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4369 "Add/Remove a VLAN identifier to/from the set of VLAN "
4370 "identifiers filtered by a port",
4372 (void *)&cmd_rx_vlan_filter_rx_vlan,
4373 (void *)&cmd_rx_vlan_filter_what,
4374 (void *)&cmd_rx_vlan_filter_vlanid,
4375 (void *)&cmd_rx_vlan_filter_portid,
4380 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4381 struct cmd_tx_vlan_set_result {
4382 cmdline_fixed_string_t tx_vlan;
4383 cmdline_fixed_string_t set;
4389 cmd_tx_vlan_set_parsed(void *parsed_result,
4390 __rte_unused struct cmdline *cl,
4391 __rte_unused void *data)
4393 struct cmd_tx_vlan_set_result *res = parsed_result;
4395 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4398 if (!port_is_stopped(res->port_id)) {
4399 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4403 tx_vlan_set(res->port_id, res->vlan_id);
4405 cmd_reconfig_device_queue(res->port_id, 1, 1);
4408 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4409 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4410 tx_vlan, "tx_vlan");
4411 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4412 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4414 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4415 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4416 port_id, RTE_UINT16);
4417 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4418 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4419 vlan_id, RTE_UINT16);
4421 cmdline_parse_inst_t cmd_tx_vlan_set = {
4422 .f = cmd_tx_vlan_set_parsed,
4424 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4425 "Enable hardware insertion of a single VLAN header "
4426 "with a given TAG Identifier in packets sent on a port",
4428 (void *)&cmd_tx_vlan_set_tx_vlan,
4429 (void *)&cmd_tx_vlan_set_set,
4430 (void *)&cmd_tx_vlan_set_portid,
4431 (void *)&cmd_tx_vlan_set_vlanid,
4436 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4437 struct cmd_tx_vlan_set_qinq_result {
4438 cmdline_fixed_string_t tx_vlan;
4439 cmdline_fixed_string_t set;
4442 uint16_t vlan_id_outer;
4446 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4447 __rte_unused struct cmdline *cl,
4448 __rte_unused void *data)
4450 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4452 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4455 if (!port_is_stopped(res->port_id)) {
4456 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4460 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4462 cmd_reconfig_device_queue(res->port_id, 1, 1);
4465 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4466 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4467 tx_vlan, "tx_vlan");
4468 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4469 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4471 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4472 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4473 port_id, RTE_UINT16);
4474 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4475 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4476 vlan_id, RTE_UINT16);
4477 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4478 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4479 vlan_id_outer, RTE_UINT16);
4481 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4482 .f = cmd_tx_vlan_set_qinq_parsed,
4484 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4485 "Enable hardware insertion of double VLAN header "
4486 "with given TAG Identifiers in packets sent on a port",
4488 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4489 (void *)&cmd_tx_vlan_set_qinq_set,
4490 (void *)&cmd_tx_vlan_set_qinq_portid,
4491 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4492 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4497 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4498 struct cmd_tx_vlan_set_pvid_result {
4499 cmdline_fixed_string_t tx_vlan;
4500 cmdline_fixed_string_t set;
4501 cmdline_fixed_string_t pvid;
4504 cmdline_fixed_string_t mode;
4508 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4509 __rte_unused struct cmdline *cl,
4510 __rte_unused void *data)
4512 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4514 if (strcmp(res->mode, "on") == 0)
4515 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4517 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4520 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4521 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4522 tx_vlan, "tx_vlan");
4523 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4524 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4526 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4527 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4529 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4530 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4531 port_id, RTE_UINT16);
4532 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4533 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4534 vlan_id, RTE_UINT16);
4535 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4536 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4539 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4540 .f = cmd_tx_vlan_set_pvid_parsed,
4542 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4544 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4545 (void *)&cmd_tx_vlan_set_pvid_set,
4546 (void *)&cmd_tx_vlan_set_pvid_pvid,
4547 (void *)&cmd_tx_vlan_set_pvid_port_id,
4548 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4549 (void *)&cmd_tx_vlan_set_pvid_mode,
4554 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4555 struct cmd_tx_vlan_reset_result {
4556 cmdline_fixed_string_t tx_vlan;
4557 cmdline_fixed_string_t reset;
4562 cmd_tx_vlan_reset_parsed(void *parsed_result,
4563 __rte_unused struct cmdline *cl,
4564 __rte_unused void *data)
4566 struct cmd_tx_vlan_reset_result *res = parsed_result;
4568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4571 if (!port_is_stopped(res->port_id)) {
4572 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4576 tx_vlan_reset(res->port_id);
4578 cmd_reconfig_device_queue(res->port_id, 1, 1);
4581 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4582 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4583 tx_vlan, "tx_vlan");
4584 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4585 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4587 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4588 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4589 port_id, RTE_UINT16);
4591 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4592 .f = cmd_tx_vlan_reset_parsed,
4594 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4595 "VLAN header in packets sent on a port",
4597 (void *)&cmd_tx_vlan_reset_tx_vlan,
4598 (void *)&cmd_tx_vlan_reset_reset,
4599 (void *)&cmd_tx_vlan_reset_portid,
4605 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4606 struct cmd_csum_result {
4607 cmdline_fixed_string_t csum;
4608 cmdline_fixed_string_t mode;
4609 cmdline_fixed_string_t proto;
4610 cmdline_fixed_string_t hwsw;
4615 csum_show(int port_id)
4617 struct rte_eth_dev_info dev_info;
4618 uint64_t tx_offloads;
4621 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4622 printf("Parse tunnel is %s\n",
4623 (ports[port_id].parse_tunnel) ? "on" : "off");
4624 printf("IP checksum offload is %s\n",
4625 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4626 printf("UDP checksum offload is %s\n",
4627 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4628 printf("TCP checksum offload is %s\n",
4629 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4630 printf("SCTP checksum offload is %s\n",
4631 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4632 printf("Outer-Ip checksum offload is %s\n",
4633 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4634 printf("Outer-Udp checksum offload is %s\n",
4635 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4637 /* display warnings if configuration is not supported by the NIC */
4638 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4642 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4643 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4645 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4648 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4649 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4651 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4654 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4655 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4657 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4660 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4661 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4663 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4666 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4667 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4669 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4672 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4673 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4676 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4682 cmd_config_queue_tx_offloads(struct rte_port *port)
4686 /* Apply queue tx offloads configuration */
4687 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4688 port->tx_conf[k].offloads =
4689 port->dev_conf.txmode.offloads;
4693 cmd_csum_parsed(void *parsed_result,
4694 __rte_unused struct cmdline *cl,
4695 __rte_unused void *data)
4697 struct cmd_csum_result *res = parsed_result;
4699 uint64_t csum_offloads = 0;
4700 struct rte_eth_dev_info dev_info;
4703 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4704 fprintf(stderr, "invalid port %d\n", res->port_id);
4707 if (!port_is_stopped(res->port_id)) {
4708 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4712 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4716 if (!strcmp(res->mode, "set")) {
4718 if (!strcmp(res->hwsw, "hw"))
4721 if (!strcmp(res->proto, "ip")) {
4722 if (hw == 0 || (dev_info.tx_offload_capa &
4723 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4724 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4727 "IP checksum offload is not supported by port %u\n",
4730 } else if (!strcmp(res->proto, "udp")) {
4731 if (hw == 0 || (dev_info.tx_offload_capa &
4732 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4733 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4736 "UDP checksum offload is not supported by port %u\n",
4739 } else if (!strcmp(res->proto, "tcp")) {
4740 if (hw == 0 || (dev_info.tx_offload_capa &
4741 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4742 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4745 "TCP checksum offload is not supported by port %u\n",
4748 } else if (!strcmp(res->proto, "sctp")) {
4749 if (hw == 0 || (dev_info.tx_offload_capa &
4750 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4751 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4754 "SCTP checksum offload is not supported by port %u\n",
4757 } else if (!strcmp(res->proto, "outer-ip")) {
4758 if (hw == 0 || (dev_info.tx_offload_capa &
4759 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4761 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4764 "Outer IP checksum offload is not supported by port %u\n",
4767 } else if (!strcmp(res->proto, "outer-udp")) {
4768 if (hw == 0 || (dev_info.tx_offload_capa &
4769 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4771 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4774 "Outer UDP checksum offload is not supported by port %u\n",
4780 ports[res->port_id].dev_conf.txmode.offloads |=
4783 ports[res->port_id].dev_conf.txmode.offloads &=
4786 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4788 csum_show(res->port_id);
4790 cmd_reconfig_device_queue(res->port_id, 1, 1);
4793 cmdline_parse_token_string_t cmd_csum_csum =
4794 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4796 cmdline_parse_token_string_t cmd_csum_mode =
4797 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4799 cmdline_parse_token_string_t cmd_csum_proto =
4800 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4801 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4802 cmdline_parse_token_string_t cmd_csum_hwsw =
4803 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4805 cmdline_parse_token_num_t cmd_csum_portid =
4806 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4807 port_id, RTE_UINT16);
4809 cmdline_parse_inst_t cmd_csum_set = {
4810 .f = cmd_csum_parsed,
4812 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4813 "Enable/Disable hardware calculation of L3/L4 checksum when "
4814 "using csum forward engine",
4816 (void *)&cmd_csum_csum,
4817 (void *)&cmd_csum_mode,
4818 (void *)&cmd_csum_proto,
4819 (void *)&cmd_csum_hwsw,
4820 (void *)&cmd_csum_portid,
4825 cmdline_parse_token_string_t cmd_csum_mode_show =
4826 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4829 cmdline_parse_inst_t cmd_csum_show = {
4830 .f = cmd_csum_parsed,
4832 .help_str = "csum show <port_id>: Show checksum offload configuration",
4834 (void *)&cmd_csum_csum,
4835 (void *)&cmd_csum_mode_show,
4836 (void *)&cmd_csum_portid,
4841 /* Enable/disable tunnel parsing */
4842 struct cmd_csum_tunnel_result {
4843 cmdline_fixed_string_t csum;
4844 cmdline_fixed_string_t parse;
4845 cmdline_fixed_string_t onoff;
4850 cmd_csum_tunnel_parsed(void *parsed_result,
4851 __rte_unused struct cmdline *cl,
4852 __rte_unused void *data)
4854 struct cmd_csum_tunnel_result *res = parsed_result;
4856 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4859 if (!strcmp(res->onoff, "on"))
4860 ports[res->port_id].parse_tunnel = 1;
4862 ports[res->port_id].parse_tunnel = 0;
4864 csum_show(res->port_id);
4867 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4868 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4870 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4871 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4872 parse, "parse-tunnel");
4873 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4874 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4876 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4877 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4878 port_id, RTE_UINT16);
4880 cmdline_parse_inst_t cmd_csum_tunnel = {
4881 .f = cmd_csum_tunnel_parsed,
4883 .help_str = "csum parse-tunnel on|off <port_id>: "
4884 "Enable/Disable parsing of tunnels for csum engine",
4886 (void *)&cmd_csum_tunnel_csum,
4887 (void *)&cmd_csum_tunnel_parse,
4888 (void *)&cmd_csum_tunnel_onoff,
4889 (void *)&cmd_csum_tunnel_portid,
4894 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4895 struct cmd_tso_set_result {
4896 cmdline_fixed_string_t tso;
4897 cmdline_fixed_string_t mode;
4903 cmd_tso_set_parsed(void *parsed_result,
4904 __rte_unused struct cmdline *cl,
4905 __rte_unused void *data)
4907 struct cmd_tso_set_result *res = parsed_result;
4908 struct rte_eth_dev_info dev_info;
4911 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4913 if (!port_is_stopped(res->port_id)) {
4914 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4918 if (!strcmp(res->mode, "set"))
4919 ports[res->port_id].tso_segsz = res->tso_segsz;
4921 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4925 if ((ports[res->port_id].tso_segsz != 0) &&
4926 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4927 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4932 if (ports[res->port_id].tso_segsz == 0) {
4933 ports[res->port_id].dev_conf.txmode.offloads &=
4934 ~DEV_TX_OFFLOAD_TCP_TSO;
4935 printf("TSO for non-tunneled packets is disabled\n");
4937 ports[res->port_id].dev_conf.txmode.offloads |=
4938 DEV_TX_OFFLOAD_TCP_TSO;
4939 printf("TSO segment size for non-tunneled packets is %d\n",
4940 ports[res->port_id].tso_segsz);
4942 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4944 /* display warnings if configuration is not supported by the NIC */
4945 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4949 if ((ports[res->port_id].tso_segsz != 0) &&
4950 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4952 "Warning: TSO enabled but not supported by port %d\n",
4956 cmd_reconfig_device_queue(res->port_id, 1, 1);
4959 cmdline_parse_token_string_t cmd_tso_set_tso =
4960 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4962 cmdline_parse_token_string_t cmd_tso_set_mode =
4963 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4965 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4966 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4967 tso_segsz, RTE_UINT16);
4968 cmdline_parse_token_num_t cmd_tso_set_portid =
4969 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4970 port_id, RTE_UINT16);
4972 cmdline_parse_inst_t cmd_tso_set = {
4973 .f = cmd_tso_set_parsed,
4975 .help_str = "tso set <tso_segsz> <port_id>: "
4976 "Set TSO segment size of non-tunneled packets for csum engine "
4979 (void *)&cmd_tso_set_tso,
4980 (void *)&cmd_tso_set_mode,
4981 (void *)&cmd_tso_set_tso_segsz,
4982 (void *)&cmd_tso_set_portid,
4987 cmdline_parse_token_string_t cmd_tso_show_mode =
4988 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4992 cmdline_parse_inst_t cmd_tso_show = {
4993 .f = cmd_tso_set_parsed,
4995 .help_str = "tso show <port_id>: "
4996 "Show TSO segment size of non-tunneled packets for csum engine",
4998 (void *)&cmd_tso_set_tso,
4999 (void *)&cmd_tso_show_mode,
5000 (void *)&cmd_tso_set_portid,
5005 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5006 struct cmd_tunnel_tso_set_result {
5007 cmdline_fixed_string_t tso;
5008 cmdline_fixed_string_t mode;
5013 static struct rte_eth_dev_info
5014 check_tunnel_tso_nic_support(portid_t port_id)
5016 struct rte_eth_dev_info dev_info;
5018 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5021 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5023 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5025 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5027 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5029 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5031 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5033 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5035 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5037 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5039 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5041 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5043 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5049 cmd_tunnel_tso_set_parsed(void *parsed_result,
5050 __rte_unused struct cmdline *cl,
5051 __rte_unused void *data)
5053 struct cmd_tunnel_tso_set_result *res = parsed_result;
5054 struct rte_eth_dev_info dev_info;
5056 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5058 if (!port_is_stopped(res->port_id)) {
5059 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5063 if (!strcmp(res->mode, "set"))
5064 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5066 dev_info = check_tunnel_tso_nic_support(res->port_id);
5067 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5068 ports[res->port_id].dev_conf.txmode.offloads &=
5069 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5070 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5071 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5072 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5073 DEV_TX_OFFLOAD_IP_TNL_TSO |
5074 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5075 printf("TSO for tunneled packets is disabled\n");
5077 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5078 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5079 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5080 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5081 DEV_TX_OFFLOAD_IP_TNL_TSO |
5082 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5084 ports[res->port_id].dev_conf.txmode.offloads |=
5085 (tso_offloads & dev_info.tx_offload_capa);
5086 printf("TSO segment size for tunneled packets is %d\n",
5087 ports[res->port_id].tunnel_tso_segsz);
5089 /* Below conditions are needed to make it work:
5090 * (1) tunnel TSO is supported by the NIC;
5091 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5093 * (3) for tunneled pkts with outer L3 of IPv4,
5094 * "csum set outer-ip" must be set to hw, because after tso,
5095 * total_len of outer IP header is changed, and the checksum
5096 * of outer IP header calculated by sw should be wrong; that
5097 * is not necessary for IPv6 tunneled pkts because there's no
5098 * checksum in IP header anymore.
5101 if (!ports[res->port_id].parse_tunnel)
5103 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5104 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5105 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5107 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5110 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5111 cmd_reconfig_device_queue(res->port_id, 1, 1);
5114 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5115 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5117 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5118 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5120 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5121 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5122 tso_segsz, RTE_UINT16);
5123 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5124 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5125 port_id, RTE_UINT16);
5127 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5128 .f = cmd_tunnel_tso_set_parsed,
5130 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5131 "Set TSO segment size of tunneled packets for csum engine "
5134 (void *)&cmd_tunnel_tso_set_tso,
5135 (void *)&cmd_tunnel_tso_set_mode,
5136 (void *)&cmd_tunnel_tso_set_tso_segsz,
5137 (void *)&cmd_tunnel_tso_set_portid,
5142 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5143 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5147 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5148 .f = cmd_tunnel_tso_set_parsed,
5150 .help_str = "tunnel_tso show <port_id> "
5151 "Show TSO segment size of tunneled packets for csum engine",
5153 (void *)&cmd_tunnel_tso_set_tso,
5154 (void *)&cmd_tunnel_tso_show_mode,
5155 (void *)&cmd_tunnel_tso_set_portid,
5160 /* *** SET GRO FOR A PORT *** */
5161 struct cmd_gro_enable_result {
5162 cmdline_fixed_string_t cmd_set;
5163 cmdline_fixed_string_t cmd_port;
5164 cmdline_fixed_string_t cmd_keyword;
5165 cmdline_fixed_string_t cmd_onoff;
5170 cmd_gro_enable_parsed(void *parsed_result,
5171 __rte_unused struct cmdline *cl,
5172 __rte_unused void *data)
5174 struct cmd_gro_enable_result *res;
5176 res = parsed_result;
5177 if (!strcmp(res->cmd_keyword, "gro"))
5178 setup_gro(res->cmd_onoff, res->cmd_pid);
5181 cmdline_parse_token_string_t cmd_gro_enable_set =
5182 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5184 cmdline_parse_token_string_t cmd_gro_enable_port =
5185 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5186 cmd_keyword, "port");
5187 cmdline_parse_token_num_t cmd_gro_enable_pid =
5188 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5189 cmd_pid, RTE_UINT16);
5190 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5191 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5192 cmd_keyword, "gro");
5193 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5194 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5195 cmd_onoff, "on#off");
5197 cmdline_parse_inst_t cmd_gro_enable = {
5198 .f = cmd_gro_enable_parsed,
5200 .help_str = "set port <port_id> gro on|off",
5202 (void *)&cmd_gro_enable_set,
5203 (void *)&cmd_gro_enable_port,
5204 (void *)&cmd_gro_enable_pid,
5205 (void *)&cmd_gro_enable_keyword,
5206 (void *)&cmd_gro_enable_onoff,
5211 /* *** DISPLAY GRO CONFIGURATION *** */
5212 struct cmd_gro_show_result {
5213 cmdline_fixed_string_t cmd_show;
5214 cmdline_fixed_string_t cmd_port;
5215 cmdline_fixed_string_t cmd_keyword;
5220 cmd_gro_show_parsed(void *parsed_result,
5221 __rte_unused struct cmdline *cl,
5222 __rte_unused void *data)
5224 struct cmd_gro_show_result *res;
5226 res = parsed_result;
5227 if (!strcmp(res->cmd_keyword, "gro"))
5228 show_gro(res->cmd_pid);
5231 cmdline_parse_token_string_t cmd_gro_show_show =
5232 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5234 cmdline_parse_token_string_t cmd_gro_show_port =
5235 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5237 cmdline_parse_token_num_t cmd_gro_show_pid =
5238 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5239 cmd_pid, RTE_UINT16);
5240 cmdline_parse_token_string_t cmd_gro_show_keyword =
5241 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5242 cmd_keyword, "gro");
5244 cmdline_parse_inst_t cmd_gro_show = {
5245 .f = cmd_gro_show_parsed,
5247 .help_str = "show port <port_id> gro",
5249 (void *)&cmd_gro_show_show,
5250 (void *)&cmd_gro_show_port,
5251 (void *)&cmd_gro_show_pid,
5252 (void *)&cmd_gro_show_keyword,
5257 /* *** SET FLUSH CYCLES FOR GRO *** */
5258 struct cmd_gro_flush_result {
5259 cmdline_fixed_string_t cmd_set;
5260 cmdline_fixed_string_t cmd_keyword;
5261 cmdline_fixed_string_t cmd_flush;
5266 cmd_gro_flush_parsed(void *parsed_result,
5267 __rte_unused struct cmdline *cl,
5268 __rte_unused void *data)
5270 struct cmd_gro_flush_result *res;
5272 res = parsed_result;
5273 if ((!strcmp(res->cmd_keyword, "gro")) &&
5274 (!strcmp(res->cmd_flush, "flush")))
5275 setup_gro_flush_cycles(res->cmd_cycles);
5278 cmdline_parse_token_string_t cmd_gro_flush_set =
5279 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5281 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5282 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5283 cmd_keyword, "gro");
5284 cmdline_parse_token_string_t cmd_gro_flush_flush =
5285 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5286 cmd_flush, "flush");
5287 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5288 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5289 cmd_cycles, RTE_UINT8);
5291 cmdline_parse_inst_t cmd_gro_flush = {
5292 .f = cmd_gro_flush_parsed,
5294 .help_str = "set gro flush <cycles>",
5296 (void *)&cmd_gro_flush_set,
5297 (void *)&cmd_gro_flush_keyword,
5298 (void *)&cmd_gro_flush_flush,
5299 (void *)&cmd_gro_flush_cycles,
5304 /* *** ENABLE/DISABLE GSO *** */
5305 struct cmd_gso_enable_result {
5306 cmdline_fixed_string_t cmd_set;
5307 cmdline_fixed_string_t cmd_port;
5308 cmdline_fixed_string_t cmd_keyword;
5309 cmdline_fixed_string_t cmd_mode;
5314 cmd_gso_enable_parsed(void *parsed_result,
5315 __rte_unused struct cmdline *cl,
5316 __rte_unused void *data)
5318 struct cmd_gso_enable_result *res;
5320 res = parsed_result;
5321 if (!strcmp(res->cmd_keyword, "gso"))
5322 setup_gso(res->cmd_mode, res->cmd_pid);
5325 cmdline_parse_token_string_t cmd_gso_enable_set =
5326 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5328 cmdline_parse_token_string_t cmd_gso_enable_port =
5329 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5331 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5332 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5333 cmd_keyword, "gso");
5334 cmdline_parse_token_string_t cmd_gso_enable_mode =
5335 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5336 cmd_mode, "on#off");
5337 cmdline_parse_token_num_t cmd_gso_enable_pid =
5338 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5339 cmd_pid, RTE_UINT16);
5341 cmdline_parse_inst_t cmd_gso_enable = {
5342 .f = cmd_gso_enable_parsed,
5344 .help_str = "set port <port_id> gso on|off",
5346 (void *)&cmd_gso_enable_set,
5347 (void *)&cmd_gso_enable_port,
5348 (void *)&cmd_gso_enable_pid,
5349 (void *)&cmd_gso_enable_keyword,
5350 (void *)&cmd_gso_enable_mode,
5355 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5356 struct cmd_gso_size_result {
5357 cmdline_fixed_string_t cmd_set;
5358 cmdline_fixed_string_t cmd_keyword;
5359 cmdline_fixed_string_t cmd_segsz;
5364 cmd_gso_size_parsed(void *parsed_result,
5365 __rte_unused struct cmdline *cl,
5366 __rte_unused void *data)
5368 struct cmd_gso_size_result *res = parsed_result;
5370 if (test_done == 0) {
5372 "Before setting GSO segsz, please first stop forwarding\n");
5376 if (!strcmp(res->cmd_keyword, "gso") &&
5377 !strcmp(res->cmd_segsz, "segsz")) {
5378 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5380 "gso_size should be larger than %zu. Please input a legal value\n",
5381 RTE_GSO_SEG_SIZE_MIN);
5383 gso_max_segment_size = res->cmd_size;
5387 cmdline_parse_token_string_t cmd_gso_size_set =
5388 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5390 cmdline_parse_token_string_t cmd_gso_size_keyword =
5391 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5392 cmd_keyword, "gso");
5393 cmdline_parse_token_string_t cmd_gso_size_segsz =
5394 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5395 cmd_segsz, "segsz");
5396 cmdline_parse_token_num_t cmd_gso_size_size =
5397 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5398 cmd_size, RTE_UINT16);
5400 cmdline_parse_inst_t cmd_gso_size = {
5401 .f = cmd_gso_size_parsed,
5403 .help_str = "set gso segsz <length>",
5405 (void *)&cmd_gso_size_set,
5406 (void *)&cmd_gso_size_keyword,
5407 (void *)&cmd_gso_size_segsz,
5408 (void *)&cmd_gso_size_size,
5413 /* *** SHOW GSO CONFIGURATION *** */
5414 struct cmd_gso_show_result {
5415 cmdline_fixed_string_t cmd_show;
5416 cmdline_fixed_string_t cmd_port;
5417 cmdline_fixed_string_t cmd_keyword;
5422 cmd_gso_show_parsed(void *parsed_result,
5423 __rte_unused struct cmdline *cl,
5424 __rte_unused void *data)
5426 struct cmd_gso_show_result *res = parsed_result;
5428 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5429 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5432 if (!strcmp(res->cmd_keyword, "gso")) {
5433 if (gso_ports[res->cmd_pid].enable) {
5434 printf("Max GSO'd packet size: %uB\n"
5435 "Supported GSO types: TCP/IPv4, "
5436 "UDP/IPv4, VxLAN with inner "
5437 "TCP/IPv4 packet, GRE with inner "
5438 "TCP/IPv4 packet\n",
5439 gso_max_segment_size);
5441 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5445 cmdline_parse_token_string_t cmd_gso_show_show =
5446 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5448 cmdline_parse_token_string_t cmd_gso_show_port =
5449 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5451 cmdline_parse_token_string_t cmd_gso_show_keyword =
5452 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5453 cmd_keyword, "gso");
5454 cmdline_parse_token_num_t cmd_gso_show_pid =
5455 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5456 cmd_pid, RTE_UINT16);
5458 cmdline_parse_inst_t cmd_gso_show = {
5459 .f = cmd_gso_show_parsed,
5461 .help_str = "show port <port_id> gso",
5463 (void *)&cmd_gso_show_show,
5464 (void *)&cmd_gso_show_port,
5465 (void *)&cmd_gso_show_pid,
5466 (void *)&cmd_gso_show_keyword,
5471 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5472 struct cmd_set_flush_rx {
5473 cmdline_fixed_string_t set;
5474 cmdline_fixed_string_t flush_rx;
5475 cmdline_fixed_string_t mode;
5479 cmd_set_flush_rx_parsed(void *parsed_result,
5480 __rte_unused struct cmdline *cl,
5481 __rte_unused void *data)
5483 struct cmd_set_flush_rx *res = parsed_result;
5485 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5486 printf("multi-process doesn't support to flush Rx queues.\n");
5490 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5493 cmdline_parse_token_string_t cmd_setflushrx_set =
5494 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5496 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5497 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5498 flush_rx, "flush_rx");
5499 cmdline_parse_token_string_t cmd_setflushrx_mode =
5500 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5504 cmdline_parse_inst_t cmd_set_flush_rx = {
5505 .f = cmd_set_flush_rx_parsed,
5506 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5509 (void *)&cmd_setflushrx_set,
5510 (void *)&cmd_setflushrx_flush_rx,
5511 (void *)&cmd_setflushrx_mode,
5516 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5517 struct cmd_set_link_check {
5518 cmdline_fixed_string_t set;
5519 cmdline_fixed_string_t link_check;
5520 cmdline_fixed_string_t mode;
5524 cmd_set_link_check_parsed(void *parsed_result,
5525 __rte_unused struct cmdline *cl,
5526 __rte_unused void *data)
5528 struct cmd_set_link_check *res = parsed_result;
5529 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5532 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5533 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5535 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5536 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5537 link_check, "link_check");
5538 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5539 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5543 cmdline_parse_inst_t cmd_set_link_check = {
5544 .f = cmd_set_link_check_parsed,
5545 .help_str = "set link_check on|off: Enable/Disable link status check "
5546 "when starting/stopping a port",
5549 (void *)&cmd_setlinkcheck_set,
5550 (void *)&cmd_setlinkcheck_link_check,
5551 (void *)&cmd_setlinkcheck_mode,
5556 /* *** SET NIC BYPASS MODE *** */
5557 struct cmd_set_bypass_mode_result {
5558 cmdline_fixed_string_t set;
5559 cmdline_fixed_string_t bypass;
5560 cmdline_fixed_string_t mode;
5561 cmdline_fixed_string_t value;
5566 cmd_set_bypass_mode_parsed(void *parsed_result,
5567 __rte_unused struct cmdline *cl,
5568 __rte_unused void *data)
5570 struct cmd_set_bypass_mode_result *res = parsed_result;
5571 portid_t port_id = res->port_id;
5572 int32_t rc = -EINVAL;
5574 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5575 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5577 if (!strcmp(res->value, "bypass"))
5578 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5579 else if (!strcmp(res->value, "isolate"))
5580 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5582 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5584 /* Set the bypass mode for the relevant port. */
5585 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5588 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5592 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5593 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5595 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5596 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5598 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5599 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5601 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5602 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5603 value, "normal#bypass#isolate");
5604 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5605 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5606 port_id, RTE_UINT16);
5608 cmdline_parse_inst_t cmd_set_bypass_mode = {
5609 .f = cmd_set_bypass_mode_parsed,
5610 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5611 "Set the NIC bypass mode for port_id",
5614 (void *)&cmd_setbypass_mode_set,
5615 (void *)&cmd_setbypass_mode_bypass,
5616 (void *)&cmd_setbypass_mode_mode,
5617 (void *)&cmd_setbypass_mode_value,
5618 (void *)&cmd_setbypass_mode_port,
5623 /* *** SET NIC BYPASS EVENT *** */
5624 struct cmd_set_bypass_event_result {
5625 cmdline_fixed_string_t set;
5626 cmdline_fixed_string_t bypass;
5627 cmdline_fixed_string_t event;
5628 cmdline_fixed_string_t event_value;
5629 cmdline_fixed_string_t mode;
5630 cmdline_fixed_string_t mode_value;
5635 cmd_set_bypass_event_parsed(void *parsed_result,
5636 __rte_unused struct cmdline *cl,
5637 __rte_unused void *data)
5639 int32_t rc = -EINVAL;
5640 struct cmd_set_bypass_event_result *res = parsed_result;
5641 portid_t port_id = res->port_id;
5643 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5644 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5645 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5647 if (!strcmp(res->event_value, "timeout"))
5648 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5649 else if (!strcmp(res->event_value, "os_on"))
5650 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5651 else if (!strcmp(res->event_value, "os_off"))
5652 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5653 else if (!strcmp(res->event_value, "power_on"))
5654 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5655 else if (!strcmp(res->event_value, "power_off"))
5656 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5658 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5660 if (!strcmp(res->mode_value, "bypass"))
5661 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5662 else if (!strcmp(res->mode_value, "isolate"))
5663 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5665 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5667 /* Set the watchdog timeout. */
5668 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5671 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5672 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5677 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5678 bypass_timeout, port_id, rc);
5682 /* Set the bypass event to transition to bypass mode. */
5683 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5688 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5692 cmdline_parse_token_string_t cmd_setbypass_event_set =
5693 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5695 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5696 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5698 cmdline_parse_token_string_t cmd_setbypass_event_event =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5701 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5703 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5704 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5705 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5707 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5708 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5709 mode_value, "normal#bypass#isolate");
5710 cmdline_parse_token_num_t cmd_setbypass_event_port =
5711 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5712 port_id, RTE_UINT16);
5714 cmdline_parse_inst_t cmd_set_bypass_event = {
5715 .f = cmd_set_bypass_event_parsed,
5716 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5717 "power_off mode normal|bypass|isolate <port_id>: "
5718 "Set the NIC bypass event mode for port_id",
5721 (void *)&cmd_setbypass_event_set,
5722 (void *)&cmd_setbypass_event_bypass,
5723 (void *)&cmd_setbypass_event_event,
5724 (void *)&cmd_setbypass_event_event_value,
5725 (void *)&cmd_setbypass_event_mode,
5726 (void *)&cmd_setbypass_event_mode_value,
5727 (void *)&cmd_setbypass_event_port,
5733 /* *** SET NIC BYPASS TIMEOUT *** */
5734 struct cmd_set_bypass_timeout_result {
5735 cmdline_fixed_string_t set;
5736 cmdline_fixed_string_t bypass;
5737 cmdline_fixed_string_t timeout;
5738 cmdline_fixed_string_t value;
5742 cmd_set_bypass_timeout_parsed(void *parsed_result,
5743 __rte_unused struct cmdline *cl,
5744 __rte_unused void *data)
5746 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5748 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5749 if (!strcmp(res->value, "1.5"))
5750 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5751 else if (!strcmp(res->value, "2"))
5752 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5753 else if (!strcmp(res->value, "3"))
5754 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5755 else if (!strcmp(res->value, "4"))
5756 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5757 else if (!strcmp(res->value, "8"))
5758 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5759 else if (!strcmp(res->value, "16"))
5760 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5761 else if (!strcmp(res->value, "32"))
5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5768 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5769 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5771 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5772 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5774 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5775 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5776 timeout, "timeout");
5777 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5778 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5779 value, "0#1.5#2#3#4#8#16#32");
5781 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5782 .f = cmd_set_bypass_timeout_parsed,
5783 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5784 "Set the NIC bypass watchdog timeout in seconds",
5787 (void *)&cmd_setbypass_timeout_set,
5788 (void *)&cmd_setbypass_timeout_bypass,
5789 (void *)&cmd_setbypass_timeout_timeout,
5790 (void *)&cmd_setbypass_timeout_value,
5795 /* *** SHOW NIC BYPASS MODE *** */
5796 struct cmd_show_bypass_config_result {
5797 cmdline_fixed_string_t show;
5798 cmdline_fixed_string_t bypass;
5799 cmdline_fixed_string_t config;
5804 cmd_show_bypass_config_parsed(void *parsed_result,
5805 __rte_unused struct cmdline *cl,
5806 __rte_unused void *data)
5808 struct cmd_show_bypass_config_result *res = parsed_result;
5809 portid_t port_id = res->port_id;
5811 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5812 uint32_t event_mode;
5813 uint32_t bypass_mode;
5814 uint32_t timeout = bypass_timeout;
5817 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5818 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5819 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5820 {"UNKNOWN", "normal", "bypass", "isolate"};
5821 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5829 /* Display the bypass mode.*/
5830 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5831 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5836 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5837 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5839 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5842 /* Display the bypass timeout.*/
5843 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5844 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5846 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5848 /* Display the bypass events and associated modes. */
5849 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5851 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5853 "\tFailed to get bypass mode for event = %s\n",
5856 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5857 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5859 printf("\tbypass event: %-16s = %s\n", events[i],
5866 "\tFailed to get bypass configuration for port = %d\n",
5870 cmdline_parse_token_string_t cmd_showbypass_config_show =
5871 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5873 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5874 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5876 cmdline_parse_token_string_t cmd_showbypass_config_config =
5877 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5879 cmdline_parse_token_num_t cmd_showbypass_config_port =
5880 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5881 port_id, RTE_UINT16);
5883 cmdline_parse_inst_t cmd_show_bypass_config = {
5884 .f = cmd_show_bypass_config_parsed,
5885 .help_str = "show bypass config <port_id>: "
5886 "Show the NIC bypass config for port_id",
5889 (void *)&cmd_showbypass_config_show,
5890 (void *)&cmd_showbypass_config_bypass,
5891 (void *)&cmd_showbypass_config_config,
5892 (void *)&cmd_showbypass_config_port,
5898 /* *** SET BONDING MODE *** */
5899 struct cmd_set_bonding_mode_result {
5900 cmdline_fixed_string_t set;
5901 cmdline_fixed_string_t bonding;
5902 cmdline_fixed_string_t mode;
5907 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5908 __rte_unused struct cmdline *cl,
5909 __rte_unused void *data)
5911 struct cmd_set_bonding_mode_result *res = parsed_result;
5912 portid_t port_id = res->port_id;
5914 /* Set the bonding mode for the relevant port. */
5915 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5916 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5920 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5923 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5925 bonding, "bonding");
5926 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5929 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5930 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5932 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5933 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5934 port_id, RTE_UINT16);
5936 cmdline_parse_inst_t cmd_set_bonding_mode = {
5937 .f = cmd_set_bonding_mode_parsed,
5938 .help_str = "set bonding mode <mode_value> <port_id>: "
5939 "Set the bonding mode for port_id",
5942 (void *) &cmd_setbonding_mode_set,
5943 (void *) &cmd_setbonding_mode_bonding,
5944 (void *) &cmd_setbonding_mode_mode,
5945 (void *) &cmd_setbonding_mode_value,
5946 (void *) &cmd_setbonding_mode_port,
5951 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5952 struct cmd_set_bonding_lacp_dedicated_queues_result {
5953 cmdline_fixed_string_t set;
5954 cmdline_fixed_string_t bonding;
5955 cmdline_fixed_string_t lacp;
5956 cmdline_fixed_string_t dedicated_queues;
5958 cmdline_fixed_string_t mode;
5961 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5962 __rte_unused struct cmdline *cl,
5963 __rte_unused void *data)
5965 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5966 portid_t port_id = res->port_id;
5967 struct rte_port *port;
5969 port = &ports[port_id];
5971 /** Check if the port is not started **/
5972 if (port->port_status != RTE_PORT_STOPPED) {
5973 fprintf(stderr, "Please stop port %d first\n", port_id);
5977 if (!strcmp(res->mode, "enable")) {
5978 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5979 printf("Dedicate queues for LACP control packets"
5982 printf("Enabling dedicate queues for LACP control "
5983 "packets on port %d failed\n", port_id);
5984 } else if (!strcmp(res->mode, "disable")) {
5985 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5986 printf("Dedicated queues for LACP control packets "
5989 printf("Disabling dedicated queues for LACP control "
5990 "traffic on port %d failed\n", port_id);
5994 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5995 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5997 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5998 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5999 bonding, "bonding");
6000 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6001 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6003 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6004 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6005 dedicated_queues, "dedicated_queues");
6006 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6007 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6008 port_id, RTE_UINT16);
6009 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6010 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6011 mode, "enable#disable");
6013 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6014 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6015 .help_str = "set bonding lacp dedicated_queues <port_id> "
6017 "Enable/disable dedicated queues for LACP control traffic for port_id",
6020 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6021 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6022 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6023 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6024 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6025 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6030 /* *** SET BALANCE XMIT POLICY *** */
6031 struct cmd_set_bonding_balance_xmit_policy_result {
6032 cmdline_fixed_string_t set;
6033 cmdline_fixed_string_t bonding;
6034 cmdline_fixed_string_t balance_xmit_policy;
6036 cmdline_fixed_string_t policy;
6039 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6040 __rte_unused struct cmdline *cl,
6041 __rte_unused void *data)
6043 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6044 portid_t port_id = res->port_id;
6047 if (!strcmp(res->policy, "l2")) {
6048 policy = BALANCE_XMIT_POLICY_LAYER2;
6049 } else if (!strcmp(res->policy, "l23")) {
6050 policy = BALANCE_XMIT_POLICY_LAYER23;
6051 } else if (!strcmp(res->policy, "l34")) {
6052 policy = BALANCE_XMIT_POLICY_LAYER34;
6054 fprintf(stderr, "\t Invalid xmit policy selection");
6058 /* Set the bonding mode for the relevant port. */
6059 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6061 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6066 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6067 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6069 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6070 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6071 bonding, "bonding");
6072 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6073 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6074 balance_xmit_policy, "balance_xmit_policy");
6075 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6076 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6077 port_id, RTE_UINT16);
6078 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6079 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6080 policy, "l2#l23#l34");
6082 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6083 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6084 .help_str = "set bonding balance_xmit_policy <port_id> "
6086 "Set the bonding balance_xmit_policy for port_id",
6089 (void *)&cmd_setbonding_balance_xmit_policy_set,
6090 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6091 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6092 (void *)&cmd_setbonding_balance_xmit_policy_port,
6093 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6098 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6099 struct cmd_show_bonding_lacp_info_result {
6100 cmdline_fixed_string_t show;
6101 cmdline_fixed_string_t bonding;
6102 cmdline_fixed_string_t lacp;
6103 cmdline_fixed_string_t info;
6107 static void port_param_show(struct port_params *params)
6109 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6111 printf("\t\tsystem priority: %u\n", params->system_priority);
6112 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6113 printf("\t\tsystem mac address: %s\n", buf);
6114 printf("\t\tport key: %u\n", params->key);
6115 printf("\t\tport priority: %u\n", params->port_priority);
6116 printf("\t\tport number: %u\n", params->port_number);
6119 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6121 char a_state[256] = { 0 };
6122 char p_state[256] = { 0 };
6127 static const char * const state[] = {
6137 static const char * const selection[] = {
6143 for (i = 0; i < RTE_DIM(state); i++) {
6144 if ((info->actor_state >> i) & 1)
6145 a_len += snprintf(&a_state[a_len],
6146 RTE_DIM(a_state) - a_len, "%s ",
6149 if ((info->partner_state >> i) & 1)
6150 p_len += snprintf(&p_state[p_len],
6151 RTE_DIM(p_state) - p_len, "%s ",
6154 printf("\tAggregator port id: %u\n", info->agg_port_id);
6155 printf("\tselection: %s\n", selection[info->selected]);
6156 printf("\tActor detail info:\n");
6157 port_param_show(&info->actor);
6158 printf("\t\tport state: %s\n", a_state);
6159 printf("\tPartner detail info:\n");
6160 port_param_show(&info->partner);
6161 printf("\t\tport state: %s\n", p_state);
6165 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6167 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6168 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6169 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6170 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6171 printf("\taggregate wait timeout: %u ms\n",
6172 conf->aggregate_wait_timeout_ms);
6173 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6174 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6175 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6176 switch (conf->agg_selection) {
6178 printf("\taggregation mode: bandwidth\n");
6181 printf("\taggregation mode: stable\n");
6184 printf("\taggregation mode: count\n");
6187 printf("\taggregation mode: invalid\n");
6194 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6195 __rte_unused struct cmdline *cl,
6196 __rte_unused void *data)
6198 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6199 struct rte_eth_bond_8023ad_slave_info slave_info;
6200 struct rte_eth_bond_8023ad_conf port_conf;
6201 portid_t slaves[RTE_MAX_ETHPORTS];
6202 portid_t port_id = res->port_id;
6203 int num_active_slaves;
6208 bonding_mode = rte_eth_bond_mode_get(port_id);
6209 if (bonding_mode != BONDING_MODE_8023AD) {
6210 fprintf(stderr, "\tBonding mode is not mode 4\n");
6214 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6216 if (num_active_slaves < 0) {
6217 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6221 if (num_active_slaves == 0)
6222 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6225 printf("\tIEEE802.3 port: %u\n", port_id);
6226 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6228 fprintf(stderr, "\tGet bonded device %u info failed\n",
6232 lacp_conf_show(&port_conf);
6234 for (i = 0; i < num_active_slaves; i++) {
6235 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6238 fprintf(stderr, "\tGet slave device %u info failed\n",
6242 printf("\tSlave Port: %u\n", slaves[i]);
6243 lacp_slave_info_show(&slave_info);
6247 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6248 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6250 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6251 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6252 bonding, "bonding");
6253 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6254 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6256 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6257 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6259 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6260 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6261 port_id, RTE_UINT16);
6263 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6264 .f = cmd_show_bonding_lacp_info_parsed,
6265 .help_str = "show bonding lacp info <port_id> : "
6266 "Show bonding IEEE802.3 information for port_id",
6269 (void *)&cmd_show_bonding_lacp_info_show,
6270 (void *)&cmd_show_bonding_lacp_info_bonding,
6271 (void *)&cmd_show_bonding_lacp_info_lacp,
6272 (void *)&cmd_show_bonding_lacp_info_info,
6273 (void *)&cmd_show_bonding_lacp_info_port_id,
6278 /* *** SHOW NIC BONDING CONFIGURATION *** */
6279 struct cmd_show_bonding_config_result {
6280 cmdline_fixed_string_t show;
6281 cmdline_fixed_string_t bonding;
6282 cmdline_fixed_string_t config;
6286 static void cmd_show_bonding_config_parsed(void *parsed_result,
6287 __rte_unused struct cmdline *cl,
6288 __rte_unused void *data)
6290 struct cmd_show_bonding_config_result *res = parsed_result;
6291 int bonding_mode, agg_mode;
6292 portid_t slaves[RTE_MAX_ETHPORTS];
6293 int num_slaves, num_active_slaves;
6296 portid_t port_id = res->port_id;
6298 /* Display the bonding mode.*/
6299 bonding_mode = rte_eth_bond_mode_get(port_id);
6300 if (bonding_mode < 0) {
6301 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6305 printf("\tBonding mode: %d\n", bonding_mode);
6307 if (bonding_mode == BONDING_MODE_BALANCE) {
6308 int balance_xmit_policy;
6310 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6311 if (balance_xmit_policy < 0) {
6313 "\tFailed to get balance xmit policy for port = %d\n",
6317 printf("\tBalance Xmit Policy: ");
6319 switch (balance_xmit_policy) {
6320 case BALANCE_XMIT_POLICY_LAYER2:
6321 printf("BALANCE_XMIT_POLICY_LAYER2");
6323 case BALANCE_XMIT_POLICY_LAYER23:
6324 printf("BALANCE_XMIT_POLICY_LAYER23");
6326 case BALANCE_XMIT_POLICY_LAYER34:
6327 printf("BALANCE_XMIT_POLICY_LAYER34");
6334 if (bonding_mode == BONDING_MODE_8023AD) {
6335 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6336 printf("\tIEEE802.3AD Aggregator Mode: ");
6339 printf("bandwidth");
6351 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6353 if (num_slaves < 0) {
6354 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6358 if (num_slaves > 0) {
6359 printf("\tSlaves (%d): [", num_slaves);
6360 for (i = 0; i < num_slaves - 1; i++)
6361 printf("%d ", slaves[i]);
6363 printf("%d]\n", slaves[num_slaves - 1]);
6365 printf("\tSlaves: []\n");
6369 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6372 if (num_active_slaves < 0) {
6374 "\tFailed to get active slave list for port = %d\n",
6378 if (num_active_slaves > 0) {
6379 printf("\tActive Slaves (%d): [", num_active_slaves);
6380 for (i = 0; i < num_active_slaves - 1; i++)
6381 printf("%d ", slaves[i]);
6383 printf("%d]\n", slaves[num_active_slaves - 1]);
6386 printf("\tActive Slaves: []\n");
6390 primary_id = rte_eth_bond_primary_get(port_id);
6391 if (primary_id < 0) {
6392 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6396 printf("\tPrimary: [%d]\n", primary_id);
6400 cmdline_parse_token_string_t cmd_showbonding_config_show =
6401 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6403 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6404 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6405 bonding, "bonding");
6406 cmdline_parse_token_string_t cmd_showbonding_config_config =
6407 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6409 cmdline_parse_token_num_t cmd_showbonding_config_port =
6410 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6411 port_id, RTE_UINT16);
6413 cmdline_parse_inst_t cmd_show_bonding_config = {
6414 .f = cmd_show_bonding_config_parsed,
6415 .help_str = "show bonding config <port_id>: "
6416 "Show the bonding config for port_id",
6419 (void *)&cmd_showbonding_config_show,
6420 (void *)&cmd_showbonding_config_bonding,
6421 (void *)&cmd_showbonding_config_config,
6422 (void *)&cmd_showbonding_config_port,
6427 /* *** SET BONDING PRIMARY *** */
6428 struct cmd_set_bonding_primary_result {
6429 cmdline_fixed_string_t set;
6430 cmdline_fixed_string_t bonding;
6431 cmdline_fixed_string_t primary;
6436 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6437 __rte_unused struct cmdline *cl,
6438 __rte_unused void *data)
6440 struct cmd_set_bonding_primary_result *res = parsed_result;
6441 portid_t master_port_id = res->port_id;
6442 portid_t slave_port_id = res->slave_id;
6444 /* Set the primary slave for a bonded device. */
6445 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6446 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6453 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6454 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6456 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6457 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6458 bonding, "bonding");
6459 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6460 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6461 primary, "primary");
6462 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6463 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6464 slave_id, RTE_UINT16);
6465 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6466 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6467 port_id, RTE_UINT16);
6469 cmdline_parse_inst_t cmd_set_bonding_primary = {
6470 .f = cmd_set_bonding_primary_parsed,
6471 .help_str = "set bonding primary <slave_id> <port_id>: "
6472 "Set the primary slave for port_id",
6475 (void *)&cmd_setbonding_primary_set,
6476 (void *)&cmd_setbonding_primary_bonding,
6477 (void *)&cmd_setbonding_primary_primary,
6478 (void *)&cmd_setbonding_primary_slave,
6479 (void *)&cmd_setbonding_primary_port,
6484 /* *** ADD SLAVE *** */
6485 struct cmd_add_bonding_slave_result {
6486 cmdline_fixed_string_t add;
6487 cmdline_fixed_string_t bonding;
6488 cmdline_fixed_string_t slave;
6493 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6494 __rte_unused struct cmdline *cl,
6495 __rte_unused void *data)
6497 struct cmd_add_bonding_slave_result *res = parsed_result;
6498 portid_t master_port_id = res->port_id;
6499 portid_t slave_port_id = res->slave_id;
6501 /* add the slave for a bonded device. */
6502 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6504 "\t Failed to add slave %d to master port = %d.\n",
6505 slave_port_id, master_port_id);
6509 set_port_slave_flag(slave_port_id);
6512 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6513 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6515 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6516 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6517 bonding, "bonding");
6518 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6519 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6521 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6522 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6523 slave_id, RTE_UINT16);
6524 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6525 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6526 port_id, RTE_UINT16);
6528 cmdline_parse_inst_t cmd_add_bonding_slave = {
6529 .f = cmd_add_bonding_slave_parsed,
6530 .help_str = "add bonding slave <slave_id> <port_id>: "
6531 "Add a slave device to a bonded device",
6534 (void *)&cmd_addbonding_slave_add,
6535 (void *)&cmd_addbonding_slave_bonding,
6536 (void *)&cmd_addbonding_slave_slave,
6537 (void *)&cmd_addbonding_slave_slaveid,
6538 (void *)&cmd_addbonding_slave_port,
6543 /* *** REMOVE SLAVE *** */
6544 struct cmd_remove_bonding_slave_result {
6545 cmdline_fixed_string_t remove;
6546 cmdline_fixed_string_t bonding;
6547 cmdline_fixed_string_t slave;
6552 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6553 __rte_unused struct cmdline *cl,
6554 __rte_unused void *data)
6556 struct cmd_remove_bonding_slave_result *res = parsed_result;
6557 portid_t master_port_id = res->port_id;
6558 portid_t slave_port_id = res->slave_id;
6560 /* remove the slave from a bonded device. */
6561 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6563 "\t Failed to remove slave %d from master port = %d.\n",
6564 slave_port_id, master_port_id);
6568 clear_port_slave_flag(slave_port_id);
6571 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6572 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6574 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6575 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6576 bonding, "bonding");
6577 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6578 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6580 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6581 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6582 slave_id, RTE_UINT16);
6583 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6584 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6585 port_id, RTE_UINT16);
6587 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6588 .f = cmd_remove_bonding_slave_parsed,
6589 .help_str = "remove bonding slave <slave_id> <port_id>: "
6590 "Remove a slave device from a bonded device",
6593 (void *)&cmd_removebonding_slave_remove,
6594 (void *)&cmd_removebonding_slave_bonding,
6595 (void *)&cmd_removebonding_slave_slave,
6596 (void *)&cmd_removebonding_slave_slaveid,
6597 (void *)&cmd_removebonding_slave_port,
6602 /* *** CREATE BONDED DEVICE *** */
6603 struct cmd_create_bonded_device_result {
6604 cmdline_fixed_string_t create;
6605 cmdline_fixed_string_t bonded;
6606 cmdline_fixed_string_t device;
6611 static int bond_dev_num = 0;
6613 static void cmd_create_bonded_device_parsed(void *parsed_result,
6614 __rte_unused struct cmdline *cl,
6615 __rte_unused void *data)
6617 struct cmd_create_bonded_device_result *res = parsed_result;
6618 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6622 if (test_done == 0) {
6623 fprintf(stderr, "Please stop forwarding first\n");
6627 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6630 /* Create a new bonded device. */
6631 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6633 fprintf(stderr, "\t Failed to create bonded device.\n");
6636 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6639 /* Update number of ports */
6640 nb_ports = rte_eth_dev_count_avail();
6641 reconfig(port_id, res->socket);
6642 ret = rte_eth_promiscuous_enable(port_id);
6645 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6646 port_id, rte_strerror(-ret));
6648 ports[port_id].need_setup = 0;
6649 ports[port_id].port_status = RTE_PORT_STOPPED;
6654 cmdline_parse_token_string_t cmd_createbonded_device_create =
6655 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6657 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6658 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6660 cmdline_parse_token_string_t cmd_createbonded_device_device =
6661 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6663 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6664 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6666 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6667 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6670 cmdline_parse_inst_t cmd_create_bonded_device = {
6671 .f = cmd_create_bonded_device_parsed,
6672 .help_str = "create bonded device <mode> <socket>: "
6673 "Create a new bonded device with specific bonding mode and socket",
6676 (void *)&cmd_createbonded_device_create,
6677 (void *)&cmd_createbonded_device_bonded,
6678 (void *)&cmd_createbonded_device_device,
6679 (void *)&cmd_createbonded_device_mode,
6680 (void *)&cmd_createbonded_device_socket,
6685 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6686 struct cmd_set_bond_mac_addr_result {
6687 cmdline_fixed_string_t set;
6688 cmdline_fixed_string_t bonding;
6689 cmdline_fixed_string_t mac_addr;
6691 struct rte_ether_addr address;
6694 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6695 __rte_unused struct cmdline *cl,
6696 __rte_unused void *data)
6698 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6701 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6704 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6706 /* check the return value and print it if is < 0 */
6708 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6712 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6713 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6714 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6715 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6717 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6718 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6720 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6721 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6722 port_num, RTE_UINT16);
6723 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6724 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6726 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6727 .f = cmd_set_bond_mac_addr_parsed,
6729 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6731 (void *)&cmd_set_bond_mac_addr_set,
6732 (void *)&cmd_set_bond_mac_addr_bonding,
6733 (void *)&cmd_set_bond_mac_addr_mac,
6734 (void *)&cmd_set_bond_mac_addr_portnum,
6735 (void *)&cmd_set_bond_mac_addr_addr,
6741 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6742 struct cmd_set_bond_mon_period_result {
6743 cmdline_fixed_string_t set;
6744 cmdline_fixed_string_t bonding;
6745 cmdline_fixed_string_t mon_period;
6750 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6751 __rte_unused struct cmdline *cl,
6752 __rte_unused void *data)
6754 struct cmd_set_bond_mon_period_result *res = parsed_result;
6757 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6759 /* check the return value and print it if is < 0 */
6761 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6765 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6766 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6768 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6769 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6770 bonding, "bonding");
6771 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6772 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6773 mon_period, "mon_period");
6774 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6775 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6776 port_num, RTE_UINT16);
6777 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6778 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6779 period_ms, RTE_UINT32);
6781 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6782 .f = cmd_set_bond_mon_period_parsed,
6784 .help_str = "set bonding mon_period <port_id> <period_ms>",
6786 (void *)&cmd_set_bond_mon_period_set,
6787 (void *)&cmd_set_bond_mon_period_bonding,
6788 (void *)&cmd_set_bond_mon_period_mon_period,
6789 (void *)&cmd_set_bond_mon_period_portnum,
6790 (void *)&cmd_set_bond_mon_period_period_ms,
6797 struct cmd_set_bonding_agg_mode_policy_result {
6798 cmdline_fixed_string_t set;
6799 cmdline_fixed_string_t bonding;
6800 cmdline_fixed_string_t agg_mode;
6802 cmdline_fixed_string_t policy;
6807 cmd_set_bonding_agg_mode(void *parsed_result,
6808 __rte_unused struct cmdline *cl,
6809 __rte_unused void *data)
6811 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6812 uint8_t policy = AGG_BANDWIDTH;
6814 if (!strcmp(res->policy, "bandwidth"))
6815 policy = AGG_BANDWIDTH;
6816 else if (!strcmp(res->policy, "stable"))
6817 policy = AGG_STABLE;
6818 else if (!strcmp(res->policy, "count"))
6821 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6825 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6826 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6828 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6829 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6830 bonding, "bonding");
6832 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6833 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6834 agg_mode, "agg_mode");
6836 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6837 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6838 port_num, RTE_UINT16);
6840 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6841 TOKEN_STRING_INITIALIZER(
6842 struct cmd_set_bonding_balance_xmit_policy_result,
6843 policy, "stable#bandwidth#count");
6845 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6846 .f = cmd_set_bonding_agg_mode,
6848 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6850 (void *)&cmd_set_bonding_agg_mode_set,
6851 (void *)&cmd_set_bonding_agg_mode_bonding,
6852 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6853 (void *)&cmd_set_bonding_agg_mode_portnum,
6854 (void *)&cmd_set_bonding_agg_mode_policy_string,
6860 #endif /* RTE_NET_BOND */
6862 /* *** SET FORWARDING MODE *** */
6863 struct cmd_set_fwd_mode_result {
6864 cmdline_fixed_string_t set;
6865 cmdline_fixed_string_t fwd;
6866 cmdline_fixed_string_t mode;
6869 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6870 __rte_unused struct cmdline *cl,
6871 __rte_unused void *data)
6873 struct cmd_set_fwd_mode_result *res = parsed_result;
6876 set_pkt_forwarding_mode(res->mode);
6879 cmdline_parse_token_string_t cmd_setfwd_set =
6880 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6881 cmdline_parse_token_string_t cmd_setfwd_fwd =
6882 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6883 cmdline_parse_token_string_t cmd_setfwd_mode =
6884 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6885 "" /* defined at init */);
6887 cmdline_parse_inst_t cmd_set_fwd_mode = {
6888 .f = cmd_set_fwd_mode_parsed,
6890 .help_str = NULL, /* defined at init */
6892 (void *)&cmd_setfwd_set,
6893 (void *)&cmd_setfwd_fwd,
6894 (void *)&cmd_setfwd_mode,
6899 static void cmd_set_fwd_mode_init(void)
6902 static char token[128];
6903 static char help[256];
6904 cmdline_parse_token_string_t *token_struct;
6906 modes = list_pkt_forwarding_modes();
6907 snprintf(help, sizeof(help), "set fwd %s: "
6908 "Set packet forwarding mode", modes);
6909 cmd_set_fwd_mode.help_str = help;
6911 /* string token separator is # */
6912 for (c = token; *modes != '\0'; modes++)
6917 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6918 token_struct->string_data.str = token;
6921 /* *** SET RETRY FORWARDING MODE *** */
6922 struct cmd_set_fwd_retry_mode_result {
6923 cmdline_fixed_string_t set;
6924 cmdline_fixed_string_t fwd;
6925 cmdline_fixed_string_t mode;
6926 cmdline_fixed_string_t retry;
6929 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6930 __rte_unused struct cmdline *cl,
6931 __rte_unused void *data)
6933 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6936 set_pkt_forwarding_mode(res->mode);
6939 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6940 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6942 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6943 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6945 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6946 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6948 "" /* defined at init */);
6949 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6950 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6953 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6954 .f = cmd_set_fwd_retry_mode_parsed,
6956 .help_str = NULL, /* defined at init */
6958 (void *)&cmd_setfwd_retry_set,
6959 (void *)&cmd_setfwd_retry_fwd,
6960 (void *)&cmd_setfwd_retry_mode,
6961 (void *)&cmd_setfwd_retry_retry,
6966 static void cmd_set_fwd_retry_mode_init(void)
6969 static char token[128];
6970 static char help[256];
6971 cmdline_parse_token_string_t *token_struct;
6973 modes = list_pkt_forwarding_retry_modes();
6974 snprintf(help, sizeof(help), "set fwd %s retry: "
6975 "Set packet forwarding mode with retry", modes);
6976 cmd_set_fwd_retry_mode.help_str = help;
6978 /* string token separator is # */
6979 for (c = token; *modes != '\0'; modes++)
6984 token_struct = (cmdline_parse_token_string_t *)
6985 cmd_set_fwd_retry_mode.tokens[2];
6986 token_struct->string_data.str = token;
6989 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6990 struct cmd_set_burst_tx_retry_result {
6991 cmdline_fixed_string_t set;
6992 cmdline_fixed_string_t burst;
6993 cmdline_fixed_string_t tx;
6994 cmdline_fixed_string_t delay;
6996 cmdline_fixed_string_t retry;
7000 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7001 __rte_unused struct cmdline *cl,
7002 __rte_unused void *data)
7004 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7006 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7007 && !strcmp(res->tx, "tx")) {
7008 if (!strcmp(res->delay, "delay"))
7009 burst_tx_delay_time = res->time;
7010 if (!strcmp(res->retry, "retry"))
7011 burst_tx_retry_num = res->retry_num;
7016 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7017 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7018 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7019 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7021 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7022 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7023 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7024 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7025 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7026 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7028 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7029 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7030 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7031 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7034 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7035 .f = cmd_set_burst_tx_retry_parsed,
7036 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7038 (void *)&cmd_set_burst_tx_retry_set,
7039 (void *)&cmd_set_burst_tx_retry_burst,
7040 (void *)&cmd_set_burst_tx_retry_tx,
7041 (void *)&cmd_set_burst_tx_retry_delay,
7042 (void *)&cmd_set_burst_tx_retry_time,
7043 (void *)&cmd_set_burst_tx_retry_retry,
7044 (void *)&cmd_set_burst_tx_retry_retry_num,
7049 /* *** SET PROMISC MODE *** */
7050 struct cmd_set_promisc_mode_result {
7051 cmdline_fixed_string_t set;
7052 cmdline_fixed_string_t promisc;
7053 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7054 uint16_t port_num; /* valid if "allports" argument == 0 */
7055 cmdline_fixed_string_t mode;
7058 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7059 __rte_unused struct cmdline *cl,
7062 struct cmd_set_promisc_mode_result *res = parsed_result;
7066 if (!strcmp(res->mode, "on"))
7073 RTE_ETH_FOREACH_DEV(i)
7074 eth_set_promisc_mode(i, enable);
7076 eth_set_promisc_mode(res->port_num, enable);
7080 cmdline_parse_token_string_t cmd_setpromisc_set =
7081 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7082 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7083 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7085 cmdline_parse_token_string_t cmd_setpromisc_portall =
7086 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7088 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7089 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7091 cmdline_parse_token_string_t cmd_setpromisc_mode =
7092 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7095 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7096 .f = cmd_set_promisc_mode_parsed,
7098 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7100 (void *)&cmd_setpromisc_set,
7101 (void *)&cmd_setpromisc_promisc,
7102 (void *)&cmd_setpromisc_portall,
7103 (void *)&cmd_setpromisc_mode,
7108 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7109 .f = cmd_set_promisc_mode_parsed,
7111 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7113 (void *)&cmd_setpromisc_set,
7114 (void *)&cmd_setpromisc_promisc,
7115 (void *)&cmd_setpromisc_portnum,
7116 (void *)&cmd_setpromisc_mode,
7121 /* *** SET ALLMULTI MODE *** */
7122 struct cmd_set_allmulti_mode_result {
7123 cmdline_fixed_string_t set;
7124 cmdline_fixed_string_t allmulti;
7125 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7126 uint16_t port_num; /* valid if "allports" argument == 0 */
7127 cmdline_fixed_string_t mode;
7130 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7131 __rte_unused struct cmdline *cl,
7134 struct cmd_set_allmulti_mode_result *res = parsed_result;
7138 if (!strcmp(res->mode, "on"))
7145 RTE_ETH_FOREACH_DEV(i) {
7146 eth_set_allmulticast_mode(i, enable);
7150 eth_set_allmulticast_mode(res->port_num, enable);
7154 cmdline_parse_token_string_t cmd_setallmulti_set =
7155 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7156 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7157 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7159 cmdline_parse_token_string_t cmd_setallmulti_portall =
7160 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7162 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7163 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7165 cmdline_parse_token_string_t cmd_setallmulti_mode =
7166 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7169 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7170 .f = cmd_set_allmulti_mode_parsed,
7172 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7174 (void *)&cmd_setallmulti_set,
7175 (void *)&cmd_setallmulti_allmulti,
7176 (void *)&cmd_setallmulti_portall,
7177 (void *)&cmd_setallmulti_mode,
7182 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7183 .f = cmd_set_allmulti_mode_parsed,
7185 .help_str = "set allmulti <port_id> on|off: "
7186 "Set allmulti mode on port_id",
7188 (void *)&cmd_setallmulti_set,
7189 (void *)&cmd_setallmulti_allmulti,
7190 (void *)&cmd_setallmulti_portnum,
7191 (void *)&cmd_setallmulti_mode,
7196 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7197 struct cmd_link_flow_ctrl_show {
7198 cmdline_fixed_string_t show;
7199 cmdline_fixed_string_t port;
7201 cmdline_fixed_string_t flow_ctrl;
7204 cmdline_parse_token_string_t cmd_lfc_show_show =
7205 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7207 cmdline_parse_token_string_t cmd_lfc_show_port =
7208 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7210 cmdline_parse_token_num_t cmd_lfc_show_portid =
7211 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7212 port_id, RTE_UINT16);
7213 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7214 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7215 flow_ctrl, "flow_ctrl");
7218 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7219 __rte_unused struct cmdline *cl,
7220 __rte_unused void *data)
7222 struct cmd_link_flow_ctrl_show *res = parsed_result;
7223 static const char *info_border = "*********************";
7224 struct rte_eth_fc_conf fc_conf;
7225 bool rx_fc_en = false;
7226 bool tx_fc_en = false;
7229 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7232 "Failed to get current flow ctrl information: err = %d\n",
7237 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7239 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7242 printf("\n%s Flow control infos for port %-2d %s\n",
7243 info_border, res->port_id, info_border);
7244 printf("FC mode:\n");
7245 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7246 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7247 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7248 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7249 printf("High waterline: 0x%x\n", fc_conf.high_water);
7250 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7251 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7252 printf("Forward MAC control frames: %s\n",
7253 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7254 printf("\n%s************** End ***********%s\n",
7255 info_border, info_border);
7258 cmdline_parse_inst_t cmd_link_flow_control_show = {
7259 .f = cmd_link_flow_ctrl_show_parsed,
7261 .help_str = "show port <port_id> flow_ctrl",
7263 (void *)&cmd_lfc_show_show,
7264 (void *)&cmd_lfc_show_port,
7265 (void *)&cmd_lfc_show_portid,
7266 (void *)&cmd_lfc_show_flow_ctrl,
7271 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7272 struct cmd_link_flow_ctrl_set_result {
7273 cmdline_fixed_string_t set;
7274 cmdline_fixed_string_t flow_ctrl;
7275 cmdline_fixed_string_t rx;
7276 cmdline_fixed_string_t rx_lfc_mode;
7277 cmdline_fixed_string_t tx;
7278 cmdline_fixed_string_t tx_lfc_mode;
7279 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7280 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7281 cmdline_fixed_string_t autoneg_str;
7282 cmdline_fixed_string_t autoneg;
7283 cmdline_fixed_string_t hw_str;
7284 uint32_t high_water;
7285 cmdline_fixed_string_t lw_str;
7287 cmdline_fixed_string_t pt_str;
7288 uint16_t pause_time;
7289 cmdline_fixed_string_t xon_str;
7294 cmdline_parse_token_string_t cmd_lfc_set_set =
7295 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7297 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7298 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7299 flow_ctrl, "flow_ctrl");
7300 cmdline_parse_token_string_t cmd_lfc_set_rx =
7301 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7303 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7304 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7305 rx_lfc_mode, "on#off");
7306 cmdline_parse_token_string_t cmd_lfc_set_tx =
7307 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7309 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7310 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7311 tx_lfc_mode, "on#off");
7312 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7313 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7314 hw_str, "high_water");
7315 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7316 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7317 high_water, RTE_UINT32);
7318 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7319 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7320 lw_str, "low_water");
7321 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7322 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7323 low_water, RTE_UINT32);
7324 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7325 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7326 pt_str, "pause_time");
7327 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7328 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7329 pause_time, RTE_UINT16);
7330 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7331 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7332 xon_str, "send_xon");
7333 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7334 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7335 send_xon, RTE_UINT16);
7336 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7337 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7338 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7339 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7340 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7341 mac_ctrl_frame_fwd_mode, "on#off");
7342 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7343 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7344 autoneg_str, "autoneg");
7345 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7346 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7348 cmdline_parse_token_num_t cmd_lfc_set_portid =
7349 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7350 port_id, RTE_UINT16);
7352 /* forward declaration */
7354 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7357 cmdline_parse_inst_t cmd_link_flow_control_set = {
7358 .f = cmd_link_flow_ctrl_set_parsed,
7360 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7361 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7362 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7364 (void *)&cmd_lfc_set_set,
7365 (void *)&cmd_lfc_set_flow_ctrl,
7366 (void *)&cmd_lfc_set_rx,
7367 (void *)&cmd_lfc_set_rx_mode,
7368 (void *)&cmd_lfc_set_tx,
7369 (void *)&cmd_lfc_set_tx_mode,
7370 (void *)&cmd_lfc_set_high_water,
7371 (void *)&cmd_lfc_set_low_water,
7372 (void *)&cmd_lfc_set_pause_time,
7373 (void *)&cmd_lfc_set_send_xon,
7374 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7375 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7376 (void *)&cmd_lfc_set_autoneg_str,
7377 (void *)&cmd_lfc_set_autoneg,
7378 (void *)&cmd_lfc_set_portid,
7383 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7384 .f = cmd_link_flow_ctrl_set_parsed,
7385 .data = (void *)&cmd_link_flow_control_set_rx,
7386 .help_str = "set flow_ctrl rx on|off <port_id>: "
7387 "Change rx flow control parameter",
7389 (void *)&cmd_lfc_set_set,
7390 (void *)&cmd_lfc_set_flow_ctrl,
7391 (void *)&cmd_lfc_set_rx,
7392 (void *)&cmd_lfc_set_rx_mode,
7393 (void *)&cmd_lfc_set_portid,
7398 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7399 .f = cmd_link_flow_ctrl_set_parsed,
7400 .data = (void *)&cmd_link_flow_control_set_tx,
7401 .help_str = "set flow_ctrl tx on|off <port_id>: "
7402 "Change tx flow control parameter",
7404 (void *)&cmd_lfc_set_set,
7405 (void *)&cmd_lfc_set_flow_ctrl,
7406 (void *)&cmd_lfc_set_tx,
7407 (void *)&cmd_lfc_set_tx_mode,
7408 (void *)&cmd_lfc_set_portid,
7413 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7414 .f = cmd_link_flow_ctrl_set_parsed,
7415 .data = (void *)&cmd_link_flow_control_set_hw,
7416 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7417 "Change high water flow control parameter",
7419 (void *)&cmd_lfc_set_set,
7420 (void *)&cmd_lfc_set_flow_ctrl,
7421 (void *)&cmd_lfc_set_high_water_str,
7422 (void *)&cmd_lfc_set_high_water,
7423 (void *)&cmd_lfc_set_portid,
7428 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7429 .f = cmd_link_flow_ctrl_set_parsed,
7430 .data = (void *)&cmd_link_flow_control_set_lw,
7431 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7432 "Change low water flow control parameter",
7434 (void *)&cmd_lfc_set_set,
7435 (void *)&cmd_lfc_set_flow_ctrl,
7436 (void *)&cmd_lfc_set_low_water_str,
7437 (void *)&cmd_lfc_set_low_water,
7438 (void *)&cmd_lfc_set_portid,
7443 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7444 .f = cmd_link_flow_ctrl_set_parsed,
7445 .data = (void *)&cmd_link_flow_control_set_pt,
7446 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7447 "Change pause time flow control parameter",
7449 (void *)&cmd_lfc_set_set,
7450 (void *)&cmd_lfc_set_flow_ctrl,
7451 (void *)&cmd_lfc_set_pause_time_str,
7452 (void *)&cmd_lfc_set_pause_time,
7453 (void *)&cmd_lfc_set_portid,
7458 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7459 .f = cmd_link_flow_ctrl_set_parsed,
7460 .data = (void *)&cmd_link_flow_control_set_xon,
7461 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7462 "Change send_xon flow control parameter",
7464 (void *)&cmd_lfc_set_set,
7465 (void *)&cmd_lfc_set_flow_ctrl,
7466 (void *)&cmd_lfc_set_send_xon_str,
7467 (void *)&cmd_lfc_set_send_xon,
7468 (void *)&cmd_lfc_set_portid,
7473 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7474 .f = cmd_link_flow_ctrl_set_parsed,
7475 .data = (void *)&cmd_link_flow_control_set_macfwd,
7476 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7477 "Change mac ctrl fwd flow control parameter",
7479 (void *)&cmd_lfc_set_set,
7480 (void *)&cmd_lfc_set_flow_ctrl,
7481 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7482 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7483 (void *)&cmd_lfc_set_portid,
7488 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7489 .f = cmd_link_flow_ctrl_set_parsed,
7490 .data = (void *)&cmd_link_flow_control_set_autoneg,
7491 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7492 "Change autoneg flow control parameter",
7494 (void *)&cmd_lfc_set_set,
7495 (void *)&cmd_lfc_set_flow_ctrl,
7496 (void *)&cmd_lfc_set_autoneg_str,
7497 (void *)&cmd_lfc_set_autoneg,
7498 (void *)&cmd_lfc_set_portid,
7504 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7505 __rte_unused struct cmdline *cl,
7508 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7509 cmdline_parse_inst_t *cmd = data;
7510 struct rte_eth_fc_conf fc_conf;
7516 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7517 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7518 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7519 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7521 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7522 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7525 /* Partial command line, retrieve current configuration */
7527 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7530 "cannot get current flow ctrl parameters, return code = %d\n",
7535 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7536 (fc_conf.mode == RTE_FC_FULL))
7538 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7539 (fc_conf.mode == RTE_FC_FULL))
7543 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7544 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7546 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7547 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7549 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7551 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7552 fc_conf.high_water = res->high_water;
7554 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7555 fc_conf.low_water = res->low_water;
7557 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7558 fc_conf.pause_time = res->pause_time;
7560 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7561 fc_conf.send_xon = res->send_xon;
7563 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7564 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7565 fc_conf.mac_ctrl_frame_fwd = 1;
7567 fc_conf.mac_ctrl_frame_fwd = 0;
7570 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7571 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7573 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7576 "bad flow control parameter, return code = %d\n",
7580 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7581 struct cmd_priority_flow_ctrl_set_result {
7582 cmdline_fixed_string_t set;
7583 cmdline_fixed_string_t pfc_ctrl;
7584 cmdline_fixed_string_t rx;
7585 cmdline_fixed_string_t rx_pfc_mode;
7586 cmdline_fixed_string_t tx;
7587 cmdline_fixed_string_t tx_pfc_mode;
7588 uint32_t high_water;
7590 uint16_t pause_time;
7596 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7597 __rte_unused struct cmdline *cl,
7598 __rte_unused void *data)
7600 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7601 struct rte_eth_pfc_conf pfc_conf;
7602 int rx_fc_enable, tx_fc_enable;
7606 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7607 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7608 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7609 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7611 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7612 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7615 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7616 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7617 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7618 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7619 pfc_conf.fc.high_water = res->high_water;
7620 pfc_conf.fc.low_water = res->low_water;
7621 pfc_conf.fc.pause_time = res->pause_time;
7622 pfc_conf.priority = res->priority;
7624 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7627 "bad priority flow control parameter, return code = %d\n",
7631 cmdline_parse_token_string_t cmd_pfc_set_set =
7632 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7634 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7635 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7636 pfc_ctrl, "pfc_ctrl");
7637 cmdline_parse_token_string_t cmd_pfc_set_rx =
7638 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7640 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7641 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7642 rx_pfc_mode, "on#off");
7643 cmdline_parse_token_string_t cmd_pfc_set_tx =
7644 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7646 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7647 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7648 tx_pfc_mode, "on#off");
7649 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7650 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7651 high_water, RTE_UINT32);
7652 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7653 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7654 low_water, RTE_UINT32);
7655 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7656 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7657 pause_time, RTE_UINT16);
7658 cmdline_parse_token_num_t cmd_pfc_set_priority =
7659 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7660 priority, RTE_UINT8);
7661 cmdline_parse_token_num_t cmd_pfc_set_portid =
7662 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7663 port_id, RTE_UINT16);
7665 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7666 .f = cmd_priority_flow_ctrl_set_parsed,
7668 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7669 "<pause_time> <priority> <port_id>: "
7670 "Configure the Ethernet priority flow control",
7672 (void *)&cmd_pfc_set_set,
7673 (void *)&cmd_pfc_set_flow_ctrl,
7674 (void *)&cmd_pfc_set_rx,
7675 (void *)&cmd_pfc_set_rx_mode,
7676 (void *)&cmd_pfc_set_tx,
7677 (void *)&cmd_pfc_set_tx_mode,
7678 (void *)&cmd_pfc_set_high_water,
7679 (void *)&cmd_pfc_set_low_water,
7680 (void *)&cmd_pfc_set_pause_time,
7681 (void *)&cmd_pfc_set_priority,
7682 (void *)&cmd_pfc_set_portid,
7687 /* *** RESET CONFIGURATION *** */
7688 struct cmd_reset_result {
7689 cmdline_fixed_string_t reset;
7690 cmdline_fixed_string_t def;
7693 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7695 __rte_unused void *data)
7697 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7698 set_def_fwd_config();
7701 cmdline_parse_token_string_t cmd_reset_set =
7702 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7703 cmdline_parse_token_string_t cmd_reset_def =
7704 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7707 cmdline_parse_inst_t cmd_reset = {
7708 .f = cmd_reset_parsed,
7710 .help_str = "set default: Reset default forwarding configuration",
7712 (void *)&cmd_reset_set,
7713 (void *)&cmd_reset_def,
7718 /* *** START FORWARDING *** */
7719 struct cmd_start_result {
7720 cmdline_fixed_string_t start;
7723 cmdline_parse_token_string_t cmd_start_start =
7724 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7726 static void cmd_start_parsed(__rte_unused void *parsed_result,
7727 __rte_unused struct cmdline *cl,
7728 __rte_unused void *data)
7730 start_packet_forwarding(0);
7733 cmdline_parse_inst_t cmd_start = {
7734 .f = cmd_start_parsed,
7736 .help_str = "start: Start packet forwarding",
7738 (void *)&cmd_start_start,
7743 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7744 struct cmd_start_tx_first_result {
7745 cmdline_fixed_string_t start;
7746 cmdline_fixed_string_t tx_first;
7750 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7751 __rte_unused struct cmdline *cl,
7752 __rte_unused void *data)
7754 start_packet_forwarding(1);
7757 cmdline_parse_token_string_t cmd_start_tx_first_start =
7758 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7760 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7761 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7762 tx_first, "tx_first");
7764 cmdline_parse_inst_t cmd_start_tx_first = {
7765 .f = cmd_start_tx_first_parsed,
7767 .help_str = "start tx_first: Start packet forwarding, "
7768 "after sending 1 burst of packets",
7770 (void *)&cmd_start_tx_first_start,
7771 (void *)&cmd_start_tx_first_tx_first,
7776 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7777 struct cmd_start_tx_first_n_result {
7778 cmdline_fixed_string_t start;
7779 cmdline_fixed_string_t tx_first;
7784 cmd_start_tx_first_n_parsed(void *parsed_result,
7785 __rte_unused struct cmdline *cl,
7786 __rte_unused void *data)
7788 struct cmd_start_tx_first_n_result *res = parsed_result;
7790 start_packet_forwarding(res->tx_num);
7793 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7794 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7796 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7797 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7798 tx_first, "tx_first");
7799 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7800 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7801 tx_num, RTE_UINT32);
7803 cmdline_parse_inst_t cmd_start_tx_first_n = {
7804 .f = cmd_start_tx_first_n_parsed,
7806 .help_str = "start tx_first <num>: "
7807 "packet forwarding, after sending <num> bursts of packets",
7809 (void *)&cmd_start_tx_first_n_start,
7810 (void *)&cmd_start_tx_first_n_tx_first,
7811 (void *)&cmd_start_tx_first_n_tx_num,
7816 /* *** SET LINK UP *** */
7817 struct cmd_set_link_up_result {
7818 cmdline_fixed_string_t set;
7819 cmdline_fixed_string_t link_up;
7820 cmdline_fixed_string_t port;
7824 cmdline_parse_token_string_t cmd_set_link_up_set =
7825 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7826 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7827 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7829 cmdline_parse_token_string_t cmd_set_link_up_port =
7830 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7831 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7832 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7835 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7836 __rte_unused struct cmdline *cl,
7837 __rte_unused void *data)
7839 struct cmd_set_link_up_result *res = parsed_result;
7840 dev_set_link_up(res->port_id);
7843 cmdline_parse_inst_t cmd_set_link_up = {
7844 .f = cmd_set_link_up_parsed,
7846 .help_str = "set link-up port <port id>",
7848 (void *)&cmd_set_link_up_set,
7849 (void *)&cmd_set_link_up_link_up,
7850 (void *)&cmd_set_link_up_port,
7851 (void *)&cmd_set_link_up_port_id,
7856 /* *** SET LINK DOWN *** */
7857 struct cmd_set_link_down_result {
7858 cmdline_fixed_string_t set;
7859 cmdline_fixed_string_t link_down;
7860 cmdline_fixed_string_t port;
7864 cmdline_parse_token_string_t cmd_set_link_down_set =
7865 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7866 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7867 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7869 cmdline_parse_token_string_t cmd_set_link_down_port =
7870 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7871 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7872 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7875 static void cmd_set_link_down_parsed(
7876 __rte_unused void *parsed_result,
7877 __rte_unused struct cmdline *cl,
7878 __rte_unused void *data)
7880 struct cmd_set_link_down_result *res = parsed_result;
7881 dev_set_link_down(res->port_id);
7884 cmdline_parse_inst_t cmd_set_link_down = {
7885 .f = cmd_set_link_down_parsed,
7887 .help_str = "set link-down port <port id>",
7889 (void *)&cmd_set_link_down_set,
7890 (void *)&cmd_set_link_down_link_down,
7891 (void *)&cmd_set_link_down_port,
7892 (void *)&cmd_set_link_down_port_id,
7897 /* *** SHOW CFG *** */
7898 struct cmd_showcfg_result {
7899 cmdline_fixed_string_t show;
7900 cmdline_fixed_string_t cfg;
7901 cmdline_fixed_string_t what;
7904 static void cmd_showcfg_parsed(void *parsed_result,
7905 __rte_unused struct cmdline *cl,
7906 __rte_unused void *data)
7908 struct cmd_showcfg_result *res = parsed_result;
7909 if (!strcmp(res->what, "rxtx"))
7910 rxtx_config_display();
7911 else if (!strcmp(res->what, "cores"))
7912 fwd_lcores_config_display();
7913 else if (!strcmp(res->what, "fwd"))
7914 pkt_fwd_config_display(&cur_fwd_config);
7915 else if (!strcmp(res->what, "rxoffs"))
7916 show_rx_pkt_offsets();
7917 else if (!strcmp(res->what, "rxpkts"))
7918 show_rx_pkt_segments();
7919 else if (!strcmp(res->what, "txpkts"))
7920 show_tx_pkt_segments();
7921 else if (!strcmp(res->what, "txtimes"))
7922 show_tx_pkt_times();
7925 cmdline_parse_token_string_t cmd_showcfg_show =
7926 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7927 cmdline_parse_token_string_t cmd_showcfg_port =
7928 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7929 cmdline_parse_token_string_t cmd_showcfg_what =
7930 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7931 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7933 cmdline_parse_inst_t cmd_showcfg = {
7934 .f = cmd_showcfg_parsed,
7936 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7938 (void *)&cmd_showcfg_show,
7939 (void *)&cmd_showcfg_port,
7940 (void *)&cmd_showcfg_what,
7945 /* *** SHOW ALL PORT INFO *** */
7946 struct cmd_showportall_result {
7947 cmdline_fixed_string_t show;
7948 cmdline_fixed_string_t port;
7949 cmdline_fixed_string_t what;
7950 cmdline_fixed_string_t all;
7953 static void cmd_showportall_parsed(void *parsed_result,
7954 __rte_unused struct cmdline *cl,
7955 __rte_unused void *data)
7959 struct cmd_showportall_result *res = parsed_result;
7960 if (!strcmp(res->show, "clear")) {
7961 if (!strcmp(res->what, "stats"))
7962 RTE_ETH_FOREACH_DEV(i)
7964 else if (!strcmp(res->what, "xstats"))
7965 RTE_ETH_FOREACH_DEV(i)
7966 nic_xstats_clear(i);
7967 } else if (!strcmp(res->what, "info"))
7968 RTE_ETH_FOREACH_DEV(i)
7969 port_infos_display(i);
7970 else if (!strcmp(res->what, "summary")) {
7971 port_summary_header_display();
7972 RTE_ETH_FOREACH_DEV(i)
7973 port_summary_display(i);
7975 else if (!strcmp(res->what, "stats"))
7976 RTE_ETH_FOREACH_DEV(i)
7977 nic_stats_display(i);
7978 else if (!strcmp(res->what, "xstats"))
7979 RTE_ETH_FOREACH_DEV(i)
7980 nic_xstats_display(i);
7981 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7982 else if (!strcmp(res->what, "fdir"))
7983 RTE_ETH_FOREACH_DEV(i)
7986 else if (!strcmp(res->what, "dcb_tc"))
7987 RTE_ETH_FOREACH_DEV(i)
7988 port_dcb_info_display(i);
7991 cmdline_parse_token_string_t cmd_showportall_show =
7992 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7994 cmdline_parse_token_string_t cmd_showportall_port =
7995 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7996 cmdline_parse_token_string_t cmd_showportall_what =
7997 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7998 "info#summary#stats#xstats#fdir#dcb_tc");
7999 cmdline_parse_token_string_t cmd_showportall_all =
8000 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8001 cmdline_parse_inst_t cmd_showportall = {
8002 .f = cmd_showportall_parsed,
8004 .help_str = "show|clear port "
8005 "info|summary|stats|xstats|fdir|dcb_tc all",
8007 (void *)&cmd_showportall_show,
8008 (void *)&cmd_showportall_port,
8009 (void *)&cmd_showportall_what,
8010 (void *)&cmd_showportall_all,
8015 /* *** SHOW PORT INFO *** */
8016 struct cmd_showport_result {
8017 cmdline_fixed_string_t show;
8018 cmdline_fixed_string_t port;
8019 cmdline_fixed_string_t what;
8023 static void cmd_showport_parsed(void *parsed_result,
8024 __rte_unused struct cmdline *cl,
8025 __rte_unused void *data)
8027 struct cmd_showport_result *res = parsed_result;
8028 if (!strcmp(res->show, "clear")) {
8029 if (!strcmp(res->what, "stats"))
8030 nic_stats_clear(res->portnum);
8031 else if (!strcmp(res->what, "xstats"))
8032 nic_xstats_clear(res->portnum);
8033 } else if (!strcmp(res->what, "info"))
8034 port_infos_display(res->portnum);
8035 else if (!strcmp(res->what, "summary")) {
8036 port_summary_header_display();
8037 port_summary_display(res->portnum);
8039 else if (!strcmp(res->what, "stats"))
8040 nic_stats_display(res->portnum);
8041 else if (!strcmp(res->what, "xstats"))
8042 nic_xstats_display(res->portnum);
8043 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8044 else if (!strcmp(res->what, "fdir"))
8045 fdir_get_infos(res->portnum);
8047 else if (!strcmp(res->what, "dcb_tc"))
8048 port_dcb_info_display(res->portnum);
8051 cmdline_parse_token_string_t cmd_showport_show =
8052 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8054 cmdline_parse_token_string_t cmd_showport_port =
8055 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8056 cmdline_parse_token_string_t cmd_showport_what =
8057 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8058 "info#summary#stats#xstats#fdir#dcb_tc");
8059 cmdline_parse_token_num_t cmd_showport_portnum =
8060 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8062 cmdline_parse_inst_t cmd_showport = {
8063 .f = cmd_showport_parsed,
8065 .help_str = "show|clear port "
8066 "info|summary|stats|xstats|fdir|dcb_tc "
8069 (void *)&cmd_showport_show,
8070 (void *)&cmd_showport_port,
8071 (void *)&cmd_showport_what,
8072 (void *)&cmd_showport_portnum,
8077 /* *** show port representors information *** */
8078 struct cmd_representor_info_result {
8079 cmdline_fixed_string_t cmd_show;
8080 cmdline_fixed_string_t cmd_port;
8081 cmdline_fixed_string_t cmd_info;
8082 cmdline_fixed_string_t cmd_keyword;
8087 cmd_representor_info_parsed(void *parsed_result,
8088 __rte_unused struct cmdline *cl,
8089 __rte_unused void *data)
8091 struct cmd_representor_info_result *res = parsed_result;
8092 struct rte_eth_representor_info *info;
8093 struct rte_eth_representor_range *range;
8094 uint32_t range_diff;
8099 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8100 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8104 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8107 "Failed to get the number of representor info ranges for port %hu: %s\n",
8108 res->cmd_pid, rte_strerror(-ret));
8113 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8116 "Failed to allocate memory for representor info for port %hu\n",
8120 info->nb_ranges_alloc = num;
8122 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8125 "Failed to get the representor info for port %hu: %s\n",
8126 res->cmd_pid, rte_strerror(-ret));
8131 printf("Port controller: %hu\n", info->controller);
8132 printf("Port PF: %hu\n", info->pf);
8134 printf("Ranges: %u\n", info->nb_ranges);
8135 for (i = 0; i < info->nb_ranges; i++) {
8136 range = &info->ranges[i];
8137 range_diff = range->id_end - range->id_base;
8139 printf("%u. ", i + 1);
8140 printf("'%s' ", range->name);
8142 printf("[%u-%u]: ", range->id_base, range->id_end);
8144 printf("[%u]: ", range->id_base);
8146 printf("Controller %d, PF %d", range->controller, range->pf);
8148 switch (range->type) {
8149 case RTE_ETH_REPRESENTOR_NONE:
8152 case RTE_ETH_REPRESENTOR_VF:
8154 printf(", VF %d..%d\n", range->vf,
8155 range->vf + range_diff);
8157 printf(", VF %d\n", range->vf);
8159 case RTE_ETH_REPRESENTOR_SF:
8160 printf(", SF %d\n", range->sf);
8162 case RTE_ETH_REPRESENTOR_PF:
8164 printf("..%d\n", range->pf + range_diff);
8169 printf(", UNKNOWN TYPE %d\n", range->type);
8177 cmdline_parse_token_string_t cmd_representor_info_show =
8178 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8180 cmdline_parse_token_string_t cmd_representor_info_port =
8181 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8183 cmdline_parse_token_string_t cmd_representor_info_info =
8184 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8186 cmdline_parse_token_num_t cmd_representor_info_pid =
8187 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8188 cmd_pid, RTE_UINT16);
8189 cmdline_parse_token_string_t cmd_representor_info_keyword =
8190 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8191 cmd_keyword, "representor");
8193 cmdline_parse_inst_t cmd_representor_info = {
8194 .f = cmd_representor_info_parsed,
8196 .help_str = "show port info <port_id> representor",
8198 (void *)&cmd_representor_info_show,
8199 (void *)&cmd_representor_info_port,
8200 (void *)&cmd_representor_info_info,
8201 (void *)&cmd_representor_info_pid,
8202 (void *)&cmd_representor_info_keyword,
8208 /* *** SHOW DEVICE INFO *** */
8209 struct cmd_showdevice_result {
8210 cmdline_fixed_string_t show;
8211 cmdline_fixed_string_t device;
8212 cmdline_fixed_string_t what;
8213 cmdline_fixed_string_t identifier;
8216 static void cmd_showdevice_parsed(void *parsed_result,
8217 __rte_unused struct cmdline *cl,
8218 __rte_unused void *data)
8220 struct cmd_showdevice_result *res = parsed_result;
8221 if (!strcmp(res->what, "info")) {
8222 if (!strcmp(res->identifier, "all"))
8223 device_infos_display(NULL);
8225 device_infos_display(res->identifier);
8229 cmdline_parse_token_string_t cmd_showdevice_show =
8230 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8232 cmdline_parse_token_string_t cmd_showdevice_device =
8233 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8234 cmdline_parse_token_string_t cmd_showdevice_what =
8235 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8237 cmdline_parse_token_string_t cmd_showdevice_identifier =
8238 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8241 cmdline_parse_inst_t cmd_showdevice = {
8242 .f = cmd_showdevice_parsed,
8244 .help_str = "show device info <identifier>|all",
8246 (void *)&cmd_showdevice_show,
8247 (void *)&cmd_showdevice_device,
8248 (void *)&cmd_showdevice_what,
8249 (void *)&cmd_showdevice_identifier,
8254 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8255 struct cmd_showeeprom_result {
8256 cmdline_fixed_string_t show;
8257 cmdline_fixed_string_t port;
8259 cmdline_fixed_string_t type;
8262 static void cmd_showeeprom_parsed(void *parsed_result,
8263 __rte_unused struct cmdline *cl,
8264 __rte_unused void *data)
8266 struct cmd_showeeprom_result *res = parsed_result;
8268 if (!strcmp(res->type, "eeprom"))
8269 port_eeprom_display(res->portnum);
8270 else if (!strcmp(res->type, "module_eeprom"))
8271 port_module_eeprom_display(res->portnum);
8273 fprintf(stderr, "Unknown argument\n");
8276 cmdline_parse_token_string_t cmd_showeeprom_show =
8277 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8278 cmdline_parse_token_string_t cmd_showeeprom_port =
8279 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8280 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8281 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8283 cmdline_parse_token_string_t cmd_showeeprom_type =
8284 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8286 cmdline_parse_inst_t cmd_showeeprom = {
8287 .f = cmd_showeeprom_parsed,
8289 .help_str = "show port <port_id> module_eeprom|eeprom",
8291 (void *)&cmd_showeeprom_show,
8292 (void *)&cmd_showeeprom_port,
8293 (void *)&cmd_showeeprom_portnum,
8294 (void *)&cmd_showeeprom_type,
8299 /* *** SHOW QUEUE INFO *** */
8300 struct cmd_showqueue_result {
8301 cmdline_fixed_string_t show;
8302 cmdline_fixed_string_t type;
8303 cmdline_fixed_string_t what;
8309 cmd_showqueue_parsed(void *parsed_result,
8310 __rte_unused struct cmdline *cl,
8311 __rte_unused void *data)
8313 struct cmd_showqueue_result *res = parsed_result;
8315 if (!strcmp(res->type, "rxq"))
8316 rx_queue_infos_display(res->portnum, res->queuenum);
8317 else if (!strcmp(res->type, "txq"))
8318 tx_queue_infos_display(res->portnum, res->queuenum);
8321 cmdline_parse_token_string_t cmd_showqueue_show =
8322 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8323 cmdline_parse_token_string_t cmd_showqueue_type =
8324 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8325 cmdline_parse_token_string_t cmd_showqueue_what =
8326 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8327 cmdline_parse_token_num_t cmd_showqueue_portnum =
8328 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8330 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8331 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8334 cmdline_parse_inst_t cmd_showqueue = {
8335 .f = cmd_showqueue_parsed,
8337 .help_str = "show rxq|txq info <port_id> <queue_id>",
8339 (void *)&cmd_showqueue_show,
8340 (void *)&cmd_showqueue_type,
8341 (void *)&cmd_showqueue_what,
8342 (void *)&cmd_showqueue_portnum,
8343 (void *)&cmd_showqueue_queuenum,
8348 /* show/clear fwd engine statistics */
8350 cmdline_fixed_string_t action;
8351 cmdline_fixed_string_t fwd;
8352 cmdline_fixed_string_t stats;
8353 cmdline_fixed_string_t all;
8356 cmdline_parse_token_string_t cmd_fwd_action =
8357 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8358 cmdline_parse_token_string_t cmd_fwd_fwd =
8359 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8360 cmdline_parse_token_string_t cmd_fwd_stats =
8361 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8362 cmdline_parse_token_string_t cmd_fwd_all =
8363 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8366 cmd_showfwdall_parsed(void *parsed_result,
8367 __rte_unused struct cmdline *cl,
8368 __rte_unused void *data)
8370 struct fwd_result *res = parsed_result;
8372 if (!strcmp(res->action, "show"))
8373 fwd_stats_display();
8378 static cmdline_parse_inst_t cmd_showfwdall = {
8379 .f = cmd_showfwdall_parsed,
8381 .help_str = "show|clear fwd stats all",
8383 (void *)&cmd_fwd_action,
8384 (void *)&cmd_fwd_fwd,
8385 (void *)&cmd_fwd_stats,
8386 (void *)&cmd_fwd_all,
8391 /* *** READ PORT REGISTER *** */
8392 struct cmd_read_reg_result {
8393 cmdline_fixed_string_t read;
8394 cmdline_fixed_string_t reg;
8400 cmd_read_reg_parsed(void *parsed_result,
8401 __rte_unused struct cmdline *cl,
8402 __rte_unused void *data)
8404 struct cmd_read_reg_result *res = parsed_result;
8405 port_reg_display(res->port_id, res->reg_off);
8408 cmdline_parse_token_string_t cmd_read_reg_read =
8409 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8410 cmdline_parse_token_string_t cmd_read_reg_reg =
8411 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8412 cmdline_parse_token_num_t cmd_read_reg_port_id =
8413 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8414 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8415 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8417 cmdline_parse_inst_t cmd_read_reg = {
8418 .f = cmd_read_reg_parsed,
8420 .help_str = "read reg <port_id> <reg_off>",
8422 (void *)&cmd_read_reg_read,
8423 (void *)&cmd_read_reg_reg,
8424 (void *)&cmd_read_reg_port_id,
8425 (void *)&cmd_read_reg_reg_off,
8430 /* *** READ PORT REGISTER BIT FIELD *** */
8431 struct cmd_read_reg_bit_field_result {
8432 cmdline_fixed_string_t read;
8433 cmdline_fixed_string_t regfield;
8441 cmd_read_reg_bit_field_parsed(void *parsed_result,
8442 __rte_unused struct cmdline *cl,
8443 __rte_unused void *data)
8445 struct cmd_read_reg_bit_field_result *res = parsed_result;
8446 port_reg_bit_field_display(res->port_id, res->reg_off,
8447 res->bit1_pos, res->bit2_pos);
8450 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8451 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8453 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8454 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8455 regfield, "regfield");
8456 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8457 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8459 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8460 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8462 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8463 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8465 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8466 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8469 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8470 .f = cmd_read_reg_bit_field_parsed,
8472 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8473 "Read register bit field between bit_x and bit_y included",
8475 (void *)&cmd_read_reg_bit_field_read,
8476 (void *)&cmd_read_reg_bit_field_regfield,
8477 (void *)&cmd_read_reg_bit_field_port_id,
8478 (void *)&cmd_read_reg_bit_field_reg_off,
8479 (void *)&cmd_read_reg_bit_field_bit1_pos,
8480 (void *)&cmd_read_reg_bit_field_bit2_pos,
8485 /* *** READ PORT REGISTER BIT *** */
8486 struct cmd_read_reg_bit_result {
8487 cmdline_fixed_string_t read;
8488 cmdline_fixed_string_t regbit;
8495 cmd_read_reg_bit_parsed(void *parsed_result,
8496 __rte_unused struct cmdline *cl,
8497 __rte_unused void *data)
8499 struct cmd_read_reg_bit_result *res = parsed_result;
8500 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8503 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8504 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8505 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8506 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8508 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8509 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8511 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8512 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8514 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8515 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8518 cmdline_parse_inst_t cmd_read_reg_bit = {
8519 .f = cmd_read_reg_bit_parsed,
8521 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8523 (void *)&cmd_read_reg_bit_read,
8524 (void *)&cmd_read_reg_bit_regbit,
8525 (void *)&cmd_read_reg_bit_port_id,
8526 (void *)&cmd_read_reg_bit_reg_off,
8527 (void *)&cmd_read_reg_bit_bit_pos,
8532 /* *** WRITE PORT REGISTER *** */
8533 struct cmd_write_reg_result {
8534 cmdline_fixed_string_t write;
8535 cmdline_fixed_string_t reg;
8542 cmd_write_reg_parsed(void *parsed_result,
8543 __rte_unused struct cmdline *cl,
8544 __rte_unused void *data)
8546 struct cmd_write_reg_result *res = parsed_result;
8547 port_reg_set(res->port_id, res->reg_off, res->value);
8550 cmdline_parse_token_string_t cmd_write_reg_write =
8551 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8552 cmdline_parse_token_string_t cmd_write_reg_reg =
8553 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8554 cmdline_parse_token_num_t cmd_write_reg_port_id =
8555 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8556 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8557 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8558 cmdline_parse_token_num_t cmd_write_reg_value =
8559 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8561 cmdline_parse_inst_t cmd_write_reg = {
8562 .f = cmd_write_reg_parsed,
8564 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8566 (void *)&cmd_write_reg_write,
8567 (void *)&cmd_write_reg_reg,
8568 (void *)&cmd_write_reg_port_id,
8569 (void *)&cmd_write_reg_reg_off,
8570 (void *)&cmd_write_reg_value,
8575 /* *** WRITE PORT REGISTER BIT FIELD *** */
8576 struct cmd_write_reg_bit_field_result {
8577 cmdline_fixed_string_t write;
8578 cmdline_fixed_string_t regfield;
8587 cmd_write_reg_bit_field_parsed(void *parsed_result,
8588 __rte_unused struct cmdline *cl,
8589 __rte_unused void *data)
8591 struct cmd_write_reg_bit_field_result *res = parsed_result;
8592 port_reg_bit_field_set(res->port_id, res->reg_off,
8593 res->bit1_pos, res->bit2_pos, res->value);
8596 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8597 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8599 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8600 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8601 regfield, "regfield");
8602 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8603 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8605 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8606 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8608 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8609 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8611 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8612 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8614 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8615 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8618 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8619 .f = cmd_write_reg_bit_field_parsed,
8621 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8623 "Set register bit field between bit_x and bit_y included",
8625 (void *)&cmd_write_reg_bit_field_write,
8626 (void *)&cmd_write_reg_bit_field_regfield,
8627 (void *)&cmd_write_reg_bit_field_port_id,
8628 (void *)&cmd_write_reg_bit_field_reg_off,
8629 (void *)&cmd_write_reg_bit_field_bit1_pos,
8630 (void *)&cmd_write_reg_bit_field_bit2_pos,
8631 (void *)&cmd_write_reg_bit_field_value,
8636 /* *** WRITE PORT REGISTER BIT *** */
8637 struct cmd_write_reg_bit_result {
8638 cmdline_fixed_string_t write;
8639 cmdline_fixed_string_t regbit;
8647 cmd_write_reg_bit_parsed(void *parsed_result,
8648 __rte_unused struct cmdline *cl,
8649 __rte_unused void *data)
8651 struct cmd_write_reg_bit_result *res = parsed_result;
8652 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8655 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8656 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8658 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8659 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8661 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8662 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8664 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8665 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8667 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8668 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8670 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8671 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8674 cmdline_parse_inst_t cmd_write_reg_bit = {
8675 .f = cmd_write_reg_bit_parsed,
8677 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8680 (void *)&cmd_write_reg_bit_write,
8681 (void *)&cmd_write_reg_bit_regbit,
8682 (void *)&cmd_write_reg_bit_port_id,
8683 (void *)&cmd_write_reg_bit_reg_off,
8684 (void *)&cmd_write_reg_bit_bit_pos,
8685 (void *)&cmd_write_reg_bit_value,
8690 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8691 struct cmd_read_rxd_txd_result {
8692 cmdline_fixed_string_t read;
8693 cmdline_fixed_string_t rxd_txd;
8700 cmd_read_rxd_txd_parsed(void *parsed_result,
8701 __rte_unused struct cmdline *cl,
8702 __rte_unused void *data)
8704 struct cmd_read_rxd_txd_result *res = parsed_result;
8706 if (!strcmp(res->rxd_txd, "rxd"))
8707 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8708 else if (!strcmp(res->rxd_txd, "txd"))
8709 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8712 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8713 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8714 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8715 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8717 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8718 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8720 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8721 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8723 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8724 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8727 cmdline_parse_inst_t cmd_read_rxd_txd = {
8728 .f = cmd_read_rxd_txd_parsed,
8730 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8732 (void *)&cmd_read_rxd_txd_read,
8733 (void *)&cmd_read_rxd_txd_rxd_txd,
8734 (void *)&cmd_read_rxd_txd_port_id,
8735 (void *)&cmd_read_rxd_txd_queue_id,
8736 (void *)&cmd_read_rxd_txd_desc_id,
8742 struct cmd_quit_result {
8743 cmdline_fixed_string_t quit;
8746 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8748 __rte_unused void *data)
8753 cmdline_parse_token_string_t cmd_quit_quit =
8754 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8756 cmdline_parse_inst_t cmd_quit = {
8757 .f = cmd_quit_parsed,
8759 .help_str = "quit: Exit application",
8761 (void *)&cmd_quit_quit,
8766 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8767 struct cmd_mac_addr_result {
8768 cmdline_fixed_string_t mac_addr_cmd;
8769 cmdline_fixed_string_t what;
8771 struct rte_ether_addr address;
8774 static void cmd_mac_addr_parsed(void *parsed_result,
8775 __rte_unused struct cmdline *cl,
8776 __rte_unused void *data)
8778 struct cmd_mac_addr_result *res = parsed_result;
8781 if (strcmp(res->what, "add") == 0)
8782 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8783 else if (strcmp(res->what, "set") == 0)
8784 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8787 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8789 /* check the return value and print it if is < 0 */
8791 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8795 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8796 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8798 cmdline_parse_token_string_t cmd_mac_addr_what =
8799 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8801 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8802 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8804 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8805 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8807 cmdline_parse_inst_t cmd_mac_addr = {
8808 .f = cmd_mac_addr_parsed,
8810 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8811 "Add/Remove/Set MAC address on port_id",
8813 (void *)&cmd_mac_addr_cmd,
8814 (void *)&cmd_mac_addr_what,
8815 (void *)&cmd_mac_addr_portnum,
8816 (void *)&cmd_mac_addr_addr,
8821 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8822 struct cmd_eth_peer_result {
8823 cmdline_fixed_string_t set;
8824 cmdline_fixed_string_t eth_peer;
8826 cmdline_fixed_string_t peer_addr;
8829 static void cmd_set_eth_peer_parsed(void *parsed_result,
8830 __rte_unused struct cmdline *cl,
8831 __rte_unused void *data)
8833 struct cmd_eth_peer_result *res = parsed_result;
8835 if (test_done == 0) {
8836 fprintf(stderr, "Please stop forwarding first\n");
8839 if (!strcmp(res->eth_peer, "eth-peer")) {
8840 set_fwd_eth_peer(res->port_id, res->peer_addr);
8844 cmdline_parse_token_string_t cmd_eth_peer_set =
8845 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8846 cmdline_parse_token_string_t cmd_eth_peer =
8847 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8848 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8849 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8851 cmdline_parse_token_string_t cmd_eth_peer_addr =
8852 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8854 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8855 .f = cmd_set_eth_peer_parsed,
8857 .help_str = "set eth-peer <port_id> <peer_mac>",
8859 (void *)&cmd_eth_peer_set,
8860 (void *)&cmd_eth_peer,
8861 (void *)&cmd_eth_peer_port_id,
8862 (void *)&cmd_eth_peer_addr,
8867 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8868 struct cmd_set_qmap_result {
8869 cmdline_fixed_string_t set;
8870 cmdline_fixed_string_t qmap;
8871 cmdline_fixed_string_t what;
8878 cmd_set_qmap_parsed(void *parsed_result,
8879 __rte_unused struct cmdline *cl,
8880 __rte_unused void *data)
8882 struct cmd_set_qmap_result *res = parsed_result;
8883 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8885 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8888 cmdline_parse_token_string_t cmd_setqmap_set =
8889 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8891 cmdline_parse_token_string_t cmd_setqmap_qmap =
8892 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8894 cmdline_parse_token_string_t cmd_setqmap_what =
8895 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8897 cmdline_parse_token_num_t cmd_setqmap_portid =
8898 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8899 port_id, RTE_UINT16);
8900 cmdline_parse_token_num_t cmd_setqmap_queueid =
8901 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8902 queue_id, RTE_UINT16);
8903 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8904 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8905 map_value, RTE_UINT8);
8907 cmdline_parse_inst_t cmd_set_qmap = {
8908 .f = cmd_set_qmap_parsed,
8910 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8911 "Set statistics mapping value on tx|rx queue_id of port_id",
8913 (void *)&cmd_setqmap_set,
8914 (void *)&cmd_setqmap_qmap,
8915 (void *)&cmd_setqmap_what,
8916 (void *)&cmd_setqmap_portid,
8917 (void *)&cmd_setqmap_queueid,
8918 (void *)&cmd_setqmap_mapvalue,
8923 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8924 struct cmd_set_xstats_hide_zero_result {
8925 cmdline_fixed_string_t keyword;
8926 cmdline_fixed_string_t name;
8927 cmdline_fixed_string_t on_off;
8931 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8932 __rte_unused struct cmdline *cl,
8933 __rte_unused void *data)
8935 struct cmd_set_xstats_hide_zero_result *res;
8936 uint16_t on_off = 0;
8938 res = parsed_result;
8939 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8940 set_xstats_hide_zero(on_off);
8943 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8944 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8946 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8947 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8948 name, "xstats-hide-zero");
8949 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8950 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8953 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8954 .f = cmd_set_xstats_hide_zero_parsed,
8956 .help_str = "set xstats-hide-zero on|off",
8958 (void *)&cmd_set_xstats_hide_zero_keyword,
8959 (void *)&cmd_set_xstats_hide_zero_name,
8960 (void *)&cmd_set_xstats_hide_zero_on_off,
8965 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8966 struct cmd_set_record_core_cycles_result {
8967 cmdline_fixed_string_t keyword;
8968 cmdline_fixed_string_t name;
8969 cmdline_fixed_string_t on_off;
8973 cmd_set_record_core_cycles_parsed(void *parsed_result,
8974 __rte_unused struct cmdline *cl,
8975 __rte_unused void *data)
8977 struct cmd_set_record_core_cycles_result *res;
8978 uint16_t on_off = 0;
8980 res = parsed_result;
8981 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8982 set_record_core_cycles(on_off);
8985 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8986 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8988 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8989 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8990 name, "record-core-cycles");
8991 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8992 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8995 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8996 .f = cmd_set_record_core_cycles_parsed,
8998 .help_str = "set record-core-cycles on|off",
9000 (void *)&cmd_set_record_core_cycles_keyword,
9001 (void *)&cmd_set_record_core_cycles_name,
9002 (void *)&cmd_set_record_core_cycles_on_off,
9007 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9008 struct cmd_set_record_burst_stats_result {
9009 cmdline_fixed_string_t keyword;
9010 cmdline_fixed_string_t name;
9011 cmdline_fixed_string_t on_off;
9015 cmd_set_record_burst_stats_parsed(void *parsed_result,
9016 __rte_unused struct cmdline *cl,
9017 __rte_unused void *data)
9019 struct cmd_set_record_burst_stats_result *res;
9020 uint16_t on_off = 0;
9022 res = parsed_result;
9023 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9024 set_record_burst_stats(on_off);
9027 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9028 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9030 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9031 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9032 name, "record-burst-stats");
9033 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9034 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9037 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9038 .f = cmd_set_record_burst_stats_parsed,
9040 .help_str = "set record-burst-stats on|off",
9042 (void *)&cmd_set_record_burst_stats_keyword,
9043 (void *)&cmd_set_record_burst_stats_name,
9044 (void *)&cmd_set_record_burst_stats_on_off,
9049 /* *** CONFIGURE UNICAST HASH TABLE *** */
9050 struct cmd_set_uc_hash_table {
9051 cmdline_fixed_string_t set;
9052 cmdline_fixed_string_t port;
9054 cmdline_fixed_string_t what;
9055 struct rte_ether_addr address;
9056 cmdline_fixed_string_t mode;
9060 cmd_set_uc_hash_parsed(void *parsed_result,
9061 __rte_unused struct cmdline *cl,
9062 __rte_unused void *data)
9065 struct cmd_set_uc_hash_table *res = parsed_result;
9067 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9069 if (strcmp(res->what, "uta") == 0)
9070 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9071 &res->address,(uint8_t)is_on);
9074 "bad unicast hash table parameter, return code = %d\n",
9079 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9080 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9082 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9083 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9085 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9086 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9087 port_id, RTE_UINT16);
9088 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9089 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9091 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9092 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9094 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9095 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9098 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9099 .f = cmd_set_uc_hash_parsed,
9101 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9103 (void *)&cmd_set_uc_hash_set,
9104 (void *)&cmd_set_uc_hash_port,
9105 (void *)&cmd_set_uc_hash_portid,
9106 (void *)&cmd_set_uc_hash_what,
9107 (void *)&cmd_set_uc_hash_mac,
9108 (void *)&cmd_set_uc_hash_mode,
9113 struct cmd_set_uc_all_hash_table {
9114 cmdline_fixed_string_t set;
9115 cmdline_fixed_string_t port;
9117 cmdline_fixed_string_t what;
9118 cmdline_fixed_string_t value;
9119 cmdline_fixed_string_t mode;
9123 cmd_set_uc_all_hash_parsed(void *parsed_result,
9124 __rte_unused struct cmdline *cl,
9125 __rte_unused void *data)
9128 struct cmd_set_uc_all_hash_table *res = parsed_result;
9130 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9132 if ((strcmp(res->what, "uta") == 0) &&
9133 (strcmp(res->value, "all") == 0))
9134 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9137 "bad unicast hash table parameter, return code = %d\n",
9141 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9142 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9144 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9145 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9147 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9148 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9149 port_id, RTE_UINT16);
9150 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9151 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9153 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9154 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9156 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9157 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9160 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9161 .f = cmd_set_uc_all_hash_parsed,
9163 .help_str = "set port <port_id> uta all on|off",
9165 (void *)&cmd_set_uc_all_hash_set,
9166 (void *)&cmd_set_uc_all_hash_port,
9167 (void *)&cmd_set_uc_all_hash_portid,
9168 (void *)&cmd_set_uc_all_hash_what,
9169 (void *)&cmd_set_uc_all_hash_value,
9170 (void *)&cmd_set_uc_all_hash_mode,
9175 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9176 struct cmd_set_vf_traffic {
9177 cmdline_fixed_string_t set;
9178 cmdline_fixed_string_t port;
9180 cmdline_fixed_string_t vf;
9182 cmdline_fixed_string_t what;
9183 cmdline_fixed_string_t mode;
9187 cmd_set_vf_traffic_parsed(void *parsed_result,
9188 __rte_unused struct cmdline *cl,
9189 __rte_unused void *data)
9191 struct cmd_set_vf_traffic *res = parsed_result;
9192 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9193 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9195 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9198 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9199 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9201 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9202 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9204 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9205 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9206 port_id, RTE_UINT16);
9207 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9208 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9210 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9211 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9213 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9214 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9216 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9217 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9220 cmdline_parse_inst_t cmd_set_vf_traffic = {
9221 .f = cmd_set_vf_traffic_parsed,
9223 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9225 (void *)&cmd_setvf_traffic_set,
9226 (void *)&cmd_setvf_traffic_port,
9227 (void *)&cmd_setvf_traffic_portid,
9228 (void *)&cmd_setvf_traffic_vf,
9229 (void *)&cmd_setvf_traffic_vfid,
9230 (void *)&cmd_setvf_traffic_what,
9231 (void *)&cmd_setvf_traffic_mode,
9236 /* *** CONFIGURE VF RECEIVE MODE *** */
9237 struct cmd_set_vf_rxmode {
9238 cmdline_fixed_string_t set;
9239 cmdline_fixed_string_t port;
9241 cmdline_fixed_string_t vf;
9243 cmdline_fixed_string_t what;
9244 cmdline_fixed_string_t mode;
9245 cmdline_fixed_string_t on;
9249 cmd_set_vf_rxmode_parsed(void *parsed_result,
9250 __rte_unused struct cmdline *cl,
9251 __rte_unused void *data)
9254 uint16_t vf_rxmode = 0;
9255 struct cmd_set_vf_rxmode *res = parsed_result;
9257 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9258 if (!strcmp(res->what,"rxmode")) {
9259 if (!strcmp(res->mode, "AUPE"))
9260 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
9261 else if (!strcmp(res->mode, "ROPE"))
9262 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
9263 else if (!strcmp(res->mode, "BAM"))
9264 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
9265 else if (!strncmp(res->mode, "MPE",3))
9266 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
9269 RTE_SET_USED(is_on);
9271 #ifdef RTE_NET_IXGBE
9272 if (ret == -ENOTSUP)
9273 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9274 vf_rxmode, (uint8_t)is_on);
9277 if (ret == -ENOTSUP)
9278 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9279 vf_rxmode, (uint8_t)is_on);
9283 "bad VF receive mode parameter, return code = %d\n",
9287 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9288 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9290 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9291 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9293 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9294 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9295 port_id, RTE_UINT16);
9296 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9297 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9299 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9300 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9302 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9303 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9305 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9306 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9307 mode, "AUPE#ROPE#BAM#MPE");
9308 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9309 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9312 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9313 .f = cmd_set_vf_rxmode_parsed,
9315 .help_str = "set port <port_id> vf <vf_id> rxmode "
9316 "AUPE|ROPE|BAM|MPE on|off",
9318 (void *)&cmd_set_vf_rxmode_set,
9319 (void *)&cmd_set_vf_rxmode_port,
9320 (void *)&cmd_set_vf_rxmode_portid,
9321 (void *)&cmd_set_vf_rxmode_vf,
9322 (void *)&cmd_set_vf_rxmode_vfid,
9323 (void *)&cmd_set_vf_rxmode_what,
9324 (void *)&cmd_set_vf_rxmode_mode,
9325 (void *)&cmd_set_vf_rxmode_on,
9330 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9331 struct cmd_vf_mac_addr_result {
9332 cmdline_fixed_string_t mac_addr_cmd;
9333 cmdline_fixed_string_t what;
9334 cmdline_fixed_string_t port;
9336 cmdline_fixed_string_t vf;
9338 struct rte_ether_addr address;
9341 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9342 __rte_unused struct cmdline *cl,
9343 __rte_unused void *data)
9345 struct cmd_vf_mac_addr_result *res = parsed_result;
9348 if (strcmp(res->what, "add") != 0)
9352 if (ret == -ENOTSUP)
9353 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9357 if (ret == -ENOTSUP)
9358 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9363 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9367 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9368 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9369 mac_addr_cmd,"mac_addr");
9370 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9371 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9373 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9374 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9376 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9377 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9378 port_num, RTE_UINT16);
9379 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9380 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9382 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9383 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9385 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9386 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9389 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9390 .f = cmd_vf_mac_addr_parsed,
9392 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9393 "Add MAC address filtering for a VF on port_id",
9395 (void *)&cmd_vf_mac_addr_cmd,
9396 (void *)&cmd_vf_mac_addr_what,
9397 (void *)&cmd_vf_mac_addr_port,
9398 (void *)&cmd_vf_mac_addr_portnum,
9399 (void *)&cmd_vf_mac_addr_vf,
9400 (void *)&cmd_vf_mac_addr_vfnum,
9401 (void *)&cmd_vf_mac_addr_addr,
9406 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9407 struct cmd_vf_rx_vlan_filter {
9408 cmdline_fixed_string_t rx_vlan;
9409 cmdline_fixed_string_t what;
9411 cmdline_fixed_string_t port;
9413 cmdline_fixed_string_t vf;
9418 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9419 __rte_unused struct cmdline *cl,
9420 __rte_unused void *data)
9422 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9425 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9427 #ifdef RTE_NET_IXGBE
9428 if (ret == -ENOTSUP)
9429 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9430 res->vlan_id, res->vf_mask, is_add);
9433 if (ret == -ENOTSUP)
9434 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9435 res->vlan_id, res->vf_mask, is_add);
9438 if (ret == -ENOTSUP)
9439 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9440 res->vlan_id, res->vf_mask, is_add);
9447 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9448 res->vlan_id, res->vf_mask);
9451 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9454 fprintf(stderr, "function not implemented or supported\n");
9457 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9461 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9462 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9463 rx_vlan, "rx_vlan");
9464 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9465 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9467 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9468 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9469 vlan_id, RTE_UINT16);
9470 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9471 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9473 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9474 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9475 port_id, RTE_UINT16);
9476 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9477 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9479 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9480 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9481 vf_mask, RTE_UINT64);
9483 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9484 .f = cmd_vf_rx_vlan_filter_parsed,
9486 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9487 "(vf_mask = hexadecimal VF mask)",
9489 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9490 (void *)&cmd_vf_rx_vlan_filter_what,
9491 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9492 (void *)&cmd_vf_rx_vlan_filter_port,
9493 (void *)&cmd_vf_rx_vlan_filter_portid,
9494 (void *)&cmd_vf_rx_vlan_filter_vf,
9495 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9500 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9501 struct cmd_queue_rate_limit_result {
9502 cmdline_fixed_string_t set;
9503 cmdline_fixed_string_t port;
9505 cmdline_fixed_string_t queue;
9507 cmdline_fixed_string_t rate;
9511 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9512 __rte_unused struct cmdline *cl,
9513 __rte_unused void *data)
9515 struct cmd_queue_rate_limit_result *res = parsed_result;
9518 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9519 && (strcmp(res->queue, "queue") == 0)
9520 && (strcmp(res->rate, "rate") == 0))
9521 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9524 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9529 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9530 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9532 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9533 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9535 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9536 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9537 port_num, RTE_UINT16);
9538 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9539 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9541 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9542 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9543 queue_num, RTE_UINT8);
9544 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9545 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9547 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9548 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9549 rate_num, RTE_UINT16);
9551 cmdline_parse_inst_t cmd_queue_rate_limit = {
9552 .f = cmd_queue_rate_limit_parsed,
9554 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9555 "Set rate limit for a queue on port_id",
9557 (void *)&cmd_queue_rate_limit_set,
9558 (void *)&cmd_queue_rate_limit_port,
9559 (void *)&cmd_queue_rate_limit_portnum,
9560 (void *)&cmd_queue_rate_limit_queue,
9561 (void *)&cmd_queue_rate_limit_queuenum,
9562 (void *)&cmd_queue_rate_limit_rate,
9563 (void *)&cmd_queue_rate_limit_ratenum,
9568 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9569 struct cmd_vf_rate_limit_result {
9570 cmdline_fixed_string_t set;
9571 cmdline_fixed_string_t port;
9573 cmdline_fixed_string_t vf;
9575 cmdline_fixed_string_t rate;
9577 cmdline_fixed_string_t q_msk;
9581 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9582 __rte_unused struct cmdline *cl,
9583 __rte_unused void *data)
9585 struct cmd_vf_rate_limit_result *res = parsed_result;
9588 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9589 && (strcmp(res->vf, "vf") == 0)
9590 && (strcmp(res->rate, "rate") == 0)
9591 && (strcmp(res->q_msk, "queue_mask") == 0))
9592 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9593 res->rate_num, res->q_msk_val);
9595 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9600 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9601 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9603 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9604 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9606 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9607 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9608 port_num, RTE_UINT16);
9609 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9610 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9612 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9613 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9615 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9616 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9618 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9619 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9620 rate_num, RTE_UINT16);
9621 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9622 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9623 q_msk, "queue_mask");
9624 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9625 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9626 q_msk_val, RTE_UINT64);
9628 cmdline_parse_inst_t cmd_vf_rate_limit = {
9629 .f = cmd_vf_rate_limit_parsed,
9631 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9632 "queue_mask <queue_mask_value>: "
9633 "Set rate limit for queues of VF on port_id",
9635 (void *)&cmd_vf_rate_limit_set,
9636 (void *)&cmd_vf_rate_limit_port,
9637 (void *)&cmd_vf_rate_limit_portnum,
9638 (void *)&cmd_vf_rate_limit_vf,
9639 (void *)&cmd_vf_rate_limit_vfnum,
9640 (void *)&cmd_vf_rate_limit_rate,
9641 (void *)&cmd_vf_rate_limit_ratenum,
9642 (void *)&cmd_vf_rate_limit_q_msk,
9643 (void *)&cmd_vf_rate_limit_q_msk_val,
9648 /* *** CONFIGURE TUNNEL UDP PORT *** */
9649 struct cmd_tunnel_udp_config {
9650 cmdline_fixed_string_t rx_vxlan_port;
9651 cmdline_fixed_string_t what;
9657 cmd_tunnel_udp_config_parsed(void *parsed_result,
9658 __rte_unused struct cmdline *cl,
9659 __rte_unused void *data)
9661 struct cmd_tunnel_udp_config *res = parsed_result;
9662 struct rte_eth_udp_tunnel tunnel_udp;
9665 tunnel_udp.udp_port = res->udp_port;
9666 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9668 if (!strcmp(res->what, "add"))
9669 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9672 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9676 fprintf(stderr, "udp tunneling add error: (%s)\n",
9680 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9681 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9682 rx_vxlan_port, "rx_vxlan_port");
9683 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9684 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9686 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9687 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9688 udp_port, RTE_UINT16);
9689 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9690 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9691 port_id, RTE_UINT16);
9693 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9694 .f = cmd_tunnel_udp_config_parsed,
9696 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9697 "Add/Remove a tunneling UDP port filter",
9699 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9700 (void *)&cmd_tunnel_udp_config_what,
9701 (void *)&cmd_tunnel_udp_config_udp_port,
9702 (void *)&cmd_tunnel_udp_config_port_id,
9707 struct cmd_config_tunnel_udp_port {
9708 cmdline_fixed_string_t port;
9709 cmdline_fixed_string_t config;
9711 cmdline_fixed_string_t udp_tunnel_port;
9712 cmdline_fixed_string_t action;
9713 cmdline_fixed_string_t tunnel_type;
9718 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9719 __rte_unused struct cmdline *cl,
9720 __rte_unused void *data)
9722 struct cmd_config_tunnel_udp_port *res = parsed_result;
9723 struct rte_eth_udp_tunnel tunnel_udp;
9726 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9729 tunnel_udp.udp_port = res->udp_port;
9731 if (!strcmp(res->tunnel_type, "vxlan")) {
9732 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9733 } else if (!strcmp(res->tunnel_type, "geneve")) {
9734 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9735 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9736 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9737 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9738 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9740 fprintf(stderr, "Invalid tunnel type\n");
9744 if (!strcmp(res->action, "add"))
9745 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9748 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9752 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9756 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9757 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9759 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9760 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9762 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9763 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9765 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9766 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9769 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9770 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9772 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9773 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9774 "vxlan#geneve#vxlan-gpe#ecpri");
9775 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9776 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9779 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9780 .f = cmd_cfg_tunnel_udp_port_parsed,
9782 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9783 "geneve|vxlan-gpe|ecpri <udp_port>",
9785 (void *)&cmd_config_tunnel_udp_port_port,
9786 (void *)&cmd_config_tunnel_udp_port_config,
9787 (void *)&cmd_config_tunnel_udp_port_port_id,
9788 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9789 (void *)&cmd_config_tunnel_udp_port_action,
9790 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9791 (void *)&cmd_config_tunnel_udp_port_value,
9796 /* ******************************************************************************** */
9798 struct cmd_dump_result {
9799 cmdline_fixed_string_t dump;
9803 dump_struct_sizes(void)
9805 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9806 DUMP_SIZE(struct rte_mbuf);
9807 DUMP_SIZE(struct rte_mempool);
9808 DUMP_SIZE(struct rte_ring);
9813 /* Dump the socket memory statistics on console */
9815 dump_socket_mem(FILE *f)
9817 struct rte_malloc_socket_stats socket_stats;
9822 unsigned int n_alloc = 0;
9823 unsigned int n_free = 0;
9824 static size_t last_allocs;
9825 static size_t last_total;
9828 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9829 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9830 !socket_stats.heap_totalsz_bytes)
9832 total += socket_stats.heap_totalsz_bytes;
9833 alloc += socket_stats.heap_allocsz_bytes;
9834 free += socket_stats.heap_freesz_bytes;
9835 n_alloc += socket_stats.alloc_count;
9836 n_free += socket_stats.free_count;
9838 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9840 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9841 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9842 (double)socket_stats.heap_allocsz_bytes * 100 /
9843 (double)socket_stats.heap_totalsz_bytes,
9844 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9845 socket_stats.alloc_count,
9846 socket_stats.free_count);
9849 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9850 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9851 total ? ((double)alloc * 100 / (double)total) : 0,
9852 (double)free / (1024 * 1024),
9855 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9856 ((double)total - (double)last_total) / (1024 * 1024),
9857 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9858 last_allocs = alloc;
9862 static void cmd_dump_parsed(void *parsed_result,
9863 __rte_unused struct cmdline *cl,
9864 __rte_unused void *data)
9866 struct cmd_dump_result *res = parsed_result;
9868 if (!strcmp(res->dump, "dump_physmem"))
9869 rte_dump_physmem_layout(stdout);
9870 else if (!strcmp(res->dump, "dump_socket_mem"))
9871 dump_socket_mem(stdout);
9872 else if (!strcmp(res->dump, "dump_memzone"))
9873 rte_memzone_dump(stdout);
9874 else if (!strcmp(res->dump, "dump_struct_sizes"))
9875 dump_struct_sizes();
9876 else if (!strcmp(res->dump, "dump_ring"))
9877 rte_ring_list_dump(stdout);
9878 else if (!strcmp(res->dump, "dump_mempool"))
9879 rte_mempool_list_dump(stdout);
9880 else if (!strcmp(res->dump, "dump_devargs"))
9881 rte_devargs_dump(stdout);
9882 else if (!strcmp(res->dump, "dump_log_types"))
9883 rte_log_dump(stdout);
9886 cmdline_parse_token_string_t cmd_dump_dump =
9887 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9891 "dump_struct_sizes#"
9897 cmdline_parse_inst_t cmd_dump = {
9898 .f = cmd_dump_parsed, /* function to call */
9899 .data = NULL, /* 2nd arg of func */
9900 .help_str = "Dump status",
9901 .tokens = { /* token list, NULL terminated */
9902 (void *)&cmd_dump_dump,
9907 /* ******************************************************************************** */
9909 struct cmd_dump_one_result {
9910 cmdline_fixed_string_t dump;
9911 cmdline_fixed_string_t name;
9914 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9915 __rte_unused void *data)
9917 struct cmd_dump_one_result *res = parsed_result;
9919 if (!strcmp(res->dump, "dump_ring")) {
9921 r = rte_ring_lookup(res->name);
9923 cmdline_printf(cl, "Cannot find ring\n");
9926 rte_ring_dump(stdout, r);
9927 } else if (!strcmp(res->dump, "dump_mempool")) {
9928 struct rte_mempool *mp;
9929 mp = rte_mempool_lookup(res->name);
9931 cmdline_printf(cl, "Cannot find mempool\n");
9934 rte_mempool_dump(stdout, mp);
9938 cmdline_parse_token_string_t cmd_dump_one_dump =
9939 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9940 "dump_ring#dump_mempool");
9942 cmdline_parse_token_string_t cmd_dump_one_name =
9943 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9945 cmdline_parse_inst_t cmd_dump_one = {
9946 .f = cmd_dump_one_parsed, /* function to call */
9947 .data = NULL, /* 2nd arg of func */
9948 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9949 .tokens = { /* token list, NULL terminated */
9950 (void *)&cmd_dump_one_dump,
9951 (void *)&cmd_dump_one_name,
9956 /* *** queue region set *** */
9957 struct cmd_queue_region_result {
9958 cmdline_fixed_string_t set;
9959 cmdline_fixed_string_t port;
9961 cmdline_fixed_string_t cmd;
9962 cmdline_fixed_string_t region;
9964 cmdline_fixed_string_t queue_start_index;
9966 cmdline_fixed_string_t queue_num;
9967 uint8_t queue_num_value;
9971 cmd_queue_region_parsed(void *parsed_result,
9972 __rte_unused struct cmdline *cl,
9973 __rte_unused void *data)
9975 struct cmd_queue_region_result *res = parsed_result;
9978 struct rte_pmd_i40e_queue_region_conf region_conf;
9979 enum rte_pmd_i40e_queue_region_op op_type;
9982 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9986 memset(®ion_conf, 0, sizeof(region_conf));
9987 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9988 region_conf.region_id = res->region_id;
9989 region_conf.queue_num = res->queue_num_value;
9990 region_conf.queue_start_index = res->queue_id;
9992 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9993 op_type, ®ion_conf);
10000 fprintf(stderr, "function not implemented or supported\n");
10003 fprintf(stderr, "queue region config error: (%s)\n",
10008 cmdline_parse_token_string_t cmd_queue_region_set =
10009 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10011 cmdline_parse_token_string_t cmd_queue_region_port =
10012 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10013 cmdline_parse_token_num_t cmd_queue_region_port_id =
10014 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10015 port_id, RTE_UINT16);
10016 cmdline_parse_token_string_t cmd_queue_region_cmd =
10017 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10018 cmd, "queue-region");
10019 cmdline_parse_token_string_t cmd_queue_region_id =
10020 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10021 region, "region_id");
10022 cmdline_parse_token_num_t cmd_queue_region_index =
10023 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10024 region_id, RTE_UINT8);
10025 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10026 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10027 queue_start_index, "queue_start_index");
10028 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10029 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10030 queue_id, RTE_UINT8);
10031 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10032 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10033 queue_num, "queue_num");
10034 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10035 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10036 queue_num_value, RTE_UINT8);
10038 cmdline_parse_inst_t cmd_queue_region = {
10039 .f = cmd_queue_region_parsed,
10041 .help_str = "set port <port_id> queue-region region_id <value> "
10042 "queue_start_index <value> queue_num <value>: Set a queue region",
10044 (void *)&cmd_queue_region_set,
10045 (void *)&cmd_queue_region_port,
10046 (void *)&cmd_queue_region_port_id,
10047 (void *)&cmd_queue_region_cmd,
10048 (void *)&cmd_queue_region_id,
10049 (void *)&cmd_queue_region_index,
10050 (void *)&cmd_queue_region_queue_start_index,
10051 (void *)&cmd_queue_region_queue_id,
10052 (void *)&cmd_queue_region_queue_num,
10053 (void *)&cmd_queue_region_queue_num_value,
10058 /* *** queue region and flowtype set *** */
10059 struct cmd_region_flowtype_result {
10060 cmdline_fixed_string_t set;
10061 cmdline_fixed_string_t port;
10063 cmdline_fixed_string_t cmd;
10064 cmdline_fixed_string_t region;
10066 cmdline_fixed_string_t flowtype;
10067 uint8_t flowtype_id;
10071 cmd_region_flowtype_parsed(void *parsed_result,
10072 __rte_unused struct cmdline *cl,
10073 __rte_unused void *data)
10075 struct cmd_region_flowtype_result *res = parsed_result;
10076 int ret = -ENOTSUP;
10077 #ifdef RTE_NET_I40E
10078 struct rte_pmd_i40e_queue_region_conf region_conf;
10079 enum rte_pmd_i40e_queue_region_op op_type;
10082 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10085 #ifdef RTE_NET_I40E
10086 memset(®ion_conf, 0, sizeof(region_conf));
10088 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10089 region_conf.region_id = res->region_id;
10090 region_conf.hw_flowtype = res->flowtype_id;
10092 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10093 op_type, ®ion_conf);
10100 fprintf(stderr, "function not implemented or supported\n");
10103 fprintf(stderr, "region flowtype config error: (%s)\n",
10108 cmdline_parse_token_string_t cmd_region_flowtype_set =
10109 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10111 cmdline_parse_token_string_t cmd_region_flowtype_port =
10112 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10114 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10115 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10116 port_id, RTE_UINT16);
10117 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10118 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10119 cmd, "queue-region");
10120 cmdline_parse_token_string_t cmd_region_flowtype_index =
10121 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10122 region, "region_id");
10123 cmdline_parse_token_num_t cmd_region_flowtype_id =
10124 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10125 region_id, RTE_UINT8);
10126 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10127 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10128 flowtype, "flowtype");
10129 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10130 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10131 flowtype_id, RTE_UINT8);
10132 cmdline_parse_inst_t cmd_region_flowtype = {
10133 .f = cmd_region_flowtype_parsed,
10135 .help_str = "set port <port_id> queue-region region_id <value> "
10136 "flowtype <value>: Set a flowtype region index",
10138 (void *)&cmd_region_flowtype_set,
10139 (void *)&cmd_region_flowtype_port,
10140 (void *)&cmd_region_flowtype_port_index,
10141 (void *)&cmd_region_flowtype_cmd,
10142 (void *)&cmd_region_flowtype_index,
10143 (void *)&cmd_region_flowtype_id,
10144 (void *)&cmd_region_flowtype_flow_index,
10145 (void *)&cmd_region_flowtype_flow_id,
10150 /* *** User Priority (UP) to queue region (region_id) set *** */
10151 struct cmd_user_priority_region_result {
10152 cmdline_fixed_string_t set;
10153 cmdline_fixed_string_t port;
10155 cmdline_fixed_string_t cmd;
10156 cmdline_fixed_string_t user_priority;
10157 uint8_t user_priority_id;
10158 cmdline_fixed_string_t region;
10163 cmd_user_priority_region_parsed(void *parsed_result,
10164 __rte_unused struct cmdline *cl,
10165 __rte_unused void *data)
10167 struct cmd_user_priority_region_result *res = parsed_result;
10168 int ret = -ENOTSUP;
10169 #ifdef RTE_NET_I40E
10170 struct rte_pmd_i40e_queue_region_conf region_conf;
10171 enum rte_pmd_i40e_queue_region_op op_type;
10174 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10177 #ifdef RTE_NET_I40E
10178 memset(®ion_conf, 0, sizeof(region_conf));
10179 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10180 region_conf.user_priority = res->user_priority_id;
10181 region_conf.region_id = res->region_id;
10183 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10184 op_type, ®ion_conf);
10191 fprintf(stderr, "function not implemented or supported\n");
10194 fprintf(stderr, "user_priority region config error: (%s)\n",
10199 cmdline_parse_token_string_t cmd_user_priority_region_set =
10200 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10202 cmdline_parse_token_string_t cmd_user_priority_region_port =
10203 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10205 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10206 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10207 port_id, RTE_UINT16);
10208 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10209 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10210 cmd, "queue-region");
10211 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10212 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10213 user_priority, "UP");
10214 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10215 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10216 user_priority_id, RTE_UINT8);
10217 cmdline_parse_token_string_t cmd_user_priority_region_region =
10218 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10219 region, "region_id");
10220 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10221 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10222 region_id, RTE_UINT8);
10224 cmdline_parse_inst_t cmd_user_priority_region = {
10225 .f = cmd_user_priority_region_parsed,
10227 .help_str = "set port <port_id> queue-region UP <value> "
10228 "region_id <value>: Set the mapping of User Priority (UP) "
10229 "to queue region (region_id) ",
10231 (void *)&cmd_user_priority_region_set,
10232 (void *)&cmd_user_priority_region_port,
10233 (void *)&cmd_user_priority_region_port_index,
10234 (void *)&cmd_user_priority_region_cmd,
10235 (void *)&cmd_user_priority_region_UP,
10236 (void *)&cmd_user_priority_region_UP_id,
10237 (void *)&cmd_user_priority_region_region,
10238 (void *)&cmd_user_priority_region_region_id,
10243 /* *** flush all queue region related configuration *** */
10244 struct cmd_flush_queue_region_result {
10245 cmdline_fixed_string_t set;
10246 cmdline_fixed_string_t port;
10248 cmdline_fixed_string_t cmd;
10249 cmdline_fixed_string_t flush;
10250 cmdline_fixed_string_t what;
10254 cmd_flush_queue_region_parsed(void *parsed_result,
10255 __rte_unused struct cmdline *cl,
10256 __rte_unused void *data)
10258 struct cmd_flush_queue_region_result *res = parsed_result;
10259 int ret = -ENOTSUP;
10260 #ifdef RTE_NET_I40E
10261 struct rte_pmd_i40e_queue_region_conf region_conf;
10262 enum rte_pmd_i40e_queue_region_op op_type;
10265 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10268 #ifdef RTE_NET_I40E
10269 memset(®ion_conf, 0, sizeof(region_conf));
10271 if (strcmp(res->what, "on") == 0)
10272 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10274 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10276 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10277 op_type, ®ion_conf);
10284 fprintf(stderr, "function not implemented or supported\n");
10287 fprintf(stderr, "queue region config flush error: (%s)\n",
10292 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10293 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10295 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10296 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10298 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10299 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10300 port_id, RTE_UINT16);
10301 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10302 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10303 cmd, "queue-region");
10304 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10305 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10307 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10308 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10311 cmdline_parse_inst_t cmd_flush_queue_region = {
10312 .f = cmd_flush_queue_region_parsed,
10314 .help_str = "set port <port_id> queue-region flush on|off"
10315 ": flush all queue region related configuration",
10317 (void *)&cmd_flush_queue_region_set,
10318 (void *)&cmd_flush_queue_region_port,
10319 (void *)&cmd_flush_queue_region_port_index,
10320 (void *)&cmd_flush_queue_region_cmd,
10321 (void *)&cmd_flush_queue_region_flush,
10322 (void *)&cmd_flush_queue_region_what,
10327 /* *** get all queue region related configuration info *** */
10328 struct cmd_show_queue_region_info {
10329 cmdline_fixed_string_t show;
10330 cmdline_fixed_string_t port;
10332 cmdline_fixed_string_t cmd;
10336 cmd_show_queue_region_info_parsed(void *parsed_result,
10337 __rte_unused struct cmdline *cl,
10338 __rte_unused void *data)
10340 struct cmd_show_queue_region_info *res = parsed_result;
10341 int ret = -ENOTSUP;
10342 #ifdef RTE_NET_I40E
10343 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10344 enum rte_pmd_i40e_queue_region_op op_type;
10347 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10350 #ifdef RTE_NET_I40E
10351 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10353 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10355 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10356 op_type, &rte_pmd_regions);
10358 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10365 fprintf(stderr, "function not implemented or supported\n");
10368 fprintf(stderr, "queue region config info show error: (%s)\n",
10373 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10374 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10376 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10377 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10379 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10380 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10381 port_id, RTE_UINT16);
10382 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10383 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10384 cmd, "queue-region");
10386 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10387 .f = cmd_show_queue_region_info_parsed,
10389 .help_str = "show port <port_id> queue-region"
10390 ": show all queue region related configuration info",
10392 (void *)&cmd_show_queue_region_info_get,
10393 (void *)&cmd_show_queue_region_info_port,
10394 (void *)&cmd_show_queue_region_info_port_index,
10395 (void *)&cmd_show_queue_region_info_cmd,
10400 /* *** Filters Control *** */
10402 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10404 if ((ip_addr).family == AF_INET) \
10405 (ip) = (ip_addr).addr.ipv4.s_addr; \
10407 fprintf(stderr, "invalid parameter.\n"); \
10412 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10414 if ((ip_addr).family == AF_INET6) \
10415 rte_memcpy(&(ip), \
10416 &((ip_addr).addr.ipv6), \
10417 sizeof(struct in6_addr)); \
10419 fprintf(stderr, "invalid parameter.\n"); \
10424 #ifdef RTE_NET_I40E
10427 str2flowtype(char *string)
10430 static const struct {
10433 } flowtype_str[] = {
10434 {"raw", RTE_ETH_FLOW_RAW},
10435 {"ipv4", RTE_ETH_FLOW_IPV4},
10436 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10437 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10438 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10439 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10440 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10441 {"ipv6", RTE_ETH_FLOW_IPV6},
10442 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10443 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10444 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10445 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10446 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10447 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10450 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10451 if (!strcmp(flowtype_str[i].str, string))
10452 return flowtype_str[i].type;
10455 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10456 return (uint16_t)atoi(string);
10458 return RTE_ETH_FLOW_UNKNOWN;
10461 /* *** deal with flow director filter *** */
10462 struct cmd_flow_director_result {
10463 cmdline_fixed_string_t flow_director_filter;
10465 cmdline_fixed_string_t mode;
10466 cmdline_fixed_string_t mode_value;
10467 cmdline_fixed_string_t ops;
10468 cmdline_fixed_string_t flow;
10469 cmdline_fixed_string_t flow_type;
10470 cmdline_fixed_string_t drop;
10471 cmdline_fixed_string_t queue;
10473 cmdline_fixed_string_t fd_id;
10474 uint32_t fd_id_value;
10475 cmdline_fixed_string_t packet;
10480 cmd_flow_director_filter_parsed(void *parsed_result,
10481 __rte_unused struct cmdline *cl,
10482 __rte_unused void *data)
10484 struct cmd_flow_director_result *res = parsed_result;
10486 struct rte_pmd_i40e_flow_type_mapping
10487 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10488 struct rte_pmd_i40e_pkt_template_conf conf;
10489 uint16_t flow_type = str2flowtype(res->flow_type);
10490 uint16_t i, port = res->port_id;
10493 memset(&conf, 0, sizeof(conf));
10495 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10496 fprintf(stderr, "Invalid flow type specified.\n");
10499 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10503 if (mapping[flow_type].pctype == 0ULL) {
10504 fprintf(stderr, "Invalid flow type specified.\n");
10507 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10508 if (mapping[flow_type].pctype & (1ULL << i)) {
10509 conf.input.pctype = i;
10514 conf.input.packet = open_file(res->filepath,
10515 &conf.input.length);
10516 if (!conf.input.packet)
10518 if (!strcmp(res->drop, "drop"))
10519 conf.action.behavior =
10520 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10522 conf.action.behavior =
10523 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10524 conf.action.report_status =
10525 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10526 conf.action.rx_queue = res->queue_id;
10527 conf.soft_id = res->fd_id_value;
10528 add = strcmp(res->ops, "del") ? 1 : 0;
10529 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10533 fprintf(stderr, "flow director config error: (%s)\n",
10535 close_file(conf.input.packet);
10538 cmdline_parse_token_string_t cmd_flow_director_filter =
10539 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10540 flow_director_filter, "flow_director_filter");
10541 cmdline_parse_token_num_t cmd_flow_director_port_id =
10542 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10543 port_id, RTE_UINT16);
10544 cmdline_parse_token_string_t cmd_flow_director_ops =
10545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10546 ops, "add#del#update");
10547 cmdline_parse_token_string_t cmd_flow_director_flow =
10548 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10550 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10551 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10553 cmdline_parse_token_string_t cmd_flow_director_drop =
10554 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10556 cmdline_parse_token_string_t cmd_flow_director_queue =
10557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10559 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10560 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10561 queue_id, RTE_UINT16);
10562 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10565 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10566 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10567 fd_id_value, RTE_UINT32);
10569 cmdline_parse_token_string_t cmd_flow_director_mode =
10570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10572 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10574 mode_value, "raw");
10575 cmdline_parse_token_string_t cmd_flow_director_packet =
10576 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10578 cmdline_parse_token_string_t cmd_flow_director_filepath =
10579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10582 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10583 .f = cmd_flow_director_filter_parsed,
10585 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10586 "director entry on NIC",
10588 (void *)&cmd_flow_director_filter,
10589 (void *)&cmd_flow_director_port_id,
10590 (void *)&cmd_flow_director_mode,
10591 (void *)&cmd_flow_director_mode_raw,
10592 (void *)&cmd_flow_director_ops,
10593 (void *)&cmd_flow_director_flow,
10594 (void *)&cmd_flow_director_flow_type,
10595 (void *)&cmd_flow_director_drop,
10596 (void *)&cmd_flow_director_queue,
10597 (void *)&cmd_flow_director_queue_id,
10598 (void *)&cmd_flow_director_fd_id,
10599 (void *)&cmd_flow_director_fd_id_value,
10600 (void *)&cmd_flow_director_packet,
10601 (void *)&cmd_flow_director_filepath,
10606 #endif /* RTE_NET_I40E */
10608 /* *** deal with flow director mask *** */
10609 struct cmd_flow_director_mask_result {
10610 cmdline_fixed_string_t flow_director_mask;
10612 cmdline_fixed_string_t mode;
10613 cmdline_fixed_string_t mode_value;
10614 cmdline_fixed_string_t vlan;
10615 uint16_t vlan_mask;
10616 cmdline_fixed_string_t src_mask;
10617 cmdline_ipaddr_t ipv4_src;
10618 cmdline_ipaddr_t ipv6_src;
10620 cmdline_fixed_string_t dst_mask;
10621 cmdline_ipaddr_t ipv4_dst;
10622 cmdline_ipaddr_t ipv6_dst;
10624 cmdline_fixed_string_t mac;
10625 uint8_t mac_addr_byte_mask;
10626 cmdline_fixed_string_t tunnel_id;
10627 uint32_t tunnel_id_mask;
10628 cmdline_fixed_string_t tunnel_type;
10629 uint8_t tunnel_type_mask;
10633 cmd_flow_director_mask_parsed(void *parsed_result,
10634 __rte_unused struct cmdline *cl,
10635 __rte_unused void *data)
10637 struct cmd_flow_director_mask_result *res = parsed_result;
10638 struct rte_eth_fdir_masks *mask;
10639 struct rte_port *port;
10641 port = &ports[res->port_id];
10642 /** Check if the port is not started **/
10643 if (port->port_status != RTE_PORT_STOPPED) {
10644 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10648 mask = &port->dev_conf.fdir_conf.mask;
10650 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10651 if (strcmp(res->mode_value, "MAC-VLAN")) {
10652 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10656 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10657 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10658 if (strcmp(res->mode_value, "Tunnel")) {
10659 fprintf(stderr, "Please set mode to Tunnel.\n");
10663 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10664 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10665 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10666 mask->tunnel_type_mask = res->tunnel_type_mask;
10668 if (strcmp(res->mode_value, "IP")) {
10669 fprintf(stderr, "Please set mode to IP.\n");
10673 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10674 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10675 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10676 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10677 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10678 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10679 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10682 cmd_reconfig_device_queue(res->port_id, 1, 1);
10685 cmdline_parse_token_string_t cmd_flow_director_mask =
10686 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10687 flow_director_mask, "flow_director_mask");
10688 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10689 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10690 port_id, RTE_UINT16);
10691 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10692 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10694 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10695 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10696 vlan_mask, RTE_UINT16);
10697 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10698 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10699 src_mask, "src_mask");
10700 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10701 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10703 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10704 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10706 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10707 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10708 port_src, RTE_UINT16);
10709 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10710 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10711 dst_mask, "dst_mask");
10712 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10713 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10715 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10716 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10718 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10719 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10720 port_dst, RTE_UINT16);
10722 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10723 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10725 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10726 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10728 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10730 mode_value, "MAC-VLAN");
10731 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10732 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10733 mode_value, "Tunnel");
10734 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10735 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10737 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10738 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10739 mac_addr_byte_mask, RTE_UINT8);
10740 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10741 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10742 tunnel_type, "tunnel-type");
10743 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10744 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10745 tunnel_type_mask, RTE_UINT8);
10746 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10747 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10748 tunnel_id, "tunnel-id");
10749 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10750 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10751 tunnel_id_mask, RTE_UINT32);
10753 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10754 .f = cmd_flow_director_mask_parsed,
10756 .help_str = "flow_director_mask ... : "
10757 "Set IP mode flow director's mask on NIC",
10759 (void *)&cmd_flow_director_mask,
10760 (void *)&cmd_flow_director_mask_port_id,
10761 (void *)&cmd_flow_director_mask_mode,
10762 (void *)&cmd_flow_director_mask_mode_ip,
10763 (void *)&cmd_flow_director_mask_vlan,
10764 (void *)&cmd_flow_director_mask_vlan_value,
10765 (void *)&cmd_flow_director_mask_src,
10766 (void *)&cmd_flow_director_mask_ipv4_src,
10767 (void *)&cmd_flow_director_mask_ipv6_src,
10768 (void *)&cmd_flow_director_mask_port_src,
10769 (void *)&cmd_flow_director_mask_dst,
10770 (void *)&cmd_flow_director_mask_ipv4_dst,
10771 (void *)&cmd_flow_director_mask_ipv6_dst,
10772 (void *)&cmd_flow_director_mask_port_dst,
10777 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10778 .f = cmd_flow_director_mask_parsed,
10780 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10781 "flow director's mask on NIC",
10783 (void *)&cmd_flow_director_mask,
10784 (void *)&cmd_flow_director_mask_port_id,
10785 (void *)&cmd_flow_director_mask_mode,
10786 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10787 (void *)&cmd_flow_director_mask_vlan,
10788 (void *)&cmd_flow_director_mask_vlan_value,
10793 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10794 .f = cmd_flow_director_mask_parsed,
10796 .help_str = "flow_director_mask ... : Set tunnel mode "
10797 "flow director's mask on NIC",
10799 (void *)&cmd_flow_director_mask,
10800 (void *)&cmd_flow_director_mask_port_id,
10801 (void *)&cmd_flow_director_mask_mode,
10802 (void *)&cmd_flow_director_mask_mode_tunnel,
10803 (void *)&cmd_flow_director_mask_vlan,
10804 (void *)&cmd_flow_director_mask_vlan_value,
10805 (void *)&cmd_flow_director_mask_mac,
10806 (void *)&cmd_flow_director_mask_mac_value,
10807 (void *)&cmd_flow_director_mask_tunnel_type,
10808 (void *)&cmd_flow_director_mask_tunnel_type_value,
10809 (void *)&cmd_flow_director_mask_tunnel_id,
10810 (void *)&cmd_flow_director_mask_tunnel_id_value,
10815 /* *** deal with flow director flexible payload configuration *** */
10816 struct cmd_flow_director_flexpayload_result {
10817 cmdline_fixed_string_t flow_director_flexpayload;
10819 cmdline_fixed_string_t payload_layer;
10820 cmdline_fixed_string_t payload_cfg;
10824 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10827 const char *p, *p0 = q_arg;
10829 unsigned long int_fld;
10830 char *str_fld[max_num];
10835 p = strchr(p0, '(');
10839 p0 = strchr(p, ')');
10844 if (size >= sizeof(s))
10847 snprintf(s, sizeof(s), "%.*s", size, p);
10848 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10849 if (ret < 0 || ret > max_num)
10851 for (i = 0; i < ret; i++) {
10853 int_fld = strtoul(str_fld[i], &end, 0);
10854 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10856 offsets[i] = (uint16_t)int_fld;
10862 cmd_flow_director_flxpld_parsed(void *parsed_result,
10863 __rte_unused struct cmdline *cl,
10864 __rte_unused void *data)
10866 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10867 struct rte_eth_flex_payload_cfg flex_cfg;
10868 struct rte_port *port;
10871 port = &ports[res->port_id];
10872 /** Check if the port is not started **/
10873 if (port->port_status != RTE_PORT_STOPPED) {
10874 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10878 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10880 if (!strcmp(res->payload_layer, "raw"))
10881 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10882 else if (!strcmp(res->payload_layer, "l2"))
10883 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10884 else if (!strcmp(res->payload_layer, "l3"))
10885 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10886 else if (!strcmp(res->payload_layer, "l4"))
10887 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10889 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10890 RTE_ETH_FDIR_MAX_FLEXLEN);
10892 fprintf(stderr, "error: Cannot parse flex payload input.\n");
10896 fdir_set_flex_payload(res->port_id, &flex_cfg);
10897 cmd_reconfig_device_queue(res->port_id, 1, 1);
10900 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10902 flow_director_flexpayload,
10903 "flow_director_flex_payload");
10904 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10905 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10906 port_id, RTE_UINT16);
10907 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10908 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10909 payload_layer, "raw#l2#l3#l4");
10910 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10911 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10912 payload_cfg, NULL);
10914 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10915 .f = cmd_flow_director_flxpld_parsed,
10917 .help_str = "flow_director_flexpayload ... : "
10918 "Set flow director's flex payload on NIC",
10920 (void *)&cmd_flow_director_flexpayload,
10921 (void *)&cmd_flow_director_flexpayload_port_id,
10922 (void *)&cmd_flow_director_flexpayload_payload_layer,
10923 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10928 /* Generic flow interface command. */
10929 extern cmdline_parse_inst_t cmd_flow;
10931 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10932 struct cmd_mcast_addr_result {
10933 cmdline_fixed_string_t mcast_addr_cmd;
10934 cmdline_fixed_string_t what;
10936 struct rte_ether_addr mc_addr;
10939 static void cmd_mcast_addr_parsed(void *parsed_result,
10940 __rte_unused struct cmdline *cl,
10941 __rte_unused void *data)
10943 struct cmd_mcast_addr_result *res = parsed_result;
10945 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10947 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
10948 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
10951 if (strcmp(res->what, "add") == 0)
10952 mcast_addr_add(res->port_num, &res->mc_addr);
10954 mcast_addr_remove(res->port_num, &res->mc_addr);
10957 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10958 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10959 mcast_addr_cmd, "mcast_addr");
10960 cmdline_parse_token_string_t cmd_mcast_addr_what =
10961 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10963 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10964 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10966 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10967 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10969 cmdline_parse_inst_t cmd_mcast_addr = {
10970 .f = cmd_mcast_addr_parsed,
10972 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10973 "Add/Remove multicast MAC address on port_id",
10975 (void *)&cmd_mcast_addr_cmd,
10976 (void *)&cmd_mcast_addr_what,
10977 (void *)&cmd_mcast_addr_portnum,
10978 (void *)&cmd_mcast_addr_addr,
10983 /* vf vlan anti spoof configuration */
10985 /* Common result structure for vf vlan anti spoof */
10986 struct cmd_vf_vlan_anti_spoof_result {
10987 cmdline_fixed_string_t set;
10988 cmdline_fixed_string_t vf;
10989 cmdline_fixed_string_t vlan;
10990 cmdline_fixed_string_t antispoof;
10993 cmdline_fixed_string_t on_off;
10996 /* Common CLI fields for vf vlan anti spoof enable disable */
10997 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10998 TOKEN_STRING_INITIALIZER
10999 (struct cmd_vf_vlan_anti_spoof_result,
11001 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11002 TOKEN_STRING_INITIALIZER
11003 (struct cmd_vf_vlan_anti_spoof_result,
11005 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11006 TOKEN_STRING_INITIALIZER
11007 (struct cmd_vf_vlan_anti_spoof_result,
11009 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11010 TOKEN_STRING_INITIALIZER
11011 (struct cmd_vf_vlan_anti_spoof_result,
11012 antispoof, "antispoof");
11013 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11014 TOKEN_NUM_INITIALIZER
11015 (struct cmd_vf_vlan_anti_spoof_result,
11016 port_id, RTE_UINT16);
11017 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11018 TOKEN_NUM_INITIALIZER
11019 (struct cmd_vf_vlan_anti_spoof_result,
11020 vf_id, RTE_UINT32);
11021 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11022 TOKEN_STRING_INITIALIZER
11023 (struct cmd_vf_vlan_anti_spoof_result,
11027 cmd_set_vf_vlan_anti_spoof_parsed(
11028 void *parsed_result,
11029 __rte_unused struct cmdline *cl,
11030 __rte_unused void *data)
11032 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11033 int ret = -ENOTSUP;
11035 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11037 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11040 #ifdef RTE_NET_IXGBE
11041 if (ret == -ENOTSUP)
11042 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11043 res->vf_id, is_on);
11045 #ifdef RTE_NET_I40E
11046 if (ret == -ENOTSUP)
11047 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11048 res->vf_id, is_on);
11050 #ifdef RTE_NET_BNXT
11051 if (ret == -ENOTSUP)
11052 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11053 res->vf_id, is_on);
11060 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11063 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11066 fprintf(stderr, "function not implemented\n");
11069 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11073 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11074 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11076 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11078 (void *)&cmd_vf_vlan_anti_spoof_set,
11079 (void *)&cmd_vf_vlan_anti_spoof_vf,
11080 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11081 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11082 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11083 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11084 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11089 /* vf mac anti spoof configuration */
11091 /* Common result structure for vf mac anti spoof */
11092 struct cmd_vf_mac_anti_spoof_result {
11093 cmdline_fixed_string_t set;
11094 cmdline_fixed_string_t vf;
11095 cmdline_fixed_string_t mac;
11096 cmdline_fixed_string_t antispoof;
11099 cmdline_fixed_string_t on_off;
11102 /* Common CLI fields for vf mac anti spoof enable disable */
11103 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11104 TOKEN_STRING_INITIALIZER
11105 (struct cmd_vf_mac_anti_spoof_result,
11107 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11108 TOKEN_STRING_INITIALIZER
11109 (struct cmd_vf_mac_anti_spoof_result,
11111 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11112 TOKEN_STRING_INITIALIZER
11113 (struct cmd_vf_mac_anti_spoof_result,
11115 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11116 TOKEN_STRING_INITIALIZER
11117 (struct cmd_vf_mac_anti_spoof_result,
11118 antispoof, "antispoof");
11119 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11120 TOKEN_NUM_INITIALIZER
11121 (struct cmd_vf_mac_anti_spoof_result,
11122 port_id, RTE_UINT16);
11123 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11124 TOKEN_NUM_INITIALIZER
11125 (struct cmd_vf_mac_anti_spoof_result,
11126 vf_id, RTE_UINT32);
11127 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11128 TOKEN_STRING_INITIALIZER
11129 (struct cmd_vf_mac_anti_spoof_result,
11133 cmd_set_vf_mac_anti_spoof_parsed(
11134 void *parsed_result,
11135 __rte_unused struct cmdline *cl,
11136 __rte_unused void *data)
11138 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11139 int ret = -ENOTSUP;
11141 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11143 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11146 #ifdef RTE_NET_IXGBE
11147 if (ret == -ENOTSUP)
11148 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11149 res->vf_id, is_on);
11151 #ifdef RTE_NET_I40E
11152 if (ret == -ENOTSUP)
11153 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11154 res->vf_id, is_on);
11156 #ifdef RTE_NET_BNXT
11157 if (ret == -ENOTSUP)
11158 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11159 res->vf_id, is_on);
11166 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11167 res->vf_id, is_on);
11170 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11173 fprintf(stderr, "function not implemented\n");
11176 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11180 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11181 .f = cmd_set_vf_mac_anti_spoof_parsed,
11183 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11185 (void *)&cmd_vf_mac_anti_spoof_set,
11186 (void *)&cmd_vf_mac_anti_spoof_vf,
11187 (void *)&cmd_vf_mac_anti_spoof_mac,
11188 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11189 (void *)&cmd_vf_mac_anti_spoof_port_id,
11190 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11191 (void *)&cmd_vf_mac_anti_spoof_on_off,
11196 /* vf vlan strip queue configuration */
11198 /* Common result structure for vf mac anti spoof */
11199 struct cmd_vf_vlan_stripq_result {
11200 cmdline_fixed_string_t set;
11201 cmdline_fixed_string_t vf;
11202 cmdline_fixed_string_t vlan;
11203 cmdline_fixed_string_t stripq;
11206 cmdline_fixed_string_t on_off;
11209 /* Common CLI fields for vf vlan strip enable disable */
11210 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11211 TOKEN_STRING_INITIALIZER
11212 (struct cmd_vf_vlan_stripq_result,
11214 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11215 TOKEN_STRING_INITIALIZER
11216 (struct cmd_vf_vlan_stripq_result,
11218 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11219 TOKEN_STRING_INITIALIZER
11220 (struct cmd_vf_vlan_stripq_result,
11222 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11223 TOKEN_STRING_INITIALIZER
11224 (struct cmd_vf_vlan_stripq_result,
11226 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11227 TOKEN_NUM_INITIALIZER
11228 (struct cmd_vf_vlan_stripq_result,
11229 port_id, RTE_UINT16);
11230 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11231 TOKEN_NUM_INITIALIZER
11232 (struct cmd_vf_vlan_stripq_result,
11233 vf_id, RTE_UINT16);
11234 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11235 TOKEN_STRING_INITIALIZER
11236 (struct cmd_vf_vlan_stripq_result,
11240 cmd_set_vf_vlan_stripq_parsed(
11241 void *parsed_result,
11242 __rte_unused struct cmdline *cl,
11243 __rte_unused void *data)
11245 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11246 int ret = -ENOTSUP;
11248 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11250 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11253 #ifdef RTE_NET_IXGBE
11254 if (ret == -ENOTSUP)
11255 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11256 res->vf_id, is_on);
11258 #ifdef RTE_NET_I40E
11259 if (ret == -ENOTSUP)
11260 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11261 res->vf_id, is_on);
11263 #ifdef RTE_NET_BNXT
11264 if (ret == -ENOTSUP)
11265 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11266 res->vf_id, is_on);
11273 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11274 res->vf_id, is_on);
11277 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11280 fprintf(stderr, "function not implemented\n");
11283 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11287 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11288 .f = cmd_set_vf_vlan_stripq_parsed,
11290 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11292 (void *)&cmd_vf_vlan_stripq_set,
11293 (void *)&cmd_vf_vlan_stripq_vf,
11294 (void *)&cmd_vf_vlan_stripq_vlan,
11295 (void *)&cmd_vf_vlan_stripq_stripq,
11296 (void *)&cmd_vf_vlan_stripq_port_id,
11297 (void *)&cmd_vf_vlan_stripq_vf_id,
11298 (void *)&cmd_vf_vlan_stripq_on_off,
11303 /* vf vlan insert configuration */
11305 /* Common result structure for vf vlan insert */
11306 struct cmd_vf_vlan_insert_result {
11307 cmdline_fixed_string_t set;
11308 cmdline_fixed_string_t vf;
11309 cmdline_fixed_string_t vlan;
11310 cmdline_fixed_string_t insert;
11316 /* Common CLI fields for vf vlan insert enable disable */
11317 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11318 TOKEN_STRING_INITIALIZER
11319 (struct cmd_vf_vlan_insert_result,
11321 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11322 TOKEN_STRING_INITIALIZER
11323 (struct cmd_vf_vlan_insert_result,
11325 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11326 TOKEN_STRING_INITIALIZER
11327 (struct cmd_vf_vlan_insert_result,
11329 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11330 TOKEN_STRING_INITIALIZER
11331 (struct cmd_vf_vlan_insert_result,
11333 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11334 TOKEN_NUM_INITIALIZER
11335 (struct cmd_vf_vlan_insert_result,
11336 port_id, RTE_UINT16);
11337 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11338 TOKEN_NUM_INITIALIZER
11339 (struct cmd_vf_vlan_insert_result,
11340 vf_id, RTE_UINT16);
11341 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11342 TOKEN_NUM_INITIALIZER
11343 (struct cmd_vf_vlan_insert_result,
11344 vlan_id, RTE_UINT16);
11347 cmd_set_vf_vlan_insert_parsed(
11348 void *parsed_result,
11349 __rte_unused struct cmdline *cl,
11350 __rte_unused void *data)
11352 struct cmd_vf_vlan_insert_result *res = parsed_result;
11353 int ret = -ENOTSUP;
11355 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11358 #ifdef RTE_NET_IXGBE
11359 if (ret == -ENOTSUP)
11360 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11363 #ifdef RTE_NET_I40E
11364 if (ret == -ENOTSUP)
11365 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11368 #ifdef RTE_NET_BNXT
11369 if (ret == -ENOTSUP)
11370 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11378 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11379 res->vf_id, res->vlan_id);
11382 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11385 fprintf(stderr, "function not implemented\n");
11388 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11392 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11393 .f = cmd_set_vf_vlan_insert_parsed,
11395 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11397 (void *)&cmd_vf_vlan_insert_set,
11398 (void *)&cmd_vf_vlan_insert_vf,
11399 (void *)&cmd_vf_vlan_insert_vlan,
11400 (void *)&cmd_vf_vlan_insert_insert,
11401 (void *)&cmd_vf_vlan_insert_port_id,
11402 (void *)&cmd_vf_vlan_insert_vf_id,
11403 (void *)&cmd_vf_vlan_insert_vlan_id,
11408 /* tx loopback configuration */
11410 /* Common result structure for tx loopback */
11411 struct cmd_tx_loopback_result {
11412 cmdline_fixed_string_t set;
11413 cmdline_fixed_string_t tx;
11414 cmdline_fixed_string_t loopback;
11416 cmdline_fixed_string_t on_off;
11419 /* Common CLI fields for tx loopback enable disable */
11420 cmdline_parse_token_string_t cmd_tx_loopback_set =
11421 TOKEN_STRING_INITIALIZER
11422 (struct cmd_tx_loopback_result,
11424 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11425 TOKEN_STRING_INITIALIZER
11426 (struct cmd_tx_loopback_result,
11428 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11429 TOKEN_STRING_INITIALIZER
11430 (struct cmd_tx_loopback_result,
11431 loopback, "loopback");
11432 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11433 TOKEN_NUM_INITIALIZER
11434 (struct cmd_tx_loopback_result,
11435 port_id, RTE_UINT16);
11436 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11437 TOKEN_STRING_INITIALIZER
11438 (struct cmd_tx_loopback_result,
11442 cmd_set_tx_loopback_parsed(
11443 void *parsed_result,
11444 __rte_unused struct cmdline *cl,
11445 __rte_unused void *data)
11447 struct cmd_tx_loopback_result *res = parsed_result;
11448 int ret = -ENOTSUP;
11450 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11452 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11455 #ifdef RTE_NET_IXGBE
11456 if (ret == -ENOTSUP)
11457 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11459 #ifdef RTE_NET_I40E
11460 if (ret == -ENOTSUP)
11461 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11463 #ifdef RTE_NET_BNXT
11464 if (ret == -ENOTSUP)
11465 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11467 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11468 if (ret == -ENOTSUP)
11469 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11476 fprintf(stderr, "invalid is_on %d\n", is_on);
11479 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11482 fprintf(stderr, "function not implemented\n");
11485 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11489 cmdline_parse_inst_t cmd_set_tx_loopback = {
11490 .f = cmd_set_tx_loopback_parsed,
11492 .help_str = "set tx loopback <port_id> on|off",
11494 (void *)&cmd_tx_loopback_set,
11495 (void *)&cmd_tx_loopback_tx,
11496 (void *)&cmd_tx_loopback_loopback,
11497 (void *)&cmd_tx_loopback_port_id,
11498 (void *)&cmd_tx_loopback_on_off,
11503 /* all queues drop enable configuration */
11505 /* Common result structure for all queues drop enable */
11506 struct cmd_all_queues_drop_en_result {
11507 cmdline_fixed_string_t set;
11508 cmdline_fixed_string_t all;
11509 cmdline_fixed_string_t queues;
11510 cmdline_fixed_string_t drop;
11512 cmdline_fixed_string_t on_off;
11515 /* Common CLI fields for tx loopback enable disable */
11516 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11517 TOKEN_STRING_INITIALIZER
11518 (struct cmd_all_queues_drop_en_result,
11520 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11521 TOKEN_STRING_INITIALIZER
11522 (struct cmd_all_queues_drop_en_result,
11524 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11525 TOKEN_STRING_INITIALIZER
11526 (struct cmd_all_queues_drop_en_result,
11528 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11529 TOKEN_STRING_INITIALIZER
11530 (struct cmd_all_queues_drop_en_result,
11532 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11533 TOKEN_NUM_INITIALIZER
11534 (struct cmd_all_queues_drop_en_result,
11535 port_id, RTE_UINT16);
11536 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11537 TOKEN_STRING_INITIALIZER
11538 (struct cmd_all_queues_drop_en_result,
11542 cmd_set_all_queues_drop_en_parsed(
11543 void *parsed_result,
11544 __rte_unused struct cmdline *cl,
11545 __rte_unused void *data)
11547 struct cmd_all_queues_drop_en_result *res = parsed_result;
11548 int ret = -ENOTSUP;
11549 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11551 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11554 #ifdef RTE_NET_IXGBE
11555 if (ret == -ENOTSUP)
11556 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11558 #ifdef RTE_NET_BNXT
11559 if (ret == -ENOTSUP)
11560 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11566 fprintf(stderr, "invalid is_on %d\n", is_on);
11569 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11572 fprintf(stderr, "function not implemented\n");
11575 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11579 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11580 .f = cmd_set_all_queues_drop_en_parsed,
11582 .help_str = "set all queues drop <port_id> on|off",
11584 (void *)&cmd_all_queues_drop_en_set,
11585 (void *)&cmd_all_queues_drop_en_all,
11586 (void *)&cmd_all_queues_drop_en_queues,
11587 (void *)&cmd_all_queues_drop_en_drop,
11588 (void *)&cmd_all_queues_drop_en_port_id,
11589 (void *)&cmd_all_queues_drop_en_on_off,
11594 /* vf split drop enable configuration */
11596 /* Common result structure for vf split drop enable */
11597 struct cmd_vf_split_drop_en_result {
11598 cmdline_fixed_string_t set;
11599 cmdline_fixed_string_t vf;
11600 cmdline_fixed_string_t split;
11601 cmdline_fixed_string_t drop;
11604 cmdline_fixed_string_t on_off;
11607 /* Common CLI fields for vf split drop enable disable */
11608 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11609 TOKEN_STRING_INITIALIZER
11610 (struct cmd_vf_split_drop_en_result,
11612 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11613 TOKEN_STRING_INITIALIZER
11614 (struct cmd_vf_split_drop_en_result,
11616 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11617 TOKEN_STRING_INITIALIZER
11618 (struct cmd_vf_split_drop_en_result,
11620 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11621 TOKEN_STRING_INITIALIZER
11622 (struct cmd_vf_split_drop_en_result,
11624 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11625 TOKEN_NUM_INITIALIZER
11626 (struct cmd_vf_split_drop_en_result,
11627 port_id, RTE_UINT16);
11628 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11629 TOKEN_NUM_INITIALIZER
11630 (struct cmd_vf_split_drop_en_result,
11631 vf_id, RTE_UINT16);
11632 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11633 TOKEN_STRING_INITIALIZER
11634 (struct cmd_vf_split_drop_en_result,
11638 cmd_set_vf_split_drop_en_parsed(
11639 void *parsed_result,
11640 __rte_unused struct cmdline *cl,
11641 __rte_unused void *data)
11643 struct cmd_vf_split_drop_en_result *res = parsed_result;
11644 int ret = -ENOTSUP;
11645 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11647 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11650 #ifdef RTE_NET_IXGBE
11651 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11658 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11659 res->vf_id, is_on);
11662 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11665 fprintf(stderr, "not supported on port %d\n", res->port_id);
11668 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11672 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11673 .f = cmd_set_vf_split_drop_en_parsed,
11675 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11677 (void *)&cmd_vf_split_drop_en_set,
11678 (void *)&cmd_vf_split_drop_en_vf,
11679 (void *)&cmd_vf_split_drop_en_split,
11680 (void *)&cmd_vf_split_drop_en_drop,
11681 (void *)&cmd_vf_split_drop_en_port_id,
11682 (void *)&cmd_vf_split_drop_en_vf_id,
11683 (void *)&cmd_vf_split_drop_en_on_off,
11688 /* vf mac address configuration */
11690 /* Common result structure for vf mac address */
11691 struct cmd_set_vf_mac_addr_result {
11692 cmdline_fixed_string_t set;
11693 cmdline_fixed_string_t vf;
11694 cmdline_fixed_string_t mac;
11695 cmdline_fixed_string_t addr;
11698 struct rte_ether_addr mac_addr;
11702 /* Common CLI fields for vf split drop enable disable */
11703 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11704 TOKEN_STRING_INITIALIZER
11705 (struct cmd_set_vf_mac_addr_result,
11707 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11708 TOKEN_STRING_INITIALIZER
11709 (struct cmd_set_vf_mac_addr_result,
11711 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11712 TOKEN_STRING_INITIALIZER
11713 (struct cmd_set_vf_mac_addr_result,
11715 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11716 TOKEN_STRING_INITIALIZER
11717 (struct cmd_set_vf_mac_addr_result,
11719 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11720 TOKEN_NUM_INITIALIZER
11721 (struct cmd_set_vf_mac_addr_result,
11722 port_id, RTE_UINT16);
11723 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11724 TOKEN_NUM_INITIALIZER
11725 (struct cmd_set_vf_mac_addr_result,
11726 vf_id, RTE_UINT16);
11727 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11728 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11732 cmd_set_vf_mac_addr_parsed(
11733 void *parsed_result,
11734 __rte_unused struct cmdline *cl,
11735 __rte_unused void *data)
11737 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11738 int ret = -ENOTSUP;
11740 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11743 #ifdef RTE_NET_IXGBE
11744 if (ret == -ENOTSUP)
11745 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11748 #ifdef RTE_NET_I40E
11749 if (ret == -ENOTSUP)
11750 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11753 #ifdef RTE_NET_BNXT
11754 if (ret == -ENOTSUP)
11755 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11763 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11766 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11769 fprintf(stderr, "function not implemented\n");
11772 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11776 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11777 .f = cmd_set_vf_mac_addr_parsed,
11779 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11781 (void *)&cmd_set_vf_mac_addr_set,
11782 (void *)&cmd_set_vf_mac_addr_vf,
11783 (void *)&cmd_set_vf_mac_addr_mac,
11784 (void *)&cmd_set_vf_mac_addr_addr,
11785 (void *)&cmd_set_vf_mac_addr_port_id,
11786 (void *)&cmd_set_vf_mac_addr_vf_id,
11787 (void *)&cmd_set_vf_mac_addr_mac_addr,
11792 /* MACsec configuration */
11794 /* Common result structure for MACsec offload enable */
11795 struct cmd_macsec_offload_on_result {
11796 cmdline_fixed_string_t set;
11797 cmdline_fixed_string_t macsec;
11798 cmdline_fixed_string_t offload;
11800 cmdline_fixed_string_t on;
11801 cmdline_fixed_string_t encrypt;
11802 cmdline_fixed_string_t en_on_off;
11803 cmdline_fixed_string_t replay_protect;
11804 cmdline_fixed_string_t rp_on_off;
11807 /* Common CLI fields for MACsec offload disable */
11808 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11809 TOKEN_STRING_INITIALIZER
11810 (struct cmd_macsec_offload_on_result,
11812 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11813 TOKEN_STRING_INITIALIZER
11814 (struct cmd_macsec_offload_on_result,
11816 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11817 TOKEN_STRING_INITIALIZER
11818 (struct cmd_macsec_offload_on_result,
11819 offload, "offload");
11820 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11821 TOKEN_NUM_INITIALIZER
11822 (struct cmd_macsec_offload_on_result,
11823 port_id, RTE_UINT16);
11824 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11825 TOKEN_STRING_INITIALIZER
11826 (struct cmd_macsec_offload_on_result,
11828 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11829 TOKEN_STRING_INITIALIZER
11830 (struct cmd_macsec_offload_on_result,
11831 encrypt, "encrypt");
11832 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11833 TOKEN_STRING_INITIALIZER
11834 (struct cmd_macsec_offload_on_result,
11835 en_on_off, "on#off");
11836 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11837 TOKEN_STRING_INITIALIZER
11838 (struct cmd_macsec_offload_on_result,
11839 replay_protect, "replay-protect");
11840 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11841 TOKEN_STRING_INITIALIZER
11842 (struct cmd_macsec_offload_on_result,
11843 rp_on_off, "on#off");
11846 cmd_set_macsec_offload_on_parsed(
11847 void *parsed_result,
11848 __rte_unused struct cmdline *cl,
11849 __rte_unused void *data)
11851 struct cmd_macsec_offload_on_result *res = parsed_result;
11852 int ret = -ENOTSUP;
11853 portid_t port_id = res->port_id;
11854 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11855 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11856 struct rte_eth_dev_info dev_info;
11858 if (port_id_is_invalid(port_id, ENABLED_WARN))
11860 if (!port_is_stopped(port_id)) {
11861 fprintf(stderr, "Please stop port %d first\n", port_id);
11865 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11869 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11870 #ifdef RTE_NET_IXGBE
11871 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11879 ports[port_id].dev_conf.txmode.offloads |=
11880 DEV_TX_OFFLOAD_MACSEC_INSERT;
11881 cmd_reconfig_device_queue(port_id, 1, 1);
11884 fprintf(stderr, "invalid port_id %d\n", port_id);
11887 fprintf(stderr, "not supported on port %d\n", port_id);
11890 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11894 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11895 .f = cmd_set_macsec_offload_on_parsed,
11897 .help_str = "set macsec offload <port_id> on "
11898 "encrypt on|off replay-protect on|off",
11900 (void *)&cmd_macsec_offload_on_set,
11901 (void *)&cmd_macsec_offload_on_macsec,
11902 (void *)&cmd_macsec_offload_on_offload,
11903 (void *)&cmd_macsec_offload_on_port_id,
11904 (void *)&cmd_macsec_offload_on_on,
11905 (void *)&cmd_macsec_offload_on_encrypt,
11906 (void *)&cmd_macsec_offload_on_en_on_off,
11907 (void *)&cmd_macsec_offload_on_replay_protect,
11908 (void *)&cmd_macsec_offload_on_rp_on_off,
11913 /* Common result structure for MACsec offload disable */
11914 struct cmd_macsec_offload_off_result {
11915 cmdline_fixed_string_t set;
11916 cmdline_fixed_string_t macsec;
11917 cmdline_fixed_string_t offload;
11919 cmdline_fixed_string_t off;
11922 /* Common CLI fields for MACsec offload disable */
11923 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11924 TOKEN_STRING_INITIALIZER
11925 (struct cmd_macsec_offload_off_result,
11927 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11928 TOKEN_STRING_INITIALIZER
11929 (struct cmd_macsec_offload_off_result,
11931 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11932 TOKEN_STRING_INITIALIZER
11933 (struct cmd_macsec_offload_off_result,
11934 offload, "offload");
11935 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11936 TOKEN_NUM_INITIALIZER
11937 (struct cmd_macsec_offload_off_result,
11938 port_id, RTE_UINT16);
11939 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11940 TOKEN_STRING_INITIALIZER
11941 (struct cmd_macsec_offload_off_result,
11945 cmd_set_macsec_offload_off_parsed(
11946 void *parsed_result,
11947 __rte_unused struct cmdline *cl,
11948 __rte_unused void *data)
11950 struct cmd_macsec_offload_off_result *res = parsed_result;
11951 int ret = -ENOTSUP;
11952 struct rte_eth_dev_info dev_info;
11953 portid_t port_id = res->port_id;
11955 if (port_id_is_invalid(port_id, ENABLED_WARN))
11957 if (!port_is_stopped(port_id)) {
11958 fprintf(stderr, "Please stop port %d first\n", port_id);
11962 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11966 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11967 #ifdef RTE_NET_IXGBE
11968 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11973 ports[port_id].dev_conf.txmode.offloads &=
11974 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11975 cmd_reconfig_device_queue(port_id, 1, 1);
11978 fprintf(stderr, "invalid port_id %d\n", port_id);
11981 fprintf(stderr, "not supported on port %d\n", port_id);
11984 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11988 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11989 .f = cmd_set_macsec_offload_off_parsed,
11991 .help_str = "set macsec offload <port_id> off",
11993 (void *)&cmd_macsec_offload_off_set,
11994 (void *)&cmd_macsec_offload_off_macsec,
11995 (void *)&cmd_macsec_offload_off_offload,
11996 (void *)&cmd_macsec_offload_off_port_id,
11997 (void *)&cmd_macsec_offload_off_off,
12002 /* Common result structure for MACsec secure connection configure */
12003 struct cmd_macsec_sc_result {
12004 cmdline_fixed_string_t set;
12005 cmdline_fixed_string_t macsec;
12006 cmdline_fixed_string_t sc;
12007 cmdline_fixed_string_t tx_rx;
12009 struct rte_ether_addr mac;
12013 /* Common CLI fields for MACsec secure connection configure */
12014 cmdline_parse_token_string_t cmd_macsec_sc_set =
12015 TOKEN_STRING_INITIALIZER
12016 (struct cmd_macsec_sc_result,
12018 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12019 TOKEN_STRING_INITIALIZER
12020 (struct cmd_macsec_sc_result,
12022 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12023 TOKEN_STRING_INITIALIZER
12024 (struct cmd_macsec_sc_result,
12026 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12027 TOKEN_STRING_INITIALIZER
12028 (struct cmd_macsec_sc_result,
12030 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12031 TOKEN_NUM_INITIALIZER
12032 (struct cmd_macsec_sc_result,
12033 port_id, RTE_UINT16);
12034 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12035 TOKEN_ETHERADDR_INITIALIZER
12036 (struct cmd_macsec_sc_result,
12038 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12039 TOKEN_NUM_INITIALIZER
12040 (struct cmd_macsec_sc_result,
12044 cmd_set_macsec_sc_parsed(
12045 void *parsed_result,
12046 __rte_unused struct cmdline *cl,
12047 __rte_unused void *data)
12049 struct cmd_macsec_sc_result *res = parsed_result;
12050 int ret = -ENOTSUP;
12051 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12053 #ifdef RTE_NET_IXGBE
12055 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12056 res->mac.addr_bytes) :
12057 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12058 res->mac.addr_bytes, res->pi);
12060 RTE_SET_USED(is_tx);
12066 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12069 fprintf(stderr, "not supported on port %d\n", res->port_id);
12072 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12076 cmdline_parse_inst_t cmd_set_macsec_sc = {
12077 .f = cmd_set_macsec_sc_parsed,
12079 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12081 (void *)&cmd_macsec_sc_set,
12082 (void *)&cmd_macsec_sc_macsec,
12083 (void *)&cmd_macsec_sc_sc,
12084 (void *)&cmd_macsec_sc_tx_rx,
12085 (void *)&cmd_macsec_sc_port_id,
12086 (void *)&cmd_macsec_sc_mac,
12087 (void *)&cmd_macsec_sc_pi,
12092 /* Common result structure for MACsec secure connection configure */
12093 struct cmd_macsec_sa_result {
12094 cmdline_fixed_string_t set;
12095 cmdline_fixed_string_t macsec;
12096 cmdline_fixed_string_t sa;
12097 cmdline_fixed_string_t tx_rx;
12102 cmdline_fixed_string_t key;
12105 /* Common CLI fields for MACsec secure connection configure */
12106 cmdline_parse_token_string_t cmd_macsec_sa_set =
12107 TOKEN_STRING_INITIALIZER
12108 (struct cmd_macsec_sa_result,
12110 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12111 TOKEN_STRING_INITIALIZER
12112 (struct cmd_macsec_sa_result,
12114 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12115 TOKEN_STRING_INITIALIZER
12116 (struct cmd_macsec_sa_result,
12118 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12119 TOKEN_STRING_INITIALIZER
12120 (struct cmd_macsec_sa_result,
12122 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12123 TOKEN_NUM_INITIALIZER
12124 (struct cmd_macsec_sa_result,
12125 port_id, RTE_UINT16);
12126 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12127 TOKEN_NUM_INITIALIZER
12128 (struct cmd_macsec_sa_result,
12130 cmdline_parse_token_num_t cmd_macsec_sa_an =
12131 TOKEN_NUM_INITIALIZER
12132 (struct cmd_macsec_sa_result,
12134 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12135 TOKEN_NUM_INITIALIZER
12136 (struct cmd_macsec_sa_result,
12138 cmdline_parse_token_string_t cmd_macsec_sa_key =
12139 TOKEN_STRING_INITIALIZER
12140 (struct cmd_macsec_sa_result,
12144 cmd_set_macsec_sa_parsed(
12145 void *parsed_result,
12146 __rte_unused struct cmdline *cl,
12147 __rte_unused void *data)
12149 struct cmd_macsec_sa_result *res = parsed_result;
12150 int ret = -ENOTSUP;
12151 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12152 uint8_t key[16] = { 0 };
12158 key_len = strlen(res->key) / 2;
12162 for (i = 0; i < key_len; i++) {
12163 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12166 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12169 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12172 #ifdef RTE_NET_IXGBE
12174 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12175 res->idx, res->an, res->pn, key) :
12176 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12177 res->idx, res->an, res->pn, key);
12179 RTE_SET_USED(is_tx);
12186 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12189 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12192 fprintf(stderr, "not supported on port %d\n", res->port_id);
12195 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12199 cmdline_parse_inst_t cmd_set_macsec_sa = {
12200 .f = cmd_set_macsec_sa_parsed,
12202 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12204 (void *)&cmd_macsec_sa_set,
12205 (void *)&cmd_macsec_sa_macsec,
12206 (void *)&cmd_macsec_sa_sa,
12207 (void *)&cmd_macsec_sa_tx_rx,
12208 (void *)&cmd_macsec_sa_port_id,
12209 (void *)&cmd_macsec_sa_idx,
12210 (void *)&cmd_macsec_sa_an,
12211 (void *)&cmd_macsec_sa_pn,
12212 (void *)&cmd_macsec_sa_key,
12217 /* VF unicast promiscuous mode configuration */
12219 /* Common result structure for VF unicast promiscuous mode */
12220 struct cmd_vf_promisc_result {
12221 cmdline_fixed_string_t set;
12222 cmdline_fixed_string_t vf;
12223 cmdline_fixed_string_t promisc;
12226 cmdline_fixed_string_t on_off;
12229 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12230 cmdline_parse_token_string_t cmd_vf_promisc_set =
12231 TOKEN_STRING_INITIALIZER
12232 (struct cmd_vf_promisc_result,
12234 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12235 TOKEN_STRING_INITIALIZER
12236 (struct cmd_vf_promisc_result,
12238 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12239 TOKEN_STRING_INITIALIZER
12240 (struct cmd_vf_promisc_result,
12241 promisc, "promisc");
12242 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12243 TOKEN_NUM_INITIALIZER
12244 (struct cmd_vf_promisc_result,
12245 port_id, RTE_UINT16);
12246 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12247 TOKEN_NUM_INITIALIZER
12248 (struct cmd_vf_promisc_result,
12249 vf_id, RTE_UINT32);
12250 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12251 TOKEN_STRING_INITIALIZER
12252 (struct cmd_vf_promisc_result,
12256 cmd_set_vf_promisc_parsed(
12257 void *parsed_result,
12258 __rte_unused struct cmdline *cl,
12259 __rte_unused void *data)
12261 struct cmd_vf_promisc_result *res = parsed_result;
12262 int ret = -ENOTSUP;
12264 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12266 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12269 #ifdef RTE_NET_I40E
12270 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12271 res->vf_id, is_on);
12278 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12281 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12284 fprintf(stderr, "function not implemented\n");
12287 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12291 cmdline_parse_inst_t cmd_set_vf_promisc = {
12292 .f = cmd_set_vf_promisc_parsed,
12294 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12295 "Set unicast promiscuous mode for a VF from the PF",
12297 (void *)&cmd_vf_promisc_set,
12298 (void *)&cmd_vf_promisc_vf,
12299 (void *)&cmd_vf_promisc_promisc,
12300 (void *)&cmd_vf_promisc_port_id,
12301 (void *)&cmd_vf_promisc_vf_id,
12302 (void *)&cmd_vf_promisc_on_off,
12307 /* VF multicast promiscuous mode configuration */
12309 /* Common result structure for VF multicast promiscuous mode */
12310 struct cmd_vf_allmulti_result {
12311 cmdline_fixed_string_t set;
12312 cmdline_fixed_string_t vf;
12313 cmdline_fixed_string_t allmulti;
12316 cmdline_fixed_string_t on_off;
12319 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12320 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12321 TOKEN_STRING_INITIALIZER
12322 (struct cmd_vf_allmulti_result,
12324 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12325 TOKEN_STRING_INITIALIZER
12326 (struct cmd_vf_allmulti_result,
12328 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12329 TOKEN_STRING_INITIALIZER
12330 (struct cmd_vf_allmulti_result,
12331 allmulti, "allmulti");
12332 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12333 TOKEN_NUM_INITIALIZER
12334 (struct cmd_vf_allmulti_result,
12335 port_id, RTE_UINT16);
12336 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12337 TOKEN_NUM_INITIALIZER
12338 (struct cmd_vf_allmulti_result,
12339 vf_id, RTE_UINT32);
12340 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12341 TOKEN_STRING_INITIALIZER
12342 (struct cmd_vf_allmulti_result,
12346 cmd_set_vf_allmulti_parsed(
12347 void *parsed_result,
12348 __rte_unused struct cmdline *cl,
12349 __rte_unused void *data)
12351 struct cmd_vf_allmulti_result *res = parsed_result;
12352 int ret = -ENOTSUP;
12354 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12356 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12359 #ifdef RTE_NET_I40E
12360 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12361 res->vf_id, is_on);
12368 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12371 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12374 fprintf(stderr, "function not implemented\n");
12377 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12381 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12382 .f = cmd_set_vf_allmulti_parsed,
12384 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12385 "Set multicast promiscuous mode for a VF from the PF",
12387 (void *)&cmd_vf_allmulti_set,
12388 (void *)&cmd_vf_allmulti_vf,
12389 (void *)&cmd_vf_allmulti_allmulti,
12390 (void *)&cmd_vf_allmulti_port_id,
12391 (void *)&cmd_vf_allmulti_vf_id,
12392 (void *)&cmd_vf_allmulti_on_off,
12397 /* vf broadcast mode configuration */
12399 /* Common result structure for vf broadcast */
12400 struct cmd_set_vf_broadcast_result {
12401 cmdline_fixed_string_t set;
12402 cmdline_fixed_string_t vf;
12403 cmdline_fixed_string_t broadcast;
12406 cmdline_fixed_string_t on_off;
12409 /* Common CLI fields for vf broadcast enable disable */
12410 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12411 TOKEN_STRING_INITIALIZER
12412 (struct cmd_set_vf_broadcast_result,
12414 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12415 TOKEN_STRING_INITIALIZER
12416 (struct cmd_set_vf_broadcast_result,
12418 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12419 TOKEN_STRING_INITIALIZER
12420 (struct cmd_set_vf_broadcast_result,
12421 broadcast, "broadcast");
12422 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12423 TOKEN_NUM_INITIALIZER
12424 (struct cmd_set_vf_broadcast_result,
12425 port_id, RTE_UINT16);
12426 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12427 TOKEN_NUM_INITIALIZER
12428 (struct cmd_set_vf_broadcast_result,
12429 vf_id, RTE_UINT16);
12430 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12431 TOKEN_STRING_INITIALIZER
12432 (struct cmd_set_vf_broadcast_result,
12436 cmd_set_vf_broadcast_parsed(
12437 void *parsed_result,
12438 __rte_unused struct cmdline *cl,
12439 __rte_unused void *data)
12441 struct cmd_set_vf_broadcast_result *res = parsed_result;
12442 int ret = -ENOTSUP;
12444 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12446 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12449 #ifdef RTE_NET_I40E
12450 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12451 res->vf_id, is_on);
12458 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12459 res->vf_id, is_on);
12462 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12465 fprintf(stderr, "function not implemented\n");
12468 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12472 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12473 .f = cmd_set_vf_broadcast_parsed,
12475 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12477 (void *)&cmd_set_vf_broadcast_set,
12478 (void *)&cmd_set_vf_broadcast_vf,
12479 (void *)&cmd_set_vf_broadcast_broadcast,
12480 (void *)&cmd_set_vf_broadcast_port_id,
12481 (void *)&cmd_set_vf_broadcast_vf_id,
12482 (void *)&cmd_set_vf_broadcast_on_off,
12487 /* vf vlan tag configuration */
12489 /* Common result structure for vf vlan tag */
12490 struct cmd_set_vf_vlan_tag_result {
12491 cmdline_fixed_string_t set;
12492 cmdline_fixed_string_t vf;
12493 cmdline_fixed_string_t vlan;
12494 cmdline_fixed_string_t tag;
12497 cmdline_fixed_string_t on_off;
12500 /* Common CLI fields for vf vlan tag enable disable */
12501 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12502 TOKEN_STRING_INITIALIZER
12503 (struct cmd_set_vf_vlan_tag_result,
12505 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12506 TOKEN_STRING_INITIALIZER
12507 (struct cmd_set_vf_vlan_tag_result,
12509 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12510 TOKEN_STRING_INITIALIZER
12511 (struct cmd_set_vf_vlan_tag_result,
12513 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12514 TOKEN_STRING_INITIALIZER
12515 (struct cmd_set_vf_vlan_tag_result,
12517 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12518 TOKEN_NUM_INITIALIZER
12519 (struct cmd_set_vf_vlan_tag_result,
12520 port_id, RTE_UINT16);
12521 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12522 TOKEN_NUM_INITIALIZER
12523 (struct cmd_set_vf_vlan_tag_result,
12524 vf_id, RTE_UINT16);
12525 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12526 TOKEN_STRING_INITIALIZER
12527 (struct cmd_set_vf_vlan_tag_result,
12531 cmd_set_vf_vlan_tag_parsed(
12532 void *parsed_result,
12533 __rte_unused struct cmdline *cl,
12534 __rte_unused void *data)
12536 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12537 int ret = -ENOTSUP;
12539 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12541 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12544 #ifdef RTE_NET_I40E
12545 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12546 res->vf_id, is_on);
12553 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12554 res->vf_id, is_on);
12557 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12560 fprintf(stderr, "function not implemented\n");
12563 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12567 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12568 .f = cmd_set_vf_vlan_tag_parsed,
12570 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12572 (void *)&cmd_set_vf_vlan_tag_set,
12573 (void *)&cmd_set_vf_vlan_tag_vf,
12574 (void *)&cmd_set_vf_vlan_tag_vlan,
12575 (void *)&cmd_set_vf_vlan_tag_tag,
12576 (void *)&cmd_set_vf_vlan_tag_port_id,
12577 (void *)&cmd_set_vf_vlan_tag_vf_id,
12578 (void *)&cmd_set_vf_vlan_tag_on_off,
12583 /* Common definition of VF and TC TX bandwidth configuration */
12584 struct cmd_vf_tc_bw_result {
12585 cmdline_fixed_string_t set;
12586 cmdline_fixed_string_t vf;
12587 cmdline_fixed_string_t tc;
12588 cmdline_fixed_string_t tx;
12589 cmdline_fixed_string_t min_bw;
12590 cmdline_fixed_string_t max_bw;
12591 cmdline_fixed_string_t strict_link_prio;
12596 cmdline_fixed_string_t bw_list;
12600 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12601 TOKEN_STRING_INITIALIZER
12602 (struct cmd_vf_tc_bw_result,
12604 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12605 TOKEN_STRING_INITIALIZER
12606 (struct cmd_vf_tc_bw_result,
12608 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12609 TOKEN_STRING_INITIALIZER
12610 (struct cmd_vf_tc_bw_result,
12612 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12613 TOKEN_STRING_INITIALIZER
12614 (struct cmd_vf_tc_bw_result,
12616 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12617 TOKEN_STRING_INITIALIZER
12618 (struct cmd_vf_tc_bw_result,
12619 strict_link_prio, "strict-link-priority");
12620 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12621 TOKEN_STRING_INITIALIZER
12622 (struct cmd_vf_tc_bw_result,
12623 min_bw, "min-bandwidth");
12624 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12625 TOKEN_STRING_INITIALIZER
12626 (struct cmd_vf_tc_bw_result,
12627 max_bw, "max-bandwidth");
12628 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12629 TOKEN_NUM_INITIALIZER
12630 (struct cmd_vf_tc_bw_result,
12631 port_id, RTE_UINT16);
12632 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12633 TOKEN_NUM_INITIALIZER
12634 (struct cmd_vf_tc_bw_result,
12635 vf_id, RTE_UINT16);
12636 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12637 TOKEN_NUM_INITIALIZER
12638 (struct cmd_vf_tc_bw_result,
12640 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12641 TOKEN_NUM_INITIALIZER
12642 (struct cmd_vf_tc_bw_result,
12644 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12645 TOKEN_STRING_INITIALIZER
12646 (struct cmd_vf_tc_bw_result,
12648 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12649 TOKEN_NUM_INITIALIZER
12650 (struct cmd_vf_tc_bw_result,
12651 tc_map, RTE_UINT8);
12653 /* VF max bandwidth setting */
12655 cmd_vf_max_bw_parsed(
12656 void *parsed_result,
12657 __rte_unused struct cmdline *cl,
12658 __rte_unused void *data)
12660 struct cmd_vf_tc_bw_result *res = parsed_result;
12661 int ret = -ENOTSUP;
12663 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12666 #ifdef RTE_NET_I40E
12667 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12668 res->vf_id, res->bw);
12675 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12676 res->vf_id, res->bw);
12679 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12682 fprintf(stderr, "function not implemented\n");
12685 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12689 cmdline_parse_inst_t cmd_vf_max_bw = {
12690 .f = cmd_vf_max_bw_parsed,
12692 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12694 (void *)&cmd_vf_tc_bw_set,
12695 (void *)&cmd_vf_tc_bw_vf,
12696 (void *)&cmd_vf_tc_bw_tx,
12697 (void *)&cmd_vf_tc_bw_max_bw,
12698 (void *)&cmd_vf_tc_bw_port_id,
12699 (void *)&cmd_vf_tc_bw_vf_id,
12700 (void *)&cmd_vf_tc_bw_bw,
12706 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12711 const char *p, *p0 = str;
12718 p = strchr(p0, '(');
12721 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12725 p0 = strchr(p, ')');
12728 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12732 if (size >= sizeof(s)) {
12734 "The string size exceeds the internal buffer size\n");
12737 snprintf(s, sizeof(s), "%.*s", size, p);
12738 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12740 fprintf(stderr, "Failed to get the bandwidth list.\n");
12744 for (i = 0; i < ret; i++)
12745 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12750 /* TC min bandwidth setting */
12752 cmd_vf_tc_min_bw_parsed(
12753 void *parsed_result,
12754 __rte_unused struct cmdline *cl,
12755 __rte_unused void *data)
12757 struct cmd_vf_tc_bw_result *res = parsed_result;
12760 int ret = -ENOTSUP;
12762 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12765 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12769 #ifdef RTE_NET_I40E
12770 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12778 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12781 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12784 fprintf(stderr, "function not implemented\n");
12787 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12791 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12792 .f = cmd_vf_tc_min_bw_parsed,
12794 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12795 " <bw1, bw2, ...>",
12797 (void *)&cmd_vf_tc_bw_set,
12798 (void *)&cmd_vf_tc_bw_vf,
12799 (void *)&cmd_vf_tc_bw_tc,
12800 (void *)&cmd_vf_tc_bw_tx,
12801 (void *)&cmd_vf_tc_bw_min_bw,
12802 (void *)&cmd_vf_tc_bw_port_id,
12803 (void *)&cmd_vf_tc_bw_vf_id,
12804 (void *)&cmd_vf_tc_bw_bw_list,
12810 cmd_tc_min_bw_parsed(
12811 void *parsed_result,
12812 __rte_unused struct cmdline *cl,
12813 __rte_unused void *data)
12815 struct cmd_vf_tc_bw_result *res = parsed_result;
12816 struct rte_port *port;
12819 int ret = -ENOTSUP;
12821 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12824 port = &ports[res->port_id];
12825 /** Check if the port is not started **/
12826 if (port->port_status != RTE_PORT_STOPPED) {
12827 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12831 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12835 #ifdef RTE_NET_IXGBE
12836 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12843 fprintf(stderr, "invalid bandwidth\n");
12846 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12849 fprintf(stderr, "function not implemented\n");
12852 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12856 cmdline_parse_inst_t cmd_tc_min_bw = {
12857 .f = cmd_tc_min_bw_parsed,
12859 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12861 (void *)&cmd_vf_tc_bw_set,
12862 (void *)&cmd_vf_tc_bw_tc,
12863 (void *)&cmd_vf_tc_bw_tx,
12864 (void *)&cmd_vf_tc_bw_min_bw,
12865 (void *)&cmd_vf_tc_bw_port_id,
12866 (void *)&cmd_vf_tc_bw_bw_list,
12871 /* TC max bandwidth setting */
12873 cmd_vf_tc_max_bw_parsed(
12874 void *parsed_result,
12875 __rte_unused struct cmdline *cl,
12876 __rte_unused void *data)
12878 struct cmd_vf_tc_bw_result *res = parsed_result;
12879 int ret = -ENOTSUP;
12881 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12884 #ifdef RTE_NET_I40E
12885 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12886 res->tc_no, res->bw);
12894 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
12895 res->vf_id, res->tc_no, res->bw);
12898 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12901 fprintf(stderr, "function not implemented\n");
12904 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12908 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12909 .f = cmd_vf_tc_max_bw_parsed,
12911 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12914 (void *)&cmd_vf_tc_bw_set,
12915 (void *)&cmd_vf_tc_bw_vf,
12916 (void *)&cmd_vf_tc_bw_tc,
12917 (void *)&cmd_vf_tc_bw_tx,
12918 (void *)&cmd_vf_tc_bw_max_bw,
12919 (void *)&cmd_vf_tc_bw_port_id,
12920 (void *)&cmd_vf_tc_bw_vf_id,
12921 (void *)&cmd_vf_tc_bw_tc_no,
12922 (void *)&cmd_vf_tc_bw_bw,
12927 /** Set VXLAN encapsulation details */
12928 struct cmd_set_vxlan_result {
12929 cmdline_fixed_string_t set;
12930 cmdline_fixed_string_t vxlan;
12931 cmdline_fixed_string_t pos_token;
12932 cmdline_fixed_string_t ip_version;
12933 uint32_t vlan_present:1;
12937 cmdline_ipaddr_t ip_src;
12938 cmdline_ipaddr_t ip_dst;
12942 struct rte_ether_addr eth_src;
12943 struct rte_ether_addr eth_dst;
12946 cmdline_parse_token_string_t cmd_set_vxlan_set =
12947 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12948 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12949 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12950 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12951 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12953 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12954 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12955 "vxlan-with-vlan");
12956 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12957 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12959 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12960 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12962 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12963 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12965 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12966 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12967 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12968 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12970 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12971 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12972 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12973 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12975 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12976 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12977 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12978 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12980 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12981 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12982 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12983 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12985 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12986 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12987 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12988 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12990 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12991 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12992 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12993 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12995 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12996 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12997 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12998 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13000 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13001 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13002 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13003 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13005 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13006 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13007 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13008 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13010 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13011 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13013 static void cmd_set_vxlan_parsed(void *parsed_result,
13014 __rte_unused struct cmdline *cl,
13015 __rte_unused void *data)
13017 struct cmd_set_vxlan_result *res = parsed_result;
13022 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13025 vxlan_encap_conf.select_tos_ttl = 0;
13026 if (strcmp(res->vxlan, "vxlan") == 0)
13027 vxlan_encap_conf.select_vlan = 0;
13028 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13029 vxlan_encap_conf.select_vlan = 1;
13030 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13031 vxlan_encap_conf.select_vlan = 0;
13032 vxlan_encap_conf.select_tos_ttl = 1;
13034 if (strcmp(res->ip_version, "ipv4") == 0)
13035 vxlan_encap_conf.select_ipv4 = 1;
13036 else if (strcmp(res->ip_version, "ipv6") == 0)
13037 vxlan_encap_conf.select_ipv4 = 0;
13040 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13041 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13042 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13043 vxlan_encap_conf.ip_tos = res->tos;
13044 vxlan_encap_conf.ip_ttl = res->ttl;
13045 if (vxlan_encap_conf.select_ipv4) {
13046 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13047 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13049 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13050 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13052 if (vxlan_encap_conf.select_vlan)
13053 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13054 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13055 RTE_ETHER_ADDR_LEN);
13056 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13057 RTE_ETHER_ADDR_LEN);
13060 cmdline_parse_inst_t cmd_set_vxlan = {
13061 .f = cmd_set_vxlan_parsed,
13063 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13064 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13065 " eth-src <eth-src> eth-dst <eth-dst>",
13067 (void *)&cmd_set_vxlan_set,
13068 (void *)&cmd_set_vxlan_vxlan,
13069 (void *)&cmd_set_vxlan_ip_version,
13070 (void *)&cmd_set_vxlan_ip_version_value,
13071 (void *)&cmd_set_vxlan_vni,
13072 (void *)&cmd_set_vxlan_vni_value,
13073 (void *)&cmd_set_vxlan_udp_src,
13074 (void *)&cmd_set_vxlan_udp_src_value,
13075 (void *)&cmd_set_vxlan_udp_dst,
13076 (void *)&cmd_set_vxlan_udp_dst_value,
13077 (void *)&cmd_set_vxlan_ip_src,
13078 (void *)&cmd_set_vxlan_ip_src_value,
13079 (void *)&cmd_set_vxlan_ip_dst,
13080 (void *)&cmd_set_vxlan_ip_dst_value,
13081 (void *)&cmd_set_vxlan_eth_src,
13082 (void *)&cmd_set_vxlan_eth_src_value,
13083 (void *)&cmd_set_vxlan_eth_dst,
13084 (void *)&cmd_set_vxlan_eth_dst_value,
13089 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13090 .f = cmd_set_vxlan_parsed,
13092 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13093 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13094 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13095 " eth-dst <eth-dst>",
13097 (void *)&cmd_set_vxlan_set,
13098 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13099 (void *)&cmd_set_vxlan_ip_version,
13100 (void *)&cmd_set_vxlan_ip_version_value,
13101 (void *)&cmd_set_vxlan_vni,
13102 (void *)&cmd_set_vxlan_vni_value,
13103 (void *)&cmd_set_vxlan_udp_src,
13104 (void *)&cmd_set_vxlan_udp_src_value,
13105 (void *)&cmd_set_vxlan_udp_dst,
13106 (void *)&cmd_set_vxlan_udp_dst_value,
13107 (void *)&cmd_set_vxlan_ip_tos,
13108 (void *)&cmd_set_vxlan_ip_tos_value,
13109 (void *)&cmd_set_vxlan_ip_ttl,
13110 (void *)&cmd_set_vxlan_ip_ttl_value,
13111 (void *)&cmd_set_vxlan_ip_src,
13112 (void *)&cmd_set_vxlan_ip_src_value,
13113 (void *)&cmd_set_vxlan_ip_dst,
13114 (void *)&cmd_set_vxlan_ip_dst_value,
13115 (void *)&cmd_set_vxlan_eth_src,
13116 (void *)&cmd_set_vxlan_eth_src_value,
13117 (void *)&cmd_set_vxlan_eth_dst,
13118 (void *)&cmd_set_vxlan_eth_dst_value,
13123 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13124 .f = cmd_set_vxlan_parsed,
13126 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13127 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13128 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13131 (void *)&cmd_set_vxlan_set,
13132 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13133 (void *)&cmd_set_vxlan_ip_version,
13134 (void *)&cmd_set_vxlan_ip_version_value,
13135 (void *)&cmd_set_vxlan_vni,
13136 (void *)&cmd_set_vxlan_vni_value,
13137 (void *)&cmd_set_vxlan_udp_src,
13138 (void *)&cmd_set_vxlan_udp_src_value,
13139 (void *)&cmd_set_vxlan_udp_dst,
13140 (void *)&cmd_set_vxlan_udp_dst_value,
13141 (void *)&cmd_set_vxlan_ip_src,
13142 (void *)&cmd_set_vxlan_ip_src_value,
13143 (void *)&cmd_set_vxlan_ip_dst,
13144 (void *)&cmd_set_vxlan_ip_dst_value,
13145 (void *)&cmd_set_vxlan_vlan,
13146 (void *)&cmd_set_vxlan_vlan_value,
13147 (void *)&cmd_set_vxlan_eth_src,
13148 (void *)&cmd_set_vxlan_eth_src_value,
13149 (void *)&cmd_set_vxlan_eth_dst,
13150 (void *)&cmd_set_vxlan_eth_dst_value,
13155 /** Set NVGRE encapsulation details */
13156 struct cmd_set_nvgre_result {
13157 cmdline_fixed_string_t set;
13158 cmdline_fixed_string_t nvgre;
13159 cmdline_fixed_string_t pos_token;
13160 cmdline_fixed_string_t ip_version;
13162 cmdline_ipaddr_t ip_src;
13163 cmdline_ipaddr_t ip_dst;
13165 struct rte_ether_addr eth_src;
13166 struct rte_ether_addr eth_dst;
13169 cmdline_parse_token_string_t cmd_set_nvgre_set =
13170 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13171 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13172 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13173 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13174 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13175 "nvgre-with-vlan");
13176 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13177 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13179 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13180 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13182 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13183 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13185 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13186 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13187 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13188 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13190 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13191 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13192 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13193 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13195 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13196 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13197 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13198 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13200 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13201 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13202 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13203 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13205 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13206 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13207 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13208 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13210 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13211 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13213 static void cmd_set_nvgre_parsed(void *parsed_result,
13214 __rte_unused struct cmdline *cl,
13215 __rte_unused void *data)
13217 struct cmd_set_nvgre_result *res = parsed_result;
13219 uint32_t nvgre_tni;
13222 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13225 if (strcmp(res->nvgre, "nvgre") == 0)
13226 nvgre_encap_conf.select_vlan = 0;
13227 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13228 nvgre_encap_conf.select_vlan = 1;
13229 if (strcmp(res->ip_version, "ipv4") == 0)
13230 nvgre_encap_conf.select_ipv4 = 1;
13231 else if (strcmp(res->ip_version, "ipv6") == 0)
13232 nvgre_encap_conf.select_ipv4 = 0;
13235 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13236 if (nvgre_encap_conf.select_ipv4) {
13237 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13238 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13240 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13241 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13243 if (nvgre_encap_conf.select_vlan)
13244 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13245 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13246 RTE_ETHER_ADDR_LEN);
13247 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13248 RTE_ETHER_ADDR_LEN);
13251 cmdline_parse_inst_t cmd_set_nvgre = {
13252 .f = cmd_set_nvgre_parsed,
13254 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13255 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13256 " eth-dst <eth-dst>",
13258 (void *)&cmd_set_nvgre_set,
13259 (void *)&cmd_set_nvgre_nvgre,
13260 (void *)&cmd_set_nvgre_ip_version,
13261 (void *)&cmd_set_nvgre_ip_version_value,
13262 (void *)&cmd_set_nvgre_tni,
13263 (void *)&cmd_set_nvgre_tni_value,
13264 (void *)&cmd_set_nvgre_ip_src,
13265 (void *)&cmd_set_nvgre_ip_src_value,
13266 (void *)&cmd_set_nvgre_ip_dst,
13267 (void *)&cmd_set_nvgre_ip_dst_value,
13268 (void *)&cmd_set_nvgre_eth_src,
13269 (void *)&cmd_set_nvgre_eth_src_value,
13270 (void *)&cmd_set_nvgre_eth_dst,
13271 (void *)&cmd_set_nvgre_eth_dst_value,
13276 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13277 .f = cmd_set_nvgre_parsed,
13279 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13280 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13281 " eth-src <eth-src> eth-dst <eth-dst>",
13283 (void *)&cmd_set_nvgre_set,
13284 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13285 (void *)&cmd_set_nvgre_ip_version,
13286 (void *)&cmd_set_nvgre_ip_version_value,
13287 (void *)&cmd_set_nvgre_tni,
13288 (void *)&cmd_set_nvgre_tni_value,
13289 (void *)&cmd_set_nvgre_ip_src,
13290 (void *)&cmd_set_nvgre_ip_src_value,
13291 (void *)&cmd_set_nvgre_ip_dst,
13292 (void *)&cmd_set_nvgre_ip_dst_value,
13293 (void *)&cmd_set_nvgre_vlan,
13294 (void *)&cmd_set_nvgre_vlan_value,
13295 (void *)&cmd_set_nvgre_eth_src,
13296 (void *)&cmd_set_nvgre_eth_src_value,
13297 (void *)&cmd_set_nvgre_eth_dst,
13298 (void *)&cmd_set_nvgre_eth_dst_value,
13303 /** Set L2 encapsulation details */
13304 struct cmd_set_l2_encap_result {
13305 cmdline_fixed_string_t set;
13306 cmdline_fixed_string_t l2_encap;
13307 cmdline_fixed_string_t pos_token;
13308 cmdline_fixed_string_t ip_version;
13309 uint32_t vlan_present:1;
13311 struct rte_ether_addr eth_src;
13312 struct rte_ether_addr eth_dst;
13315 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13316 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13317 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13318 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13319 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13320 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13321 "l2_encap-with-vlan");
13322 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13323 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13325 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13326 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13328 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13329 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13331 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13332 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13333 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13334 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13336 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13337 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13338 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13339 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13341 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13342 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13344 static void cmd_set_l2_encap_parsed(void *parsed_result,
13345 __rte_unused struct cmdline *cl,
13346 __rte_unused void *data)
13348 struct cmd_set_l2_encap_result *res = parsed_result;
13350 if (strcmp(res->l2_encap, "l2_encap") == 0)
13351 l2_encap_conf.select_vlan = 0;
13352 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13353 l2_encap_conf.select_vlan = 1;
13354 if (strcmp(res->ip_version, "ipv4") == 0)
13355 l2_encap_conf.select_ipv4 = 1;
13356 else if (strcmp(res->ip_version, "ipv6") == 0)
13357 l2_encap_conf.select_ipv4 = 0;
13360 if (l2_encap_conf.select_vlan)
13361 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13362 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13363 RTE_ETHER_ADDR_LEN);
13364 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13365 RTE_ETHER_ADDR_LEN);
13368 cmdline_parse_inst_t cmd_set_l2_encap = {
13369 .f = cmd_set_l2_encap_parsed,
13371 .help_str = "set l2_encap ip-version ipv4|ipv6"
13372 " eth-src <eth-src> eth-dst <eth-dst>",
13374 (void *)&cmd_set_l2_encap_set,
13375 (void *)&cmd_set_l2_encap_l2_encap,
13376 (void *)&cmd_set_l2_encap_ip_version,
13377 (void *)&cmd_set_l2_encap_ip_version_value,
13378 (void *)&cmd_set_l2_encap_eth_src,
13379 (void *)&cmd_set_l2_encap_eth_src_value,
13380 (void *)&cmd_set_l2_encap_eth_dst,
13381 (void *)&cmd_set_l2_encap_eth_dst_value,
13386 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13387 .f = cmd_set_l2_encap_parsed,
13389 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13390 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13392 (void *)&cmd_set_l2_encap_set,
13393 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13394 (void *)&cmd_set_l2_encap_ip_version,
13395 (void *)&cmd_set_l2_encap_ip_version_value,
13396 (void *)&cmd_set_l2_encap_vlan,
13397 (void *)&cmd_set_l2_encap_vlan_value,
13398 (void *)&cmd_set_l2_encap_eth_src,
13399 (void *)&cmd_set_l2_encap_eth_src_value,
13400 (void *)&cmd_set_l2_encap_eth_dst,
13401 (void *)&cmd_set_l2_encap_eth_dst_value,
13406 /** Set L2 decapsulation details */
13407 struct cmd_set_l2_decap_result {
13408 cmdline_fixed_string_t set;
13409 cmdline_fixed_string_t l2_decap;
13410 cmdline_fixed_string_t pos_token;
13411 uint32_t vlan_present:1;
13414 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13415 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13416 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13417 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13419 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13420 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13421 "l2_decap-with-vlan");
13423 static void cmd_set_l2_decap_parsed(void *parsed_result,
13424 __rte_unused struct cmdline *cl,
13425 __rte_unused void *data)
13427 struct cmd_set_l2_decap_result *res = parsed_result;
13429 if (strcmp(res->l2_decap, "l2_decap") == 0)
13430 l2_decap_conf.select_vlan = 0;
13431 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13432 l2_decap_conf.select_vlan = 1;
13435 cmdline_parse_inst_t cmd_set_l2_decap = {
13436 .f = cmd_set_l2_decap_parsed,
13438 .help_str = "set l2_decap",
13440 (void *)&cmd_set_l2_decap_set,
13441 (void *)&cmd_set_l2_decap_l2_decap,
13446 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13447 .f = cmd_set_l2_decap_parsed,
13449 .help_str = "set l2_decap-with-vlan",
13451 (void *)&cmd_set_l2_decap_set,
13452 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13457 /** Set MPLSoGRE encapsulation details */
13458 struct cmd_set_mplsogre_encap_result {
13459 cmdline_fixed_string_t set;
13460 cmdline_fixed_string_t mplsogre;
13461 cmdline_fixed_string_t pos_token;
13462 cmdline_fixed_string_t ip_version;
13463 uint32_t vlan_present:1;
13465 cmdline_ipaddr_t ip_src;
13466 cmdline_ipaddr_t ip_dst;
13468 struct rte_ether_addr eth_src;
13469 struct rte_ether_addr eth_dst;
13472 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13473 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13475 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13476 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13478 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13479 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13480 mplsogre, "mplsogre_encap-with-vlan");
13481 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13482 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13483 pos_token, "ip-version");
13484 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13485 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13486 ip_version, "ipv4#ipv6");
13487 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13488 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13489 pos_token, "label");
13490 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13491 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13493 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13494 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13495 pos_token, "ip-src");
13496 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13497 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13498 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13499 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13500 pos_token, "ip-dst");
13501 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13502 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13503 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13504 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13505 pos_token, "vlan-tci");
13506 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13507 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13509 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13510 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13511 pos_token, "eth-src");
13512 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13513 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13515 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13516 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13517 pos_token, "eth-dst");
13518 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13519 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13522 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13523 __rte_unused struct cmdline *cl,
13524 __rte_unused void *data)
13526 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13528 uint32_t mplsogre_label;
13531 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13534 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13535 mplsogre_encap_conf.select_vlan = 0;
13536 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13537 mplsogre_encap_conf.select_vlan = 1;
13538 if (strcmp(res->ip_version, "ipv4") == 0)
13539 mplsogre_encap_conf.select_ipv4 = 1;
13540 else if (strcmp(res->ip_version, "ipv6") == 0)
13541 mplsogre_encap_conf.select_ipv4 = 0;
13544 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13545 if (mplsogre_encap_conf.select_ipv4) {
13546 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13547 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13549 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13550 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13552 if (mplsogre_encap_conf.select_vlan)
13553 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13554 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13555 RTE_ETHER_ADDR_LEN);
13556 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13557 RTE_ETHER_ADDR_LEN);
13560 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13561 .f = cmd_set_mplsogre_encap_parsed,
13563 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13564 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13565 " eth-dst <eth-dst>",
13567 (void *)&cmd_set_mplsogre_encap_set,
13568 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13569 (void *)&cmd_set_mplsogre_encap_ip_version,
13570 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13571 (void *)&cmd_set_mplsogre_encap_label,
13572 (void *)&cmd_set_mplsogre_encap_label_value,
13573 (void *)&cmd_set_mplsogre_encap_ip_src,
13574 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13575 (void *)&cmd_set_mplsogre_encap_ip_dst,
13576 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13577 (void *)&cmd_set_mplsogre_encap_eth_src,
13578 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13579 (void *)&cmd_set_mplsogre_encap_eth_dst,
13580 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13585 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13586 .f = cmd_set_mplsogre_encap_parsed,
13588 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13589 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13590 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13592 (void *)&cmd_set_mplsogre_encap_set,
13593 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13594 (void *)&cmd_set_mplsogre_encap_ip_version,
13595 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13596 (void *)&cmd_set_mplsogre_encap_label,
13597 (void *)&cmd_set_mplsogre_encap_label_value,
13598 (void *)&cmd_set_mplsogre_encap_ip_src,
13599 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13600 (void *)&cmd_set_mplsogre_encap_ip_dst,
13601 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13602 (void *)&cmd_set_mplsogre_encap_vlan,
13603 (void *)&cmd_set_mplsogre_encap_vlan_value,
13604 (void *)&cmd_set_mplsogre_encap_eth_src,
13605 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13606 (void *)&cmd_set_mplsogre_encap_eth_dst,
13607 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13612 /** Set MPLSoGRE decapsulation details */
13613 struct cmd_set_mplsogre_decap_result {
13614 cmdline_fixed_string_t set;
13615 cmdline_fixed_string_t mplsogre;
13616 cmdline_fixed_string_t pos_token;
13617 cmdline_fixed_string_t ip_version;
13618 uint32_t vlan_present:1;
13621 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13622 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13624 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13625 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13627 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13628 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13629 mplsogre, "mplsogre_decap-with-vlan");
13630 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13631 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13632 pos_token, "ip-version");
13633 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13634 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13635 ip_version, "ipv4#ipv6");
13637 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13638 __rte_unused struct cmdline *cl,
13639 __rte_unused void *data)
13641 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13643 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13644 mplsogre_decap_conf.select_vlan = 0;
13645 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13646 mplsogre_decap_conf.select_vlan = 1;
13647 if (strcmp(res->ip_version, "ipv4") == 0)
13648 mplsogre_decap_conf.select_ipv4 = 1;
13649 else if (strcmp(res->ip_version, "ipv6") == 0)
13650 mplsogre_decap_conf.select_ipv4 = 0;
13653 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13654 .f = cmd_set_mplsogre_decap_parsed,
13656 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13658 (void *)&cmd_set_mplsogre_decap_set,
13659 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13660 (void *)&cmd_set_mplsogre_decap_ip_version,
13661 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13666 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13667 .f = cmd_set_mplsogre_decap_parsed,
13669 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13671 (void *)&cmd_set_mplsogre_decap_set,
13672 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13673 (void *)&cmd_set_mplsogre_decap_ip_version,
13674 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13679 /** Set MPLSoUDP encapsulation details */
13680 struct cmd_set_mplsoudp_encap_result {
13681 cmdline_fixed_string_t set;
13682 cmdline_fixed_string_t mplsoudp;
13683 cmdline_fixed_string_t pos_token;
13684 cmdline_fixed_string_t ip_version;
13685 uint32_t vlan_present:1;
13689 cmdline_ipaddr_t ip_src;
13690 cmdline_ipaddr_t ip_dst;
13692 struct rte_ether_addr eth_src;
13693 struct rte_ether_addr eth_dst;
13696 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13697 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13699 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13700 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13702 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13703 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13704 mplsoudp, "mplsoudp_encap-with-vlan");
13705 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13706 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13707 pos_token, "ip-version");
13708 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13709 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13710 ip_version, "ipv4#ipv6");
13711 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13712 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13713 pos_token, "label");
13714 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13715 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13717 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13718 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13719 pos_token, "udp-src");
13720 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13721 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13723 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13724 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13725 pos_token, "udp-dst");
13726 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13727 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13729 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13730 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13731 pos_token, "ip-src");
13732 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13733 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13734 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13735 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13736 pos_token, "ip-dst");
13737 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13738 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13739 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13740 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13741 pos_token, "vlan-tci");
13742 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13743 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13745 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13746 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13747 pos_token, "eth-src");
13748 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13749 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13751 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13752 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13753 pos_token, "eth-dst");
13754 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13755 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13758 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13759 __rte_unused struct cmdline *cl,
13760 __rte_unused void *data)
13762 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13764 uint32_t mplsoudp_label;
13767 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13770 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13771 mplsoudp_encap_conf.select_vlan = 0;
13772 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13773 mplsoudp_encap_conf.select_vlan = 1;
13774 if (strcmp(res->ip_version, "ipv4") == 0)
13775 mplsoudp_encap_conf.select_ipv4 = 1;
13776 else if (strcmp(res->ip_version, "ipv6") == 0)
13777 mplsoudp_encap_conf.select_ipv4 = 0;
13780 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13781 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13782 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13783 if (mplsoudp_encap_conf.select_ipv4) {
13784 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13785 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13787 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13788 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13790 if (mplsoudp_encap_conf.select_vlan)
13791 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13792 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13793 RTE_ETHER_ADDR_LEN);
13794 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13795 RTE_ETHER_ADDR_LEN);
13798 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13799 .f = cmd_set_mplsoudp_encap_parsed,
13801 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13802 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13803 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13805 (void *)&cmd_set_mplsoudp_encap_set,
13806 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13807 (void *)&cmd_set_mplsoudp_encap_ip_version,
13808 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13809 (void *)&cmd_set_mplsoudp_encap_label,
13810 (void *)&cmd_set_mplsoudp_encap_label_value,
13811 (void *)&cmd_set_mplsoudp_encap_udp_src,
13812 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13813 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13814 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13815 (void *)&cmd_set_mplsoudp_encap_ip_src,
13816 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13817 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13818 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13819 (void *)&cmd_set_mplsoudp_encap_eth_src,
13820 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13821 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13822 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13827 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13828 .f = cmd_set_mplsoudp_encap_parsed,
13830 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13831 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13832 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13833 " eth-src <eth-src> eth-dst <eth-dst>",
13835 (void *)&cmd_set_mplsoudp_encap_set,
13836 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13837 (void *)&cmd_set_mplsoudp_encap_ip_version,
13838 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13839 (void *)&cmd_set_mplsoudp_encap_label,
13840 (void *)&cmd_set_mplsoudp_encap_label_value,
13841 (void *)&cmd_set_mplsoudp_encap_udp_src,
13842 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13843 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13844 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13845 (void *)&cmd_set_mplsoudp_encap_ip_src,
13846 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13847 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13848 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13849 (void *)&cmd_set_mplsoudp_encap_vlan,
13850 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13851 (void *)&cmd_set_mplsoudp_encap_eth_src,
13852 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13853 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13854 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13859 /** Set MPLSoUDP decapsulation details */
13860 struct cmd_set_mplsoudp_decap_result {
13861 cmdline_fixed_string_t set;
13862 cmdline_fixed_string_t mplsoudp;
13863 cmdline_fixed_string_t pos_token;
13864 cmdline_fixed_string_t ip_version;
13865 uint32_t vlan_present:1;
13868 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13869 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13871 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13872 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13874 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13875 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13876 mplsoudp, "mplsoudp_decap-with-vlan");
13877 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13878 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13879 pos_token, "ip-version");
13880 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13881 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13882 ip_version, "ipv4#ipv6");
13884 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13885 __rte_unused struct cmdline *cl,
13886 __rte_unused void *data)
13888 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13890 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13891 mplsoudp_decap_conf.select_vlan = 0;
13892 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13893 mplsoudp_decap_conf.select_vlan = 1;
13894 if (strcmp(res->ip_version, "ipv4") == 0)
13895 mplsoudp_decap_conf.select_ipv4 = 1;
13896 else if (strcmp(res->ip_version, "ipv6") == 0)
13897 mplsoudp_decap_conf.select_ipv4 = 0;
13900 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13901 .f = cmd_set_mplsoudp_decap_parsed,
13903 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13905 (void *)&cmd_set_mplsoudp_decap_set,
13906 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13907 (void *)&cmd_set_mplsoudp_decap_ip_version,
13908 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13913 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13914 .f = cmd_set_mplsoudp_decap_parsed,
13916 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13918 (void *)&cmd_set_mplsoudp_decap_set,
13919 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13920 (void *)&cmd_set_mplsoudp_decap_ip_version,
13921 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13926 /** Set connection tracking object common details */
13927 struct cmd_set_conntrack_common_result {
13928 cmdline_fixed_string_t set;
13929 cmdline_fixed_string_t conntrack;
13930 cmdline_fixed_string_t common;
13931 cmdline_fixed_string_t peer;
13932 cmdline_fixed_string_t is_orig;
13933 cmdline_fixed_string_t enable;
13934 cmdline_fixed_string_t live;
13935 cmdline_fixed_string_t sack;
13936 cmdline_fixed_string_t cack;
13937 cmdline_fixed_string_t last_dir;
13938 cmdline_fixed_string_t liberal;
13939 cmdline_fixed_string_t state;
13940 cmdline_fixed_string_t max_ack_win;
13941 cmdline_fixed_string_t retrans;
13942 cmdline_fixed_string_t last_win;
13943 cmdline_fixed_string_t last_seq;
13944 cmdline_fixed_string_t last_ack;
13945 cmdline_fixed_string_t last_end;
13946 cmdline_fixed_string_t last_index;
13949 uint16_t peer_port;
13950 uint32_t is_original;
13965 cmdline_parse_token_string_t cmd_set_conntrack_set =
13966 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13968 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13969 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13970 conntrack, "conntrack");
13971 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13972 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13974 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13975 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13977 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13978 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13979 peer_port, RTE_UINT16);
13980 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13981 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13982 is_orig, "is_orig");
13983 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13984 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13985 is_original, RTE_UINT32);
13986 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13987 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13989 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13990 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13992 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13993 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13995 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13996 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13997 is_live, RTE_UINT32);
13998 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13999 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14001 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14002 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14003 s_ack, RTE_UINT32);
14004 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14005 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14007 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14008 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14009 c_ack, RTE_UINT32);
14010 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14011 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14012 last_dir, "last_dir");
14013 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14014 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14016 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14017 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14018 liberal, "liberal");
14019 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14020 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14022 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14023 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14025 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14026 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14028 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14029 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14030 max_ack_win, "max_ack_win");
14031 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14032 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14033 factor, RTE_UINT8);
14034 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14035 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14037 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14038 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14039 re_num, RTE_UINT8);
14040 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14041 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14042 last_win, "last_win");
14043 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14044 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14046 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14047 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14048 last_seq, "last_seq");
14049 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14050 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14052 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14053 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14054 last_ack, "last_ack");
14055 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14056 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14058 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14059 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14060 last_end, "last_end");
14061 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14062 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14064 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14065 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14066 last_index, "last_index");
14067 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14068 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14071 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14072 __rte_unused struct cmdline *cl,
14073 __rte_unused void *data)
14075 struct cmd_set_conntrack_common_result *res = parsed_result;
14077 /* No need to swap to big endian. */
14078 conntrack_context.peer_port = res->peer_port;
14079 conntrack_context.is_original_dir = res->is_original;
14080 conntrack_context.enable = res->en;
14081 conntrack_context.live_connection = res->is_live;
14082 conntrack_context.selective_ack = res->s_ack;
14083 conntrack_context.challenge_ack_passed = res->c_ack;
14084 conntrack_context.last_direction = res->ld;
14085 conntrack_context.liberal_mode = res->lb;
14086 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14087 conntrack_context.max_ack_window = res->factor;
14088 conntrack_context.retransmission_limit = res->re_num;
14089 conntrack_context.last_window = res->lw;
14090 conntrack_context.last_index =
14091 (enum rte_flow_conntrack_tcp_last_index)res->li;
14092 conntrack_context.last_seq = res->ls;
14093 conntrack_context.last_ack = res->la;
14094 conntrack_context.last_end = res->le;
14097 cmdline_parse_inst_t cmd_set_conntrack_common = {
14098 .f = cmd_set_conntrack_common_parsed,
14100 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14101 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14102 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14103 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14104 " last_index <flag>",
14106 (void *)&cmd_set_conntrack_set,
14107 (void *)&cmd_set_conntrack_conntrack,
14108 (void *)&cmd_set_conntrack_common_com,
14109 (void *)&cmd_set_conntrack_common_peer,
14110 (void *)&cmd_set_conntrack_common_peer_value,
14111 (void *)&cmd_set_conntrack_common_is_orig,
14112 (void *)&cmd_set_conntrack_common_is_orig_value,
14113 (void *)&cmd_set_conntrack_common_enable,
14114 (void *)&cmd_set_conntrack_common_enable_value,
14115 (void *)&cmd_set_conntrack_common_live,
14116 (void *)&cmd_set_conntrack_common_live_value,
14117 (void *)&cmd_set_conntrack_common_sack,
14118 (void *)&cmd_set_conntrack_common_sack_value,
14119 (void *)&cmd_set_conntrack_common_cack,
14120 (void *)&cmd_set_conntrack_common_cack_value,
14121 (void *)&cmd_set_conntrack_common_last_dir,
14122 (void *)&cmd_set_conntrack_common_last_dir_value,
14123 (void *)&cmd_set_conntrack_common_liberal,
14124 (void *)&cmd_set_conntrack_common_liberal_value,
14125 (void *)&cmd_set_conntrack_common_state,
14126 (void *)&cmd_set_conntrack_common_state_value,
14127 (void *)&cmd_set_conntrack_common_max_ackwin,
14128 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14129 (void *)&cmd_set_conntrack_common_retrans,
14130 (void *)&cmd_set_conntrack_common_retrans_value,
14131 (void *)&cmd_set_conntrack_common_last_win,
14132 (void *)&cmd_set_conntrack_common_last_win_value,
14133 (void *)&cmd_set_conntrack_common_last_seq,
14134 (void *)&cmd_set_conntrack_common_last_seq_value,
14135 (void *)&cmd_set_conntrack_common_last_ack,
14136 (void *)&cmd_set_conntrack_common_last_ack_value,
14137 (void *)&cmd_set_conntrack_common_last_end,
14138 (void *)&cmd_set_conntrack_common_last_end_value,
14139 (void *)&cmd_set_conntrack_common_last_index,
14140 (void *)&cmd_set_conntrack_common_last_index_value,
14145 /** Set connection tracking object both directions' details */
14146 struct cmd_set_conntrack_dir_result {
14147 cmdline_fixed_string_t set;
14148 cmdline_fixed_string_t conntrack;
14149 cmdline_fixed_string_t dir;
14150 cmdline_fixed_string_t scale;
14151 cmdline_fixed_string_t fin;
14152 cmdline_fixed_string_t ack_seen;
14153 cmdline_fixed_string_t unack;
14154 cmdline_fixed_string_t sent_end;
14155 cmdline_fixed_string_t reply_end;
14156 cmdline_fixed_string_t max_win;
14157 cmdline_fixed_string_t max_ack;
14168 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14169 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14171 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14172 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14173 conntrack, "conntrack");
14174 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14175 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14177 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14178 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14180 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14181 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14182 factor, RTE_UINT32);
14183 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14184 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14186 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14187 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14189 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14190 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14191 ack_seen, "acked");
14192 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14193 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14195 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14196 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14197 unack, "unack_data");
14198 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14199 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14201 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14202 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14203 sent_end, "sent_end");
14204 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14205 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14207 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14208 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14209 reply_end, "reply_end");
14210 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14211 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14213 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14214 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14215 max_win, "max_win");
14216 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14217 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14219 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14220 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14221 max_ack, "max_ack");
14222 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14223 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14226 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14227 __rte_unused struct cmdline *cl,
14228 __rte_unused void *data)
14230 struct cmd_set_conntrack_dir_result *res = parsed_result;
14231 struct rte_flow_tcp_dir_param *dir = NULL;
14233 if (strcmp(res->dir, "orig") == 0)
14234 dir = &conntrack_context.original_dir;
14235 else if (strcmp(res->dir, "rply") == 0)
14236 dir = &conntrack_context.reply_dir;
14239 dir->scale = res->factor;
14240 dir->close_initiated = res->f;
14241 dir->last_ack_seen = res->as;
14242 dir->data_unacked = res->un;
14243 dir->sent_end = res->se;
14244 dir->reply_end = res->re;
14245 dir->max_ack = res->ma;
14246 dir->max_win = res->mw;
14249 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14250 .f = cmd_set_conntrack_dir_parsed,
14252 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14253 " acked <seen> unack_data <unack> sent_end <sent>"
14254 " reply_end <reply> max_win <win> max_ack <ack>",
14256 (void *)&cmd_set_conntrack_set,
14257 (void *)&cmd_set_conntrack_conntrack,
14258 (void *)&cmd_set_conntrack_dir_dir,
14259 (void *)&cmd_set_conntrack_dir_scale,
14260 (void *)&cmd_set_conntrack_dir_scale_value,
14261 (void *)&cmd_set_conntrack_dir_fin,
14262 (void *)&cmd_set_conntrack_dir_fin_value,
14263 (void *)&cmd_set_conntrack_dir_ack,
14264 (void *)&cmd_set_conntrack_dir_ack_value,
14265 (void *)&cmd_set_conntrack_dir_unack_data,
14266 (void *)&cmd_set_conntrack_dir_unack_data_value,
14267 (void *)&cmd_set_conntrack_dir_sent_end,
14268 (void *)&cmd_set_conntrack_dir_sent_end_value,
14269 (void *)&cmd_set_conntrack_dir_reply_end,
14270 (void *)&cmd_set_conntrack_dir_reply_end_value,
14271 (void *)&cmd_set_conntrack_dir_max_win,
14272 (void *)&cmd_set_conntrack_dir_max_win_value,
14273 (void *)&cmd_set_conntrack_dir_max_ack,
14274 (void *)&cmd_set_conntrack_dir_max_ack_value,
14279 /* Strict link priority scheduling mode setting */
14281 cmd_strict_link_prio_parsed(
14282 void *parsed_result,
14283 __rte_unused struct cmdline *cl,
14284 __rte_unused void *data)
14286 struct cmd_vf_tc_bw_result *res = parsed_result;
14287 int ret = -ENOTSUP;
14289 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14292 #ifdef RTE_NET_I40E
14293 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14300 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14303 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14306 fprintf(stderr, "function not implemented\n");
14309 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14313 cmdline_parse_inst_t cmd_strict_link_prio = {
14314 .f = cmd_strict_link_prio_parsed,
14316 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14318 (void *)&cmd_vf_tc_bw_set,
14319 (void *)&cmd_vf_tc_bw_tx,
14320 (void *)&cmd_vf_tc_bw_strict_link_prio,
14321 (void *)&cmd_vf_tc_bw_port_id,
14322 (void *)&cmd_vf_tc_bw_tc_map,
14327 /* Load dynamic device personalization*/
14328 struct cmd_ddp_add_result {
14329 cmdline_fixed_string_t ddp;
14330 cmdline_fixed_string_t add;
14335 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14336 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14337 cmdline_parse_token_string_t cmd_ddp_add_add =
14338 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14339 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14340 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14342 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14343 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14346 cmd_ddp_add_parsed(
14347 void *parsed_result,
14348 __rte_unused struct cmdline *cl,
14349 __rte_unused void *data)
14351 struct cmd_ddp_add_result *res = parsed_result;
14357 int ret = -ENOTSUP;
14359 if (!all_ports_stopped()) {
14360 fprintf(stderr, "Please stop all ports first\n");
14364 filepath = strdup(res->filepath);
14365 if (filepath == NULL) {
14366 fprintf(stderr, "Failed to allocate memory\n");
14369 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14371 buff = open_file(file_fld[0], &size);
14373 free((void *)filepath);
14377 #ifdef RTE_NET_I40E
14378 if (ret == -ENOTSUP)
14379 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14381 RTE_PMD_I40E_PKG_OP_WR_ADD);
14384 if (ret == -EEXIST)
14385 fprintf(stderr, "Profile has already existed.\n");
14387 fprintf(stderr, "Failed to load profile.\n");
14388 else if (file_num == 2)
14389 save_file(file_fld[1], buff, size);
14392 free((void *)filepath);
14395 cmdline_parse_inst_t cmd_ddp_add = {
14396 .f = cmd_ddp_add_parsed,
14398 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14400 (void *)&cmd_ddp_add_ddp,
14401 (void *)&cmd_ddp_add_add,
14402 (void *)&cmd_ddp_add_port_id,
14403 (void *)&cmd_ddp_add_filepath,
14408 /* Delete dynamic device personalization*/
14409 struct cmd_ddp_del_result {
14410 cmdline_fixed_string_t ddp;
14411 cmdline_fixed_string_t del;
14416 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14417 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14418 cmdline_parse_token_string_t cmd_ddp_del_del =
14419 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14420 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14421 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14422 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14423 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14426 cmd_ddp_del_parsed(
14427 void *parsed_result,
14428 __rte_unused struct cmdline *cl,
14429 __rte_unused void *data)
14431 struct cmd_ddp_del_result *res = parsed_result;
14434 int ret = -ENOTSUP;
14436 if (!all_ports_stopped()) {
14437 fprintf(stderr, "Please stop all ports first\n");
14441 buff = open_file(res->filepath, &size);
14445 #ifdef RTE_NET_I40E
14446 if (ret == -ENOTSUP)
14447 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14449 RTE_PMD_I40E_PKG_OP_WR_DEL);
14452 if (ret == -EACCES)
14453 fprintf(stderr, "Profile does not exist.\n");
14455 fprintf(stderr, "Failed to delete profile.\n");
14460 cmdline_parse_inst_t cmd_ddp_del = {
14461 .f = cmd_ddp_del_parsed,
14463 .help_str = "ddp del <port_id> <backup_profile_path>",
14465 (void *)&cmd_ddp_del_ddp,
14466 (void *)&cmd_ddp_del_del,
14467 (void *)&cmd_ddp_del_port_id,
14468 (void *)&cmd_ddp_del_filepath,
14473 /* Get dynamic device personalization profile info */
14474 struct cmd_ddp_info_result {
14475 cmdline_fixed_string_t ddp;
14476 cmdline_fixed_string_t get;
14477 cmdline_fixed_string_t info;
14481 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14483 cmdline_parse_token_string_t cmd_ddp_info_get =
14484 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14485 cmdline_parse_token_string_t cmd_ddp_info_info =
14486 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14487 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14488 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14491 cmd_ddp_info_parsed(
14492 void *parsed_result,
14493 __rte_unused struct cmdline *cl,
14494 __rte_unused void *data)
14496 struct cmd_ddp_info_result *res = parsed_result;
14499 int ret = -ENOTSUP;
14500 #ifdef RTE_NET_I40E
14503 uint32_t buff_size = 0;
14504 struct rte_pmd_i40e_profile_info info;
14505 uint32_t dev_num = 0;
14506 struct rte_pmd_i40e_ddp_device_id *devs;
14507 uint32_t proto_num = 0;
14508 struct rte_pmd_i40e_proto_info *proto = NULL;
14509 uint32_t pctype_num = 0;
14510 struct rte_pmd_i40e_ptype_info *pctype;
14511 uint32_t ptype_num = 0;
14512 struct rte_pmd_i40e_ptype_info *ptype;
14517 pkg = open_file(res->filepath, &pkg_size);
14521 #ifdef RTE_NET_I40E
14522 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14523 (uint8_t *)&info, sizeof(info),
14524 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14526 printf("Global Track id: 0x%x\n", info.track_id);
14527 printf("Global Version: %d.%d.%d.%d\n",
14528 info.version.major,
14529 info.version.minor,
14530 info.version.update,
14531 info.version.draft);
14532 printf("Global Package name: %s\n\n", info.name);
14535 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14536 (uint8_t *)&info, sizeof(info),
14537 RTE_PMD_I40E_PKG_INFO_HEADER);
14539 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14540 printf("i40e Profile Version: %d.%d.%d.%d\n",
14541 info.version.major,
14542 info.version.minor,
14543 info.version.update,
14544 info.version.draft);
14545 printf("i40e Profile name: %s\n\n", info.name);
14548 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14549 (uint8_t *)&buff_size, sizeof(buff_size),
14550 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14551 if (!ret && buff_size) {
14552 buff = (uint8_t *)malloc(buff_size);
14554 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14556 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14558 printf("Package Notes:\n%s\n\n", buff);
14563 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14564 (uint8_t *)&dev_num, sizeof(dev_num),
14565 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14566 if (!ret && dev_num) {
14567 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14568 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14570 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14571 (uint8_t *)devs, buff_size,
14572 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14574 printf("List of supported devices:\n");
14575 for (i = 0; i < dev_num; i++) {
14576 printf(" %04X:%04X %04X:%04X\n",
14577 devs[i].vendor_dev_id >> 16,
14578 devs[i].vendor_dev_id & 0xFFFF,
14579 devs[i].sub_vendor_dev_id >> 16,
14580 devs[i].sub_vendor_dev_id & 0xFFFF);
14588 /* get information about protocols and packet types */
14589 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14590 (uint8_t *)&proto_num, sizeof(proto_num),
14591 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14592 if (ret || !proto_num)
14593 goto no_print_return;
14595 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14596 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14598 goto no_print_return;
14600 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14602 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14604 printf("List of used protocols:\n");
14605 for (i = 0; i < proto_num; i++)
14606 printf(" %2u: %s\n", proto[i].proto_id,
14610 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14611 (uint8_t *)&pctype_num, sizeof(pctype_num),
14612 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14613 if (ret || !pctype_num)
14614 goto no_print_pctypes;
14616 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14617 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14619 goto no_print_pctypes;
14621 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14623 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14626 goto no_print_pctypes;
14629 printf("List of defined packet classification types:\n");
14630 for (i = 0; i < pctype_num; i++) {
14631 printf(" %2u:", pctype[i].ptype_id);
14632 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14633 proto_id = pctype[i].protocols[j];
14634 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14635 for (n = 0; n < proto_num; n++) {
14636 if (proto[n].proto_id == proto_id) {
14637 printf(" %s", proto[n].name);
14650 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14652 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14653 if (ret || !ptype_num)
14654 goto no_print_return;
14656 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14657 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14659 goto no_print_return;
14661 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14663 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14666 goto no_print_return;
14668 printf("List of defined packet types:\n");
14669 for (i = 0; i < ptype_num; i++) {
14670 printf(" %2u:", ptype[i].ptype_id);
14671 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14672 proto_id = ptype[i].protocols[j];
14673 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14674 for (n = 0; n < proto_num; n++) {
14675 if (proto[n].proto_id == proto_id) {
14676 printf(" %s", proto[n].name);
14692 if (ret == -ENOTSUP)
14693 fprintf(stderr, "Function not supported in PMD driver\n");
14697 cmdline_parse_inst_t cmd_ddp_get_info = {
14698 .f = cmd_ddp_info_parsed,
14700 .help_str = "ddp get info <profile_path>",
14702 (void *)&cmd_ddp_info_ddp,
14703 (void *)&cmd_ddp_info_get,
14704 (void *)&cmd_ddp_info_info,
14705 (void *)&cmd_ddp_info_filepath,
14710 /* Get dynamic device personalization profile info list*/
14711 #define PROFILE_INFO_SIZE 48
14712 #define MAX_PROFILE_NUM 16
14714 struct cmd_ddp_get_list_result {
14715 cmdline_fixed_string_t ddp;
14716 cmdline_fixed_string_t get;
14717 cmdline_fixed_string_t list;
14721 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14722 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14723 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14724 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14725 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14726 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14727 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14728 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14732 cmd_ddp_get_list_parsed(
14733 __rte_unused void *parsed_result,
14734 __rte_unused struct cmdline *cl,
14735 __rte_unused void *data)
14737 #ifdef RTE_NET_I40E
14738 struct cmd_ddp_get_list_result *res = parsed_result;
14739 struct rte_pmd_i40e_profile_list *p_list;
14740 struct rte_pmd_i40e_profile_info *p_info;
14745 int ret = -ENOTSUP;
14747 #ifdef RTE_NET_I40E
14748 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14749 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14751 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14755 if (ret == -ENOTSUP)
14756 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14757 (uint8_t *)p_list, size);
14760 p_num = p_list->p_count;
14761 printf("Profile number is: %d\n\n", p_num);
14763 for (i = 0; i < p_num; i++) {
14764 p_info = &p_list->p_info[i];
14765 printf("Profile %d:\n", i);
14766 printf("Track id: 0x%x\n", p_info->track_id);
14767 printf("Version: %d.%d.%d.%d\n",
14768 p_info->version.major,
14769 p_info->version.minor,
14770 p_info->version.update,
14771 p_info->version.draft);
14772 printf("Profile name: %s\n\n", p_info->name);
14780 fprintf(stderr, "Failed to get ddp list\n");
14783 cmdline_parse_inst_t cmd_ddp_get_list = {
14784 .f = cmd_ddp_get_list_parsed,
14786 .help_str = "ddp get list <port_id>",
14788 (void *)&cmd_ddp_get_list_ddp,
14789 (void *)&cmd_ddp_get_list_get,
14790 (void *)&cmd_ddp_get_list_list,
14791 (void *)&cmd_ddp_get_list_port_id,
14796 /* Configure input set */
14797 struct cmd_cfg_input_set_result {
14798 cmdline_fixed_string_t port;
14799 cmdline_fixed_string_t cfg;
14801 cmdline_fixed_string_t pctype;
14803 cmdline_fixed_string_t inset_type;
14804 cmdline_fixed_string_t opt;
14805 cmdline_fixed_string_t field;
14810 cmd_cfg_input_set_parsed(
14811 __rte_unused void *parsed_result,
14812 __rte_unused struct cmdline *cl,
14813 __rte_unused void *data)
14815 #ifdef RTE_NET_I40E
14816 struct cmd_cfg_input_set_result *res = parsed_result;
14817 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14818 struct rte_pmd_i40e_inset inset;
14820 int ret = -ENOTSUP;
14822 if (!all_ports_stopped()) {
14823 fprintf(stderr, "Please stop all ports first\n");
14827 #ifdef RTE_NET_I40E
14828 if (!strcmp(res->inset_type, "hash_inset"))
14829 inset_type = INSET_HASH;
14830 else if (!strcmp(res->inset_type, "fdir_inset"))
14831 inset_type = INSET_FDIR;
14832 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14833 inset_type = INSET_FDIR_FLX;
14834 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14835 &inset, inset_type);
14837 fprintf(stderr, "Failed to get input set.\n");
14841 if (!strcmp(res->opt, "get")) {
14842 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14845 printf("Field index %d is enabled.\n", res->field_idx);
14847 printf("Field index %d is disabled.\n", res->field_idx);
14849 } else if (!strcmp(res->opt, "set"))
14850 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14852 else if (!strcmp(res->opt, "clear"))
14853 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14856 fprintf(stderr, "Failed to configure input set field.\n");
14860 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14861 &inset, inset_type);
14863 fprintf(stderr, "Failed to set input set.\n");
14868 if (ret == -ENOTSUP)
14869 fprintf(stderr, "Function not supported\n");
14872 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14873 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14875 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14876 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14878 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14879 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14880 port_id, RTE_UINT16);
14881 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14882 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14884 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14885 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14886 pctype_id, RTE_UINT8);
14887 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14888 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14890 "hash_inset#fdir_inset#fdir_flx_inset");
14891 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14892 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14893 opt, "get#set#clear");
14894 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14895 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14897 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14898 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14899 field_idx, RTE_UINT8);
14901 cmdline_parse_inst_t cmd_cfg_input_set = {
14902 .f = cmd_cfg_input_set_parsed,
14904 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14905 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14907 (void *)&cmd_cfg_input_set_port,
14908 (void *)&cmd_cfg_input_set_cfg,
14909 (void *)&cmd_cfg_input_set_port_id,
14910 (void *)&cmd_cfg_input_set_pctype,
14911 (void *)&cmd_cfg_input_set_pctype_id,
14912 (void *)&cmd_cfg_input_set_inset_type,
14913 (void *)&cmd_cfg_input_set_opt,
14914 (void *)&cmd_cfg_input_set_field,
14915 (void *)&cmd_cfg_input_set_field_idx,
14920 /* Clear input set */
14921 struct cmd_clear_input_set_result {
14922 cmdline_fixed_string_t port;
14923 cmdline_fixed_string_t cfg;
14925 cmdline_fixed_string_t pctype;
14927 cmdline_fixed_string_t inset_type;
14928 cmdline_fixed_string_t clear;
14929 cmdline_fixed_string_t all;
14933 cmd_clear_input_set_parsed(
14934 __rte_unused void *parsed_result,
14935 __rte_unused struct cmdline *cl,
14936 __rte_unused void *data)
14938 #ifdef RTE_NET_I40E
14939 struct cmd_clear_input_set_result *res = parsed_result;
14940 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14941 struct rte_pmd_i40e_inset inset;
14943 int ret = -ENOTSUP;
14945 if (!all_ports_stopped()) {
14946 fprintf(stderr, "Please stop all ports first\n");
14950 #ifdef RTE_NET_I40E
14951 if (!strcmp(res->inset_type, "hash_inset"))
14952 inset_type = INSET_HASH;
14953 else if (!strcmp(res->inset_type, "fdir_inset"))
14954 inset_type = INSET_FDIR;
14955 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14956 inset_type = INSET_FDIR_FLX;
14958 memset(&inset, 0, sizeof(inset));
14960 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14961 &inset, inset_type);
14963 fprintf(stderr, "Failed to clear input set.\n");
14969 if (ret == -ENOTSUP)
14970 fprintf(stderr, "Function not supported\n");
14973 cmdline_parse_token_string_t cmd_clear_input_set_port =
14974 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14976 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14977 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14979 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14980 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14981 port_id, RTE_UINT16);
14982 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14983 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14985 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14986 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14987 pctype_id, RTE_UINT8);
14988 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14989 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14991 "hash_inset#fdir_inset#fdir_flx_inset");
14992 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14993 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14995 cmdline_parse_token_string_t cmd_clear_input_set_all =
14996 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14999 cmdline_parse_inst_t cmd_clear_input_set = {
15000 .f = cmd_clear_input_set_parsed,
15002 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15003 "fdir_inset|fdir_flx_inset clear all",
15005 (void *)&cmd_clear_input_set_port,
15006 (void *)&cmd_clear_input_set_cfg,
15007 (void *)&cmd_clear_input_set_port_id,
15008 (void *)&cmd_clear_input_set_pctype,
15009 (void *)&cmd_clear_input_set_pctype_id,
15010 (void *)&cmd_clear_input_set_inset_type,
15011 (void *)&cmd_clear_input_set_clear,
15012 (void *)&cmd_clear_input_set_all,
15017 /* show vf stats */
15019 /* Common result structure for show vf stats */
15020 struct cmd_show_vf_stats_result {
15021 cmdline_fixed_string_t show;
15022 cmdline_fixed_string_t vf;
15023 cmdline_fixed_string_t stats;
15028 /* Common CLI fields show vf stats*/
15029 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15030 TOKEN_STRING_INITIALIZER
15031 (struct cmd_show_vf_stats_result,
15033 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15034 TOKEN_STRING_INITIALIZER
15035 (struct cmd_show_vf_stats_result,
15037 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15038 TOKEN_STRING_INITIALIZER
15039 (struct cmd_show_vf_stats_result,
15041 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15042 TOKEN_NUM_INITIALIZER
15043 (struct cmd_show_vf_stats_result,
15044 port_id, RTE_UINT16);
15045 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15046 TOKEN_NUM_INITIALIZER
15047 (struct cmd_show_vf_stats_result,
15048 vf_id, RTE_UINT16);
15051 cmd_show_vf_stats_parsed(
15052 void *parsed_result,
15053 __rte_unused struct cmdline *cl,
15054 __rte_unused void *data)
15056 struct cmd_show_vf_stats_result *res = parsed_result;
15057 struct rte_eth_stats stats;
15058 int ret = -ENOTSUP;
15059 static const char *nic_stats_border = "########################";
15061 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15064 memset(&stats, 0, sizeof(stats));
15066 #ifdef RTE_NET_I40E
15067 if (ret == -ENOTSUP)
15068 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15072 #ifdef RTE_NET_BNXT
15073 if (ret == -ENOTSUP)
15074 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15083 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15086 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15089 fprintf(stderr, "function not implemented\n");
15092 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15095 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15096 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15098 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15100 stats.ipackets, stats.imissed, stats.ibytes);
15101 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15102 printf(" RX-nombuf: %-10"PRIu64"\n",
15104 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15106 stats.opackets, stats.oerrors, stats.obytes);
15108 printf(" %s############################%s\n",
15109 nic_stats_border, nic_stats_border);
15112 cmdline_parse_inst_t cmd_show_vf_stats = {
15113 .f = cmd_show_vf_stats_parsed,
15115 .help_str = "show vf stats <port_id> <vf_id>",
15117 (void *)&cmd_show_vf_stats_show,
15118 (void *)&cmd_show_vf_stats_vf,
15119 (void *)&cmd_show_vf_stats_stats,
15120 (void *)&cmd_show_vf_stats_port_id,
15121 (void *)&cmd_show_vf_stats_vf_id,
15126 /* clear vf stats */
15128 /* Common result structure for clear vf stats */
15129 struct cmd_clear_vf_stats_result {
15130 cmdline_fixed_string_t clear;
15131 cmdline_fixed_string_t vf;
15132 cmdline_fixed_string_t stats;
15137 /* Common CLI fields clear vf stats*/
15138 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15139 TOKEN_STRING_INITIALIZER
15140 (struct cmd_clear_vf_stats_result,
15142 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15143 TOKEN_STRING_INITIALIZER
15144 (struct cmd_clear_vf_stats_result,
15146 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15147 TOKEN_STRING_INITIALIZER
15148 (struct cmd_clear_vf_stats_result,
15150 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15151 TOKEN_NUM_INITIALIZER
15152 (struct cmd_clear_vf_stats_result,
15153 port_id, RTE_UINT16);
15154 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15155 TOKEN_NUM_INITIALIZER
15156 (struct cmd_clear_vf_stats_result,
15157 vf_id, RTE_UINT16);
15160 cmd_clear_vf_stats_parsed(
15161 void *parsed_result,
15162 __rte_unused struct cmdline *cl,
15163 __rte_unused void *data)
15165 struct cmd_clear_vf_stats_result *res = parsed_result;
15166 int ret = -ENOTSUP;
15168 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15171 #ifdef RTE_NET_I40E
15172 if (ret == -ENOTSUP)
15173 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15176 #ifdef RTE_NET_BNXT
15177 if (ret == -ENOTSUP)
15178 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15186 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15189 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15192 fprintf(stderr, "function not implemented\n");
15195 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15199 cmdline_parse_inst_t cmd_clear_vf_stats = {
15200 .f = cmd_clear_vf_stats_parsed,
15202 .help_str = "clear vf stats <port_id> <vf_id>",
15204 (void *)&cmd_clear_vf_stats_clear,
15205 (void *)&cmd_clear_vf_stats_vf,
15206 (void *)&cmd_clear_vf_stats_stats,
15207 (void *)&cmd_clear_vf_stats_port_id,
15208 (void *)&cmd_clear_vf_stats_vf_id,
15213 /* port config pctype mapping reset */
15215 /* Common result structure for port config pctype mapping reset */
15216 struct cmd_pctype_mapping_reset_result {
15217 cmdline_fixed_string_t port;
15218 cmdline_fixed_string_t config;
15220 cmdline_fixed_string_t pctype;
15221 cmdline_fixed_string_t mapping;
15222 cmdline_fixed_string_t reset;
15225 /* Common CLI fields for port config pctype mapping reset*/
15226 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15227 TOKEN_STRING_INITIALIZER
15228 (struct cmd_pctype_mapping_reset_result,
15230 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15231 TOKEN_STRING_INITIALIZER
15232 (struct cmd_pctype_mapping_reset_result,
15234 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15235 TOKEN_NUM_INITIALIZER
15236 (struct cmd_pctype_mapping_reset_result,
15237 port_id, RTE_UINT16);
15238 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15239 TOKEN_STRING_INITIALIZER
15240 (struct cmd_pctype_mapping_reset_result,
15242 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15243 TOKEN_STRING_INITIALIZER
15244 (struct cmd_pctype_mapping_reset_result,
15245 mapping, "mapping");
15246 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15247 TOKEN_STRING_INITIALIZER
15248 (struct cmd_pctype_mapping_reset_result,
15252 cmd_pctype_mapping_reset_parsed(
15253 void *parsed_result,
15254 __rte_unused struct cmdline *cl,
15255 __rte_unused void *data)
15257 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15258 int ret = -ENOTSUP;
15260 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15263 #ifdef RTE_NET_I40E
15264 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15271 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15274 fprintf(stderr, "function not implemented\n");
15277 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15281 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15282 .f = cmd_pctype_mapping_reset_parsed,
15284 .help_str = "port config <port_id> pctype mapping reset",
15286 (void *)&cmd_pctype_mapping_reset_port,
15287 (void *)&cmd_pctype_mapping_reset_config,
15288 (void *)&cmd_pctype_mapping_reset_port_id,
15289 (void *)&cmd_pctype_mapping_reset_pctype,
15290 (void *)&cmd_pctype_mapping_reset_mapping,
15291 (void *)&cmd_pctype_mapping_reset_reset,
15296 /* show port pctype mapping */
15298 /* Common result structure for show port pctype mapping */
15299 struct cmd_pctype_mapping_get_result {
15300 cmdline_fixed_string_t show;
15301 cmdline_fixed_string_t port;
15303 cmdline_fixed_string_t pctype;
15304 cmdline_fixed_string_t mapping;
15307 /* Common CLI fields for pctype mapping get */
15308 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15309 TOKEN_STRING_INITIALIZER
15310 (struct cmd_pctype_mapping_get_result,
15312 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15313 TOKEN_STRING_INITIALIZER
15314 (struct cmd_pctype_mapping_get_result,
15316 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15317 TOKEN_NUM_INITIALIZER
15318 (struct cmd_pctype_mapping_get_result,
15319 port_id, RTE_UINT16);
15320 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15321 TOKEN_STRING_INITIALIZER
15322 (struct cmd_pctype_mapping_get_result,
15324 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15325 TOKEN_STRING_INITIALIZER
15326 (struct cmd_pctype_mapping_get_result,
15327 mapping, "mapping");
15330 cmd_pctype_mapping_get_parsed(
15331 void *parsed_result,
15332 __rte_unused struct cmdline *cl,
15333 __rte_unused void *data)
15335 struct cmd_pctype_mapping_get_result *res = parsed_result;
15336 int ret = -ENOTSUP;
15337 #ifdef RTE_NET_I40E
15338 struct rte_pmd_i40e_flow_type_mapping
15339 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15340 int i, j, first_pctype;
15343 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15346 #ifdef RTE_NET_I40E
15347 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15354 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15357 fprintf(stderr, "function not implemented\n");
15360 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15364 #ifdef RTE_NET_I40E
15365 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15366 if (mapping[i].pctype != 0ULL) {
15369 printf("pctype: ");
15370 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15371 if (mapping[i].pctype & (1ULL << j)) {
15372 printf(first_pctype ?
15373 "%02d" : ",%02d", j);
15377 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15383 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15384 .f = cmd_pctype_mapping_get_parsed,
15386 .help_str = "show port <port_id> pctype mapping",
15388 (void *)&cmd_pctype_mapping_get_show,
15389 (void *)&cmd_pctype_mapping_get_port,
15390 (void *)&cmd_pctype_mapping_get_port_id,
15391 (void *)&cmd_pctype_mapping_get_pctype,
15392 (void *)&cmd_pctype_mapping_get_mapping,
15397 /* port config pctype mapping update */
15399 /* Common result structure for port config pctype mapping update */
15400 struct cmd_pctype_mapping_update_result {
15401 cmdline_fixed_string_t port;
15402 cmdline_fixed_string_t config;
15404 cmdline_fixed_string_t pctype;
15405 cmdline_fixed_string_t mapping;
15406 cmdline_fixed_string_t update;
15407 cmdline_fixed_string_t pctype_list;
15408 uint16_t flow_type;
15411 /* Common CLI fields for pctype mapping update*/
15412 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15413 TOKEN_STRING_INITIALIZER
15414 (struct cmd_pctype_mapping_update_result,
15416 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15417 TOKEN_STRING_INITIALIZER
15418 (struct cmd_pctype_mapping_update_result,
15420 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15421 TOKEN_NUM_INITIALIZER
15422 (struct cmd_pctype_mapping_update_result,
15423 port_id, RTE_UINT16);
15424 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15425 TOKEN_STRING_INITIALIZER
15426 (struct cmd_pctype_mapping_update_result,
15428 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15429 TOKEN_STRING_INITIALIZER
15430 (struct cmd_pctype_mapping_update_result,
15431 mapping, "mapping");
15432 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15433 TOKEN_STRING_INITIALIZER
15434 (struct cmd_pctype_mapping_update_result,
15436 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15437 TOKEN_STRING_INITIALIZER
15438 (struct cmd_pctype_mapping_update_result,
15439 pctype_list, NULL);
15440 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15441 TOKEN_NUM_INITIALIZER
15442 (struct cmd_pctype_mapping_update_result,
15443 flow_type, RTE_UINT16);
15446 cmd_pctype_mapping_update_parsed(
15447 void *parsed_result,
15448 __rte_unused struct cmdline *cl,
15449 __rte_unused void *data)
15451 struct cmd_pctype_mapping_update_result *res = parsed_result;
15452 int ret = -ENOTSUP;
15453 #ifdef RTE_NET_I40E
15454 struct rte_pmd_i40e_flow_type_mapping mapping;
15456 unsigned int nb_item;
15457 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15460 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15463 #ifdef RTE_NET_I40E
15464 nb_item = parse_item_list(res->pctype_list, "pctypes",
15465 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15466 mapping.flow_type = res->flow_type;
15467 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15468 mapping.pctype |= (1ULL << pctype_list[i]);
15469 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15479 fprintf(stderr, "invalid pctype or flow type\n");
15482 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15485 fprintf(stderr, "function not implemented\n");
15488 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15492 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15493 .f = cmd_pctype_mapping_update_parsed,
15495 .help_str = "port config <port_id> pctype mapping update"
15496 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15498 (void *)&cmd_pctype_mapping_update_port,
15499 (void *)&cmd_pctype_mapping_update_config,
15500 (void *)&cmd_pctype_mapping_update_port_id,
15501 (void *)&cmd_pctype_mapping_update_pctype,
15502 (void *)&cmd_pctype_mapping_update_mapping,
15503 (void *)&cmd_pctype_mapping_update_update,
15504 (void *)&cmd_pctype_mapping_update_pc_type,
15505 (void *)&cmd_pctype_mapping_update_flow_type,
15510 /* ptype mapping get */
15512 /* Common result structure for ptype mapping get */
15513 struct cmd_ptype_mapping_get_result {
15514 cmdline_fixed_string_t ptype;
15515 cmdline_fixed_string_t mapping;
15516 cmdline_fixed_string_t get;
15518 uint8_t valid_only;
15521 /* Common CLI fields for ptype mapping get */
15522 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15523 TOKEN_STRING_INITIALIZER
15524 (struct cmd_ptype_mapping_get_result,
15526 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15527 TOKEN_STRING_INITIALIZER
15528 (struct cmd_ptype_mapping_get_result,
15529 mapping, "mapping");
15530 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15531 TOKEN_STRING_INITIALIZER
15532 (struct cmd_ptype_mapping_get_result,
15534 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15535 TOKEN_NUM_INITIALIZER
15536 (struct cmd_ptype_mapping_get_result,
15537 port_id, RTE_UINT16);
15538 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15539 TOKEN_NUM_INITIALIZER
15540 (struct cmd_ptype_mapping_get_result,
15541 valid_only, RTE_UINT8);
15544 cmd_ptype_mapping_get_parsed(
15545 void *parsed_result,
15546 __rte_unused struct cmdline *cl,
15547 __rte_unused void *data)
15549 struct cmd_ptype_mapping_get_result *res = parsed_result;
15550 int ret = -ENOTSUP;
15551 #ifdef RTE_NET_I40E
15552 int max_ptype_num = 256;
15553 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15558 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15561 #ifdef RTE_NET_I40E
15562 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15573 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15576 fprintf(stderr, "function not implemented\n");
15579 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15582 #ifdef RTE_NET_I40E
15584 for (i = 0; i < count; i++)
15585 printf("%3d\t0x%08x\n",
15586 mapping[i].hw_ptype, mapping[i].sw_ptype);
15591 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15592 .f = cmd_ptype_mapping_get_parsed,
15594 .help_str = "ptype mapping get <port_id> <valid_only>",
15596 (void *)&cmd_ptype_mapping_get_ptype,
15597 (void *)&cmd_ptype_mapping_get_mapping,
15598 (void *)&cmd_ptype_mapping_get_get,
15599 (void *)&cmd_ptype_mapping_get_port_id,
15600 (void *)&cmd_ptype_mapping_get_valid_only,
15605 /* ptype mapping replace */
15607 /* Common result structure for ptype mapping replace */
15608 struct cmd_ptype_mapping_replace_result {
15609 cmdline_fixed_string_t ptype;
15610 cmdline_fixed_string_t mapping;
15611 cmdline_fixed_string_t replace;
15618 /* Common CLI fields for ptype mapping replace */
15619 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15620 TOKEN_STRING_INITIALIZER
15621 (struct cmd_ptype_mapping_replace_result,
15623 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15624 TOKEN_STRING_INITIALIZER
15625 (struct cmd_ptype_mapping_replace_result,
15626 mapping, "mapping");
15627 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15628 TOKEN_STRING_INITIALIZER
15629 (struct cmd_ptype_mapping_replace_result,
15630 replace, "replace");
15631 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15632 TOKEN_NUM_INITIALIZER
15633 (struct cmd_ptype_mapping_replace_result,
15634 port_id, RTE_UINT16);
15635 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15636 TOKEN_NUM_INITIALIZER
15637 (struct cmd_ptype_mapping_replace_result,
15638 target, RTE_UINT32);
15639 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15640 TOKEN_NUM_INITIALIZER
15641 (struct cmd_ptype_mapping_replace_result,
15643 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15644 TOKEN_NUM_INITIALIZER
15645 (struct cmd_ptype_mapping_replace_result,
15646 pkt_type, RTE_UINT32);
15649 cmd_ptype_mapping_replace_parsed(
15650 void *parsed_result,
15651 __rte_unused struct cmdline *cl,
15652 __rte_unused void *data)
15654 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15655 int ret = -ENOTSUP;
15657 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15660 #ifdef RTE_NET_I40E
15661 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15671 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15672 res->target, res->pkt_type);
15675 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15678 fprintf(stderr, "function not implemented\n");
15681 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15685 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15686 .f = cmd_ptype_mapping_replace_parsed,
15689 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15691 (void *)&cmd_ptype_mapping_replace_ptype,
15692 (void *)&cmd_ptype_mapping_replace_mapping,
15693 (void *)&cmd_ptype_mapping_replace_replace,
15694 (void *)&cmd_ptype_mapping_replace_port_id,
15695 (void *)&cmd_ptype_mapping_replace_target,
15696 (void *)&cmd_ptype_mapping_replace_mask,
15697 (void *)&cmd_ptype_mapping_replace_pkt_type,
15702 /* ptype mapping reset */
15704 /* Common result structure for ptype mapping reset */
15705 struct cmd_ptype_mapping_reset_result {
15706 cmdline_fixed_string_t ptype;
15707 cmdline_fixed_string_t mapping;
15708 cmdline_fixed_string_t reset;
15712 /* Common CLI fields for ptype mapping reset*/
15713 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15714 TOKEN_STRING_INITIALIZER
15715 (struct cmd_ptype_mapping_reset_result,
15717 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15718 TOKEN_STRING_INITIALIZER
15719 (struct cmd_ptype_mapping_reset_result,
15720 mapping, "mapping");
15721 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15722 TOKEN_STRING_INITIALIZER
15723 (struct cmd_ptype_mapping_reset_result,
15725 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15726 TOKEN_NUM_INITIALIZER
15727 (struct cmd_ptype_mapping_reset_result,
15728 port_id, RTE_UINT16);
15731 cmd_ptype_mapping_reset_parsed(
15732 void *parsed_result,
15733 __rte_unused struct cmdline *cl,
15734 __rte_unused void *data)
15736 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15737 int ret = -ENOTSUP;
15739 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15742 #ifdef RTE_NET_I40E
15743 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15750 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15753 fprintf(stderr, "function not implemented\n");
15756 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15760 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15761 .f = cmd_ptype_mapping_reset_parsed,
15763 .help_str = "ptype mapping reset <port_id>",
15765 (void *)&cmd_ptype_mapping_reset_ptype,
15766 (void *)&cmd_ptype_mapping_reset_mapping,
15767 (void *)&cmd_ptype_mapping_reset_reset,
15768 (void *)&cmd_ptype_mapping_reset_port_id,
15773 /* ptype mapping update */
15775 /* Common result structure for ptype mapping update */
15776 struct cmd_ptype_mapping_update_result {
15777 cmdline_fixed_string_t ptype;
15778 cmdline_fixed_string_t mapping;
15779 cmdline_fixed_string_t reset;
15785 /* Common CLI fields for ptype mapping update*/
15786 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15787 TOKEN_STRING_INITIALIZER
15788 (struct cmd_ptype_mapping_update_result,
15790 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15791 TOKEN_STRING_INITIALIZER
15792 (struct cmd_ptype_mapping_update_result,
15793 mapping, "mapping");
15794 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15795 TOKEN_STRING_INITIALIZER
15796 (struct cmd_ptype_mapping_update_result,
15798 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15799 TOKEN_NUM_INITIALIZER
15800 (struct cmd_ptype_mapping_update_result,
15801 port_id, RTE_UINT16);
15802 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15803 TOKEN_NUM_INITIALIZER
15804 (struct cmd_ptype_mapping_update_result,
15805 hw_ptype, RTE_UINT8);
15806 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15807 TOKEN_NUM_INITIALIZER
15808 (struct cmd_ptype_mapping_update_result,
15809 sw_ptype, RTE_UINT32);
15812 cmd_ptype_mapping_update_parsed(
15813 void *parsed_result,
15814 __rte_unused struct cmdline *cl,
15815 __rte_unused void *data)
15817 struct cmd_ptype_mapping_update_result *res = parsed_result;
15818 int ret = -ENOTSUP;
15819 #ifdef RTE_NET_I40E
15820 struct rte_pmd_i40e_ptype_mapping mapping;
15822 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15825 #ifdef RTE_NET_I40E
15826 mapping.hw_ptype = res->hw_ptype;
15827 mapping.sw_ptype = res->sw_ptype;
15828 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15838 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15841 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15844 fprintf(stderr, "function not implemented\n");
15847 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15851 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15852 .f = cmd_ptype_mapping_update_parsed,
15854 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15856 (void *)&cmd_ptype_mapping_update_ptype,
15857 (void *)&cmd_ptype_mapping_update_mapping,
15858 (void *)&cmd_ptype_mapping_update_update,
15859 (void *)&cmd_ptype_mapping_update_port_id,
15860 (void *)&cmd_ptype_mapping_update_hw_ptype,
15861 (void *)&cmd_ptype_mapping_update_sw_ptype,
15866 /* Common result structure for file commands */
15867 struct cmd_cmdfile_result {
15868 cmdline_fixed_string_t load;
15869 cmdline_fixed_string_t filename;
15872 /* Common CLI fields for file commands */
15873 cmdline_parse_token_string_t cmd_load_cmdfile =
15874 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15875 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15876 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15879 cmd_load_from_file_parsed(
15880 void *parsed_result,
15881 __rte_unused struct cmdline *cl,
15882 __rte_unused void *data)
15884 struct cmd_cmdfile_result *res = parsed_result;
15886 cmdline_read_from_file(res->filename);
15889 cmdline_parse_inst_t cmd_load_from_file = {
15890 .f = cmd_load_from_file_parsed,
15892 .help_str = "load <filename>",
15894 (void *)&cmd_load_cmdfile,
15895 (void *)&cmd_load_cmdfile_filename,
15900 /* Get Rx offloads capabilities */
15901 struct cmd_rx_offload_get_capa_result {
15902 cmdline_fixed_string_t show;
15903 cmdline_fixed_string_t port;
15905 cmdline_fixed_string_t rx_offload;
15906 cmdline_fixed_string_t capabilities;
15909 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15910 TOKEN_STRING_INITIALIZER
15911 (struct cmd_rx_offload_get_capa_result,
15913 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15914 TOKEN_STRING_INITIALIZER
15915 (struct cmd_rx_offload_get_capa_result,
15917 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15918 TOKEN_NUM_INITIALIZER
15919 (struct cmd_rx_offload_get_capa_result,
15920 port_id, RTE_UINT16);
15921 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15922 TOKEN_STRING_INITIALIZER
15923 (struct cmd_rx_offload_get_capa_result,
15924 rx_offload, "rx_offload");
15925 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15926 TOKEN_STRING_INITIALIZER
15927 (struct cmd_rx_offload_get_capa_result,
15928 capabilities, "capabilities");
15931 print_rx_offloads(uint64_t offloads)
15933 uint64_t single_offload;
15941 begin = __builtin_ctzll(offloads);
15942 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15944 single_offload = 1ULL << begin;
15945 for (bit = begin; bit < end; bit++) {
15946 if (offloads & single_offload)
15948 rte_eth_dev_rx_offload_name(single_offload));
15949 single_offload <<= 1;
15954 cmd_rx_offload_get_capa_parsed(
15955 void *parsed_result,
15956 __rte_unused struct cmdline *cl,
15957 __rte_unused void *data)
15959 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15960 struct rte_eth_dev_info dev_info;
15961 portid_t port_id = res->port_id;
15962 uint64_t queue_offloads;
15963 uint64_t port_offloads;
15966 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15970 queue_offloads = dev_info.rx_queue_offload_capa;
15971 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15973 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15974 printf(" Per Queue :");
15975 print_rx_offloads(queue_offloads);
15978 printf(" Per Port :");
15979 print_rx_offloads(port_offloads);
15983 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15984 .f = cmd_rx_offload_get_capa_parsed,
15986 .help_str = "show port <port_id> rx_offload capabilities",
15988 (void *)&cmd_rx_offload_get_capa_show,
15989 (void *)&cmd_rx_offload_get_capa_port,
15990 (void *)&cmd_rx_offload_get_capa_port_id,
15991 (void *)&cmd_rx_offload_get_capa_rx_offload,
15992 (void *)&cmd_rx_offload_get_capa_capabilities,
15997 /* Get Rx offloads configuration */
15998 struct cmd_rx_offload_get_configuration_result {
15999 cmdline_fixed_string_t show;
16000 cmdline_fixed_string_t port;
16002 cmdline_fixed_string_t rx_offload;
16003 cmdline_fixed_string_t configuration;
16006 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16007 TOKEN_STRING_INITIALIZER
16008 (struct cmd_rx_offload_get_configuration_result,
16010 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16011 TOKEN_STRING_INITIALIZER
16012 (struct cmd_rx_offload_get_configuration_result,
16014 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16015 TOKEN_NUM_INITIALIZER
16016 (struct cmd_rx_offload_get_configuration_result,
16017 port_id, RTE_UINT16);
16018 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16019 TOKEN_STRING_INITIALIZER
16020 (struct cmd_rx_offload_get_configuration_result,
16021 rx_offload, "rx_offload");
16022 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16023 TOKEN_STRING_INITIALIZER
16024 (struct cmd_rx_offload_get_configuration_result,
16025 configuration, "configuration");
16028 cmd_rx_offload_get_configuration_parsed(
16029 void *parsed_result,
16030 __rte_unused struct cmdline *cl,
16031 __rte_unused void *data)
16033 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16034 struct rte_eth_dev_info dev_info;
16035 portid_t port_id = res->port_id;
16036 struct rte_port *port = &ports[port_id];
16037 uint64_t port_offloads;
16038 uint64_t queue_offloads;
16039 uint16_t nb_rx_queues;
16043 printf("Rx Offloading Configuration of port %d :\n", port_id);
16045 port_offloads = port->dev_conf.rxmode.offloads;
16047 print_rx_offloads(port_offloads);
16050 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16054 nb_rx_queues = dev_info.nb_rx_queues;
16055 for (q = 0; q < nb_rx_queues; q++) {
16056 queue_offloads = port->rx_conf[q].offloads;
16057 printf(" Queue[%2d] :", q);
16058 print_rx_offloads(queue_offloads);
16064 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16065 .f = cmd_rx_offload_get_configuration_parsed,
16067 .help_str = "show port <port_id> rx_offload configuration",
16069 (void *)&cmd_rx_offload_get_configuration_show,
16070 (void *)&cmd_rx_offload_get_configuration_port,
16071 (void *)&cmd_rx_offload_get_configuration_port_id,
16072 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16073 (void *)&cmd_rx_offload_get_configuration_configuration,
16078 /* Enable/Disable a per port offloading */
16079 struct cmd_config_per_port_rx_offload_result {
16080 cmdline_fixed_string_t port;
16081 cmdline_fixed_string_t config;
16083 cmdline_fixed_string_t rx_offload;
16084 cmdline_fixed_string_t offload;
16085 cmdline_fixed_string_t on_off;
16088 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16089 TOKEN_STRING_INITIALIZER
16090 (struct cmd_config_per_port_rx_offload_result,
16092 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16093 TOKEN_STRING_INITIALIZER
16094 (struct cmd_config_per_port_rx_offload_result,
16096 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16097 TOKEN_NUM_INITIALIZER
16098 (struct cmd_config_per_port_rx_offload_result,
16099 port_id, RTE_UINT16);
16100 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16101 TOKEN_STRING_INITIALIZER
16102 (struct cmd_config_per_port_rx_offload_result,
16103 rx_offload, "rx_offload");
16104 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16105 TOKEN_STRING_INITIALIZER
16106 (struct cmd_config_per_port_rx_offload_result,
16107 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16108 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16109 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16110 "scatter#buffer_split#timestamp#security#"
16111 "keep_crc#rss_hash");
16112 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16113 TOKEN_STRING_INITIALIZER
16114 (struct cmd_config_per_port_rx_offload_result,
16118 search_rx_offload(const char *name)
16120 uint64_t single_offload;
16121 const char *single_name;
16125 single_offload = 1;
16126 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16127 single_name = rte_eth_dev_rx_offload_name(single_offload);
16128 if (!strcasecmp(single_name, name)) {
16132 single_offload <<= 1;
16136 return single_offload;
16142 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16143 __rte_unused struct cmdline *cl,
16144 __rte_unused void *data)
16146 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16147 portid_t port_id = res->port_id;
16148 struct rte_eth_dev_info dev_info;
16149 struct rte_port *port = &ports[port_id];
16150 uint64_t single_offload;
16151 uint16_t nb_rx_queues;
16155 if (port->port_status != RTE_PORT_STOPPED) {
16157 "Error: Can't config offload when Port %d is not stopped\n",
16162 single_offload = search_rx_offload(res->offload);
16163 if (single_offload == 0) {
16164 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16168 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16172 nb_rx_queues = dev_info.nb_rx_queues;
16173 if (!strcmp(res->on_off, "on")) {
16174 port->dev_conf.rxmode.offloads |= single_offload;
16175 for (q = 0; q < nb_rx_queues; q++)
16176 port->rx_conf[q].offloads |= single_offload;
16178 port->dev_conf.rxmode.offloads &= ~single_offload;
16179 for (q = 0; q < nb_rx_queues; q++)
16180 port->rx_conf[q].offloads &= ~single_offload;
16183 cmd_reconfig_device_queue(port_id, 1, 1);
16186 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16187 .f = cmd_config_per_port_rx_offload_parsed,
16189 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16190 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16191 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16192 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16193 "keep_crc|rss_hash on|off",
16195 (void *)&cmd_config_per_port_rx_offload_result_port,
16196 (void *)&cmd_config_per_port_rx_offload_result_config,
16197 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16198 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16199 (void *)&cmd_config_per_port_rx_offload_result_offload,
16200 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16205 /* Enable/Disable a per queue offloading */
16206 struct cmd_config_per_queue_rx_offload_result {
16207 cmdline_fixed_string_t port;
16209 cmdline_fixed_string_t rxq;
16211 cmdline_fixed_string_t rx_offload;
16212 cmdline_fixed_string_t offload;
16213 cmdline_fixed_string_t on_off;
16216 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16217 TOKEN_STRING_INITIALIZER
16218 (struct cmd_config_per_queue_rx_offload_result,
16220 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16221 TOKEN_NUM_INITIALIZER
16222 (struct cmd_config_per_queue_rx_offload_result,
16223 port_id, RTE_UINT16);
16224 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16225 TOKEN_STRING_INITIALIZER
16226 (struct cmd_config_per_queue_rx_offload_result,
16228 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16229 TOKEN_NUM_INITIALIZER
16230 (struct cmd_config_per_queue_rx_offload_result,
16231 queue_id, RTE_UINT16);
16232 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16233 TOKEN_STRING_INITIALIZER
16234 (struct cmd_config_per_queue_rx_offload_result,
16235 rx_offload, "rx_offload");
16236 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16237 TOKEN_STRING_INITIALIZER
16238 (struct cmd_config_per_queue_rx_offload_result,
16239 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16240 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16241 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16242 "scatter#buffer_split#timestamp#security#keep_crc");
16243 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16244 TOKEN_STRING_INITIALIZER
16245 (struct cmd_config_per_queue_rx_offload_result,
16249 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16250 __rte_unused struct cmdline *cl,
16251 __rte_unused void *data)
16253 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16254 struct rte_eth_dev_info dev_info;
16255 portid_t port_id = res->port_id;
16256 uint16_t queue_id = res->queue_id;
16257 struct rte_port *port = &ports[port_id];
16258 uint64_t single_offload;
16261 if (port->port_status != RTE_PORT_STOPPED) {
16263 "Error: Can't config offload when Port %d is not stopped\n",
16268 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16272 if (queue_id >= dev_info.nb_rx_queues) {
16274 "Error: input queue_id should be 0 ... %d\n",
16275 dev_info.nb_rx_queues - 1);
16279 single_offload = search_rx_offload(res->offload);
16280 if (single_offload == 0) {
16281 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16285 if (!strcmp(res->on_off, "on"))
16286 port->rx_conf[queue_id].offloads |= single_offload;
16288 port->rx_conf[queue_id].offloads &= ~single_offload;
16290 cmd_reconfig_device_queue(port_id, 1, 1);
16293 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16294 .f = cmd_config_per_queue_rx_offload_parsed,
16296 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16297 "vlan_strip|ipv4_cksum|"
16298 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16299 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16300 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16303 (void *)&cmd_config_per_queue_rx_offload_result_port,
16304 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16305 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16306 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16307 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16308 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16309 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16314 /* Get Tx offloads capabilities */
16315 struct cmd_tx_offload_get_capa_result {
16316 cmdline_fixed_string_t show;
16317 cmdline_fixed_string_t port;
16319 cmdline_fixed_string_t tx_offload;
16320 cmdline_fixed_string_t capabilities;
16323 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16324 TOKEN_STRING_INITIALIZER
16325 (struct cmd_tx_offload_get_capa_result,
16327 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16328 TOKEN_STRING_INITIALIZER
16329 (struct cmd_tx_offload_get_capa_result,
16331 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16332 TOKEN_NUM_INITIALIZER
16333 (struct cmd_tx_offload_get_capa_result,
16334 port_id, RTE_UINT16);
16335 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16336 TOKEN_STRING_INITIALIZER
16337 (struct cmd_tx_offload_get_capa_result,
16338 tx_offload, "tx_offload");
16339 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16340 TOKEN_STRING_INITIALIZER
16341 (struct cmd_tx_offload_get_capa_result,
16342 capabilities, "capabilities");
16345 print_tx_offloads(uint64_t offloads)
16347 uint64_t single_offload;
16355 begin = __builtin_ctzll(offloads);
16356 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16358 single_offload = 1ULL << begin;
16359 for (bit = begin; bit < end; bit++) {
16360 if (offloads & single_offload)
16362 rte_eth_dev_tx_offload_name(single_offload));
16363 single_offload <<= 1;
16368 cmd_tx_offload_get_capa_parsed(
16369 void *parsed_result,
16370 __rte_unused struct cmdline *cl,
16371 __rte_unused void *data)
16373 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16374 struct rte_eth_dev_info dev_info;
16375 portid_t port_id = res->port_id;
16376 uint64_t queue_offloads;
16377 uint64_t port_offloads;
16380 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16384 queue_offloads = dev_info.tx_queue_offload_capa;
16385 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16387 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16388 printf(" Per Queue :");
16389 print_tx_offloads(queue_offloads);
16392 printf(" Per Port :");
16393 print_tx_offloads(port_offloads);
16397 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16398 .f = cmd_tx_offload_get_capa_parsed,
16400 .help_str = "show port <port_id> tx_offload capabilities",
16402 (void *)&cmd_tx_offload_get_capa_show,
16403 (void *)&cmd_tx_offload_get_capa_port,
16404 (void *)&cmd_tx_offload_get_capa_port_id,
16405 (void *)&cmd_tx_offload_get_capa_tx_offload,
16406 (void *)&cmd_tx_offload_get_capa_capabilities,
16411 /* Get Tx offloads configuration */
16412 struct cmd_tx_offload_get_configuration_result {
16413 cmdline_fixed_string_t show;
16414 cmdline_fixed_string_t port;
16416 cmdline_fixed_string_t tx_offload;
16417 cmdline_fixed_string_t configuration;
16420 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16421 TOKEN_STRING_INITIALIZER
16422 (struct cmd_tx_offload_get_configuration_result,
16424 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16425 TOKEN_STRING_INITIALIZER
16426 (struct cmd_tx_offload_get_configuration_result,
16428 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16429 TOKEN_NUM_INITIALIZER
16430 (struct cmd_tx_offload_get_configuration_result,
16431 port_id, RTE_UINT16);
16432 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16433 TOKEN_STRING_INITIALIZER
16434 (struct cmd_tx_offload_get_configuration_result,
16435 tx_offload, "tx_offload");
16436 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16437 TOKEN_STRING_INITIALIZER
16438 (struct cmd_tx_offload_get_configuration_result,
16439 configuration, "configuration");
16442 cmd_tx_offload_get_configuration_parsed(
16443 void *parsed_result,
16444 __rte_unused struct cmdline *cl,
16445 __rte_unused void *data)
16447 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16448 struct rte_eth_dev_info dev_info;
16449 portid_t port_id = res->port_id;
16450 struct rte_port *port = &ports[port_id];
16451 uint64_t port_offloads;
16452 uint64_t queue_offloads;
16453 uint16_t nb_tx_queues;
16457 printf("Tx Offloading Configuration of port %d :\n", port_id);
16459 port_offloads = port->dev_conf.txmode.offloads;
16461 print_tx_offloads(port_offloads);
16464 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16468 nb_tx_queues = dev_info.nb_tx_queues;
16469 for (q = 0; q < nb_tx_queues; q++) {
16470 queue_offloads = port->tx_conf[q].offloads;
16471 printf(" Queue[%2d] :", q);
16472 print_tx_offloads(queue_offloads);
16478 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16479 .f = cmd_tx_offload_get_configuration_parsed,
16481 .help_str = "show port <port_id> tx_offload configuration",
16483 (void *)&cmd_tx_offload_get_configuration_show,
16484 (void *)&cmd_tx_offload_get_configuration_port,
16485 (void *)&cmd_tx_offload_get_configuration_port_id,
16486 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16487 (void *)&cmd_tx_offload_get_configuration_configuration,
16492 /* Enable/Disable a per port offloading */
16493 struct cmd_config_per_port_tx_offload_result {
16494 cmdline_fixed_string_t port;
16495 cmdline_fixed_string_t config;
16497 cmdline_fixed_string_t tx_offload;
16498 cmdline_fixed_string_t offload;
16499 cmdline_fixed_string_t on_off;
16502 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16503 TOKEN_STRING_INITIALIZER
16504 (struct cmd_config_per_port_tx_offload_result,
16506 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16507 TOKEN_STRING_INITIALIZER
16508 (struct cmd_config_per_port_tx_offload_result,
16510 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16511 TOKEN_NUM_INITIALIZER
16512 (struct cmd_config_per_port_tx_offload_result,
16513 port_id, RTE_UINT16);
16514 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16515 TOKEN_STRING_INITIALIZER
16516 (struct cmd_config_per_port_tx_offload_result,
16517 tx_offload, "tx_offload");
16518 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16519 TOKEN_STRING_INITIALIZER
16520 (struct cmd_config_per_port_tx_offload_result,
16521 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16522 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16523 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16524 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16525 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16526 "send_on_timestamp");
16527 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16528 TOKEN_STRING_INITIALIZER
16529 (struct cmd_config_per_port_tx_offload_result,
16533 search_tx_offload(const char *name)
16535 uint64_t single_offload;
16536 const char *single_name;
16540 single_offload = 1;
16541 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16542 single_name = rte_eth_dev_tx_offload_name(single_offload);
16543 if (single_name == NULL)
16545 if (!strcasecmp(single_name, name)) {
16548 } else if (!strcasecmp(single_name, "UNKNOWN"))
16550 single_offload <<= 1;
16554 return single_offload;
16560 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16561 __rte_unused struct cmdline *cl,
16562 __rte_unused void *data)
16564 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16565 portid_t port_id = res->port_id;
16566 struct rte_eth_dev_info dev_info;
16567 struct rte_port *port = &ports[port_id];
16568 uint64_t single_offload;
16569 uint16_t nb_tx_queues;
16573 if (port->port_status != RTE_PORT_STOPPED) {
16575 "Error: Can't config offload when Port %d is not stopped\n",
16580 single_offload = search_tx_offload(res->offload);
16581 if (single_offload == 0) {
16582 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16586 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16590 nb_tx_queues = dev_info.nb_tx_queues;
16591 if (!strcmp(res->on_off, "on")) {
16592 port->dev_conf.txmode.offloads |= single_offload;
16593 for (q = 0; q < nb_tx_queues; q++)
16594 port->tx_conf[q].offloads |= single_offload;
16596 port->dev_conf.txmode.offloads &= ~single_offload;
16597 for (q = 0; q < nb_tx_queues; q++)
16598 port->tx_conf[q].offloads &= ~single_offload;
16601 cmd_reconfig_device_queue(port_id, 1, 1);
16604 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16605 .f = cmd_config_per_port_tx_offload_parsed,
16607 .help_str = "port config <port_id> tx_offload "
16608 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16609 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16610 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16611 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16612 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16613 "send_on_timestamp on|off",
16615 (void *)&cmd_config_per_port_tx_offload_result_port,
16616 (void *)&cmd_config_per_port_tx_offload_result_config,
16617 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16618 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16619 (void *)&cmd_config_per_port_tx_offload_result_offload,
16620 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16625 /* Enable/Disable a per queue offloading */
16626 struct cmd_config_per_queue_tx_offload_result {
16627 cmdline_fixed_string_t port;
16629 cmdline_fixed_string_t txq;
16631 cmdline_fixed_string_t tx_offload;
16632 cmdline_fixed_string_t offload;
16633 cmdline_fixed_string_t on_off;
16636 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16637 TOKEN_STRING_INITIALIZER
16638 (struct cmd_config_per_queue_tx_offload_result,
16640 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16641 TOKEN_NUM_INITIALIZER
16642 (struct cmd_config_per_queue_tx_offload_result,
16643 port_id, RTE_UINT16);
16644 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16645 TOKEN_STRING_INITIALIZER
16646 (struct cmd_config_per_queue_tx_offload_result,
16648 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16649 TOKEN_NUM_INITIALIZER
16650 (struct cmd_config_per_queue_tx_offload_result,
16651 queue_id, RTE_UINT16);
16652 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16653 TOKEN_STRING_INITIALIZER
16654 (struct cmd_config_per_queue_tx_offload_result,
16655 tx_offload, "tx_offload");
16656 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16657 TOKEN_STRING_INITIALIZER
16658 (struct cmd_config_per_queue_tx_offload_result,
16659 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16660 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16661 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16662 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16663 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16664 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16665 TOKEN_STRING_INITIALIZER
16666 (struct cmd_config_per_queue_tx_offload_result,
16670 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16671 __rte_unused struct cmdline *cl,
16672 __rte_unused void *data)
16674 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16675 struct rte_eth_dev_info dev_info;
16676 portid_t port_id = res->port_id;
16677 uint16_t queue_id = res->queue_id;
16678 struct rte_port *port = &ports[port_id];
16679 uint64_t single_offload;
16682 if (port->port_status != RTE_PORT_STOPPED) {
16684 "Error: Can't config offload when Port %d is not stopped\n",
16689 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16693 if (queue_id >= dev_info.nb_tx_queues) {
16695 "Error: input queue_id should be 0 ... %d\n",
16696 dev_info.nb_tx_queues - 1);
16700 single_offload = search_tx_offload(res->offload);
16701 if (single_offload == 0) {
16702 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16706 if (!strcmp(res->on_off, "on"))
16707 port->tx_conf[queue_id].offloads |= single_offload;
16709 port->tx_conf[queue_id].offloads &= ~single_offload;
16711 cmd_reconfig_device_queue(port_id, 1, 1);
16714 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16715 .f = cmd_config_per_queue_tx_offload_parsed,
16717 .help_str = "port <port_id> txq <queue_id> tx_offload "
16718 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16719 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16720 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16721 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16722 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16725 (void *)&cmd_config_per_queue_tx_offload_result_port,
16726 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16727 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16728 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16729 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16730 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16731 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16736 /* *** configure tx_metadata for specific port *** */
16737 struct cmd_config_tx_metadata_specific_result {
16738 cmdline_fixed_string_t port;
16739 cmdline_fixed_string_t keyword;
16741 cmdline_fixed_string_t item;
16746 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16747 __rte_unused struct cmdline *cl,
16748 __rte_unused void *data)
16750 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16752 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16754 ports[res->port_id].tx_metadata = res->value;
16755 /* Add/remove callback to insert valid metadata in every Tx packet. */
16756 if (ports[res->port_id].tx_metadata)
16757 add_tx_md_callback(res->port_id);
16759 remove_tx_md_callback(res->port_id);
16760 rte_flow_dynf_metadata_register();
16763 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16764 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16766 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16767 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16768 keyword, "config");
16769 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16770 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16771 port_id, RTE_UINT16);
16772 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16773 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16774 item, "tx_metadata");
16775 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16776 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16777 value, RTE_UINT32);
16779 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16780 .f = cmd_config_tx_metadata_specific_parsed,
16782 .help_str = "port config <port_id> tx_metadata <value>",
16784 (void *)&cmd_config_tx_metadata_specific_port,
16785 (void *)&cmd_config_tx_metadata_specific_keyword,
16786 (void *)&cmd_config_tx_metadata_specific_id,
16787 (void *)&cmd_config_tx_metadata_specific_item,
16788 (void *)&cmd_config_tx_metadata_specific_value,
16793 /* *** set dynf *** */
16794 struct cmd_config_tx_dynf_specific_result {
16795 cmdline_fixed_string_t port;
16796 cmdline_fixed_string_t keyword;
16798 cmdline_fixed_string_t item;
16799 cmdline_fixed_string_t name;
16800 cmdline_fixed_string_t value;
16804 cmd_config_dynf_specific_parsed(void *parsed_result,
16805 __rte_unused struct cmdline *cl,
16806 __rte_unused void *data)
16808 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16809 struct rte_mbuf_dynflag desc_flag;
16811 uint64_t old_port_flags;
16813 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16815 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16817 if (strlcpy(desc_flag.name, res->name,
16818 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16819 fprintf(stderr, "Flag name too long\n");
16822 desc_flag.flags = 0;
16823 flag = rte_mbuf_dynflag_register(&desc_flag);
16825 fprintf(stderr, "Can't register flag\n");
16828 strcpy(dynf_names[flag], desc_flag.name);
16830 old_port_flags = ports[res->port_id].mbuf_dynf;
16831 if (!strcmp(res->value, "set")) {
16832 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16833 if (old_port_flags == 0)
16834 add_tx_dynf_callback(res->port_id);
16836 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16837 if (ports[res->port_id].mbuf_dynf == 0)
16838 remove_tx_dynf_callback(res->port_id);
16842 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16843 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16845 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16846 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16847 keyword, "config");
16848 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16849 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16850 port_id, RTE_UINT16);
16851 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16852 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16854 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16855 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16857 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16858 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16859 value, "set#clear");
16861 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16862 .f = cmd_config_dynf_specific_parsed,
16864 .help_str = "port config <port id> dynf <name> set|clear",
16866 (void *)&cmd_config_tx_dynf_specific_port,
16867 (void *)&cmd_config_tx_dynf_specific_keyword,
16868 (void *)&cmd_config_tx_dynf_specific_port_id,
16869 (void *)&cmd_config_tx_dynf_specific_item,
16870 (void *)&cmd_config_tx_dynf_specific_name,
16871 (void *)&cmd_config_tx_dynf_specific_value,
16876 /* *** display tx_metadata per port configuration *** */
16877 struct cmd_show_tx_metadata_result {
16878 cmdline_fixed_string_t cmd_show;
16879 cmdline_fixed_string_t cmd_port;
16880 cmdline_fixed_string_t cmd_keyword;
16885 cmd_show_tx_metadata_parsed(void *parsed_result,
16886 __rte_unused struct cmdline *cl,
16887 __rte_unused void *data)
16889 struct cmd_show_tx_metadata_result *res = parsed_result;
16891 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16892 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16895 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16896 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16897 ports[res->cmd_pid].tx_metadata);
16901 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16902 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16904 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16905 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16907 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16908 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16909 cmd_pid, RTE_UINT16);
16910 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16911 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16912 cmd_keyword, "tx_metadata");
16914 cmdline_parse_inst_t cmd_show_tx_metadata = {
16915 .f = cmd_show_tx_metadata_parsed,
16917 .help_str = "show port <port_id> tx_metadata",
16919 (void *)&cmd_show_tx_metadata_show,
16920 (void *)&cmd_show_tx_metadata_port,
16921 (void *)&cmd_show_tx_metadata_pid,
16922 (void *)&cmd_show_tx_metadata_keyword,
16927 /* *** show fec capability per port configuration *** */
16928 struct cmd_show_fec_capability_result {
16929 cmdline_fixed_string_t cmd_show;
16930 cmdline_fixed_string_t cmd_port;
16931 cmdline_fixed_string_t cmd_fec;
16932 cmdline_fixed_string_t cmd_keyword;
16937 cmd_show_fec_capability_parsed(void *parsed_result,
16938 __rte_unused struct cmdline *cl,
16939 __rte_unused void *data)
16941 struct cmd_show_fec_capability_result *res = parsed_result;
16942 struct rte_eth_fec_capa *speed_fec_capa;
16946 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16947 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16951 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16952 if (ret == -ENOTSUP) {
16953 fprintf(stderr, "Function not implemented\n");
16955 } else if (ret < 0) {
16956 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16960 num = (unsigned int)ret;
16961 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16962 if (speed_fec_capa == NULL) {
16963 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16967 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16969 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
16973 show_fec_capability(num, speed_fec_capa);
16975 free(speed_fec_capa);
16978 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16979 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16981 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16982 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16984 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16985 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16986 cmd_pid, RTE_UINT16);
16987 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16988 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16990 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16991 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16992 cmd_keyword, "capabilities");
16994 cmdline_parse_inst_t cmd_show_capability = {
16995 .f = cmd_show_fec_capability_parsed,
16997 .help_str = "show port <port_id> fec capabilities",
16999 (void *)&cmd_show_fec_capability_show,
17000 (void *)&cmd_show_fec_capability_port,
17001 (void *)&cmd_show_fec_capability_pid,
17002 (void *)&cmd_show_fec_capability_fec,
17003 (void *)&cmd_show_fec_capability_keyword,
17008 /* *** show fec mode per port configuration *** */
17009 struct cmd_show_fec_metadata_result {
17010 cmdline_fixed_string_t cmd_show;
17011 cmdline_fixed_string_t cmd_port;
17012 cmdline_fixed_string_t cmd_keyword;
17017 cmd_show_fec_mode_parsed(void *parsed_result,
17018 __rte_unused struct cmdline *cl,
17019 __rte_unused void *data)
17021 #define FEC_NAME_SIZE 16
17022 struct cmd_show_fec_metadata_result *res = parsed_result;
17024 char buf[FEC_NAME_SIZE];
17027 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17028 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17031 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17032 if (ret == -ENOTSUP) {
17033 fprintf(stderr, "Function not implemented\n");
17035 } else if (ret < 0) {
17036 fprintf(stderr, "Get FEC mode failed\n");
17041 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17042 strlcpy(buf, "off", sizeof(buf));
17044 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17045 strlcpy(buf, "auto", sizeof(buf));
17047 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17048 strlcpy(buf, "baser", sizeof(buf));
17050 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17051 strlcpy(buf, "rs", sizeof(buf));
17057 printf("%s\n", buf);
17060 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17061 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17063 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17064 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17066 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17067 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17068 cmd_pid, RTE_UINT16);
17069 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17070 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17071 cmd_keyword, "fec_mode");
17073 cmdline_parse_inst_t cmd_show_fec_mode = {
17074 .f = cmd_show_fec_mode_parsed,
17076 .help_str = "show port <port_id> fec_mode",
17078 (void *)&cmd_show_fec_mode_show,
17079 (void *)&cmd_show_fec_mode_port,
17080 (void *)&cmd_show_fec_mode_pid,
17081 (void *)&cmd_show_fec_mode_keyword,
17086 /* *** set fec mode per port configuration *** */
17087 struct cmd_set_port_fec_mode {
17088 cmdline_fixed_string_t set;
17089 cmdline_fixed_string_t port;
17091 cmdline_fixed_string_t fec_mode;
17092 cmdline_fixed_string_t fec_value;
17095 /* Common CLI fields for set fec mode */
17096 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17097 TOKEN_STRING_INITIALIZER
17098 (struct cmd_set_port_fec_mode,
17100 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17101 TOKEN_STRING_INITIALIZER
17102 (struct cmd_set_port_fec_mode,
17104 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17105 TOKEN_NUM_INITIALIZER
17106 (struct cmd_set_port_fec_mode,
17107 port_id, RTE_UINT16);
17108 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17109 TOKEN_STRING_INITIALIZER
17110 (struct cmd_set_port_fec_mode,
17111 fec_mode, "fec_mode");
17112 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17113 TOKEN_STRING_INITIALIZER
17114 (struct cmd_set_port_fec_mode,
17118 cmd_set_port_fec_mode_parsed(
17119 void *parsed_result,
17120 __rte_unused struct cmdline *cl,
17121 __rte_unused void *data)
17123 struct cmd_set_port_fec_mode *res = parsed_result;
17124 uint16_t port_id = res->port_id;
17128 ret = parse_fec_mode(res->fec_value, &fec_capa);
17130 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17131 res->fec_value, port_id);
17135 ret = rte_eth_fec_set(port_id, fec_capa);
17136 if (ret == -ENOTSUP) {
17137 fprintf(stderr, "Function not implemented\n");
17139 } else if (ret < 0) {
17140 fprintf(stderr, "Set FEC mode failed\n");
17145 cmdline_parse_inst_t cmd_set_fec_mode = {
17146 .f = cmd_set_port_fec_mode_parsed,
17148 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17150 (void *)&cmd_set_port_fec_mode_set,
17151 (void *)&cmd_set_port_fec_mode_port,
17152 (void *)&cmd_set_port_fec_mode_port_id,
17153 (void *)&cmd_set_port_fec_mode_str,
17154 (void *)&cmd_set_port_fec_mode_value,
17159 /* show port supported ptypes */
17161 /* Common result structure for show port ptypes */
17162 struct cmd_show_port_supported_ptypes_result {
17163 cmdline_fixed_string_t show;
17164 cmdline_fixed_string_t port;
17166 cmdline_fixed_string_t ptypes;
17169 /* Common CLI fields for show port ptypes */
17170 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17171 TOKEN_STRING_INITIALIZER
17172 (struct cmd_show_port_supported_ptypes_result,
17174 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17175 TOKEN_STRING_INITIALIZER
17176 (struct cmd_show_port_supported_ptypes_result,
17178 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17179 TOKEN_NUM_INITIALIZER
17180 (struct cmd_show_port_supported_ptypes_result,
17181 port_id, RTE_UINT16);
17182 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17183 TOKEN_STRING_INITIALIZER
17184 (struct cmd_show_port_supported_ptypes_result,
17188 cmd_show_port_supported_ptypes_parsed(
17189 void *parsed_result,
17190 __rte_unused struct cmdline *cl,
17191 __rte_unused void *data)
17193 #define RSVD_PTYPE_MASK 0xf0000000
17194 #define MAX_PTYPES_PER_LAYER 16
17195 #define LTYPE_NAMESIZE 32
17196 #define PTYPE_NAMESIZE 256
17197 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17198 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17199 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17200 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17201 uint16_t port_id = res->port_id;
17204 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17208 while (ptype_mask != RSVD_PTYPE_MASK) {
17210 switch (ptype_mask) {
17211 case RTE_PTYPE_L2_MASK:
17212 strlcpy(ltype, "L2", sizeof(ltype));
17214 case RTE_PTYPE_L3_MASK:
17215 strlcpy(ltype, "L3", sizeof(ltype));
17217 case RTE_PTYPE_L4_MASK:
17218 strlcpy(ltype, "L4", sizeof(ltype));
17220 case RTE_PTYPE_TUNNEL_MASK:
17221 strlcpy(ltype, "Tunnel", sizeof(ltype));
17223 case RTE_PTYPE_INNER_L2_MASK:
17224 strlcpy(ltype, "Inner L2", sizeof(ltype));
17226 case RTE_PTYPE_INNER_L3_MASK:
17227 strlcpy(ltype, "Inner L3", sizeof(ltype));
17229 case RTE_PTYPE_INNER_L4_MASK:
17230 strlcpy(ltype, "Inner L4", sizeof(ltype));
17236 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17237 ptype_mask, ptypes,
17238 MAX_PTYPES_PER_LAYER);
17241 printf("Supported %s ptypes:\n", ltype);
17243 printf("%s ptypes unsupported\n", ltype);
17245 for (i = 0; i < ret; ++i) {
17246 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17247 printf("%s\n", buf);
17254 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17255 .f = cmd_show_port_supported_ptypes_parsed,
17257 .help_str = "show port <port_id> ptypes",
17259 (void *)&cmd_show_port_supported_ptypes_show,
17260 (void *)&cmd_show_port_supported_ptypes_port,
17261 (void *)&cmd_show_port_supported_ptypes_port_id,
17262 (void *)&cmd_show_port_supported_ptypes_ptypes,
17267 /* *** display rx/tx descriptor status *** */
17268 struct cmd_show_rx_tx_desc_status_result {
17269 cmdline_fixed_string_t cmd_show;
17270 cmdline_fixed_string_t cmd_port;
17271 cmdline_fixed_string_t cmd_keyword;
17272 cmdline_fixed_string_t cmd_desc;
17273 cmdline_fixed_string_t cmd_status;
17280 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17281 __rte_unused struct cmdline *cl,
17282 __rte_unused void *data)
17284 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17287 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17288 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17292 if (!strcmp(res->cmd_keyword, "rxq")) {
17293 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17297 "Invalid input: queue id = %d, desc id = %d\n",
17298 res->cmd_qid, res->cmd_did);
17301 if (rc == RTE_ETH_RX_DESC_AVAIL)
17302 printf("Desc status = AVAILABLE\n");
17303 else if (rc == RTE_ETH_RX_DESC_DONE)
17304 printf("Desc status = DONE\n");
17306 printf("Desc status = UNAVAILABLE\n");
17307 } else if (!strcmp(res->cmd_keyword, "txq")) {
17308 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17312 "Invalid input: queue id = %d, desc id = %d\n",
17313 res->cmd_qid, res->cmd_did);
17316 if (rc == RTE_ETH_TX_DESC_FULL)
17317 printf("Desc status = FULL\n");
17318 else if (rc == RTE_ETH_TX_DESC_DONE)
17319 printf("Desc status = DONE\n");
17321 printf("Desc status = UNAVAILABLE\n");
17325 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17326 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17328 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17329 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17331 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17332 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17333 cmd_pid, RTE_UINT16);
17334 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17335 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17336 cmd_keyword, "rxq#txq");
17337 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17338 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17339 cmd_qid, RTE_UINT16);
17340 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17341 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17343 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17344 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17345 cmd_did, RTE_UINT16);
17346 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17347 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17348 cmd_status, "status");
17349 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17350 .f = cmd_show_rx_tx_desc_status_parsed,
17352 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17355 (void *)&cmd_show_rx_tx_desc_status_show,
17356 (void *)&cmd_show_rx_tx_desc_status_port,
17357 (void *)&cmd_show_rx_tx_desc_status_pid,
17358 (void *)&cmd_show_rx_tx_desc_status_keyword,
17359 (void *)&cmd_show_rx_tx_desc_status_qid,
17360 (void *)&cmd_show_rx_tx_desc_status_desc,
17361 (void *)&cmd_show_rx_tx_desc_status_did,
17362 (void *)&cmd_show_rx_tx_desc_status_status,
17367 /* *** display rx queue desc used count *** */
17368 struct cmd_show_rx_queue_desc_used_count_result {
17369 cmdline_fixed_string_t cmd_show;
17370 cmdline_fixed_string_t cmd_port;
17371 cmdline_fixed_string_t cmd_rxq;
17372 cmdline_fixed_string_t cmd_desc;
17373 cmdline_fixed_string_t cmd_used;
17374 cmdline_fixed_string_t cmd_count;
17380 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17381 __rte_unused struct cmdline *cl,
17382 __rte_unused void *data)
17384 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17387 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17388 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17392 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17394 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17397 printf("Used desc count = %d\n", rc);
17400 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17401 TOKEN_STRING_INITIALIZER
17402 (struct cmd_show_rx_queue_desc_used_count_result,
17404 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17405 TOKEN_STRING_INITIALIZER
17406 (struct cmd_show_rx_queue_desc_used_count_result,
17408 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17409 TOKEN_NUM_INITIALIZER
17410 (struct cmd_show_rx_queue_desc_used_count_result,
17411 cmd_pid, RTE_UINT16);
17412 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17413 TOKEN_STRING_INITIALIZER
17414 (struct cmd_show_rx_queue_desc_used_count_result,
17416 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17417 TOKEN_NUM_INITIALIZER
17418 (struct cmd_show_rx_queue_desc_used_count_result,
17419 cmd_qid, RTE_UINT16);
17420 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17421 TOKEN_STRING_INITIALIZER
17422 (struct cmd_show_rx_queue_desc_used_count_result,
17423 cmd_count, "desc");
17424 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17425 TOKEN_STRING_INITIALIZER
17426 (struct cmd_show_rx_queue_desc_used_count_result,
17427 cmd_count, "used");
17428 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17429 TOKEN_STRING_INITIALIZER
17430 (struct cmd_show_rx_queue_desc_used_count_result,
17431 cmd_count, "count");
17432 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17433 .f = cmd_show_rx_queue_desc_used_count_parsed,
17435 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17437 (void *)&cmd_show_rx_queue_desc_used_count_show,
17438 (void *)&cmd_show_rx_queue_desc_used_count_port,
17439 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17440 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17441 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17442 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17443 (void *)&cmd_show_rx_queue_desc_used_count_used,
17444 (void *)&cmd_show_rx_queue_desc_used_count_count,
17449 /* Common result structure for set port ptypes */
17450 struct cmd_set_port_ptypes_result {
17451 cmdline_fixed_string_t set;
17452 cmdline_fixed_string_t port;
17454 cmdline_fixed_string_t ptype_mask;
17458 /* Common CLI fields for set port ptypes */
17459 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17460 TOKEN_STRING_INITIALIZER
17461 (struct cmd_set_port_ptypes_result,
17463 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17464 TOKEN_STRING_INITIALIZER
17465 (struct cmd_set_port_ptypes_result,
17467 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17468 TOKEN_NUM_INITIALIZER
17469 (struct cmd_set_port_ptypes_result,
17470 port_id, RTE_UINT16);
17471 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17472 TOKEN_STRING_INITIALIZER
17473 (struct cmd_set_port_ptypes_result,
17474 ptype_mask, "ptype_mask");
17475 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17476 TOKEN_NUM_INITIALIZER
17477 (struct cmd_set_port_ptypes_result,
17481 cmd_set_port_ptypes_parsed(
17482 void *parsed_result,
17483 __rte_unused struct cmdline *cl,
17484 __rte_unused void *data)
17486 struct cmd_set_port_ptypes_result *res = parsed_result;
17487 #define PTYPE_NAMESIZE 256
17488 char ptype_name[PTYPE_NAMESIZE];
17489 uint16_t port_id = res->port_id;
17490 uint32_t ptype_mask = res->mask;
17493 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17496 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17501 uint32_t ptypes[ret];
17503 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17505 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17510 printf("Successfully set following ptypes for Port %d\n", port_id);
17511 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17512 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17513 printf("%s\n", ptype_name);
17516 clear_ptypes = false;
17519 cmdline_parse_inst_t cmd_set_port_ptypes = {
17520 .f = cmd_set_port_ptypes_parsed,
17522 .help_str = "set port <port_id> ptype_mask <mask>",
17524 (void *)&cmd_set_port_ptypes_set,
17525 (void *)&cmd_set_port_ptypes_port,
17526 (void *)&cmd_set_port_ptypes_port_id,
17527 (void *)&cmd_set_port_ptypes_mask_str,
17528 (void *)&cmd_set_port_ptypes_mask_u32,
17533 /* *** display mac addresses added to a port *** */
17534 struct cmd_showport_macs_result {
17535 cmdline_fixed_string_t cmd_show;
17536 cmdline_fixed_string_t cmd_port;
17537 cmdline_fixed_string_t cmd_keyword;
17542 cmd_showport_macs_parsed(void *parsed_result,
17543 __rte_unused struct cmdline *cl,
17544 __rte_unused void *data)
17546 struct cmd_showport_macs_result *res = parsed_result;
17548 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17551 if (!strcmp(res->cmd_keyword, "macs"))
17552 show_macs(res->cmd_pid);
17553 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17554 show_mcast_macs(res->cmd_pid);
17557 cmdline_parse_token_string_t cmd_showport_macs_show =
17558 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17560 cmdline_parse_token_string_t cmd_showport_macs_port =
17561 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17563 cmdline_parse_token_num_t cmd_showport_macs_pid =
17564 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17565 cmd_pid, RTE_UINT16);
17566 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17567 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17568 cmd_keyword, "macs#mcast_macs");
17570 cmdline_parse_inst_t cmd_showport_macs = {
17571 .f = cmd_showport_macs_parsed,
17573 .help_str = "show port <port_id> macs|mcast_macs",
17575 (void *)&cmd_showport_macs_show,
17576 (void *)&cmd_showport_macs_port,
17577 (void *)&cmd_showport_macs_pid,
17578 (void *)&cmd_showport_macs_keyword,
17583 /* ******************************************************************************** */
17585 /* list of instructions */
17586 cmdline_parse_ctx_t main_ctx[] = {
17587 (cmdline_parse_inst_t *)&cmd_help_brief,
17588 (cmdline_parse_inst_t *)&cmd_help_long,
17589 (cmdline_parse_inst_t *)&cmd_quit,
17590 (cmdline_parse_inst_t *)&cmd_load_from_file,
17591 (cmdline_parse_inst_t *)&cmd_showport,
17592 (cmdline_parse_inst_t *)&cmd_showqueue,
17593 (cmdline_parse_inst_t *)&cmd_showeeprom,
17594 (cmdline_parse_inst_t *)&cmd_showportall,
17595 (cmdline_parse_inst_t *)&cmd_representor_info,
17596 (cmdline_parse_inst_t *)&cmd_showdevice,
17597 (cmdline_parse_inst_t *)&cmd_showcfg,
17598 (cmdline_parse_inst_t *)&cmd_showfwdall,
17599 (cmdline_parse_inst_t *)&cmd_start,
17600 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17601 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17602 (cmdline_parse_inst_t *)&cmd_set_link_up,
17603 (cmdline_parse_inst_t *)&cmd_set_link_down,
17604 (cmdline_parse_inst_t *)&cmd_reset,
17605 (cmdline_parse_inst_t *)&cmd_set_numbers,
17606 (cmdline_parse_inst_t *)&cmd_set_log,
17607 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17608 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17609 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17610 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17611 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17612 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17613 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17614 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17615 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17616 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17617 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17618 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17619 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17620 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17621 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17622 (cmdline_parse_inst_t *)&cmd_set_link_check,
17623 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17624 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17625 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17626 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17627 #ifdef RTE_NET_BOND
17628 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17629 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17630 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17631 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17632 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17633 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17634 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17635 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17636 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17637 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17638 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17639 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17641 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17642 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17643 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17644 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17645 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17646 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17647 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17648 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17649 (cmdline_parse_inst_t *)&cmd_csum_set,
17650 (cmdline_parse_inst_t *)&cmd_csum_show,
17651 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17652 (cmdline_parse_inst_t *)&cmd_tso_set,
17653 (cmdline_parse_inst_t *)&cmd_tso_show,
17654 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17655 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17656 (cmdline_parse_inst_t *)&cmd_gro_enable,
17657 (cmdline_parse_inst_t *)&cmd_gro_flush,
17658 (cmdline_parse_inst_t *)&cmd_gro_show,
17659 (cmdline_parse_inst_t *)&cmd_gso_enable,
17660 (cmdline_parse_inst_t *)&cmd_gso_size,
17661 (cmdline_parse_inst_t *)&cmd_gso_show,
17662 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17663 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17664 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17665 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17666 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17667 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17668 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17669 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17670 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17671 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17672 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17673 (cmdline_parse_inst_t *)&cmd_config_dcb,
17674 (cmdline_parse_inst_t *)&cmd_read_reg,
17675 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17676 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17677 (cmdline_parse_inst_t *)&cmd_write_reg,
17678 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17679 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17680 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17681 (cmdline_parse_inst_t *)&cmd_stop,
17682 (cmdline_parse_inst_t *)&cmd_mac_addr,
17683 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17684 (cmdline_parse_inst_t *)&cmd_set_qmap,
17685 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17686 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17687 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17688 (cmdline_parse_inst_t *)&cmd_operate_port,
17689 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17690 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17691 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17692 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17693 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17694 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17695 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17696 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17697 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17698 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17699 (cmdline_parse_inst_t *)&cmd_config_mtu,
17700 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17701 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17702 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17703 (cmdline_parse_inst_t *)&cmd_config_rss,
17704 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17705 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17706 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17707 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17708 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17709 (cmdline_parse_inst_t *)&cmd_showport_reta,
17710 (cmdline_parse_inst_t *)&cmd_showport_macs,
17711 (cmdline_parse_inst_t *)&cmd_config_burst,
17712 (cmdline_parse_inst_t *)&cmd_config_thresh,
17713 (cmdline_parse_inst_t *)&cmd_config_threshold,
17714 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17715 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17716 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17717 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17718 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17719 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17720 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17721 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17722 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17723 (cmdline_parse_inst_t *)&cmd_dump,
17724 (cmdline_parse_inst_t *)&cmd_dump_one,
17725 #ifdef RTE_NET_I40E
17726 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17728 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17729 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17730 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17731 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17732 (cmdline_parse_inst_t *)&cmd_flow,
17733 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17734 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17735 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17736 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17737 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17738 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17739 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17740 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17741 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17742 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17743 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17744 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17745 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17746 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17747 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17748 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17749 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17750 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17751 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17752 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17753 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17754 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17755 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17756 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17757 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17758 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17759 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17760 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17761 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17762 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17763 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17764 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17765 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17766 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17767 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17768 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17769 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17770 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17771 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17772 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17773 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17774 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17775 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17776 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17777 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17778 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17779 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17780 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17781 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17782 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17783 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17784 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17785 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17786 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17787 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17788 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17789 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17790 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17791 (cmdline_parse_inst_t *)&cmd_ddp_add,
17792 (cmdline_parse_inst_t *)&cmd_ddp_del,
17793 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17794 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17795 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17796 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17797 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17798 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17799 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17800 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17801 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17802 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17803 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17804 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17806 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17807 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17808 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17809 (cmdline_parse_inst_t *)&cmd_queue_region,
17810 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17811 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17812 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17813 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17814 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17815 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17816 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17817 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17818 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17819 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17820 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17821 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17822 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17823 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17824 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17825 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17826 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17827 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17828 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17829 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17830 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17831 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17832 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17833 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17834 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17835 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17836 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17837 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17838 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17839 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17840 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17841 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17842 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17843 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17844 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17845 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17847 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17848 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17850 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17851 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17852 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17853 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17854 (cmdline_parse_inst_t *)&cmd_set_raw,
17855 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17856 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17857 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17858 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17859 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17860 (cmdline_parse_inst_t *)&cmd_show_capability,
17864 /* read cmdline commands from file */
17866 cmdline_read_from_file(const char *filename)
17868 struct cmdline *cl;
17870 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17873 "Failed to create file based cmdline context: %s\n",
17878 cmdline_interact(cl);
17883 printf("Read CLI commands from %s\n", filename);
17886 /* prompt function, called from main on MAIN lcore */
17891 /* initialize non-constant commands */
17892 cmd_set_fwd_mode_init();
17893 cmd_set_fwd_retry_mode_init();
17895 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17896 if (testpmd_cl == NULL)
17899 ret = atexit(prompt_exit);
17901 fprintf(stderr, "Cannot set exit function for cmdline\n");
17903 cmdline_interact(testpmd_cl);
17905 cmdline_stdin_exit(testpmd_cl);
17911 if (testpmd_cl != NULL) {
17912 cmdline_quit(testpmd_cl);
17913 cmdline_stdin_exit(testpmd_cl);
17918 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17920 if (id == (portid_t)RTE_PORT_ALL) {
17923 RTE_ETH_FOREACH_DEV(pid) {
17924 /* check if need_reconfig has been set to 1 */
17925 if (ports[pid].need_reconfig == 0)
17926 ports[pid].need_reconfig = dev;
17927 /* check if need_reconfig_queues has been set to 1 */
17928 if (ports[pid].need_reconfig_queues == 0)
17929 ports[pid].need_reconfig_queues = queue;
17931 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17932 /* check if need_reconfig has been set to 1 */
17933 if (ports[id].need_reconfig == 0)
17934 ports[id].need_reconfig = dev;
17935 /* check if need_reconfig_queues has been set to 1 */
17936 if (ports[id].need_reconfig_queues == 0)
17937 ports[id].need_reconfig_queues = queue;