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 port_id (module_eeprom|eeprom)\n"
166 " Display the module EEPROM or EEPROM information for port_id.\n\n"
168 "show port X rss reta (size) (mask0,mask1,...)\n"
169 " Display the rss redirection table entry indicated"
170 " by masks on port X. size is used to indicate the"
171 " hardware supported reta size\n\n"
173 "show port (port_id) rss-hash [key]\n"
174 " Display the RSS hash functions and RSS hash key of port\n\n"
176 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
177 " Clear information for port_id, or all.\n\n"
179 "show (rxq|txq) info (port_id) (queue_id)\n"
180 " Display information for configured RX/TX queue.\n\n"
182 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
183 " Display the given configuration.\n\n"
185 "read rxd (port_id) (queue_id) (rxd_id)\n"
186 " Display an RX descriptor of a port RX queue.\n\n"
188 "read txd (port_id) (queue_id) (txd_id)\n"
189 " Display a TX descriptor of a port TX queue.\n\n"
191 "ddp get list (port_id)\n"
192 " Get ddp profile info list\n\n"
194 "ddp get info (profile_path)\n"
195 " Get ddp profile information.\n\n"
197 "show vf stats (port_id) (vf_id)\n"
198 " Display a VF's statistics.\n\n"
200 "clear vf stats (port_id) (vf_id)\n"
201 " Reset a VF's statistics.\n\n"
203 "show port (port_id) pctype mapping\n"
204 " Get flow ptype to pctype mapping on a port\n\n"
206 "show port meter stats (port_id) (meter_id) (clear)\n"
207 " Get meter stats on a port\n\n"
209 "show fwd stats all\n"
210 " Display statistics for all fwd engines.\n\n"
212 "clear fwd stats all\n"
213 " Clear statistics for all fwd engines.\n\n"
215 "show port (port_id) rx_offload capabilities\n"
216 " List all per queue and per port Rx offloading"
217 " capabilities of a port\n\n"
219 "show port (port_id) rx_offload configuration\n"
220 " List port level and all queue level"
221 " Rx offloading configuration\n\n"
223 "show port (port_id) tx_offload capabilities\n"
224 " List all per queue and per port"
225 " Tx offloading capabilities of a port\n\n"
227 "show port (port_id) tx_offload configuration\n"
228 " List port level and all queue level"
229 " Tx offloading configuration\n\n"
231 "show port (port_id) tx_metadata\n"
232 " Show Tx metadata value set"
233 " for a specific port\n\n"
235 "show port (port_id) ptypes\n"
236 " Show port supported ptypes"
237 " for a specific port\n\n"
239 "show device info (<identifier>|all)"
240 " Show general information about devices probed.\n\n"
242 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
243 " Show status of rx|tx descriptor.\n\n"
245 "show port (port_id) rxq (queue_id) desc used count\n"
246 " Show current number of filled receive"
247 " packet descriptors.\n\n"
249 "show port (port_id) macs|mcast_macs"
250 " Display list of mac addresses added to port.\n\n"
252 "show port (port_id) fec capabilities"
253 " Show fec capabilities of a port.\n\n"
255 "show port (port_id) fec_mode"
256 " Show fec mode of a port.\n\n"
258 "show port (port_id) flow_ctrl"
259 " Show flow control info of a port.\n\n"
263 if (show_all || !strcmp(res->section, "config")) {
269 "Configuration changes only become active when"
270 " forwarding is started/restarted.\n\n"
273 " Reset forwarding to the default configuration.\n\n"
275 "set verbose (level)\n"
276 " Set the debug verbosity level X.\n\n"
278 "set log global|(type) (level)\n"
279 " Set the log level.\n\n"
282 " Set number of ports.\n\n"
285 " Set number of cores.\n\n"
287 "set coremask (mask)\n"
288 " Set the forwarding cores hexadecimal mask.\n\n"
290 "set portmask (mask)\n"
291 " Set the forwarding ports hexadecimal mask.\n\n"
294 " Set number of packets per burst.\n\n"
296 "set burst tx delay (microseconds) retry (num)\n"
297 " Set the transmit delay time and number of retries,"
298 " effective when retry is enabled.\n\n"
300 "set rxoffs (x[,y]*)\n"
301 " Set the offset of each packet segment on"
302 " receiving if split feature is engaged."
303 " Affects only the queues configured with split"
306 "set rxpkts (x[,y]*)\n"
307 " Set the length of each segment to scatter"
308 " packets on receiving if split feature is engaged."
309 " Affects only the queues configured with split"
312 "set txpkts (x[,y]*)\n"
313 " Set the length of each segment of TXONLY"
314 " and optionally CSUM packets.\n\n"
316 "set txsplit (off|on|rand)\n"
317 " Set the split policy for the TX packets."
318 " Right now only applicable for CSUM and TXONLY"
321 "set txtimes (x, y)\n"
322 " Set the scheduling on timestamps"
323 " timings for the TXONLY mode\n\n"
325 "set corelist (x[,y]*)\n"
326 " Set the list of forwarding cores.\n\n"
328 "set portlist (x[,y]*)\n"
329 " Set the list of forwarding ports.\n\n"
331 "set port setup on (iterator|event)\n"
332 " Select how attached port is retrieved for setup.\n\n"
334 "set tx loopback (port_id) (on|off)\n"
335 " Enable or disable tx loopback.\n\n"
337 "set all queues drop (port_id) (on|off)\n"
338 " Set drop enable bit for all queues.\n\n"
340 "set vf split drop (port_id) (vf_id) (on|off)\n"
341 " Set split drop enable bit for a VF from the PF.\n\n"
343 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
344 " Set MAC antispoof for a VF from the PF.\n\n"
346 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
347 " Enable MACsec offload.\n\n"
349 "set macsec offload (port_id) off\n"
350 " Disable MACsec offload.\n\n"
352 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
353 " Configure MACsec secure connection (SC).\n\n"
355 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
356 " Configure MACsec secure association (SA).\n\n"
358 "set vf broadcast (port_id) (vf_id) (on|off)\n"
359 " Set VF broadcast for a VF from the PF.\n\n"
361 "vlan set stripq (on|off) (port_id,queue_id)\n"
362 " Set the VLAN strip for a queue on a port.\n\n"
364 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
365 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
367 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
368 " Set VLAN insert for a VF from the PF.\n\n"
370 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
371 " Set VLAN antispoof for a VF from the PF.\n\n"
373 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
374 " Set VLAN tag for a VF from the PF.\n\n"
376 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
377 " Set a VF's max bandwidth(Mbps).\n\n"
379 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
380 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
382 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
383 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
385 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
386 " Set some TCs' strict link priority mode on a physical port.\n\n"
388 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
389 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
391 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
392 " Set the VLAN strip or filter or qinq strip or extend\n\n"
394 "vlan set (inner|outer) tpid (value) (port_id)\n"
395 " Set the VLAN TPID for Packet Filtering on"
398 "rx_vlan add (vlan_id|all) (port_id)\n"
399 " Add a vlan_id, or all identifiers, to the set"
400 " of VLAN identifiers filtered by port_id.\n\n"
402 "rx_vlan rm (vlan_id|all) (port_id)\n"
403 " Remove a vlan_id, or all identifiers, from the set"
404 " of VLAN identifiers filtered by port_id.\n\n"
406 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
407 " Add a vlan_id, to the set of VLAN identifiers"
408 "filtered for VF(s) from port_id.\n\n"
410 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
411 " Remove a vlan_id, to the set of VLAN identifiers"
412 "filtered for VF(s) from port_id.\n\n"
414 "rx_vxlan_port add (udp_port) (port_id)\n"
415 " Add an UDP port for VXLAN packet filter on a port\n\n"
417 "rx_vxlan_port rm (udp_port) (port_id)\n"
418 " Remove an UDP port for VXLAN packet filter on a port\n\n"
420 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
421 " Set hardware insertion of VLAN IDs (single or double VLAN "
422 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
424 "tx_vlan set pvid port_id vlan_id (on|off)\n"
425 " Set port based TX VLAN insertion.\n\n"
427 "tx_vlan reset (port_id)\n"
428 " Disable hardware insertion of a VLAN header in"
429 " packets sent on a port.\n\n"
431 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
432 " Select hardware or software calculation of the"
433 " checksum when transmitting a packet using the"
434 " csum forward engine.\n"
435 " ip|udp|tcp|sctp always concern the inner layer.\n"
436 " outer-ip concerns the outer IP layer in"
437 " outer-udp concerns the outer UDP layer in"
438 " case the packet is recognized as a tunnel packet by"
439 " the forward engine (vxlan, gre and ipip are supported)\n"
440 " Please check the NIC datasheet for HW limits.\n\n"
442 "csum parse-tunnel (on|off) (tx_port_id)\n"
443 " If disabled, treat tunnel packets as non-tunneled"
444 " packets (treat inner headers as payload). The port\n"
445 " argument is the port used for TX in csum forward"
448 "csum show (port_id)\n"
449 " Display tx checksum offload configuration\n\n"
451 "tso set (segsize) (portid)\n"
452 " Enable TCP Segmentation Offload in csum forward"
454 " Please check the NIC datasheet for HW limits.\n\n"
457 " Display the status of TCP Segmentation Offload.\n\n"
459 "set port (port_id) gro on|off\n"
460 " Enable or disable Generic Receive Offload in"
461 " csum forwarding engine.\n\n"
463 "show port (port_id) gro\n"
464 " Display GRO configuration.\n\n"
466 "set gro flush (cycles)\n"
467 " Set the cycle to flush GROed packets from"
468 " reassembly tables.\n\n"
470 "set port (port_id) gso (on|off)"
471 " Enable or disable Generic Segmentation Offload in"
472 " csum forwarding engine.\n\n"
474 "set gso segsz (length)\n"
475 " Set max packet length for output GSO segments,"
476 " including packet header and payload.\n\n"
478 "show port (port_id) gso\n"
479 " Show GSO configuration.\n\n"
482 " Set packet forwarding mode.\n\n"
484 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 " Add a MAC address on port_id.\n\n"
487 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 " Remove a MAC address from port_id.\n\n"
490 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
491 " Set the default MAC address for port_id.\n\n"
493 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
494 " Add a MAC address for a VF on the port.\n\n"
496 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
497 " Set the MAC address for a VF from the PF.\n\n"
499 "set eth-peer (port_id) (peer_addr)\n"
500 " set the peer address for certain port.\n\n"
502 "set port (port_id) uta (mac_address|all) (on|off)\n"
503 " Add/Remove a or all unicast hash filter(s)"
506 "set promisc (port_id|all) (on|off)\n"
507 " Set the promiscuous mode on port_id, or all.\n\n"
509 "set allmulti (port_id|all) (on|off)\n"
510 " Set the allmulti mode on port_id, or all.\n\n"
512 "set vf promisc (port_id) (vf_id) (on|off)\n"
513 " Set unicast promiscuous mode for a VF from the PF.\n\n"
515 "set vf allmulti (port_id) (vf_id) (on|off)\n"
516 " Set multicast promiscuous mode for a VF from the PF.\n\n"
518 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
519 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
520 " (on|off) autoneg (on|off) (port_id)\n"
521 "set flow_ctrl rx (on|off) (portid)\n"
522 "set flow_ctrl tx (on|off) (portid)\n"
523 "set flow_ctrl high_water (high_water) (portid)\n"
524 "set flow_ctrl low_water (low_water) (portid)\n"
525 "set flow_ctrl pause_time (pause_time) (portid)\n"
526 "set flow_ctrl send_xon (send_xon) (portid)\n"
527 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
528 "set flow_ctrl autoneg (on|off) (port_id)\n"
529 " Set the link flow control parameter on a port.\n\n"
531 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
532 " (low_water) (pause_time) (priority) (port_id)\n"
533 " Set the priority flow control parameter on a"
536 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
537 " Set statistics mapping (qmapping 0..15) for RX/TX"
539 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
540 " on port 0 to mapping 5.\n\n"
542 "set xstats-hide-zero on|off\n"
543 " Set the option to hide the zero values"
544 " for xstats display.\n"
546 "set record-core-cycles on|off\n"
547 " Set the option to enable measurement of CPU cycles.\n"
549 "set record-burst-stats on|off\n"
550 " Set the option to enable display of RX and TX bursts.\n"
552 "set port (port_id) vf (vf_id) rx|tx on|off\n"
553 " Enable/Disable a VF receive/tranmit from a port\n\n"
555 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
557 " AUPE:accepts untagged VLAN;"
558 "ROPE:accept unicast hash\n\n"
559 " BAM:accepts broadcast packets;"
560 "MPE:accepts all multicast packets\n\n"
561 " Enable/Disable a VF receive mode of a port\n\n"
563 "set port (port_id) queue (queue_id) rate (rate_num)\n"
564 " Set rate limit for a queue of a port\n\n"
566 "set port (port_id) vf (vf_id) rate (rate_num) "
567 "queue_mask (queue_mask_value)\n"
568 " Set rate limit for queues in VF of a port\n\n"
570 "set flush_rx (on|off)\n"
571 " Flush (default) or don't flush RX streams before"
572 " forwarding. Mainly used with PCAP drivers.\n\n"
574 "set bypass mode (normal|bypass|isolate) (port_id)\n"
575 " Set the bypass mode for the lowest port on bypass enabled"
578 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
579 "mode (normal|bypass|isolate) (port_id)\n"
580 " Set the event required to initiate specified bypass mode for"
581 " the lowest port on a bypass enabled NIC where:\n"
582 " timeout = enable bypass after watchdog timeout.\n"
583 " os_on = enable bypass when OS/board is powered on.\n"
584 " os_off = enable bypass when OS/board is powered off.\n"
585 " power_on = enable bypass when power supply is turned on.\n"
586 " power_off = enable bypass when power supply is turned off."
589 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
590 " Set the bypass watchdog timeout to 'n' seconds"
591 " where 0 = instant.\n\n"
593 "show bypass config (port_id)\n"
594 " Show the bypass configuration for a bypass enabled NIC"
595 " using the lowest port on the NIC.\n\n"
598 "create bonded device (mode) (socket)\n"
599 " Create a new bonded device with specific bonding mode and socket.\n\n"
601 "add bonding slave (slave_id) (port_id)\n"
602 " Add a slave device to a bonded device.\n\n"
604 "remove bonding slave (slave_id) (port_id)\n"
605 " Remove a slave device from a bonded device.\n\n"
607 "set bonding mode (value) (port_id)\n"
608 " Set the bonding mode on a bonded device.\n\n"
610 "set bonding primary (slave_id) (port_id)\n"
611 " Set the primary slave for a bonded device.\n\n"
613 "show bonding config (port_id)\n"
614 " Show the bonding config for port_id.\n\n"
616 "show bonding lacp info (port_id)\n"
617 " Show the bonding lacp information for port_id.\n\n"
619 "set bonding mac_addr (port_id) (address)\n"
620 " Set the MAC address of a bonded device.\n\n"
622 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
623 " Set Aggregation mode for IEEE802.3AD (mode 4)"
625 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
626 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
628 "set bonding mon_period (port_id) (value)\n"
629 " Set the bonding link status monitoring polling period in ms.\n\n"
631 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
632 " Enable/disable dedicated queues for LACP control traffic.\n\n"
635 "set link-up port (port_id)\n"
636 " Set link up for a port.\n\n"
638 "set link-down port (port_id)\n"
639 " Set link down for a port.\n\n"
641 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
642 " Load a profile package on a port\n\n"
644 "ddp del (port_id) (backup_profile_path)\n"
645 " Delete a profile package from a port\n\n"
647 "ptype mapping get (port_id) (valid_only)\n"
648 " Get ptype mapping on a port\n\n"
650 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
651 " Replace target with the pkt_type in ptype mapping\n\n"
653 "ptype mapping reset (port_id)\n"
654 " Reset ptype mapping on a port\n\n"
656 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
657 " Update a ptype mapping item on a port\n\n"
659 "set port (port_id) ptype_mask (ptype_mask)\n"
660 " set packet types classification for a specific port\n\n"
662 "set port (port_id) queue-region region_id (value) "
663 "queue_start_index (value) queue_num (value)\n"
664 " Set a queue region on a port\n\n"
666 "set port (port_id) queue-region region_id (value) "
668 " Set a flowtype region index on a port\n\n"
670 "set port (port_id) queue-region UP (value) region_id (value)\n"
671 " Set the mapping of User Priority to "
672 "queue region on a port\n\n"
674 "set port (port_id) queue-region flush (on|off)\n"
675 " flush all queue region related configuration\n\n"
677 "show port meter cap (port_id)\n"
678 " Show port meter capability information\n\n"
680 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
681 " meter profile add - srtcm rfc 2697\n\n"
683 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
684 " meter profile add - trtcm rfc 2698\n\n"
686 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
687 " meter profile add - trtcm rfc 4115\n\n"
689 "del port meter profile (port_id) (profile_id)\n"
690 " meter profile delete\n\n"
692 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
693 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
694 "(dscp_tbl_entry63)]\n"
697 "enable port meter (port_id) (mtr_id)\n"
700 "disable port meter (port_id) (mtr_id)\n"
703 "del port meter (port_id) (mtr_id)\n"
706 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
707 "y_actions (actions) r_actions (actions)\n"
708 " meter policy add\n\n"
710 "del port meter policy (port_id) (policy_id)\n"
711 " meter policy delete\n\n"
713 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
714 " meter update meter profile\n\n"
716 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
717 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
718 " update meter dscp table entries\n\n"
720 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
721 "(action0) [(action1) (action2)]\n"
722 " meter update policer action\n\n"
724 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
725 " meter update stats\n\n"
727 "show port (port_id) queue-region\n"
728 " show all queue region related configuration info\n\n"
730 "set port (port_id) fec_mode auto|off|rs|baser\n"
731 " set fec mode for a specific port\n\n"
733 , list_pkt_forwarding_modes()
737 if (show_all || !strcmp(res->section, "ports")) {
743 "----------------\n\n"
745 "port start (port_id|all)\n"
746 " Start all ports or port_id.\n\n"
748 "port stop (port_id|all)\n"
749 " Stop all ports or port_id.\n\n"
751 "port close (port_id|all)\n"
752 " Close all ports or port_id.\n\n"
754 "port reset (port_id|all)\n"
755 " Reset all ports or port_id.\n\n"
757 "port attach (ident)\n"
758 " Attach physical or virtual dev by pci address or virtual device name\n\n"
760 "port detach (port_id)\n"
761 " Detach physical or virtual dev by port_id\n\n"
763 "port config (port_id|all)"
764 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
765 " duplex (half|full|auto)\n"
766 " Set speed and duplex for all ports or port_id\n\n"
768 "port config (port_id|all) loopback (mode)\n"
769 " Set loopback mode for all ports or port_id\n\n"
771 "port config all (rxq|txq|rxd|txd) (value)\n"
772 " Set number for rxq/txq/rxd/txd.\n\n"
774 "port config all max-pkt-len (value)\n"
775 " Set the max packet length.\n\n"
777 "port config all max-lro-pkt-size (value)\n"
778 " Set the max LRO aggregated packet size.\n\n"
780 "port config all drop-en (on|off)\n"
781 " Enable or disable packet drop on all RX queues of all ports when no "
782 "receive buffers available.\n\n"
784 "port config all rss (all|default|ip|tcp|udp|sctp|"
785 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
786 "level-outer|level-inner|<flowtype_id>)\n"
787 " Set the RSS mode.\n\n"
789 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
790 " Set the RSS redirection table.\n\n"
792 "port config (port_id) dcb vt (on|off) (traffic_class)"
794 " Set the DCB mode.\n\n"
796 "port config all burst (value)\n"
797 " Set the number of packets per burst.\n\n"
799 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
801 " Set the ring prefetch/host/writeback threshold"
802 " for tx/rx queue.\n\n"
804 "port config all (txfreet|txrst|rxfreet) (value)\n"
805 " Set free threshold for rx/tx, or set"
806 " tx rs bit threshold.\n\n"
807 "port config mtu X value\n"
808 " Set the MTU of port X to a given value\n\n"
810 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
811 " Set a rx/tx queue's ring size configuration, the new"
812 " value will take effect after command that (re-)start the port"
813 " or command that setup the specific queue\n\n"
815 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
816 " Start/stop a rx/tx queue of port X. Only take effect"
817 " when port X is started\n\n"
819 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
820 " Switch on/off a deferred start of port X rx/tx queue. Only"
821 " take effect when port X is stopped.\n\n"
823 "port (port_id) (rxq|txq) (queue_id) setup\n"
824 " Setup a rx/tx queue of port X.\n\n"
826 "port config (port_id) pctype mapping reset\n"
827 " Reset flow type to pctype mapping on a port\n\n"
829 "port config (port_id) pctype mapping update"
830 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
831 " Update a flow type to pctype mapping item on a port\n\n"
833 "port config (port_id) pctype (pctype_id) hash_inset|"
834 "fdir_inset|fdir_flx_inset get|set|clear field\n"
836 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
838 "port config (port_id) pctype (pctype_id) hash_inset|"
839 "fdir_inset|fdir_flx_inset clear all"
840 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
842 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
843 " Add/remove UDP tunnel port for tunneling offload\n\n"
845 "port config <port_id> rx_offload vlan_strip|"
846 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
847 "outer_ipv4_cksum|macsec_strip|header_split|"
848 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
849 "buffer_split|timestamp|security|keep_crc on|off\n"
850 " Enable or disable a per port Rx offloading"
851 " on all Rx queues of a port\n\n"
853 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
854 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
855 "outer_ipv4_cksum|macsec_strip|header_split|"
856 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
857 "buffer_split|timestamp|security|keep_crc on|off\n"
858 " Enable or disable a per queue Rx offloading"
859 " only on a specific Rx queue\n\n"
861 "port config (port_id) tx_offload vlan_insert|"
862 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
863 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
864 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
865 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
867 " Enable or disable a per port Tx offloading"
868 " on all Tx queues of a port\n\n"
870 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
871 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
872 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
873 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
874 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
876 " Enable or disable a per queue Tx offloading"
877 " only on a specific Tx queue\n\n"
879 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
880 " Load an eBPF program as a callback"
881 " for particular RX/TX queue\n\n"
883 "bpf-unload rx|tx (port) (queue)\n"
884 " Unload previously loaded eBPF program"
885 " for particular RX/TX queue\n\n"
887 "port config (port_id) tx_metadata (value)\n"
888 " Set Tx metadata value per port. Testpmd will add this value"
889 " to any Tx packet sent from this port\n\n"
891 "port config (port_id) dynf (name) set|clear\n"
892 " Register a dynf and Set/clear this flag on Tx. "
893 "Testpmd will set this value to any Tx packet "
894 "sent from this port\n\n"
896 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
897 " Cleanup txq mbufs for a specific Tx queue\n\n"
901 if (show_all || !strcmp(res->section, "registers")) {
909 "read reg (port_id) (address)\n"
910 " Display value of a port register.\n\n"
912 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
913 " Display a port register bit field.\n\n"
915 "read regbit (port_id) (address) (bit_x)\n"
916 " Display a single port register bit.\n\n"
918 "write reg (port_id) (address) (value)\n"
919 " Set value of a port register.\n\n"
921 "write regfield (port_id) (address) (bit_x) (bit_y)"
923 " Set bit field of a port register.\n\n"
925 "write regbit (port_id) (address) (bit_x) (value)\n"
926 " Set single bit value of a port register.\n\n"
929 if (show_all || !strcmp(res->section, "filters")) {
938 "flow_director_filter (port_id) mode raw (add|del|update)"
939 " flow (flow_id) (drop|fwd) queue (queue_id)"
940 " fd_id (fd_id_value) packet (packet file name)\n"
941 " Add/Del a raw type flow director filter.\n\n"
944 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
945 " src_mask (ipv4_src) (ipv6_src) (src_port)"
946 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
947 " Set flow director IP mask.\n\n"
949 "flow_director_mask (port_id) mode MAC-VLAN"
950 " vlan (vlan_value)\n"
951 " Set flow director MAC-VLAN mask.\n\n"
953 "flow_director_mask (port_id) mode Tunnel"
954 " vlan (vlan_value) mac (mac_value)"
955 " tunnel-type (tunnel_type_value)"
956 " tunnel-id (tunnel_id_value)\n"
957 " Set flow director Tunnel mask.\n\n"
959 "flow_director_flex_payload (port_id)"
960 " (raw|l2|l3|l4) (config)\n"
961 " Configure flex payload selection.\n\n"
963 "flow validate {port_id}"
964 " [group {group_id}] [priority {level}]"
965 " [ingress] [egress]"
966 " pattern {item} [/ {item} [...]] / end"
967 " actions {action} [/ {action} [...]] / end\n"
968 " Check whether a flow rule can be created.\n\n"
970 "flow create {port_id}"
971 " [group {group_id}] [priority {level}]"
972 " [ingress] [egress]"
973 " pattern {item} [/ {item} [...]] / end"
974 " actions {action} [/ {action} [...]] / end\n"
975 " Create a flow rule.\n\n"
977 "flow destroy {port_id} rule {rule_id} [...]\n"
978 " Destroy specific flow rules.\n\n"
980 "flow flush {port_id}\n"
981 " Destroy all flow rules.\n\n"
983 "flow query {port_id} {rule_id} {action}\n"
984 " Query an existing flow rule.\n\n"
986 "flow list {port_id} [group {group_id}] [...]\n"
987 " List existing flow rules sorted by priority,"
988 " filtered by group identifiers.\n\n"
990 "flow isolate {port_id} {boolean}\n"
991 " Restrict ingress traffic to the defined"
994 "flow aged {port_id} [destroy]\n"
995 " List and destroy aged flows"
998 "flow indirect_action {port_id} create"
999 " [action_id {indirect_action_id}]"
1000 " [ingress] [egress]"
1001 " action {action} / end\n"
1002 " Create indirect action.\n\n"
1004 "flow indirect_action {port_id} update"
1005 " {indirect_action_id} action {action} / end\n"
1006 " Update indirect action.\n\n"
1008 "flow indirect_action {port_id} destroy"
1009 " action_id {indirect_action_id} [...]\n"
1010 " Destroy specific indirect actions.\n\n"
1012 "flow indirect_action {port_id} query"
1013 " {indirect_action_id}\n"
1014 " Query an existing indirect action.\n\n"
1016 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1017 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1018 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1019 " Configure the VXLAN encapsulation for flows.\n\n"
1021 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1022 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1023 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1024 " eth-dst (eth-dst)\n"
1025 " Configure the VXLAN encapsulation for flows.\n\n"
1027 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1028 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1029 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1030 " eth-dst (eth-dst)\n"
1031 " Configure the VXLAN encapsulation for flows.\n\n"
1033 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1034 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1036 " Configure the NVGRE encapsulation for flows.\n\n"
1038 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1039 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1040 " eth-src (eth-src) eth-dst (eth-dst)\n"
1041 " Configure the NVGRE encapsulation for flows.\n\n"
1043 "set raw_encap {flow items}\n"
1044 " Configure the encapsulation with raw data.\n\n"
1046 "set raw_decap {flow items}\n"
1047 " Configure the decapsulation with raw data.\n\n"
1052 if (show_all || !strcmp(res->section, "traffic_management")) {
1056 "Traffic Management:\n"
1058 "show port tm cap (port_id)\n"
1059 " Display the port TM capability.\n\n"
1061 "show port tm level cap (port_id) (level_id)\n"
1062 " Display the port TM hierarchical level capability.\n\n"
1064 "show port tm node cap (port_id) (node_id)\n"
1065 " Display the port TM node capability.\n\n"
1067 "show port tm node type (port_id) (node_id)\n"
1068 " Display the port TM node type.\n\n"
1070 "show port tm node stats (port_id) (node_id) (clear)\n"
1071 " Display the port TM node stats.\n\n"
1073 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1074 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1075 " (packet_length_adjust) (packet_mode)\n"
1076 " Add port tm node private shaper profile.\n\n"
1078 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1079 " Delete port tm node private shaper profile.\n\n"
1081 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1082 " (shaper_profile_id)\n"
1083 " Add/update port tm node shared shaper.\n\n"
1085 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1086 " Delete port tm node shared shaper.\n\n"
1088 "set port tm node shaper profile (port_id) (node_id)"
1089 " (shaper_profile_id)\n"
1090 " Set port tm node shaper profile.\n\n"
1092 "add port tm node wred profile (port_id) (wred_profile_id)"
1093 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1094 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1095 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1096 " Add port tm node wred profile.\n\n"
1098 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1099 " Delete port tm node wred profile.\n\n"
1101 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1102 " (priority) (weight) (level_id) (shaper_profile_id)"
1103 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1104 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1105 " Add port tm nonleaf node.\n\n"
1107 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1108 " (priority) (weight) (level_id) (shaper_profile_id)"
1109 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1110 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1111 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1113 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1114 " (priority) (weight) (level_id) (shaper_profile_id)"
1115 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1116 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1117 " Add port tm leaf node.\n\n"
1119 "del port tm node (port_id) (node_id)\n"
1120 " Delete port tm node.\n\n"
1122 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1123 " (priority) (weight)\n"
1124 " Set port tm node parent.\n\n"
1126 "suspend port tm node (port_id) (node_id)"
1127 " Suspend tm node.\n\n"
1129 "resume port tm node (port_id) (node_id)"
1130 " Resume tm node.\n\n"
1132 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1133 " Commit tm hierarchy.\n\n"
1135 "set port tm mark ip_ecn (port) (green) (yellow)"
1137 " Enables/Disables the traffic management marking"
1138 " for IP ECN (Explicit Congestion Notification)"
1139 " packets on a given port\n\n"
1141 "set port tm mark ip_dscp (port) (green) (yellow)"
1143 " Enables/Disables the traffic management marking"
1144 " on the port for IP dscp packets\n\n"
1146 "set port tm mark vlan_dei (port) (green) (yellow)"
1148 " Enables/Disables the traffic management marking"
1149 " on the port for VLAN packets with DEI enabled\n\n"
1153 if (show_all || !strcmp(res->section, "devices")) {
1157 "Device Operations:\n"
1159 "device detach (identifier)\n"
1160 " Detach device by identifier.\n\n"
1166 cmdline_parse_token_string_t cmd_help_long_help =
1167 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1169 cmdline_parse_token_string_t cmd_help_long_section =
1170 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1171 "all#control#display#config#"
1172 "ports#registers#filters#traffic_management#devices");
1174 cmdline_parse_inst_t cmd_help_long = {
1175 .f = cmd_help_long_parsed,
1177 .help_str = "help all|control|display|config|ports|register|"
1178 "filters|traffic_management|devices: "
1181 (void *)&cmd_help_long_help,
1182 (void *)&cmd_help_long_section,
1188 /* *** start/stop/close all ports *** */
1189 struct cmd_operate_port_result {
1190 cmdline_fixed_string_t keyword;
1191 cmdline_fixed_string_t name;
1192 cmdline_fixed_string_t value;
1195 static void cmd_operate_port_parsed(void *parsed_result,
1196 __rte_unused struct cmdline *cl,
1197 __rte_unused void *data)
1199 struct cmd_operate_port_result *res = parsed_result;
1201 if (!strcmp(res->name, "start"))
1202 start_port(RTE_PORT_ALL);
1203 else if (!strcmp(res->name, "stop"))
1204 stop_port(RTE_PORT_ALL);
1205 else if (!strcmp(res->name, "close"))
1206 close_port(RTE_PORT_ALL);
1207 else if (!strcmp(res->name, "reset"))
1208 reset_port(RTE_PORT_ALL);
1210 fprintf(stderr, "Unknown parameter\n");
1213 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1214 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1216 cmdline_parse_token_string_t cmd_operate_port_all_port =
1217 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1218 "start#stop#close#reset");
1219 cmdline_parse_token_string_t cmd_operate_port_all_all =
1220 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1222 cmdline_parse_inst_t cmd_operate_port = {
1223 .f = cmd_operate_port_parsed,
1225 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1227 (void *)&cmd_operate_port_all_cmd,
1228 (void *)&cmd_operate_port_all_port,
1229 (void *)&cmd_operate_port_all_all,
1234 /* *** start/stop/close specific port *** */
1235 struct cmd_operate_specific_port_result {
1236 cmdline_fixed_string_t keyword;
1237 cmdline_fixed_string_t name;
1241 static void cmd_operate_specific_port_parsed(void *parsed_result,
1242 __rte_unused struct cmdline *cl,
1243 __rte_unused void *data)
1245 struct cmd_operate_specific_port_result *res = parsed_result;
1247 if (!strcmp(res->name, "start"))
1248 start_port(res->value);
1249 else if (!strcmp(res->name, "stop"))
1250 stop_port(res->value);
1251 else if (!strcmp(res->name, "close"))
1252 close_port(res->value);
1253 else if (!strcmp(res->name, "reset"))
1254 reset_port(res->value);
1256 fprintf(stderr, "Unknown parameter\n");
1259 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1260 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1262 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1263 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1264 name, "start#stop#close#reset");
1265 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1266 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1269 cmdline_parse_inst_t cmd_operate_specific_port = {
1270 .f = cmd_operate_specific_port_parsed,
1272 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1274 (void *)&cmd_operate_specific_port_cmd,
1275 (void *)&cmd_operate_specific_port_port,
1276 (void *)&cmd_operate_specific_port_id,
1281 /* *** enable port setup (after attach) via iterator or event *** */
1282 struct cmd_set_port_setup_on_result {
1283 cmdline_fixed_string_t set;
1284 cmdline_fixed_string_t port;
1285 cmdline_fixed_string_t setup;
1286 cmdline_fixed_string_t on;
1287 cmdline_fixed_string_t mode;
1290 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1291 __rte_unused struct cmdline *cl,
1292 __rte_unused void *data)
1294 struct cmd_set_port_setup_on_result *res = parsed_result;
1296 if (strcmp(res->mode, "event") == 0)
1297 setup_on_probe_event = true;
1298 else if (strcmp(res->mode, "iterator") == 0)
1299 setup_on_probe_event = false;
1301 fprintf(stderr, "Unknown mode\n");
1304 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1305 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1307 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1308 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1310 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1311 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1313 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1314 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1316 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1317 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1318 mode, "iterator#event");
1320 cmdline_parse_inst_t cmd_set_port_setup_on = {
1321 .f = cmd_set_port_setup_on_parsed,
1323 .help_str = "set port setup on iterator|event",
1325 (void *)&cmd_set_port_setup_on_set,
1326 (void *)&cmd_set_port_setup_on_port,
1327 (void *)&cmd_set_port_setup_on_setup,
1328 (void *)&cmd_set_port_setup_on_on,
1329 (void *)&cmd_set_port_setup_on_mode,
1334 /* *** attach a specified port *** */
1335 struct cmd_operate_attach_port_result {
1336 cmdline_fixed_string_t port;
1337 cmdline_fixed_string_t keyword;
1338 cmdline_multi_string_t identifier;
1341 static void cmd_operate_attach_port_parsed(void *parsed_result,
1342 __rte_unused struct cmdline *cl,
1343 __rte_unused void *data)
1345 struct cmd_operate_attach_port_result *res = parsed_result;
1347 if (!strcmp(res->keyword, "attach"))
1348 attach_port(res->identifier);
1350 fprintf(stderr, "Unknown parameter\n");
1353 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1354 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1356 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1357 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1359 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1360 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1361 identifier, TOKEN_STRING_MULTI);
1363 cmdline_parse_inst_t cmd_operate_attach_port = {
1364 .f = cmd_operate_attach_port_parsed,
1366 .help_str = "port attach <identifier>: "
1367 "(identifier: pci address or virtual dev name)",
1369 (void *)&cmd_operate_attach_port_port,
1370 (void *)&cmd_operate_attach_port_keyword,
1371 (void *)&cmd_operate_attach_port_identifier,
1376 /* *** detach a specified port *** */
1377 struct cmd_operate_detach_port_result {
1378 cmdline_fixed_string_t port;
1379 cmdline_fixed_string_t keyword;
1383 static void cmd_operate_detach_port_parsed(void *parsed_result,
1384 __rte_unused struct cmdline *cl,
1385 __rte_unused void *data)
1387 struct cmd_operate_detach_port_result *res = parsed_result;
1389 if (!strcmp(res->keyword, "detach")) {
1390 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1391 detach_port_device(res->port_id);
1393 fprintf(stderr, "Unknown parameter\n");
1397 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1398 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1400 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1401 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1403 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1404 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1405 port_id, RTE_UINT16);
1407 cmdline_parse_inst_t cmd_operate_detach_port = {
1408 .f = cmd_operate_detach_port_parsed,
1410 .help_str = "port detach <port_id>",
1412 (void *)&cmd_operate_detach_port_port,
1413 (void *)&cmd_operate_detach_port_keyword,
1414 (void *)&cmd_operate_detach_port_port_id,
1419 /* *** detach device by identifier *** */
1420 struct cmd_operate_detach_device_result {
1421 cmdline_fixed_string_t device;
1422 cmdline_fixed_string_t keyword;
1423 cmdline_fixed_string_t identifier;
1426 static void cmd_operate_detach_device_parsed(void *parsed_result,
1427 __rte_unused struct cmdline *cl,
1428 __rte_unused void *data)
1430 struct cmd_operate_detach_device_result *res = parsed_result;
1432 if (!strcmp(res->keyword, "detach"))
1433 detach_devargs(res->identifier);
1435 fprintf(stderr, "Unknown parameter\n");
1438 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1439 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1441 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1442 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1444 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1445 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1448 cmdline_parse_inst_t cmd_operate_detach_device = {
1449 .f = cmd_operate_detach_device_parsed,
1451 .help_str = "device detach <identifier>:"
1452 "(identifier: pci address or virtual dev name)",
1454 (void *)&cmd_operate_detach_device_device,
1455 (void *)&cmd_operate_detach_device_keyword,
1456 (void *)&cmd_operate_detach_device_identifier,
1460 /* *** configure speed for all ports *** */
1461 struct cmd_config_speed_all {
1462 cmdline_fixed_string_t port;
1463 cmdline_fixed_string_t keyword;
1464 cmdline_fixed_string_t all;
1465 cmdline_fixed_string_t item1;
1466 cmdline_fixed_string_t item2;
1467 cmdline_fixed_string_t value1;
1468 cmdline_fixed_string_t value2;
1472 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1477 if (!strcmp(duplexstr, "half")) {
1478 duplex = ETH_LINK_HALF_DUPLEX;
1479 } else if (!strcmp(duplexstr, "full")) {
1480 duplex = ETH_LINK_FULL_DUPLEX;
1481 } else if (!strcmp(duplexstr, "auto")) {
1482 duplex = ETH_LINK_FULL_DUPLEX;
1484 fprintf(stderr, "Unknown duplex parameter\n");
1488 if (!strcmp(speedstr, "10")) {
1489 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1490 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1491 } else if (!strcmp(speedstr, "100")) {
1492 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1493 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1495 if (duplex != ETH_LINK_FULL_DUPLEX) {
1496 fprintf(stderr, "Invalid speed/duplex parameters\n");
1499 if (!strcmp(speedstr, "1000")) {
1500 *speed = ETH_LINK_SPEED_1G;
1501 } else if (!strcmp(speedstr, "10000")) {
1502 *speed = ETH_LINK_SPEED_10G;
1503 } else if (!strcmp(speedstr, "25000")) {
1504 *speed = ETH_LINK_SPEED_25G;
1505 } else if (!strcmp(speedstr, "40000")) {
1506 *speed = ETH_LINK_SPEED_40G;
1507 } else if (!strcmp(speedstr, "50000")) {
1508 *speed = ETH_LINK_SPEED_50G;
1509 } else if (!strcmp(speedstr, "100000")) {
1510 *speed = ETH_LINK_SPEED_100G;
1511 } else if (!strcmp(speedstr, "200000")) {
1512 *speed = ETH_LINK_SPEED_200G;
1513 } else if (!strcmp(speedstr, "auto")) {
1514 *speed = ETH_LINK_SPEED_AUTONEG;
1516 fprintf(stderr, "Unknown speed parameter\n");
1521 if (*speed != ETH_LINK_SPEED_AUTONEG)
1522 *speed |= ETH_LINK_SPEED_FIXED;
1528 cmd_config_speed_all_parsed(void *parsed_result,
1529 __rte_unused struct cmdline *cl,
1530 __rte_unused void *data)
1532 struct cmd_config_speed_all *res = parsed_result;
1533 uint32_t link_speed;
1536 if (!all_ports_stopped()) {
1537 fprintf(stderr, "Please stop all ports first\n");
1541 if (parse_and_check_speed_duplex(res->value1, res->value2,
1545 RTE_ETH_FOREACH_DEV(pid) {
1546 ports[pid].dev_conf.link_speeds = link_speed;
1549 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1552 cmdline_parse_token_string_t cmd_config_speed_all_port =
1553 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1554 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1555 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1557 cmdline_parse_token_string_t cmd_config_speed_all_all =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1559 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1561 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1563 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1564 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1565 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1566 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1570 cmdline_parse_inst_t cmd_config_speed_all = {
1571 .f = cmd_config_speed_all_parsed,
1573 .help_str = "port config all speed "
1574 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1577 (void *)&cmd_config_speed_all_port,
1578 (void *)&cmd_config_speed_all_keyword,
1579 (void *)&cmd_config_speed_all_all,
1580 (void *)&cmd_config_speed_all_item1,
1581 (void *)&cmd_config_speed_all_value1,
1582 (void *)&cmd_config_speed_all_item2,
1583 (void *)&cmd_config_speed_all_value2,
1588 /* *** configure speed for specific port *** */
1589 struct cmd_config_speed_specific {
1590 cmdline_fixed_string_t port;
1591 cmdline_fixed_string_t keyword;
1593 cmdline_fixed_string_t item1;
1594 cmdline_fixed_string_t item2;
1595 cmdline_fixed_string_t value1;
1596 cmdline_fixed_string_t value2;
1600 cmd_config_speed_specific_parsed(void *parsed_result,
1601 __rte_unused struct cmdline *cl,
1602 __rte_unused void *data)
1604 struct cmd_config_speed_specific *res = parsed_result;
1605 uint32_t link_speed;
1607 if (port_id_is_invalid(res->id, ENABLED_WARN))
1610 if (!port_is_stopped(res->id)) {
1611 fprintf(stderr, "Please stop port %d first\n", res->id);
1615 if (parse_and_check_speed_duplex(res->value1, res->value2,
1619 ports[res->id].dev_conf.link_speeds = link_speed;
1621 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1625 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1626 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1628 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1631 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1632 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1633 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1636 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1638 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1639 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1642 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1646 cmdline_parse_inst_t cmd_config_speed_specific = {
1647 .f = cmd_config_speed_specific_parsed,
1649 .help_str = "port config <port_id> speed "
1650 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1653 (void *)&cmd_config_speed_specific_port,
1654 (void *)&cmd_config_speed_specific_keyword,
1655 (void *)&cmd_config_speed_specific_id,
1656 (void *)&cmd_config_speed_specific_item1,
1657 (void *)&cmd_config_speed_specific_value1,
1658 (void *)&cmd_config_speed_specific_item2,
1659 (void *)&cmd_config_speed_specific_value2,
1664 /* *** configure loopback for all ports *** */
1665 struct cmd_config_loopback_all {
1666 cmdline_fixed_string_t port;
1667 cmdline_fixed_string_t keyword;
1668 cmdline_fixed_string_t all;
1669 cmdline_fixed_string_t item;
1674 cmd_config_loopback_all_parsed(void *parsed_result,
1675 __rte_unused struct cmdline *cl,
1676 __rte_unused void *data)
1678 struct cmd_config_loopback_all *res = parsed_result;
1681 if (!all_ports_stopped()) {
1682 fprintf(stderr, "Please stop all ports first\n");
1686 RTE_ETH_FOREACH_DEV(pid) {
1687 ports[pid].dev_conf.lpbk_mode = res->mode;
1690 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1693 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1695 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1698 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1699 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1700 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1701 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1703 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1704 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1706 cmdline_parse_inst_t cmd_config_loopback_all = {
1707 .f = cmd_config_loopback_all_parsed,
1709 .help_str = "port config all loopback <mode>",
1711 (void *)&cmd_config_loopback_all_port,
1712 (void *)&cmd_config_loopback_all_keyword,
1713 (void *)&cmd_config_loopback_all_all,
1714 (void *)&cmd_config_loopback_all_item,
1715 (void *)&cmd_config_loopback_all_mode,
1720 /* *** configure loopback for specific port *** */
1721 struct cmd_config_loopback_specific {
1722 cmdline_fixed_string_t port;
1723 cmdline_fixed_string_t keyword;
1725 cmdline_fixed_string_t item;
1730 cmd_config_loopback_specific_parsed(void *parsed_result,
1731 __rte_unused struct cmdline *cl,
1732 __rte_unused void *data)
1734 struct cmd_config_loopback_specific *res = parsed_result;
1736 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1739 if (!port_is_stopped(res->port_id)) {
1740 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1744 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1746 cmd_reconfig_device_queue(res->port_id, 1, 1);
1750 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1751 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1753 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1754 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1756 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1757 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1759 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1762 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1763 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1766 cmdline_parse_inst_t cmd_config_loopback_specific = {
1767 .f = cmd_config_loopback_specific_parsed,
1769 .help_str = "port config <port_id> loopback <mode>",
1771 (void *)&cmd_config_loopback_specific_port,
1772 (void *)&cmd_config_loopback_specific_keyword,
1773 (void *)&cmd_config_loopback_specific_id,
1774 (void *)&cmd_config_loopback_specific_item,
1775 (void *)&cmd_config_loopback_specific_mode,
1780 /* *** configure txq/rxq, txd/rxd *** */
1781 struct cmd_config_rx_tx {
1782 cmdline_fixed_string_t port;
1783 cmdline_fixed_string_t keyword;
1784 cmdline_fixed_string_t all;
1785 cmdline_fixed_string_t name;
1790 cmd_config_rx_tx_parsed(void *parsed_result,
1791 __rte_unused struct cmdline *cl,
1792 __rte_unused void *data)
1794 struct cmd_config_rx_tx *res = parsed_result;
1796 if (!all_ports_stopped()) {
1797 fprintf(stderr, "Please stop all ports first\n");
1800 if (!strcmp(res->name, "rxq")) {
1801 if (!res->value && !nb_txq) {
1802 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1805 if (check_nb_rxq(res->value) != 0)
1807 nb_rxq = res->value;
1809 else if (!strcmp(res->name, "txq")) {
1810 if (!res->value && !nb_rxq) {
1811 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1814 if (check_nb_txq(res->value) != 0)
1816 nb_txq = res->value;
1818 else if (!strcmp(res->name, "rxd")) {
1819 if (check_nb_rxd(res->value) != 0)
1821 nb_rxd = res->value;
1822 } else if (!strcmp(res->name, "txd")) {
1823 if (check_nb_txd(res->value) != 0)
1826 nb_txd = res->value;
1828 fprintf(stderr, "Unknown parameter\n");
1836 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1839 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1840 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1841 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1842 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1843 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1845 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1846 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1848 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1849 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1851 cmdline_parse_inst_t cmd_config_rx_tx = {
1852 .f = cmd_config_rx_tx_parsed,
1854 .help_str = "port config all rxq|txq|rxd|txd <value>",
1856 (void *)&cmd_config_rx_tx_port,
1857 (void *)&cmd_config_rx_tx_keyword,
1858 (void *)&cmd_config_rx_tx_all,
1859 (void *)&cmd_config_rx_tx_name,
1860 (void *)&cmd_config_rx_tx_value,
1865 /* *** config max packet length *** */
1866 struct cmd_config_max_pkt_len_result {
1867 cmdline_fixed_string_t port;
1868 cmdline_fixed_string_t keyword;
1869 cmdline_fixed_string_t all;
1870 cmdline_fixed_string_t name;
1875 cmd_config_max_pkt_len_parsed(void *parsed_result,
1876 __rte_unused struct cmdline *cl,
1877 __rte_unused void *data)
1879 struct cmd_config_max_pkt_len_result *res = parsed_result;
1880 uint32_t max_rx_pkt_len_backup = 0;
1884 if (!all_ports_stopped()) {
1885 fprintf(stderr, "Please stop all ports first\n");
1889 RTE_ETH_FOREACH_DEV(pid) {
1890 struct rte_port *port = &ports[pid];
1892 if (!strcmp(res->name, "max-pkt-len")) {
1893 if (res->value < RTE_ETHER_MIN_LEN) {
1895 "max-pkt-len can not be less than %d\n",
1899 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1902 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1905 "rte_eth_dev_info_get() failed for port %u\n",
1910 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1912 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1913 if (update_jumbo_frame_offload(pid) != 0)
1914 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1916 fprintf(stderr, "Unknown parameter\n");
1923 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1926 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1927 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1929 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1930 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1932 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1935 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1938 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1939 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1942 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1943 .f = cmd_config_max_pkt_len_parsed,
1945 .help_str = "port config all max-pkt-len <value>",
1947 (void *)&cmd_config_max_pkt_len_port,
1948 (void *)&cmd_config_max_pkt_len_keyword,
1949 (void *)&cmd_config_max_pkt_len_all,
1950 (void *)&cmd_config_max_pkt_len_name,
1951 (void *)&cmd_config_max_pkt_len_value,
1956 /* *** config max LRO aggregated packet size *** */
1957 struct cmd_config_max_lro_pkt_size_result {
1958 cmdline_fixed_string_t port;
1959 cmdline_fixed_string_t keyword;
1960 cmdline_fixed_string_t all;
1961 cmdline_fixed_string_t name;
1966 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1967 __rte_unused struct cmdline *cl,
1968 __rte_unused void *data)
1970 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1973 if (!all_ports_stopped()) {
1974 fprintf(stderr, "Please stop all ports first\n");
1978 RTE_ETH_FOREACH_DEV(pid) {
1979 struct rte_port *port = &ports[pid];
1981 if (!strcmp(res->name, "max-lro-pkt-size")) {
1983 port->dev_conf.rxmode.max_lro_pkt_size)
1986 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1988 fprintf(stderr, "Unknown parameter\n");
1995 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1998 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
1999 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2001 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2004 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2005 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2007 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2009 name, "max-lro-pkt-size");
2010 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2011 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2014 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2015 .f = cmd_config_max_lro_pkt_size_parsed,
2017 .help_str = "port config all max-lro-pkt-size <value>",
2019 (void *)&cmd_config_max_lro_pkt_size_port,
2020 (void *)&cmd_config_max_lro_pkt_size_keyword,
2021 (void *)&cmd_config_max_lro_pkt_size_all,
2022 (void *)&cmd_config_max_lro_pkt_size_name,
2023 (void *)&cmd_config_max_lro_pkt_size_value,
2028 /* *** configure port MTU *** */
2029 struct cmd_config_mtu_result {
2030 cmdline_fixed_string_t port;
2031 cmdline_fixed_string_t keyword;
2032 cmdline_fixed_string_t mtu;
2038 cmd_config_mtu_parsed(void *parsed_result,
2039 __rte_unused struct cmdline *cl,
2040 __rte_unused void *data)
2042 struct cmd_config_mtu_result *res = parsed_result;
2044 if (res->value < RTE_ETHER_MIN_LEN) {
2045 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2048 port_mtu_set(res->port_id, res->value);
2051 cmdline_parse_token_string_t cmd_config_mtu_port =
2052 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2054 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2055 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2057 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2058 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2060 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2061 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2063 cmdline_parse_token_num_t cmd_config_mtu_value =
2064 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2067 cmdline_parse_inst_t cmd_config_mtu = {
2068 .f = cmd_config_mtu_parsed,
2070 .help_str = "port config mtu <port_id> <value>",
2072 (void *)&cmd_config_mtu_port,
2073 (void *)&cmd_config_mtu_keyword,
2074 (void *)&cmd_config_mtu_mtu,
2075 (void *)&cmd_config_mtu_port_id,
2076 (void *)&cmd_config_mtu_value,
2081 /* *** configure rx mode *** */
2082 struct cmd_config_rx_mode_flag {
2083 cmdline_fixed_string_t port;
2084 cmdline_fixed_string_t keyword;
2085 cmdline_fixed_string_t all;
2086 cmdline_fixed_string_t name;
2087 cmdline_fixed_string_t value;
2091 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2092 __rte_unused struct cmdline *cl,
2093 __rte_unused void *data)
2095 struct cmd_config_rx_mode_flag *res = parsed_result;
2097 if (!all_ports_stopped()) {
2098 fprintf(stderr, "Please stop all ports first\n");
2102 if (!strcmp(res->name, "drop-en")) {
2103 if (!strcmp(res->value, "on"))
2105 else if (!strcmp(res->value, "off"))
2108 fprintf(stderr, "Unknown parameter\n");
2112 fprintf(stderr, "Unknown parameter\n");
2118 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2121 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2122 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2123 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2124 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2126 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2127 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2128 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2129 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2131 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2135 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2136 .f = cmd_config_rx_mode_flag_parsed,
2138 .help_str = "port config all drop-en on|off",
2140 (void *)&cmd_config_rx_mode_flag_port,
2141 (void *)&cmd_config_rx_mode_flag_keyword,
2142 (void *)&cmd_config_rx_mode_flag_all,
2143 (void *)&cmd_config_rx_mode_flag_name,
2144 (void *)&cmd_config_rx_mode_flag_value,
2149 /* *** configure rss *** */
2150 struct cmd_config_rss {
2151 cmdline_fixed_string_t port;
2152 cmdline_fixed_string_t keyword;
2153 cmdline_fixed_string_t all;
2154 cmdline_fixed_string_t name;
2155 cmdline_fixed_string_t value;
2159 cmd_config_rss_parsed(void *parsed_result,
2160 __rte_unused struct cmdline *cl,
2161 __rte_unused void *data)
2163 struct cmd_config_rss *res = parsed_result;
2164 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2165 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2166 int use_default = 0;
2167 int all_updated = 1;
2172 if (!strcmp(res->value, "all"))
2173 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2174 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2175 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2176 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2178 else if (!strcmp(res->value, "eth"))
2179 rss_conf.rss_hf = ETH_RSS_ETH;
2180 else if (!strcmp(res->value, "vlan"))
2181 rss_conf.rss_hf = ETH_RSS_VLAN;
2182 else if (!strcmp(res->value, "ip"))
2183 rss_conf.rss_hf = ETH_RSS_IP;
2184 else if (!strcmp(res->value, "udp"))
2185 rss_conf.rss_hf = ETH_RSS_UDP;
2186 else if (!strcmp(res->value, "tcp"))
2187 rss_conf.rss_hf = ETH_RSS_TCP;
2188 else if (!strcmp(res->value, "sctp"))
2189 rss_conf.rss_hf = ETH_RSS_SCTP;
2190 else if (!strcmp(res->value, "ether"))
2191 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2192 else if (!strcmp(res->value, "port"))
2193 rss_conf.rss_hf = ETH_RSS_PORT;
2194 else if (!strcmp(res->value, "vxlan"))
2195 rss_conf.rss_hf = ETH_RSS_VXLAN;
2196 else if (!strcmp(res->value, "geneve"))
2197 rss_conf.rss_hf = ETH_RSS_GENEVE;
2198 else if (!strcmp(res->value, "nvgre"))
2199 rss_conf.rss_hf = ETH_RSS_NVGRE;
2200 else if (!strcmp(res->value, "l3-pre32"))
2201 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2202 else if (!strcmp(res->value, "l3-pre40"))
2203 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2204 else if (!strcmp(res->value, "l3-pre48"))
2205 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2206 else if (!strcmp(res->value, "l3-pre56"))
2207 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2208 else if (!strcmp(res->value, "l3-pre64"))
2209 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2210 else if (!strcmp(res->value, "l3-pre96"))
2211 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2212 else if (!strcmp(res->value, "l3-src-only"))
2213 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2214 else if (!strcmp(res->value, "l3-dst-only"))
2215 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2216 else if (!strcmp(res->value, "l4-src-only"))
2217 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2218 else if (!strcmp(res->value, "l4-dst-only"))
2219 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2220 else if (!strcmp(res->value, "l2-src-only"))
2221 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2222 else if (!strcmp(res->value, "l2-dst-only"))
2223 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2224 else if (!strcmp(res->value, "l2tpv3"))
2225 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2226 else if (!strcmp(res->value, "esp"))
2227 rss_conf.rss_hf = ETH_RSS_ESP;
2228 else if (!strcmp(res->value, "ah"))
2229 rss_conf.rss_hf = ETH_RSS_AH;
2230 else if (!strcmp(res->value, "pfcp"))
2231 rss_conf.rss_hf = ETH_RSS_PFCP;
2232 else if (!strcmp(res->value, "pppoe"))
2233 rss_conf.rss_hf = ETH_RSS_PPPOE;
2234 else if (!strcmp(res->value, "gtpu"))
2235 rss_conf.rss_hf = ETH_RSS_GTPU;
2236 else if (!strcmp(res->value, "ecpri"))
2237 rss_conf.rss_hf = ETH_RSS_ECPRI;
2238 else if (!strcmp(res->value, "mpls"))
2239 rss_conf.rss_hf = ETH_RSS_MPLS;
2240 else if (!strcmp(res->value, "ipv4-chksum"))
2241 rss_conf.rss_hf = ETH_RSS_IPV4_CHKSUM;
2242 else if (!strcmp(res->value, "none"))
2243 rss_conf.rss_hf = 0;
2244 else if (!strcmp(res->value, "level-default")) {
2245 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2246 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2247 } else if (!strcmp(res->value, "level-outer")) {
2248 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2249 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2250 } else if (!strcmp(res->value, "level-inner")) {
2251 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2252 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2253 } else if (!strcmp(res->value, "default"))
2255 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2256 atoi(res->value) < 64)
2257 rss_conf.rss_hf = 1ULL << atoi(res->value);
2259 fprintf(stderr, "Unknown parameter\n");
2262 rss_conf.rss_key = NULL;
2263 /* Update global configuration for RSS types. */
2264 RTE_ETH_FOREACH_DEV(i) {
2265 struct rte_eth_rss_conf local_rss_conf;
2267 ret = eth_dev_info_get_print_err(i, &dev_info);
2272 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2274 local_rss_conf = rss_conf;
2275 local_rss_conf.rss_hf = rss_conf.rss_hf &
2276 dev_info.flow_type_rss_offloads;
2277 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2278 printf("Port %u modified RSS hash function based on hardware support,"
2279 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2280 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2282 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2286 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2287 i, -diag, strerror(-diag));
2290 if (all_updated && !use_default) {
2291 rss_hf = rss_conf.rss_hf;
2292 printf("rss_hf %#"PRIx64"\n", rss_hf);
2296 cmdline_parse_token_string_t cmd_config_rss_port =
2297 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2298 cmdline_parse_token_string_t cmd_config_rss_keyword =
2299 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2300 cmdline_parse_token_string_t cmd_config_rss_all =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2302 cmdline_parse_token_string_t cmd_config_rss_name =
2303 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2304 cmdline_parse_token_string_t cmd_config_rss_value =
2305 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2307 cmdline_parse_inst_t cmd_config_rss = {
2308 .f = cmd_config_rss_parsed,
2310 .help_str = "port config all rss "
2311 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2312 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2313 "level-outer|level-inner|ipv4-chksum|<flowtype_id>",
2315 (void *)&cmd_config_rss_port,
2316 (void *)&cmd_config_rss_keyword,
2317 (void *)&cmd_config_rss_all,
2318 (void *)&cmd_config_rss_name,
2319 (void *)&cmd_config_rss_value,
2324 /* *** configure rss hash key *** */
2325 struct cmd_config_rss_hash_key {
2326 cmdline_fixed_string_t port;
2327 cmdline_fixed_string_t config;
2329 cmdline_fixed_string_t rss_hash_key;
2330 cmdline_fixed_string_t rss_type;
2331 cmdline_fixed_string_t key;
2335 hexa_digit_to_value(char hexa_digit)
2337 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2338 return (uint8_t) (hexa_digit - '0');
2339 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2340 return (uint8_t) ((hexa_digit - 'a') + 10);
2341 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2342 return (uint8_t) ((hexa_digit - 'A') + 10);
2343 /* Invalid hexa digit */
2348 parse_and_check_key_hexa_digit(char *key, int idx)
2352 hexa_v = hexa_digit_to_value(key[idx]);
2355 "invalid key: character %c at position %d is not a valid hexa digit\n",
2361 cmd_config_rss_hash_key_parsed(void *parsed_result,
2362 __rte_unused struct cmdline *cl,
2363 __rte_unused void *data)
2365 struct cmd_config_rss_hash_key *res = parsed_result;
2366 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2370 struct rte_eth_dev_info dev_info;
2371 uint8_t hash_key_size;
2375 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2379 if (dev_info.hash_key_size > 0 &&
2380 dev_info.hash_key_size <= sizeof(hash_key))
2381 hash_key_size = dev_info.hash_key_size;
2384 "dev_info did not provide a valid hash key size\n");
2387 /* Check the length of the RSS hash key */
2388 key_len = strlen(res->key);
2389 if (key_len != (hash_key_size * 2)) {
2391 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2392 (int)key_len, hash_key_size * 2);
2395 /* Translate RSS hash key into binary representation */
2396 for (i = 0; i < hash_key_size; i++) {
2397 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2400 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2403 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2405 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2409 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2410 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2411 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2412 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2414 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2415 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2417 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2418 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2419 rss_hash_key, "rss-hash-key");
2420 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2421 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2422 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2423 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2424 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2425 "ipv6-tcp-ex#ipv6-udp-ex#"
2426 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2427 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2428 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2429 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2430 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2432 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2433 .f = cmd_config_rss_hash_key_parsed,
2435 .help_str = "port config <port_id> rss-hash-key "
2436 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2437 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2438 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2439 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2440 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2441 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2442 "<string of hex digits (variable length, NIC dependent)>",
2444 (void *)&cmd_config_rss_hash_key_port,
2445 (void *)&cmd_config_rss_hash_key_config,
2446 (void *)&cmd_config_rss_hash_key_port_id,
2447 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2448 (void *)&cmd_config_rss_hash_key_rss_type,
2449 (void *)&cmd_config_rss_hash_key_value,
2454 /* *** cleanup txq mbufs *** */
2455 struct cmd_cleanup_txq_mbufs_result {
2456 cmdline_fixed_string_t port;
2457 cmdline_fixed_string_t keyword;
2458 cmdline_fixed_string_t name;
2465 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2466 __rte_unused struct cmdline *cl,
2467 __rte_unused void *data)
2469 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2470 uint16_t port_id = res->port_id;
2471 uint16_t queue_id = res->queue_id;
2472 uint32_t free_cnt = res->free_cnt;
2473 struct rte_eth_txq_info qinfo;
2476 if (test_done == 0) {
2477 fprintf(stderr, "Please stop forwarding first\n");
2481 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2482 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2487 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2488 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2492 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2495 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2496 port_id, queue_id, strerror(-ret), ret);
2500 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2501 port_id, queue_id, ret);
2504 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2505 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2507 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2508 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2510 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2511 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2513 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2514 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2516 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2517 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2519 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2520 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2523 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2524 .f = cmd_cleanup_txq_mbufs_parsed,
2526 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2528 (void *)&cmd_cleanup_txq_mbufs_port,
2529 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2530 (void *)&cmd_cleanup_txq_mbufs_port_id,
2531 (void *)&cmd_cleanup_txq_mbufs_txq,
2532 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2533 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2538 /* *** configure port rxq/txq ring size *** */
2539 struct cmd_config_rxtx_ring_size {
2540 cmdline_fixed_string_t port;
2541 cmdline_fixed_string_t config;
2543 cmdline_fixed_string_t rxtxq;
2545 cmdline_fixed_string_t rsize;
2550 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2551 __rte_unused struct cmdline *cl,
2552 __rte_unused void *data)
2554 struct cmd_config_rxtx_ring_size *res = parsed_result;
2555 struct rte_port *port;
2558 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2561 if (res->portid == (portid_t)RTE_PORT_ALL) {
2562 fprintf(stderr, "Invalid port id\n");
2566 port = &ports[res->portid];
2568 if (!strcmp(res->rxtxq, "rxq"))
2570 else if (!strcmp(res->rxtxq, "txq"))
2573 fprintf(stderr, "Unknown parameter\n");
2577 if (isrx && rx_queue_id_is_invalid(res->qid))
2579 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2582 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2584 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2590 port->nb_rx_desc[res->qid] = res->size;
2592 port->nb_tx_desc[res->qid] = res->size;
2594 cmd_reconfig_device_queue(res->portid, 0, 1);
2597 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2598 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2600 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2601 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2603 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2604 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2605 portid, RTE_UINT16);
2606 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2607 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2609 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2610 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2612 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2613 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2614 rsize, "ring_size");
2615 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2616 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2619 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2620 .f = cmd_config_rxtx_ring_size_parsed,
2622 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2624 (void *)&cmd_config_rxtx_ring_size_port,
2625 (void *)&cmd_config_rxtx_ring_size_config,
2626 (void *)&cmd_config_rxtx_ring_size_portid,
2627 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2628 (void *)&cmd_config_rxtx_ring_size_qid,
2629 (void *)&cmd_config_rxtx_ring_size_rsize,
2630 (void *)&cmd_config_rxtx_ring_size_size,
2635 /* *** configure port rxq/txq start/stop *** */
2636 struct cmd_config_rxtx_queue {
2637 cmdline_fixed_string_t port;
2639 cmdline_fixed_string_t rxtxq;
2641 cmdline_fixed_string_t opname;
2645 cmd_config_rxtx_queue_parsed(void *parsed_result,
2646 __rte_unused struct cmdline *cl,
2647 __rte_unused void *data)
2649 struct cmd_config_rxtx_queue *res = parsed_result;
2654 if (test_done == 0) {
2655 fprintf(stderr, "Please stop forwarding first\n");
2659 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2662 if (port_is_started(res->portid) != 1) {
2663 fprintf(stderr, "Please start port %u first\n", res->portid);
2667 if (!strcmp(res->rxtxq, "rxq"))
2669 else if (!strcmp(res->rxtxq, "txq"))
2672 fprintf(stderr, "Unknown parameter\n");
2676 if (isrx && rx_queue_id_is_invalid(res->qid))
2678 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2681 if (!strcmp(res->opname, "start"))
2683 else if (!strcmp(res->opname, "stop"))
2686 fprintf(stderr, "Unknown parameter\n");
2690 if (isstart && isrx)
2691 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2692 else if (!isstart && isrx)
2693 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2694 else if (isstart && !isrx)
2695 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2697 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2699 if (ret == -ENOTSUP)
2700 fprintf(stderr, "Function not supported in PMD driver\n");
2703 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2704 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2705 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2706 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2707 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2708 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2709 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2710 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2711 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2712 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2715 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2716 .f = cmd_config_rxtx_queue_parsed,
2718 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2720 (void *)&cmd_config_rxtx_queue_port,
2721 (void *)&cmd_config_rxtx_queue_portid,
2722 (void *)&cmd_config_rxtx_queue_rxtxq,
2723 (void *)&cmd_config_rxtx_queue_qid,
2724 (void *)&cmd_config_rxtx_queue_opname,
2729 /* *** configure port rxq/txq deferred start on/off *** */
2730 struct cmd_config_deferred_start_rxtx_queue {
2731 cmdline_fixed_string_t port;
2733 cmdline_fixed_string_t rxtxq;
2735 cmdline_fixed_string_t opname;
2736 cmdline_fixed_string_t state;
2740 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2741 __rte_unused struct cmdline *cl,
2742 __rte_unused void *data)
2744 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2745 struct rte_port *port;
2748 uint8_t needreconfig = 0;
2750 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2753 if (port_is_started(res->port_id) != 0) {
2754 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2758 port = &ports[res->port_id];
2760 isrx = !strcmp(res->rxtxq, "rxq");
2762 if (isrx && rx_queue_id_is_invalid(res->qid))
2764 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2767 ison = !strcmp(res->state, "on");
2769 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2770 port->rx_conf[res->qid].rx_deferred_start = ison;
2772 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2773 port->tx_conf[res->qid].tx_deferred_start = ison;
2778 cmd_reconfig_device_queue(res->port_id, 0, 1);
2781 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2782 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2784 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2785 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2786 port_id, RTE_UINT16);
2787 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2788 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2790 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2791 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2793 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2794 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2795 opname, "deferred_start");
2796 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2797 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2800 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2801 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2803 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2805 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2806 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2807 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2808 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2809 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2810 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2815 /* *** configure port rxq/txq setup *** */
2816 struct cmd_setup_rxtx_queue {
2817 cmdline_fixed_string_t port;
2819 cmdline_fixed_string_t rxtxq;
2821 cmdline_fixed_string_t setup;
2824 /* Common CLI fields for queue setup */
2825 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2826 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2827 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2828 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2829 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2830 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2831 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2832 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2833 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2834 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2837 cmd_setup_rxtx_queue_parsed(
2838 void *parsed_result,
2839 __rte_unused struct cmdline *cl,
2840 __rte_unused void *data)
2842 struct cmd_setup_rxtx_queue *res = parsed_result;
2843 struct rte_port *port;
2844 struct rte_mempool *mp;
2845 unsigned int socket_id;
2849 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2852 if (res->portid == (portid_t)RTE_PORT_ALL) {
2853 fprintf(stderr, "Invalid port id\n");
2857 if (!strcmp(res->rxtxq, "rxq"))
2859 else if (!strcmp(res->rxtxq, "txq"))
2862 fprintf(stderr, "Unknown parameter\n");
2866 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2867 fprintf(stderr, "Invalid rx queue\n");
2869 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2870 fprintf(stderr, "Invalid tx queue\n");
2874 port = &ports[res->portid];
2876 socket_id = rxring_numa[res->portid];
2877 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2878 socket_id = port->socket_id;
2880 mp = mbuf_pool_find(socket_id, 0);
2883 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2884 rxring_numa[res->portid]);
2887 ret = rx_queue_setup(res->portid,
2889 port->nb_rx_desc[res->qid],
2891 &port->rx_conf[res->qid],
2894 fprintf(stderr, "Failed to setup RX queue\n");
2896 socket_id = txring_numa[res->portid];
2897 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2898 socket_id = port->socket_id;
2900 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2902 "Failed to setup TX queue: not enough descriptors\n");
2905 ret = rte_eth_tx_queue_setup(res->portid,
2907 port->nb_tx_desc[res->qid],
2909 &port->tx_conf[res->qid]);
2911 fprintf(stderr, "Failed to setup TX queue\n");
2915 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2916 .f = cmd_setup_rxtx_queue_parsed,
2918 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2920 (void *)&cmd_setup_rxtx_queue_port,
2921 (void *)&cmd_setup_rxtx_queue_portid,
2922 (void *)&cmd_setup_rxtx_queue_rxtxq,
2923 (void *)&cmd_setup_rxtx_queue_qid,
2924 (void *)&cmd_setup_rxtx_queue_setup,
2930 /* *** Configure RSS RETA *** */
2931 struct cmd_config_rss_reta {
2932 cmdline_fixed_string_t port;
2933 cmdline_fixed_string_t keyword;
2935 cmdline_fixed_string_t name;
2936 cmdline_fixed_string_t list_name;
2937 cmdline_fixed_string_t list_of_items;
2941 parse_reta_config(const char *str,
2942 struct rte_eth_rss_reta_entry64 *reta_conf,
2943 uint16_t nb_entries)
2947 uint16_t hash_index, idx, shift;
2950 const char *p, *p0 = str;
2957 unsigned long int_fld[_NUM_FLD];
2958 char *str_fld[_NUM_FLD];
2960 while ((p = strchr(p0,'(')) != NULL) {
2962 if((p0 = strchr(p,')')) == NULL)
2966 if(size >= sizeof(s))
2969 snprintf(s, sizeof(s), "%.*s", size, p);
2970 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2972 for (i = 0; i < _NUM_FLD; i++) {
2974 int_fld[i] = strtoul(str_fld[i], &end, 0);
2975 if (errno != 0 || end == str_fld[i] ||
2980 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2981 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2983 if (hash_index >= nb_entries) {
2984 fprintf(stderr, "Invalid RETA hash index=%d\n",
2989 idx = hash_index / RTE_RETA_GROUP_SIZE;
2990 shift = hash_index % RTE_RETA_GROUP_SIZE;
2991 reta_conf[idx].mask |= (1ULL << shift);
2992 reta_conf[idx].reta[shift] = nb_queue;
2999 cmd_set_rss_reta_parsed(void *parsed_result,
3000 __rte_unused struct cmdline *cl,
3001 __rte_unused void *data)
3004 struct rte_eth_dev_info dev_info;
3005 struct rte_eth_rss_reta_entry64 reta_conf[8];
3006 struct cmd_config_rss_reta *res = parsed_result;
3008 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3012 if (dev_info.reta_size == 0) {
3014 "Redirection table size is 0 which is invalid for RSS\n");
3017 printf("The reta size of port %d is %u\n",
3018 res->port_id, dev_info.reta_size);
3019 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3021 "Currently do not support more than %u entries of redirection table\n",
3022 ETH_RSS_RETA_SIZE_512);
3026 memset(reta_conf, 0, sizeof(reta_conf));
3027 if (!strcmp(res->list_name, "reta")) {
3028 if (parse_reta_config(res->list_of_items, reta_conf,
3029 dev_info.reta_size)) {
3031 "Invalid RSS Redirection Table config entered\n");
3034 ret = rte_eth_dev_rss_reta_update(res->port_id,
3035 reta_conf, dev_info.reta_size);
3038 "Bad redirection table parameter, return code = %d\n",
3043 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3044 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3045 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3046 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3047 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3048 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3049 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3050 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3051 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3052 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3053 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3054 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3056 cmdline_parse_inst_t cmd_config_rss_reta = {
3057 .f = cmd_set_rss_reta_parsed,
3059 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3061 (void *)&cmd_config_rss_reta_port,
3062 (void *)&cmd_config_rss_reta_keyword,
3063 (void *)&cmd_config_rss_reta_port_id,
3064 (void *)&cmd_config_rss_reta_name,
3065 (void *)&cmd_config_rss_reta_list_name,
3066 (void *)&cmd_config_rss_reta_list_of_items,
3071 /* *** SHOW PORT RETA INFO *** */
3072 struct cmd_showport_reta {
3073 cmdline_fixed_string_t show;
3074 cmdline_fixed_string_t port;
3076 cmdline_fixed_string_t rss;
3077 cmdline_fixed_string_t reta;
3079 cmdline_fixed_string_t list_of_items;
3083 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3084 uint16_t nb_entries,
3088 const char *p, *p0 = str;
3093 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3094 RTE_RETA_GROUP_SIZE;
3097 p = strchr(p0, '(');
3101 p0 = strchr(p, ')');
3105 if (size >= sizeof(s)) {
3107 "The string size exceeds the internal buffer size\n");
3110 snprintf(s, sizeof(s), "%.*s", size, p);
3111 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3112 if (ret <= 0 || ret != num) {
3114 "The bits of masks do not match the number of reta entries: %u\n",
3118 for (i = 0; i < ret; i++)
3119 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3125 cmd_showport_reta_parsed(void *parsed_result,
3126 __rte_unused struct cmdline *cl,
3127 __rte_unused void *data)
3129 struct cmd_showport_reta *res = parsed_result;
3130 struct rte_eth_rss_reta_entry64 reta_conf[8];
3131 struct rte_eth_dev_info dev_info;
3132 uint16_t max_reta_size;
3135 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3139 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3140 if (res->size == 0 || res->size > max_reta_size) {
3141 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3142 res->size, max_reta_size);
3146 memset(reta_conf, 0, sizeof(reta_conf));
3147 if (showport_parse_reta_config(reta_conf, res->size,
3148 res->list_of_items) < 0) {
3149 fprintf(stderr, "Invalid string: %s for reta masks\n",
3150 res->list_of_items);
3153 port_rss_reta_info(res->port_id, reta_conf, res->size);
3156 cmdline_parse_token_string_t cmd_showport_reta_show =
3157 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3158 cmdline_parse_token_string_t cmd_showport_reta_port =
3159 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3160 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3161 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3162 cmdline_parse_token_string_t cmd_showport_reta_rss =
3163 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3164 cmdline_parse_token_string_t cmd_showport_reta_reta =
3165 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3166 cmdline_parse_token_num_t cmd_showport_reta_size =
3167 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3168 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3169 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3170 list_of_items, NULL);
3172 cmdline_parse_inst_t cmd_showport_reta = {
3173 .f = cmd_showport_reta_parsed,
3175 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3177 (void *)&cmd_showport_reta_show,
3178 (void *)&cmd_showport_reta_port,
3179 (void *)&cmd_showport_reta_port_id,
3180 (void *)&cmd_showport_reta_rss,
3181 (void *)&cmd_showport_reta_reta,
3182 (void *)&cmd_showport_reta_size,
3183 (void *)&cmd_showport_reta_list_of_items,
3188 /* *** Show RSS hash configuration *** */
3189 struct cmd_showport_rss_hash {
3190 cmdline_fixed_string_t show;
3191 cmdline_fixed_string_t port;
3193 cmdline_fixed_string_t rss_hash;
3194 cmdline_fixed_string_t rss_type;
3195 cmdline_fixed_string_t key; /* optional argument */
3198 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3199 __rte_unused struct cmdline *cl,
3202 struct cmd_showport_rss_hash *res = parsed_result;
3204 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3207 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3208 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3209 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3210 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3211 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3212 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3214 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3215 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3217 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3218 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3220 cmdline_parse_inst_t cmd_showport_rss_hash = {
3221 .f = cmd_showport_rss_hash_parsed,
3223 .help_str = "show port <port_id> rss-hash",
3225 (void *)&cmd_showport_rss_hash_show,
3226 (void *)&cmd_showport_rss_hash_port,
3227 (void *)&cmd_showport_rss_hash_port_id,
3228 (void *)&cmd_showport_rss_hash_rss_hash,
3233 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3234 .f = cmd_showport_rss_hash_parsed,
3236 .help_str = "show port <port_id> rss-hash key",
3238 (void *)&cmd_showport_rss_hash_show,
3239 (void *)&cmd_showport_rss_hash_port,
3240 (void *)&cmd_showport_rss_hash_port_id,
3241 (void *)&cmd_showport_rss_hash_rss_hash,
3242 (void *)&cmd_showport_rss_hash_rss_key,
3247 /* *** Configure DCB *** */
3248 struct cmd_config_dcb {
3249 cmdline_fixed_string_t port;
3250 cmdline_fixed_string_t config;
3252 cmdline_fixed_string_t dcb;
3253 cmdline_fixed_string_t vt;
3254 cmdline_fixed_string_t vt_en;
3256 cmdline_fixed_string_t pfc;
3257 cmdline_fixed_string_t pfc_en;
3261 cmd_config_dcb_parsed(void *parsed_result,
3262 __rte_unused struct cmdline *cl,
3263 __rte_unused void *data)
3265 struct cmd_config_dcb *res = parsed_result;
3266 struct rte_eth_dcb_info dcb_info;
3267 portid_t port_id = res->port_id;
3268 struct rte_port *port;
3272 port = &ports[port_id];
3273 /** Check if the port is not started **/
3274 if (port->port_status != RTE_PORT_STOPPED) {
3275 fprintf(stderr, "Please stop port %d first\n", port_id);
3279 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3281 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3285 if (nb_fwd_lcores < res->num_tcs) {
3287 "nb_cores shouldn't be less than number of TCs.\n");
3291 /* Check whether the port supports the report of DCB info. */
3292 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3293 if (ret == -ENOTSUP) {
3294 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3298 if (!strncmp(res->pfc_en, "on", 2))
3303 /* DCB in VT mode */
3304 if (!strncmp(res->vt_en, "on", 2))
3305 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3306 (enum rte_eth_nb_tcs)res->num_tcs,
3309 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3310 (enum rte_eth_nb_tcs)res->num_tcs,
3313 fprintf(stderr, "Cannot initialize network ports.\n");
3319 cmd_reconfig_device_queue(port_id, 1, 1);
3322 cmdline_parse_token_string_t cmd_config_dcb_port =
3323 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3324 cmdline_parse_token_string_t cmd_config_dcb_config =
3325 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3326 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3327 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3328 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3329 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3330 cmdline_parse_token_string_t cmd_config_dcb_vt =
3331 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3332 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3333 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3334 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3335 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3336 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3337 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3338 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3339 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3341 cmdline_parse_inst_t cmd_config_dcb = {
3342 .f = cmd_config_dcb_parsed,
3344 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3346 (void *)&cmd_config_dcb_port,
3347 (void *)&cmd_config_dcb_config,
3348 (void *)&cmd_config_dcb_port_id,
3349 (void *)&cmd_config_dcb_dcb,
3350 (void *)&cmd_config_dcb_vt,
3351 (void *)&cmd_config_dcb_vt_en,
3352 (void *)&cmd_config_dcb_num_tcs,
3353 (void *)&cmd_config_dcb_pfc,
3354 (void *)&cmd_config_dcb_pfc_en,
3359 /* *** configure number of packets per burst *** */
3360 struct cmd_config_burst {
3361 cmdline_fixed_string_t port;
3362 cmdline_fixed_string_t keyword;
3363 cmdline_fixed_string_t all;
3364 cmdline_fixed_string_t name;
3369 cmd_config_burst_parsed(void *parsed_result,
3370 __rte_unused struct cmdline *cl,
3371 __rte_unused void *data)
3373 struct cmd_config_burst *res = parsed_result;
3374 struct rte_eth_dev_info dev_info;
3375 uint16_t rec_nb_pkts;
3378 if (!all_ports_stopped()) {
3379 fprintf(stderr, "Please stop all ports first\n");
3383 if (!strcmp(res->name, "burst")) {
3384 if (res->value == 0) {
3385 /* If user gives a value of zero, query the PMD for
3386 * its recommended Rx burst size. Testpmd uses a single
3387 * size for all ports, so assume all ports are the same
3388 * NIC model and use the values from Port 0.
3390 ret = eth_dev_info_get_print_err(0, &dev_info);
3394 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3396 if (rec_nb_pkts == 0) {
3397 printf("PMD does not recommend a burst size.\n"
3398 "User provided value must be between"
3399 " 1 and %d\n", MAX_PKT_BURST);
3401 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3402 printf("PMD recommended burst size of %d"
3403 " exceeds maximum value of %d\n",
3404 rec_nb_pkts, MAX_PKT_BURST);
3407 printf("Using PMD-provided burst value of %d\n",
3409 nb_pkt_per_burst = rec_nb_pkts;
3410 } else if (res->value > MAX_PKT_BURST) {
3411 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3415 nb_pkt_per_burst = res->value;
3417 fprintf(stderr, "Unknown parameter\n");
3423 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3426 cmdline_parse_token_string_t cmd_config_burst_port =
3427 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3428 cmdline_parse_token_string_t cmd_config_burst_keyword =
3429 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3430 cmdline_parse_token_string_t cmd_config_burst_all =
3431 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3432 cmdline_parse_token_string_t cmd_config_burst_name =
3433 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3434 cmdline_parse_token_num_t cmd_config_burst_value =
3435 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3437 cmdline_parse_inst_t cmd_config_burst = {
3438 .f = cmd_config_burst_parsed,
3440 .help_str = "port config all burst <value>",
3442 (void *)&cmd_config_burst_port,
3443 (void *)&cmd_config_burst_keyword,
3444 (void *)&cmd_config_burst_all,
3445 (void *)&cmd_config_burst_name,
3446 (void *)&cmd_config_burst_value,
3451 /* *** configure rx/tx queues *** */
3452 struct cmd_config_thresh {
3453 cmdline_fixed_string_t port;
3454 cmdline_fixed_string_t keyword;
3455 cmdline_fixed_string_t all;
3456 cmdline_fixed_string_t name;
3461 cmd_config_thresh_parsed(void *parsed_result,
3462 __rte_unused struct cmdline *cl,
3463 __rte_unused void *data)
3465 struct cmd_config_thresh *res = parsed_result;
3467 if (!all_ports_stopped()) {
3468 fprintf(stderr, "Please stop all ports first\n");
3472 if (!strcmp(res->name, "txpt"))
3473 tx_pthresh = res->value;
3474 else if(!strcmp(res->name, "txht"))
3475 tx_hthresh = res->value;
3476 else if(!strcmp(res->name, "txwt"))
3477 tx_wthresh = res->value;
3478 else if(!strcmp(res->name, "rxpt"))
3479 rx_pthresh = res->value;
3480 else if(!strcmp(res->name, "rxht"))
3481 rx_hthresh = res->value;
3482 else if(!strcmp(res->name, "rxwt"))
3483 rx_wthresh = res->value;
3485 fprintf(stderr, "Unknown parameter\n");
3491 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3494 cmdline_parse_token_string_t cmd_config_thresh_port =
3495 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3496 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3497 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3498 cmdline_parse_token_string_t cmd_config_thresh_all =
3499 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3500 cmdline_parse_token_string_t cmd_config_thresh_name =
3501 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3502 "txpt#txht#txwt#rxpt#rxht#rxwt");
3503 cmdline_parse_token_num_t cmd_config_thresh_value =
3504 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3506 cmdline_parse_inst_t cmd_config_thresh = {
3507 .f = cmd_config_thresh_parsed,
3509 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3511 (void *)&cmd_config_thresh_port,
3512 (void *)&cmd_config_thresh_keyword,
3513 (void *)&cmd_config_thresh_all,
3514 (void *)&cmd_config_thresh_name,
3515 (void *)&cmd_config_thresh_value,
3520 /* *** configure free/rs threshold *** */
3521 struct cmd_config_threshold {
3522 cmdline_fixed_string_t port;
3523 cmdline_fixed_string_t keyword;
3524 cmdline_fixed_string_t all;
3525 cmdline_fixed_string_t name;
3530 cmd_config_threshold_parsed(void *parsed_result,
3531 __rte_unused struct cmdline *cl,
3532 __rte_unused void *data)
3534 struct cmd_config_threshold *res = parsed_result;
3536 if (!all_ports_stopped()) {
3537 fprintf(stderr, "Please stop all ports first\n");
3541 if (!strcmp(res->name, "txfreet"))
3542 tx_free_thresh = res->value;
3543 else if (!strcmp(res->name, "txrst"))
3544 tx_rs_thresh = res->value;
3545 else if (!strcmp(res->name, "rxfreet"))
3546 rx_free_thresh = res->value;
3548 fprintf(stderr, "Unknown parameter\n");
3554 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3557 cmdline_parse_token_string_t cmd_config_threshold_port =
3558 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3559 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3560 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3562 cmdline_parse_token_string_t cmd_config_threshold_all =
3563 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3564 cmdline_parse_token_string_t cmd_config_threshold_name =
3565 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3566 "txfreet#txrst#rxfreet");
3567 cmdline_parse_token_num_t cmd_config_threshold_value =
3568 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3570 cmdline_parse_inst_t cmd_config_threshold = {
3571 .f = cmd_config_threshold_parsed,
3573 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3575 (void *)&cmd_config_threshold_port,
3576 (void *)&cmd_config_threshold_keyword,
3577 (void *)&cmd_config_threshold_all,
3578 (void *)&cmd_config_threshold_name,
3579 (void *)&cmd_config_threshold_value,
3585 struct cmd_stop_result {
3586 cmdline_fixed_string_t stop;
3589 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3590 __rte_unused struct cmdline *cl,
3591 __rte_unused void *data)
3593 stop_packet_forwarding();
3596 cmdline_parse_token_string_t cmd_stop_stop =
3597 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3599 cmdline_parse_inst_t cmd_stop = {
3600 .f = cmd_stop_parsed,
3602 .help_str = "stop: Stop packet forwarding",
3604 (void *)&cmd_stop_stop,
3609 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3612 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3613 unsigned int *parsed_items, int check_unique_values)
3615 unsigned int nb_item;
3623 * First parse all items in the list and store their value.
3628 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3630 if ((c >= '0') && (c <= '9')) {
3631 value = (unsigned int) (value * 10 + (c - '0'));
3636 fprintf(stderr, "character %c is not a decimal digit\n", c);
3640 fprintf(stderr, "No valid value before comma\n");
3643 if (nb_item < max_items) {
3644 parsed_items[nb_item] = value;
3650 if (nb_item >= max_items) {
3651 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3652 item_name, nb_item + 1, max_items);
3655 parsed_items[nb_item++] = value;
3656 if (! check_unique_values)
3660 * Then, check that all values in the list are differents.
3661 * No optimization here...
3663 for (i = 0; i < nb_item; i++) {
3664 for (j = i + 1; j < nb_item; j++) {
3665 if (parsed_items[j] == parsed_items[i]) {
3667 "duplicated %s %u at index %u and %u\n",
3668 item_name, parsed_items[i], i, j);
3676 struct cmd_set_list_result {
3677 cmdline_fixed_string_t cmd_keyword;
3678 cmdline_fixed_string_t list_name;
3679 cmdline_fixed_string_t list_of_items;
3682 static void cmd_set_list_parsed(void *parsed_result,
3683 __rte_unused struct cmdline *cl,
3684 __rte_unused void *data)
3686 struct cmd_set_list_result *res;
3688 unsigned int lcorelist[RTE_MAX_LCORE];
3689 unsigned int portlist[RTE_MAX_ETHPORTS];
3691 unsigned int nb_item;
3693 if (test_done == 0) {
3694 fprintf(stderr, "Please stop forwarding first\n");
3698 res = parsed_result;
3699 if (!strcmp(res->list_name, "corelist")) {
3700 nb_item = parse_item_list(res->list_of_items, "core",
3702 parsed_items.lcorelist, 1);
3704 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3709 if (!strcmp(res->list_name, "portlist")) {
3710 nb_item = parse_item_list(res->list_of_items, "port",
3712 parsed_items.portlist, 1);
3714 set_fwd_ports_list(parsed_items.portlist, nb_item);
3720 cmdline_parse_token_string_t cmd_set_list_keyword =
3721 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3723 cmdline_parse_token_string_t cmd_set_list_name =
3724 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3725 "corelist#portlist");
3726 cmdline_parse_token_string_t cmd_set_list_of_items =
3727 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3730 cmdline_parse_inst_t cmd_set_fwd_list = {
3731 .f = cmd_set_list_parsed,
3733 .help_str = "set corelist|portlist <list0[,list1]*>",
3735 (void *)&cmd_set_list_keyword,
3736 (void *)&cmd_set_list_name,
3737 (void *)&cmd_set_list_of_items,
3742 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3744 struct cmd_setmask_result {
3745 cmdline_fixed_string_t set;
3746 cmdline_fixed_string_t mask;
3750 static void cmd_set_mask_parsed(void *parsed_result,
3751 __rte_unused struct cmdline *cl,
3752 __rte_unused void *data)
3754 struct cmd_setmask_result *res = parsed_result;
3756 if (test_done == 0) {
3757 fprintf(stderr, "Please stop forwarding first\n");
3760 if (!strcmp(res->mask, "coremask")) {
3761 set_fwd_lcores_mask(res->hexavalue);
3763 } else if (!strcmp(res->mask, "portmask")) {
3764 set_fwd_ports_mask(res->hexavalue);
3769 cmdline_parse_token_string_t cmd_setmask_set =
3770 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3771 cmdline_parse_token_string_t cmd_setmask_mask =
3772 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3773 "coremask#portmask");
3774 cmdline_parse_token_num_t cmd_setmask_value =
3775 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3777 cmdline_parse_inst_t cmd_set_fwd_mask = {
3778 .f = cmd_set_mask_parsed,
3780 .help_str = "set coremask|portmask <hexadecimal value>",
3782 (void *)&cmd_setmask_set,
3783 (void *)&cmd_setmask_mask,
3784 (void *)&cmd_setmask_value,
3790 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3792 struct cmd_set_result {
3793 cmdline_fixed_string_t set;
3794 cmdline_fixed_string_t what;
3798 static void cmd_set_parsed(void *parsed_result,
3799 __rte_unused struct cmdline *cl,
3800 __rte_unused void *data)
3802 struct cmd_set_result *res = parsed_result;
3803 if (!strcmp(res->what, "nbport")) {
3804 set_fwd_ports_number(res->value);
3806 } else if (!strcmp(res->what, "nbcore")) {
3807 set_fwd_lcores_number(res->value);
3809 } else if (!strcmp(res->what, "burst"))
3810 set_nb_pkt_per_burst(res->value);
3811 else if (!strcmp(res->what, "verbose"))
3812 set_verbose_level(res->value);
3815 cmdline_parse_token_string_t cmd_set_set =
3816 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3817 cmdline_parse_token_string_t cmd_set_what =
3818 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3819 "nbport#nbcore#burst#verbose");
3820 cmdline_parse_token_num_t cmd_set_value =
3821 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3823 cmdline_parse_inst_t cmd_set_numbers = {
3824 .f = cmd_set_parsed,
3826 .help_str = "set nbport|nbcore|burst|verbose <value>",
3828 (void *)&cmd_set_set,
3829 (void *)&cmd_set_what,
3830 (void *)&cmd_set_value,
3835 /* *** SET LOG LEVEL CONFIGURATION *** */
3837 struct cmd_set_log_result {
3838 cmdline_fixed_string_t set;
3839 cmdline_fixed_string_t log;
3840 cmdline_fixed_string_t type;
3845 cmd_set_log_parsed(void *parsed_result,
3846 __rte_unused struct cmdline *cl,
3847 __rte_unused void *data)
3849 struct cmd_set_log_result *res;
3852 res = parsed_result;
3853 if (!strcmp(res->type, "global"))
3854 rte_log_set_global_level(res->level);
3856 ret = rte_log_set_level_regexp(res->type, res->level);
3858 fprintf(stderr, "Unable to set log level\n");
3862 cmdline_parse_token_string_t cmd_set_log_set =
3863 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3864 cmdline_parse_token_string_t cmd_set_log_log =
3865 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3866 cmdline_parse_token_string_t cmd_set_log_type =
3867 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3868 cmdline_parse_token_num_t cmd_set_log_level =
3869 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3871 cmdline_parse_inst_t cmd_set_log = {
3872 .f = cmd_set_log_parsed,
3874 .help_str = "set log global|<type> <level>",
3876 (void *)&cmd_set_log_set,
3877 (void *)&cmd_set_log_log,
3878 (void *)&cmd_set_log_type,
3879 (void *)&cmd_set_log_level,
3884 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3886 struct cmd_set_rxoffs_result {
3887 cmdline_fixed_string_t cmd_keyword;
3888 cmdline_fixed_string_t rxoffs;
3889 cmdline_fixed_string_t seg_offsets;
3893 cmd_set_rxoffs_parsed(void *parsed_result,
3894 __rte_unused struct cmdline *cl,
3895 __rte_unused void *data)
3897 struct cmd_set_rxoffs_result *res;
3898 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3899 unsigned int nb_segs;
3901 res = parsed_result;
3902 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3903 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3905 set_rx_pkt_offsets(seg_offsets, nb_segs);
3906 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3909 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3910 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3911 cmd_keyword, "set");
3912 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3913 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3915 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3916 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3919 cmdline_parse_inst_t cmd_set_rxoffs = {
3920 .f = cmd_set_rxoffs_parsed,
3922 .help_str = "set rxoffs <len0[,len1]*>",
3924 (void *)&cmd_set_rxoffs_keyword,
3925 (void *)&cmd_set_rxoffs_name,
3926 (void *)&cmd_set_rxoffs_offsets,
3931 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3933 struct cmd_set_rxpkts_result {
3934 cmdline_fixed_string_t cmd_keyword;
3935 cmdline_fixed_string_t rxpkts;
3936 cmdline_fixed_string_t seg_lengths;
3940 cmd_set_rxpkts_parsed(void *parsed_result,
3941 __rte_unused struct cmdline *cl,
3942 __rte_unused void *data)
3944 struct cmd_set_rxpkts_result *res;
3945 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3946 unsigned int nb_segs;
3948 res = parsed_result;
3949 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3950 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3952 set_rx_pkt_segments(seg_lengths, nb_segs);
3953 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3956 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3957 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3958 cmd_keyword, "set");
3959 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3960 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3962 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3963 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3966 cmdline_parse_inst_t cmd_set_rxpkts = {
3967 .f = cmd_set_rxpkts_parsed,
3969 .help_str = "set rxpkts <len0[,len1]*>",
3971 (void *)&cmd_set_rxpkts_keyword,
3972 (void *)&cmd_set_rxpkts_name,
3973 (void *)&cmd_set_rxpkts_lengths,
3978 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3980 struct cmd_set_txpkts_result {
3981 cmdline_fixed_string_t cmd_keyword;
3982 cmdline_fixed_string_t txpkts;
3983 cmdline_fixed_string_t seg_lengths;
3987 cmd_set_txpkts_parsed(void *parsed_result,
3988 __rte_unused struct cmdline *cl,
3989 __rte_unused void *data)
3991 struct cmd_set_txpkts_result *res;
3992 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3993 unsigned int nb_segs;
3995 res = parsed_result;
3996 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3997 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3999 set_tx_pkt_segments(seg_lengths, nb_segs);
4002 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4003 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4004 cmd_keyword, "set");
4005 cmdline_parse_token_string_t cmd_set_txpkts_name =
4006 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4008 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4009 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4012 cmdline_parse_inst_t cmd_set_txpkts = {
4013 .f = cmd_set_txpkts_parsed,
4015 .help_str = "set txpkts <len0[,len1]*>",
4017 (void *)&cmd_set_txpkts_keyword,
4018 (void *)&cmd_set_txpkts_name,
4019 (void *)&cmd_set_txpkts_lengths,
4024 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4026 struct cmd_set_txsplit_result {
4027 cmdline_fixed_string_t cmd_keyword;
4028 cmdline_fixed_string_t txsplit;
4029 cmdline_fixed_string_t mode;
4033 cmd_set_txsplit_parsed(void *parsed_result,
4034 __rte_unused struct cmdline *cl,
4035 __rte_unused void *data)
4037 struct cmd_set_txsplit_result *res;
4039 res = parsed_result;
4040 set_tx_pkt_split(res->mode);
4043 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4044 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4045 cmd_keyword, "set");
4046 cmdline_parse_token_string_t cmd_set_txsplit_name =
4047 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4048 txsplit, "txsplit");
4049 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4050 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4053 cmdline_parse_inst_t cmd_set_txsplit = {
4054 .f = cmd_set_txsplit_parsed,
4056 .help_str = "set txsplit on|off|rand",
4058 (void *)&cmd_set_txsplit_keyword,
4059 (void *)&cmd_set_txsplit_name,
4060 (void *)&cmd_set_txsplit_mode,
4065 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4067 struct cmd_set_txtimes_result {
4068 cmdline_fixed_string_t cmd_keyword;
4069 cmdline_fixed_string_t txtimes;
4070 cmdline_fixed_string_t tx_times;
4074 cmd_set_txtimes_parsed(void *parsed_result,
4075 __rte_unused struct cmdline *cl,
4076 __rte_unused void *data)
4078 struct cmd_set_txtimes_result *res;
4079 unsigned int tx_times[2] = {0, 0};
4080 unsigned int n_times;
4082 res = parsed_result;
4083 n_times = parse_item_list(res->tx_times, "tx times",
4086 set_tx_pkt_times(tx_times);
4089 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4090 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4091 cmd_keyword, "set");
4092 cmdline_parse_token_string_t cmd_set_txtimes_name =
4093 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4094 txtimes, "txtimes");
4095 cmdline_parse_token_string_t cmd_set_txtimes_value =
4096 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4099 cmdline_parse_inst_t cmd_set_txtimes = {
4100 .f = cmd_set_txtimes_parsed,
4102 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4104 (void *)&cmd_set_txtimes_keyword,
4105 (void *)&cmd_set_txtimes_name,
4106 (void *)&cmd_set_txtimes_value,
4111 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4112 struct cmd_rx_vlan_filter_all_result {
4113 cmdline_fixed_string_t rx_vlan;
4114 cmdline_fixed_string_t what;
4115 cmdline_fixed_string_t all;
4120 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4121 __rte_unused struct cmdline *cl,
4122 __rte_unused void *data)
4124 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4126 if (!strcmp(res->what, "add"))
4127 rx_vlan_all_filter_set(res->port_id, 1);
4129 rx_vlan_all_filter_set(res->port_id, 0);
4132 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4133 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4134 rx_vlan, "rx_vlan");
4135 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4136 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4138 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4139 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4141 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4142 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4143 port_id, RTE_UINT16);
4145 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4146 .f = cmd_rx_vlan_filter_all_parsed,
4148 .help_str = "rx_vlan add|rm all <port_id>: "
4149 "Add/Remove all identifiers to/from the set of VLAN "
4150 "identifiers filtered by a port",
4152 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4153 (void *)&cmd_rx_vlan_filter_all_what,
4154 (void *)&cmd_rx_vlan_filter_all_all,
4155 (void *)&cmd_rx_vlan_filter_all_portid,
4160 /* *** VLAN OFFLOAD SET ON A PORT *** */
4161 struct cmd_vlan_offload_result {
4162 cmdline_fixed_string_t vlan;
4163 cmdline_fixed_string_t set;
4164 cmdline_fixed_string_t vlan_type;
4165 cmdline_fixed_string_t what;
4166 cmdline_fixed_string_t on;
4167 cmdline_fixed_string_t port_id;
4171 cmd_vlan_offload_parsed(void *parsed_result,
4172 __rte_unused struct cmdline *cl,
4173 __rte_unused void *data)
4176 struct cmd_vlan_offload_result *res = parsed_result;
4179 portid_t port_id = 0;
4183 len = strnlen(str, STR_TOKEN_SIZE);
4185 /* Get port_id first */
4193 tmp = strtoul(str, NULL, 0);
4194 /* If port_id greater that what portid_t can represent, return */
4195 if(tmp >= RTE_MAX_ETHPORTS)
4197 port_id = (portid_t)tmp;
4199 if (!strcmp(res->on, "on"))
4204 if (!strcmp(res->what, "strip"))
4205 rx_vlan_strip_set(port_id, on);
4206 else if(!strcmp(res->what, "stripq")){
4207 uint16_t queue_id = 0;
4209 /* No queue_id, return */
4211 fprintf(stderr, "must specify (port,queue_id)\n");
4214 tmp = strtoul(str + i + 1, NULL, 0);
4215 /* If queue_id greater that what 16-bits can represent, return */
4219 queue_id = (uint16_t)tmp;
4220 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4222 else if (!strcmp(res->what, "filter"))
4223 rx_vlan_filter_set(port_id, on);
4224 else if (!strcmp(res->what, "qinq_strip"))
4225 rx_vlan_qinq_strip_set(port_id, on);
4227 vlan_extend_set(port_id, on);
4232 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4233 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4235 cmdline_parse_token_string_t cmd_vlan_offload_set =
4236 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4238 cmdline_parse_token_string_t cmd_vlan_offload_what =
4239 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4240 what, "strip#filter#qinq_strip#extend#stripq");
4241 cmdline_parse_token_string_t cmd_vlan_offload_on =
4242 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4244 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4245 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4248 cmdline_parse_inst_t cmd_vlan_offload = {
4249 .f = cmd_vlan_offload_parsed,
4251 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4252 "<port_id[,queue_id]>: "
4253 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4255 (void *)&cmd_vlan_offload_vlan,
4256 (void *)&cmd_vlan_offload_set,
4257 (void *)&cmd_vlan_offload_what,
4258 (void *)&cmd_vlan_offload_on,
4259 (void *)&cmd_vlan_offload_portid,
4264 /* *** VLAN TPID SET ON A PORT *** */
4265 struct cmd_vlan_tpid_result {
4266 cmdline_fixed_string_t vlan;
4267 cmdline_fixed_string_t set;
4268 cmdline_fixed_string_t vlan_type;
4269 cmdline_fixed_string_t what;
4275 cmd_vlan_tpid_parsed(void *parsed_result,
4276 __rte_unused struct cmdline *cl,
4277 __rte_unused void *data)
4279 struct cmd_vlan_tpid_result *res = parsed_result;
4280 enum rte_vlan_type vlan_type;
4282 if (!strcmp(res->vlan_type, "inner"))
4283 vlan_type = ETH_VLAN_TYPE_INNER;
4284 else if (!strcmp(res->vlan_type, "outer"))
4285 vlan_type = ETH_VLAN_TYPE_OUTER;
4287 fprintf(stderr, "Unknown vlan type\n");
4290 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4293 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4294 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4296 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4297 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4299 cmdline_parse_token_string_t cmd_vlan_type =
4300 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4301 vlan_type, "inner#outer");
4302 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4303 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4305 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4306 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4308 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4309 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4310 port_id, RTE_UINT16);
4312 cmdline_parse_inst_t cmd_vlan_tpid = {
4313 .f = cmd_vlan_tpid_parsed,
4315 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4316 "Set the VLAN Ether type",
4318 (void *)&cmd_vlan_tpid_vlan,
4319 (void *)&cmd_vlan_tpid_set,
4320 (void *)&cmd_vlan_type,
4321 (void *)&cmd_vlan_tpid_what,
4322 (void *)&cmd_vlan_tpid_tpid,
4323 (void *)&cmd_vlan_tpid_portid,
4328 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4329 struct cmd_rx_vlan_filter_result {
4330 cmdline_fixed_string_t rx_vlan;
4331 cmdline_fixed_string_t what;
4337 cmd_rx_vlan_filter_parsed(void *parsed_result,
4338 __rte_unused struct cmdline *cl,
4339 __rte_unused void *data)
4341 struct cmd_rx_vlan_filter_result *res = parsed_result;
4343 if (!strcmp(res->what, "add"))
4344 rx_vft_set(res->port_id, res->vlan_id, 1);
4346 rx_vft_set(res->port_id, res->vlan_id, 0);
4349 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4350 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4351 rx_vlan, "rx_vlan");
4352 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4353 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4355 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4356 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4357 vlan_id, RTE_UINT16);
4358 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4359 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4360 port_id, RTE_UINT16);
4362 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4363 .f = cmd_rx_vlan_filter_parsed,
4365 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4366 "Add/Remove a VLAN identifier to/from the set of VLAN "
4367 "identifiers filtered by a port",
4369 (void *)&cmd_rx_vlan_filter_rx_vlan,
4370 (void *)&cmd_rx_vlan_filter_what,
4371 (void *)&cmd_rx_vlan_filter_vlanid,
4372 (void *)&cmd_rx_vlan_filter_portid,
4377 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4378 struct cmd_tx_vlan_set_result {
4379 cmdline_fixed_string_t tx_vlan;
4380 cmdline_fixed_string_t set;
4386 cmd_tx_vlan_set_parsed(void *parsed_result,
4387 __rte_unused struct cmdline *cl,
4388 __rte_unused void *data)
4390 struct cmd_tx_vlan_set_result *res = parsed_result;
4392 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4395 if (!port_is_stopped(res->port_id)) {
4396 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4400 tx_vlan_set(res->port_id, res->vlan_id);
4402 cmd_reconfig_device_queue(res->port_id, 1, 1);
4405 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4406 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4407 tx_vlan, "tx_vlan");
4408 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4409 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4411 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4412 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4413 port_id, RTE_UINT16);
4414 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4415 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4416 vlan_id, RTE_UINT16);
4418 cmdline_parse_inst_t cmd_tx_vlan_set = {
4419 .f = cmd_tx_vlan_set_parsed,
4421 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4422 "Enable hardware insertion of a single VLAN header "
4423 "with a given TAG Identifier in packets sent on a port",
4425 (void *)&cmd_tx_vlan_set_tx_vlan,
4426 (void *)&cmd_tx_vlan_set_set,
4427 (void *)&cmd_tx_vlan_set_portid,
4428 (void *)&cmd_tx_vlan_set_vlanid,
4433 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4434 struct cmd_tx_vlan_set_qinq_result {
4435 cmdline_fixed_string_t tx_vlan;
4436 cmdline_fixed_string_t set;
4439 uint16_t vlan_id_outer;
4443 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4444 __rte_unused struct cmdline *cl,
4445 __rte_unused void *data)
4447 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4449 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4452 if (!port_is_stopped(res->port_id)) {
4453 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4457 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4459 cmd_reconfig_device_queue(res->port_id, 1, 1);
4462 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4463 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4464 tx_vlan, "tx_vlan");
4465 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4466 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4468 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4469 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4470 port_id, RTE_UINT16);
4471 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4472 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4473 vlan_id, RTE_UINT16);
4474 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4475 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4476 vlan_id_outer, RTE_UINT16);
4478 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4479 .f = cmd_tx_vlan_set_qinq_parsed,
4481 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4482 "Enable hardware insertion of double VLAN header "
4483 "with given TAG Identifiers in packets sent on a port",
4485 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4486 (void *)&cmd_tx_vlan_set_qinq_set,
4487 (void *)&cmd_tx_vlan_set_qinq_portid,
4488 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4489 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4494 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4495 struct cmd_tx_vlan_set_pvid_result {
4496 cmdline_fixed_string_t tx_vlan;
4497 cmdline_fixed_string_t set;
4498 cmdline_fixed_string_t pvid;
4501 cmdline_fixed_string_t mode;
4505 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4506 __rte_unused struct cmdline *cl,
4507 __rte_unused void *data)
4509 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4511 if (strcmp(res->mode, "on") == 0)
4512 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4514 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4517 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4518 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4519 tx_vlan, "tx_vlan");
4520 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4521 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4523 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4524 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4526 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4527 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4528 port_id, RTE_UINT16);
4529 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4530 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4531 vlan_id, RTE_UINT16);
4532 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4533 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4536 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4537 .f = cmd_tx_vlan_set_pvid_parsed,
4539 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4541 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4542 (void *)&cmd_tx_vlan_set_pvid_set,
4543 (void *)&cmd_tx_vlan_set_pvid_pvid,
4544 (void *)&cmd_tx_vlan_set_pvid_port_id,
4545 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4546 (void *)&cmd_tx_vlan_set_pvid_mode,
4551 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4552 struct cmd_tx_vlan_reset_result {
4553 cmdline_fixed_string_t tx_vlan;
4554 cmdline_fixed_string_t reset;
4559 cmd_tx_vlan_reset_parsed(void *parsed_result,
4560 __rte_unused struct cmdline *cl,
4561 __rte_unused void *data)
4563 struct cmd_tx_vlan_reset_result *res = parsed_result;
4565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4568 if (!port_is_stopped(res->port_id)) {
4569 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4573 tx_vlan_reset(res->port_id);
4575 cmd_reconfig_device_queue(res->port_id, 1, 1);
4578 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4579 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4580 tx_vlan, "tx_vlan");
4581 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4582 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4584 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4585 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4586 port_id, RTE_UINT16);
4588 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4589 .f = cmd_tx_vlan_reset_parsed,
4591 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4592 "VLAN header in packets sent on a port",
4594 (void *)&cmd_tx_vlan_reset_tx_vlan,
4595 (void *)&cmd_tx_vlan_reset_reset,
4596 (void *)&cmd_tx_vlan_reset_portid,
4602 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4603 struct cmd_csum_result {
4604 cmdline_fixed_string_t csum;
4605 cmdline_fixed_string_t mode;
4606 cmdline_fixed_string_t proto;
4607 cmdline_fixed_string_t hwsw;
4612 csum_show(int port_id)
4614 struct rte_eth_dev_info dev_info;
4615 uint64_t tx_offloads;
4618 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4619 printf("Parse tunnel is %s\n",
4620 (ports[port_id].parse_tunnel) ? "on" : "off");
4621 printf("IP checksum offload is %s\n",
4622 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4623 printf("UDP checksum offload is %s\n",
4624 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4625 printf("TCP checksum offload is %s\n",
4626 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4627 printf("SCTP checksum offload is %s\n",
4628 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4629 printf("Outer-Ip checksum offload is %s\n",
4630 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4631 printf("Outer-Udp checksum offload is %s\n",
4632 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4634 /* display warnings if configuration is not supported by the NIC */
4635 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4639 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4640 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4642 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4645 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4646 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4648 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4651 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4652 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4654 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4657 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4658 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4660 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4663 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4664 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4666 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4669 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4670 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4673 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4679 cmd_config_queue_tx_offloads(struct rte_port *port)
4683 /* Apply queue tx offloads configuration */
4684 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4685 port->tx_conf[k].offloads =
4686 port->dev_conf.txmode.offloads;
4690 cmd_csum_parsed(void *parsed_result,
4691 __rte_unused struct cmdline *cl,
4692 __rte_unused void *data)
4694 struct cmd_csum_result *res = parsed_result;
4696 uint64_t csum_offloads = 0;
4697 struct rte_eth_dev_info dev_info;
4700 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4701 fprintf(stderr, "invalid port %d\n", res->port_id);
4704 if (!port_is_stopped(res->port_id)) {
4705 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4709 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4713 if (!strcmp(res->mode, "set")) {
4715 if (!strcmp(res->hwsw, "hw"))
4718 if (!strcmp(res->proto, "ip")) {
4719 if (hw == 0 || (dev_info.tx_offload_capa &
4720 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4721 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4724 "IP checksum offload is not supported by port %u\n",
4727 } else if (!strcmp(res->proto, "udp")) {
4728 if (hw == 0 || (dev_info.tx_offload_capa &
4729 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4730 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4733 "UDP checksum offload is not supported by port %u\n",
4736 } else if (!strcmp(res->proto, "tcp")) {
4737 if (hw == 0 || (dev_info.tx_offload_capa &
4738 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4739 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4742 "TCP checksum offload is not supported by port %u\n",
4745 } else if (!strcmp(res->proto, "sctp")) {
4746 if (hw == 0 || (dev_info.tx_offload_capa &
4747 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4748 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4751 "SCTP checksum offload is not supported by port %u\n",
4754 } else if (!strcmp(res->proto, "outer-ip")) {
4755 if (hw == 0 || (dev_info.tx_offload_capa &
4756 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4758 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4761 "Outer IP checksum offload is not supported by port %u\n",
4764 } else if (!strcmp(res->proto, "outer-udp")) {
4765 if (hw == 0 || (dev_info.tx_offload_capa &
4766 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4768 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4771 "Outer UDP checksum offload is not supported by port %u\n",
4777 ports[res->port_id].dev_conf.txmode.offloads |=
4780 ports[res->port_id].dev_conf.txmode.offloads &=
4783 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4785 csum_show(res->port_id);
4787 cmd_reconfig_device_queue(res->port_id, 1, 1);
4790 cmdline_parse_token_string_t cmd_csum_csum =
4791 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4793 cmdline_parse_token_string_t cmd_csum_mode =
4794 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4796 cmdline_parse_token_string_t cmd_csum_proto =
4797 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4798 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4799 cmdline_parse_token_string_t cmd_csum_hwsw =
4800 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4802 cmdline_parse_token_num_t cmd_csum_portid =
4803 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4804 port_id, RTE_UINT16);
4806 cmdline_parse_inst_t cmd_csum_set = {
4807 .f = cmd_csum_parsed,
4809 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4810 "Enable/Disable hardware calculation of L3/L4 checksum when "
4811 "using csum forward engine",
4813 (void *)&cmd_csum_csum,
4814 (void *)&cmd_csum_mode,
4815 (void *)&cmd_csum_proto,
4816 (void *)&cmd_csum_hwsw,
4817 (void *)&cmd_csum_portid,
4822 cmdline_parse_token_string_t cmd_csum_mode_show =
4823 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4826 cmdline_parse_inst_t cmd_csum_show = {
4827 .f = cmd_csum_parsed,
4829 .help_str = "csum show <port_id>: Show checksum offload configuration",
4831 (void *)&cmd_csum_csum,
4832 (void *)&cmd_csum_mode_show,
4833 (void *)&cmd_csum_portid,
4838 /* Enable/disable tunnel parsing */
4839 struct cmd_csum_tunnel_result {
4840 cmdline_fixed_string_t csum;
4841 cmdline_fixed_string_t parse;
4842 cmdline_fixed_string_t onoff;
4847 cmd_csum_tunnel_parsed(void *parsed_result,
4848 __rte_unused struct cmdline *cl,
4849 __rte_unused void *data)
4851 struct cmd_csum_tunnel_result *res = parsed_result;
4853 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4856 if (!strcmp(res->onoff, "on"))
4857 ports[res->port_id].parse_tunnel = 1;
4859 ports[res->port_id].parse_tunnel = 0;
4861 csum_show(res->port_id);
4864 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4865 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4867 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4868 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4869 parse, "parse-tunnel");
4870 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4871 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4873 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4874 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4875 port_id, RTE_UINT16);
4877 cmdline_parse_inst_t cmd_csum_tunnel = {
4878 .f = cmd_csum_tunnel_parsed,
4880 .help_str = "csum parse-tunnel on|off <port_id>: "
4881 "Enable/Disable parsing of tunnels for csum engine",
4883 (void *)&cmd_csum_tunnel_csum,
4884 (void *)&cmd_csum_tunnel_parse,
4885 (void *)&cmd_csum_tunnel_onoff,
4886 (void *)&cmd_csum_tunnel_portid,
4891 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4892 struct cmd_tso_set_result {
4893 cmdline_fixed_string_t tso;
4894 cmdline_fixed_string_t mode;
4900 cmd_tso_set_parsed(void *parsed_result,
4901 __rte_unused struct cmdline *cl,
4902 __rte_unused void *data)
4904 struct cmd_tso_set_result *res = parsed_result;
4905 struct rte_eth_dev_info dev_info;
4908 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4910 if (!port_is_stopped(res->port_id)) {
4911 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4915 if (!strcmp(res->mode, "set"))
4916 ports[res->port_id].tso_segsz = res->tso_segsz;
4918 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4922 if ((ports[res->port_id].tso_segsz != 0) &&
4923 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4924 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4929 if (ports[res->port_id].tso_segsz == 0) {
4930 ports[res->port_id].dev_conf.txmode.offloads &=
4931 ~DEV_TX_OFFLOAD_TCP_TSO;
4932 printf("TSO for non-tunneled packets is disabled\n");
4934 ports[res->port_id].dev_conf.txmode.offloads |=
4935 DEV_TX_OFFLOAD_TCP_TSO;
4936 printf("TSO segment size for non-tunneled packets is %d\n",
4937 ports[res->port_id].tso_segsz);
4939 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4941 /* display warnings if configuration is not supported by the NIC */
4942 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4946 if ((ports[res->port_id].tso_segsz != 0) &&
4947 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4949 "Warning: TSO enabled but not supported by port %d\n",
4953 cmd_reconfig_device_queue(res->port_id, 1, 1);
4956 cmdline_parse_token_string_t cmd_tso_set_tso =
4957 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4959 cmdline_parse_token_string_t cmd_tso_set_mode =
4960 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4962 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4963 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4964 tso_segsz, RTE_UINT16);
4965 cmdline_parse_token_num_t cmd_tso_set_portid =
4966 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4967 port_id, RTE_UINT16);
4969 cmdline_parse_inst_t cmd_tso_set = {
4970 .f = cmd_tso_set_parsed,
4972 .help_str = "tso set <tso_segsz> <port_id>: "
4973 "Set TSO segment size of non-tunneled packets for csum engine "
4976 (void *)&cmd_tso_set_tso,
4977 (void *)&cmd_tso_set_mode,
4978 (void *)&cmd_tso_set_tso_segsz,
4979 (void *)&cmd_tso_set_portid,
4984 cmdline_parse_token_string_t cmd_tso_show_mode =
4985 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4989 cmdline_parse_inst_t cmd_tso_show = {
4990 .f = cmd_tso_set_parsed,
4992 .help_str = "tso show <port_id>: "
4993 "Show TSO segment size of non-tunneled packets for csum engine",
4995 (void *)&cmd_tso_set_tso,
4996 (void *)&cmd_tso_show_mode,
4997 (void *)&cmd_tso_set_portid,
5002 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5003 struct cmd_tunnel_tso_set_result {
5004 cmdline_fixed_string_t tso;
5005 cmdline_fixed_string_t mode;
5010 static struct rte_eth_dev_info
5011 check_tunnel_tso_nic_support(portid_t port_id)
5013 struct rte_eth_dev_info dev_info;
5015 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5018 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5020 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5022 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5024 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5026 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5028 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5030 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5032 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5034 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5036 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5038 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5040 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5046 cmd_tunnel_tso_set_parsed(void *parsed_result,
5047 __rte_unused struct cmdline *cl,
5048 __rte_unused void *data)
5050 struct cmd_tunnel_tso_set_result *res = parsed_result;
5051 struct rte_eth_dev_info dev_info;
5053 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5055 if (!port_is_stopped(res->port_id)) {
5056 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5060 if (!strcmp(res->mode, "set"))
5061 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5063 dev_info = check_tunnel_tso_nic_support(res->port_id);
5064 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5065 ports[res->port_id].dev_conf.txmode.offloads &=
5066 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5067 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5068 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5069 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5070 DEV_TX_OFFLOAD_IP_TNL_TSO |
5071 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5072 printf("TSO for tunneled packets is disabled\n");
5074 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5075 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5076 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5077 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5078 DEV_TX_OFFLOAD_IP_TNL_TSO |
5079 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5081 ports[res->port_id].dev_conf.txmode.offloads |=
5082 (tso_offloads & dev_info.tx_offload_capa);
5083 printf("TSO segment size for tunneled packets is %d\n",
5084 ports[res->port_id].tunnel_tso_segsz);
5086 /* Below conditions are needed to make it work:
5087 * (1) tunnel TSO is supported by the NIC;
5088 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5090 * (3) for tunneled pkts with outer L3 of IPv4,
5091 * "csum set outer-ip" must be set to hw, because after tso,
5092 * total_len of outer IP header is changed, and the checksum
5093 * of outer IP header calculated by sw should be wrong; that
5094 * is not necessary for IPv6 tunneled pkts because there's no
5095 * checksum in IP header anymore.
5098 if (!ports[res->port_id].parse_tunnel)
5100 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5101 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5102 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5104 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5107 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5108 cmd_reconfig_device_queue(res->port_id, 1, 1);
5111 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5112 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5114 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5115 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5117 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5118 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5119 tso_segsz, RTE_UINT16);
5120 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5121 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5122 port_id, RTE_UINT16);
5124 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5125 .f = cmd_tunnel_tso_set_parsed,
5127 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5128 "Set TSO segment size of tunneled packets for csum engine "
5131 (void *)&cmd_tunnel_tso_set_tso,
5132 (void *)&cmd_tunnel_tso_set_mode,
5133 (void *)&cmd_tunnel_tso_set_tso_segsz,
5134 (void *)&cmd_tunnel_tso_set_portid,
5139 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5140 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5144 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5145 .f = cmd_tunnel_tso_set_parsed,
5147 .help_str = "tunnel_tso show <port_id> "
5148 "Show TSO segment size of tunneled packets for csum engine",
5150 (void *)&cmd_tunnel_tso_set_tso,
5151 (void *)&cmd_tunnel_tso_show_mode,
5152 (void *)&cmd_tunnel_tso_set_portid,
5157 /* *** SET GRO FOR A PORT *** */
5158 struct cmd_gro_enable_result {
5159 cmdline_fixed_string_t cmd_set;
5160 cmdline_fixed_string_t cmd_port;
5161 cmdline_fixed_string_t cmd_keyword;
5162 cmdline_fixed_string_t cmd_onoff;
5167 cmd_gro_enable_parsed(void *parsed_result,
5168 __rte_unused struct cmdline *cl,
5169 __rte_unused void *data)
5171 struct cmd_gro_enable_result *res;
5173 res = parsed_result;
5174 if (!strcmp(res->cmd_keyword, "gro"))
5175 setup_gro(res->cmd_onoff, res->cmd_pid);
5178 cmdline_parse_token_string_t cmd_gro_enable_set =
5179 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5181 cmdline_parse_token_string_t cmd_gro_enable_port =
5182 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5183 cmd_keyword, "port");
5184 cmdline_parse_token_num_t cmd_gro_enable_pid =
5185 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5186 cmd_pid, RTE_UINT16);
5187 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5188 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5189 cmd_keyword, "gro");
5190 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5191 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5192 cmd_onoff, "on#off");
5194 cmdline_parse_inst_t cmd_gro_enable = {
5195 .f = cmd_gro_enable_parsed,
5197 .help_str = "set port <port_id> gro on|off",
5199 (void *)&cmd_gro_enable_set,
5200 (void *)&cmd_gro_enable_port,
5201 (void *)&cmd_gro_enable_pid,
5202 (void *)&cmd_gro_enable_keyword,
5203 (void *)&cmd_gro_enable_onoff,
5208 /* *** DISPLAY GRO CONFIGURATION *** */
5209 struct cmd_gro_show_result {
5210 cmdline_fixed_string_t cmd_show;
5211 cmdline_fixed_string_t cmd_port;
5212 cmdline_fixed_string_t cmd_keyword;
5217 cmd_gro_show_parsed(void *parsed_result,
5218 __rte_unused struct cmdline *cl,
5219 __rte_unused void *data)
5221 struct cmd_gro_show_result *res;
5223 res = parsed_result;
5224 if (!strcmp(res->cmd_keyword, "gro"))
5225 show_gro(res->cmd_pid);
5228 cmdline_parse_token_string_t cmd_gro_show_show =
5229 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5231 cmdline_parse_token_string_t cmd_gro_show_port =
5232 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5234 cmdline_parse_token_num_t cmd_gro_show_pid =
5235 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5236 cmd_pid, RTE_UINT16);
5237 cmdline_parse_token_string_t cmd_gro_show_keyword =
5238 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5239 cmd_keyword, "gro");
5241 cmdline_parse_inst_t cmd_gro_show = {
5242 .f = cmd_gro_show_parsed,
5244 .help_str = "show port <port_id> gro",
5246 (void *)&cmd_gro_show_show,
5247 (void *)&cmd_gro_show_port,
5248 (void *)&cmd_gro_show_pid,
5249 (void *)&cmd_gro_show_keyword,
5254 /* *** SET FLUSH CYCLES FOR GRO *** */
5255 struct cmd_gro_flush_result {
5256 cmdline_fixed_string_t cmd_set;
5257 cmdline_fixed_string_t cmd_keyword;
5258 cmdline_fixed_string_t cmd_flush;
5263 cmd_gro_flush_parsed(void *parsed_result,
5264 __rte_unused struct cmdline *cl,
5265 __rte_unused void *data)
5267 struct cmd_gro_flush_result *res;
5269 res = parsed_result;
5270 if ((!strcmp(res->cmd_keyword, "gro")) &&
5271 (!strcmp(res->cmd_flush, "flush")))
5272 setup_gro_flush_cycles(res->cmd_cycles);
5275 cmdline_parse_token_string_t cmd_gro_flush_set =
5276 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5278 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5279 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5280 cmd_keyword, "gro");
5281 cmdline_parse_token_string_t cmd_gro_flush_flush =
5282 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5283 cmd_flush, "flush");
5284 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5285 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5286 cmd_cycles, RTE_UINT8);
5288 cmdline_parse_inst_t cmd_gro_flush = {
5289 .f = cmd_gro_flush_parsed,
5291 .help_str = "set gro flush <cycles>",
5293 (void *)&cmd_gro_flush_set,
5294 (void *)&cmd_gro_flush_keyword,
5295 (void *)&cmd_gro_flush_flush,
5296 (void *)&cmd_gro_flush_cycles,
5301 /* *** ENABLE/DISABLE GSO *** */
5302 struct cmd_gso_enable_result {
5303 cmdline_fixed_string_t cmd_set;
5304 cmdline_fixed_string_t cmd_port;
5305 cmdline_fixed_string_t cmd_keyword;
5306 cmdline_fixed_string_t cmd_mode;
5311 cmd_gso_enable_parsed(void *parsed_result,
5312 __rte_unused struct cmdline *cl,
5313 __rte_unused void *data)
5315 struct cmd_gso_enable_result *res;
5317 res = parsed_result;
5318 if (!strcmp(res->cmd_keyword, "gso"))
5319 setup_gso(res->cmd_mode, res->cmd_pid);
5322 cmdline_parse_token_string_t cmd_gso_enable_set =
5323 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5325 cmdline_parse_token_string_t cmd_gso_enable_port =
5326 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5328 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5329 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5330 cmd_keyword, "gso");
5331 cmdline_parse_token_string_t cmd_gso_enable_mode =
5332 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5333 cmd_mode, "on#off");
5334 cmdline_parse_token_num_t cmd_gso_enable_pid =
5335 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5336 cmd_pid, RTE_UINT16);
5338 cmdline_parse_inst_t cmd_gso_enable = {
5339 .f = cmd_gso_enable_parsed,
5341 .help_str = "set port <port_id> gso on|off",
5343 (void *)&cmd_gso_enable_set,
5344 (void *)&cmd_gso_enable_port,
5345 (void *)&cmd_gso_enable_pid,
5346 (void *)&cmd_gso_enable_keyword,
5347 (void *)&cmd_gso_enable_mode,
5352 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5353 struct cmd_gso_size_result {
5354 cmdline_fixed_string_t cmd_set;
5355 cmdline_fixed_string_t cmd_keyword;
5356 cmdline_fixed_string_t cmd_segsz;
5361 cmd_gso_size_parsed(void *parsed_result,
5362 __rte_unused struct cmdline *cl,
5363 __rte_unused void *data)
5365 struct cmd_gso_size_result *res = parsed_result;
5367 if (test_done == 0) {
5369 "Before setting GSO segsz, please first stop forwarding\n");
5373 if (!strcmp(res->cmd_keyword, "gso") &&
5374 !strcmp(res->cmd_segsz, "segsz")) {
5375 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5377 "gso_size should be larger than %zu. Please input a legal value\n",
5378 RTE_GSO_SEG_SIZE_MIN);
5380 gso_max_segment_size = res->cmd_size;
5384 cmdline_parse_token_string_t cmd_gso_size_set =
5385 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5387 cmdline_parse_token_string_t cmd_gso_size_keyword =
5388 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5389 cmd_keyword, "gso");
5390 cmdline_parse_token_string_t cmd_gso_size_segsz =
5391 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5392 cmd_segsz, "segsz");
5393 cmdline_parse_token_num_t cmd_gso_size_size =
5394 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5395 cmd_size, RTE_UINT16);
5397 cmdline_parse_inst_t cmd_gso_size = {
5398 .f = cmd_gso_size_parsed,
5400 .help_str = "set gso segsz <length>",
5402 (void *)&cmd_gso_size_set,
5403 (void *)&cmd_gso_size_keyword,
5404 (void *)&cmd_gso_size_segsz,
5405 (void *)&cmd_gso_size_size,
5410 /* *** SHOW GSO CONFIGURATION *** */
5411 struct cmd_gso_show_result {
5412 cmdline_fixed_string_t cmd_show;
5413 cmdline_fixed_string_t cmd_port;
5414 cmdline_fixed_string_t cmd_keyword;
5419 cmd_gso_show_parsed(void *parsed_result,
5420 __rte_unused struct cmdline *cl,
5421 __rte_unused void *data)
5423 struct cmd_gso_show_result *res = parsed_result;
5425 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5426 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5429 if (!strcmp(res->cmd_keyword, "gso")) {
5430 if (gso_ports[res->cmd_pid].enable) {
5431 printf("Max GSO'd packet size: %uB\n"
5432 "Supported GSO types: TCP/IPv4, "
5433 "UDP/IPv4, VxLAN with inner "
5434 "TCP/IPv4 packet, GRE with inner "
5435 "TCP/IPv4 packet\n",
5436 gso_max_segment_size);
5438 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5442 cmdline_parse_token_string_t cmd_gso_show_show =
5443 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5445 cmdline_parse_token_string_t cmd_gso_show_port =
5446 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5448 cmdline_parse_token_string_t cmd_gso_show_keyword =
5449 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5450 cmd_keyword, "gso");
5451 cmdline_parse_token_num_t cmd_gso_show_pid =
5452 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5453 cmd_pid, RTE_UINT16);
5455 cmdline_parse_inst_t cmd_gso_show = {
5456 .f = cmd_gso_show_parsed,
5458 .help_str = "show port <port_id> gso",
5460 (void *)&cmd_gso_show_show,
5461 (void *)&cmd_gso_show_port,
5462 (void *)&cmd_gso_show_pid,
5463 (void *)&cmd_gso_show_keyword,
5468 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5469 struct cmd_set_flush_rx {
5470 cmdline_fixed_string_t set;
5471 cmdline_fixed_string_t flush_rx;
5472 cmdline_fixed_string_t mode;
5476 cmd_set_flush_rx_parsed(void *parsed_result,
5477 __rte_unused struct cmdline *cl,
5478 __rte_unused void *data)
5480 struct cmd_set_flush_rx *res = parsed_result;
5482 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5483 printf("multi-process doesn't support to flush Rx queues.\n");
5487 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5490 cmdline_parse_token_string_t cmd_setflushrx_set =
5491 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5493 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5494 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5495 flush_rx, "flush_rx");
5496 cmdline_parse_token_string_t cmd_setflushrx_mode =
5497 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5501 cmdline_parse_inst_t cmd_set_flush_rx = {
5502 .f = cmd_set_flush_rx_parsed,
5503 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5506 (void *)&cmd_setflushrx_set,
5507 (void *)&cmd_setflushrx_flush_rx,
5508 (void *)&cmd_setflushrx_mode,
5513 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5514 struct cmd_set_link_check {
5515 cmdline_fixed_string_t set;
5516 cmdline_fixed_string_t link_check;
5517 cmdline_fixed_string_t mode;
5521 cmd_set_link_check_parsed(void *parsed_result,
5522 __rte_unused struct cmdline *cl,
5523 __rte_unused void *data)
5525 struct cmd_set_link_check *res = parsed_result;
5526 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5529 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5530 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5532 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5533 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5534 link_check, "link_check");
5535 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5536 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5540 cmdline_parse_inst_t cmd_set_link_check = {
5541 .f = cmd_set_link_check_parsed,
5542 .help_str = "set link_check on|off: Enable/Disable link status check "
5543 "when starting/stopping a port",
5546 (void *)&cmd_setlinkcheck_set,
5547 (void *)&cmd_setlinkcheck_link_check,
5548 (void *)&cmd_setlinkcheck_mode,
5553 /* *** SET NIC BYPASS MODE *** */
5554 struct cmd_set_bypass_mode_result {
5555 cmdline_fixed_string_t set;
5556 cmdline_fixed_string_t bypass;
5557 cmdline_fixed_string_t mode;
5558 cmdline_fixed_string_t value;
5563 cmd_set_bypass_mode_parsed(void *parsed_result,
5564 __rte_unused struct cmdline *cl,
5565 __rte_unused void *data)
5567 struct cmd_set_bypass_mode_result *res = parsed_result;
5568 portid_t port_id = res->port_id;
5569 int32_t rc = -EINVAL;
5571 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5572 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5574 if (!strcmp(res->value, "bypass"))
5575 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5576 else if (!strcmp(res->value, "isolate"))
5577 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5579 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5581 /* Set the bypass mode for the relevant port. */
5582 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5585 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5589 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5590 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5592 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5593 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5595 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5596 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5598 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5599 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5600 value, "normal#bypass#isolate");
5601 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5602 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5603 port_id, RTE_UINT16);
5605 cmdline_parse_inst_t cmd_set_bypass_mode = {
5606 .f = cmd_set_bypass_mode_parsed,
5607 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5608 "Set the NIC bypass mode for port_id",
5611 (void *)&cmd_setbypass_mode_set,
5612 (void *)&cmd_setbypass_mode_bypass,
5613 (void *)&cmd_setbypass_mode_mode,
5614 (void *)&cmd_setbypass_mode_value,
5615 (void *)&cmd_setbypass_mode_port,
5620 /* *** SET NIC BYPASS EVENT *** */
5621 struct cmd_set_bypass_event_result {
5622 cmdline_fixed_string_t set;
5623 cmdline_fixed_string_t bypass;
5624 cmdline_fixed_string_t event;
5625 cmdline_fixed_string_t event_value;
5626 cmdline_fixed_string_t mode;
5627 cmdline_fixed_string_t mode_value;
5632 cmd_set_bypass_event_parsed(void *parsed_result,
5633 __rte_unused struct cmdline *cl,
5634 __rte_unused void *data)
5636 int32_t rc = -EINVAL;
5637 struct cmd_set_bypass_event_result *res = parsed_result;
5638 portid_t port_id = res->port_id;
5640 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5641 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5642 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5644 if (!strcmp(res->event_value, "timeout"))
5645 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5646 else if (!strcmp(res->event_value, "os_on"))
5647 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5648 else if (!strcmp(res->event_value, "os_off"))
5649 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5650 else if (!strcmp(res->event_value, "power_on"))
5651 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5652 else if (!strcmp(res->event_value, "power_off"))
5653 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5655 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5657 if (!strcmp(res->mode_value, "bypass"))
5658 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5659 else if (!strcmp(res->mode_value, "isolate"))
5660 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5662 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5664 /* Set the watchdog timeout. */
5665 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5668 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5669 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5674 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5675 bypass_timeout, port_id, rc);
5679 /* Set the bypass event to transition to bypass mode. */
5680 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5685 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5689 cmdline_parse_token_string_t cmd_setbypass_event_set =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5692 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5693 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5695 cmdline_parse_token_string_t cmd_setbypass_event_event =
5696 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5698 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5700 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5701 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5704 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5705 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5706 mode_value, "normal#bypass#isolate");
5707 cmdline_parse_token_num_t cmd_setbypass_event_port =
5708 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5709 port_id, RTE_UINT16);
5711 cmdline_parse_inst_t cmd_set_bypass_event = {
5712 .f = cmd_set_bypass_event_parsed,
5713 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5714 "power_off mode normal|bypass|isolate <port_id>: "
5715 "Set the NIC bypass event mode for port_id",
5718 (void *)&cmd_setbypass_event_set,
5719 (void *)&cmd_setbypass_event_bypass,
5720 (void *)&cmd_setbypass_event_event,
5721 (void *)&cmd_setbypass_event_event_value,
5722 (void *)&cmd_setbypass_event_mode,
5723 (void *)&cmd_setbypass_event_mode_value,
5724 (void *)&cmd_setbypass_event_port,
5730 /* *** SET NIC BYPASS TIMEOUT *** */
5731 struct cmd_set_bypass_timeout_result {
5732 cmdline_fixed_string_t set;
5733 cmdline_fixed_string_t bypass;
5734 cmdline_fixed_string_t timeout;
5735 cmdline_fixed_string_t value;
5739 cmd_set_bypass_timeout_parsed(void *parsed_result,
5740 __rte_unused struct cmdline *cl,
5741 __rte_unused void *data)
5743 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5745 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5746 if (!strcmp(res->value, "1.5"))
5747 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5748 else if (!strcmp(res->value, "2"))
5749 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5750 else if (!strcmp(res->value, "3"))
5751 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5752 else if (!strcmp(res->value, "4"))
5753 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5754 else if (!strcmp(res->value, "8"))
5755 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5756 else if (!strcmp(res->value, "16"))
5757 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5758 else if (!strcmp(res->value, "32"))
5759 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5761 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5765 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5766 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5768 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5769 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5771 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5772 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5773 timeout, "timeout");
5774 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5775 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5776 value, "0#1.5#2#3#4#8#16#32");
5778 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5779 .f = cmd_set_bypass_timeout_parsed,
5780 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5781 "Set the NIC bypass watchdog timeout in seconds",
5784 (void *)&cmd_setbypass_timeout_set,
5785 (void *)&cmd_setbypass_timeout_bypass,
5786 (void *)&cmd_setbypass_timeout_timeout,
5787 (void *)&cmd_setbypass_timeout_value,
5792 /* *** SHOW NIC BYPASS MODE *** */
5793 struct cmd_show_bypass_config_result {
5794 cmdline_fixed_string_t show;
5795 cmdline_fixed_string_t bypass;
5796 cmdline_fixed_string_t config;
5801 cmd_show_bypass_config_parsed(void *parsed_result,
5802 __rte_unused struct cmdline *cl,
5803 __rte_unused void *data)
5805 struct cmd_show_bypass_config_result *res = parsed_result;
5806 portid_t port_id = res->port_id;
5808 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5809 uint32_t event_mode;
5810 uint32_t bypass_mode;
5811 uint32_t timeout = bypass_timeout;
5814 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5815 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5816 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5817 {"UNKNOWN", "normal", "bypass", "isolate"};
5818 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5826 /* Display the bypass mode.*/
5827 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5828 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5833 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5834 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5836 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5839 /* Display the bypass timeout.*/
5840 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5841 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5843 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5845 /* Display the bypass events and associated modes. */
5846 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5848 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5850 "\tFailed to get bypass mode for event = %s\n",
5853 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5854 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5856 printf("\tbypass event: %-16s = %s\n", events[i],
5863 "\tFailed to get bypass configuration for port = %d\n",
5867 cmdline_parse_token_string_t cmd_showbypass_config_show =
5868 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5870 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5871 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5873 cmdline_parse_token_string_t cmd_showbypass_config_config =
5874 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5876 cmdline_parse_token_num_t cmd_showbypass_config_port =
5877 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5878 port_id, RTE_UINT16);
5880 cmdline_parse_inst_t cmd_show_bypass_config = {
5881 .f = cmd_show_bypass_config_parsed,
5882 .help_str = "show bypass config <port_id>: "
5883 "Show the NIC bypass config for port_id",
5886 (void *)&cmd_showbypass_config_show,
5887 (void *)&cmd_showbypass_config_bypass,
5888 (void *)&cmd_showbypass_config_config,
5889 (void *)&cmd_showbypass_config_port,
5895 /* *** SET BONDING MODE *** */
5896 struct cmd_set_bonding_mode_result {
5897 cmdline_fixed_string_t set;
5898 cmdline_fixed_string_t bonding;
5899 cmdline_fixed_string_t mode;
5904 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5905 __rte_unused struct cmdline *cl,
5906 __rte_unused void *data)
5908 struct cmd_set_bonding_mode_result *res = parsed_result;
5909 portid_t port_id = res->port_id;
5911 /* Set the bonding mode for the relevant port. */
5912 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5913 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5917 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5920 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5922 bonding, "bonding");
5923 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5926 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5927 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5929 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5930 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5931 port_id, RTE_UINT16);
5933 cmdline_parse_inst_t cmd_set_bonding_mode = {
5934 .f = cmd_set_bonding_mode_parsed,
5935 .help_str = "set bonding mode <mode_value> <port_id>: "
5936 "Set the bonding mode for port_id",
5939 (void *) &cmd_setbonding_mode_set,
5940 (void *) &cmd_setbonding_mode_bonding,
5941 (void *) &cmd_setbonding_mode_mode,
5942 (void *) &cmd_setbonding_mode_value,
5943 (void *) &cmd_setbonding_mode_port,
5948 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5949 struct cmd_set_bonding_lacp_dedicated_queues_result {
5950 cmdline_fixed_string_t set;
5951 cmdline_fixed_string_t bonding;
5952 cmdline_fixed_string_t lacp;
5953 cmdline_fixed_string_t dedicated_queues;
5955 cmdline_fixed_string_t mode;
5958 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5959 __rte_unused struct cmdline *cl,
5960 __rte_unused void *data)
5962 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5963 portid_t port_id = res->port_id;
5964 struct rte_port *port;
5966 port = &ports[port_id];
5968 /** Check if the port is not started **/
5969 if (port->port_status != RTE_PORT_STOPPED) {
5970 fprintf(stderr, "Please stop port %d first\n", port_id);
5974 if (!strcmp(res->mode, "enable")) {
5975 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5976 printf("Dedicate queues for LACP control packets"
5979 printf("Enabling dedicate queues for LACP control "
5980 "packets on port %d failed\n", port_id);
5981 } else if (!strcmp(res->mode, "disable")) {
5982 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5983 printf("Dedicated queues for LACP control packets "
5986 printf("Disabling dedicated queues for LACP control "
5987 "traffic on port %d failed\n", port_id);
5991 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5992 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5994 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5995 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5996 bonding, "bonding");
5997 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5998 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6000 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6001 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6002 dedicated_queues, "dedicated_queues");
6003 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6004 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6005 port_id, RTE_UINT16);
6006 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6007 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6008 mode, "enable#disable");
6010 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6011 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6012 .help_str = "set bonding lacp dedicated_queues <port_id> "
6014 "Enable/disable dedicated queues for LACP control traffic for port_id",
6017 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6018 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6019 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6020 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6021 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6022 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6027 /* *** SET BALANCE XMIT POLICY *** */
6028 struct cmd_set_bonding_balance_xmit_policy_result {
6029 cmdline_fixed_string_t set;
6030 cmdline_fixed_string_t bonding;
6031 cmdline_fixed_string_t balance_xmit_policy;
6033 cmdline_fixed_string_t policy;
6036 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6037 __rte_unused struct cmdline *cl,
6038 __rte_unused void *data)
6040 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6041 portid_t port_id = res->port_id;
6044 if (!strcmp(res->policy, "l2")) {
6045 policy = BALANCE_XMIT_POLICY_LAYER2;
6046 } else if (!strcmp(res->policy, "l23")) {
6047 policy = BALANCE_XMIT_POLICY_LAYER23;
6048 } else if (!strcmp(res->policy, "l34")) {
6049 policy = BALANCE_XMIT_POLICY_LAYER34;
6051 fprintf(stderr, "\t Invalid xmit policy selection");
6055 /* Set the bonding mode for the relevant port. */
6056 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6058 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6063 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6064 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6066 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6067 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6068 bonding, "bonding");
6069 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6070 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6071 balance_xmit_policy, "balance_xmit_policy");
6072 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6073 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6074 port_id, RTE_UINT16);
6075 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6076 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6077 policy, "l2#l23#l34");
6079 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6080 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6081 .help_str = "set bonding balance_xmit_policy <port_id> "
6083 "Set the bonding balance_xmit_policy for port_id",
6086 (void *)&cmd_setbonding_balance_xmit_policy_set,
6087 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6088 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6089 (void *)&cmd_setbonding_balance_xmit_policy_port,
6090 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6095 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6096 struct cmd_show_bonding_lacp_info_result {
6097 cmdline_fixed_string_t show;
6098 cmdline_fixed_string_t bonding;
6099 cmdline_fixed_string_t lacp;
6100 cmdline_fixed_string_t info;
6104 static void port_param_show(struct port_params *params)
6106 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6108 printf("\t\tsystem priority: %u\n", params->system_priority);
6109 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6110 printf("\t\tsystem mac address: %s\n", buf);
6111 printf("\t\tport key: %u\n", params->key);
6112 printf("\t\tport priority: %u\n", params->port_priority);
6113 printf("\t\tport number: %u\n", params->port_number);
6116 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6118 char a_state[256] = { 0 };
6119 char p_state[256] = { 0 };
6124 static const char * const state[] = {
6134 static const char * const selection[] = {
6140 for (i = 0; i < RTE_DIM(state); i++) {
6141 if ((info->actor_state >> i) & 1)
6142 a_len += snprintf(&a_state[a_len],
6143 RTE_DIM(a_state) - a_len, "%s ",
6146 if ((info->partner_state >> i) & 1)
6147 p_len += snprintf(&p_state[p_len],
6148 RTE_DIM(p_state) - p_len, "%s ",
6151 printf("\tAggregator port id: %u\n", info->agg_port_id);
6152 printf("\tselection: %s\n", selection[info->selected]);
6153 printf("\tActor detail info:\n");
6154 port_param_show(&info->actor);
6155 printf("\t\tport state: %s\n", a_state);
6156 printf("\tPartner detail info:\n");
6157 port_param_show(&info->partner);
6158 printf("\t\tport state: %s\n", p_state);
6162 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6164 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6165 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6166 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6167 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6168 printf("\taggregate wait timeout: %u ms\n",
6169 conf->aggregate_wait_timeout_ms);
6170 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6171 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6172 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6173 switch (conf->agg_selection) {
6175 printf("\taggregation mode: bandwidth\n");
6178 printf("\taggregation mode: stable\n");
6181 printf("\taggregation mode: count\n");
6184 printf("\taggregation mode: invalid\n");
6191 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6192 __rte_unused struct cmdline *cl,
6193 __rte_unused void *data)
6195 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6196 struct rte_eth_bond_8023ad_slave_info slave_info;
6197 struct rte_eth_bond_8023ad_conf port_conf;
6198 portid_t slaves[RTE_MAX_ETHPORTS];
6199 portid_t port_id = res->port_id;
6200 int num_active_slaves;
6205 bonding_mode = rte_eth_bond_mode_get(port_id);
6206 if (bonding_mode != BONDING_MODE_8023AD) {
6207 fprintf(stderr, "\tBonding mode is not mode 4\n");
6211 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6213 if (num_active_slaves < 0) {
6214 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6218 if (num_active_slaves == 0)
6219 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6222 printf("\tIEEE802.3 port: %u\n", port_id);
6223 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6225 fprintf(stderr, "\tGet bonded device %u info failed\n",
6229 lacp_conf_show(&port_conf);
6231 for (i = 0; i < num_active_slaves; i++) {
6232 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6235 fprintf(stderr, "\tGet slave device %u info failed\n",
6239 printf("\tSlave Port: %u\n", slaves[i]);
6240 lacp_slave_info_show(&slave_info);
6244 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6245 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6247 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6248 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6249 bonding, "bonding");
6250 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6251 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6253 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6254 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6256 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6257 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6258 port_id, RTE_UINT16);
6260 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6261 .f = cmd_show_bonding_lacp_info_parsed,
6262 .help_str = "show bonding lacp info <port_id> : "
6263 "Show bonding IEEE802.3 information for port_id",
6266 (void *)&cmd_show_bonding_lacp_info_show,
6267 (void *)&cmd_show_bonding_lacp_info_bonding,
6268 (void *)&cmd_show_bonding_lacp_info_lacp,
6269 (void *)&cmd_show_bonding_lacp_info_info,
6270 (void *)&cmd_show_bonding_lacp_info_port_id,
6275 /* *** SHOW NIC BONDING CONFIGURATION *** */
6276 struct cmd_show_bonding_config_result {
6277 cmdline_fixed_string_t show;
6278 cmdline_fixed_string_t bonding;
6279 cmdline_fixed_string_t config;
6283 static void cmd_show_bonding_config_parsed(void *parsed_result,
6284 __rte_unused struct cmdline *cl,
6285 __rte_unused void *data)
6287 struct cmd_show_bonding_config_result *res = parsed_result;
6288 int bonding_mode, agg_mode;
6289 portid_t slaves[RTE_MAX_ETHPORTS];
6290 int num_slaves, num_active_slaves;
6293 portid_t port_id = res->port_id;
6295 /* Display the bonding mode.*/
6296 bonding_mode = rte_eth_bond_mode_get(port_id);
6297 if (bonding_mode < 0) {
6298 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6302 printf("\tBonding mode: %d\n", bonding_mode);
6304 if (bonding_mode == BONDING_MODE_BALANCE) {
6305 int balance_xmit_policy;
6307 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6308 if (balance_xmit_policy < 0) {
6310 "\tFailed to get balance xmit policy for port = %d\n",
6314 printf("\tBalance Xmit Policy: ");
6316 switch (balance_xmit_policy) {
6317 case BALANCE_XMIT_POLICY_LAYER2:
6318 printf("BALANCE_XMIT_POLICY_LAYER2");
6320 case BALANCE_XMIT_POLICY_LAYER23:
6321 printf("BALANCE_XMIT_POLICY_LAYER23");
6323 case BALANCE_XMIT_POLICY_LAYER34:
6324 printf("BALANCE_XMIT_POLICY_LAYER34");
6331 if (bonding_mode == BONDING_MODE_8023AD) {
6332 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6333 printf("\tIEEE802.3AD Aggregator Mode: ");
6336 printf("bandwidth");
6348 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6350 if (num_slaves < 0) {
6351 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6355 if (num_slaves > 0) {
6356 printf("\tSlaves (%d): [", num_slaves);
6357 for (i = 0; i < num_slaves - 1; i++)
6358 printf("%d ", slaves[i]);
6360 printf("%d]\n", slaves[num_slaves - 1]);
6362 printf("\tSlaves: []\n");
6366 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6369 if (num_active_slaves < 0) {
6371 "\tFailed to get active slave list for port = %d\n",
6375 if (num_active_slaves > 0) {
6376 printf("\tActive Slaves (%d): [", num_active_slaves);
6377 for (i = 0; i < num_active_slaves - 1; i++)
6378 printf("%d ", slaves[i]);
6380 printf("%d]\n", slaves[num_active_slaves - 1]);
6383 printf("\tActive Slaves: []\n");
6387 primary_id = rte_eth_bond_primary_get(port_id);
6388 if (primary_id < 0) {
6389 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6393 printf("\tPrimary: [%d]\n", primary_id);
6397 cmdline_parse_token_string_t cmd_showbonding_config_show =
6398 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6400 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6401 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6402 bonding, "bonding");
6403 cmdline_parse_token_string_t cmd_showbonding_config_config =
6404 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6406 cmdline_parse_token_num_t cmd_showbonding_config_port =
6407 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6408 port_id, RTE_UINT16);
6410 cmdline_parse_inst_t cmd_show_bonding_config = {
6411 .f = cmd_show_bonding_config_parsed,
6412 .help_str = "show bonding config <port_id>: "
6413 "Show the bonding config for port_id",
6416 (void *)&cmd_showbonding_config_show,
6417 (void *)&cmd_showbonding_config_bonding,
6418 (void *)&cmd_showbonding_config_config,
6419 (void *)&cmd_showbonding_config_port,
6424 /* *** SET BONDING PRIMARY *** */
6425 struct cmd_set_bonding_primary_result {
6426 cmdline_fixed_string_t set;
6427 cmdline_fixed_string_t bonding;
6428 cmdline_fixed_string_t primary;
6433 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6434 __rte_unused struct cmdline *cl,
6435 __rte_unused void *data)
6437 struct cmd_set_bonding_primary_result *res = parsed_result;
6438 portid_t master_port_id = res->port_id;
6439 portid_t slave_port_id = res->slave_id;
6441 /* Set the primary slave for a bonded device. */
6442 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6443 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6450 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6451 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6453 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6454 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6455 bonding, "bonding");
6456 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6457 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6458 primary, "primary");
6459 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6460 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6461 slave_id, RTE_UINT16);
6462 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6463 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6464 port_id, RTE_UINT16);
6466 cmdline_parse_inst_t cmd_set_bonding_primary = {
6467 .f = cmd_set_bonding_primary_parsed,
6468 .help_str = "set bonding primary <slave_id> <port_id>: "
6469 "Set the primary slave for port_id",
6472 (void *)&cmd_setbonding_primary_set,
6473 (void *)&cmd_setbonding_primary_bonding,
6474 (void *)&cmd_setbonding_primary_primary,
6475 (void *)&cmd_setbonding_primary_slave,
6476 (void *)&cmd_setbonding_primary_port,
6481 /* *** ADD SLAVE *** */
6482 struct cmd_add_bonding_slave_result {
6483 cmdline_fixed_string_t add;
6484 cmdline_fixed_string_t bonding;
6485 cmdline_fixed_string_t slave;
6490 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6491 __rte_unused struct cmdline *cl,
6492 __rte_unused void *data)
6494 struct cmd_add_bonding_slave_result *res = parsed_result;
6495 portid_t master_port_id = res->port_id;
6496 portid_t slave_port_id = res->slave_id;
6498 /* add the slave for a bonded device. */
6499 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6501 "\t Failed to add slave %d to master port = %d.\n",
6502 slave_port_id, master_port_id);
6506 set_port_slave_flag(slave_port_id);
6509 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6510 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6512 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6513 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6514 bonding, "bonding");
6515 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6516 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6518 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6519 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6520 slave_id, RTE_UINT16);
6521 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6522 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6523 port_id, RTE_UINT16);
6525 cmdline_parse_inst_t cmd_add_bonding_slave = {
6526 .f = cmd_add_bonding_slave_parsed,
6527 .help_str = "add bonding slave <slave_id> <port_id>: "
6528 "Add a slave device to a bonded device",
6531 (void *)&cmd_addbonding_slave_add,
6532 (void *)&cmd_addbonding_slave_bonding,
6533 (void *)&cmd_addbonding_slave_slave,
6534 (void *)&cmd_addbonding_slave_slaveid,
6535 (void *)&cmd_addbonding_slave_port,
6540 /* *** REMOVE SLAVE *** */
6541 struct cmd_remove_bonding_slave_result {
6542 cmdline_fixed_string_t remove;
6543 cmdline_fixed_string_t bonding;
6544 cmdline_fixed_string_t slave;
6549 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6550 __rte_unused struct cmdline *cl,
6551 __rte_unused void *data)
6553 struct cmd_remove_bonding_slave_result *res = parsed_result;
6554 portid_t master_port_id = res->port_id;
6555 portid_t slave_port_id = res->slave_id;
6557 /* remove the slave from a bonded device. */
6558 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6560 "\t Failed to remove slave %d from master port = %d.\n",
6561 slave_port_id, master_port_id);
6565 clear_port_slave_flag(slave_port_id);
6568 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6569 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6571 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6572 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6573 bonding, "bonding");
6574 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6575 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6577 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6578 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6579 slave_id, RTE_UINT16);
6580 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6581 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6582 port_id, RTE_UINT16);
6584 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6585 .f = cmd_remove_bonding_slave_parsed,
6586 .help_str = "remove bonding slave <slave_id> <port_id>: "
6587 "Remove a slave device from a bonded device",
6590 (void *)&cmd_removebonding_slave_remove,
6591 (void *)&cmd_removebonding_slave_bonding,
6592 (void *)&cmd_removebonding_slave_slave,
6593 (void *)&cmd_removebonding_slave_slaveid,
6594 (void *)&cmd_removebonding_slave_port,
6599 /* *** CREATE BONDED DEVICE *** */
6600 struct cmd_create_bonded_device_result {
6601 cmdline_fixed_string_t create;
6602 cmdline_fixed_string_t bonded;
6603 cmdline_fixed_string_t device;
6608 static int bond_dev_num = 0;
6610 static void cmd_create_bonded_device_parsed(void *parsed_result,
6611 __rte_unused struct cmdline *cl,
6612 __rte_unused void *data)
6614 struct cmd_create_bonded_device_result *res = parsed_result;
6615 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6619 if (test_done == 0) {
6620 fprintf(stderr, "Please stop forwarding first\n");
6624 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6627 /* Create a new bonded device. */
6628 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6630 fprintf(stderr, "\t Failed to create bonded device.\n");
6633 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6636 /* Update number of ports */
6637 nb_ports = rte_eth_dev_count_avail();
6638 reconfig(port_id, res->socket);
6639 ret = rte_eth_promiscuous_enable(port_id);
6642 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6643 port_id, rte_strerror(-ret));
6645 ports[port_id].need_setup = 0;
6646 ports[port_id].port_status = RTE_PORT_STOPPED;
6651 cmdline_parse_token_string_t cmd_createbonded_device_create =
6652 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6654 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6655 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6657 cmdline_parse_token_string_t cmd_createbonded_device_device =
6658 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6660 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6661 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6663 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6664 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6667 cmdline_parse_inst_t cmd_create_bonded_device = {
6668 .f = cmd_create_bonded_device_parsed,
6669 .help_str = "create bonded device <mode> <socket>: "
6670 "Create a new bonded device with specific bonding mode and socket",
6673 (void *)&cmd_createbonded_device_create,
6674 (void *)&cmd_createbonded_device_bonded,
6675 (void *)&cmd_createbonded_device_device,
6676 (void *)&cmd_createbonded_device_mode,
6677 (void *)&cmd_createbonded_device_socket,
6682 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6683 struct cmd_set_bond_mac_addr_result {
6684 cmdline_fixed_string_t set;
6685 cmdline_fixed_string_t bonding;
6686 cmdline_fixed_string_t mac_addr;
6688 struct rte_ether_addr address;
6691 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6692 __rte_unused struct cmdline *cl,
6693 __rte_unused void *data)
6695 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6698 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6701 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6703 /* check the return value and print it if is < 0 */
6705 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6709 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6710 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6711 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6712 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6714 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6715 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6717 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6718 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6719 port_num, RTE_UINT16);
6720 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6721 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6723 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6724 .f = cmd_set_bond_mac_addr_parsed,
6726 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6728 (void *)&cmd_set_bond_mac_addr_set,
6729 (void *)&cmd_set_bond_mac_addr_bonding,
6730 (void *)&cmd_set_bond_mac_addr_mac,
6731 (void *)&cmd_set_bond_mac_addr_portnum,
6732 (void *)&cmd_set_bond_mac_addr_addr,
6738 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6739 struct cmd_set_bond_mon_period_result {
6740 cmdline_fixed_string_t set;
6741 cmdline_fixed_string_t bonding;
6742 cmdline_fixed_string_t mon_period;
6747 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6748 __rte_unused struct cmdline *cl,
6749 __rte_unused void *data)
6751 struct cmd_set_bond_mon_period_result *res = parsed_result;
6754 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6756 /* check the return value and print it if is < 0 */
6758 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6762 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6763 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6765 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6766 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6767 bonding, "bonding");
6768 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6769 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6770 mon_period, "mon_period");
6771 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6772 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6773 port_num, RTE_UINT16);
6774 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6775 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6776 period_ms, RTE_UINT32);
6778 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6779 .f = cmd_set_bond_mon_period_parsed,
6781 .help_str = "set bonding mon_period <port_id> <period_ms>",
6783 (void *)&cmd_set_bond_mon_period_set,
6784 (void *)&cmd_set_bond_mon_period_bonding,
6785 (void *)&cmd_set_bond_mon_period_mon_period,
6786 (void *)&cmd_set_bond_mon_period_portnum,
6787 (void *)&cmd_set_bond_mon_period_period_ms,
6794 struct cmd_set_bonding_agg_mode_policy_result {
6795 cmdline_fixed_string_t set;
6796 cmdline_fixed_string_t bonding;
6797 cmdline_fixed_string_t agg_mode;
6799 cmdline_fixed_string_t policy;
6804 cmd_set_bonding_agg_mode(void *parsed_result,
6805 __rte_unused struct cmdline *cl,
6806 __rte_unused void *data)
6808 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6809 uint8_t policy = AGG_BANDWIDTH;
6811 if (!strcmp(res->policy, "bandwidth"))
6812 policy = AGG_BANDWIDTH;
6813 else if (!strcmp(res->policy, "stable"))
6814 policy = AGG_STABLE;
6815 else if (!strcmp(res->policy, "count"))
6818 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6822 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6823 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6825 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6826 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6827 bonding, "bonding");
6829 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6830 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6831 agg_mode, "agg_mode");
6833 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6834 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6835 port_num, RTE_UINT16);
6837 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6838 TOKEN_STRING_INITIALIZER(
6839 struct cmd_set_bonding_balance_xmit_policy_result,
6840 policy, "stable#bandwidth#count");
6842 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6843 .f = cmd_set_bonding_agg_mode,
6845 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6847 (void *)&cmd_set_bonding_agg_mode_set,
6848 (void *)&cmd_set_bonding_agg_mode_bonding,
6849 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6850 (void *)&cmd_set_bonding_agg_mode_portnum,
6851 (void *)&cmd_set_bonding_agg_mode_policy_string,
6857 #endif /* RTE_NET_BOND */
6859 /* *** SET FORWARDING MODE *** */
6860 struct cmd_set_fwd_mode_result {
6861 cmdline_fixed_string_t set;
6862 cmdline_fixed_string_t fwd;
6863 cmdline_fixed_string_t mode;
6866 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6867 __rte_unused struct cmdline *cl,
6868 __rte_unused void *data)
6870 struct cmd_set_fwd_mode_result *res = parsed_result;
6873 set_pkt_forwarding_mode(res->mode);
6876 cmdline_parse_token_string_t cmd_setfwd_set =
6877 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6878 cmdline_parse_token_string_t cmd_setfwd_fwd =
6879 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6880 cmdline_parse_token_string_t cmd_setfwd_mode =
6881 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6882 "" /* defined at init */);
6884 cmdline_parse_inst_t cmd_set_fwd_mode = {
6885 .f = cmd_set_fwd_mode_parsed,
6887 .help_str = NULL, /* defined at init */
6889 (void *)&cmd_setfwd_set,
6890 (void *)&cmd_setfwd_fwd,
6891 (void *)&cmd_setfwd_mode,
6896 static void cmd_set_fwd_mode_init(void)
6899 static char token[128];
6900 static char help[256];
6901 cmdline_parse_token_string_t *token_struct;
6903 modes = list_pkt_forwarding_modes();
6904 snprintf(help, sizeof(help), "set fwd %s: "
6905 "Set packet forwarding mode", modes);
6906 cmd_set_fwd_mode.help_str = help;
6908 /* string token separator is # */
6909 for (c = token; *modes != '\0'; modes++)
6914 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6915 token_struct->string_data.str = token;
6918 /* *** SET RETRY FORWARDING MODE *** */
6919 struct cmd_set_fwd_retry_mode_result {
6920 cmdline_fixed_string_t set;
6921 cmdline_fixed_string_t fwd;
6922 cmdline_fixed_string_t mode;
6923 cmdline_fixed_string_t retry;
6926 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6927 __rte_unused struct cmdline *cl,
6928 __rte_unused void *data)
6930 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6933 set_pkt_forwarding_mode(res->mode);
6936 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6937 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6939 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6940 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6942 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6943 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6945 "" /* defined at init */);
6946 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6947 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6950 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6951 .f = cmd_set_fwd_retry_mode_parsed,
6953 .help_str = NULL, /* defined at init */
6955 (void *)&cmd_setfwd_retry_set,
6956 (void *)&cmd_setfwd_retry_fwd,
6957 (void *)&cmd_setfwd_retry_mode,
6958 (void *)&cmd_setfwd_retry_retry,
6963 static void cmd_set_fwd_retry_mode_init(void)
6966 static char token[128];
6967 static char help[256];
6968 cmdline_parse_token_string_t *token_struct;
6970 modes = list_pkt_forwarding_retry_modes();
6971 snprintf(help, sizeof(help), "set fwd %s retry: "
6972 "Set packet forwarding mode with retry", modes);
6973 cmd_set_fwd_retry_mode.help_str = help;
6975 /* string token separator is # */
6976 for (c = token; *modes != '\0'; modes++)
6981 token_struct = (cmdline_parse_token_string_t *)
6982 cmd_set_fwd_retry_mode.tokens[2];
6983 token_struct->string_data.str = token;
6986 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6987 struct cmd_set_burst_tx_retry_result {
6988 cmdline_fixed_string_t set;
6989 cmdline_fixed_string_t burst;
6990 cmdline_fixed_string_t tx;
6991 cmdline_fixed_string_t delay;
6993 cmdline_fixed_string_t retry;
6997 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6998 __rte_unused struct cmdline *cl,
6999 __rte_unused void *data)
7001 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7003 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7004 && !strcmp(res->tx, "tx")) {
7005 if (!strcmp(res->delay, "delay"))
7006 burst_tx_delay_time = res->time;
7007 if (!strcmp(res->retry, "retry"))
7008 burst_tx_retry_num = res->retry_num;
7013 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7014 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7015 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7016 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7018 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7019 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7020 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7021 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7022 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7023 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7025 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7026 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7027 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7028 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7031 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7032 .f = cmd_set_burst_tx_retry_parsed,
7033 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7035 (void *)&cmd_set_burst_tx_retry_set,
7036 (void *)&cmd_set_burst_tx_retry_burst,
7037 (void *)&cmd_set_burst_tx_retry_tx,
7038 (void *)&cmd_set_burst_tx_retry_delay,
7039 (void *)&cmd_set_burst_tx_retry_time,
7040 (void *)&cmd_set_burst_tx_retry_retry,
7041 (void *)&cmd_set_burst_tx_retry_retry_num,
7046 /* *** SET PROMISC MODE *** */
7047 struct cmd_set_promisc_mode_result {
7048 cmdline_fixed_string_t set;
7049 cmdline_fixed_string_t promisc;
7050 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7051 uint16_t port_num; /* valid if "allports" argument == 0 */
7052 cmdline_fixed_string_t mode;
7055 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7056 __rte_unused struct cmdline *cl,
7059 struct cmd_set_promisc_mode_result *res = parsed_result;
7063 if (!strcmp(res->mode, "on"))
7070 RTE_ETH_FOREACH_DEV(i)
7071 eth_set_promisc_mode(i, enable);
7073 eth_set_promisc_mode(res->port_num, enable);
7077 cmdline_parse_token_string_t cmd_setpromisc_set =
7078 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7079 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7080 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7082 cmdline_parse_token_string_t cmd_setpromisc_portall =
7083 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7085 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7086 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7088 cmdline_parse_token_string_t cmd_setpromisc_mode =
7089 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7092 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7093 .f = cmd_set_promisc_mode_parsed,
7095 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7097 (void *)&cmd_setpromisc_set,
7098 (void *)&cmd_setpromisc_promisc,
7099 (void *)&cmd_setpromisc_portall,
7100 (void *)&cmd_setpromisc_mode,
7105 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7106 .f = cmd_set_promisc_mode_parsed,
7108 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7110 (void *)&cmd_setpromisc_set,
7111 (void *)&cmd_setpromisc_promisc,
7112 (void *)&cmd_setpromisc_portnum,
7113 (void *)&cmd_setpromisc_mode,
7118 /* *** SET ALLMULTI MODE *** */
7119 struct cmd_set_allmulti_mode_result {
7120 cmdline_fixed_string_t set;
7121 cmdline_fixed_string_t allmulti;
7122 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7123 uint16_t port_num; /* valid if "allports" argument == 0 */
7124 cmdline_fixed_string_t mode;
7127 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7128 __rte_unused struct cmdline *cl,
7131 struct cmd_set_allmulti_mode_result *res = parsed_result;
7135 if (!strcmp(res->mode, "on"))
7142 RTE_ETH_FOREACH_DEV(i) {
7143 eth_set_allmulticast_mode(i, enable);
7147 eth_set_allmulticast_mode(res->port_num, enable);
7151 cmdline_parse_token_string_t cmd_setallmulti_set =
7152 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7153 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7154 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7156 cmdline_parse_token_string_t cmd_setallmulti_portall =
7157 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7159 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7160 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7162 cmdline_parse_token_string_t cmd_setallmulti_mode =
7163 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7166 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7167 .f = cmd_set_allmulti_mode_parsed,
7169 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7171 (void *)&cmd_setallmulti_set,
7172 (void *)&cmd_setallmulti_allmulti,
7173 (void *)&cmd_setallmulti_portall,
7174 (void *)&cmd_setallmulti_mode,
7179 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7180 .f = cmd_set_allmulti_mode_parsed,
7182 .help_str = "set allmulti <port_id> on|off: "
7183 "Set allmulti mode on port_id",
7185 (void *)&cmd_setallmulti_set,
7186 (void *)&cmd_setallmulti_allmulti,
7187 (void *)&cmd_setallmulti_portnum,
7188 (void *)&cmd_setallmulti_mode,
7193 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7194 struct cmd_link_flow_ctrl_show {
7195 cmdline_fixed_string_t show;
7196 cmdline_fixed_string_t port;
7198 cmdline_fixed_string_t flow_ctrl;
7201 cmdline_parse_token_string_t cmd_lfc_show_show =
7202 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7204 cmdline_parse_token_string_t cmd_lfc_show_port =
7205 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7207 cmdline_parse_token_num_t cmd_lfc_show_portid =
7208 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7209 port_id, RTE_UINT16);
7210 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7211 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7212 flow_ctrl, "flow_ctrl");
7215 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7216 __rte_unused struct cmdline *cl,
7217 __rte_unused void *data)
7219 struct cmd_link_flow_ctrl_show *res = parsed_result;
7220 static const char *info_border = "*********************";
7221 struct rte_eth_fc_conf fc_conf;
7222 bool rx_fc_en = false;
7223 bool tx_fc_en = false;
7226 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7229 "Failed to get current flow ctrl information: err = %d\n",
7234 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7236 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7239 printf("\n%s Flow control infos for port %-2d %s\n",
7240 info_border, res->port_id, info_border);
7241 printf("FC mode:\n");
7242 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7243 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7244 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7245 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7246 printf("High waterline: 0x%x\n", fc_conf.high_water);
7247 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7248 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7249 printf("Forward MAC control frames: %s\n",
7250 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7251 printf("\n%s************** End ***********%s\n",
7252 info_border, info_border);
7255 cmdline_parse_inst_t cmd_link_flow_control_show = {
7256 .f = cmd_link_flow_ctrl_show_parsed,
7258 .help_str = "show port <port_id> flow_ctrl",
7260 (void *)&cmd_lfc_show_show,
7261 (void *)&cmd_lfc_show_port,
7262 (void *)&cmd_lfc_show_portid,
7263 (void *)&cmd_lfc_show_flow_ctrl,
7268 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7269 struct cmd_link_flow_ctrl_set_result {
7270 cmdline_fixed_string_t set;
7271 cmdline_fixed_string_t flow_ctrl;
7272 cmdline_fixed_string_t rx;
7273 cmdline_fixed_string_t rx_lfc_mode;
7274 cmdline_fixed_string_t tx;
7275 cmdline_fixed_string_t tx_lfc_mode;
7276 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7277 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7278 cmdline_fixed_string_t autoneg_str;
7279 cmdline_fixed_string_t autoneg;
7280 cmdline_fixed_string_t hw_str;
7281 uint32_t high_water;
7282 cmdline_fixed_string_t lw_str;
7284 cmdline_fixed_string_t pt_str;
7285 uint16_t pause_time;
7286 cmdline_fixed_string_t xon_str;
7291 cmdline_parse_token_string_t cmd_lfc_set_set =
7292 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7294 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7295 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7296 flow_ctrl, "flow_ctrl");
7297 cmdline_parse_token_string_t cmd_lfc_set_rx =
7298 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7300 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7301 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7302 rx_lfc_mode, "on#off");
7303 cmdline_parse_token_string_t cmd_lfc_set_tx =
7304 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7306 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7307 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7308 tx_lfc_mode, "on#off");
7309 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7310 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7311 hw_str, "high_water");
7312 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7313 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7314 high_water, RTE_UINT32);
7315 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7316 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7317 lw_str, "low_water");
7318 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7319 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7320 low_water, RTE_UINT32);
7321 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7322 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7323 pt_str, "pause_time");
7324 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7325 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7326 pause_time, RTE_UINT16);
7327 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7328 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7329 xon_str, "send_xon");
7330 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7331 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7332 send_xon, RTE_UINT16);
7333 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7334 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7335 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7336 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7337 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7338 mac_ctrl_frame_fwd_mode, "on#off");
7339 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7340 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7341 autoneg_str, "autoneg");
7342 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7343 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7345 cmdline_parse_token_num_t cmd_lfc_set_portid =
7346 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7347 port_id, RTE_UINT16);
7349 /* forward declaration */
7351 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7354 cmdline_parse_inst_t cmd_link_flow_control_set = {
7355 .f = cmd_link_flow_ctrl_set_parsed,
7357 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7358 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7359 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7361 (void *)&cmd_lfc_set_set,
7362 (void *)&cmd_lfc_set_flow_ctrl,
7363 (void *)&cmd_lfc_set_rx,
7364 (void *)&cmd_lfc_set_rx_mode,
7365 (void *)&cmd_lfc_set_tx,
7366 (void *)&cmd_lfc_set_tx_mode,
7367 (void *)&cmd_lfc_set_high_water,
7368 (void *)&cmd_lfc_set_low_water,
7369 (void *)&cmd_lfc_set_pause_time,
7370 (void *)&cmd_lfc_set_send_xon,
7371 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7372 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7373 (void *)&cmd_lfc_set_autoneg_str,
7374 (void *)&cmd_lfc_set_autoneg,
7375 (void *)&cmd_lfc_set_portid,
7380 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7381 .f = cmd_link_flow_ctrl_set_parsed,
7382 .data = (void *)&cmd_link_flow_control_set_rx,
7383 .help_str = "set flow_ctrl rx on|off <port_id>: "
7384 "Change rx flow control parameter",
7386 (void *)&cmd_lfc_set_set,
7387 (void *)&cmd_lfc_set_flow_ctrl,
7388 (void *)&cmd_lfc_set_rx,
7389 (void *)&cmd_lfc_set_rx_mode,
7390 (void *)&cmd_lfc_set_portid,
7395 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7396 .f = cmd_link_flow_ctrl_set_parsed,
7397 .data = (void *)&cmd_link_flow_control_set_tx,
7398 .help_str = "set flow_ctrl tx on|off <port_id>: "
7399 "Change tx flow control parameter",
7401 (void *)&cmd_lfc_set_set,
7402 (void *)&cmd_lfc_set_flow_ctrl,
7403 (void *)&cmd_lfc_set_tx,
7404 (void *)&cmd_lfc_set_tx_mode,
7405 (void *)&cmd_lfc_set_portid,
7410 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7411 .f = cmd_link_flow_ctrl_set_parsed,
7412 .data = (void *)&cmd_link_flow_control_set_hw,
7413 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7414 "Change high water flow control parameter",
7416 (void *)&cmd_lfc_set_set,
7417 (void *)&cmd_lfc_set_flow_ctrl,
7418 (void *)&cmd_lfc_set_high_water_str,
7419 (void *)&cmd_lfc_set_high_water,
7420 (void *)&cmd_lfc_set_portid,
7425 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7426 .f = cmd_link_flow_ctrl_set_parsed,
7427 .data = (void *)&cmd_link_flow_control_set_lw,
7428 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7429 "Change low water flow control parameter",
7431 (void *)&cmd_lfc_set_set,
7432 (void *)&cmd_lfc_set_flow_ctrl,
7433 (void *)&cmd_lfc_set_low_water_str,
7434 (void *)&cmd_lfc_set_low_water,
7435 (void *)&cmd_lfc_set_portid,
7440 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7441 .f = cmd_link_flow_ctrl_set_parsed,
7442 .data = (void *)&cmd_link_flow_control_set_pt,
7443 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7444 "Change pause time flow control parameter",
7446 (void *)&cmd_lfc_set_set,
7447 (void *)&cmd_lfc_set_flow_ctrl,
7448 (void *)&cmd_lfc_set_pause_time_str,
7449 (void *)&cmd_lfc_set_pause_time,
7450 (void *)&cmd_lfc_set_portid,
7455 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7456 .f = cmd_link_flow_ctrl_set_parsed,
7457 .data = (void *)&cmd_link_flow_control_set_xon,
7458 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7459 "Change send_xon flow control parameter",
7461 (void *)&cmd_lfc_set_set,
7462 (void *)&cmd_lfc_set_flow_ctrl,
7463 (void *)&cmd_lfc_set_send_xon_str,
7464 (void *)&cmd_lfc_set_send_xon,
7465 (void *)&cmd_lfc_set_portid,
7470 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7471 .f = cmd_link_flow_ctrl_set_parsed,
7472 .data = (void *)&cmd_link_flow_control_set_macfwd,
7473 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7474 "Change mac ctrl fwd flow control parameter",
7476 (void *)&cmd_lfc_set_set,
7477 (void *)&cmd_lfc_set_flow_ctrl,
7478 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7479 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7480 (void *)&cmd_lfc_set_portid,
7485 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7486 .f = cmd_link_flow_ctrl_set_parsed,
7487 .data = (void *)&cmd_link_flow_control_set_autoneg,
7488 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7489 "Change autoneg flow control parameter",
7491 (void *)&cmd_lfc_set_set,
7492 (void *)&cmd_lfc_set_flow_ctrl,
7493 (void *)&cmd_lfc_set_autoneg_str,
7494 (void *)&cmd_lfc_set_autoneg,
7495 (void *)&cmd_lfc_set_portid,
7501 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7502 __rte_unused struct cmdline *cl,
7505 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7506 cmdline_parse_inst_t *cmd = data;
7507 struct rte_eth_fc_conf fc_conf;
7513 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7514 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7515 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7516 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7518 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7519 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7522 /* Partial command line, retrieve current configuration */
7524 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7527 "cannot get current flow ctrl parameters, return code = %d\n",
7532 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7533 (fc_conf.mode == RTE_FC_FULL))
7535 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7536 (fc_conf.mode == RTE_FC_FULL))
7540 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7541 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7543 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7544 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7546 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7548 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7549 fc_conf.high_water = res->high_water;
7551 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7552 fc_conf.low_water = res->low_water;
7554 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7555 fc_conf.pause_time = res->pause_time;
7557 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7558 fc_conf.send_xon = res->send_xon;
7560 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7561 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7562 fc_conf.mac_ctrl_frame_fwd = 1;
7564 fc_conf.mac_ctrl_frame_fwd = 0;
7567 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7568 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7570 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7573 "bad flow control parameter, return code = %d\n",
7577 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7578 struct cmd_priority_flow_ctrl_set_result {
7579 cmdline_fixed_string_t set;
7580 cmdline_fixed_string_t pfc_ctrl;
7581 cmdline_fixed_string_t rx;
7582 cmdline_fixed_string_t rx_pfc_mode;
7583 cmdline_fixed_string_t tx;
7584 cmdline_fixed_string_t tx_pfc_mode;
7585 uint32_t high_water;
7587 uint16_t pause_time;
7593 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7594 __rte_unused struct cmdline *cl,
7595 __rte_unused void *data)
7597 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7598 struct rte_eth_pfc_conf pfc_conf;
7599 int rx_fc_enable, tx_fc_enable;
7603 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7604 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7605 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7606 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7608 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7609 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7612 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7613 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7614 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7615 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7616 pfc_conf.fc.high_water = res->high_water;
7617 pfc_conf.fc.low_water = res->low_water;
7618 pfc_conf.fc.pause_time = res->pause_time;
7619 pfc_conf.priority = res->priority;
7621 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7624 "bad priority flow control parameter, return code = %d\n",
7628 cmdline_parse_token_string_t cmd_pfc_set_set =
7629 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7631 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7632 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7633 pfc_ctrl, "pfc_ctrl");
7634 cmdline_parse_token_string_t cmd_pfc_set_rx =
7635 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7637 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7638 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7639 rx_pfc_mode, "on#off");
7640 cmdline_parse_token_string_t cmd_pfc_set_tx =
7641 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7643 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7644 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7645 tx_pfc_mode, "on#off");
7646 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7647 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7648 high_water, RTE_UINT32);
7649 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7650 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7651 low_water, RTE_UINT32);
7652 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7653 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7654 pause_time, RTE_UINT16);
7655 cmdline_parse_token_num_t cmd_pfc_set_priority =
7656 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7657 priority, RTE_UINT8);
7658 cmdline_parse_token_num_t cmd_pfc_set_portid =
7659 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7660 port_id, RTE_UINT16);
7662 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7663 .f = cmd_priority_flow_ctrl_set_parsed,
7665 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7666 "<pause_time> <priority> <port_id>: "
7667 "Configure the Ethernet priority flow control",
7669 (void *)&cmd_pfc_set_set,
7670 (void *)&cmd_pfc_set_flow_ctrl,
7671 (void *)&cmd_pfc_set_rx,
7672 (void *)&cmd_pfc_set_rx_mode,
7673 (void *)&cmd_pfc_set_tx,
7674 (void *)&cmd_pfc_set_tx_mode,
7675 (void *)&cmd_pfc_set_high_water,
7676 (void *)&cmd_pfc_set_low_water,
7677 (void *)&cmd_pfc_set_pause_time,
7678 (void *)&cmd_pfc_set_priority,
7679 (void *)&cmd_pfc_set_portid,
7684 /* *** RESET CONFIGURATION *** */
7685 struct cmd_reset_result {
7686 cmdline_fixed_string_t reset;
7687 cmdline_fixed_string_t def;
7690 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7692 __rte_unused void *data)
7694 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7695 set_def_fwd_config();
7698 cmdline_parse_token_string_t cmd_reset_set =
7699 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7700 cmdline_parse_token_string_t cmd_reset_def =
7701 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7704 cmdline_parse_inst_t cmd_reset = {
7705 .f = cmd_reset_parsed,
7707 .help_str = "set default: Reset default forwarding configuration",
7709 (void *)&cmd_reset_set,
7710 (void *)&cmd_reset_def,
7715 /* *** START FORWARDING *** */
7716 struct cmd_start_result {
7717 cmdline_fixed_string_t start;
7720 cmdline_parse_token_string_t cmd_start_start =
7721 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7723 static void cmd_start_parsed(__rte_unused void *parsed_result,
7724 __rte_unused struct cmdline *cl,
7725 __rte_unused void *data)
7727 start_packet_forwarding(0);
7730 cmdline_parse_inst_t cmd_start = {
7731 .f = cmd_start_parsed,
7733 .help_str = "start: Start packet forwarding",
7735 (void *)&cmd_start_start,
7740 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7741 struct cmd_start_tx_first_result {
7742 cmdline_fixed_string_t start;
7743 cmdline_fixed_string_t tx_first;
7747 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7748 __rte_unused struct cmdline *cl,
7749 __rte_unused void *data)
7751 start_packet_forwarding(1);
7754 cmdline_parse_token_string_t cmd_start_tx_first_start =
7755 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7757 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7758 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7759 tx_first, "tx_first");
7761 cmdline_parse_inst_t cmd_start_tx_first = {
7762 .f = cmd_start_tx_first_parsed,
7764 .help_str = "start tx_first: Start packet forwarding, "
7765 "after sending 1 burst of packets",
7767 (void *)&cmd_start_tx_first_start,
7768 (void *)&cmd_start_tx_first_tx_first,
7773 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7774 struct cmd_start_tx_first_n_result {
7775 cmdline_fixed_string_t start;
7776 cmdline_fixed_string_t tx_first;
7781 cmd_start_tx_first_n_parsed(void *parsed_result,
7782 __rte_unused struct cmdline *cl,
7783 __rte_unused void *data)
7785 struct cmd_start_tx_first_n_result *res = parsed_result;
7787 start_packet_forwarding(res->tx_num);
7790 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7791 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7793 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7794 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7795 tx_first, "tx_first");
7796 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7797 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7798 tx_num, RTE_UINT32);
7800 cmdline_parse_inst_t cmd_start_tx_first_n = {
7801 .f = cmd_start_tx_first_n_parsed,
7803 .help_str = "start tx_first <num>: "
7804 "packet forwarding, after sending <num> bursts of packets",
7806 (void *)&cmd_start_tx_first_n_start,
7807 (void *)&cmd_start_tx_first_n_tx_first,
7808 (void *)&cmd_start_tx_first_n_tx_num,
7813 /* *** SET LINK UP *** */
7814 struct cmd_set_link_up_result {
7815 cmdline_fixed_string_t set;
7816 cmdline_fixed_string_t link_up;
7817 cmdline_fixed_string_t port;
7821 cmdline_parse_token_string_t cmd_set_link_up_set =
7822 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7823 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7824 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7826 cmdline_parse_token_string_t cmd_set_link_up_port =
7827 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7828 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7829 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7832 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7833 __rte_unused struct cmdline *cl,
7834 __rte_unused void *data)
7836 struct cmd_set_link_up_result *res = parsed_result;
7837 dev_set_link_up(res->port_id);
7840 cmdline_parse_inst_t cmd_set_link_up = {
7841 .f = cmd_set_link_up_parsed,
7843 .help_str = "set link-up port <port id>",
7845 (void *)&cmd_set_link_up_set,
7846 (void *)&cmd_set_link_up_link_up,
7847 (void *)&cmd_set_link_up_port,
7848 (void *)&cmd_set_link_up_port_id,
7853 /* *** SET LINK DOWN *** */
7854 struct cmd_set_link_down_result {
7855 cmdline_fixed_string_t set;
7856 cmdline_fixed_string_t link_down;
7857 cmdline_fixed_string_t port;
7861 cmdline_parse_token_string_t cmd_set_link_down_set =
7862 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7863 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7864 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7866 cmdline_parse_token_string_t cmd_set_link_down_port =
7867 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7868 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7869 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7872 static void cmd_set_link_down_parsed(
7873 __rte_unused void *parsed_result,
7874 __rte_unused struct cmdline *cl,
7875 __rte_unused void *data)
7877 struct cmd_set_link_down_result *res = parsed_result;
7878 dev_set_link_down(res->port_id);
7881 cmdline_parse_inst_t cmd_set_link_down = {
7882 .f = cmd_set_link_down_parsed,
7884 .help_str = "set link-down port <port id>",
7886 (void *)&cmd_set_link_down_set,
7887 (void *)&cmd_set_link_down_link_down,
7888 (void *)&cmd_set_link_down_port,
7889 (void *)&cmd_set_link_down_port_id,
7894 /* *** SHOW CFG *** */
7895 struct cmd_showcfg_result {
7896 cmdline_fixed_string_t show;
7897 cmdline_fixed_string_t cfg;
7898 cmdline_fixed_string_t what;
7901 static void cmd_showcfg_parsed(void *parsed_result,
7902 __rte_unused struct cmdline *cl,
7903 __rte_unused void *data)
7905 struct cmd_showcfg_result *res = parsed_result;
7906 if (!strcmp(res->what, "rxtx"))
7907 rxtx_config_display();
7908 else if (!strcmp(res->what, "cores"))
7909 fwd_lcores_config_display();
7910 else if (!strcmp(res->what, "fwd"))
7911 pkt_fwd_config_display(&cur_fwd_config);
7912 else if (!strcmp(res->what, "rxoffs"))
7913 show_rx_pkt_offsets();
7914 else if (!strcmp(res->what, "rxpkts"))
7915 show_rx_pkt_segments();
7916 else if (!strcmp(res->what, "txpkts"))
7917 show_tx_pkt_segments();
7918 else if (!strcmp(res->what, "txtimes"))
7919 show_tx_pkt_times();
7922 cmdline_parse_token_string_t cmd_showcfg_show =
7923 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7924 cmdline_parse_token_string_t cmd_showcfg_port =
7925 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7926 cmdline_parse_token_string_t cmd_showcfg_what =
7927 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7928 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7930 cmdline_parse_inst_t cmd_showcfg = {
7931 .f = cmd_showcfg_parsed,
7933 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7935 (void *)&cmd_showcfg_show,
7936 (void *)&cmd_showcfg_port,
7937 (void *)&cmd_showcfg_what,
7942 /* *** SHOW ALL PORT INFO *** */
7943 struct cmd_showportall_result {
7944 cmdline_fixed_string_t show;
7945 cmdline_fixed_string_t port;
7946 cmdline_fixed_string_t what;
7947 cmdline_fixed_string_t all;
7950 static void cmd_showportall_parsed(void *parsed_result,
7951 __rte_unused struct cmdline *cl,
7952 __rte_unused void *data)
7956 struct cmd_showportall_result *res = parsed_result;
7957 if (!strcmp(res->show, "clear")) {
7958 if (!strcmp(res->what, "stats"))
7959 RTE_ETH_FOREACH_DEV(i)
7961 else if (!strcmp(res->what, "xstats"))
7962 RTE_ETH_FOREACH_DEV(i)
7963 nic_xstats_clear(i);
7964 } else if (!strcmp(res->what, "info"))
7965 RTE_ETH_FOREACH_DEV(i)
7966 port_infos_display(i);
7967 else if (!strcmp(res->what, "summary")) {
7968 port_summary_header_display();
7969 RTE_ETH_FOREACH_DEV(i)
7970 port_summary_display(i);
7972 else if (!strcmp(res->what, "stats"))
7973 RTE_ETH_FOREACH_DEV(i)
7974 nic_stats_display(i);
7975 else if (!strcmp(res->what, "xstats"))
7976 RTE_ETH_FOREACH_DEV(i)
7977 nic_xstats_display(i);
7978 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7979 else if (!strcmp(res->what, "fdir"))
7980 RTE_ETH_FOREACH_DEV(i)
7983 else if (!strcmp(res->what, "dcb_tc"))
7984 RTE_ETH_FOREACH_DEV(i)
7985 port_dcb_info_display(i);
7988 cmdline_parse_token_string_t cmd_showportall_show =
7989 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7991 cmdline_parse_token_string_t cmd_showportall_port =
7992 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7993 cmdline_parse_token_string_t cmd_showportall_what =
7994 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7995 "info#summary#stats#xstats#fdir#dcb_tc");
7996 cmdline_parse_token_string_t cmd_showportall_all =
7997 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7998 cmdline_parse_inst_t cmd_showportall = {
7999 .f = cmd_showportall_parsed,
8001 .help_str = "show|clear port "
8002 "info|summary|stats|xstats|fdir|dcb_tc all",
8004 (void *)&cmd_showportall_show,
8005 (void *)&cmd_showportall_port,
8006 (void *)&cmd_showportall_what,
8007 (void *)&cmd_showportall_all,
8012 /* *** SHOW PORT INFO *** */
8013 struct cmd_showport_result {
8014 cmdline_fixed_string_t show;
8015 cmdline_fixed_string_t port;
8016 cmdline_fixed_string_t what;
8020 static void cmd_showport_parsed(void *parsed_result,
8021 __rte_unused struct cmdline *cl,
8022 __rte_unused void *data)
8024 struct cmd_showport_result *res = parsed_result;
8025 if (!strcmp(res->show, "clear")) {
8026 if (!strcmp(res->what, "stats"))
8027 nic_stats_clear(res->portnum);
8028 else if (!strcmp(res->what, "xstats"))
8029 nic_xstats_clear(res->portnum);
8030 } else if (!strcmp(res->what, "info"))
8031 port_infos_display(res->portnum);
8032 else if (!strcmp(res->what, "summary")) {
8033 port_summary_header_display();
8034 port_summary_display(res->portnum);
8036 else if (!strcmp(res->what, "stats"))
8037 nic_stats_display(res->portnum);
8038 else if (!strcmp(res->what, "xstats"))
8039 nic_xstats_display(res->portnum);
8040 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8041 else if (!strcmp(res->what, "fdir"))
8042 fdir_get_infos(res->portnum);
8044 else if (!strcmp(res->what, "dcb_tc"))
8045 port_dcb_info_display(res->portnum);
8048 cmdline_parse_token_string_t cmd_showport_show =
8049 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8051 cmdline_parse_token_string_t cmd_showport_port =
8052 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8053 cmdline_parse_token_string_t cmd_showport_what =
8054 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8055 "info#summary#stats#xstats#fdir#dcb_tc");
8056 cmdline_parse_token_num_t cmd_showport_portnum =
8057 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8059 cmdline_parse_inst_t cmd_showport = {
8060 .f = cmd_showport_parsed,
8062 .help_str = "show|clear port "
8063 "info|summary|stats|xstats|fdir|dcb_tc "
8066 (void *)&cmd_showport_show,
8067 (void *)&cmd_showport_port,
8068 (void *)&cmd_showport_what,
8069 (void *)&cmd_showport_portnum,
8074 /* *** SHOW DEVICE INFO *** */
8075 struct cmd_showdevice_result {
8076 cmdline_fixed_string_t show;
8077 cmdline_fixed_string_t device;
8078 cmdline_fixed_string_t what;
8079 cmdline_fixed_string_t identifier;
8082 static void cmd_showdevice_parsed(void *parsed_result,
8083 __rte_unused struct cmdline *cl,
8084 __rte_unused void *data)
8086 struct cmd_showdevice_result *res = parsed_result;
8087 if (!strcmp(res->what, "info")) {
8088 if (!strcmp(res->identifier, "all"))
8089 device_infos_display(NULL);
8091 device_infos_display(res->identifier);
8095 cmdline_parse_token_string_t cmd_showdevice_show =
8096 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8098 cmdline_parse_token_string_t cmd_showdevice_device =
8099 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8100 cmdline_parse_token_string_t cmd_showdevice_what =
8101 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8103 cmdline_parse_token_string_t cmd_showdevice_identifier =
8104 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8107 cmdline_parse_inst_t cmd_showdevice = {
8108 .f = cmd_showdevice_parsed,
8110 .help_str = "show device info <identifier>|all",
8112 (void *)&cmd_showdevice_show,
8113 (void *)&cmd_showdevice_device,
8114 (void *)&cmd_showdevice_what,
8115 (void *)&cmd_showdevice_identifier,
8120 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8121 struct cmd_showeeprom_result {
8122 cmdline_fixed_string_t show;
8123 cmdline_fixed_string_t port;
8125 cmdline_fixed_string_t type;
8128 static void cmd_showeeprom_parsed(void *parsed_result,
8129 __rte_unused struct cmdline *cl,
8130 __rte_unused void *data)
8132 struct cmd_showeeprom_result *res = parsed_result;
8134 if (!strcmp(res->type, "eeprom"))
8135 port_eeprom_display(res->portnum);
8136 else if (!strcmp(res->type, "module_eeprom"))
8137 port_module_eeprom_display(res->portnum);
8139 fprintf(stderr, "Unknown argument\n");
8142 cmdline_parse_token_string_t cmd_showeeprom_show =
8143 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8144 cmdline_parse_token_string_t cmd_showeeprom_port =
8145 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8146 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8147 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8149 cmdline_parse_token_string_t cmd_showeeprom_type =
8150 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8152 cmdline_parse_inst_t cmd_showeeprom = {
8153 .f = cmd_showeeprom_parsed,
8155 .help_str = "show port <port_id> module_eeprom|eeprom",
8157 (void *)&cmd_showeeprom_show,
8158 (void *)&cmd_showeeprom_port,
8159 (void *)&cmd_showeeprom_portnum,
8160 (void *)&cmd_showeeprom_type,
8165 /* *** SHOW QUEUE INFO *** */
8166 struct cmd_showqueue_result {
8167 cmdline_fixed_string_t show;
8168 cmdline_fixed_string_t type;
8169 cmdline_fixed_string_t what;
8175 cmd_showqueue_parsed(void *parsed_result,
8176 __rte_unused struct cmdline *cl,
8177 __rte_unused void *data)
8179 struct cmd_showqueue_result *res = parsed_result;
8181 if (!strcmp(res->type, "rxq"))
8182 rx_queue_infos_display(res->portnum, res->queuenum);
8183 else if (!strcmp(res->type, "txq"))
8184 tx_queue_infos_display(res->portnum, res->queuenum);
8187 cmdline_parse_token_string_t cmd_showqueue_show =
8188 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8189 cmdline_parse_token_string_t cmd_showqueue_type =
8190 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8191 cmdline_parse_token_string_t cmd_showqueue_what =
8192 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8193 cmdline_parse_token_num_t cmd_showqueue_portnum =
8194 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8196 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8197 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8200 cmdline_parse_inst_t cmd_showqueue = {
8201 .f = cmd_showqueue_parsed,
8203 .help_str = "show rxq|txq info <port_id> <queue_id>",
8205 (void *)&cmd_showqueue_show,
8206 (void *)&cmd_showqueue_type,
8207 (void *)&cmd_showqueue_what,
8208 (void *)&cmd_showqueue_portnum,
8209 (void *)&cmd_showqueue_queuenum,
8214 /* show/clear fwd engine statistics */
8216 cmdline_fixed_string_t action;
8217 cmdline_fixed_string_t fwd;
8218 cmdline_fixed_string_t stats;
8219 cmdline_fixed_string_t all;
8222 cmdline_parse_token_string_t cmd_fwd_action =
8223 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8224 cmdline_parse_token_string_t cmd_fwd_fwd =
8225 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8226 cmdline_parse_token_string_t cmd_fwd_stats =
8227 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8228 cmdline_parse_token_string_t cmd_fwd_all =
8229 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8232 cmd_showfwdall_parsed(void *parsed_result,
8233 __rte_unused struct cmdline *cl,
8234 __rte_unused void *data)
8236 struct fwd_result *res = parsed_result;
8238 if (!strcmp(res->action, "show"))
8239 fwd_stats_display();
8244 static cmdline_parse_inst_t cmd_showfwdall = {
8245 .f = cmd_showfwdall_parsed,
8247 .help_str = "show|clear fwd stats all",
8249 (void *)&cmd_fwd_action,
8250 (void *)&cmd_fwd_fwd,
8251 (void *)&cmd_fwd_stats,
8252 (void *)&cmd_fwd_all,
8257 /* *** READ PORT REGISTER *** */
8258 struct cmd_read_reg_result {
8259 cmdline_fixed_string_t read;
8260 cmdline_fixed_string_t reg;
8266 cmd_read_reg_parsed(void *parsed_result,
8267 __rte_unused struct cmdline *cl,
8268 __rte_unused void *data)
8270 struct cmd_read_reg_result *res = parsed_result;
8271 port_reg_display(res->port_id, res->reg_off);
8274 cmdline_parse_token_string_t cmd_read_reg_read =
8275 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8276 cmdline_parse_token_string_t cmd_read_reg_reg =
8277 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8278 cmdline_parse_token_num_t cmd_read_reg_port_id =
8279 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8280 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8281 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8283 cmdline_parse_inst_t cmd_read_reg = {
8284 .f = cmd_read_reg_parsed,
8286 .help_str = "read reg <port_id> <reg_off>",
8288 (void *)&cmd_read_reg_read,
8289 (void *)&cmd_read_reg_reg,
8290 (void *)&cmd_read_reg_port_id,
8291 (void *)&cmd_read_reg_reg_off,
8296 /* *** READ PORT REGISTER BIT FIELD *** */
8297 struct cmd_read_reg_bit_field_result {
8298 cmdline_fixed_string_t read;
8299 cmdline_fixed_string_t regfield;
8307 cmd_read_reg_bit_field_parsed(void *parsed_result,
8308 __rte_unused struct cmdline *cl,
8309 __rte_unused void *data)
8311 struct cmd_read_reg_bit_field_result *res = parsed_result;
8312 port_reg_bit_field_display(res->port_id, res->reg_off,
8313 res->bit1_pos, res->bit2_pos);
8316 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8317 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8319 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8320 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8321 regfield, "regfield");
8322 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8323 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8325 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8326 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8328 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8329 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8331 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8332 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8335 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8336 .f = cmd_read_reg_bit_field_parsed,
8338 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8339 "Read register bit field between bit_x and bit_y included",
8341 (void *)&cmd_read_reg_bit_field_read,
8342 (void *)&cmd_read_reg_bit_field_regfield,
8343 (void *)&cmd_read_reg_bit_field_port_id,
8344 (void *)&cmd_read_reg_bit_field_reg_off,
8345 (void *)&cmd_read_reg_bit_field_bit1_pos,
8346 (void *)&cmd_read_reg_bit_field_bit2_pos,
8351 /* *** READ PORT REGISTER BIT *** */
8352 struct cmd_read_reg_bit_result {
8353 cmdline_fixed_string_t read;
8354 cmdline_fixed_string_t regbit;
8361 cmd_read_reg_bit_parsed(void *parsed_result,
8362 __rte_unused struct cmdline *cl,
8363 __rte_unused void *data)
8365 struct cmd_read_reg_bit_result *res = parsed_result;
8366 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8369 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8370 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8371 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8372 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8374 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8375 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8377 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8378 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8380 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8381 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8384 cmdline_parse_inst_t cmd_read_reg_bit = {
8385 .f = cmd_read_reg_bit_parsed,
8387 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8389 (void *)&cmd_read_reg_bit_read,
8390 (void *)&cmd_read_reg_bit_regbit,
8391 (void *)&cmd_read_reg_bit_port_id,
8392 (void *)&cmd_read_reg_bit_reg_off,
8393 (void *)&cmd_read_reg_bit_bit_pos,
8398 /* *** WRITE PORT REGISTER *** */
8399 struct cmd_write_reg_result {
8400 cmdline_fixed_string_t write;
8401 cmdline_fixed_string_t reg;
8408 cmd_write_reg_parsed(void *parsed_result,
8409 __rte_unused struct cmdline *cl,
8410 __rte_unused void *data)
8412 struct cmd_write_reg_result *res = parsed_result;
8413 port_reg_set(res->port_id, res->reg_off, res->value);
8416 cmdline_parse_token_string_t cmd_write_reg_write =
8417 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8418 cmdline_parse_token_string_t cmd_write_reg_reg =
8419 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8420 cmdline_parse_token_num_t cmd_write_reg_port_id =
8421 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8422 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8423 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8424 cmdline_parse_token_num_t cmd_write_reg_value =
8425 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8427 cmdline_parse_inst_t cmd_write_reg = {
8428 .f = cmd_write_reg_parsed,
8430 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8432 (void *)&cmd_write_reg_write,
8433 (void *)&cmd_write_reg_reg,
8434 (void *)&cmd_write_reg_port_id,
8435 (void *)&cmd_write_reg_reg_off,
8436 (void *)&cmd_write_reg_value,
8441 /* *** WRITE PORT REGISTER BIT FIELD *** */
8442 struct cmd_write_reg_bit_field_result {
8443 cmdline_fixed_string_t write;
8444 cmdline_fixed_string_t regfield;
8453 cmd_write_reg_bit_field_parsed(void *parsed_result,
8454 __rte_unused struct cmdline *cl,
8455 __rte_unused void *data)
8457 struct cmd_write_reg_bit_field_result *res = parsed_result;
8458 port_reg_bit_field_set(res->port_id, res->reg_off,
8459 res->bit1_pos, res->bit2_pos, res->value);
8462 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8463 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8465 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8466 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8467 regfield, "regfield");
8468 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8469 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8471 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8472 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8474 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8475 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8477 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8478 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8480 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8481 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8484 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8485 .f = cmd_write_reg_bit_field_parsed,
8487 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8489 "Set register bit field between bit_x and bit_y included",
8491 (void *)&cmd_write_reg_bit_field_write,
8492 (void *)&cmd_write_reg_bit_field_regfield,
8493 (void *)&cmd_write_reg_bit_field_port_id,
8494 (void *)&cmd_write_reg_bit_field_reg_off,
8495 (void *)&cmd_write_reg_bit_field_bit1_pos,
8496 (void *)&cmd_write_reg_bit_field_bit2_pos,
8497 (void *)&cmd_write_reg_bit_field_value,
8502 /* *** WRITE PORT REGISTER BIT *** */
8503 struct cmd_write_reg_bit_result {
8504 cmdline_fixed_string_t write;
8505 cmdline_fixed_string_t regbit;
8513 cmd_write_reg_bit_parsed(void *parsed_result,
8514 __rte_unused struct cmdline *cl,
8515 __rte_unused void *data)
8517 struct cmd_write_reg_bit_result *res = parsed_result;
8518 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8521 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8522 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8524 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8525 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8527 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8528 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8530 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8531 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8533 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8534 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8536 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8537 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8540 cmdline_parse_inst_t cmd_write_reg_bit = {
8541 .f = cmd_write_reg_bit_parsed,
8543 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8546 (void *)&cmd_write_reg_bit_write,
8547 (void *)&cmd_write_reg_bit_regbit,
8548 (void *)&cmd_write_reg_bit_port_id,
8549 (void *)&cmd_write_reg_bit_reg_off,
8550 (void *)&cmd_write_reg_bit_bit_pos,
8551 (void *)&cmd_write_reg_bit_value,
8556 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8557 struct cmd_read_rxd_txd_result {
8558 cmdline_fixed_string_t read;
8559 cmdline_fixed_string_t rxd_txd;
8566 cmd_read_rxd_txd_parsed(void *parsed_result,
8567 __rte_unused struct cmdline *cl,
8568 __rte_unused void *data)
8570 struct cmd_read_rxd_txd_result *res = parsed_result;
8572 if (!strcmp(res->rxd_txd, "rxd"))
8573 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8574 else if (!strcmp(res->rxd_txd, "txd"))
8575 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8578 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8579 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8580 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8581 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8583 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8584 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8586 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8587 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8589 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8590 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8593 cmdline_parse_inst_t cmd_read_rxd_txd = {
8594 .f = cmd_read_rxd_txd_parsed,
8596 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8598 (void *)&cmd_read_rxd_txd_read,
8599 (void *)&cmd_read_rxd_txd_rxd_txd,
8600 (void *)&cmd_read_rxd_txd_port_id,
8601 (void *)&cmd_read_rxd_txd_queue_id,
8602 (void *)&cmd_read_rxd_txd_desc_id,
8608 struct cmd_quit_result {
8609 cmdline_fixed_string_t quit;
8612 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8614 __rte_unused void *data)
8619 cmdline_parse_token_string_t cmd_quit_quit =
8620 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8622 cmdline_parse_inst_t cmd_quit = {
8623 .f = cmd_quit_parsed,
8625 .help_str = "quit: Exit application",
8627 (void *)&cmd_quit_quit,
8632 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8633 struct cmd_mac_addr_result {
8634 cmdline_fixed_string_t mac_addr_cmd;
8635 cmdline_fixed_string_t what;
8637 struct rte_ether_addr address;
8640 static void cmd_mac_addr_parsed(void *parsed_result,
8641 __rte_unused struct cmdline *cl,
8642 __rte_unused void *data)
8644 struct cmd_mac_addr_result *res = parsed_result;
8647 if (strcmp(res->what, "add") == 0)
8648 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8649 else if (strcmp(res->what, "set") == 0)
8650 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8653 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8655 /* check the return value and print it if is < 0 */
8657 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8661 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8662 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8664 cmdline_parse_token_string_t cmd_mac_addr_what =
8665 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8667 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8668 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8670 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8671 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8673 cmdline_parse_inst_t cmd_mac_addr = {
8674 .f = cmd_mac_addr_parsed,
8676 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8677 "Add/Remove/Set MAC address on port_id",
8679 (void *)&cmd_mac_addr_cmd,
8680 (void *)&cmd_mac_addr_what,
8681 (void *)&cmd_mac_addr_portnum,
8682 (void *)&cmd_mac_addr_addr,
8687 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8688 struct cmd_eth_peer_result {
8689 cmdline_fixed_string_t set;
8690 cmdline_fixed_string_t eth_peer;
8692 cmdline_fixed_string_t peer_addr;
8695 static void cmd_set_eth_peer_parsed(void *parsed_result,
8696 __rte_unused struct cmdline *cl,
8697 __rte_unused void *data)
8699 struct cmd_eth_peer_result *res = parsed_result;
8701 if (test_done == 0) {
8702 fprintf(stderr, "Please stop forwarding first\n");
8705 if (!strcmp(res->eth_peer, "eth-peer")) {
8706 set_fwd_eth_peer(res->port_id, res->peer_addr);
8710 cmdline_parse_token_string_t cmd_eth_peer_set =
8711 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8712 cmdline_parse_token_string_t cmd_eth_peer =
8713 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8714 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8715 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8717 cmdline_parse_token_string_t cmd_eth_peer_addr =
8718 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8720 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8721 .f = cmd_set_eth_peer_parsed,
8723 .help_str = "set eth-peer <port_id> <peer_mac>",
8725 (void *)&cmd_eth_peer_set,
8726 (void *)&cmd_eth_peer,
8727 (void *)&cmd_eth_peer_port_id,
8728 (void *)&cmd_eth_peer_addr,
8733 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8734 struct cmd_set_qmap_result {
8735 cmdline_fixed_string_t set;
8736 cmdline_fixed_string_t qmap;
8737 cmdline_fixed_string_t what;
8744 cmd_set_qmap_parsed(void *parsed_result,
8745 __rte_unused struct cmdline *cl,
8746 __rte_unused void *data)
8748 struct cmd_set_qmap_result *res = parsed_result;
8749 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8751 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8754 cmdline_parse_token_string_t cmd_setqmap_set =
8755 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8757 cmdline_parse_token_string_t cmd_setqmap_qmap =
8758 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8760 cmdline_parse_token_string_t cmd_setqmap_what =
8761 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8763 cmdline_parse_token_num_t cmd_setqmap_portid =
8764 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8765 port_id, RTE_UINT16);
8766 cmdline_parse_token_num_t cmd_setqmap_queueid =
8767 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8768 queue_id, RTE_UINT16);
8769 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8770 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8771 map_value, RTE_UINT8);
8773 cmdline_parse_inst_t cmd_set_qmap = {
8774 .f = cmd_set_qmap_parsed,
8776 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8777 "Set statistics mapping value on tx|rx queue_id of port_id",
8779 (void *)&cmd_setqmap_set,
8780 (void *)&cmd_setqmap_qmap,
8781 (void *)&cmd_setqmap_what,
8782 (void *)&cmd_setqmap_portid,
8783 (void *)&cmd_setqmap_queueid,
8784 (void *)&cmd_setqmap_mapvalue,
8789 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8790 struct cmd_set_xstats_hide_zero_result {
8791 cmdline_fixed_string_t keyword;
8792 cmdline_fixed_string_t name;
8793 cmdline_fixed_string_t on_off;
8797 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8798 __rte_unused struct cmdline *cl,
8799 __rte_unused void *data)
8801 struct cmd_set_xstats_hide_zero_result *res;
8802 uint16_t on_off = 0;
8804 res = parsed_result;
8805 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8806 set_xstats_hide_zero(on_off);
8809 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8810 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8812 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8813 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8814 name, "xstats-hide-zero");
8815 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8816 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8819 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8820 .f = cmd_set_xstats_hide_zero_parsed,
8822 .help_str = "set xstats-hide-zero on|off",
8824 (void *)&cmd_set_xstats_hide_zero_keyword,
8825 (void *)&cmd_set_xstats_hide_zero_name,
8826 (void *)&cmd_set_xstats_hide_zero_on_off,
8831 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8832 struct cmd_set_record_core_cycles_result {
8833 cmdline_fixed_string_t keyword;
8834 cmdline_fixed_string_t name;
8835 cmdline_fixed_string_t on_off;
8839 cmd_set_record_core_cycles_parsed(void *parsed_result,
8840 __rte_unused struct cmdline *cl,
8841 __rte_unused void *data)
8843 struct cmd_set_record_core_cycles_result *res;
8844 uint16_t on_off = 0;
8846 res = parsed_result;
8847 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8848 set_record_core_cycles(on_off);
8851 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8852 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8854 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8855 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8856 name, "record-core-cycles");
8857 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8858 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8861 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8862 .f = cmd_set_record_core_cycles_parsed,
8864 .help_str = "set record-core-cycles on|off",
8866 (void *)&cmd_set_record_core_cycles_keyword,
8867 (void *)&cmd_set_record_core_cycles_name,
8868 (void *)&cmd_set_record_core_cycles_on_off,
8873 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8874 struct cmd_set_record_burst_stats_result {
8875 cmdline_fixed_string_t keyword;
8876 cmdline_fixed_string_t name;
8877 cmdline_fixed_string_t on_off;
8881 cmd_set_record_burst_stats_parsed(void *parsed_result,
8882 __rte_unused struct cmdline *cl,
8883 __rte_unused void *data)
8885 struct cmd_set_record_burst_stats_result *res;
8886 uint16_t on_off = 0;
8888 res = parsed_result;
8889 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8890 set_record_burst_stats(on_off);
8893 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8894 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8896 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8897 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8898 name, "record-burst-stats");
8899 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8900 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8903 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8904 .f = cmd_set_record_burst_stats_parsed,
8906 .help_str = "set record-burst-stats on|off",
8908 (void *)&cmd_set_record_burst_stats_keyword,
8909 (void *)&cmd_set_record_burst_stats_name,
8910 (void *)&cmd_set_record_burst_stats_on_off,
8915 /* *** CONFIGURE UNICAST HASH TABLE *** */
8916 struct cmd_set_uc_hash_table {
8917 cmdline_fixed_string_t set;
8918 cmdline_fixed_string_t port;
8920 cmdline_fixed_string_t what;
8921 struct rte_ether_addr address;
8922 cmdline_fixed_string_t mode;
8926 cmd_set_uc_hash_parsed(void *parsed_result,
8927 __rte_unused struct cmdline *cl,
8928 __rte_unused void *data)
8931 struct cmd_set_uc_hash_table *res = parsed_result;
8933 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8935 if (strcmp(res->what, "uta") == 0)
8936 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8937 &res->address,(uint8_t)is_on);
8940 "bad unicast hash table parameter, return code = %d\n",
8945 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8946 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8948 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8949 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8951 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8952 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8953 port_id, RTE_UINT16);
8954 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8955 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8957 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8958 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8960 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8961 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8964 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8965 .f = cmd_set_uc_hash_parsed,
8967 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8969 (void *)&cmd_set_uc_hash_set,
8970 (void *)&cmd_set_uc_hash_port,
8971 (void *)&cmd_set_uc_hash_portid,
8972 (void *)&cmd_set_uc_hash_what,
8973 (void *)&cmd_set_uc_hash_mac,
8974 (void *)&cmd_set_uc_hash_mode,
8979 struct cmd_set_uc_all_hash_table {
8980 cmdline_fixed_string_t set;
8981 cmdline_fixed_string_t port;
8983 cmdline_fixed_string_t what;
8984 cmdline_fixed_string_t value;
8985 cmdline_fixed_string_t mode;
8989 cmd_set_uc_all_hash_parsed(void *parsed_result,
8990 __rte_unused struct cmdline *cl,
8991 __rte_unused void *data)
8994 struct cmd_set_uc_all_hash_table *res = parsed_result;
8996 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8998 if ((strcmp(res->what, "uta") == 0) &&
8999 (strcmp(res->value, "all") == 0))
9000 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9003 "bad unicast hash table parameter, return code = %d\n",
9007 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9008 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9010 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9011 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9013 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9014 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9015 port_id, RTE_UINT16);
9016 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9017 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9019 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9020 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9022 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9023 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9026 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9027 .f = cmd_set_uc_all_hash_parsed,
9029 .help_str = "set port <port_id> uta all on|off",
9031 (void *)&cmd_set_uc_all_hash_set,
9032 (void *)&cmd_set_uc_all_hash_port,
9033 (void *)&cmd_set_uc_all_hash_portid,
9034 (void *)&cmd_set_uc_all_hash_what,
9035 (void *)&cmd_set_uc_all_hash_value,
9036 (void *)&cmd_set_uc_all_hash_mode,
9041 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9042 struct cmd_set_vf_traffic {
9043 cmdline_fixed_string_t set;
9044 cmdline_fixed_string_t port;
9046 cmdline_fixed_string_t vf;
9048 cmdline_fixed_string_t what;
9049 cmdline_fixed_string_t mode;
9053 cmd_set_vf_traffic_parsed(void *parsed_result,
9054 __rte_unused struct cmdline *cl,
9055 __rte_unused void *data)
9057 struct cmd_set_vf_traffic *res = parsed_result;
9058 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9059 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9061 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9064 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9065 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9067 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9068 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9070 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9071 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9072 port_id, RTE_UINT16);
9073 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9074 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9076 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9077 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9079 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9080 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9082 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9083 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9086 cmdline_parse_inst_t cmd_set_vf_traffic = {
9087 .f = cmd_set_vf_traffic_parsed,
9089 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9091 (void *)&cmd_setvf_traffic_set,
9092 (void *)&cmd_setvf_traffic_port,
9093 (void *)&cmd_setvf_traffic_portid,
9094 (void *)&cmd_setvf_traffic_vf,
9095 (void *)&cmd_setvf_traffic_vfid,
9096 (void *)&cmd_setvf_traffic_what,
9097 (void *)&cmd_setvf_traffic_mode,
9102 /* *** CONFIGURE VF RECEIVE MODE *** */
9103 struct cmd_set_vf_rxmode {
9104 cmdline_fixed_string_t set;
9105 cmdline_fixed_string_t port;
9107 cmdline_fixed_string_t vf;
9109 cmdline_fixed_string_t what;
9110 cmdline_fixed_string_t mode;
9111 cmdline_fixed_string_t on;
9115 cmd_set_vf_rxmode_parsed(void *parsed_result,
9116 __rte_unused struct cmdline *cl,
9117 __rte_unused void *data)
9120 uint16_t vf_rxmode = 0;
9121 struct cmd_set_vf_rxmode *res = parsed_result;
9123 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9124 if (!strcmp(res->what,"rxmode")) {
9125 if (!strcmp(res->mode, "AUPE"))
9126 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
9127 else if (!strcmp(res->mode, "ROPE"))
9128 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
9129 else if (!strcmp(res->mode, "BAM"))
9130 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
9131 else if (!strncmp(res->mode, "MPE",3))
9132 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
9135 RTE_SET_USED(is_on);
9137 #ifdef RTE_NET_IXGBE
9138 if (ret == -ENOTSUP)
9139 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9140 vf_rxmode, (uint8_t)is_on);
9143 if (ret == -ENOTSUP)
9144 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9145 vf_rxmode, (uint8_t)is_on);
9149 "bad VF receive mode parameter, return code = %d\n",
9153 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9154 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9156 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9157 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9159 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9160 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9161 port_id, RTE_UINT16);
9162 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9163 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9165 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9166 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9168 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9169 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9171 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9172 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9173 mode, "AUPE#ROPE#BAM#MPE");
9174 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9175 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9178 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9179 .f = cmd_set_vf_rxmode_parsed,
9181 .help_str = "set port <port_id> vf <vf_id> rxmode "
9182 "AUPE|ROPE|BAM|MPE on|off",
9184 (void *)&cmd_set_vf_rxmode_set,
9185 (void *)&cmd_set_vf_rxmode_port,
9186 (void *)&cmd_set_vf_rxmode_portid,
9187 (void *)&cmd_set_vf_rxmode_vf,
9188 (void *)&cmd_set_vf_rxmode_vfid,
9189 (void *)&cmd_set_vf_rxmode_what,
9190 (void *)&cmd_set_vf_rxmode_mode,
9191 (void *)&cmd_set_vf_rxmode_on,
9196 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9197 struct cmd_vf_mac_addr_result {
9198 cmdline_fixed_string_t mac_addr_cmd;
9199 cmdline_fixed_string_t what;
9200 cmdline_fixed_string_t port;
9202 cmdline_fixed_string_t vf;
9204 struct rte_ether_addr address;
9207 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9208 __rte_unused struct cmdline *cl,
9209 __rte_unused void *data)
9211 struct cmd_vf_mac_addr_result *res = parsed_result;
9214 if (strcmp(res->what, "add") != 0)
9218 if (ret == -ENOTSUP)
9219 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9223 if (ret == -ENOTSUP)
9224 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9229 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9233 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9234 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9235 mac_addr_cmd,"mac_addr");
9236 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9237 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9239 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9240 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9242 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9243 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9244 port_num, RTE_UINT16);
9245 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9246 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9248 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9249 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9251 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9252 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9255 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9256 .f = cmd_vf_mac_addr_parsed,
9258 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9259 "Add MAC address filtering for a VF on port_id",
9261 (void *)&cmd_vf_mac_addr_cmd,
9262 (void *)&cmd_vf_mac_addr_what,
9263 (void *)&cmd_vf_mac_addr_port,
9264 (void *)&cmd_vf_mac_addr_portnum,
9265 (void *)&cmd_vf_mac_addr_vf,
9266 (void *)&cmd_vf_mac_addr_vfnum,
9267 (void *)&cmd_vf_mac_addr_addr,
9272 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9273 struct cmd_vf_rx_vlan_filter {
9274 cmdline_fixed_string_t rx_vlan;
9275 cmdline_fixed_string_t what;
9277 cmdline_fixed_string_t port;
9279 cmdline_fixed_string_t vf;
9284 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9285 __rte_unused struct cmdline *cl,
9286 __rte_unused void *data)
9288 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9291 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9293 #ifdef RTE_NET_IXGBE
9294 if (ret == -ENOTSUP)
9295 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9296 res->vlan_id, res->vf_mask, is_add);
9299 if (ret == -ENOTSUP)
9300 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9301 res->vlan_id, res->vf_mask, is_add);
9304 if (ret == -ENOTSUP)
9305 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9306 res->vlan_id, res->vf_mask, is_add);
9313 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9314 res->vlan_id, res->vf_mask);
9317 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9320 fprintf(stderr, "function not implemented or supported\n");
9323 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9327 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9328 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9329 rx_vlan, "rx_vlan");
9330 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9331 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9333 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9334 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9335 vlan_id, RTE_UINT16);
9336 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9337 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9339 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9340 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9341 port_id, RTE_UINT16);
9342 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9343 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9345 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9346 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9347 vf_mask, RTE_UINT64);
9349 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9350 .f = cmd_vf_rx_vlan_filter_parsed,
9352 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9353 "(vf_mask = hexadecimal VF mask)",
9355 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9356 (void *)&cmd_vf_rx_vlan_filter_what,
9357 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9358 (void *)&cmd_vf_rx_vlan_filter_port,
9359 (void *)&cmd_vf_rx_vlan_filter_portid,
9360 (void *)&cmd_vf_rx_vlan_filter_vf,
9361 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9366 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9367 struct cmd_queue_rate_limit_result {
9368 cmdline_fixed_string_t set;
9369 cmdline_fixed_string_t port;
9371 cmdline_fixed_string_t queue;
9373 cmdline_fixed_string_t rate;
9377 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9378 __rte_unused struct cmdline *cl,
9379 __rte_unused void *data)
9381 struct cmd_queue_rate_limit_result *res = parsed_result;
9384 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9385 && (strcmp(res->queue, "queue") == 0)
9386 && (strcmp(res->rate, "rate") == 0))
9387 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9390 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9395 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9396 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9398 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9399 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9401 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9402 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9403 port_num, RTE_UINT16);
9404 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9405 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9407 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9408 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9409 queue_num, RTE_UINT8);
9410 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9411 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9413 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9414 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9415 rate_num, RTE_UINT16);
9417 cmdline_parse_inst_t cmd_queue_rate_limit = {
9418 .f = cmd_queue_rate_limit_parsed,
9420 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9421 "Set rate limit for a queue on port_id",
9423 (void *)&cmd_queue_rate_limit_set,
9424 (void *)&cmd_queue_rate_limit_port,
9425 (void *)&cmd_queue_rate_limit_portnum,
9426 (void *)&cmd_queue_rate_limit_queue,
9427 (void *)&cmd_queue_rate_limit_queuenum,
9428 (void *)&cmd_queue_rate_limit_rate,
9429 (void *)&cmd_queue_rate_limit_ratenum,
9434 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9435 struct cmd_vf_rate_limit_result {
9436 cmdline_fixed_string_t set;
9437 cmdline_fixed_string_t port;
9439 cmdline_fixed_string_t vf;
9441 cmdline_fixed_string_t rate;
9443 cmdline_fixed_string_t q_msk;
9447 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9448 __rte_unused struct cmdline *cl,
9449 __rte_unused void *data)
9451 struct cmd_vf_rate_limit_result *res = parsed_result;
9454 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9455 && (strcmp(res->vf, "vf") == 0)
9456 && (strcmp(res->rate, "rate") == 0)
9457 && (strcmp(res->q_msk, "queue_mask") == 0))
9458 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9459 res->rate_num, res->q_msk_val);
9461 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9466 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9467 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9469 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9470 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9472 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9473 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9474 port_num, RTE_UINT16);
9475 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9476 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9478 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9479 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9481 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9482 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9484 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9485 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9486 rate_num, RTE_UINT16);
9487 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9488 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9489 q_msk, "queue_mask");
9490 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9491 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9492 q_msk_val, RTE_UINT64);
9494 cmdline_parse_inst_t cmd_vf_rate_limit = {
9495 .f = cmd_vf_rate_limit_parsed,
9497 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9498 "queue_mask <queue_mask_value>: "
9499 "Set rate limit for queues of VF on port_id",
9501 (void *)&cmd_vf_rate_limit_set,
9502 (void *)&cmd_vf_rate_limit_port,
9503 (void *)&cmd_vf_rate_limit_portnum,
9504 (void *)&cmd_vf_rate_limit_vf,
9505 (void *)&cmd_vf_rate_limit_vfnum,
9506 (void *)&cmd_vf_rate_limit_rate,
9507 (void *)&cmd_vf_rate_limit_ratenum,
9508 (void *)&cmd_vf_rate_limit_q_msk,
9509 (void *)&cmd_vf_rate_limit_q_msk_val,
9514 /* *** CONFIGURE TUNNEL UDP PORT *** */
9515 struct cmd_tunnel_udp_config {
9516 cmdline_fixed_string_t rx_vxlan_port;
9517 cmdline_fixed_string_t what;
9523 cmd_tunnel_udp_config_parsed(void *parsed_result,
9524 __rte_unused struct cmdline *cl,
9525 __rte_unused void *data)
9527 struct cmd_tunnel_udp_config *res = parsed_result;
9528 struct rte_eth_udp_tunnel tunnel_udp;
9531 tunnel_udp.udp_port = res->udp_port;
9532 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9534 if (!strcmp(res->what, "add"))
9535 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9538 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9542 fprintf(stderr, "udp tunneling add error: (%s)\n",
9546 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9547 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9548 rx_vxlan_port, "rx_vxlan_port");
9549 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9550 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9552 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9553 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9554 udp_port, RTE_UINT16);
9555 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9556 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9557 port_id, RTE_UINT16);
9559 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9560 .f = cmd_tunnel_udp_config_parsed,
9562 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9563 "Add/Remove a tunneling UDP port filter",
9565 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9566 (void *)&cmd_tunnel_udp_config_what,
9567 (void *)&cmd_tunnel_udp_config_udp_port,
9568 (void *)&cmd_tunnel_udp_config_port_id,
9573 struct cmd_config_tunnel_udp_port {
9574 cmdline_fixed_string_t port;
9575 cmdline_fixed_string_t config;
9577 cmdline_fixed_string_t udp_tunnel_port;
9578 cmdline_fixed_string_t action;
9579 cmdline_fixed_string_t tunnel_type;
9584 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9585 __rte_unused struct cmdline *cl,
9586 __rte_unused void *data)
9588 struct cmd_config_tunnel_udp_port *res = parsed_result;
9589 struct rte_eth_udp_tunnel tunnel_udp;
9592 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9595 tunnel_udp.udp_port = res->udp_port;
9597 if (!strcmp(res->tunnel_type, "vxlan")) {
9598 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9599 } else if (!strcmp(res->tunnel_type, "geneve")) {
9600 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9601 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9602 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9603 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9604 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9606 fprintf(stderr, "Invalid tunnel type\n");
9610 if (!strcmp(res->action, "add"))
9611 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9614 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9618 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9622 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9623 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9625 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9626 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9628 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9629 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9631 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9632 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9635 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9636 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9638 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9639 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9640 "vxlan#geneve#vxlan-gpe#ecpri");
9641 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9642 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9645 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9646 .f = cmd_cfg_tunnel_udp_port_parsed,
9648 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9649 "geneve|vxlan-gpe|ecpri <udp_port>",
9651 (void *)&cmd_config_tunnel_udp_port_port,
9652 (void *)&cmd_config_tunnel_udp_port_config,
9653 (void *)&cmd_config_tunnel_udp_port_port_id,
9654 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9655 (void *)&cmd_config_tunnel_udp_port_action,
9656 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9657 (void *)&cmd_config_tunnel_udp_port_value,
9662 /* ******************************************************************************** */
9664 struct cmd_dump_result {
9665 cmdline_fixed_string_t dump;
9669 dump_struct_sizes(void)
9671 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9672 DUMP_SIZE(struct rte_mbuf);
9673 DUMP_SIZE(struct rte_mempool);
9674 DUMP_SIZE(struct rte_ring);
9679 /* Dump the socket memory statistics on console */
9681 dump_socket_mem(FILE *f)
9683 struct rte_malloc_socket_stats socket_stats;
9688 unsigned int n_alloc = 0;
9689 unsigned int n_free = 0;
9690 static size_t last_allocs;
9691 static size_t last_total;
9694 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9695 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9696 !socket_stats.heap_totalsz_bytes)
9698 total += socket_stats.heap_totalsz_bytes;
9699 alloc += socket_stats.heap_allocsz_bytes;
9700 free += socket_stats.heap_freesz_bytes;
9701 n_alloc += socket_stats.alloc_count;
9702 n_free += socket_stats.free_count;
9704 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9706 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9707 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9708 (double)socket_stats.heap_allocsz_bytes * 100 /
9709 (double)socket_stats.heap_totalsz_bytes,
9710 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9711 socket_stats.alloc_count,
9712 socket_stats.free_count);
9715 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9716 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9717 total ? ((double)alloc * 100 / (double)total) : 0,
9718 (double)free / (1024 * 1024),
9721 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9722 ((double)total - (double)last_total) / (1024 * 1024),
9723 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9724 last_allocs = alloc;
9728 static void cmd_dump_parsed(void *parsed_result,
9729 __rte_unused struct cmdline *cl,
9730 __rte_unused void *data)
9732 struct cmd_dump_result *res = parsed_result;
9734 if (!strcmp(res->dump, "dump_physmem"))
9735 rte_dump_physmem_layout(stdout);
9736 else if (!strcmp(res->dump, "dump_socket_mem"))
9737 dump_socket_mem(stdout);
9738 else if (!strcmp(res->dump, "dump_memzone"))
9739 rte_memzone_dump(stdout);
9740 else if (!strcmp(res->dump, "dump_struct_sizes"))
9741 dump_struct_sizes();
9742 else if (!strcmp(res->dump, "dump_ring"))
9743 rte_ring_list_dump(stdout);
9744 else if (!strcmp(res->dump, "dump_mempool"))
9745 rte_mempool_list_dump(stdout);
9746 else if (!strcmp(res->dump, "dump_devargs"))
9747 rte_devargs_dump(stdout);
9748 else if (!strcmp(res->dump, "dump_log_types"))
9749 rte_log_dump(stdout);
9752 cmdline_parse_token_string_t cmd_dump_dump =
9753 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9757 "dump_struct_sizes#"
9763 cmdline_parse_inst_t cmd_dump = {
9764 .f = cmd_dump_parsed, /* function to call */
9765 .data = NULL, /* 2nd arg of func */
9766 .help_str = "Dump status",
9767 .tokens = { /* token list, NULL terminated */
9768 (void *)&cmd_dump_dump,
9773 /* ******************************************************************************** */
9775 struct cmd_dump_one_result {
9776 cmdline_fixed_string_t dump;
9777 cmdline_fixed_string_t name;
9780 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9781 __rte_unused void *data)
9783 struct cmd_dump_one_result *res = parsed_result;
9785 if (!strcmp(res->dump, "dump_ring")) {
9787 r = rte_ring_lookup(res->name);
9789 cmdline_printf(cl, "Cannot find ring\n");
9792 rte_ring_dump(stdout, r);
9793 } else if (!strcmp(res->dump, "dump_mempool")) {
9794 struct rte_mempool *mp;
9795 mp = rte_mempool_lookup(res->name);
9797 cmdline_printf(cl, "Cannot find mempool\n");
9800 rte_mempool_dump(stdout, mp);
9804 cmdline_parse_token_string_t cmd_dump_one_dump =
9805 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9806 "dump_ring#dump_mempool");
9808 cmdline_parse_token_string_t cmd_dump_one_name =
9809 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9811 cmdline_parse_inst_t cmd_dump_one = {
9812 .f = cmd_dump_one_parsed, /* function to call */
9813 .data = NULL, /* 2nd arg of func */
9814 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9815 .tokens = { /* token list, NULL terminated */
9816 (void *)&cmd_dump_one_dump,
9817 (void *)&cmd_dump_one_name,
9822 /* *** queue region set *** */
9823 struct cmd_queue_region_result {
9824 cmdline_fixed_string_t set;
9825 cmdline_fixed_string_t port;
9827 cmdline_fixed_string_t cmd;
9828 cmdline_fixed_string_t region;
9830 cmdline_fixed_string_t queue_start_index;
9832 cmdline_fixed_string_t queue_num;
9833 uint8_t queue_num_value;
9837 cmd_queue_region_parsed(void *parsed_result,
9838 __rte_unused struct cmdline *cl,
9839 __rte_unused void *data)
9841 struct cmd_queue_region_result *res = parsed_result;
9844 struct rte_pmd_i40e_queue_region_conf region_conf;
9845 enum rte_pmd_i40e_queue_region_op op_type;
9848 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9852 memset(®ion_conf, 0, sizeof(region_conf));
9853 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9854 region_conf.region_id = res->region_id;
9855 region_conf.queue_num = res->queue_num_value;
9856 region_conf.queue_start_index = res->queue_id;
9858 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9859 op_type, ®ion_conf);
9866 fprintf(stderr, "function not implemented or supported\n");
9869 fprintf(stderr, "queue region config error: (%s)\n",
9874 cmdline_parse_token_string_t cmd_queue_region_set =
9875 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9877 cmdline_parse_token_string_t cmd_queue_region_port =
9878 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9879 cmdline_parse_token_num_t cmd_queue_region_port_id =
9880 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9881 port_id, RTE_UINT16);
9882 cmdline_parse_token_string_t cmd_queue_region_cmd =
9883 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9884 cmd, "queue-region");
9885 cmdline_parse_token_string_t cmd_queue_region_id =
9886 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9887 region, "region_id");
9888 cmdline_parse_token_num_t cmd_queue_region_index =
9889 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9890 region_id, RTE_UINT8);
9891 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9892 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9893 queue_start_index, "queue_start_index");
9894 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9895 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9896 queue_id, RTE_UINT8);
9897 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9898 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9899 queue_num, "queue_num");
9900 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9901 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9902 queue_num_value, RTE_UINT8);
9904 cmdline_parse_inst_t cmd_queue_region = {
9905 .f = cmd_queue_region_parsed,
9907 .help_str = "set port <port_id> queue-region region_id <value> "
9908 "queue_start_index <value> queue_num <value>: Set a queue region",
9910 (void *)&cmd_queue_region_set,
9911 (void *)&cmd_queue_region_port,
9912 (void *)&cmd_queue_region_port_id,
9913 (void *)&cmd_queue_region_cmd,
9914 (void *)&cmd_queue_region_id,
9915 (void *)&cmd_queue_region_index,
9916 (void *)&cmd_queue_region_queue_start_index,
9917 (void *)&cmd_queue_region_queue_id,
9918 (void *)&cmd_queue_region_queue_num,
9919 (void *)&cmd_queue_region_queue_num_value,
9924 /* *** queue region and flowtype set *** */
9925 struct cmd_region_flowtype_result {
9926 cmdline_fixed_string_t set;
9927 cmdline_fixed_string_t port;
9929 cmdline_fixed_string_t cmd;
9930 cmdline_fixed_string_t region;
9932 cmdline_fixed_string_t flowtype;
9933 uint8_t flowtype_id;
9937 cmd_region_flowtype_parsed(void *parsed_result,
9938 __rte_unused struct cmdline *cl,
9939 __rte_unused void *data)
9941 struct cmd_region_flowtype_result *res = parsed_result;
9944 struct rte_pmd_i40e_queue_region_conf region_conf;
9945 enum rte_pmd_i40e_queue_region_op op_type;
9948 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9952 memset(®ion_conf, 0, sizeof(region_conf));
9954 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9955 region_conf.region_id = res->region_id;
9956 region_conf.hw_flowtype = res->flowtype_id;
9958 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9959 op_type, ®ion_conf);
9966 fprintf(stderr, "function not implemented or supported\n");
9969 fprintf(stderr, "region flowtype config error: (%s)\n",
9974 cmdline_parse_token_string_t cmd_region_flowtype_set =
9975 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9977 cmdline_parse_token_string_t cmd_region_flowtype_port =
9978 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9980 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9981 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9982 port_id, RTE_UINT16);
9983 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9984 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9985 cmd, "queue-region");
9986 cmdline_parse_token_string_t cmd_region_flowtype_index =
9987 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9988 region, "region_id");
9989 cmdline_parse_token_num_t cmd_region_flowtype_id =
9990 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9991 region_id, RTE_UINT8);
9992 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9993 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9994 flowtype, "flowtype");
9995 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9996 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9997 flowtype_id, RTE_UINT8);
9998 cmdline_parse_inst_t cmd_region_flowtype = {
9999 .f = cmd_region_flowtype_parsed,
10001 .help_str = "set port <port_id> queue-region region_id <value> "
10002 "flowtype <value>: Set a flowtype region index",
10004 (void *)&cmd_region_flowtype_set,
10005 (void *)&cmd_region_flowtype_port,
10006 (void *)&cmd_region_flowtype_port_index,
10007 (void *)&cmd_region_flowtype_cmd,
10008 (void *)&cmd_region_flowtype_index,
10009 (void *)&cmd_region_flowtype_id,
10010 (void *)&cmd_region_flowtype_flow_index,
10011 (void *)&cmd_region_flowtype_flow_id,
10016 /* *** User Priority (UP) to queue region (region_id) set *** */
10017 struct cmd_user_priority_region_result {
10018 cmdline_fixed_string_t set;
10019 cmdline_fixed_string_t port;
10021 cmdline_fixed_string_t cmd;
10022 cmdline_fixed_string_t user_priority;
10023 uint8_t user_priority_id;
10024 cmdline_fixed_string_t region;
10029 cmd_user_priority_region_parsed(void *parsed_result,
10030 __rte_unused struct cmdline *cl,
10031 __rte_unused void *data)
10033 struct cmd_user_priority_region_result *res = parsed_result;
10034 int ret = -ENOTSUP;
10035 #ifdef RTE_NET_I40E
10036 struct rte_pmd_i40e_queue_region_conf region_conf;
10037 enum rte_pmd_i40e_queue_region_op op_type;
10040 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10043 #ifdef RTE_NET_I40E
10044 memset(®ion_conf, 0, sizeof(region_conf));
10045 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10046 region_conf.user_priority = res->user_priority_id;
10047 region_conf.region_id = res->region_id;
10049 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10050 op_type, ®ion_conf);
10057 fprintf(stderr, "function not implemented or supported\n");
10060 fprintf(stderr, "user_priority region config error: (%s)\n",
10065 cmdline_parse_token_string_t cmd_user_priority_region_set =
10066 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10068 cmdline_parse_token_string_t cmd_user_priority_region_port =
10069 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10071 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10072 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10073 port_id, RTE_UINT16);
10074 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10075 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10076 cmd, "queue-region");
10077 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10078 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10079 user_priority, "UP");
10080 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10081 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10082 user_priority_id, RTE_UINT8);
10083 cmdline_parse_token_string_t cmd_user_priority_region_region =
10084 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10085 region, "region_id");
10086 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10087 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10088 region_id, RTE_UINT8);
10090 cmdline_parse_inst_t cmd_user_priority_region = {
10091 .f = cmd_user_priority_region_parsed,
10093 .help_str = "set port <port_id> queue-region UP <value> "
10094 "region_id <value>: Set the mapping of User Priority (UP) "
10095 "to queue region (region_id) ",
10097 (void *)&cmd_user_priority_region_set,
10098 (void *)&cmd_user_priority_region_port,
10099 (void *)&cmd_user_priority_region_port_index,
10100 (void *)&cmd_user_priority_region_cmd,
10101 (void *)&cmd_user_priority_region_UP,
10102 (void *)&cmd_user_priority_region_UP_id,
10103 (void *)&cmd_user_priority_region_region,
10104 (void *)&cmd_user_priority_region_region_id,
10109 /* *** flush all queue region related configuration *** */
10110 struct cmd_flush_queue_region_result {
10111 cmdline_fixed_string_t set;
10112 cmdline_fixed_string_t port;
10114 cmdline_fixed_string_t cmd;
10115 cmdline_fixed_string_t flush;
10116 cmdline_fixed_string_t what;
10120 cmd_flush_queue_region_parsed(void *parsed_result,
10121 __rte_unused struct cmdline *cl,
10122 __rte_unused void *data)
10124 struct cmd_flush_queue_region_result *res = parsed_result;
10125 int ret = -ENOTSUP;
10126 #ifdef RTE_NET_I40E
10127 struct rte_pmd_i40e_queue_region_conf region_conf;
10128 enum rte_pmd_i40e_queue_region_op op_type;
10131 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10134 #ifdef RTE_NET_I40E
10135 memset(®ion_conf, 0, sizeof(region_conf));
10137 if (strcmp(res->what, "on") == 0)
10138 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10140 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10142 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10143 op_type, ®ion_conf);
10150 fprintf(stderr, "function not implemented or supported\n");
10153 fprintf(stderr, "queue region config flush error: (%s)\n",
10158 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10159 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10161 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10162 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10164 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10165 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10166 port_id, RTE_UINT16);
10167 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10168 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10169 cmd, "queue-region");
10170 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10171 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10173 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10174 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10177 cmdline_parse_inst_t cmd_flush_queue_region = {
10178 .f = cmd_flush_queue_region_parsed,
10180 .help_str = "set port <port_id> queue-region flush on|off"
10181 ": flush all queue region related configuration",
10183 (void *)&cmd_flush_queue_region_set,
10184 (void *)&cmd_flush_queue_region_port,
10185 (void *)&cmd_flush_queue_region_port_index,
10186 (void *)&cmd_flush_queue_region_cmd,
10187 (void *)&cmd_flush_queue_region_flush,
10188 (void *)&cmd_flush_queue_region_what,
10193 /* *** get all queue region related configuration info *** */
10194 struct cmd_show_queue_region_info {
10195 cmdline_fixed_string_t show;
10196 cmdline_fixed_string_t port;
10198 cmdline_fixed_string_t cmd;
10202 cmd_show_queue_region_info_parsed(void *parsed_result,
10203 __rte_unused struct cmdline *cl,
10204 __rte_unused void *data)
10206 struct cmd_show_queue_region_info *res = parsed_result;
10207 int ret = -ENOTSUP;
10208 #ifdef RTE_NET_I40E
10209 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10210 enum rte_pmd_i40e_queue_region_op op_type;
10213 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10216 #ifdef RTE_NET_I40E
10217 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10219 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10221 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10222 op_type, &rte_pmd_regions);
10224 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10231 fprintf(stderr, "function not implemented or supported\n");
10234 fprintf(stderr, "queue region config info show error: (%s)\n",
10239 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10240 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10242 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10243 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10245 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10246 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10247 port_id, RTE_UINT16);
10248 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10249 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10250 cmd, "queue-region");
10252 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10253 .f = cmd_show_queue_region_info_parsed,
10255 .help_str = "show port <port_id> queue-region"
10256 ": show all queue region related configuration info",
10258 (void *)&cmd_show_queue_region_info_get,
10259 (void *)&cmd_show_queue_region_info_port,
10260 (void *)&cmd_show_queue_region_info_port_index,
10261 (void *)&cmd_show_queue_region_info_cmd,
10266 /* *** Filters Control *** */
10268 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10270 if ((ip_addr).family == AF_INET) \
10271 (ip) = (ip_addr).addr.ipv4.s_addr; \
10273 fprintf(stderr, "invalid parameter.\n"); \
10278 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10280 if ((ip_addr).family == AF_INET6) \
10281 rte_memcpy(&(ip), \
10282 &((ip_addr).addr.ipv6), \
10283 sizeof(struct in6_addr)); \
10285 fprintf(stderr, "invalid parameter.\n"); \
10290 #ifdef RTE_NET_I40E
10293 str2flowtype(char *string)
10296 static const struct {
10299 } flowtype_str[] = {
10300 {"raw", RTE_ETH_FLOW_RAW},
10301 {"ipv4", RTE_ETH_FLOW_IPV4},
10302 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10303 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10304 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10305 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10306 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10307 {"ipv6", RTE_ETH_FLOW_IPV6},
10308 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10309 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10310 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10311 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10312 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10313 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10316 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10317 if (!strcmp(flowtype_str[i].str, string))
10318 return flowtype_str[i].type;
10321 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10322 return (uint16_t)atoi(string);
10324 return RTE_ETH_FLOW_UNKNOWN;
10327 /* *** deal with flow director filter *** */
10328 struct cmd_flow_director_result {
10329 cmdline_fixed_string_t flow_director_filter;
10331 cmdline_fixed_string_t mode;
10332 cmdline_fixed_string_t mode_value;
10333 cmdline_fixed_string_t ops;
10334 cmdline_fixed_string_t flow;
10335 cmdline_fixed_string_t flow_type;
10336 cmdline_fixed_string_t drop;
10337 cmdline_fixed_string_t queue;
10339 cmdline_fixed_string_t fd_id;
10340 uint32_t fd_id_value;
10341 cmdline_fixed_string_t packet;
10346 cmd_flow_director_filter_parsed(void *parsed_result,
10347 __rte_unused struct cmdline *cl,
10348 __rte_unused void *data)
10350 struct cmd_flow_director_result *res = parsed_result;
10352 struct rte_pmd_i40e_flow_type_mapping
10353 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10354 struct rte_pmd_i40e_pkt_template_conf conf;
10355 uint16_t flow_type = str2flowtype(res->flow_type);
10356 uint16_t i, port = res->port_id;
10359 memset(&conf, 0, sizeof(conf));
10361 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10362 fprintf(stderr, "Invalid flow type specified.\n");
10365 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10369 if (mapping[flow_type].pctype == 0ULL) {
10370 fprintf(stderr, "Invalid flow type specified.\n");
10373 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10374 if (mapping[flow_type].pctype & (1ULL << i)) {
10375 conf.input.pctype = i;
10380 conf.input.packet = open_file(res->filepath,
10381 &conf.input.length);
10382 if (!conf.input.packet)
10384 if (!strcmp(res->drop, "drop"))
10385 conf.action.behavior =
10386 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10388 conf.action.behavior =
10389 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10390 conf.action.report_status =
10391 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10392 conf.action.rx_queue = res->queue_id;
10393 conf.soft_id = res->fd_id_value;
10394 add = strcmp(res->ops, "del") ? 1 : 0;
10395 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10399 fprintf(stderr, "flow director config error: (%s)\n",
10401 close_file(conf.input.packet);
10404 cmdline_parse_token_string_t cmd_flow_director_filter =
10405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10406 flow_director_filter, "flow_director_filter");
10407 cmdline_parse_token_num_t cmd_flow_director_port_id =
10408 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10409 port_id, RTE_UINT16);
10410 cmdline_parse_token_string_t cmd_flow_director_ops =
10411 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10412 ops, "add#del#update");
10413 cmdline_parse_token_string_t cmd_flow_director_flow =
10414 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10416 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10417 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10419 cmdline_parse_token_string_t cmd_flow_director_drop =
10420 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10422 cmdline_parse_token_string_t cmd_flow_director_queue =
10423 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10425 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10426 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10427 queue_id, RTE_UINT16);
10428 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10431 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10432 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10433 fd_id_value, RTE_UINT32);
10435 cmdline_parse_token_string_t cmd_flow_director_mode =
10436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10438 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10439 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10440 mode_value, "raw");
10441 cmdline_parse_token_string_t cmd_flow_director_packet =
10442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10444 cmdline_parse_token_string_t cmd_flow_director_filepath =
10445 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10448 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10449 .f = cmd_flow_director_filter_parsed,
10451 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10452 "director entry on NIC",
10454 (void *)&cmd_flow_director_filter,
10455 (void *)&cmd_flow_director_port_id,
10456 (void *)&cmd_flow_director_mode,
10457 (void *)&cmd_flow_director_mode_raw,
10458 (void *)&cmd_flow_director_ops,
10459 (void *)&cmd_flow_director_flow,
10460 (void *)&cmd_flow_director_flow_type,
10461 (void *)&cmd_flow_director_drop,
10462 (void *)&cmd_flow_director_queue,
10463 (void *)&cmd_flow_director_queue_id,
10464 (void *)&cmd_flow_director_fd_id,
10465 (void *)&cmd_flow_director_fd_id_value,
10466 (void *)&cmd_flow_director_packet,
10467 (void *)&cmd_flow_director_filepath,
10472 #endif /* RTE_NET_I40E */
10474 /* *** deal with flow director mask *** */
10475 struct cmd_flow_director_mask_result {
10476 cmdline_fixed_string_t flow_director_mask;
10478 cmdline_fixed_string_t mode;
10479 cmdline_fixed_string_t mode_value;
10480 cmdline_fixed_string_t vlan;
10481 uint16_t vlan_mask;
10482 cmdline_fixed_string_t src_mask;
10483 cmdline_ipaddr_t ipv4_src;
10484 cmdline_ipaddr_t ipv6_src;
10486 cmdline_fixed_string_t dst_mask;
10487 cmdline_ipaddr_t ipv4_dst;
10488 cmdline_ipaddr_t ipv6_dst;
10490 cmdline_fixed_string_t mac;
10491 uint8_t mac_addr_byte_mask;
10492 cmdline_fixed_string_t tunnel_id;
10493 uint32_t tunnel_id_mask;
10494 cmdline_fixed_string_t tunnel_type;
10495 uint8_t tunnel_type_mask;
10499 cmd_flow_director_mask_parsed(void *parsed_result,
10500 __rte_unused struct cmdline *cl,
10501 __rte_unused void *data)
10503 struct cmd_flow_director_mask_result *res = parsed_result;
10504 struct rte_eth_fdir_masks *mask;
10505 struct rte_port *port;
10507 port = &ports[res->port_id];
10508 /** Check if the port is not started **/
10509 if (port->port_status != RTE_PORT_STOPPED) {
10510 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10514 mask = &port->dev_conf.fdir_conf.mask;
10516 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10517 if (strcmp(res->mode_value, "MAC-VLAN")) {
10518 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10522 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10523 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10524 if (strcmp(res->mode_value, "Tunnel")) {
10525 fprintf(stderr, "Please set mode to Tunnel.\n");
10529 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10530 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10531 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10532 mask->tunnel_type_mask = res->tunnel_type_mask;
10534 if (strcmp(res->mode_value, "IP")) {
10535 fprintf(stderr, "Please set mode to IP.\n");
10539 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10540 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10541 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10542 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10543 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10544 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10545 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10548 cmd_reconfig_device_queue(res->port_id, 1, 1);
10551 cmdline_parse_token_string_t cmd_flow_director_mask =
10552 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10553 flow_director_mask, "flow_director_mask");
10554 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10555 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10556 port_id, RTE_UINT16);
10557 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10558 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10560 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10561 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10562 vlan_mask, RTE_UINT16);
10563 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10564 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10565 src_mask, "src_mask");
10566 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10567 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10569 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10570 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10572 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10573 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10574 port_src, RTE_UINT16);
10575 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10576 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10577 dst_mask, "dst_mask");
10578 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10579 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10581 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10582 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10584 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10585 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10586 port_dst, RTE_UINT16);
10588 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10589 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10591 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10592 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10594 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10595 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10596 mode_value, "MAC-VLAN");
10597 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10598 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10599 mode_value, "Tunnel");
10600 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10601 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10603 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10604 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10605 mac_addr_byte_mask, RTE_UINT8);
10606 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10607 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10608 tunnel_type, "tunnel-type");
10609 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10610 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10611 tunnel_type_mask, RTE_UINT8);
10612 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10613 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10614 tunnel_id, "tunnel-id");
10615 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10616 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10617 tunnel_id_mask, RTE_UINT32);
10619 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10620 .f = cmd_flow_director_mask_parsed,
10622 .help_str = "flow_director_mask ... : "
10623 "Set IP mode flow director's mask on NIC",
10625 (void *)&cmd_flow_director_mask,
10626 (void *)&cmd_flow_director_mask_port_id,
10627 (void *)&cmd_flow_director_mask_mode,
10628 (void *)&cmd_flow_director_mask_mode_ip,
10629 (void *)&cmd_flow_director_mask_vlan,
10630 (void *)&cmd_flow_director_mask_vlan_value,
10631 (void *)&cmd_flow_director_mask_src,
10632 (void *)&cmd_flow_director_mask_ipv4_src,
10633 (void *)&cmd_flow_director_mask_ipv6_src,
10634 (void *)&cmd_flow_director_mask_port_src,
10635 (void *)&cmd_flow_director_mask_dst,
10636 (void *)&cmd_flow_director_mask_ipv4_dst,
10637 (void *)&cmd_flow_director_mask_ipv6_dst,
10638 (void *)&cmd_flow_director_mask_port_dst,
10643 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10644 .f = cmd_flow_director_mask_parsed,
10646 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10647 "flow director's mask on NIC",
10649 (void *)&cmd_flow_director_mask,
10650 (void *)&cmd_flow_director_mask_port_id,
10651 (void *)&cmd_flow_director_mask_mode,
10652 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10653 (void *)&cmd_flow_director_mask_vlan,
10654 (void *)&cmd_flow_director_mask_vlan_value,
10659 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10660 .f = cmd_flow_director_mask_parsed,
10662 .help_str = "flow_director_mask ... : Set tunnel mode "
10663 "flow director's mask on NIC",
10665 (void *)&cmd_flow_director_mask,
10666 (void *)&cmd_flow_director_mask_port_id,
10667 (void *)&cmd_flow_director_mask_mode,
10668 (void *)&cmd_flow_director_mask_mode_tunnel,
10669 (void *)&cmd_flow_director_mask_vlan,
10670 (void *)&cmd_flow_director_mask_vlan_value,
10671 (void *)&cmd_flow_director_mask_mac,
10672 (void *)&cmd_flow_director_mask_mac_value,
10673 (void *)&cmd_flow_director_mask_tunnel_type,
10674 (void *)&cmd_flow_director_mask_tunnel_type_value,
10675 (void *)&cmd_flow_director_mask_tunnel_id,
10676 (void *)&cmd_flow_director_mask_tunnel_id_value,
10681 /* *** deal with flow director flexible payload configuration *** */
10682 struct cmd_flow_director_flexpayload_result {
10683 cmdline_fixed_string_t flow_director_flexpayload;
10685 cmdline_fixed_string_t payload_layer;
10686 cmdline_fixed_string_t payload_cfg;
10690 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10693 const char *p, *p0 = q_arg;
10695 unsigned long int_fld;
10696 char *str_fld[max_num];
10701 p = strchr(p0, '(');
10705 p0 = strchr(p, ')');
10710 if (size >= sizeof(s))
10713 snprintf(s, sizeof(s), "%.*s", size, p);
10714 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10715 if (ret < 0 || ret > max_num)
10717 for (i = 0; i < ret; i++) {
10719 int_fld = strtoul(str_fld[i], &end, 0);
10720 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10722 offsets[i] = (uint16_t)int_fld;
10728 cmd_flow_director_flxpld_parsed(void *parsed_result,
10729 __rte_unused struct cmdline *cl,
10730 __rte_unused void *data)
10732 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10733 struct rte_eth_flex_payload_cfg flex_cfg;
10734 struct rte_port *port;
10737 port = &ports[res->port_id];
10738 /** Check if the port is not started **/
10739 if (port->port_status != RTE_PORT_STOPPED) {
10740 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10744 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10746 if (!strcmp(res->payload_layer, "raw"))
10747 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10748 else if (!strcmp(res->payload_layer, "l2"))
10749 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10750 else if (!strcmp(res->payload_layer, "l3"))
10751 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10752 else if (!strcmp(res->payload_layer, "l4"))
10753 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10755 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10756 RTE_ETH_FDIR_MAX_FLEXLEN);
10758 fprintf(stderr, "error: Cannot parse flex payload input.\n");
10762 fdir_set_flex_payload(res->port_id, &flex_cfg);
10763 cmd_reconfig_device_queue(res->port_id, 1, 1);
10766 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10768 flow_director_flexpayload,
10769 "flow_director_flex_payload");
10770 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10771 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10772 port_id, RTE_UINT16);
10773 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10774 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10775 payload_layer, "raw#l2#l3#l4");
10776 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10777 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10778 payload_cfg, NULL);
10780 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10781 .f = cmd_flow_director_flxpld_parsed,
10783 .help_str = "flow_director_flexpayload ... : "
10784 "Set flow director's flex payload on NIC",
10786 (void *)&cmd_flow_director_flexpayload,
10787 (void *)&cmd_flow_director_flexpayload_port_id,
10788 (void *)&cmd_flow_director_flexpayload_payload_layer,
10789 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10794 /* Generic flow interface command. */
10795 extern cmdline_parse_inst_t cmd_flow;
10797 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10798 struct cmd_mcast_addr_result {
10799 cmdline_fixed_string_t mcast_addr_cmd;
10800 cmdline_fixed_string_t what;
10802 struct rte_ether_addr mc_addr;
10805 static void cmd_mcast_addr_parsed(void *parsed_result,
10806 __rte_unused struct cmdline *cl,
10807 __rte_unused void *data)
10809 struct cmd_mcast_addr_result *res = parsed_result;
10811 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10813 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
10814 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
10817 if (strcmp(res->what, "add") == 0)
10818 mcast_addr_add(res->port_num, &res->mc_addr);
10820 mcast_addr_remove(res->port_num, &res->mc_addr);
10823 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10824 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10825 mcast_addr_cmd, "mcast_addr");
10826 cmdline_parse_token_string_t cmd_mcast_addr_what =
10827 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10829 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10830 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10832 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10833 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10835 cmdline_parse_inst_t cmd_mcast_addr = {
10836 .f = cmd_mcast_addr_parsed,
10838 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10839 "Add/Remove multicast MAC address on port_id",
10841 (void *)&cmd_mcast_addr_cmd,
10842 (void *)&cmd_mcast_addr_what,
10843 (void *)&cmd_mcast_addr_portnum,
10844 (void *)&cmd_mcast_addr_addr,
10849 /* vf vlan anti spoof configuration */
10851 /* Common result structure for vf vlan anti spoof */
10852 struct cmd_vf_vlan_anti_spoof_result {
10853 cmdline_fixed_string_t set;
10854 cmdline_fixed_string_t vf;
10855 cmdline_fixed_string_t vlan;
10856 cmdline_fixed_string_t antispoof;
10859 cmdline_fixed_string_t on_off;
10862 /* Common CLI fields for vf vlan anti spoof enable disable */
10863 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10864 TOKEN_STRING_INITIALIZER
10865 (struct cmd_vf_vlan_anti_spoof_result,
10867 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10868 TOKEN_STRING_INITIALIZER
10869 (struct cmd_vf_vlan_anti_spoof_result,
10871 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10872 TOKEN_STRING_INITIALIZER
10873 (struct cmd_vf_vlan_anti_spoof_result,
10875 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10876 TOKEN_STRING_INITIALIZER
10877 (struct cmd_vf_vlan_anti_spoof_result,
10878 antispoof, "antispoof");
10879 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10880 TOKEN_NUM_INITIALIZER
10881 (struct cmd_vf_vlan_anti_spoof_result,
10882 port_id, RTE_UINT16);
10883 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10884 TOKEN_NUM_INITIALIZER
10885 (struct cmd_vf_vlan_anti_spoof_result,
10886 vf_id, RTE_UINT32);
10887 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10888 TOKEN_STRING_INITIALIZER
10889 (struct cmd_vf_vlan_anti_spoof_result,
10893 cmd_set_vf_vlan_anti_spoof_parsed(
10894 void *parsed_result,
10895 __rte_unused struct cmdline *cl,
10896 __rte_unused void *data)
10898 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10899 int ret = -ENOTSUP;
10901 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10903 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10906 #ifdef RTE_NET_IXGBE
10907 if (ret == -ENOTSUP)
10908 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10909 res->vf_id, is_on);
10911 #ifdef RTE_NET_I40E
10912 if (ret == -ENOTSUP)
10913 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10914 res->vf_id, is_on);
10916 #ifdef RTE_NET_BNXT
10917 if (ret == -ENOTSUP)
10918 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10919 res->vf_id, is_on);
10926 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
10929 fprintf(stderr, "invalid port_id %d\n", res->port_id);
10932 fprintf(stderr, "function not implemented\n");
10935 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10939 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10940 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10942 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10944 (void *)&cmd_vf_vlan_anti_spoof_set,
10945 (void *)&cmd_vf_vlan_anti_spoof_vf,
10946 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10947 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10948 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10949 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10950 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10955 /* vf mac anti spoof configuration */
10957 /* Common result structure for vf mac anti spoof */
10958 struct cmd_vf_mac_anti_spoof_result {
10959 cmdline_fixed_string_t set;
10960 cmdline_fixed_string_t vf;
10961 cmdline_fixed_string_t mac;
10962 cmdline_fixed_string_t antispoof;
10965 cmdline_fixed_string_t on_off;
10968 /* Common CLI fields for vf mac anti spoof enable disable */
10969 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10970 TOKEN_STRING_INITIALIZER
10971 (struct cmd_vf_mac_anti_spoof_result,
10973 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10974 TOKEN_STRING_INITIALIZER
10975 (struct cmd_vf_mac_anti_spoof_result,
10977 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10978 TOKEN_STRING_INITIALIZER
10979 (struct cmd_vf_mac_anti_spoof_result,
10981 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10982 TOKEN_STRING_INITIALIZER
10983 (struct cmd_vf_mac_anti_spoof_result,
10984 antispoof, "antispoof");
10985 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10986 TOKEN_NUM_INITIALIZER
10987 (struct cmd_vf_mac_anti_spoof_result,
10988 port_id, RTE_UINT16);
10989 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10990 TOKEN_NUM_INITIALIZER
10991 (struct cmd_vf_mac_anti_spoof_result,
10992 vf_id, RTE_UINT32);
10993 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10994 TOKEN_STRING_INITIALIZER
10995 (struct cmd_vf_mac_anti_spoof_result,
10999 cmd_set_vf_mac_anti_spoof_parsed(
11000 void *parsed_result,
11001 __rte_unused struct cmdline *cl,
11002 __rte_unused void *data)
11004 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11005 int ret = -ENOTSUP;
11007 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11009 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11012 #ifdef RTE_NET_IXGBE
11013 if (ret == -ENOTSUP)
11014 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11015 res->vf_id, is_on);
11017 #ifdef RTE_NET_I40E
11018 if (ret == -ENOTSUP)
11019 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11020 res->vf_id, is_on);
11022 #ifdef RTE_NET_BNXT
11023 if (ret == -ENOTSUP)
11024 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11025 res->vf_id, is_on);
11032 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11033 res->vf_id, is_on);
11036 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11039 fprintf(stderr, "function not implemented\n");
11042 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11046 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11047 .f = cmd_set_vf_mac_anti_spoof_parsed,
11049 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11051 (void *)&cmd_vf_mac_anti_spoof_set,
11052 (void *)&cmd_vf_mac_anti_spoof_vf,
11053 (void *)&cmd_vf_mac_anti_spoof_mac,
11054 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11055 (void *)&cmd_vf_mac_anti_spoof_port_id,
11056 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11057 (void *)&cmd_vf_mac_anti_spoof_on_off,
11062 /* vf vlan strip queue configuration */
11064 /* Common result structure for vf mac anti spoof */
11065 struct cmd_vf_vlan_stripq_result {
11066 cmdline_fixed_string_t set;
11067 cmdline_fixed_string_t vf;
11068 cmdline_fixed_string_t vlan;
11069 cmdline_fixed_string_t stripq;
11072 cmdline_fixed_string_t on_off;
11075 /* Common CLI fields for vf vlan strip enable disable */
11076 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11077 TOKEN_STRING_INITIALIZER
11078 (struct cmd_vf_vlan_stripq_result,
11080 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11081 TOKEN_STRING_INITIALIZER
11082 (struct cmd_vf_vlan_stripq_result,
11084 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11085 TOKEN_STRING_INITIALIZER
11086 (struct cmd_vf_vlan_stripq_result,
11088 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11089 TOKEN_STRING_INITIALIZER
11090 (struct cmd_vf_vlan_stripq_result,
11092 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11093 TOKEN_NUM_INITIALIZER
11094 (struct cmd_vf_vlan_stripq_result,
11095 port_id, RTE_UINT16);
11096 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11097 TOKEN_NUM_INITIALIZER
11098 (struct cmd_vf_vlan_stripq_result,
11099 vf_id, RTE_UINT16);
11100 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11101 TOKEN_STRING_INITIALIZER
11102 (struct cmd_vf_vlan_stripq_result,
11106 cmd_set_vf_vlan_stripq_parsed(
11107 void *parsed_result,
11108 __rte_unused struct cmdline *cl,
11109 __rte_unused void *data)
11111 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11112 int ret = -ENOTSUP;
11114 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11116 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11119 #ifdef RTE_NET_IXGBE
11120 if (ret == -ENOTSUP)
11121 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11122 res->vf_id, is_on);
11124 #ifdef RTE_NET_I40E
11125 if (ret == -ENOTSUP)
11126 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11127 res->vf_id, is_on);
11129 #ifdef RTE_NET_BNXT
11130 if (ret == -ENOTSUP)
11131 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11132 res->vf_id, is_on);
11139 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11140 res->vf_id, is_on);
11143 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11146 fprintf(stderr, "function not implemented\n");
11149 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11153 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11154 .f = cmd_set_vf_vlan_stripq_parsed,
11156 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11158 (void *)&cmd_vf_vlan_stripq_set,
11159 (void *)&cmd_vf_vlan_stripq_vf,
11160 (void *)&cmd_vf_vlan_stripq_vlan,
11161 (void *)&cmd_vf_vlan_stripq_stripq,
11162 (void *)&cmd_vf_vlan_stripq_port_id,
11163 (void *)&cmd_vf_vlan_stripq_vf_id,
11164 (void *)&cmd_vf_vlan_stripq_on_off,
11169 /* vf vlan insert configuration */
11171 /* Common result structure for vf vlan insert */
11172 struct cmd_vf_vlan_insert_result {
11173 cmdline_fixed_string_t set;
11174 cmdline_fixed_string_t vf;
11175 cmdline_fixed_string_t vlan;
11176 cmdline_fixed_string_t insert;
11182 /* Common CLI fields for vf vlan insert enable disable */
11183 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11184 TOKEN_STRING_INITIALIZER
11185 (struct cmd_vf_vlan_insert_result,
11187 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11188 TOKEN_STRING_INITIALIZER
11189 (struct cmd_vf_vlan_insert_result,
11191 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11192 TOKEN_STRING_INITIALIZER
11193 (struct cmd_vf_vlan_insert_result,
11195 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11196 TOKEN_STRING_INITIALIZER
11197 (struct cmd_vf_vlan_insert_result,
11199 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11200 TOKEN_NUM_INITIALIZER
11201 (struct cmd_vf_vlan_insert_result,
11202 port_id, RTE_UINT16);
11203 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11204 TOKEN_NUM_INITIALIZER
11205 (struct cmd_vf_vlan_insert_result,
11206 vf_id, RTE_UINT16);
11207 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11208 TOKEN_NUM_INITIALIZER
11209 (struct cmd_vf_vlan_insert_result,
11210 vlan_id, RTE_UINT16);
11213 cmd_set_vf_vlan_insert_parsed(
11214 void *parsed_result,
11215 __rte_unused struct cmdline *cl,
11216 __rte_unused void *data)
11218 struct cmd_vf_vlan_insert_result *res = parsed_result;
11219 int ret = -ENOTSUP;
11221 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11224 #ifdef RTE_NET_IXGBE
11225 if (ret == -ENOTSUP)
11226 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11229 #ifdef RTE_NET_I40E
11230 if (ret == -ENOTSUP)
11231 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11234 #ifdef RTE_NET_BNXT
11235 if (ret == -ENOTSUP)
11236 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11244 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11245 res->vf_id, res->vlan_id);
11248 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11251 fprintf(stderr, "function not implemented\n");
11254 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11258 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11259 .f = cmd_set_vf_vlan_insert_parsed,
11261 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11263 (void *)&cmd_vf_vlan_insert_set,
11264 (void *)&cmd_vf_vlan_insert_vf,
11265 (void *)&cmd_vf_vlan_insert_vlan,
11266 (void *)&cmd_vf_vlan_insert_insert,
11267 (void *)&cmd_vf_vlan_insert_port_id,
11268 (void *)&cmd_vf_vlan_insert_vf_id,
11269 (void *)&cmd_vf_vlan_insert_vlan_id,
11274 /* tx loopback configuration */
11276 /* Common result structure for tx loopback */
11277 struct cmd_tx_loopback_result {
11278 cmdline_fixed_string_t set;
11279 cmdline_fixed_string_t tx;
11280 cmdline_fixed_string_t loopback;
11282 cmdline_fixed_string_t on_off;
11285 /* Common CLI fields for tx loopback enable disable */
11286 cmdline_parse_token_string_t cmd_tx_loopback_set =
11287 TOKEN_STRING_INITIALIZER
11288 (struct cmd_tx_loopback_result,
11290 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11291 TOKEN_STRING_INITIALIZER
11292 (struct cmd_tx_loopback_result,
11294 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11295 TOKEN_STRING_INITIALIZER
11296 (struct cmd_tx_loopback_result,
11297 loopback, "loopback");
11298 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11299 TOKEN_NUM_INITIALIZER
11300 (struct cmd_tx_loopback_result,
11301 port_id, RTE_UINT16);
11302 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11303 TOKEN_STRING_INITIALIZER
11304 (struct cmd_tx_loopback_result,
11308 cmd_set_tx_loopback_parsed(
11309 void *parsed_result,
11310 __rte_unused struct cmdline *cl,
11311 __rte_unused void *data)
11313 struct cmd_tx_loopback_result *res = parsed_result;
11314 int ret = -ENOTSUP;
11316 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11318 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11321 #ifdef RTE_NET_IXGBE
11322 if (ret == -ENOTSUP)
11323 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11325 #ifdef RTE_NET_I40E
11326 if (ret == -ENOTSUP)
11327 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11329 #ifdef RTE_NET_BNXT
11330 if (ret == -ENOTSUP)
11331 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11333 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11334 if (ret == -ENOTSUP)
11335 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11342 fprintf(stderr, "invalid is_on %d\n", is_on);
11345 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11348 fprintf(stderr, "function not implemented\n");
11351 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11355 cmdline_parse_inst_t cmd_set_tx_loopback = {
11356 .f = cmd_set_tx_loopback_parsed,
11358 .help_str = "set tx loopback <port_id> on|off",
11360 (void *)&cmd_tx_loopback_set,
11361 (void *)&cmd_tx_loopback_tx,
11362 (void *)&cmd_tx_loopback_loopback,
11363 (void *)&cmd_tx_loopback_port_id,
11364 (void *)&cmd_tx_loopback_on_off,
11369 /* all queues drop enable configuration */
11371 /* Common result structure for all queues drop enable */
11372 struct cmd_all_queues_drop_en_result {
11373 cmdline_fixed_string_t set;
11374 cmdline_fixed_string_t all;
11375 cmdline_fixed_string_t queues;
11376 cmdline_fixed_string_t drop;
11378 cmdline_fixed_string_t on_off;
11381 /* Common CLI fields for tx loopback enable disable */
11382 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11383 TOKEN_STRING_INITIALIZER
11384 (struct cmd_all_queues_drop_en_result,
11386 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11387 TOKEN_STRING_INITIALIZER
11388 (struct cmd_all_queues_drop_en_result,
11390 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11391 TOKEN_STRING_INITIALIZER
11392 (struct cmd_all_queues_drop_en_result,
11394 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11395 TOKEN_STRING_INITIALIZER
11396 (struct cmd_all_queues_drop_en_result,
11398 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11399 TOKEN_NUM_INITIALIZER
11400 (struct cmd_all_queues_drop_en_result,
11401 port_id, RTE_UINT16);
11402 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11403 TOKEN_STRING_INITIALIZER
11404 (struct cmd_all_queues_drop_en_result,
11408 cmd_set_all_queues_drop_en_parsed(
11409 void *parsed_result,
11410 __rte_unused struct cmdline *cl,
11411 __rte_unused void *data)
11413 struct cmd_all_queues_drop_en_result *res = parsed_result;
11414 int ret = -ENOTSUP;
11415 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11417 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11420 #ifdef RTE_NET_IXGBE
11421 if (ret == -ENOTSUP)
11422 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11424 #ifdef RTE_NET_BNXT
11425 if (ret == -ENOTSUP)
11426 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11432 fprintf(stderr, "invalid is_on %d\n", is_on);
11435 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11438 fprintf(stderr, "function not implemented\n");
11441 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11445 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11446 .f = cmd_set_all_queues_drop_en_parsed,
11448 .help_str = "set all queues drop <port_id> on|off",
11450 (void *)&cmd_all_queues_drop_en_set,
11451 (void *)&cmd_all_queues_drop_en_all,
11452 (void *)&cmd_all_queues_drop_en_queues,
11453 (void *)&cmd_all_queues_drop_en_drop,
11454 (void *)&cmd_all_queues_drop_en_port_id,
11455 (void *)&cmd_all_queues_drop_en_on_off,
11460 /* vf split drop enable configuration */
11462 /* Common result structure for vf split drop enable */
11463 struct cmd_vf_split_drop_en_result {
11464 cmdline_fixed_string_t set;
11465 cmdline_fixed_string_t vf;
11466 cmdline_fixed_string_t split;
11467 cmdline_fixed_string_t drop;
11470 cmdline_fixed_string_t on_off;
11473 /* Common CLI fields for vf split drop enable disable */
11474 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11475 TOKEN_STRING_INITIALIZER
11476 (struct cmd_vf_split_drop_en_result,
11478 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11479 TOKEN_STRING_INITIALIZER
11480 (struct cmd_vf_split_drop_en_result,
11482 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11483 TOKEN_STRING_INITIALIZER
11484 (struct cmd_vf_split_drop_en_result,
11486 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11487 TOKEN_STRING_INITIALIZER
11488 (struct cmd_vf_split_drop_en_result,
11490 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11491 TOKEN_NUM_INITIALIZER
11492 (struct cmd_vf_split_drop_en_result,
11493 port_id, RTE_UINT16);
11494 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11495 TOKEN_NUM_INITIALIZER
11496 (struct cmd_vf_split_drop_en_result,
11497 vf_id, RTE_UINT16);
11498 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11499 TOKEN_STRING_INITIALIZER
11500 (struct cmd_vf_split_drop_en_result,
11504 cmd_set_vf_split_drop_en_parsed(
11505 void *parsed_result,
11506 __rte_unused struct cmdline *cl,
11507 __rte_unused void *data)
11509 struct cmd_vf_split_drop_en_result *res = parsed_result;
11510 int ret = -ENOTSUP;
11511 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11513 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11516 #ifdef RTE_NET_IXGBE
11517 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11524 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11525 res->vf_id, is_on);
11528 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11531 fprintf(stderr, "not supported on port %d\n", res->port_id);
11534 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11538 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11539 .f = cmd_set_vf_split_drop_en_parsed,
11541 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11543 (void *)&cmd_vf_split_drop_en_set,
11544 (void *)&cmd_vf_split_drop_en_vf,
11545 (void *)&cmd_vf_split_drop_en_split,
11546 (void *)&cmd_vf_split_drop_en_drop,
11547 (void *)&cmd_vf_split_drop_en_port_id,
11548 (void *)&cmd_vf_split_drop_en_vf_id,
11549 (void *)&cmd_vf_split_drop_en_on_off,
11554 /* vf mac address configuration */
11556 /* Common result structure for vf mac address */
11557 struct cmd_set_vf_mac_addr_result {
11558 cmdline_fixed_string_t set;
11559 cmdline_fixed_string_t vf;
11560 cmdline_fixed_string_t mac;
11561 cmdline_fixed_string_t addr;
11564 struct rte_ether_addr mac_addr;
11568 /* Common CLI fields for vf split drop enable disable */
11569 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11570 TOKEN_STRING_INITIALIZER
11571 (struct cmd_set_vf_mac_addr_result,
11573 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11574 TOKEN_STRING_INITIALIZER
11575 (struct cmd_set_vf_mac_addr_result,
11577 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11578 TOKEN_STRING_INITIALIZER
11579 (struct cmd_set_vf_mac_addr_result,
11581 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11582 TOKEN_STRING_INITIALIZER
11583 (struct cmd_set_vf_mac_addr_result,
11585 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11586 TOKEN_NUM_INITIALIZER
11587 (struct cmd_set_vf_mac_addr_result,
11588 port_id, RTE_UINT16);
11589 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11590 TOKEN_NUM_INITIALIZER
11591 (struct cmd_set_vf_mac_addr_result,
11592 vf_id, RTE_UINT16);
11593 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11594 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11598 cmd_set_vf_mac_addr_parsed(
11599 void *parsed_result,
11600 __rte_unused struct cmdline *cl,
11601 __rte_unused void *data)
11603 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11604 int ret = -ENOTSUP;
11606 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11609 #ifdef RTE_NET_IXGBE
11610 if (ret == -ENOTSUP)
11611 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11614 #ifdef RTE_NET_I40E
11615 if (ret == -ENOTSUP)
11616 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11619 #ifdef RTE_NET_BNXT
11620 if (ret == -ENOTSUP)
11621 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11629 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11632 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11635 fprintf(stderr, "function not implemented\n");
11638 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11642 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11643 .f = cmd_set_vf_mac_addr_parsed,
11645 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11647 (void *)&cmd_set_vf_mac_addr_set,
11648 (void *)&cmd_set_vf_mac_addr_vf,
11649 (void *)&cmd_set_vf_mac_addr_mac,
11650 (void *)&cmd_set_vf_mac_addr_addr,
11651 (void *)&cmd_set_vf_mac_addr_port_id,
11652 (void *)&cmd_set_vf_mac_addr_vf_id,
11653 (void *)&cmd_set_vf_mac_addr_mac_addr,
11658 /* MACsec configuration */
11660 /* Common result structure for MACsec offload enable */
11661 struct cmd_macsec_offload_on_result {
11662 cmdline_fixed_string_t set;
11663 cmdline_fixed_string_t macsec;
11664 cmdline_fixed_string_t offload;
11666 cmdline_fixed_string_t on;
11667 cmdline_fixed_string_t encrypt;
11668 cmdline_fixed_string_t en_on_off;
11669 cmdline_fixed_string_t replay_protect;
11670 cmdline_fixed_string_t rp_on_off;
11673 /* Common CLI fields for MACsec offload disable */
11674 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11675 TOKEN_STRING_INITIALIZER
11676 (struct cmd_macsec_offload_on_result,
11678 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11679 TOKEN_STRING_INITIALIZER
11680 (struct cmd_macsec_offload_on_result,
11682 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11683 TOKEN_STRING_INITIALIZER
11684 (struct cmd_macsec_offload_on_result,
11685 offload, "offload");
11686 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11687 TOKEN_NUM_INITIALIZER
11688 (struct cmd_macsec_offload_on_result,
11689 port_id, RTE_UINT16);
11690 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11691 TOKEN_STRING_INITIALIZER
11692 (struct cmd_macsec_offload_on_result,
11694 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11695 TOKEN_STRING_INITIALIZER
11696 (struct cmd_macsec_offload_on_result,
11697 encrypt, "encrypt");
11698 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11699 TOKEN_STRING_INITIALIZER
11700 (struct cmd_macsec_offload_on_result,
11701 en_on_off, "on#off");
11702 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11703 TOKEN_STRING_INITIALIZER
11704 (struct cmd_macsec_offload_on_result,
11705 replay_protect, "replay-protect");
11706 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11707 TOKEN_STRING_INITIALIZER
11708 (struct cmd_macsec_offload_on_result,
11709 rp_on_off, "on#off");
11712 cmd_set_macsec_offload_on_parsed(
11713 void *parsed_result,
11714 __rte_unused struct cmdline *cl,
11715 __rte_unused void *data)
11717 struct cmd_macsec_offload_on_result *res = parsed_result;
11718 int ret = -ENOTSUP;
11719 portid_t port_id = res->port_id;
11720 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11721 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11722 struct rte_eth_dev_info dev_info;
11724 if (port_id_is_invalid(port_id, ENABLED_WARN))
11726 if (!port_is_stopped(port_id)) {
11727 fprintf(stderr, "Please stop port %d first\n", port_id);
11731 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11735 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11736 #ifdef RTE_NET_IXGBE
11737 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11745 ports[port_id].dev_conf.txmode.offloads |=
11746 DEV_TX_OFFLOAD_MACSEC_INSERT;
11747 cmd_reconfig_device_queue(port_id, 1, 1);
11750 fprintf(stderr, "invalid port_id %d\n", port_id);
11753 fprintf(stderr, "not supported on port %d\n", port_id);
11756 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11760 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11761 .f = cmd_set_macsec_offload_on_parsed,
11763 .help_str = "set macsec offload <port_id> on "
11764 "encrypt on|off replay-protect on|off",
11766 (void *)&cmd_macsec_offload_on_set,
11767 (void *)&cmd_macsec_offload_on_macsec,
11768 (void *)&cmd_macsec_offload_on_offload,
11769 (void *)&cmd_macsec_offload_on_port_id,
11770 (void *)&cmd_macsec_offload_on_on,
11771 (void *)&cmd_macsec_offload_on_encrypt,
11772 (void *)&cmd_macsec_offload_on_en_on_off,
11773 (void *)&cmd_macsec_offload_on_replay_protect,
11774 (void *)&cmd_macsec_offload_on_rp_on_off,
11779 /* Common result structure for MACsec offload disable */
11780 struct cmd_macsec_offload_off_result {
11781 cmdline_fixed_string_t set;
11782 cmdline_fixed_string_t macsec;
11783 cmdline_fixed_string_t offload;
11785 cmdline_fixed_string_t off;
11788 /* Common CLI fields for MACsec offload disable */
11789 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11790 TOKEN_STRING_INITIALIZER
11791 (struct cmd_macsec_offload_off_result,
11793 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11794 TOKEN_STRING_INITIALIZER
11795 (struct cmd_macsec_offload_off_result,
11797 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11798 TOKEN_STRING_INITIALIZER
11799 (struct cmd_macsec_offload_off_result,
11800 offload, "offload");
11801 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11802 TOKEN_NUM_INITIALIZER
11803 (struct cmd_macsec_offload_off_result,
11804 port_id, RTE_UINT16);
11805 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11806 TOKEN_STRING_INITIALIZER
11807 (struct cmd_macsec_offload_off_result,
11811 cmd_set_macsec_offload_off_parsed(
11812 void *parsed_result,
11813 __rte_unused struct cmdline *cl,
11814 __rte_unused void *data)
11816 struct cmd_macsec_offload_off_result *res = parsed_result;
11817 int ret = -ENOTSUP;
11818 struct rte_eth_dev_info dev_info;
11819 portid_t port_id = res->port_id;
11821 if (port_id_is_invalid(port_id, ENABLED_WARN))
11823 if (!port_is_stopped(port_id)) {
11824 fprintf(stderr, "Please stop port %d first\n", port_id);
11828 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11832 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11833 #ifdef RTE_NET_IXGBE
11834 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11839 ports[port_id].dev_conf.txmode.offloads &=
11840 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11841 cmd_reconfig_device_queue(port_id, 1, 1);
11844 fprintf(stderr, "invalid port_id %d\n", port_id);
11847 fprintf(stderr, "not supported on port %d\n", port_id);
11850 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11854 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11855 .f = cmd_set_macsec_offload_off_parsed,
11857 .help_str = "set macsec offload <port_id> off",
11859 (void *)&cmd_macsec_offload_off_set,
11860 (void *)&cmd_macsec_offload_off_macsec,
11861 (void *)&cmd_macsec_offload_off_offload,
11862 (void *)&cmd_macsec_offload_off_port_id,
11863 (void *)&cmd_macsec_offload_off_off,
11868 /* Common result structure for MACsec secure connection configure */
11869 struct cmd_macsec_sc_result {
11870 cmdline_fixed_string_t set;
11871 cmdline_fixed_string_t macsec;
11872 cmdline_fixed_string_t sc;
11873 cmdline_fixed_string_t tx_rx;
11875 struct rte_ether_addr mac;
11879 /* Common CLI fields for MACsec secure connection configure */
11880 cmdline_parse_token_string_t cmd_macsec_sc_set =
11881 TOKEN_STRING_INITIALIZER
11882 (struct cmd_macsec_sc_result,
11884 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11885 TOKEN_STRING_INITIALIZER
11886 (struct cmd_macsec_sc_result,
11888 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11889 TOKEN_STRING_INITIALIZER
11890 (struct cmd_macsec_sc_result,
11892 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11893 TOKEN_STRING_INITIALIZER
11894 (struct cmd_macsec_sc_result,
11896 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11897 TOKEN_NUM_INITIALIZER
11898 (struct cmd_macsec_sc_result,
11899 port_id, RTE_UINT16);
11900 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11901 TOKEN_ETHERADDR_INITIALIZER
11902 (struct cmd_macsec_sc_result,
11904 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11905 TOKEN_NUM_INITIALIZER
11906 (struct cmd_macsec_sc_result,
11910 cmd_set_macsec_sc_parsed(
11911 void *parsed_result,
11912 __rte_unused struct cmdline *cl,
11913 __rte_unused void *data)
11915 struct cmd_macsec_sc_result *res = parsed_result;
11916 int ret = -ENOTSUP;
11917 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11919 #ifdef RTE_NET_IXGBE
11921 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11922 res->mac.addr_bytes) :
11923 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11924 res->mac.addr_bytes, res->pi);
11926 RTE_SET_USED(is_tx);
11932 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11935 fprintf(stderr, "not supported on port %d\n", res->port_id);
11938 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11942 cmdline_parse_inst_t cmd_set_macsec_sc = {
11943 .f = cmd_set_macsec_sc_parsed,
11945 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11947 (void *)&cmd_macsec_sc_set,
11948 (void *)&cmd_macsec_sc_macsec,
11949 (void *)&cmd_macsec_sc_sc,
11950 (void *)&cmd_macsec_sc_tx_rx,
11951 (void *)&cmd_macsec_sc_port_id,
11952 (void *)&cmd_macsec_sc_mac,
11953 (void *)&cmd_macsec_sc_pi,
11958 /* Common result structure for MACsec secure connection configure */
11959 struct cmd_macsec_sa_result {
11960 cmdline_fixed_string_t set;
11961 cmdline_fixed_string_t macsec;
11962 cmdline_fixed_string_t sa;
11963 cmdline_fixed_string_t tx_rx;
11968 cmdline_fixed_string_t key;
11971 /* Common CLI fields for MACsec secure connection configure */
11972 cmdline_parse_token_string_t cmd_macsec_sa_set =
11973 TOKEN_STRING_INITIALIZER
11974 (struct cmd_macsec_sa_result,
11976 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11977 TOKEN_STRING_INITIALIZER
11978 (struct cmd_macsec_sa_result,
11980 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11981 TOKEN_STRING_INITIALIZER
11982 (struct cmd_macsec_sa_result,
11984 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11985 TOKEN_STRING_INITIALIZER
11986 (struct cmd_macsec_sa_result,
11988 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11989 TOKEN_NUM_INITIALIZER
11990 (struct cmd_macsec_sa_result,
11991 port_id, RTE_UINT16);
11992 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11993 TOKEN_NUM_INITIALIZER
11994 (struct cmd_macsec_sa_result,
11996 cmdline_parse_token_num_t cmd_macsec_sa_an =
11997 TOKEN_NUM_INITIALIZER
11998 (struct cmd_macsec_sa_result,
12000 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12001 TOKEN_NUM_INITIALIZER
12002 (struct cmd_macsec_sa_result,
12004 cmdline_parse_token_string_t cmd_macsec_sa_key =
12005 TOKEN_STRING_INITIALIZER
12006 (struct cmd_macsec_sa_result,
12010 cmd_set_macsec_sa_parsed(
12011 void *parsed_result,
12012 __rte_unused struct cmdline *cl,
12013 __rte_unused void *data)
12015 struct cmd_macsec_sa_result *res = parsed_result;
12016 int ret = -ENOTSUP;
12017 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12018 uint8_t key[16] = { 0 };
12024 key_len = strlen(res->key) / 2;
12028 for (i = 0; i < key_len; i++) {
12029 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12032 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12035 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12038 #ifdef RTE_NET_IXGBE
12040 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12041 res->idx, res->an, res->pn, key) :
12042 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12043 res->idx, res->an, res->pn, key);
12045 RTE_SET_USED(is_tx);
12052 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12055 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12058 fprintf(stderr, "not supported on port %d\n", res->port_id);
12061 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12065 cmdline_parse_inst_t cmd_set_macsec_sa = {
12066 .f = cmd_set_macsec_sa_parsed,
12068 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12070 (void *)&cmd_macsec_sa_set,
12071 (void *)&cmd_macsec_sa_macsec,
12072 (void *)&cmd_macsec_sa_sa,
12073 (void *)&cmd_macsec_sa_tx_rx,
12074 (void *)&cmd_macsec_sa_port_id,
12075 (void *)&cmd_macsec_sa_idx,
12076 (void *)&cmd_macsec_sa_an,
12077 (void *)&cmd_macsec_sa_pn,
12078 (void *)&cmd_macsec_sa_key,
12083 /* VF unicast promiscuous mode configuration */
12085 /* Common result structure for VF unicast promiscuous mode */
12086 struct cmd_vf_promisc_result {
12087 cmdline_fixed_string_t set;
12088 cmdline_fixed_string_t vf;
12089 cmdline_fixed_string_t promisc;
12092 cmdline_fixed_string_t on_off;
12095 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12096 cmdline_parse_token_string_t cmd_vf_promisc_set =
12097 TOKEN_STRING_INITIALIZER
12098 (struct cmd_vf_promisc_result,
12100 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12101 TOKEN_STRING_INITIALIZER
12102 (struct cmd_vf_promisc_result,
12104 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12105 TOKEN_STRING_INITIALIZER
12106 (struct cmd_vf_promisc_result,
12107 promisc, "promisc");
12108 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12109 TOKEN_NUM_INITIALIZER
12110 (struct cmd_vf_promisc_result,
12111 port_id, RTE_UINT16);
12112 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12113 TOKEN_NUM_INITIALIZER
12114 (struct cmd_vf_promisc_result,
12115 vf_id, RTE_UINT32);
12116 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12117 TOKEN_STRING_INITIALIZER
12118 (struct cmd_vf_promisc_result,
12122 cmd_set_vf_promisc_parsed(
12123 void *parsed_result,
12124 __rte_unused struct cmdline *cl,
12125 __rte_unused void *data)
12127 struct cmd_vf_promisc_result *res = parsed_result;
12128 int ret = -ENOTSUP;
12130 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12132 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12135 #ifdef RTE_NET_I40E
12136 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12137 res->vf_id, is_on);
12144 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12147 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12150 fprintf(stderr, "function not implemented\n");
12153 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12157 cmdline_parse_inst_t cmd_set_vf_promisc = {
12158 .f = cmd_set_vf_promisc_parsed,
12160 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12161 "Set unicast promiscuous mode for a VF from the PF",
12163 (void *)&cmd_vf_promisc_set,
12164 (void *)&cmd_vf_promisc_vf,
12165 (void *)&cmd_vf_promisc_promisc,
12166 (void *)&cmd_vf_promisc_port_id,
12167 (void *)&cmd_vf_promisc_vf_id,
12168 (void *)&cmd_vf_promisc_on_off,
12173 /* VF multicast promiscuous mode configuration */
12175 /* Common result structure for VF multicast promiscuous mode */
12176 struct cmd_vf_allmulti_result {
12177 cmdline_fixed_string_t set;
12178 cmdline_fixed_string_t vf;
12179 cmdline_fixed_string_t allmulti;
12182 cmdline_fixed_string_t on_off;
12185 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12186 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12187 TOKEN_STRING_INITIALIZER
12188 (struct cmd_vf_allmulti_result,
12190 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12191 TOKEN_STRING_INITIALIZER
12192 (struct cmd_vf_allmulti_result,
12194 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12195 TOKEN_STRING_INITIALIZER
12196 (struct cmd_vf_allmulti_result,
12197 allmulti, "allmulti");
12198 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12199 TOKEN_NUM_INITIALIZER
12200 (struct cmd_vf_allmulti_result,
12201 port_id, RTE_UINT16);
12202 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12203 TOKEN_NUM_INITIALIZER
12204 (struct cmd_vf_allmulti_result,
12205 vf_id, RTE_UINT32);
12206 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12207 TOKEN_STRING_INITIALIZER
12208 (struct cmd_vf_allmulti_result,
12212 cmd_set_vf_allmulti_parsed(
12213 void *parsed_result,
12214 __rte_unused struct cmdline *cl,
12215 __rte_unused void *data)
12217 struct cmd_vf_allmulti_result *res = parsed_result;
12218 int ret = -ENOTSUP;
12220 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12222 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12225 #ifdef RTE_NET_I40E
12226 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12227 res->vf_id, is_on);
12234 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12237 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12240 fprintf(stderr, "function not implemented\n");
12243 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12247 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12248 .f = cmd_set_vf_allmulti_parsed,
12250 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12251 "Set multicast promiscuous mode for a VF from the PF",
12253 (void *)&cmd_vf_allmulti_set,
12254 (void *)&cmd_vf_allmulti_vf,
12255 (void *)&cmd_vf_allmulti_allmulti,
12256 (void *)&cmd_vf_allmulti_port_id,
12257 (void *)&cmd_vf_allmulti_vf_id,
12258 (void *)&cmd_vf_allmulti_on_off,
12263 /* vf broadcast mode configuration */
12265 /* Common result structure for vf broadcast */
12266 struct cmd_set_vf_broadcast_result {
12267 cmdline_fixed_string_t set;
12268 cmdline_fixed_string_t vf;
12269 cmdline_fixed_string_t broadcast;
12272 cmdline_fixed_string_t on_off;
12275 /* Common CLI fields for vf broadcast enable disable */
12276 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12277 TOKEN_STRING_INITIALIZER
12278 (struct cmd_set_vf_broadcast_result,
12280 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12281 TOKEN_STRING_INITIALIZER
12282 (struct cmd_set_vf_broadcast_result,
12284 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12285 TOKEN_STRING_INITIALIZER
12286 (struct cmd_set_vf_broadcast_result,
12287 broadcast, "broadcast");
12288 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12289 TOKEN_NUM_INITIALIZER
12290 (struct cmd_set_vf_broadcast_result,
12291 port_id, RTE_UINT16);
12292 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12293 TOKEN_NUM_INITIALIZER
12294 (struct cmd_set_vf_broadcast_result,
12295 vf_id, RTE_UINT16);
12296 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12297 TOKEN_STRING_INITIALIZER
12298 (struct cmd_set_vf_broadcast_result,
12302 cmd_set_vf_broadcast_parsed(
12303 void *parsed_result,
12304 __rte_unused struct cmdline *cl,
12305 __rte_unused void *data)
12307 struct cmd_set_vf_broadcast_result *res = parsed_result;
12308 int ret = -ENOTSUP;
12310 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12312 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12315 #ifdef RTE_NET_I40E
12316 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12317 res->vf_id, is_on);
12324 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12325 res->vf_id, is_on);
12328 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12331 fprintf(stderr, "function not implemented\n");
12334 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12338 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12339 .f = cmd_set_vf_broadcast_parsed,
12341 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12343 (void *)&cmd_set_vf_broadcast_set,
12344 (void *)&cmd_set_vf_broadcast_vf,
12345 (void *)&cmd_set_vf_broadcast_broadcast,
12346 (void *)&cmd_set_vf_broadcast_port_id,
12347 (void *)&cmd_set_vf_broadcast_vf_id,
12348 (void *)&cmd_set_vf_broadcast_on_off,
12353 /* vf vlan tag configuration */
12355 /* Common result structure for vf vlan tag */
12356 struct cmd_set_vf_vlan_tag_result {
12357 cmdline_fixed_string_t set;
12358 cmdline_fixed_string_t vf;
12359 cmdline_fixed_string_t vlan;
12360 cmdline_fixed_string_t tag;
12363 cmdline_fixed_string_t on_off;
12366 /* Common CLI fields for vf vlan tag enable disable */
12367 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12368 TOKEN_STRING_INITIALIZER
12369 (struct cmd_set_vf_vlan_tag_result,
12371 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12372 TOKEN_STRING_INITIALIZER
12373 (struct cmd_set_vf_vlan_tag_result,
12375 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12376 TOKEN_STRING_INITIALIZER
12377 (struct cmd_set_vf_vlan_tag_result,
12379 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12380 TOKEN_STRING_INITIALIZER
12381 (struct cmd_set_vf_vlan_tag_result,
12383 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12384 TOKEN_NUM_INITIALIZER
12385 (struct cmd_set_vf_vlan_tag_result,
12386 port_id, RTE_UINT16);
12387 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12388 TOKEN_NUM_INITIALIZER
12389 (struct cmd_set_vf_vlan_tag_result,
12390 vf_id, RTE_UINT16);
12391 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12392 TOKEN_STRING_INITIALIZER
12393 (struct cmd_set_vf_vlan_tag_result,
12397 cmd_set_vf_vlan_tag_parsed(
12398 void *parsed_result,
12399 __rte_unused struct cmdline *cl,
12400 __rte_unused void *data)
12402 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12403 int ret = -ENOTSUP;
12405 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12407 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12410 #ifdef RTE_NET_I40E
12411 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12412 res->vf_id, is_on);
12419 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12420 res->vf_id, is_on);
12423 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12426 fprintf(stderr, "function not implemented\n");
12429 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12433 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12434 .f = cmd_set_vf_vlan_tag_parsed,
12436 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12438 (void *)&cmd_set_vf_vlan_tag_set,
12439 (void *)&cmd_set_vf_vlan_tag_vf,
12440 (void *)&cmd_set_vf_vlan_tag_vlan,
12441 (void *)&cmd_set_vf_vlan_tag_tag,
12442 (void *)&cmd_set_vf_vlan_tag_port_id,
12443 (void *)&cmd_set_vf_vlan_tag_vf_id,
12444 (void *)&cmd_set_vf_vlan_tag_on_off,
12449 /* Common definition of VF and TC TX bandwidth configuration */
12450 struct cmd_vf_tc_bw_result {
12451 cmdline_fixed_string_t set;
12452 cmdline_fixed_string_t vf;
12453 cmdline_fixed_string_t tc;
12454 cmdline_fixed_string_t tx;
12455 cmdline_fixed_string_t min_bw;
12456 cmdline_fixed_string_t max_bw;
12457 cmdline_fixed_string_t strict_link_prio;
12462 cmdline_fixed_string_t bw_list;
12466 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12467 TOKEN_STRING_INITIALIZER
12468 (struct cmd_vf_tc_bw_result,
12470 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12471 TOKEN_STRING_INITIALIZER
12472 (struct cmd_vf_tc_bw_result,
12474 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12475 TOKEN_STRING_INITIALIZER
12476 (struct cmd_vf_tc_bw_result,
12478 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12479 TOKEN_STRING_INITIALIZER
12480 (struct cmd_vf_tc_bw_result,
12482 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12483 TOKEN_STRING_INITIALIZER
12484 (struct cmd_vf_tc_bw_result,
12485 strict_link_prio, "strict-link-priority");
12486 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12487 TOKEN_STRING_INITIALIZER
12488 (struct cmd_vf_tc_bw_result,
12489 min_bw, "min-bandwidth");
12490 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12491 TOKEN_STRING_INITIALIZER
12492 (struct cmd_vf_tc_bw_result,
12493 max_bw, "max-bandwidth");
12494 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12495 TOKEN_NUM_INITIALIZER
12496 (struct cmd_vf_tc_bw_result,
12497 port_id, RTE_UINT16);
12498 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12499 TOKEN_NUM_INITIALIZER
12500 (struct cmd_vf_tc_bw_result,
12501 vf_id, RTE_UINT16);
12502 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12503 TOKEN_NUM_INITIALIZER
12504 (struct cmd_vf_tc_bw_result,
12506 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12507 TOKEN_NUM_INITIALIZER
12508 (struct cmd_vf_tc_bw_result,
12510 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12511 TOKEN_STRING_INITIALIZER
12512 (struct cmd_vf_tc_bw_result,
12514 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12515 TOKEN_NUM_INITIALIZER
12516 (struct cmd_vf_tc_bw_result,
12517 tc_map, RTE_UINT8);
12519 /* VF max bandwidth setting */
12521 cmd_vf_max_bw_parsed(
12522 void *parsed_result,
12523 __rte_unused struct cmdline *cl,
12524 __rte_unused void *data)
12526 struct cmd_vf_tc_bw_result *res = parsed_result;
12527 int ret = -ENOTSUP;
12529 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12532 #ifdef RTE_NET_I40E
12533 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12534 res->vf_id, res->bw);
12541 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12542 res->vf_id, res->bw);
12545 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12548 fprintf(stderr, "function not implemented\n");
12551 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12555 cmdline_parse_inst_t cmd_vf_max_bw = {
12556 .f = cmd_vf_max_bw_parsed,
12558 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12560 (void *)&cmd_vf_tc_bw_set,
12561 (void *)&cmd_vf_tc_bw_vf,
12562 (void *)&cmd_vf_tc_bw_tx,
12563 (void *)&cmd_vf_tc_bw_max_bw,
12564 (void *)&cmd_vf_tc_bw_port_id,
12565 (void *)&cmd_vf_tc_bw_vf_id,
12566 (void *)&cmd_vf_tc_bw_bw,
12572 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12577 const char *p, *p0 = str;
12584 p = strchr(p0, '(');
12587 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12591 p0 = strchr(p, ')');
12594 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12598 if (size >= sizeof(s)) {
12600 "The string size exceeds the internal buffer size\n");
12603 snprintf(s, sizeof(s), "%.*s", size, p);
12604 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12606 fprintf(stderr, "Failed to get the bandwidth list.\n");
12610 for (i = 0; i < ret; i++)
12611 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12616 /* TC min bandwidth setting */
12618 cmd_vf_tc_min_bw_parsed(
12619 void *parsed_result,
12620 __rte_unused struct cmdline *cl,
12621 __rte_unused void *data)
12623 struct cmd_vf_tc_bw_result *res = parsed_result;
12626 int ret = -ENOTSUP;
12628 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12631 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12635 #ifdef RTE_NET_I40E
12636 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12644 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12647 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12650 fprintf(stderr, "function not implemented\n");
12653 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12657 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12658 .f = cmd_vf_tc_min_bw_parsed,
12660 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12661 " <bw1, bw2, ...>",
12663 (void *)&cmd_vf_tc_bw_set,
12664 (void *)&cmd_vf_tc_bw_vf,
12665 (void *)&cmd_vf_tc_bw_tc,
12666 (void *)&cmd_vf_tc_bw_tx,
12667 (void *)&cmd_vf_tc_bw_min_bw,
12668 (void *)&cmd_vf_tc_bw_port_id,
12669 (void *)&cmd_vf_tc_bw_vf_id,
12670 (void *)&cmd_vf_tc_bw_bw_list,
12676 cmd_tc_min_bw_parsed(
12677 void *parsed_result,
12678 __rte_unused struct cmdline *cl,
12679 __rte_unused void *data)
12681 struct cmd_vf_tc_bw_result *res = parsed_result;
12682 struct rte_port *port;
12685 int ret = -ENOTSUP;
12687 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12690 port = &ports[res->port_id];
12691 /** Check if the port is not started **/
12692 if (port->port_status != RTE_PORT_STOPPED) {
12693 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12697 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12701 #ifdef RTE_NET_IXGBE
12702 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12709 fprintf(stderr, "invalid bandwidth\n");
12712 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12715 fprintf(stderr, "function not implemented\n");
12718 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12722 cmdline_parse_inst_t cmd_tc_min_bw = {
12723 .f = cmd_tc_min_bw_parsed,
12725 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12727 (void *)&cmd_vf_tc_bw_set,
12728 (void *)&cmd_vf_tc_bw_tc,
12729 (void *)&cmd_vf_tc_bw_tx,
12730 (void *)&cmd_vf_tc_bw_min_bw,
12731 (void *)&cmd_vf_tc_bw_port_id,
12732 (void *)&cmd_vf_tc_bw_bw_list,
12737 /* TC max bandwidth setting */
12739 cmd_vf_tc_max_bw_parsed(
12740 void *parsed_result,
12741 __rte_unused struct cmdline *cl,
12742 __rte_unused void *data)
12744 struct cmd_vf_tc_bw_result *res = parsed_result;
12745 int ret = -ENOTSUP;
12747 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12750 #ifdef RTE_NET_I40E
12751 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12752 res->tc_no, res->bw);
12760 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
12761 res->vf_id, res->tc_no, res->bw);
12764 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12767 fprintf(stderr, "function not implemented\n");
12770 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12774 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12775 .f = cmd_vf_tc_max_bw_parsed,
12777 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12780 (void *)&cmd_vf_tc_bw_set,
12781 (void *)&cmd_vf_tc_bw_vf,
12782 (void *)&cmd_vf_tc_bw_tc,
12783 (void *)&cmd_vf_tc_bw_tx,
12784 (void *)&cmd_vf_tc_bw_max_bw,
12785 (void *)&cmd_vf_tc_bw_port_id,
12786 (void *)&cmd_vf_tc_bw_vf_id,
12787 (void *)&cmd_vf_tc_bw_tc_no,
12788 (void *)&cmd_vf_tc_bw_bw,
12793 /** Set VXLAN encapsulation details */
12794 struct cmd_set_vxlan_result {
12795 cmdline_fixed_string_t set;
12796 cmdline_fixed_string_t vxlan;
12797 cmdline_fixed_string_t pos_token;
12798 cmdline_fixed_string_t ip_version;
12799 uint32_t vlan_present:1;
12803 cmdline_ipaddr_t ip_src;
12804 cmdline_ipaddr_t ip_dst;
12808 struct rte_ether_addr eth_src;
12809 struct rte_ether_addr eth_dst;
12812 cmdline_parse_token_string_t cmd_set_vxlan_set =
12813 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12814 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12815 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12816 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12817 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12819 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12820 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12821 "vxlan-with-vlan");
12822 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12823 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12825 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12826 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12828 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12829 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12831 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12832 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12833 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12834 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12836 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12837 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12838 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12839 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12841 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12842 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12843 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12844 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12846 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12847 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12848 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12849 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12851 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12852 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12853 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12854 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12856 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12857 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12858 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12859 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12861 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12862 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12863 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12864 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12866 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12867 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12868 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12869 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12871 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12872 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12873 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12874 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12876 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12877 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12879 static void cmd_set_vxlan_parsed(void *parsed_result,
12880 __rte_unused struct cmdline *cl,
12881 __rte_unused void *data)
12883 struct cmd_set_vxlan_result *res = parsed_result;
12888 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12891 vxlan_encap_conf.select_tos_ttl = 0;
12892 if (strcmp(res->vxlan, "vxlan") == 0)
12893 vxlan_encap_conf.select_vlan = 0;
12894 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12895 vxlan_encap_conf.select_vlan = 1;
12896 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12897 vxlan_encap_conf.select_vlan = 0;
12898 vxlan_encap_conf.select_tos_ttl = 1;
12900 if (strcmp(res->ip_version, "ipv4") == 0)
12901 vxlan_encap_conf.select_ipv4 = 1;
12902 else if (strcmp(res->ip_version, "ipv6") == 0)
12903 vxlan_encap_conf.select_ipv4 = 0;
12906 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12907 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12908 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12909 vxlan_encap_conf.ip_tos = res->tos;
12910 vxlan_encap_conf.ip_ttl = res->ttl;
12911 if (vxlan_encap_conf.select_ipv4) {
12912 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12913 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12915 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12916 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12918 if (vxlan_encap_conf.select_vlan)
12919 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12920 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12921 RTE_ETHER_ADDR_LEN);
12922 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12923 RTE_ETHER_ADDR_LEN);
12926 cmdline_parse_inst_t cmd_set_vxlan = {
12927 .f = cmd_set_vxlan_parsed,
12929 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12930 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12931 " eth-src <eth-src> eth-dst <eth-dst>",
12933 (void *)&cmd_set_vxlan_set,
12934 (void *)&cmd_set_vxlan_vxlan,
12935 (void *)&cmd_set_vxlan_ip_version,
12936 (void *)&cmd_set_vxlan_ip_version_value,
12937 (void *)&cmd_set_vxlan_vni,
12938 (void *)&cmd_set_vxlan_vni_value,
12939 (void *)&cmd_set_vxlan_udp_src,
12940 (void *)&cmd_set_vxlan_udp_src_value,
12941 (void *)&cmd_set_vxlan_udp_dst,
12942 (void *)&cmd_set_vxlan_udp_dst_value,
12943 (void *)&cmd_set_vxlan_ip_src,
12944 (void *)&cmd_set_vxlan_ip_src_value,
12945 (void *)&cmd_set_vxlan_ip_dst,
12946 (void *)&cmd_set_vxlan_ip_dst_value,
12947 (void *)&cmd_set_vxlan_eth_src,
12948 (void *)&cmd_set_vxlan_eth_src_value,
12949 (void *)&cmd_set_vxlan_eth_dst,
12950 (void *)&cmd_set_vxlan_eth_dst_value,
12955 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12956 .f = cmd_set_vxlan_parsed,
12958 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12959 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12960 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12961 " eth-dst <eth-dst>",
12963 (void *)&cmd_set_vxlan_set,
12964 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12965 (void *)&cmd_set_vxlan_ip_version,
12966 (void *)&cmd_set_vxlan_ip_version_value,
12967 (void *)&cmd_set_vxlan_vni,
12968 (void *)&cmd_set_vxlan_vni_value,
12969 (void *)&cmd_set_vxlan_udp_src,
12970 (void *)&cmd_set_vxlan_udp_src_value,
12971 (void *)&cmd_set_vxlan_udp_dst,
12972 (void *)&cmd_set_vxlan_udp_dst_value,
12973 (void *)&cmd_set_vxlan_ip_tos,
12974 (void *)&cmd_set_vxlan_ip_tos_value,
12975 (void *)&cmd_set_vxlan_ip_ttl,
12976 (void *)&cmd_set_vxlan_ip_ttl_value,
12977 (void *)&cmd_set_vxlan_ip_src,
12978 (void *)&cmd_set_vxlan_ip_src_value,
12979 (void *)&cmd_set_vxlan_ip_dst,
12980 (void *)&cmd_set_vxlan_ip_dst_value,
12981 (void *)&cmd_set_vxlan_eth_src,
12982 (void *)&cmd_set_vxlan_eth_src_value,
12983 (void *)&cmd_set_vxlan_eth_dst,
12984 (void *)&cmd_set_vxlan_eth_dst_value,
12989 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12990 .f = cmd_set_vxlan_parsed,
12992 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12993 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12994 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12997 (void *)&cmd_set_vxlan_set,
12998 (void *)&cmd_set_vxlan_vxlan_with_vlan,
12999 (void *)&cmd_set_vxlan_ip_version,
13000 (void *)&cmd_set_vxlan_ip_version_value,
13001 (void *)&cmd_set_vxlan_vni,
13002 (void *)&cmd_set_vxlan_vni_value,
13003 (void *)&cmd_set_vxlan_udp_src,
13004 (void *)&cmd_set_vxlan_udp_src_value,
13005 (void *)&cmd_set_vxlan_udp_dst,
13006 (void *)&cmd_set_vxlan_udp_dst_value,
13007 (void *)&cmd_set_vxlan_ip_src,
13008 (void *)&cmd_set_vxlan_ip_src_value,
13009 (void *)&cmd_set_vxlan_ip_dst,
13010 (void *)&cmd_set_vxlan_ip_dst_value,
13011 (void *)&cmd_set_vxlan_vlan,
13012 (void *)&cmd_set_vxlan_vlan_value,
13013 (void *)&cmd_set_vxlan_eth_src,
13014 (void *)&cmd_set_vxlan_eth_src_value,
13015 (void *)&cmd_set_vxlan_eth_dst,
13016 (void *)&cmd_set_vxlan_eth_dst_value,
13021 /** Set NVGRE encapsulation details */
13022 struct cmd_set_nvgre_result {
13023 cmdline_fixed_string_t set;
13024 cmdline_fixed_string_t nvgre;
13025 cmdline_fixed_string_t pos_token;
13026 cmdline_fixed_string_t ip_version;
13028 cmdline_ipaddr_t ip_src;
13029 cmdline_ipaddr_t ip_dst;
13031 struct rte_ether_addr eth_src;
13032 struct rte_ether_addr eth_dst;
13035 cmdline_parse_token_string_t cmd_set_nvgre_set =
13036 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13037 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13038 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13039 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13040 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13041 "nvgre-with-vlan");
13042 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13043 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13045 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13046 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13048 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13049 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13051 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13052 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13053 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13054 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13056 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13057 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13058 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13059 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13061 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13062 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13063 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13064 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13066 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13067 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13068 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13069 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13071 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13072 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13073 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13074 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13076 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13077 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13079 static void cmd_set_nvgre_parsed(void *parsed_result,
13080 __rte_unused struct cmdline *cl,
13081 __rte_unused void *data)
13083 struct cmd_set_nvgre_result *res = parsed_result;
13085 uint32_t nvgre_tni;
13088 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13091 if (strcmp(res->nvgre, "nvgre") == 0)
13092 nvgre_encap_conf.select_vlan = 0;
13093 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13094 nvgre_encap_conf.select_vlan = 1;
13095 if (strcmp(res->ip_version, "ipv4") == 0)
13096 nvgre_encap_conf.select_ipv4 = 1;
13097 else if (strcmp(res->ip_version, "ipv6") == 0)
13098 nvgre_encap_conf.select_ipv4 = 0;
13101 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13102 if (nvgre_encap_conf.select_ipv4) {
13103 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13104 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13106 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13107 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13109 if (nvgre_encap_conf.select_vlan)
13110 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13111 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13112 RTE_ETHER_ADDR_LEN);
13113 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13114 RTE_ETHER_ADDR_LEN);
13117 cmdline_parse_inst_t cmd_set_nvgre = {
13118 .f = cmd_set_nvgre_parsed,
13120 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13121 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13122 " eth-dst <eth-dst>",
13124 (void *)&cmd_set_nvgre_set,
13125 (void *)&cmd_set_nvgre_nvgre,
13126 (void *)&cmd_set_nvgre_ip_version,
13127 (void *)&cmd_set_nvgre_ip_version_value,
13128 (void *)&cmd_set_nvgre_tni,
13129 (void *)&cmd_set_nvgre_tni_value,
13130 (void *)&cmd_set_nvgre_ip_src,
13131 (void *)&cmd_set_nvgre_ip_src_value,
13132 (void *)&cmd_set_nvgre_ip_dst,
13133 (void *)&cmd_set_nvgre_ip_dst_value,
13134 (void *)&cmd_set_nvgre_eth_src,
13135 (void *)&cmd_set_nvgre_eth_src_value,
13136 (void *)&cmd_set_nvgre_eth_dst,
13137 (void *)&cmd_set_nvgre_eth_dst_value,
13142 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13143 .f = cmd_set_nvgre_parsed,
13145 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13146 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13147 " eth-src <eth-src> eth-dst <eth-dst>",
13149 (void *)&cmd_set_nvgre_set,
13150 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13151 (void *)&cmd_set_nvgre_ip_version,
13152 (void *)&cmd_set_nvgre_ip_version_value,
13153 (void *)&cmd_set_nvgre_tni,
13154 (void *)&cmd_set_nvgre_tni_value,
13155 (void *)&cmd_set_nvgre_ip_src,
13156 (void *)&cmd_set_nvgre_ip_src_value,
13157 (void *)&cmd_set_nvgre_ip_dst,
13158 (void *)&cmd_set_nvgre_ip_dst_value,
13159 (void *)&cmd_set_nvgre_vlan,
13160 (void *)&cmd_set_nvgre_vlan_value,
13161 (void *)&cmd_set_nvgre_eth_src,
13162 (void *)&cmd_set_nvgre_eth_src_value,
13163 (void *)&cmd_set_nvgre_eth_dst,
13164 (void *)&cmd_set_nvgre_eth_dst_value,
13169 /** Set L2 encapsulation details */
13170 struct cmd_set_l2_encap_result {
13171 cmdline_fixed_string_t set;
13172 cmdline_fixed_string_t l2_encap;
13173 cmdline_fixed_string_t pos_token;
13174 cmdline_fixed_string_t ip_version;
13175 uint32_t vlan_present:1;
13177 struct rte_ether_addr eth_src;
13178 struct rte_ether_addr eth_dst;
13181 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13182 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13183 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13184 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13185 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13186 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13187 "l2_encap-with-vlan");
13188 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13189 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13191 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13192 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13194 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13195 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13197 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13198 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13199 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13200 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13202 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13203 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13204 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13205 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13207 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13208 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13210 static void cmd_set_l2_encap_parsed(void *parsed_result,
13211 __rte_unused struct cmdline *cl,
13212 __rte_unused void *data)
13214 struct cmd_set_l2_encap_result *res = parsed_result;
13216 if (strcmp(res->l2_encap, "l2_encap") == 0)
13217 l2_encap_conf.select_vlan = 0;
13218 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13219 l2_encap_conf.select_vlan = 1;
13220 if (strcmp(res->ip_version, "ipv4") == 0)
13221 l2_encap_conf.select_ipv4 = 1;
13222 else if (strcmp(res->ip_version, "ipv6") == 0)
13223 l2_encap_conf.select_ipv4 = 0;
13226 if (l2_encap_conf.select_vlan)
13227 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13228 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13229 RTE_ETHER_ADDR_LEN);
13230 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13231 RTE_ETHER_ADDR_LEN);
13234 cmdline_parse_inst_t cmd_set_l2_encap = {
13235 .f = cmd_set_l2_encap_parsed,
13237 .help_str = "set l2_encap ip-version ipv4|ipv6"
13238 " eth-src <eth-src> eth-dst <eth-dst>",
13240 (void *)&cmd_set_l2_encap_set,
13241 (void *)&cmd_set_l2_encap_l2_encap,
13242 (void *)&cmd_set_l2_encap_ip_version,
13243 (void *)&cmd_set_l2_encap_ip_version_value,
13244 (void *)&cmd_set_l2_encap_eth_src,
13245 (void *)&cmd_set_l2_encap_eth_src_value,
13246 (void *)&cmd_set_l2_encap_eth_dst,
13247 (void *)&cmd_set_l2_encap_eth_dst_value,
13252 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13253 .f = cmd_set_l2_encap_parsed,
13255 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13256 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13258 (void *)&cmd_set_l2_encap_set,
13259 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13260 (void *)&cmd_set_l2_encap_ip_version,
13261 (void *)&cmd_set_l2_encap_ip_version_value,
13262 (void *)&cmd_set_l2_encap_vlan,
13263 (void *)&cmd_set_l2_encap_vlan_value,
13264 (void *)&cmd_set_l2_encap_eth_src,
13265 (void *)&cmd_set_l2_encap_eth_src_value,
13266 (void *)&cmd_set_l2_encap_eth_dst,
13267 (void *)&cmd_set_l2_encap_eth_dst_value,
13272 /** Set L2 decapsulation details */
13273 struct cmd_set_l2_decap_result {
13274 cmdline_fixed_string_t set;
13275 cmdline_fixed_string_t l2_decap;
13276 cmdline_fixed_string_t pos_token;
13277 uint32_t vlan_present:1;
13280 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13281 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13282 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13283 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13285 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13286 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13287 "l2_decap-with-vlan");
13289 static void cmd_set_l2_decap_parsed(void *parsed_result,
13290 __rte_unused struct cmdline *cl,
13291 __rte_unused void *data)
13293 struct cmd_set_l2_decap_result *res = parsed_result;
13295 if (strcmp(res->l2_decap, "l2_decap") == 0)
13296 l2_decap_conf.select_vlan = 0;
13297 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13298 l2_decap_conf.select_vlan = 1;
13301 cmdline_parse_inst_t cmd_set_l2_decap = {
13302 .f = cmd_set_l2_decap_parsed,
13304 .help_str = "set l2_decap",
13306 (void *)&cmd_set_l2_decap_set,
13307 (void *)&cmd_set_l2_decap_l2_decap,
13312 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13313 .f = cmd_set_l2_decap_parsed,
13315 .help_str = "set l2_decap-with-vlan",
13317 (void *)&cmd_set_l2_decap_set,
13318 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13323 /** Set MPLSoGRE encapsulation details */
13324 struct cmd_set_mplsogre_encap_result {
13325 cmdline_fixed_string_t set;
13326 cmdline_fixed_string_t mplsogre;
13327 cmdline_fixed_string_t pos_token;
13328 cmdline_fixed_string_t ip_version;
13329 uint32_t vlan_present:1;
13331 cmdline_ipaddr_t ip_src;
13332 cmdline_ipaddr_t ip_dst;
13334 struct rte_ether_addr eth_src;
13335 struct rte_ether_addr eth_dst;
13338 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13339 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13341 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13342 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13344 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13345 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13346 mplsogre, "mplsogre_encap-with-vlan");
13347 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13348 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13349 pos_token, "ip-version");
13350 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13351 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13352 ip_version, "ipv4#ipv6");
13353 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13354 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13355 pos_token, "label");
13356 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13357 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13359 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13360 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13361 pos_token, "ip-src");
13362 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13363 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13364 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13365 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13366 pos_token, "ip-dst");
13367 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13368 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13369 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13370 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13371 pos_token, "vlan-tci");
13372 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13373 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13375 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13376 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13377 pos_token, "eth-src");
13378 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13379 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13381 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13382 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13383 pos_token, "eth-dst");
13384 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13385 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13388 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13389 __rte_unused struct cmdline *cl,
13390 __rte_unused void *data)
13392 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13394 uint32_t mplsogre_label;
13397 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13400 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13401 mplsogre_encap_conf.select_vlan = 0;
13402 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13403 mplsogre_encap_conf.select_vlan = 1;
13404 if (strcmp(res->ip_version, "ipv4") == 0)
13405 mplsogre_encap_conf.select_ipv4 = 1;
13406 else if (strcmp(res->ip_version, "ipv6") == 0)
13407 mplsogre_encap_conf.select_ipv4 = 0;
13410 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13411 if (mplsogre_encap_conf.select_ipv4) {
13412 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13413 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13415 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13416 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13418 if (mplsogre_encap_conf.select_vlan)
13419 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13420 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13421 RTE_ETHER_ADDR_LEN);
13422 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13423 RTE_ETHER_ADDR_LEN);
13426 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13427 .f = cmd_set_mplsogre_encap_parsed,
13429 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13430 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13431 " eth-dst <eth-dst>",
13433 (void *)&cmd_set_mplsogre_encap_set,
13434 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13435 (void *)&cmd_set_mplsogre_encap_ip_version,
13436 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13437 (void *)&cmd_set_mplsogre_encap_label,
13438 (void *)&cmd_set_mplsogre_encap_label_value,
13439 (void *)&cmd_set_mplsogre_encap_ip_src,
13440 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13441 (void *)&cmd_set_mplsogre_encap_ip_dst,
13442 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13443 (void *)&cmd_set_mplsogre_encap_eth_src,
13444 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13445 (void *)&cmd_set_mplsogre_encap_eth_dst,
13446 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13451 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13452 .f = cmd_set_mplsogre_encap_parsed,
13454 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13455 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13456 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13458 (void *)&cmd_set_mplsogre_encap_set,
13459 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13460 (void *)&cmd_set_mplsogre_encap_ip_version,
13461 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13462 (void *)&cmd_set_mplsogre_encap_label,
13463 (void *)&cmd_set_mplsogre_encap_label_value,
13464 (void *)&cmd_set_mplsogre_encap_ip_src,
13465 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13466 (void *)&cmd_set_mplsogre_encap_ip_dst,
13467 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13468 (void *)&cmd_set_mplsogre_encap_vlan,
13469 (void *)&cmd_set_mplsogre_encap_vlan_value,
13470 (void *)&cmd_set_mplsogre_encap_eth_src,
13471 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13472 (void *)&cmd_set_mplsogre_encap_eth_dst,
13473 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13478 /** Set MPLSoGRE decapsulation details */
13479 struct cmd_set_mplsogre_decap_result {
13480 cmdline_fixed_string_t set;
13481 cmdline_fixed_string_t mplsogre;
13482 cmdline_fixed_string_t pos_token;
13483 cmdline_fixed_string_t ip_version;
13484 uint32_t vlan_present:1;
13487 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13488 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13490 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13491 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13493 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13494 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13495 mplsogre, "mplsogre_decap-with-vlan");
13496 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13497 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13498 pos_token, "ip-version");
13499 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13500 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13501 ip_version, "ipv4#ipv6");
13503 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13504 __rte_unused struct cmdline *cl,
13505 __rte_unused void *data)
13507 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13509 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13510 mplsogre_decap_conf.select_vlan = 0;
13511 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13512 mplsogre_decap_conf.select_vlan = 1;
13513 if (strcmp(res->ip_version, "ipv4") == 0)
13514 mplsogre_decap_conf.select_ipv4 = 1;
13515 else if (strcmp(res->ip_version, "ipv6") == 0)
13516 mplsogre_decap_conf.select_ipv4 = 0;
13519 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13520 .f = cmd_set_mplsogre_decap_parsed,
13522 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13524 (void *)&cmd_set_mplsogre_decap_set,
13525 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13526 (void *)&cmd_set_mplsogre_decap_ip_version,
13527 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13532 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13533 .f = cmd_set_mplsogre_decap_parsed,
13535 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13537 (void *)&cmd_set_mplsogre_decap_set,
13538 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13539 (void *)&cmd_set_mplsogre_decap_ip_version,
13540 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13545 /** Set MPLSoUDP encapsulation details */
13546 struct cmd_set_mplsoudp_encap_result {
13547 cmdline_fixed_string_t set;
13548 cmdline_fixed_string_t mplsoudp;
13549 cmdline_fixed_string_t pos_token;
13550 cmdline_fixed_string_t ip_version;
13551 uint32_t vlan_present:1;
13555 cmdline_ipaddr_t ip_src;
13556 cmdline_ipaddr_t ip_dst;
13558 struct rte_ether_addr eth_src;
13559 struct rte_ether_addr eth_dst;
13562 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13563 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13565 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13566 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13568 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13569 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13570 mplsoudp, "mplsoudp_encap-with-vlan");
13571 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13572 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13573 pos_token, "ip-version");
13574 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13575 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13576 ip_version, "ipv4#ipv6");
13577 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13578 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13579 pos_token, "label");
13580 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13581 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13583 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13584 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13585 pos_token, "udp-src");
13586 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13587 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13589 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13590 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13591 pos_token, "udp-dst");
13592 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13593 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13595 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13596 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13597 pos_token, "ip-src");
13598 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13599 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13600 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13601 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13602 pos_token, "ip-dst");
13603 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13604 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13605 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13606 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13607 pos_token, "vlan-tci");
13608 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13609 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13611 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13612 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13613 pos_token, "eth-src");
13614 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13615 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13617 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13618 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13619 pos_token, "eth-dst");
13620 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13621 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13624 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13625 __rte_unused struct cmdline *cl,
13626 __rte_unused void *data)
13628 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13630 uint32_t mplsoudp_label;
13633 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13636 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13637 mplsoudp_encap_conf.select_vlan = 0;
13638 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13639 mplsoudp_encap_conf.select_vlan = 1;
13640 if (strcmp(res->ip_version, "ipv4") == 0)
13641 mplsoudp_encap_conf.select_ipv4 = 1;
13642 else if (strcmp(res->ip_version, "ipv6") == 0)
13643 mplsoudp_encap_conf.select_ipv4 = 0;
13646 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13647 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13648 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13649 if (mplsoudp_encap_conf.select_ipv4) {
13650 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13651 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13653 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13654 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13656 if (mplsoudp_encap_conf.select_vlan)
13657 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13658 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13659 RTE_ETHER_ADDR_LEN);
13660 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13661 RTE_ETHER_ADDR_LEN);
13664 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13665 .f = cmd_set_mplsoudp_encap_parsed,
13667 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13668 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13669 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13671 (void *)&cmd_set_mplsoudp_encap_set,
13672 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13673 (void *)&cmd_set_mplsoudp_encap_ip_version,
13674 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13675 (void *)&cmd_set_mplsoudp_encap_label,
13676 (void *)&cmd_set_mplsoudp_encap_label_value,
13677 (void *)&cmd_set_mplsoudp_encap_udp_src,
13678 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13679 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13680 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13681 (void *)&cmd_set_mplsoudp_encap_ip_src,
13682 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13683 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13684 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13685 (void *)&cmd_set_mplsoudp_encap_eth_src,
13686 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13687 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13688 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13693 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13694 .f = cmd_set_mplsoudp_encap_parsed,
13696 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13697 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13698 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13699 " eth-src <eth-src> eth-dst <eth-dst>",
13701 (void *)&cmd_set_mplsoudp_encap_set,
13702 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13703 (void *)&cmd_set_mplsoudp_encap_ip_version,
13704 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13705 (void *)&cmd_set_mplsoudp_encap_label,
13706 (void *)&cmd_set_mplsoudp_encap_label_value,
13707 (void *)&cmd_set_mplsoudp_encap_udp_src,
13708 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13709 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13710 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13711 (void *)&cmd_set_mplsoudp_encap_ip_src,
13712 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13713 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13714 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13715 (void *)&cmd_set_mplsoudp_encap_vlan,
13716 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13717 (void *)&cmd_set_mplsoudp_encap_eth_src,
13718 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13719 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13720 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13725 /** Set MPLSoUDP decapsulation details */
13726 struct cmd_set_mplsoudp_decap_result {
13727 cmdline_fixed_string_t set;
13728 cmdline_fixed_string_t mplsoudp;
13729 cmdline_fixed_string_t pos_token;
13730 cmdline_fixed_string_t ip_version;
13731 uint32_t vlan_present:1;
13734 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13735 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13737 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13738 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13740 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13741 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13742 mplsoudp, "mplsoudp_decap-with-vlan");
13743 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13744 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13745 pos_token, "ip-version");
13746 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13747 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13748 ip_version, "ipv4#ipv6");
13750 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13751 __rte_unused struct cmdline *cl,
13752 __rte_unused void *data)
13754 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13756 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13757 mplsoudp_decap_conf.select_vlan = 0;
13758 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13759 mplsoudp_decap_conf.select_vlan = 1;
13760 if (strcmp(res->ip_version, "ipv4") == 0)
13761 mplsoudp_decap_conf.select_ipv4 = 1;
13762 else if (strcmp(res->ip_version, "ipv6") == 0)
13763 mplsoudp_decap_conf.select_ipv4 = 0;
13766 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13767 .f = cmd_set_mplsoudp_decap_parsed,
13769 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13771 (void *)&cmd_set_mplsoudp_decap_set,
13772 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13773 (void *)&cmd_set_mplsoudp_decap_ip_version,
13774 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13779 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13780 .f = cmd_set_mplsoudp_decap_parsed,
13782 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13784 (void *)&cmd_set_mplsoudp_decap_set,
13785 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13786 (void *)&cmd_set_mplsoudp_decap_ip_version,
13787 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13792 /** Set connection tracking object common details */
13793 struct cmd_set_conntrack_common_result {
13794 cmdline_fixed_string_t set;
13795 cmdline_fixed_string_t conntrack;
13796 cmdline_fixed_string_t common;
13797 cmdline_fixed_string_t peer;
13798 cmdline_fixed_string_t is_orig;
13799 cmdline_fixed_string_t enable;
13800 cmdline_fixed_string_t live;
13801 cmdline_fixed_string_t sack;
13802 cmdline_fixed_string_t cack;
13803 cmdline_fixed_string_t last_dir;
13804 cmdline_fixed_string_t liberal;
13805 cmdline_fixed_string_t state;
13806 cmdline_fixed_string_t max_ack_win;
13807 cmdline_fixed_string_t retrans;
13808 cmdline_fixed_string_t last_win;
13809 cmdline_fixed_string_t last_seq;
13810 cmdline_fixed_string_t last_ack;
13811 cmdline_fixed_string_t last_end;
13812 cmdline_fixed_string_t last_index;
13815 uint16_t peer_port;
13816 uint32_t is_original;
13831 cmdline_parse_token_string_t cmd_set_conntrack_set =
13832 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13834 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13835 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13836 conntrack, "conntrack");
13837 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13838 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13840 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13841 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13843 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13844 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13845 peer_port, RTE_UINT16);
13846 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13847 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13848 is_orig, "is_orig");
13849 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13850 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13851 is_original, RTE_UINT32);
13852 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13853 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13855 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13856 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13858 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13859 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13861 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13862 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13863 is_live, RTE_UINT32);
13864 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13865 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13867 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13868 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13869 s_ack, RTE_UINT32);
13870 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13871 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13873 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13874 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13875 c_ack, RTE_UINT32);
13876 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13877 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13878 last_dir, "last_dir");
13879 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13880 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13882 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13883 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13884 liberal, "liberal");
13885 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13886 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13888 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13889 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13891 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13892 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13894 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13895 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13896 max_ack_win, "max_ack_win");
13897 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13898 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13899 factor, RTE_UINT8);
13900 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13901 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13903 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13904 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13905 re_num, RTE_UINT8);
13906 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13907 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13908 last_win, "last_win");
13909 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13910 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13912 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13913 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13914 last_seq, "last_seq");
13915 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13916 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13918 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13919 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13920 last_ack, "last_ack");
13921 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13922 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13924 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13925 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13926 last_end, "last_end");
13927 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13928 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13930 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13931 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13932 last_index, "last_index");
13933 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13934 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13937 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13938 __rte_unused struct cmdline *cl,
13939 __rte_unused void *data)
13941 struct cmd_set_conntrack_common_result *res = parsed_result;
13943 /* No need to swap to big endian. */
13944 conntrack_context.peer_port = res->peer_port;
13945 conntrack_context.is_original_dir = res->is_original;
13946 conntrack_context.enable = res->en;
13947 conntrack_context.live_connection = res->is_live;
13948 conntrack_context.selective_ack = res->s_ack;
13949 conntrack_context.challenge_ack_passed = res->c_ack;
13950 conntrack_context.last_direction = res->ld;
13951 conntrack_context.liberal_mode = res->lb;
13952 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13953 conntrack_context.max_ack_window = res->factor;
13954 conntrack_context.retransmission_limit = res->re_num;
13955 conntrack_context.last_window = res->lw;
13956 conntrack_context.last_index =
13957 (enum rte_flow_conntrack_tcp_last_index)res->li;
13958 conntrack_context.last_seq = res->ls;
13959 conntrack_context.last_ack = res->la;
13960 conntrack_context.last_end = res->le;
13963 cmdline_parse_inst_t cmd_set_conntrack_common = {
13964 .f = cmd_set_conntrack_common_parsed,
13966 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13967 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13968 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13969 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13970 " last_index <flag>",
13972 (void *)&cmd_set_conntrack_set,
13973 (void *)&cmd_set_conntrack_conntrack,
13974 (void *)&cmd_set_conntrack_common_com,
13975 (void *)&cmd_set_conntrack_common_peer,
13976 (void *)&cmd_set_conntrack_common_peer_value,
13977 (void *)&cmd_set_conntrack_common_is_orig,
13978 (void *)&cmd_set_conntrack_common_is_orig_value,
13979 (void *)&cmd_set_conntrack_common_enable,
13980 (void *)&cmd_set_conntrack_common_enable_value,
13981 (void *)&cmd_set_conntrack_common_live,
13982 (void *)&cmd_set_conntrack_common_live_value,
13983 (void *)&cmd_set_conntrack_common_sack,
13984 (void *)&cmd_set_conntrack_common_sack_value,
13985 (void *)&cmd_set_conntrack_common_cack,
13986 (void *)&cmd_set_conntrack_common_cack_value,
13987 (void *)&cmd_set_conntrack_common_last_dir,
13988 (void *)&cmd_set_conntrack_common_last_dir_value,
13989 (void *)&cmd_set_conntrack_common_liberal,
13990 (void *)&cmd_set_conntrack_common_liberal_value,
13991 (void *)&cmd_set_conntrack_common_state,
13992 (void *)&cmd_set_conntrack_common_state_value,
13993 (void *)&cmd_set_conntrack_common_max_ackwin,
13994 (void *)&cmd_set_conntrack_common_max_ackwin_value,
13995 (void *)&cmd_set_conntrack_common_retrans,
13996 (void *)&cmd_set_conntrack_common_retrans_value,
13997 (void *)&cmd_set_conntrack_common_last_win,
13998 (void *)&cmd_set_conntrack_common_last_win_value,
13999 (void *)&cmd_set_conntrack_common_last_seq,
14000 (void *)&cmd_set_conntrack_common_last_seq_value,
14001 (void *)&cmd_set_conntrack_common_last_ack,
14002 (void *)&cmd_set_conntrack_common_last_ack_value,
14003 (void *)&cmd_set_conntrack_common_last_end,
14004 (void *)&cmd_set_conntrack_common_last_end_value,
14005 (void *)&cmd_set_conntrack_common_last_index,
14006 (void *)&cmd_set_conntrack_common_last_index_value,
14011 /** Set connection tracking object both directions' details */
14012 struct cmd_set_conntrack_dir_result {
14013 cmdline_fixed_string_t set;
14014 cmdline_fixed_string_t conntrack;
14015 cmdline_fixed_string_t dir;
14016 cmdline_fixed_string_t scale;
14017 cmdline_fixed_string_t fin;
14018 cmdline_fixed_string_t ack_seen;
14019 cmdline_fixed_string_t unack;
14020 cmdline_fixed_string_t sent_end;
14021 cmdline_fixed_string_t reply_end;
14022 cmdline_fixed_string_t max_win;
14023 cmdline_fixed_string_t max_ack;
14034 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14035 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14037 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14038 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14039 conntrack, "conntrack");
14040 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14041 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14043 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14044 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14046 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14047 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14048 factor, RTE_UINT32);
14049 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14050 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14052 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14053 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14055 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14056 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14057 ack_seen, "acked");
14058 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14059 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14061 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14062 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14063 unack, "unack_data");
14064 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14065 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14067 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14068 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14069 sent_end, "sent_end");
14070 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14071 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14073 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14074 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14075 reply_end, "reply_end");
14076 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14077 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14079 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14080 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14081 max_win, "max_win");
14082 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14083 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14085 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14086 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14087 max_ack, "max_ack");
14088 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14089 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14092 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14093 __rte_unused struct cmdline *cl,
14094 __rte_unused void *data)
14096 struct cmd_set_conntrack_dir_result *res = parsed_result;
14097 struct rte_flow_tcp_dir_param *dir = NULL;
14099 if (strcmp(res->dir, "orig") == 0)
14100 dir = &conntrack_context.original_dir;
14101 else if (strcmp(res->dir, "rply") == 0)
14102 dir = &conntrack_context.reply_dir;
14105 dir->scale = res->factor;
14106 dir->close_initiated = res->f;
14107 dir->last_ack_seen = res->as;
14108 dir->data_unacked = res->un;
14109 dir->sent_end = res->se;
14110 dir->reply_end = res->re;
14111 dir->max_ack = res->ma;
14112 dir->max_win = res->mw;
14115 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14116 .f = cmd_set_conntrack_dir_parsed,
14118 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14119 " acked <seen> unack_data <unack> sent_end <sent>"
14120 " reply_end <reply> max_win <win> max_ack <ack>",
14122 (void *)&cmd_set_conntrack_set,
14123 (void *)&cmd_set_conntrack_conntrack,
14124 (void *)&cmd_set_conntrack_dir_dir,
14125 (void *)&cmd_set_conntrack_dir_scale,
14126 (void *)&cmd_set_conntrack_dir_scale_value,
14127 (void *)&cmd_set_conntrack_dir_fin,
14128 (void *)&cmd_set_conntrack_dir_fin_value,
14129 (void *)&cmd_set_conntrack_dir_ack,
14130 (void *)&cmd_set_conntrack_dir_ack_value,
14131 (void *)&cmd_set_conntrack_dir_unack_data,
14132 (void *)&cmd_set_conntrack_dir_unack_data_value,
14133 (void *)&cmd_set_conntrack_dir_sent_end,
14134 (void *)&cmd_set_conntrack_dir_sent_end_value,
14135 (void *)&cmd_set_conntrack_dir_reply_end,
14136 (void *)&cmd_set_conntrack_dir_reply_end_value,
14137 (void *)&cmd_set_conntrack_dir_max_win,
14138 (void *)&cmd_set_conntrack_dir_max_win_value,
14139 (void *)&cmd_set_conntrack_dir_max_ack,
14140 (void *)&cmd_set_conntrack_dir_max_ack_value,
14145 /* Strict link priority scheduling mode setting */
14147 cmd_strict_link_prio_parsed(
14148 void *parsed_result,
14149 __rte_unused struct cmdline *cl,
14150 __rte_unused void *data)
14152 struct cmd_vf_tc_bw_result *res = parsed_result;
14153 int ret = -ENOTSUP;
14155 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14158 #ifdef RTE_NET_I40E
14159 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14166 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14169 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14172 fprintf(stderr, "function not implemented\n");
14175 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14179 cmdline_parse_inst_t cmd_strict_link_prio = {
14180 .f = cmd_strict_link_prio_parsed,
14182 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14184 (void *)&cmd_vf_tc_bw_set,
14185 (void *)&cmd_vf_tc_bw_tx,
14186 (void *)&cmd_vf_tc_bw_strict_link_prio,
14187 (void *)&cmd_vf_tc_bw_port_id,
14188 (void *)&cmd_vf_tc_bw_tc_map,
14193 /* Load dynamic device personalization*/
14194 struct cmd_ddp_add_result {
14195 cmdline_fixed_string_t ddp;
14196 cmdline_fixed_string_t add;
14201 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14202 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14203 cmdline_parse_token_string_t cmd_ddp_add_add =
14204 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14205 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14206 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14208 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14209 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14212 cmd_ddp_add_parsed(
14213 void *parsed_result,
14214 __rte_unused struct cmdline *cl,
14215 __rte_unused void *data)
14217 struct cmd_ddp_add_result *res = parsed_result;
14223 int ret = -ENOTSUP;
14225 if (!all_ports_stopped()) {
14226 fprintf(stderr, "Please stop all ports first\n");
14230 filepath = strdup(res->filepath);
14231 if (filepath == NULL) {
14232 fprintf(stderr, "Failed to allocate memory\n");
14235 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14237 buff = open_file(file_fld[0], &size);
14239 free((void *)filepath);
14243 #ifdef RTE_NET_I40E
14244 if (ret == -ENOTSUP)
14245 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14247 RTE_PMD_I40E_PKG_OP_WR_ADD);
14250 if (ret == -EEXIST)
14251 fprintf(stderr, "Profile has already existed.\n");
14253 fprintf(stderr, "Failed to load profile.\n");
14254 else if (file_num == 2)
14255 save_file(file_fld[1], buff, size);
14258 free((void *)filepath);
14261 cmdline_parse_inst_t cmd_ddp_add = {
14262 .f = cmd_ddp_add_parsed,
14264 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14266 (void *)&cmd_ddp_add_ddp,
14267 (void *)&cmd_ddp_add_add,
14268 (void *)&cmd_ddp_add_port_id,
14269 (void *)&cmd_ddp_add_filepath,
14274 /* Delete dynamic device personalization*/
14275 struct cmd_ddp_del_result {
14276 cmdline_fixed_string_t ddp;
14277 cmdline_fixed_string_t del;
14282 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14283 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14284 cmdline_parse_token_string_t cmd_ddp_del_del =
14285 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14286 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14287 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14288 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14289 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14292 cmd_ddp_del_parsed(
14293 void *parsed_result,
14294 __rte_unused struct cmdline *cl,
14295 __rte_unused void *data)
14297 struct cmd_ddp_del_result *res = parsed_result;
14300 int ret = -ENOTSUP;
14302 if (!all_ports_stopped()) {
14303 fprintf(stderr, "Please stop all ports first\n");
14307 buff = open_file(res->filepath, &size);
14311 #ifdef RTE_NET_I40E
14312 if (ret == -ENOTSUP)
14313 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14315 RTE_PMD_I40E_PKG_OP_WR_DEL);
14318 if (ret == -EACCES)
14319 fprintf(stderr, "Profile does not exist.\n");
14321 fprintf(stderr, "Failed to delete profile.\n");
14326 cmdline_parse_inst_t cmd_ddp_del = {
14327 .f = cmd_ddp_del_parsed,
14329 .help_str = "ddp del <port_id> <backup_profile_path>",
14331 (void *)&cmd_ddp_del_ddp,
14332 (void *)&cmd_ddp_del_del,
14333 (void *)&cmd_ddp_del_port_id,
14334 (void *)&cmd_ddp_del_filepath,
14339 /* Get dynamic device personalization profile info */
14340 struct cmd_ddp_info_result {
14341 cmdline_fixed_string_t ddp;
14342 cmdline_fixed_string_t get;
14343 cmdline_fixed_string_t info;
14347 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14348 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14349 cmdline_parse_token_string_t cmd_ddp_info_get =
14350 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14351 cmdline_parse_token_string_t cmd_ddp_info_info =
14352 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14353 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14354 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14357 cmd_ddp_info_parsed(
14358 void *parsed_result,
14359 __rte_unused struct cmdline *cl,
14360 __rte_unused void *data)
14362 struct cmd_ddp_info_result *res = parsed_result;
14365 int ret = -ENOTSUP;
14366 #ifdef RTE_NET_I40E
14369 uint32_t buff_size = 0;
14370 struct rte_pmd_i40e_profile_info info;
14371 uint32_t dev_num = 0;
14372 struct rte_pmd_i40e_ddp_device_id *devs;
14373 uint32_t proto_num = 0;
14374 struct rte_pmd_i40e_proto_info *proto = NULL;
14375 uint32_t pctype_num = 0;
14376 struct rte_pmd_i40e_ptype_info *pctype;
14377 uint32_t ptype_num = 0;
14378 struct rte_pmd_i40e_ptype_info *ptype;
14383 pkg = open_file(res->filepath, &pkg_size);
14387 #ifdef RTE_NET_I40E
14388 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14389 (uint8_t *)&info, sizeof(info),
14390 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14392 printf("Global Track id: 0x%x\n", info.track_id);
14393 printf("Global Version: %d.%d.%d.%d\n",
14394 info.version.major,
14395 info.version.minor,
14396 info.version.update,
14397 info.version.draft);
14398 printf("Global Package name: %s\n\n", info.name);
14401 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14402 (uint8_t *)&info, sizeof(info),
14403 RTE_PMD_I40E_PKG_INFO_HEADER);
14405 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14406 printf("i40e Profile Version: %d.%d.%d.%d\n",
14407 info.version.major,
14408 info.version.minor,
14409 info.version.update,
14410 info.version.draft);
14411 printf("i40e Profile name: %s\n\n", info.name);
14414 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14415 (uint8_t *)&buff_size, sizeof(buff_size),
14416 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14417 if (!ret && buff_size) {
14418 buff = (uint8_t *)malloc(buff_size);
14420 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14422 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14424 printf("Package Notes:\n%s\n\n", buff);
14429 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14430 (uint8_t *)&dev_num, sizeof(dev_num),
14431 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14432 if (!ret && dev_num) {
14433 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14434 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14436 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14437 (uint8_t *)devs, buff_size,
14438 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14440 printf("List of supported devices:\n");
14441 for (i = 0; i < dev_num; i++) {
14442 printf(" %04X:%04X %04X:%04X\n",
14443 devs[i].vendor_dev_id >> 16,
14444 devs[i].vendor_dev_id & 0xFFFF,
14445 devs[i].sub_vendor_dev_id >> 16,
14446 devs[i].sub_vendor_dev_id & 0xFFFF);
14454 /* get information about protocols and packet types */
14455 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14456 (uint8_t *)&proto_num, sizeof(proto_num),
14457 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14458 if (ret || !proto_num)
14459 goto no_print_return;
14461 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14462 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14464 goto no_print_return;
14466 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14468 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14470 printf("List of used protocols:\n");
14471 for (i = 0; i < proto_num; i++)
14472 printf(" %2u: %s\n", proto[i].proto_id,
14476 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14477 (uint8_t *)&pctype_num, sizeof(pctype_num),
14478 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14479 if (ret || !pctype_num)
14480 goto no_print_pctypes;
14482 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14483 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14485 goto no_print_pctypes;
14487 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14489 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14492 goto no_print_pctypes;
14495 printf("List of defined packet classification types:\n");
14496 for (i = 0; i < pctype_num; i++) {
14497 printf(" %2u:", pctype[i].ptype_id);
14498 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14499 proto_id = pctype[i].protocols[j];
14500 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14501 for (n = 0; n < proto_num; n++) {
14502 if (proto[n].proto_id == proto_id) {
14503 printf(" %s", proto[n].name);
14516 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14518 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14519 if (ret || !ptype_num)
14520 goto no_print_return;
14522 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14523 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14525 goto no_print_return;
14527 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14529 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14532 goto no_print_return;
14534 printf("List of defined packet types:\n");
14535 for (i = 0; i < ptype_num; i++) {
14536 printf(" %2u:", ptype[i].ptype_id);
14537 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14538 proto_id = ptype[i].protocols[j];
14539 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14540 for (n = 0; n < proto_num; n++) {
14541 if (proto[n].proto_id == proto_id) {
14542 printf(" %s", proto[n].name);
14558 if (ret == -ENOTSUP)
14559 fprintf(stderr, "Function not supported in PMD driver\n");
14563 cmdline_parse_inst_t cmd_ddp_get_info = {
14564 .f = cmd_ddp_info_parsed,
14566 .help_str = "ddp get info <profile_path>",
14568 (void *)&cmd_ddp_info_ddp,
14569 (void *)&cmd_ddp_info_get,
14570 (void *)&cmd_ddp_info_info,
14571 (void *)&cmd_ddp_info_filepath,
14576 /* Get dynamic device personalization profile info list*/
14577 #define PROFILE_INFO_SIZE 48
14578 #define MAX_PROFILE_NUM 16
14580 struct cmd_ddp_get_list_result {
14581 cmdline_fixed_string_t ddp;
14582 cmdline_fixed_string_t get;
14583 cmdline_fixed_string_t list;
14587 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14588 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14589 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14590 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14591 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14592 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14593 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14594 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14598 cmd_ddp_get_list_parsed(
14599 __rte_unused void *parsed_result,
14600 __rte_unused struct cmdline *cl,
14601 __rte_unused void *data)
14603 #ifdef RTE_NET_I40E
14604 struct cmd_ddp_get_list_result *res = parsed_result;
14605 struct rte_pmd_i40e_profile_list *p_list;
14606 struct rte_pmd_i40e_profile_info *p_info;
14611 int ret = -ENOTSUP;
14613 #ifdef RTE_NET_I40E
14614 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14615 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14617 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14621 if (ret == -ENOTSUP)
14622 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14623 (uint8_t *)p_list, size);
14626 p_num = p_list->p_count;
14627 printf("Profile number is: %d\n\n", p_num);
14629 for (i = 0; i < p_num; i++) {
14630 p_info = &p_list->p_info[i];
14631 printf("Profile %d:\n", i);
14632 printf("Track id: 0x%x\n", p_info->track_id);
14633 printf("Version: %d.%d.%d.%d\n",
14634 p_info->version.major,
14635 p_info->version.minor,
14636 p_info->version.update,
14637 p_info->version.draft);
14638 printf("Profile name: %s\n\n", p_info->name);
14646 fprintf(stderr, "Failed to get ddp list\n");
14649 cmdline_parse_inst_t cmd_ddp_get_list = {
14650 .f = cmd_ddp_get_list_parsed,
14652 .help_str = "ddp get list <port_id>",
14654 (void *)&cmd_ddp_get_list_ddp,
14655 (void *)&cmd_ddp_get_list_get,
14656 (void *)&cmd_ddp_get_list_list,
14657 (void *)&cmd_ddp_get_list_port_id,
14662 /* Configure input set */
14663 struct cmd_cfg_input_set_result {
14664 cmdline_fixed_string_t port;
14665 cmdline_fixed_string_t cfg;
14667 cmdline_fixed_string_t pctype;
14669 cmdline_fixed_string_t inset_type;
14670 cmdline_fixed_string_t opt;
14671 cmdline_fixed_string_t field;
14676 cmd_cfg_input_set_parsed(
14677 __rte_unused void *parsed_result,
14678 __rte_unused struct cmdline *cl,
14679 __rte_unused void *data)
14681 #ifdef RTE_NET_I40E
14682 struct cmd_cfg_input_set_result *res = parsed_result;
14683 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14684 struct rte_pmd_i40e_inset inset;
14686 int ret = -ENOTSUP;
14688 if (!all_ports_stopped()) {
14689 fprintf(stderr, "Please stop all ports first\n");
14693 #ifdef RTE_NET_I40E
14694 if (!strcmp(res->inset_type, "hash_inset"))
14695 inset_type = INSET_HASH;
14696 else if (!strcmp(res->inset_type, "fdir_inset"))
14697 inset_type = INSET_FDIR;
14698 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14699 inset_type = INSET_FDIR_FLX;
14700 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14701 &inset, inset_type);
14703 fprintf(stderr, "Failed to get input set.\n");
14707 if (!strcmp(res->opt, "get")) {
14708 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14711 printf("Field index %d is enabled.\n", res->field_idx);
14713 printf("Field index %d is disabled.\n", res->field_idx);
14715 } else if (!strcmp(res->opt, "set"))
14716 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14718 else if (!strcmp(res->opt, "clear"))
14719 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14722 fprintf(stderr, "Failed to configure input set field.\n");
14726 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14727 &inset, inset_type);
14729 fprintf(stderr, "Failed to set input set.\n");
14734 if (ret == -ENOTSUP)
14735 fprintf(stderr, "Function not supported\n");
14738 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14739 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14741 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14742 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14744 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14745 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14746 port_id, RTE_UINT16);
14747 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14748 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14750 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14751 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14752 pctype_id, RTE_UINT8);
14753 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14754 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14756 "hash_inset#fdir_inset#fdir_flx_inset");
14757 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14758 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14759 opt, "get#set#clear");
14760 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14761 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14763 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14764 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14765 field_idx, RTE_UINT8);
14767 cmdline_parse_inst_t cmd_cfg_input_set = {
14768 .f = cmd_cfg_input_set_parsed,
14770 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14771 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14773 (void *)&cmd_cfg_input_set_port,
14774 (void *)&cmd_cfg_input_set_cfg,
14775 (void *)&cmd_cfg_input_set_port_id,
14776 (void *)&cmd_cfg_input_set_pctype,
14777 (void *)&cmd_cfg_input_set_pctype_id,
14778 (void *)&cmd_cfg_input_set_inset_type,
14779 (void *)&cmd_cfg_input_set_opt,
14780 (void *)&cmd_cfg_input_set_field,
14781 (void *)&cmd_cfg_input_set_field_idx,
14786 /* Clear input set */
14787 struct cmd_clear_input_set_result {
14788 cmdline_fixed_string_t port;
14789 cmdline_fixed_string_t cfg;
14791 cmdline_fixed_string_t pctype;
14793 cmdline_fixed_string_t inset_type;
14794 cmdline_fixed_string_t clear;
14795 cmdline_fixed_string_t all;
14799 cmd_clear_input_set_parsed(
14800 __rte_unused void *parsed_result,
14801 __rte_unused struct cmdline *cl,
14802 __rte_unused void *data)
14804 #ifdef RTE_NET_I40E
14805 struct cmd_clear_input_set_result *res = parsed_result;
14806 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14807 struct rte_pmd_i40e_inset inset;
14809 int ret = -ENOTSUP;
14811 if (!all_ports_stopped()) {
14812 fprintf(stderr, "Please stop all ports first\n");
14816 #ifdef RTE_NET_I40E
14817 if (!strcmp(res->inset_type, "hash_inset"))
14818 inset_type = INSET_HASH;
14819 else if (!strcmp(res->inset_type, "fdir_inset"))
14820 inset_type = INSET_FDIR;
14821 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14822 inset_type = INSET_FDIR_FLX;
14824 memset(&inset, 0, sizeof(inset));
14826 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14827 &inset, inset_type);
14829 fprintf(stderr, "Failed to clear input set.\n");
14835 if (ret == -ENOTSUP)
14836 fprintf(stderr, "Function not supported\n");
14839 cmdline_parse_token_string_t cmd_clear_input_set_port =
14840 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14842 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14843 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14845 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14846 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14847 port_id, RTE_UINT16);
14848 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14849 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14851 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14852 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14853 pctype_id, RTE_UINT8);
14854 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14855 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14857 "hash_inset#fdir_inset#fdir_flx_inset");
14858 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14859 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14861 cmdline_parse_token_string_t cmd_clear_input_set_all =
14862 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14865 cmdline_parse_inst_t cmd_clear_input_set = {
14866 .f = cmd_clear_input_set_parsed,
14868 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14869 "fdir_inset|fdir_flx_inset clear all",
14871 (void *)&cmd_clear_input_set_port,
14872 (void *)&cmd_clear_input_set_cfg,
14873 (void *)&cmd_clear_input_set_port_id,
14874 (void *)&cmd_clear_input_set_pctype,
14875 (void *)&cmd_clear_input_set_pctype_id,
14876 (void *)&cmd_clear_input_set_inset_type,
14877 (void *)&cmd_clear_input_set_clear,
14878 (void *)&cmd_clear_input_set_all,
14883 /* show vf stats */
14885 /* Common result structure for show vf stats */
14886 struct cmd_show_vf_stats_result {
14887 cmdline_fixed_string_t show;
14888 cmdline_fixed_string_t vf;
14889 cmdline_fixed_string_t stats;
14894 /* Common CLI fields show vf stats*/
14895 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14896 TOKEN_STRING_INITIALIZER
14897 (struct cmd_show_vf_stats_result,
14899 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14900 TOKEN_STRING_INITIALIZER
14901 (struct cmd_show_vf_stats_result,
14903 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14904 TOKEN_STRING_INITIALIZER
14905 (struct cmd_show_vf_stats_result,
14907 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14908 TOKEN_NUM_INITIALIZER
14909 (struct cmd_show_vf_stats_result,
14910 port_id, RTE_UINT16);
14911 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14912 TOKEN_NUM_INITIALIZER
14913 (struct cmd_show_vf_stats_result,
14914 vf_id, RTE_UINT16);
14917 cmd_show_vf_stats_parsed(
14918 void *parsed_result,
14919 __rte_unused struct cmdline *cl,
14920 __rte_unused void *data)
14922 struct cmd_show_vf_stats_result *res = parsed_result;
14923 struct rte_eth_stats stats;
14924 int ret = -ENOTSUP;
14925 static const char *nic_stats_border = "########################";
14927 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14930 memset(&stats, 0, sizeof(stats));
14932 #ifdef RTE_NET_I40E
14933 if (ret == -ENOTSUP)
14934 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14938 #ifdef RTE_NET_BNXT
14939 if (ret == -ENOTSUP)
14940 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14949 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
14952 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14955 fprintf(stderr, "function not implemented\n");
14958 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14961 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14962 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14964 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14966 stats.ipackets, stats.imissed, stats.ibytes);
14967 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14968 printf(" RX-nombuf: %-10"PRIu64"\n",
14970 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14972 stats.opackets, stats.oerrors, stats.obytes);
14974 printf(" %s############################%s\n",
14975 nic_stats_border, nic_stats_border);
14978 cmdline_parse_inst_t cmd_show_vf_stats = {
14979 .f = cmd_show_vf_stats_parsed,
14981 .help_str = "show vf stats <port_id> <vf_id>",
14983 (void *)&cmd_show_vf_stats_show,
14984 (void *)&cmd_show_vf_stats_vf,
14985 (void *)&cmd_show_vf_stats_stats,
14986 (void *)&cmd_show_vf_stats_port_id,
14987 (void *)&cmd_show_vf_stats_vf_id,
14992 /* clear vf stats */
14994 /* Common result structure for clear vf stats */
14995 struct cmd_clear_vf_stats_result {
14996 cmdline_fixed_string_t clear;
14997 cmdline_fixed_string_t vf;
14998 cmdline_fixed_string_t stats;
15003 /* Common CLI fields clear vf stats*/
15004 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15005 TOKEN_STRING_INITIALIZER
15006 (struct cmd_clear_vf_stats_result,
15008 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15009 TOKEN_STRING_INITIALIZER
15010 (struct cmd_clear_vf_stats_result,
15012 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15013 TOKEN_STRING_INITIALIZER
15014 (struct cmd_clear_vf_stats_result,
15016 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15017 TOKEN_NUM_INITIALIZER
15018 (struct cmd_clear_vf_stats_result,
15019 port_id, RTE_UINT16);
15020 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15021 TOKEN_NUM_INITIALIZER
15022 (struct cmd_clear_vf_stats_result,
15023 vf_id, RTE_UINT16);
15026 cmd_clear_vf_stats_parsed(
15027 void *parsed_result,
15028 __rte_unused struct cmdline *cl,
15029 __rte_unused void *data)
15031 struct cmd_clear_vf_stats_result *res = parsed_result;
15032 int ret = -ENOTSUP;
15034 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15037 #ifdef RTE_NET_I40E
15038 if (ret == -ENOTSUP)
15039 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15042 #ifdef RTE_NET_BNXT
15043 if (ret == -ENOTSUP)
15044 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15052 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15055 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15058 fprintf(stderr, "function not implemented\n");
15061 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15065 cmdline_parse_inst_t cmd_clear_vf_stats = {
15066 .f = cmd_clear_vf_stats_parsed,
15068 .help_str = "clear vf stats <port_id> <vf_id>",
15070 (void *)&cmd_clear_vf_stats_clear,
15071 (void *)&cmd_clear_vf_stats_vf,
15072 (void *)&cmd_clear_vf_stats_stats,
15073 (void *)&cmd_clear_vf_stats_port_id,
15074 (void *)&cmd_clear_vf_stats_vf_id,
15079 /* port config pctype mapping reset */
15081 /* Common result structure for port config pctype mapping reset */
15082 struct cmd_pctype_mapping_reset_result {
15083 cmdline_fixed_string_t port;
15084 cmdline_fixed_string_t config;
15086 cmdline_fixed_string_t pctype;
15087 cmdline_fixed_string_t mapping;
15088 cmdline_fixed_string_t reset;
15091 /* Common CLI fields for port config pctype mapping reset*/
15092 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15093 TOKEN_STRING_INITIALIZER
15094 (struct cmd_pctype_mapping_reset_result,
15096 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15097 TOKEN_STRING_INITIALIZER
15098 (struct cmd_pctype_mapping_reset_result,
15100 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15101 TOKEN_NUM_INITIALIZER
15102 (struct cmd_pctype_mapping_reset_result,
15103 port_id, RTE_UINT16);
15104 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15105 TOKEN_STRING_INITIALIZER
15106 (struct cmd_pctype_mapping_reset_result,
15108 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15109 TOKEN_STRING_INITIALIZER
15110 (struct cmd_pctype_mapping_reset_result,
15111 mapping, "mapping");
15112 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15113 TOKEN_STRING_INITIALIZER
15114 (struct cmd_pctype_mapping_reset_result,
15118 cmd_pctype_mapping_reset_parsed(
15119 void *parsed_result,
15120 __rte_unused struct cmdline *cl,
15121 __rte_unused void *data)
15123 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15124 int ret = -ENOTSUP;
15126 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15129 #ifdef RTE_NET_I40E
15130 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15137 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15140 fprintf(stderr, "function not implemented\n");
15143 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15147 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15148 .f = cmd_pctype_mapping_reset_parsed,
15150 .help_str = "port config <port_id> pctype mapping reset",
15152 (void *)&cmd_pctype_mapping_reset_port,
15153 (void *)&cmd_pctype_mapping_reset_config,
15154 (void *)&cmd_pctype_mapping_reset_port_id,
15155 (void *)&cmd_pctype_mapping_reset_pctype,
15156 (void *)&cmd_pctype_mapping_reset_mapping,
15157 (void *)&cmd_pctype_mapping_reset_reset,
15162 /* show port pctype mapping */
15164 /* Common result structure for show port pctype mapping */
15165 struct cmd_pctype_mapping_get_result {
15166 cmdline_fixed_string_t show;
15167 cmdline_fixed_string_t port;
15169 cmdline_fixed_string_t pctype;
15170 cmdline_fixed_string_t mapping;
15173 /* Common CLI fields for pctype mapping get */
15174 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15175 TOKEN_STRING_INITIALIZER
15176 (struct cmd_pctype_mapping_get_result,
15178 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15179 TOKEN_STRING_INITIALIZER
15180 (struct cmd_pctype_mapping_get_result,
15182 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15183 TOKEN_NUM_INITIALIZER
15184 (struct cmd_pctype_mapping_get_result,
15185 port_id, RTE_UINT16);
15186 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15187 TOKEN_STRING_INITIALIZER
15188 (struct cmd_pctype_mapping_get_result,
15190 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15191 TOKEN_STRING_INITIALIZER
15192 (struct cmd_pctype_mapping_get_result,
15193 mapping, "mapping");
15196 cmd_pctype_mapping_get_parsed(
15197 void *parsed_result,
15198 __rte_unused struct cmdline *cl,
15199 __rte_unused void *data)
15201 struct cmd_pctype_mapping_get_result *res = parsed_result;
15202 int ret = -ENOTSUP;
15203 #ifdef RTE_NET_I40E
15204 struct rte_pmd_i40e_flow_type_mapping
15205 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15206 int i, j, first_pctype;
15209 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15212 #ifdef RTE_NET_I40E
15213 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15220 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15223 fprintf(stderr, "function not implemented\n");
15226 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15230 #ifdef RTE_NET_I40E
15231 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15232 if (mapping[i].pctype != 0ULL) {
15235 printf("pctype: ");
15236 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15237 if (mapping[i].pctype & (1ULL << j)) {
15238 printf(first_pctype ?
15239 "%02d" : ",%02d", j);
15243 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15249 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15250 .f = cmd_pctype_mapping_get_parsed,
15252 .help_str = "show port <port_id> pctype mapping",
15254 (void *)&cmd_pctype_mapping_get_show,
15255 (void *)&cmd_pctype_mapping_get_port,
15256 (void *)&cmd_pctype_mapping_get_port_id,
15257 (void *)&cmd_pctype_mapping_get_pctype,
15258 (void *)&cmd_pctype_mapping_get_mapping,
15263 /* port config pctype mapping update */
15265 /* Common result structure for port config pctype mapping update */
15266 struct cmd_pctype_mapping_update_result {
15267 cmdline_fixed_string_t port;
15268 cmdline_fixed_string_t config;
15270 cmdline_fixed_string_t pctype;
15271 cmdline_fixed_string_t mapping;
15272 cmdline_fixed_string_t update;
15273 cmdline_fixed_string_t pctype_list;
15274 uint16_t flow_type;
15277 /* Common CLI fields for pctype mapping update*/
15278 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15279 TOKEN_STRING_INITIALIZER
15280 (struct cmd_pctype_mapping_update_result,
15282 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15283 TOKEN_STRING_INITIALIZER
15284 (struct cmd_pctype_mapping_update_result,
15286 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15287 TOKEN_NUM_INITIALIZER
15288 (struct cmd_pctype_mapping_update_result,
15289 port_id, RTE_UINT16);
15290 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15291 TOKEN_STRING_INITIALIZER
15292 (struct cmd_pctype_mapping_update_result,
15294 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15295 TOKEN_STRING_INITIALIZER
15296 (struct cmd_pctype_mapping_update_result,
15297 mapping, "mapping");
15298 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15299 TOKEN_STRING_INITIALIZER
15300 (struct cmd_pctype_mapping_update_result,
15302 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15303 TOKEN_STRING_INITIALIZER
15304 (struct cmd_pctype_mapping_update_result,
15305 pctype_list, NULL);
15306 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15307 TOKEN_NUM_INITIALIZER
15308 (struct cmd_pctype_mapping_update_result,
15309 flow_type, RTE_UINT16);
15312 cmd_pctype_mapping_update_parsed(
15313 void *parsed_result,
15314 __rte_unused struct cmdline *cl,
15315 __rte_unused void *data)
15317 struct cmd_pctype_mapping_update_result *res = parsed_result;
15318 int ret = -ENOTSUP;
15319 #ifdef RTE_NET_I40E
15320 struct rte_pmd_i40e_flow_type_mapping mapping;
15322 unsigned int nb_item;
15323 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15326 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15329 #ifdef RTE_NET_I40E
15330 nb_item = parse_item_list(res->pctype_list, "pctypes",
15331 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15332 mapping.flow_type = res->flow_type;
15333 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15334 mapping.pctype |= (1ULL << pctype_list[i]);
15335 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15345 fprintf(stderr, "invalid pctype or flow type\n");
15348 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15351 fprintf(stderr, "function not implemented\n");
15354 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15358 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15359 .f = cmd_pctype_mapping_update_parsed,
15361 .help_str = "port config <port_id> pctype mapping update"
15362 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15364 (void *)&cmd_pctype_mapping_update_port,
15365 (void *)&cmd_pctype_mapping_update_config,
15366 (void *)&cmd_pctype_mapping_update_port_id,
15367 (void *)&cmd_pctype_mapping_update_pctype,
15368 (void *)&cmd_pctype_mapping_update_mapping,
15369 (void *)&cmd_pctype_mapping_update_update,
15370 (void *)&cmd_pctype_mapping_update_pc_type,
15371 (void *)&cmd_pctype_mapping_update_flow_type,
15376 /* ptype mapping get */
15378 /* Common result structure for ptype mapping get */
15379 struct cmd_ptype_mapping_get_result {
15380 cmdline_fixed_string_t ptype;
15381 cmdline_fixed_string_t mapping;
15382 cmdline_fixed_string_t get;
15384 uint8_t valid_only;
15387 /* Common CLI fields for ptype mapping get */
15388 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15389 TOKEN_STRING_INITIALIZER
15390 (struct cmd_ptype_mapping_get_result,
15392 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15393 TOKEN_STRING_INITIALIZER
15394 (struct cmd_ptype_mapping_get_result,
15395 mapping, "mapping");
15396 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15397 TOKEN_STRING_INITIALIZER
15398 (struct cmd_ptype_mapping_get_result,
15400 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15401 TOKEN_NUM_INITIALIZER
15402 (struct cmd_ptype_mapping_get_result,
15403 port_id, RTE_UINT16);
15404 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15405 TOKEN_NUM_INITIALIZER
15406 (struct cmd_ptype_mapping_get_result,
15407 valid_only, RTE_UINT8);
15410 cmd_ptype_mapping_get_parsed(
15411 void *parsed_result,
15412 __rte_unused struct cmdline *cl,
15413 __rte_unused void *data)
15415 struct cmd_ptype_mapping_get_result *res = parsed_result;
15416 int ret = -ENOTSUP;
15417 #ifdef RTE_NET_I40E
15418 int max_ptype_num = 256;
15419 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15424 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15427 #ifdef RTE_NET_I40E
15428 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15439 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15442 fprintf(stderr, "function not implemented\n");
15445 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15448 #ifdef RTE_NET_I40E
15450 for (i = 0; i < count; i++)
15451 printf("%3d\t0x%08x\n",
15452 mapping[i].hw_ptype, mapping[i].sw_ptype);
15457 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15458 .f = cmd_ptype_mapping_get_parsed,
15460 .help_str = "ptype mapping get <port_id> <valid_only>",
15462 (void *)&cmd_ptype_mapping_get_ptype,
15463 (void *)&cmd_ptype_mapping_get_mapping,
15464 (void *)&cmd_ptype_mapping_get_get,
15465 (void *)&cmd_ptype_mapping_get_port_id,
15466 (void *)&cmd_ptype_mapping_get_valid_only,
15471 /* ptype mapping replace */
15473 /* Common result structure for ptype mapping replace */
15474 struct cmd_ptype_mapping_replace_result {
15475 cmdline_fixed_string_t ptype;
15476 cmdline_fixed_string_t mapping;
15477 cmdline_fixed_string_t replace;
15484 /* Common CLI fields for ptype mapping replace */
15485 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15486 TOKEN_STRING_INITIALIZER
15487 (struct cmd_ptype_mapping_replace_result,
15489 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15490 TOKEN_STRING_INITIALIZER
15491 (struct cmd_ptype_mapping_replace_result,
15492 mapping, "mapping");
15493 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15494 TOKEN_STRING_INITIALIZER
15495 (struct cmd_ptype_mapping_replace_result,
15496 replace, "replace");
15497 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15498 TOKEN_NUM_INITIALIZER
15499 (struct cmd_ptype_mapping_replace_result,
15500 port_id, RTE_UINT16);
15501 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15502 TOKEN_NUM_INITIALIZER
15503 (struct cmd_ptype_mapping_replace_result,
15504 target, RTE_UINT32);
15505 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15506 TOKEN_NUM_INITIALIZER
15507 (struct cmd_ptype_mapping_replace_result,
15509 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15510 TOKEN_NUM_INITIALIZER
15511 (struct cmd_ptype_mapping_replace_result,
15512 pkt_type, RTE_UINT32);
15515 cmd_ptype_mapping_replace_parsed(
15516 void *parsed_result,
15517 __rte_unused struct cmdline *cl,
15518 __rte_unused void *data)
15520 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15521 int ret = -ENOTSUP;
15523 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15526 #ifdef RTE_NET_I40E
15527 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15537 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15538 res->target, res->pkt_type);
15541 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15544 fprintf(stderr, "function not implemented\n");
15547 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15551 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15552 .f = cmd_ptype_mapping_replace_parsed,
15555 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15557 (void *)&cmd_ptype_mapping_replace_ptype,
15558 (void *)&cmd_ptype_mapping_replace_mapping,
15559 (void *)&cmd_ptype_mapping_replace_replace,
15560 (void *)&cmd_ptype_mapping_replace_port_id,
15561 (void *)&cmd_ptype_mapping_replace_target,
15562 (void *)&cmd_ptype_mapping_replace_mask,
15563 (void *)&cmd_ptype_mapping_replace_pkt_type,
15568 /* ptype mapping reset */
15570 /* Common result structure for ptype mapping reset */
15571 struct cmd_ptype_mapping_reset_result {
15572 cmdline_fixed_string_t ptype;
15573 cmdline_fixed_string_t mapping;
15574 cmdline_fixed_string_t reset;
15578 /* Common CLI fields for ptype mapping reset*/
15579 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15580 TOKEN_STRING_INITIALIZER
15581 (struct cmd_ptype_mapping_reset_result,
15583 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15584 TOKEN_STRING_INITIALIZER
15585 (struct cmd_ptype_mapping_reset_result,
15586 mapping, "mapping");
15587 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15588 TOKEN_STRING_INITIALIZER
15589 (struct cmd_ptype_mapping_reset_result,
15591 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15592 TOKEN_NUM_INITIALIZER
15593 (struct cmd_ptype_mapping_reset_result,
15594 port_id, RTE_UINT16);
15597 cmd_ptype_mapping_reset_parsed(
15598 void *parsed_result,
15599 __rte_unused struct cmdline *cl,
15600 __rte_unused void *data)
15602 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15603 int ret = -ENOTSUP;
15605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15608 #ifdef RTE_NET_I40E
15609 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15616 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15619 fprintf(stderr, "function not implemented\n");
15622 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15626 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15627 .f = cmd_ptype_mapping_reset_parsed,
15629 .help_str = "ptype mapping reset <port_id>",
15631 (void *)&cmd_ptype_mapping_reset_ptype,
15632 (void *)&cmd_ptype_mapping_reset_mapping,
15633 (void *)&cmd_ptype_mapping_reset_reset,
15634 (void *)&cmd_ptype_mapping_reset_port_id,
15639 /* ptype mapping update */
15641 /* Common result structure for ptype mapping update */
15642 struct cmd_ptype_mapping_update_result {
15643 cmdline_fixed_string_t ptype;
15644 cmdline_fixed_string_t mapping;
15645 cmdline_fixed_string_t reset;
15651 /* Common CLI fields for ptype mapping update*/
15652 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15653 TOKEN_STRING_INITIALIZER
15654 (struct cmd_ptype_mapping_update_result,
15656 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15657 TOKEN_STRING_INITIALIZER
15658 (struct cmd_ptype_mapping_update_result,
15659 mapping, "mapping");
15660 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15661 TOKEN_STRING_INITIALIZER
15662 (struct cmd_ptype_mapping_update_result,
15664 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15665 TOKEN_NUM_INITIALIZER
15666 (struct cmd_ptype_mapping_update_result,
15667 port_id, RTE_UINT16);
15668 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15669 TOKEN_NUM_INITIALIZER
15670 (struct cmd_ptype_mapping_update_result,
15671 hw_ptype, RTE_UINT8);
15672 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15673 TOKEN_NUM_INITIALIZER
15674 (struct cmd_ptype_mapping_update_result,
15675 sw_ptype, RTE_UINT32);
15678 cmd_ptype_mapping_update_parsed(
15679 void *parsed_result,
15680 __rte_unused struct cmdline *cl,
15681 __rte_unused void *data)
15683 struct cmd_ptype_mapping_update_result *res = parsed_result;
15684 int ret = -ENOTSUP;
15685 #ifdef RTE_NET_I40E
15686 struct rte_pmd_i40e_ptype_mapping mapping;
15688 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15691 #ifdef RTE_NET_I40E
15692 mapping.hw_ptype = res->hw_ptype;
15693 mapping.sw_ptype = res->sw_ptype;
15694 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15704 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15707 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15710 fprintf(stderr, "function not implemented\n");
15713 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15717 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15718 .f = cmd_ptype_mapping_update_parsed,
15720 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15722 (void *)&cmd_ptype_mapping_update_ptype,
15723 (void *)&cmd_ptype_mapping_update_mapping,
15724 (void *)&cmd_ptype_mapping_update_update,
15725 (void *)&cmd_ptype_mapping_update_port_id,
15726 (void *)&cmd_ptype_mapping_update_hw_ptype,
15727 (void *)&cmd_ptype_mapping_update_sw_ptype,
15732 /* Common result structure for file commands */
15733 struct cmd_cmdfile_result {
15734 cmdline_fixed_string_t load;
15735 cmdline_fixed_string_t filename;
15738 /* Common CLI fields for file commands */
15739 cmdline_parse_token_string_t cmd_load_cmdfile =
15740 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15741 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15742 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15745 cmd_load_from_file_parsed(
15746 void *parsed_result,
15747 __rte_unused struct cmdline *cl,
15748 __rte_unused void *data)
15750 struct cmd_cmdfile_result *res = parsed_result;
15752 cmdline_read_from_file(res->filename);
15755 cmdline_parse_inst_t cmd_load_from_file = {
15756 .f = cmd_load_from_file_parsed,
15758 .help_str = "load <filename>",
15760 (void *)&cmd_load_cmdfile,
15761 (void *)&cmd_load_cmdfile_filename,
15766 /* Get Rx offloads capabilities */
15767 struct cmd_rx_offload_get_capa_result {
15768 cmdline_fixed_string_t show;
15769 cmdline_fixed_string_t port;
15771 cmdline_fixed_string_t rx_offload;
15772 cmdline_fixed_string_t capabilities;
15775 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15776 TOKEN_STRING_INITIALIZER
15777 (struct cmd_rx_offload_get_capa_result,
15779 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15780 TOKEN_STRING_INITIALIZER
15781 (struct cmd_rx_offload_get_capa_result,
15783 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15784 TOKEN_NUM_INITIALIZER
15785 (struct cmd_rx_offload_get_capa_result,
15786 port_id, RTE_UINT16);
15787 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15788 TOKEN_STRING_INITIALIZER
15789 (struct cmd_rx_offload_get_capa_result,
15790 rx_offload, "rx_offload");
15791 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15792 TOKEN_STRING_INITIALIZER
15793 (struct cmd_rx_offload_get_capa_result,
15794 capabilities, "capabilities");
15797 print_rx_offloads(uint64_t offloads)
15799 uint64_t single_offload;
15807 begin = __builtin_ctzll(offloads);
15808 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15810 single_offload = 1ULL << begin;
15811 for (bit = begin; bit < end; bit++) {
15812 if (offloads & single_offload)
15814 rte_eth_dev_rx_offload_name(single_offload));
15815 single_offload <<= 1;
15820 cmd_rx_offload_get_capa_parsed(
15821 void *parsed_result,
15822 __rte_unused struct cmdline *cl,
15823 __rte_unused void *data)
15825 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15826 struct rte_eth_dev_info dev_info;
15827 portid_t port_id = res->port_id;
15828 uint64_t queue_offloads;
15829 uint64_t port_offloads;
15832 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15836 queue_offloads = dev_info.rx_queue_offload_capa;
15837 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15839 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15840 printf(" Per Queue :");
15841 print_rx_offloads(queue_offloads);
15844 printf(" Per Port :");
15845 print_rx_offloads(port_offloads);
15849 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15850 .f = cmd_rx_offload_get_capa_parsed,
15852 .help_str = "show port <port_id> rx_offload capabilities",
15854 (void *)&cmd_rx_offload_get_capa_show,
15855 (void *)&cmd_rx_offload_get_capa_port,
15856 (void *)&cmd_rx_offload_get_capa_port_id,
15857 (void *)&cmd_rx_offload_get_capa_rx_offload,
15858 (void *)&cmd_rx_offload_get_capa_capabilities,
15863 /* Get Rx offloads configuration */
15864 struct cmd_rx_offload_get_configuration_result {
15865 cmdline_fixed_string_t show;
15866 cmdline_fixed_string_t port;
15868 cmdline_fixed_string_t rx_offload;
15869 cmdline_fixed_string_t configuration;
15872 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15873 TOKEN_STRING_INITIALIZER
15874 (struct cmd_rx_offload_get_configuration_result,
15876 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15877 TOKEN_STRING_INITIALIZER
15878 (struct cmd_rx_offload_get_configuration_result,
15880 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15881 TOKEN_NUM_INITIALIZER
15882 (struct cmd_rx_offload_get_configuration_result,
15883 port_id, RTE_UINT16);
15884 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15885 TOKEN_STRING_INITIALIZER
15886 (struct cmd_rx_offload_get_configuration_result,
15887 rx_offload, "rx_offload");
15888 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15889 TOKEN_STRING_INITIALIZER
15890 (struct cmd_rx_offload_get_configuration_result,
15891 configuration, "configuration");
15894 cmd_rx_offload_get_configuration_parsed(
15895 void *parsed_result,
15896 __rte_unused struct cmdline *cl,
15897 __rte_unused void *data)
15899 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15900 struct rte_eth_dev_info dev_info;
15901 portid_t port_id = res->port_id;
15902 struct rte_port *port = &ports[port_id];
15903 uint64_t port_offloads;
15904 uint64_t queue_offloads;
15905 uint16_t nb_rx_queues;
15909 printf("Rx Offloading Configuration of port %d :\n", port_id);
15911 port_offloads = port->dev_conf.rxmode.offloads;
15913 print_rx_offloads(port_offloads);
15916 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15920 nb_rx_queues = dev_info.nb_rx_queues;
15921 for (q = 0; q < nb_rx_queues; q++) {
15922 queue_offloads = port->rx_conf[q].offloads;
15923 printf(" Queue[%2d] :", q);
15924 print_rx_offloads(queue_offloads);
15930 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15931 .f = cmd_rx_offload_get_configuration_parsed,
15933 .help_str = "show port <port_id> rx_offload configuration",
15935 (void *)&cmd_rx_offload_get_configuration_show,
15936 (void *)&cmd_rx_offload_get_configuration_port,
15937 (void *)&cmd_rx_offload_get_configuration_port_id,
15938 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15939 (void *)&cmd_rx_offload_get_configuration_configuration,
15944 /* Enable/Disable a per port offloading */
15945 struct cmd_config_per_port_rx_offload_result {
15946 cmdline_fixed_string_t port;
15947 cmdline_fixed_string_t config;
15949 cmdline_fixed_string_t rx_offload;
15950 cmdline_fixed_string_t offload;
15951 cmdline_fixed_string_t on_off;
15954 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15955 TOKEN_STRING_INITIALIZER
15956 (struct cmd_config_per_port_rx_offload_result,
15958 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15959 TOKEN_STRING_INITIALIZER
15960 (struct cmd_config_per_port_rx_offload_result,
15962 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15963 TOKEN_NUM_INITIALIZER
15964 (struct cmd_config_per_port_rx_offload_result,
15965 port_id, RTE_UINT16);
15966 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15967 TOKEN_STRING_INITIALIZER
15968 (struct cmd_config_per_port_rx_offload_result,
15969 rx_offload, "rx_offload");
15970 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15971 TOKEN_STRING_INITIALIZER
15972 (struct cmd_config_per_port_rx_offload_result,
15973 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15974 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15975 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15976 "scatter#buffer_split#timestamp#security#"
15977 "keep_crc#rss_hash");
15978 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15979 TOKEN_STRING_INITIALIZER
15980 (struct cmd_config_per_port_rx_offload_result,
15984 search_rx_offload(const char *name)
15986 uint64_t single_offload;
15987 const char *single_name;
15991 single_offload = 1;
15992 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15993 single_name = rte_eth_dev_rx_offload_name(single_offload);
15994 if (!strcasecmp(single_name, name)) {
15998 single_offload <<= 1;
16002 return single_offload;
16008 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16009 __rte_unused struct cmdline *cl,
16010 __rte_unused void *data)
16012 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16013 portid_t port_id = res->port_id;
16014 struct rte_eth_dev_info dev_info;
16015 struct rte_port *port = &ports[port_id];
16016 uint64_t single_offload;
16017 uint16_t nb_rx_queues;
16021 if (port->port_status != RTE_PORT_STOPPED) {
16023 "Error: Can't config offload when Port %d is not stopped\n",
16028 single_offload = search_rx_offload(res->offload);
16029 if (single_offload == 0) {
16030 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16034 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16038 nb_rx_queues = dev_info.nb_rx_queues;
16039 if (!strcmp(res->on_off, "on")) {
16040 port->dev_conf.rxmode.offloads |= single_offload;
16041 for (q = 0; q < nb_rx_queues; q++)
16042 port->rx_conf[q].offloads |= single_offload;
16044 port->dev_conf.rxmode.offloads &= ~single_offload;
16045 for (q = 0; q < nb_rx_queues; q++)
16046 port->rx_conf[q].offloads &= ~single_offload;
16049 cmd_reconfig_device_queue(port_id, 1, 1);
16052 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16053 .f = cmd_config_per_port_rx_offload_parsed,
16055 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16056 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16057 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16058 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16059 "keep_crc|rss_hash on|off",
16061 (void *)&cmd_config_per_port_rx_offload_result_port,
16062 (void *)&cmd_config_per_port_rx_offload_result_config,
16063 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16064 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16065 (void *)&cmd_config_per_port_rx_offload_result_offload,
16066 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16071 /* Enable/Disable a per queue offloading */
16072 struct cmd_config_per_queue_rx_offload_result {
16073 cmdline_fixed_string_t port;
16075 cmdline_fixed_string_t rxq;
16077 cmdline_fixed_string_t rx_offload;
16078 cmdline_fixed_string_t offload;
16079 cmdline_fixed_string_t on_off;
16082 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16083 TOKEN_STRING_INITIALIZER
16084 (struct cmd_config_per_queue_rx_offload_result,
16086 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16087 TOKEN_NUM_INITIALIZER
16088 (struct cmd_config_per_queue_rx_offload_result,
16089 port_id, RTE_UINT16);
16090 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16091 TOKEN_STRING_INITIALIZER
16092 (struct cmd_config_per_queue_rx_offload_result,
16094 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16095 TOKEN_NUM_INITIALIZER
16096 (struct cmd_config_per_queue_rx_offload_result,
16097 queue_id, RTE_UINT16);
16098 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16099 TOKEN_STRING_INITIALIZER
16100 (struct cmd_config_per_queue_rx_offload_result,
16101 rx_offload, "rx_offload");
16102 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16103 TOKEN_STRING_INITIALIZER
16104 (struct cmd_config_per_queue_rx_offload_result,
16105 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16106 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16107 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16108 "scatter#buffer_split#timestamp#security#keep_crc");
16109 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16110 TOKEN_STRING_INITIALIZER
16111 (struct cmd_config_per_queue_rx_offload_result,
16115 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16116 __rte_unused struct cmdline *cl,
16117 __rte_unused void *data)
16119 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16120 struct rte_eth_dev_info dev_info;
16121 portid_t port_id = res->port_id;
16122 uint16_t queue_id = res->queue_id;
16123 struct rte_port *port = &ports[port_id];
16124 uint64_t single_offload;
16127 if (port->port_status != RTE_PORT_STOPPED) {
16129 "Error: Can't config offload when Port %d is not stopped\n",
16134 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16138 if (queue_id >= dev_info.nb_rx_queues) {
16140 "Error: input queue_id should be 0 ... %d\n",
16141 dev_info.nb_rx_queues - 1);
16145 single_offload = search_rx_offload(res->offload);
16146 if (single_offload == 0) {
16147 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16151 if (!strcmp(res->on_off, "on"))
16152 port->rx_conf[queue_id].offloads |= single_offload;
16154 port->rx_conf[queue_id].offloads &= ~single_offload;
16156 cmd_reconfig_device_queue(port_id, 1, 1);
16159 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16160 .f = cmd_config_per_queue_rx_offload_parsed,
16162 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16163 "vlan_strip|ipv4_cksum|"
16164 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16165 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16166 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16169 (void *)&cmd_config_per_queue_rx_offload_result_port,
16170 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16171 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16172 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16173 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16174 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16175 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16180 /* Get Tx offloads capabilities */
16181 struct cmd_tx_offload_get_capa_result {
16182 cmdline_fixed_string_t show;
16183 cmdline_fixed_string_t port;
16185 cmdline_fixed_string_t tx_offload;
16186 cmdline_fixed_string_t capabilities;
16189 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16190 TOKEN_STRING_INITIALIZER
16191 (struct cmd_tx_offload_get_capa_result,
16193 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16194 TOKEN_STRING_INITIALIZER
16195 (struct cmd_tx_offload_get_capa_result,
16197 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16198 TOKEN_NUM_INITIALIZER
16199 (struct cmd_tx_offload_get_capa_result,
16200 port_id, RTE_UINT16);
16201 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16202 TOKEN_STRING_INITIALIZER
16203 (struct cmd_tx_offload_get_capa_result,
16204 tx_offload, "tx_offload");
16205 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16206 TOKEN_STRING_INITIALIZER
16207 (struct cmd_tx_offload_get_capa_result,
16208 capabilities, "capabilities");
16211 print_tx_offloads(uint64_t offloads)
16213 uint64_t single_offload;
16221 begin = __builtin_ctzll(offloads);
16222 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16224 single_offload = 1ULL << begin;
16225 for (bit = begin; bit < end; bit++) {
16226 if (offloads & single_offload)
16228 rte_eth_dev_tx_offload_name(single_offload));
16229 single_offload <<= 1;
16234 cmd_tx_offload_get_capa_parsed(
16235 void *parsed_result,
16236 __rte_unused struct cmdline *cl,
16237 __rte_unused void *data)
16239 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16240 struct rte_eth_dev_info dev_info;
16241 portid_t port_id = res->port_id;
16242 uint64_t queue_offloads;
16243 uint64_t port_offloads;
16246 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16250 queue_offloads = dev_info.tx_queue_offload_capa;
16251 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16253 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16254 printf(" Per Queue :");
16255 print_tx_offloads(queue_offloads);
16258 printf(" Per Port :");
16259 print_tx_offloads(port_offloads);
16263 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16264 .f = cmd_tx_offload_get_capa_parsed,
16266 .help_str = "show port <port_id> tx_offload capabilities",
16268 (void *)&cmd_tx_offload_get_capa_show,
16269 (void *)&cmd_tx_offload_get_capa_port,
16270 (void *)&cmd_tx_offload_get_capa_port_id,
16271 (void *)&cmd_tx_offload_get_capa_tx_offload,
16272 (void *)&cmd_tx_offload_get_capa_capabilities,
16277 /* Get Tx offloads configuration */
16278 struct cmd_tx_offload_get_configuration_result {
16279 cmdline_fixed_string_t show;
16280 cmdline_fixed_string_t port;
16282 cmdline_fixed_string_t tx_offload;
16283 cmdline_fixed_string_t configuration;
16286 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16287 TOKEN_STRING_INITIALIZER
16288 (struct cmd_tx_offload_get_configuration_result,
16290 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16291 TOKEN_STRING_INITIALIZER
16292 (struct cmd_tx_offload_get_configuration_result,
16294 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16295 TOKEN_NUM_INITIALIZER
16296 (struct cmd_tx_offload_get_configuration_result,
16297 port_id, RTE_UINT16);
16298 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16299 TOKEN_STRING_INITIALIZER
16300 (struct cmd_tx_offload_get_configuration_result,
16301 tx_offload, "tx_offload");
16302 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16303 TOKEN_STRING_INITIALIZER
16304 (struct cmd_tx_offload_get_configuration_result,
16305 configuration, "configuration");
16308 cmd_tx_offload_get_configuration_parsed(
16309 void *parsed_result,
16310 __rte_unused struct cmdline *cl,
16311 __rte_unused void *data)
16313 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16314 struct rte_eth_dev_info dev_info;
16315 portid_t port_id = res->port_id;
16316 struct rte_port *port = &ports[port_id];
16317 uint64_t port_offloads;
16318 uint64_t queue_offloads;
16319 uint16_t nb_tx_queues;
16323 printf("Tx Offloading Configuration of port %d :\n", port_id);
16325 port_offloads = port->dev_conf.txmode.offloads;
16327 print_tx_offloads(port_offloads);
16330 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16334 nb_tx_queues = dev_info.nb_tx_queues;
16335 for (q = 0; q < nb_tx_queues; q++) {
16336 queue_offloads = port->tx_conf[q].offloads;
16337 printf(" Queue[%2d] :", q);
16338 print_tx_offloads(queue_offloads);
16344 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16345 .f = cmd_tx_offload_get_configuration_parsed,
16347 .help_str = "show port <port_id> tx_offload configuration",
16349 (void *)&cmd_tx_offload_get_configuration_show,
16350 (void *)&cmd_tx_offload_get_configuration_port,
16351 (void *)&cmd_tx_offload_get_configuration_port_id,
16352 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16353 (void *)&cmd_tx_offload_get_configuration_configuration,
16358 /* Enable/Disable a per port offloading */
16359 struct cmd_config_per_port_tx_offload_result {
16360 cmdline_fixed_string_t port;
16361 cmdline_fixed_string_t config;
16363 cmdline_fixed_string_t tx_offload;
16364 cmdline_fixed_string_t offload;
16365 cmdline_fixed_string_t on_off;
16368 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16369 TOKEN_STRING_INITIALIZER
16370 (struct cmd_config_per_port_tx_offload_result,
16372 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16373 TOKEN_STRING_INITIALIZER
16374 (struct cmd_config_per_port_tx_offload_result,
16376 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16377 TOKEN_NUM_INITIALIZER
16378 (struct cmd_config_per_port_tx_offload_result,
16379 port_id, RTE_UINT16);
16380 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16381 TOKEN_STRING_INITIALIZER
16382 (struct cmd_config_per_port_tx_offload_result,
16383 tx_offload, "tx_offload");
16384 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16385 TOKEN_STRING_INITIALIZER
16386 (struct cmd_config_per_port_tx_offload_result,
16387 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16388 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16389 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16390 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16391 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16392 "send_on_timestamp");
16393 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16394 TOKEN_STRING_INITIALIZER
16395 (struct cmd_config_per_port_tx_offload_result,
16399 search_tx_offload(const char *name)
16401 uint64_t single_offload;
16402 const char *single_name;
16406 single_offload = 1;
16407 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16408 single_name = rte_eth_dev_tx_offload_name(single_offload);
16409 if (single_name == NULL)
16411 if (!strcasecmp(single_name, name)) {
16414 } else if (!strcasecmp(single_name, "UNKNOWN"))
16416 single_offload <<= 1;
16420 return single_offload;
16426 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16427 __rte_unused struct cmdline *cl,
16428 __rte_unused void *data)
16430 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16431 portid_t port_id = res->port_id;
16432 struct rte_eth_dev_info dev_info;
16433 struct rte_port *port = &ports[port_id];
16434 uint64_t single_offload;
16435 uint16_t nb_tx_queues;
16439 if (port->port_status != RTE_PORT_STOPPED) {
16441 "Error: Can't config offload when Port %d is not stopped\n",
16446 single_offload = search_tx_offload(res->offload);
16447 if (single_offload == 0) {
16448 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16452 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16456 nb_tx_queues = dev_info.nb_tx_queues;
16457 if (!strcmp(res->on_off, "on")) {
16458 port->dev_conf.txmode.offloads |= single_offload;
16459 for (q = 0; q < nb_tx_queues; q++)
16460 port->tx_conf[q].offloads |= single_offload;
16462 port->dev_conf.txmode.offloads &= ~single_offload;
16463 for (q = 0; q < nb_tx_queues; q++)
16464 port->tx_conf[q].offloads &= ~single_offload;
16467 cmd_reconfig_device_queue(port_id, 1, 1);
16470 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16471 .f = cmd_config_per_port_tx_offload_parsed,
16473 .help_str = "port config <port_id> tx_offload "
16474 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16475 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16476 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16477 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16478 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16479 "send_on_timestamp on|off",
16481 (void *)&cmd_config_per_port_tx_offload_result_port,
16482 (void *)&cmd_config_per_port_tx_offload_result_config,
16483 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16484 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16485 (void *)&cmd_config_per_port_tx_offload_result_offload,
16486 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16491 /* Enable/Disable a per queue offloading */
16492 struct cmd_config_per_queue_tx_offload_result {
16493 cmdline_fixed_string_t port;
16495 cmdline_fixed_string_t txq;
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_queue_tx_offload_result_port =
16503 TOKEN_STRING_INITIALIZER
16504 (struct cmd_config_per_queue_tx_offload_result,
16506 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16507 TOKEN_NUM_INITIALIZER
16508 (struct cmd_config_per_queue_tx_offload_result,
16509 port_id, RTE_UINT16);
16510 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16511 TOKEN_STRING_INITIALIZER
16512 (struct cmd_config_per_queue_tx_offload_result,
16514 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16515 TOKEN_NUM_INITIALIZER
16516 (struct cmd_config_per_queue_tx_offload_result,
16517 queue_id, RTE_UINT16);
16518 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16519 TOKEN_STRING_INITIALIZER
16520 (struct cmd_config_per_queue_tx_offload_result,
16521 tx_offload, "tx_offload");
16522 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16523 TOKEN_STRING_INITIALIZER
16524 (struct cmd_config_per_queue_tx_offload_result,
16525 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16526 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16527 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16528 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16529 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16530 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16531 TOKEN_STRING_INITIALIZER
16532 (struct cmd_config_per_queue_tx_offload_result,
16536 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16537 __rte_unused struct cmdline *cl,
16538 __rte_unused void *data)
16540 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16541 struct rte_eth_dev_info dev_info;
16542 portid_t port_id = res->port_id;
16543 uint16_t queue_id = res->queue_id;
16544 struct rte_port *port = &ports[port_id];
16545 uint64_t single_offload;
16548 if (port->port_status != RTE_PORT_STOPPED) {
16550 "Error: Can't config offload when Port %d is not stopped\n",
16555 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16559 if (queue_id >= dev_info.nb_tx_queues) {
16561 "Error: input queue_id should be 0 ... %d\n",
16562 dev_info.nb_tx_queues - 1);
16566 single_offload = search_tx_offload(res->offload);
16567 if (single_offload == 0) {
16568 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16572 if (!strcmp(res->on_off, "on"))
16573 port->tx_conf[queue_id].offloads |= single_offload;
16575 port->tx_conf[queue_id].offloads &= ~single_offload;
16577 cmd_reconfig_device_queue(port_id, 1, 1);
16580 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16581 .f = cmd_config_per_queue_tx_offload_parsed,
16583 .help_str = "port <port_id> txq <queue_id> tx_offload "
16584 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16585 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16586 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16587 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16588 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16591 (void *)&cmd_config_per_queue_tx_offload_result_port,
16592 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16593 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16594 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16595 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16596 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16597 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16602 /* *** configure tx_metadata for specific port *** */
16603 struct cmd_config_tx_metadata_specific_result {
16604 cmdline_fixed_string_t port;
16605 cmdline_fixed_string_t keyword;
16607 cmdline_fixed_string_t item;
16612 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16613 __rte_unused struct cmdline *cl,
16614 __rte_unused void *data)
16616 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16618 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16620 ports[res->port_id].tx_metadata = res->value;
16621 /* Add/remove callback to insert valid metadata in every Tx packet. */
16622 if (ports[res->port_id].tx_metadata)
16623 add_tx_md_callback(res->port_id);
16625 remove_tx_md_callback(res->port_id);
16626 rte_flow_dynf_metadata_register();
16629 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16630 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16632 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16633 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16634 keyword, "config");
16635 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16636 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16637 port_id, RTE_UINT16);
16638 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16639 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16640 item, "tx_metadata");
16641 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16642 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16643 value, RTE_UINT32);
16645 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16646 .f = cmd_config_tx_metadata_specific_parsed,
16648 .help_str = "port config <port_id> tx_metadata <value>",
16650 (void *)&cmd_config_tx_metadata_specific_port,
16651 (void *)&cmd_config_tx_metadata_specific_keyword,
16652 (void *)&cmd_config_tx_metadata_specific_id,
16653 (void *)&cmd_config_tx_metadata_specific_item,
16654 (void *)&cmd_config_tx_metadata_specific_value,
16659 /* *** set dynf *** */
16660 struct cmd_config_tx_dynf_specific_result {
16661 cmdline_fixed_string_t port;
16662 cmdline_fixed_string_t keyword;
16664 cmdline_fixed_string_t item;
16665 cmdline_fixed_string_t name;
16666 cmdline_fixed_string_t value;
16670 cmd_config_dynf_specific_parsed(void *parsed_result,
16671 __rte_unused struct cmdline *cl,
16672 __rte_unused void *data)
16674 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16675 struct rte_mbuf_dynflag desc_flag;
16677 uint64_t old_port_flags;
16679 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16681 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16683 if (strlcpy(desc_flag.name, res->name,
16684 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16685 fprintf(stderr, "Flag name too long\n");
16688 desc_flag.flags = 0;
16689 flag = rte_mbuf_dynflag_register(&desc_flag);
16691 fprintf(stderr, "Can't register flag\n");
16694 strcpy(dynf_names[flag], desc_flag.name);
16696 old_port_flags = ports[res->port_id].mbuf_dynf;
16697 if (!strcmp(res->value, "set")) {
16698 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16699 if (old_port_flags == 0)
16700 add_tx_dynf_callback(res->port_id);
16702 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16703 if (ports[res->port_id].mbuf_dynf == 0)
16704 remove_tx_dynf_callback(res->port_id);
16708 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16709 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16711 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16712 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16713 keyword, "config");
16714 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16715 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16716 port_id, RTE_UINT16);
16717 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16718 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16720 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16721 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16723 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16724 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16725 value, "set#clear");
16727 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16728 .f = cmd_config_dynf_specific_parsed,
16730 .help_str = "port config <port id> dynf <name> set|clear",
16732 (void *)&cmd_config_tx_dynf_specific_port,
16733 (void *)&cmd_config_tx_dynf_specific_keyword,
16734 (void *)&cmd_config_tx_dynf_specific_port_id,
16735 (void *)&cmd_config_tx_dynf_specific_item,
16736 (void *)&cmd_config_tx_dynf_specific_name,
16737 (void *)&cmd_config_tx_dynf_specific_value,
16742 /* *** display tx_metadata per port configuration *** */
16743 struct cmd_show_tx_metadata_result {
16744 cmdline_fixed_string_t cmd_show;
16745 cmdline_fixed_string_t cmd_port;
16746 cmdline_fixed_string_t cmd_keyword;
16751 cmd_show_tx_metadata_parsed(void *parsed_result,
16752 __rte_unused struct cmdline *cl,
16753 __rte_unused void *data)
16755 struct cmd_show_tx_metadata_result *res = parsed_result;
16757 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16758 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16761 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16762 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16763 ports[res->cmd_pid].tx_metadata);
16767 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16768 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16770 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16771 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16773 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16774 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16775 cmd_pid, RTE_UINT16);
16776 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16777 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16778 cmd_keyword, "tx_metadata");
16780 cmdline_parse_inst_t cmd_show_tx_metadata = {
16781 .f = cmd_show_tx_metadata_parsed,
16783 .help_str = "show port <port_id> tx_metadata",
16785 (void *)&cmd_show_tx_metadata_show,
16786 (void *)&cmd_show_tx_metadata_port,
16787 (void *)&cmd_show_tx_metadata_pid,
16788 (void *)&cmd_show_tx_metadata_keyword,
16793 /* *** show fec capability per port configuration *** */
16794 struct cmd_show_fec_capability_result {
16795 cmdline_fixed_string_t cmd_show;
16796 cmdline_fixed_string_t cmd_port;
16797 cmdline_fixed_string_t cmd_fec;
16798 cmdline_fixed_string_t cmd_keyword;
16803 cmd_show_fec_capability_parsed(void *parsed_result,
16804 __rte_unused struct cmdline *cl,
16805 __rte_unused void *data)
16807 struct cmd_show_fec_capability_result *res = parsed_result;
16808 struct rte_eth_fec_capa *speed_fec_capa;
16812 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16813 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16817 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16818 if (ret == -ENOTSUP) {
16819 fprintf(stderr, "Function not implemented\n");
16821 } else if (ret < 0) {
16822 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16826 num = (unsigned int)ret;
16827 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16828 if (speed_fec_capa == NULL) {
16829 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16833 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16835 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
16839 show_fec_capability(num, speed_fec_capa);
16841 free(speed_fec_capa);
16844 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16845 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16847 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16848 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16850 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16851 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16852 cmd_pid, RTE_UINT16);
16853 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16854 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16856 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16857 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16858 cmd_keyword, "capabilities");
16860 cmdline_parse_inst_t cmd_show_capability = {
16861 .f = cmd_show_fec_capability_parsed,
16863 .help_str = "show port <port_id> fec capabilities",
16865 (void *)&cmd_show_fec_capability_show,
16866 (void *)&cmd_show_fec_capability_port,
16867 (void *)&cmd_show_fec_capability_pid,
16868 (void *)&cmd_show_fec_capability_fec,
16869 (void *)&cmd_show_fec_capability_keyword,
16874 /* *** show fec mode per port configuration *** */
16875 struct cmd_show_fec_metadata_result {
16876 cmdline_fixed_string_t cmd_show;
16877 cmdline_fixed_string_t cmd_port;
16878 cmdline_fixed_string_t cmd_keyword;
16883 cmd_show_fec_mode_parsed(void *parsed_result,
16884 __rte_unused struct cmdline *cl,
16885 __rte_unused void *data)
16887 #define FEC_NAME_SIZE 16
16888 struct cmd_show_fec_metadata_result *res = parsed_result;
16890 char buf[FEC_NAME_SIZE];
16893 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16894 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16897 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16898 if (ret == -ENOTSUP) {
16899 fprintf(stderr, "Function not implemented\n");
16901 } else if (ret < 0) {
16902 fprintf(stderr, "Get FEC mode failed\n");
16907 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16908 strlcpy(buf, "off", sizeof(buf));
16910 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16911 strlcpy(buf, "auto", sizeof(buf));
16913 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16914 strlcpy(buf, "baser", sizeof(buf));
16916 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16917 strlcpy(buf, "rs", sizeof(buf));
16923 printf("%s\n", buf);
16926 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16927 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16929 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16930 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16932 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16933 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16934 cmd_pid, RTE_UINT16);
16935 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16936 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16937 cmd_keyword, "fec_mode");
16939 cmdline_parse_inst_t cmd_show_fec_mode = {
16940 .f = cmd_show_fec_mode_parsed,
16942 .help_str = "show port <port_id> fec_mode",
16944 (void *)&cmd_show_fec_mode_show,
16945 (void *)&cmd_show_fec_mode_port,
16946 (void *)&cmd_show_fec_mode_pid,
16947 (void *)&cmd_show_fec_mode_keyword,
16952 /* *** set fec mode per port configuration *** */
16953 struct cmd_set_port_fec_mode {
16954 cmdline_fixed_string_t set;
16955 cmdline_fixed_string_t port;
16957 cmdline_fixed_string_t fec_mode;
16958 cmdline_fixed_string_t fec_value;
16961 /* Common CLI fields for set fec mode */
16962 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16963 TOKEN_STRING_INITIALIZER
16964 (struct cmd_set_port_fec_mode,
16966 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16967 TOKEN_STRING_INITIALIZER
16968 (struct cmd_set_port_fec_mode,
16970 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16971 TOKEN_NUM_INITIALIZER
16972 (struct cmd_set_port_fec_mode,
16973 port_id, RTE_UINT16);
16974 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16975 TOKEN_STRING_INITIALIZER
16976 (struct cmd_set_port_fec_mode,
16977 fec_mode, "fec_mode");
16978 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16979 TOKEN_STRING_INITIALIZER
16980 (struct cmd_set_port_fec_mode,
16984 cmd_set_port_fec_mode_parsed(
16985 void *parsed_result,
16986 __rte_unused struct cmdline *cl,
16987 __rte_unused void *data)
16989 struct cmd_set_port_fec_mode *res = parsed_result;
16990 uint16_t port_id = res->port_id;
16994 ret = parse_fec_mode(res->fec_value, &fec_capa);
16996 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
16997 res->fec_value, port_id);
17001 ret = rte_eth_fec_set(port_id, fec_capa);
17002 if (ret == -ENOTSUP) {
17003 fprintf(stderr, "Function not implemented\n");
17005 } else if (ret < 0) {
17006 fprintf(stderr, "Set FEC mode failed\n");
17011 cmdline_parse_inst_t cmd_set_fec_mode = {
17012 .f = cmd_set_port_fec_mode_parsed,
17014 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17016 (void *)&cmd_set_port_fec_mode_set,
17017 (void *)&cmd_set_port_fec_mode_port,
17018 (void *)&cmd_set_port_fec_mode_port_id,
17019 (void *)&cmd_set_port_fec_mode_str,
17020 (void *)&cmd_set_port_fec_mode_value,
17025 /* show port supported ptypes */
17027 /* Common result structure for show port ptypes */
17028 struct cmd_show_port_supported_ptypes_result {
17029 cmdline_fixed_string_t show;
17030 cmdline_fixed_string_t port;
17032 cmdline_fixed_string_t ptypes;
17035 /* Common CLI fields for show port ptypes */
17036 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17037 TOKEN_STRING_INITIALIZER
17038 (struct cmd_show_port_supported_ptypes_result,
17040 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17041 TOKEN_STRING_INITIALIZER
17042 (struct cmd_show_port_supported_ptypes_result,
17044 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17045 TOKEN_NUM_INITIALIZER
17046 (struct cmd_show_port_supported_ptypes_result,
17047 port_id, RTE_UINT16);
17048 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17049 TOKEN_STRING_INITIALIZER
17050 (struct cmd_show_port_supported_ptypes_result,
17054 cmd_show_port_supported_ptypes_parsed(
17055 void *parsed_result,
17056 __rte_unused struct cmdline *cl,
17057 __rte_unused void *data)
17059 #define RSVD_PTYPE_MASK 0xf0000000
17060 #define MAX_PTYPES_PER_LAYER 16
17061 #define LTYPE_NAMESIZE 32
17062 #define PTYPE_NAMESIZE 256
17063 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17064 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17065 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17066 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17067 uint16_t port_id = res->port_id;
17070 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17074 while (ptype_mask != RSVD_PTYPE_MASK) {
17076 switch (ptype_mask) {
17077 case RTE_PTYPE_L2_MASK:
17078 strlcpy(ltype, "L2", sizeof(ltype));
17080 case RTE_PTYPE_L3_MASK:
17081 strlcpy(ltype, "L3", sizeof(ltype));
17083 case RTE_PTYPE_L4_MASK:
17084 strlcpy(ltype, "L4", sizeof(ltype));
17086 case RTE_PTYPE_TUNNEL_MASK:
17087 strlcpy(ltype, "Tunnel", sizeof(ltype));
17089 case RTE_PTYPE_INNER_L2_MASK:
17090 strlcpy(ltype, "Inner L2", sizeof(ltype));
17092 case RTE_PTYPE_INNER_L3_MASK:
17093 strlcpy(ltype, "Inner L3", sizeof(ltype));
17095 case RTE_PTYPE_INNER_L4_MASK:
17096 strlcpy(ltype, "Inner L4", sizeof(ltype));
17102 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17103 ptype_mask, ptypes,
17104 MAX_PTYPES_PER_LAYER);
17107 printf("Supported %s ptypes:\n", ltype);
17109 printf("%s ptypes unsupported\n", ltype);
17111 for (i = 0; i < ret; ++i) {
17112 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17113 printf("%s\n", buf);
17120 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17121 .f = cmd_show_port_supported_ptypes_parsed,
17123 .help_str = "show port <port_id> ptypes",
17125 (void *)&cmd_show_port_supported_ptypes_show,
17126 (void *)&cmd_show_port_supported_ptypes_port,
17127 (void *)&cmd_show_port_supported_ptypes_port_id,
17128 (void *)&cmd_show_port_supported_ptypes_ptypes,
17133 /* *** display rx/tx descriptor status *** */
17134 struct cmd_show_rx_tx_desc_status_result {
17135 cmdline_fixed_string_t cmd_show;
17136 cmdline_fixed_string_t cmd_port;
17137 cmdline_fixed_string_t cmd_keyword;
17138 cmdline_fixed_string_t cmd_desc;
17139 cmdline_fixed_string_t cmd_status;
17146 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17147 __rte_unused struct cmdline *cl,
17148 __rte_unused void *data)
17150 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17153 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17154 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17158 if (!strcmp(res->cmd_keyword, "rxq")) {
17159 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17163 "Invalid input: queue id = %d, desc id = %d\n",
17164 res->cmd_qid, res->cmd_did);
17167 if (rc == RTE_ETH_RX_DESC_AVAIL)
17168 printf("Desc status = AVAILABLE\n");
17169 else if (rc == RTE_ETH_RX_DESC_DONE)
17170 printf("Desc status = DONE\n");
17172 printf("Desc status = UNAVAILABLE\n");
17173 } else if (!strcmp(res->cmd_keyword, "txq")) {
17174 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17178 "Invalid input: queue id = %d, desc id = %d\n",
17179 res->cmd_qid, res->cmd_did);
17182 if (rc == RTE_ETH_TX_DESC_FULL)
17183 printf("Desc status = FULL\n");
17184 else if (rc == RTE_ETH_TX_DESC_DONE)
17185 printf("Desc status = DONE\n");
17187 printf("Desc status = UNAVAILABLE\n");
17191 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17192 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17194 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17195 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17197 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17198 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17199 cmd_pid, RTE_UINT16);
17200 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17201 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17202 cmd_keyword, "rxq#txq");
17203 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17204 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17205 cmd_qid, RTE_UINT16);
17206 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17207 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17209 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17210 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17211 cmd_did, RTE_UINT16);
17212 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17213 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17214 cmd_status, "status");
17215 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17216 .f = cmd_show_rx_tx_desc_status_parsed,
17218 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17221 (void *)&cmd_show_rx_tx_desc_status_show,
17222 (void *)&cmd_show_rx_tx_desc_status_port,
17223 (void *)&cmd_show_rx_tx_desc_status_pid,
17224 (void *)&cmd_show_rx_tx_desc_status_keyword,
17225 (void *)&cmd_show_rx_tx_desc_status_qid,
17226 (void *)&cmd_show_rx_tx_desc_status_desc,
17227 (void *)&cmd_show_rx_tx_desc_status_did,
17228 (void *)&cmd_show_rx_tx_desc_status_status,
17233 /* *** display rx queue desc used count *** */
17234 struct cmd_show_rx_queue_desc_used_count_result {
17235 cmdline_fixed_string_t cmd_show;
17236 cmdline_fixed_string_t cmd_port;
17237 cmdline_fixed_string_t cmd_rxq;
17238 cmdline_fixed_string_t cmd_desc;
17239 cmdline_fixed_string_t cmd_used;
17240 cmdline_fixed_string_t cmd_count;
17246 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17247 __rte_unused struct cmdline *cl,
17248 __rte_unused void *data)
17250 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17253 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17254 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17258 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17260 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17263 printf("Used desc count = %d\n", rc);
17266 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17267 TOKEN_STRING_INITIALIZER
17268 (struct cmd_show_rx_queue_desc_used_count_result,
17270 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17271 TOKEN_STRING_INITIALIZER
17272 (struct cmd_show_rx_queue_desc_used_count_result,
17274 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17275 TOKEN_NUM_INITIALIZER
17276 (struct cmd_show_rx_queue_desc_used_count_result,
17277 cmd_pid, RTE_UINT16);
17278 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17279 TOKEN_STRING_INITIALIZER
17280 (struct cmd_show_rx_queue_desc_used_count_result,
17282 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17283 TOKEN_NUM_INITIALIZER
17284 (struct cmd_show_rx_queue_desc_used_count_result,
17285 cmd_qid, RTE_UINT16);
17286 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17287 TOKEN_STRING_INITIALIZER
17288 (struct cmd_show_rx_queue_desc_used_count_result,
17289 cmd_count, "desc");
17290 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17291 TOKEN_STRING_INITIALIZER
17292 (struct cmd_show_rx_queue_desc_used_count_result,
17293 cmd_count, "used");
17294 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17295 TOKEN_STRING_INITIALIZER
17296 (struct cmd_show_rx_queue_desc_used_count_result,
17297 cmd_count, "count");
17298 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17299 .f = cmd_show_rx_queue_desc_used_count_parsed,
17301 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17303 (void *)&cmd_show_rx_queue_desc_used_count_show,
17304 (void *)&cmd_show_rx_queue_desc_used_count_port,
17305 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17306 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17307 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17308 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17309 (void *)&cmd_show_rx_queue_desc_used_count_used,
17310 (void *)&cmd_show_rx_queue_desc_used_count_count,
17315 /* Common result structure for set port ptypes */
17316 struct cmd_set_port_ptypes_result {
17317 cmdline_fixed_string_t set;
17318 cmdline_fixed_string_t port;
17320 cmdline_fixed_string_t ptype_mask;
17324 /* Common CLI fields for set port ptypes */
17325 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17326 TOKEN_STRING_INITIALIZER
17327 (struct cmd_set_port_ptypes_result,
17329 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17330 TOKEN_STRING_INITIALIZER
17331 (struct cmd_set_port_ptypes_result,
17333 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17334 TOKEN_NUM_INITIALIZER
17335 (struct cmd_set_port_ptypes_result,
17336 port_id, RTE_UINT16);
17337 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17338 TOKEN_STRING_INITIALIZER
17339 (struct cmd_set_port_ptypes_result,
17340 ptype_mask, "ptype_mask");
17341 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17342 TOKEN_NUM_INITIALIZER
17343 (struct cmd_set_port_ptypes_result,
17347 cmd_set_port_ptypes_parsed(
17348 void *parsed_result,
17349 __rte_unused struct cmdline *cl,
17350 __rte_unused void *data)
17352 struct cmd_set_port_ptypes_result *res = parsed_result;
17353 #define PTYPE_NAMESIZE 256
17354 char ptype_name[PTYPE_NAMESIZE];
17355 uint16_t port_id = res->port_id;
17356 uint32_t ptype_mask = res->mask;
17359 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17362 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17367 uint32_t ptypes[ret];
17369 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17371 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17376 printf("Successfully set following ptypes for Port %d\n", port_id);
17377 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17378 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17379 printf("%s\n", ptype_name);
17382 clear_ptypes = false;
17385 cmdline_parse_inst_t cmd_set_port_ptypes = {
17386 .f = cmd_set_port_ptypes_parsed,
17388 .help_str = "set port <port_id> ptype_mask <mask>",
17390 (void *)&cmd_set_port_ptypes_set,
17391 (void *)&cmd_set_port_ptypes_port,
17392 (void *)&cmd_set_port_ptypes_port_id,
17393 (void *)&cmd_set_port_ptypes_mask_str,
17394 (void *)&cmd_set_port_ptypes_mask_u32,
17399 /* *** display mac addresses added to a port *** */
17400 struct cmd_showport_macs_result {
17401 cmdline_fixed_string_t cmd_show;
17402 cmdline_fixed_string_t cmd_port;
17403 cmdline_fixed_string_t cmd_keyword;
17408 cmd_showport_macs_parsed(void *parsed_result,
17409 __rte_unused struct cmdline *cl,
17410 __rte_unused void *data)
17412 struct cmd_showport_macs_result *res = parsed_result;
17414 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17417 if (!strcmp(res->cmd_keyword, "macs"))
17418 show_macs(res->cmd_pid);
17419 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17420 show_mcast_macs(res->cmd_pid);
17423 cmdline_parse_token_string_t cmd_showport_macs_show =
17424 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17426 cmdline_parse_token_string_t cmd_showport_macs_port =
17427 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17429 cmdline_parse_token_num_t cmd_showport_macs_pid =
17430 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17431 cmd_pid, RTE_UINT16);
17432 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17433 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17434 cmd_keyword, "macs#mcast_macs");
17436 cmdline_parse_inst_t cmd_showport_macs = {
17437 .f = cmd_showport_macs_parsed,
17439 .help_str = "show port <port_id> macs|mcast_macs",
17441 (void *)&cmd_showport_macs_show,
17442 (void *)&cmd_showport_macs_port,
17443 (void *)&cmd_showport_macs_pid,
17444 (void *)&cmd_showport_macs_keyword,
17449 /* ******************************************************************************** */
17451 /* list of instructions */
17452 cmdline_parse_ctx_t main_ctx[] = {
17453 (cmdline_parse_inst_t *)&cmd_help_brief,
17454 (cmdline_parse_inst_t *)&cmd_help_long,
17455 (cmdline_parse_inst_t *)&cmd_quit,
17456 (cmdline_parse_inst_t *)&cmd_load_from_file,
17457 (cmdline_parse_inst_t *)&cmd_showport,
17458 (cmdline_parse_inst_t *)&cmd_showqueue,
17459 (cmdline_parse_inst_t *)&cmd_showeeprom,
17460 (cmdline_parse_inst_t *)&cmd_showportall,
17461 (cmdline_parse_inst_t *)&cmd_showdevice,
17462 (cmdline_parse_inst_t *)&cmd_showcfg,
17463 (cmdline_parse_inst_t *)&cmd_showfwdall,
17464 (cmdline_parse_inst_t *)&cmd_start,
17465 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17466 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17467 (cmdline_parse_inst_t *)&cmd_set_link_up,
17468 (cmdline_parse_inst_t *)&cmd_set_link_down,
17469 (cmdline_parse_inst_t *)&cmd_reset,
17470 (cmdline_parse_inst_t *)&cmd_set_numbers,
17471 (cmdline_parse_inst_t *)&cmd_set_log,
17472 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17473 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17474 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17475 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17476 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17477 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17478 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17479 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17480 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17481 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17482 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17483 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17484 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17485 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17486 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17487 (cmdline_parse_inst_t *)&cmd_set_link_check,
17488 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17489 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17490 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17491 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17492 #ifdef RTE_NET_BOND
17493 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17494 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17495 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17496 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17497 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17498 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17499 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17500 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17501 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17502 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17503 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17504 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17506 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17507 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17508 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17509 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17510 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17511 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17512 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17513 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17514 (cmdline_parse_inst_t *)&cmd_csum_set,
17515 (cmdline_parse_inst_t *)&cmd_csum_show,
17516 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17517 (cmdline_parse_inst_t *)&cmd_tso_set,
17518 (cmdline_parse_inst_t *)&cmd_tso_show,
17519 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17520 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17521 (cmdline_parse_inst_t *)&cmd_gro_enable,
17522 (cmdline_parse_inst_t *)&cmd_gro_flush,
17523 (cmdline_parse_inst_t *)&cmd_gro_show,
17524 (cmdline_parse_inst_t *)&cmd_gso_enable,
17525 (cmdline_parse_inst_t *)&cmd_gso_size,
17526 (cmdline_parse_inst_t *)&cmd_gso_show,
17527 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17528 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17529 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17530 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17531 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17532 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17533 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17534 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17535 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17536 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17537 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17538 (cmdline_parse_inst_t *)&cmd_config_dcb,
17539 (cmdline_parse_inst_t *)&cmd_read_reg,
17540 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17541 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17542 (cmdline_parse_inst_t *)&cmd_write_reg,
17543 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17544 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17545 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17546 (cmdline_parse_inst_t *)&cmd_stop,
17547 (cmdline_parse_inst_t *)&cmd_mac_addr,
17548 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17549 (cmdline_parse_inst_t *)&cmd_set_qmap,
17550 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17551 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17552 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17553 (cmdline_parse_inst_t *)&cmd_operate_port,
17554 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17555 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17556 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17557 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17558 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17559 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17560 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17561 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17562 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17563 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17564 (cmdline_parse_inst_t *)&cmd_config_mtu,
17565 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17566 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17567 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17568 (cmdline_parse_inst_t *)&cmd_config_rss,
17569 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17570 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17571 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17572 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17573 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17574 (cmdline_parse_inst_t *)&cmd_showport_reta,
17575 (cmdline_parse_inst_t *)&cmd_showport_macs,
17576 (cmdline_parse_inst_t *)&cmd_config_burst,
17577 (cmdline_parse_inst_t *)&cmd_config_thresh,
17578 (cmdline_parse_inst_t *)&cmd_config_threshold,
17579 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17580 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17581 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17582 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17583 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17584 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17585 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17586 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17587 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17588 (cmdline_parse_inst_t *)&cmd_dump,
17589 (cmdline_parse_inst_t *)&cmd_dump_one,
17590 #ifdef RTE_NET_I40E
17591 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17593 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17594 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17595 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17596 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17597 (cmdline_parse_inst_t *)&cmd_flow,
17598 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17599 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17600 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17601 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17602 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17603 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17604 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17605 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17606 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17607 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17608 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17609 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17610 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17611 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17612 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17613 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17614 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17615 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17616 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17617 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17618 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17619 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17620 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17621 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17622 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17623 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17624 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17625 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17626 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17627 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17628 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17629 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17630 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17631 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17632 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17633 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17634 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17635 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17636 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17637 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17638 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17639 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17640 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17641 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17642 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17643 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17644 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17645 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17646 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17647 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17648 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17649 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17650 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17651 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17652 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17653 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17654 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17655 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17656 (cmdline_parse_inst_t *)&cmd_ddp_add,
17657 (cmdline_parse_inst_t *)&cmd_ddp_del,
17658 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17659 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17660 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17661 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17662 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17663 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17664 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17665 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17666 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17667 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17668 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17669 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17671 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17672 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17673 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17674 (cmdline_parse_inst_t *)&cmd_queue_region,
17675 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17676 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17677 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17678 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17679 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17680 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17681 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17682 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17683 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17684 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17685 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17686 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17687 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17688 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17689 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17690 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17691 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17692 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17693 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17694 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17695 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17696 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17697 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17698 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17699 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17700 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17701 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17702 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17703 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17704 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17705 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17706 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17707 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17708 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17709 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17710 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17712 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17713 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17715 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17716 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17717 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17718 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17719 (cmdline_parse_inst_t *)&cmd_set_raw,
17720 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17721 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17722 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17723 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17724 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17725 (cmdline_parse_inst_t *)&cmd_show_capability,
17729 /* read cmdline commands from file */
17731 cmdline_read_from_file(const char *filename)
17733 struct cmdline *cl;
17735 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17738 "Failed to create file based cmdline context: %s\n",
17743 cmdline_interact(cl);
17748 printf("Read CLI commands from %s\n", filename);
17751 /* prompt function, called from main on MAIN lcore */
17756 /* initialize non-constant commands */
17757 cmd_set_fwd_mode_init();
17758 cmd_set_fwd_retry_mode_init();
17760 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17761 if (testpmd_cl == NULL)
17764 ret = atexit(prompt_exit);
17766 fprintf(stderr, "Cannot set exit function for cmdline\n");
17768 cmdline_interact(testpmd_cl);
17770 cmdline_stdin_exit(testpmd_cl);
17776 if (testpmd_cl != NULL) {
17777 cmdline_quit(testpmd_cl);
17778 cmdline_stdin_exit(testpmd_cl);
17783 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17785 if (id == (portid_t)RTE_PORT_ALL) {
17788 RTE_ETH_FOREACH_DEV(pid) {
17789 /* check if need_reconfig has been set to 1 */
17790 if (ports[pid].need_reconfig == 0)
17791 ports[pid].need_reconfig = dev;
17792 /* check if need_reconfig_queues has been set to 1 */
17793 if (ports[pid].need_reconfig_queues == 0)
17794 ports[pid].need_reconfig_queues = queue;
17796 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17797 /* check if need_reconfig has been set to 1 */
17798 if (ports[id].need_reconfig == 0)
17799 ports[id].need_reconfig = dev;
17800 /* check if need_reconfig_queues has been set to 1 */
17801 if (ports[id].need_reconfig_queues == 0)
17802 ports[id].need_reconfig_queues = queue;