1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
61 #include <rte_pmd_ixgbe.h>
64 #include <rte_pmd_i40e.h>
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) rxq (queue_id) desc used count\n"
250 " Show current number of filled receive"
251 " packet descriptors.\n\n"
253 "show port (port_id) macs|mcast_macs"
254 " Display list of mac addresses added to port.\n\n"
256 "show port (port_id) fec capabilities"
257 " Show fec capabilities of a port.\n\n"
259 "show port (port_id) fec_mode"
260 " Show fec mode of a port.\n\n"
262 "show port (port_id) flow_ctrl"
263 " Show flow control info of a port.\n\n"
267 if (show_all || !strcmp(res->section, "config")) {
273 "Configuration changes only become active when"
274 " forwarding is started/restarted.\n\n"
277 " Reset forwarding to the default configuration.\n\n"
279 "set verbose (level)\n"
280 " Set the debug verbosity level X.\n\n"
282 "set log global|(type) (level)\n"
283 " Set the log level.\n\n"
286 " Set number of ports.\n\n"
289 " Set number of cores.\n\n"
291 "set coremask (mask)\n"
292 " Set the forwarding cores hexadecimal mask.\n\n"
294 "set portmask (mask)\n"
295 " Set the forwarding ports hexadecimal mask.\n\n"
298 " Set number of packets per burst.\n\n"
300 "set burst tx delay (microseconds) retry (num)\n"
301 " Set the transmit delay time and number of retries,"
302 " effective when retry is enabled.\n\n"
304 "set rxoffs (x[,y]*)\n"
305 " Set the offset of each packet segment on"
306 " receiving if split feature is engaged."
307 " Affects only the queues configured with split"
310 "set rxpkts (x[,y]*)\n"
311 " Set the length of each segment to scatter"
312 " packets on receiving if split feature is engaged."
313 " Affects only the queues configured with split"
316 "set txpkts (x[,y]*)\n"
317 " Set the length of each segment of TXONLY"
318 " and optionally CSUM packets.\n\n"
320 "set txsplit (off|on|rand)\n"
321 " Set the split policy for the TX packets."
322 " Right now only applicable for CSUM and TXONLY"
325 "set txtimes (x, y)\n"
326 " Set the scheduling on timestamps"
327 " timings for the TXONLY mode\n\n"
329 "set corelist (x[,y]*)\n"
330 " Set the list of forwarding cores.\n\n"
332 "set portlist (x[,y]*)\n"
333 " Set the list of forwarding ports.\n\n"
335 "set port setup on (iterator|event)\n"
336 " Select how attached port is retrieved for setup.\n\n"
338 "set tx loopback (port_id) (on|off)\n"
339 " Enable or disable tx loopback.\n\n"
341 "set all queues drop (port_id) (on|off)\n"
342 " Set drop enable bit for all queues.\n\n"
344 "set vf split drop (port_id) (vf_id) (on|off)\n"
345 " Set split drop enable bit for a VF from the PF.\n\n"
347 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
348 " Set MAC antispoof for a VF from the PF.\n\n"
350 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
351 " Enable MACsec offload.\n\n"
353 "set macsec offload (port_id) off\n"
354 " Disable MACsec offload.\n\n"
356 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
357 " Configure MACsec secure connection (SC).\n\n"
359 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
360 " Configure MACsec secure association (SA).\n\n"
362 "set vf broadcast (port_id) (vf_id) (on|off)\n"
363 " Set VF broadcast for a VF from the PF.\n\n"
365 "vlan set stripq (on|off) (port_id,queue_id)\n"
366 " Set the VLAN strip for a queue on a port.\n\n"
368 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
369 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
371 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
372 " Set VLAN insert for a VF from the PF.\n\n"
374 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
375 " Set VLAN antispoof for a VF from the PF.\n\n"
377 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
378 " Set VLAN tag for a VF from the PF.\n\n"
380 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
381 " Set a VF's max bandwidth(Mbps).\n\n"
383 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
384 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
386 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
387 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
389 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
390 " Set some TCs' strict link priority mode on a physical port.\n\n"
392 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
393 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
395 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
396 " Set the VLAN strip or filter or qinq strip or extend\n\n"
398 "vlan set (inner|outer) tpid (value) (port_id)\n"
399 " Set the VLAN TPID for Packet Filtering on"
402 "rx_vlan add (vlan_id|all) (port_id)\n"
403 " Add a vlan_id, or all identifiers, to the set"
404 " of VLAN identifiers filtered by port_id.\n\n"
406 "rx_vlan rm (vlan_id|all) (port_id)\n"
407 " Remove a vlan_id, or all identifiers, from the set"
408 " of VLAN identifiers filtered by port_id.\n\n"
410 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
411 " Add a vlan_id, to the set of VLAN identifiers"
412 "filtered for VF(s) from port_id.\n\n"
414 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
415 " Remove a vlan_id, to the set of VLAN identifiers"
416 "filtered for VF(s) from port_id.\n\n"
418 "rx_vxlan_port add (udp_port) (port_id)\n"
419 " Add an UDP port for VXLAN packet filter on a port\n\n"
421 "rx_vxlan_port rm (udp_port) (port_id)\n"
422 " Remove an UDP port for VXLAN packet filter on a port\n\n"
424 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
425 " Set hardware insertion of VLAN IDs (single or double VLAN "
426 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
428 "tx_vlan set pvid port_id vlan_id (on|off)\n"
429 " Set port based TX VLAN insertion.\n\n"
431 "tx_vlan reset (port_id)\n"
432 " Disable hardware insertion of a VLAN header in"
433 " packets sent on a port.\n\n"
435 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
436 " Select hardware or software calculation of the"
437 " checksum when transmitting a packet using the"
438 " csum forward engine.\n"
439 " ip|udp|tcp|sctp always concern the inner layer.\n"
440 " outer-ip concerns the outer IP layer in"
441 " outer-udp concerns the outer UDP layer in"
442 " case the packet is recognized as a tunnel packet by"
443 " the forward engine (vxlan, gre and ipip are supported)\n"
444 " Please check the NIC datasheet for HW limits.\n\n"
446 "csum parse-tunnel (on|off) (tx_port_id)\n"
447 " If disabled, treat tunnel packets as non-tunneled"
448 " packets (treat inner headers as payload). The port\n"
449 " argument is the port used for TX in csum forward"
452 "csum show (port_id)\n"
453 " Display tx checksum offload configuration\n\n"
455 "tso set (segsize) (portid)\n"
456 " Enable TCP Segmentation Offload in csum forward"
458 " Please check the NIC datasheet for HW limits.\n\n"
461 " Display the status of TCP Segmentation Offload.\n\n"
463 "set port (port_id) gro on|off\n"
464 " Enable or disable Generic Receive Offload in"
465 " csum forwarding engine.\n\n"
467 "show port (port_id) gro\n"
468 " Display GRO configuration.\n\n"
470 "set gro flush (cycles)\n"
471 " Set the cycle to flush GROed packets from"
472 " reassembly tables.\n\n"
474 "set port (port_id) gso (on|off)"
475 " Enable or disable Generic Segmentation Offload in"
476 " csum forwarding engine.\n\n"
478 "set gso segsz (length)\n"
479 " Set max packet length for output GSO segments,"
480 " including packet header and payload.\n\n"
482 "show port (port_id) gso\n"
483 " Show GSO configuration.\n\n"
486 " Set packet forwarding mode.\n\n"
488 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
489 " Add a MAC address on port_id.\n\n"
491 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 " Remove a MAC address from port_id.\n\n"
494 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
495 " Set the default MAC address for port_id.\n\n"
497 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
498 " Add a MAC address for a VF on the port.\n\n"
500 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
501 " Set the MAC address for a VF from the PF.\n\n"
503 "set eth-peer (port_id) (peer_addr)\n"
504 " set the peer address for certain port.\n\n"
506 "set port (port_id) uta (mac_address|all) (on|off)\n"
507 " Add/Remove a or all unicast hash filter(s)"
510 "set promisc (port_id|all) (on|off)\n"
511 " Set the promiscuous mode on port_id, or all.\n\n"
513 "set allmulti (port_id|all) (on|off)\n"
514 " Set the allmulti mode on port_id, or all.\n\n"
516 "set vf promisc (port_id) (vf_id) (on|off)\n"
517 " Set unicast promiscuous mode for a VF from the PF.\n\n"
519 "set vf allmulti (port_id) (vf_id) (on|off)\n"
520 " Set multicast promiscuous mode for a VF from the PF.\n\n"
522 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
523 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
524 " (on|off) autoneg (on|off) (port_id)\n"
525 "set flow_ctrl rx (on|off) (portid)\n"
526 "set flow_ctrl tx (on|off) (portid)\n"
527 "set flow_ctrl high_water (high_water) (portid)\n"
528 "set flow_ctrl low_water (low_water) (portid)\n"
529 "set flow_ctrl pause_time (pause_time) (portid)\n"
530 "set flow_ctrl send_xon (send_xon) (portid)\n"
531 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
532 "set flow_ctrl autoneg (on|off) (port_id)\n"
533 " Set the link flow control parameter on a port.\n\n"
535 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
536 " (low_water) (pause_time) (priority) (port_id)\n"
537 " Set the priority flow control parameter on a"
540 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
541 " Set statistics mapping (qmapping 0..15) for RX/TX"
543 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
544 " on port 0 to mapping 5.\n\n"
546 "set xstats-hide-zero on|off\n"
547 " Set the option to hide the zero values"
548 " for xstats display.\n"
550 "set record-core-cycles on|off\n"
551 " Set the option to enable measurement of CPU cycles.\n"
553 "set record-burst-stats on|off\n"
554 " Set the option to enable display of RX and TX bursts.\n"
556 "set port (port_id) vf (vf_id) rx|tx on|off\n"
557 " Enable/Disable a VF receive/tranmit from a port\n\n"
559 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
561 " AUPE:accepts untagged VLAN;"
562 "ROPE:accept unicast hash\n\n"
563 " BAM:accepts broadcast packets;"
564 "MPE:accepts all multicast packets\n\n"
565 " Enable/Disable a VF receive mode of a port\n\n"
567 "set port (port_id) queue (queue_id) rate (rate_num)\n"
568 " Set rate limit for a queue of a port\n\n"
570 "set port (port_id) vf (vf_id) rate (rate_num) "
571 "queue_mask (queue_mask_value)\n"
572 " Set rate limit for queues in VF of a port\n\n"
574 "set port (port_id) mirror-rule (rule_id)"
575 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
576 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
577 " Set pool or vlan type mirror rule on a port.\n"
578 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
579 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
582 "set port (port_id) mirror-rule (rule_id)"
583 " (uplink-mirror|downlink-mirror) dst-pool"
584 " (pool_id) (on|off)\n"
585 " Set uplink or downlink type mirror rule on a port.\n"
586 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
587 " 0 on' enable mirror income traffic to pool 0.\n\n"
589 "reset port (port_id) mirror-rule (rule_id)\n"
590 " Reset a mirror rule.\n\n"
592 "set flush_rx (on|off)\n"
593 " Flush (default) or don't flush RX streams before"
594 " forwarding. Mainly used with PCAP drivers.\n\n"
596 "set bypass mode (normal|bypass|isolate) (port_id)\n"
597 " Set the bypass mode for the lowest port on bypass enabled"
600 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
601 "mode (normal|bypass|isolate) (port_id)\n"
602 " Set the event required to initiate specified bypass mode for"
603 " the lowest port on a bypass enabled NIC where:\n"
604 " timeout = enable bypass after watchdog timeout.\n"
605 " os_on = enable bypass when OS/board is powered on.\n"
606 " os_off = enable bypass when OS/board is powered off.\n"
607 " power_on = enable bypass when power supply is turned on.\n"
608 " power_off = enable bypass when power supply is turned off."
611 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
612 " Set the bypass watchdog timeout to 'n' seconds"
613 " where 0 = instant.\n\n"
615 "show bypass config (port_id)\n"
616 " Show the bypass configuration for a bypass enabled NIC"
617 " using the lowest port on the NIC.\n\n"
620 "create bonded device (mode) (socket)\n"
621 " Create a new bonded device with specific bonding mode and socket.\n\n"
623 "add bonding slave (slave_id) (port_id)\n"
624 " Add a slave device to a bonded device.\n\n"
626 "remove bonding slave (slave_id) (port_id)\n"
627 " Remove a slave device from a bonded device.\n\n"
629 "set bonding mode (value) (port_id)\n"
630 " Set the bonding mode on a bonded device.\n\n"
632 "set bonding primary (slave_id) (port_id)\n"
633 " Set the primary slave for a bonded device.\n\n"
635 "show bonding config (port_id)\n"
636 " Show the bonding config for port_id.\n\n"
638 "set bonding mac_addr (port_id) (address)\n"
639 " Set the MAC address of a bonded device.\n\n"
641 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
642 " Set Aggregation mode for IEEE802.3AD (mode 4)"
644 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
645 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
647 "set bonding mon_period (port_id) (value)\n"
648 " Set the bonding link status monitoring polling period in ms.\n\n"
650 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
651 " Enable/disable dedicated queues for LACP control traffic.\n\n"
654 "set link-up port (port_id)\n"
655 " Set link up for a port.\n\n"
657 "set link-down port (port_id)\n"
658 " Set link down for a port.\n\n"
660 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
661 " Load a profile package on a port\n\n"
663 "ddp del (port_id) (backup_profile_path)\n"
664 " Delete a profile package from a port\n\n"
666 "ptype mapping get (port_id) (valid_only)\n"
667 " Get ptype mapping on a port\n\n"
669 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
670 " Replace target with the pkt_type in ptype mapping\n\n"
672 "ptype mapping reset (port_id)\n"
673 " Reset ptype mapping on a port\n\n"
675 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
676 " Update a ptype mapping item on a port\n\n"
678 "set port (port_id) ptype_mask (ptype_mask)\n"
679 " set packet types classification for a specific port\n\n"
681 "set port (port_id) queue-region region_id (value) "
682 "queue_start_index (value) queue_num (value)\n"
683 " Set a queue region on a port\n\n"
685 "set port (port_id) queue-region region_id (value) "
687 " Set a flowtype region index on a port\n\n"
689 "set port (port_id) queue-region UP (value) region_id (value)\n"
690 " Set the mapping of User Priority to "
691 "queue region on a port\n\n"
693 "set port (port_id) queue-region flush (on|off)\n"
694 " flush all queue region related configuration\n\n"
696 "show port meter cap (port_id)\n"
697 " Show port meter capability information\n\n"
699 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
700 " meter profile add - srtcm rfc 2697\n\n"
702 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
703 " meter profile add - trtcm rfc 2698\n\n"
705 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
706 " meter profile add - trtcm rfc 4115\n\n"
708 "del port meter profile (port_id) (profile_id)\n"
709 " meter profile delete\n\n"
711 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
712 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
713 "(dscp_tbl_entry63)]\n"
716 "enable port meter (port_id) (mtr_id)\n"
719 "disable port meter (port_id) (mtr_id)\n"
722 "del port meter (port_id) (mtr_id)\n"
725 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
726 "y_actions (actions) r_actions (actions)\n"
727 " meter policy add\n\n"
729 "del port meter policy (port_id) (policy_id)\n"
730 " meter policy delete\n\n"
732 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
733 " meter update meter profile\n\n"
735 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
736 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
737 " update meter dscp table entries\n\n"
739 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
740 "(action0) [(action1) (action2)]\n"
741 " meter update policer action\n\n"
743 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
744 " meter update stats\n\n"
746 "show port (port_id) queue-region\n"
747 " show all queue region related configuration info\n\n"
749 "set port (port_id) fec_mode auto|off|rs|baser\n"
750 " set fec mode for a specific port\n\n"
752 , list_pkt_forwarding_modes()
756 if (show_all || !strcmp(res->section, "ports")) {
762 "----------------\n\n"
764 "port start (port_id|all)\n"
765 " Start all ports or port_id.\n\n"
767 "port stop (port_id|all)\n"
768 " Stop all ports or port_id.\n\n"
770 "port close (port_id|all)\n"
771 " Close all ports or port_id.\n\n"
773 "port reset (port_id|all)\n"
774 " Reset all ports or port_id.\n\n"
776 "port attach (ident)\n"
777 " Attach physical or virtual dev by pci address or virtual device name\n\n"
779 "port detach (port_id)\n"
780 " Detach physical or virtual dev by port_id\n\n"
782 "port config (port_id|all)"
783 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
784 " duplex (half|full|auto)\n"
785 " Set speed and duplex for all ports or port_id\n\n"
787 "port config (port_id|all) loopback (mode)\n"
788 " Set loopback mode for all ports or port_id\n\n"
790 "port config all (rxq|txq|rxd|txd) (value)\n"
791 " Set number for rxq/txq/rxd/txd.\n\n"
793 "port config all max-pkt-len (value)\n"
794 " Set the max packet length.\n\n"
796 "port config all max-lro-pkt-size (value)\n"
797 " Set the max LRO aggregated packet size.\n\n"
799 "port config all drop-en (on|off)\n"
800 " Enable or disable packet drop on all RX queues of all ports when no "
801 "receive buffers available.\n\n"
803 "port config all rss (all|default|ip|tcp|udp|sctp|"
804 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
805 "level-outer|level-inner|<flowtype_id>)\n"
806 " Set the RSS mode.\n\n"
808 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
809 " Set the RSS redirection table.\n\n"
811 "port config (port_id) dcb vt (on|off) (traffic_class)"
813 " Set the DCB mode.\n\n"
815 "port config all burst (value)\n"
816 " Set the number of packets per burst.\n\n"
818 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
820 " Set the ring prefetch/host/writeback threshold"
821 " for tx/rx queue.\n\n"
823 "port config all (txfreet|txrst|rxfreet) (value)\n"
824 " Set free threshold for rx/tx, or set"
825 " tx rs bit threshold.\n\n"
826 "port config mtu X value\n"
827 " Set the MTU of port X to a given value\n\n"
829 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
830 " Set a rx/tx queue's ring size configuration, the new"
831 " value will take effect after command that (re-)start the port"
832 " or command that setup the specific queue\n\n"
834 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
835 " Start/stop a rx/tx queue of port X. Only take effect"
836 " when port X is started\n\n"
838 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
839 " Switch on/off a deferred start of port X rx/tx queue. Only"
840 " take effect when port X is stopped.\n\n"
842 "port (port_id) (rxq|txq) (queue_id) setup\n"
843 " Setup a rx/tx queue of port X.\n\n"
845 "port config (port_id) pctype mapping reset\n"
846 " Reset flow type to pctype mapping on a port\n\n"
848 "port config (port_id) pctype mapping update"
849 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
850 " Update a flow type to pctype mapping item on a port\n\n"
852 "port config (port_id) pctype (pctype_id) hash_inset|"
853 "fdir_inset|fdir_flx_inset get|set|clear field\n"
855 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
857 "port config (port_id) pctype (pctype_id) hash_inset|"
858 "fdir_inset|fdir_flx_inset clear all"
859 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
861 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
862 " Add/remove UDP tunnel port for tunneling offload\n\n"
864 "port config <port_id> rx_offload vlan_strip|"
865 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
866 "outer_ipv4_cksum|macsec_strip|header_split|"
867 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
868 "buffer_split|timestamp|security|keep_crc on|off\n"
869 " Enable or disable a per port Rx offloading"
870 " on all Rx queues of a port\n\n"
872 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
873 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
874 "outer_ipv4_cksum|macsec_strip|header_split|"
875 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
876 "buffer_split|timestamp|security|keep_crc on|off\n"
877 " Enable or disable a per queue Rx offloading"
878 " only on a specific Rx queue\n\n"
880 "port config (port_id) tx_offload vlan_insert|"
881 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
882 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
883 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
884 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
886 " Enable or disable a per port Tx offloading"
887 " on all Tx queues of a port\n\n"
889 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
890 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
891 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
892 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
893 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
895 " Enable or disable a per queue Tx offloading"
896 " only on a specific Tx queue\n\n"
898 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
899 " Load an eBPF program as a callback"
900 " for particular RX/TX queue\n\n"
902 "bpf-unload rx|tx (port) (queue)\n"
903 " Unload previously loaded eBPF program"
904 " for particular RX/TX queue\n\n"
906 "port config (port_id) tx_metadata (value)\n"
907 " Set Tx metadata value per port. Testpmd will add this value"
908 " to any Tx packet sent from this port\n\n"
910 "port config (port_id) dynf (name) set|clear\n"
911 " Register a dynf and Set/clear this flag on Tx. "
912 "Testpmd will set this value to any Tx packet "
913 "sent from this port\n\n"
915 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
916 " Cleanup txq mbufs for a specific Tx queue\n\n"
920 if (show_all || !strcmp(res->section, "registers")) {
928 "read reg (port_id) (address)\n"
929 " Display value of a port register.\n\n"
931 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
932 " Display a port register bit field.\n\n"
934 "read regbit (port_id) (address) (bit_x)\n"
935 " Display a single port register bit.\n\n"
937 "write reg (port_id) (address) (value)\n"
938 " Set value of a port register.\n\n"
940 "write regfield (port_id) (address) (bit_x) (bit_y)"
942 " Set bit field of a port register.\n\n"
944 "write regbit (port_id) (address) (bit_x) (value)\n"
945 " Set single bit value of a port register.\n\n"
948 if (show_all || !strcmp(res->section, "filters")) {
957 "flow_director_filter (port_id) mode raw (add|del|update)"
958 " flow (flow_id) (drop|fwd) queue (queue_id)"
959 " fd_id (fd_id_value) packet (packet file name)\n"
960 " Add/Del a raw type flow director filter.\n\n"
963 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
964 " src_mask (ipv4_src) (ipv6_src) (src_port)"
965 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
966 " Set flow director IP mask.\n\n"
968 "flow_director_mask (port_id) mode MAC-VLAN"
969 " vlan (vlan_value)\n"
970 " Set flow director MAC-VLAN mask.\n\n"
972 "flow_director_mask (port_id) mode Tunnel"
973 " vlan (vlan_value) mac (mac_value)"
974 " tunnel-type (tunnel_type_value)"
975 " tunnel-id (tunnel_id_value)\n"
976 " Set flow director Tunnel mask.\n\n"
978 "flow_director_flex_payload (port_id)"
979 " (raw|l2|l3|l4) (config)\n"
980 " Configure flex payload selection.\n\n"
982 "flow validate {port_id}"
983 " [group {group_id}] [priority {level}]"
984 " [ingress] [egress]"
985 " pattern {item} [/ {item} [...]] / end"
986 " actions {action} [/ {action} [...]] / end\n"
987 " Check whether a flow rule can be created.\n\n"
989 "flow create {port_id}"
990 " [group {group_id}] [priority {level}]"
991 " [ingress] [egress]"
992 " pattern {item} [/ {item} [...]] / end"
993 " actions {action} [/ {action} [...]] / end\n"
994 " Create a flow rule.\n\n"
996 "flow destroy {port_id} rule {rule_id} [...]\n"
997 " Destroy specific flow rules.\n\n"
999 "flow flush {port_id}\n"
1000 " Destroy all flow rules.\n\n"
1002 "flow query {port_id} {rule_id} {action}\n"
1003 " Query an existing flow rule.\n\n"
1005 "flow list {port_id} [group {group_id}] [...]\n"
1006 " List existing flow rules sorted by priority,"
1007 " filtered by group identifiers.\n\n"
1009 "flow isolate {port_id} {boolean}\n"
1010 " Restrict ingress traffic to the defined"
1013 "flow aged {port_id} [destroy]\n"
1014 " List and destroy aged flows"
1017 "flow indirect_action {port_id} create"
1018 " [action_id {indirect_action_id}]"
1019 " [ingress] [egress]"
1020 " action {action} / end\n"
1021 " Create indirect action.\n\n"
1023 "flow indirect_action {port_id} update"
1024 " {indirect_action_id} action {action} / end\n"
1025 " Update indirect action.\n\n"
1027 "flow indirect_action {port_id} destroy"
1028 " action_id {indirect_action_id} [...]\n"
1029 " Destroy specific indirect actions.\n\n"
1031 "flow indirect_action {port_id} query"
1032 " {indirect_action_id}\n"
1033 " Query an existing indirect action.\n\n"
1035 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1036 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1037 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1038 " Configure the VXLAN encapsulation for flows.\n\n"
1040 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1041 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1042 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1043 " eth-dst (eth-dst)\n"
1044 " Configure the VXLAN encapsulation for flows.\n\n"
1046 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1047 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1048 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1049 " eth-dst (eth-dst)\n"
1050 " Configure the VXLAN encapsulation for flows.\n\n"
1052 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1053 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1055 " Configure the NVGRE encapsulation for flows.\n\n"
1057 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1058 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1059 " eth-src (eth-src) eth-dst (eth-dst)\n"
1060 " Configure the NVGRE encapsulation for flows.\n\n"
1062 "set raw_encap {flow items}\n"
1063 " Configure the encapsulation with raw data.\n\n"
1065 "set raw_decap {flow items}\n"
1066 " Configure the decapsulation with raw data.\n\n"
1071 if (show_all || !strcmp(res->section, "traffic_management")) {
1075 "Traffic Management:\n"
1077 "show port tm cap (port_id)\n"
1078 " Display the port TM capability.\n\n"
1080 "show port tm level cap (port_id) (level_id)\n"
1081 " Display the port TM hierarchical level capability.\n\n"
1083 "show port tm node cap (port_id) (node_id)\n"
1084 " Display the port TM node capability.\n\n"
1086 "show port tm node type (port_id) (node_id)\n"
1087 " Display the port TM node type.\n\n"
1089 "show port tm node stats (port_id) (node_id) (clear)\n"
1090 " Display the port TM node stats.\n\n"
1092 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1093 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1094 " (packet_length_adjust) (packet_mode)\n"
1095 " Add port tm node private shaper profile.\n\n"
1097 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1098 " Delete port tm node private shaper profile.\n\n"
1100 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1101 " (shaper_profile_id)\n"
1102 " Add/update port tm node shared shaper.\n\n"
1104 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1105 " Delete port tm node shared shaper.\n\n"
1107 "set port tm node shaper profile (port_id) (node_id)"
1108 " (shaper_profile_id)\n"
1109 " Set port tm node shaper profile.\n\n"
1111 "add port tm node wred profile (port_id) (wred_profile_id)"
1112 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1113 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1114 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1115 " Add port tm node wred profile.\n\n"
1117 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1118 " Delete port tm node wred profile.\n\n"
1120 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1121 " (priority) (weight) (level_id) (shaper_profile_id)"
1122 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1123 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1124 " Add port tm nonleaf node.\n\n"
1126 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1127 " (priority) (weight) (level_id) (shaper_profile_id)"
1128 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1129 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1130 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1132 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1133 " (priority) (weight) (level_id) (shaper_profile_id)"
1134 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1135 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1136 " Add port tm leaf node.\n\n"
1138 "del port tm node (port_id) (node_id)\n"
1139 " Delete port tm node.\n\n"
1141 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1142 " (priority) (weight)\n"
1143 " Set port tm node parent.\n\n"
1145 "suspend port tm node (port_id) (node_id)"
1146 " Suspend tm node.\n\n"
1148 "resume port tm node (port_id) (node_id)"
1149 " Resume tm node.\n\n"
1151 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1152 " Commit tm hierarchy.\n\n"
1154 "set port tm mark ip_ecn (port) (green) (yellow)"
1156 " Enables/Disables the traffic management marking"
1157 " for IP ECN (Explicit Congestion Notification)"
1158 " packets on a given port\n\n"
1160 "set port tm mark ip_dscp (port) (green) (yellow)"
1162 " Enables/Disables the traffic management marking"
1163 " on the port for IP dscp packets\n\n"
1165 "set port tm mark vlan_dei (port) (green) (yellow)"
1167 " Enables/Disables the traffic management marking"
1168 " on the port for VLAN packets with DEI enabled\n\n"
1172 if (show_all || !strcmp(res->section, "devices")) {
1176 "Device Operations:\n"
1178 "device detach (identifier)\n"
1179 " Detach device by identifier.\n\n"
1185 cmdline_parse_token_string_t cmd_help_long_help =
1186 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1188 cmdline_parse_token_string_t cmd_help_long_section =
1189 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1190 "all#control#display#config#"
1191 "ports#registers#filters#traffic_management#devices");
1193 cmdline_parse_inst_t cmd_help_long = {
1194 .f = cmd_help_long_parsed,
1196 .help_str = "help all|control|display|config|ports|register|"
1197 "filters|traffic_management|devices: "
1200 (void *)&cmd_help_long_help,
1201 (void *)&cmd_help_long_section,
1207 /* *** start/stop/close all ports *** */
1208 struct cmd_operate_port_result {
1209 cmdline_fixed_string_t keyword;
1210 cmdline_fixed_string_t name;
1211 cmdline_fixed_string_t value;
1214 static void cmd_operate_port_parsed(void *parsed_result,
1215 __rte_unused struct cmdline *cl,
1216 __rte_unused void *data)
1218 struct cmd_operate_port_result *res = parsed_result;
1220 if (!strcmp(res->name, "start"))
1221 start_port(RTE_PORT_ALL);
1222 else if (!strcmp(res->name, "stop"))
1223 stop_port(RTE_PORT_ALL);
1224 else if (!strcmp(res->name, "close"))
1225 close_port(RTE_PORT_ALL);
1226 else if (!strcmp(res->name, "reset"))
1227 reset_port(RTE_PORT_ALL);
1229 printf("Unknown parameter\n");
1232 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1233 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1235 cmdline_parse_token_string_t cmd_operate_port_all_port =
1236 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1237 "start#stop#close#reset");
1238 cmdline_parse_token_string_t cmd_operate_port_all_all =
1239 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1241 cmdline_parse_inst_t cmd_operate_port = {
1242 .f = cmd_operate_port_parsed,
1244 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1246 (void *)&cmd_operate_port_all_cmd,
1247 (void *)&cmd_operate_port_all_port,
1248 (void *)&cmd_operate_port_all_all,
1253 /* *** start/stop/close specific port *** */
1254 struct cmd_operate_specific_port_result {
1255 cmdline_fixed_string_t keyword;
1256 cmdline_fixed_string_t name;
1260 static void cmd_operate_specific_port_parsed(void *parsed_result,
1261 __rte_unused struct cmdline *cl,
1262 __rte_unused void *data)
1264 struct cmd_operate_specific_port_result *res = parsed_result;
1266 if (!strcmp(res->name, "start"))
1267 start_port(res->value);
1268 else if (!strcmp(res->name, "stop"))
1269 stop_port(res->value);
1270 else if (!strcmp(res->name, "close"))
1271 close_port(res->value);
1272 else if (!strcmp(res->name, "reset"))
1273 reset_port(res->value);
1275 printf("Unknown parameter\n");
1278 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1281 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1282 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1283 name, "start#stop#close#reset");
1284 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1285 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1288 cmdline_parse_inst_t cmd_operate_specific_port = {
1289 .f = cmd_operate_specific_port_parsed,
1291 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1293 (void *)&cmd_operate_specific_port_cmd,
1294 (void *)&cmd_operate_specific_port_port,
1295 (void *)&cmd_operate_specific_port_id,
1300 /* *** enable port setup (after attach) via iterator or event *** */
1301 struct cmd_set_port_setup_on_result {
1302 cmdline_fixed_string_t set;
1303 cmdline_fixed_string_t port;
1304 cmdline_fixed_string_t setup;
1305 cmdline_fixed_string_t on;
1306 cmdline_fixed_string_t mode;
1309 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1310 __rte_unused struct cmdline *cl,
1311 __rte_unused void *data)
1313 struct cmd_set_port_setup_on_result *res = parsed_result;
1315 if (strcmp(res->mode, "event") == 0)
1316 setup_on_probe_event = true;
1317 else if (strcmp(res->mode, "iterator") == 0)
1318 setup_on_probe_event = false;
1320 printf("Unknown mode\n");
1323 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1324 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1326 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1327 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1329 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1330 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1332 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1333 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1335 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1336 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1337 mode, "iterator#event");
1339 cmdline_parse_inst_t cmd_set_port_setup_on = {
1340 .f = cmd_set_port_setup_on_parsed,
1342 .help_str = "set port setup on iterator|event",
1344 (void *)&cmd_set_port_setup_on_set,
1345 (void *)&cmd_set_port_setup_on_port,
1346 (void *)&cmd_set_port_setup_on_setup,
1347 (void *)&cmd_set_port_setup_on_on,
1348 (void *)&cmd_set_port_setup_on_mode,
1353 /* *** attach a specified port *** */
1354 struct cmd_operate_attach_port_result {
1355 cmdline_fixed_string_t port;
1356 cmdline_fixed_string_t keyword;
1357 cmdline_multi_string_t identifier;
1360 static void cmd_operate_attach_port_parsed(void *parsed_result,
1361 __rte_unused struct cmdline *cl,
1362 __rte_unused void *data)
1364 struct cmd_operate_attach_port_result *res = parsed_result;
1366 if (!strcmp(res->keyword, "attach"))
1367 attach_port(res->identifier);
1369 printf("Unknown parameter\n");
1372 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1373 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1375 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1376 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1378 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1379 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1380 identifier, TOKEN_STRING_MULTI);
1382 cmdline_parse_inst_t cmd_operate_attach_port = {
1383 .f = cmd_operate_attach_port_parsed,
1385 .help_str = "port attach <identifier>: "
1386 "(identifier: pci address or virtual dev name)",
1388 (void *)&cmd_operate_attach_port_port,
1389 (void *)&cmd_operate_attach_port_keyword,
1390 (void *)&cmd_operate_attach_port_identifier,
1395 /* *** detach a specified port *** */
1396 struct cmd_operate_detach_port_result {
1397 cmdline_fixed_string_t port;
1398 cmdline_fixed_string_t keyword;
1402 static void cmd_operate_detach_port_parsed(void *parsed_result,
1403 __rte_unused struct cmdline *cl,
1404 __rte_unused void *data)
1406 struct cmd_operate_detach_port_result *res = parsed_result;
1408 if (!strcmp(res->keyword, "detach")) {
1409 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1410 detach_port_device(res->port_id);
1412 printf("Unknown parameter\n");
1416 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1417 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1419 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1420 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1422 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1423 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1424 port_id, RTE_UINT16);
1426 cmdline_parse_inst_t cmd_operate_detach_port = {
1427 .f = cmd_operate_detach_port_parsed,
1429 .help_str = "port detach <port_id>",
1431 (void *)&cmd_operate_detach_port_port,
1432 (void *)&cmd_operate_detach_port_keyword,
1433 (void *)&cmd_operate_detach_port_port_id,
1438 /* *** detach device by identifier *** */
1439 struct cmd_operate_detach_device_result {
1440 cmdline_fixed_string_t device;
1441 cmdline_fixed_string_t keyword;
1442 cmdline_fixed_string_t identifier;
1445 static void cmd_operate_detach_device_parsed(void *parsed_result,
1446 __rte_unused struct cmdline *cl,
1447 __rte_unused void *data)
1449 struct cmd_operate_detach_device_result *res = parsed_result;
1451 if (!strcmp(res->keyword, "detach"))
1452 detach_devargs(res->identifier);
1454 printf("Unknown parameter\n");
1457 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1460 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1461 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1463 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1464 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1467 cmdline_parse_inst_t cmd_operate_detach_device = {
1468 .f = cmd_operate_detach_device_parsed,
1470 .help_str = "device detach <identifier>:"
1471 "(identifier: pci address or virtual dev name)",
1473 (void *)&cmd_operate_detach_device_device,
1474 (void *)&cmd_operate_detach_device_keyword,
1475 (void *)&cmd_operate_detach_device_identifier,
1479 /* *** configure speed for all ports *** */
1480 struct cmd_config_speed_all {
1481 cmdline_fixed_string_t port;
1482 cmdline_fixed_string_t keyword;
1483 cmdline_fixed_string_t all;
1484 cmdline_fixed_string_t item1;
1485 cmdline_fixed_string_t item2;
1486 cmdline_fixed_string_t value1;
1487 cmdline_fixed_string_t value2;
1491 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1496 if (!strcmp(duplexstr, "half")) {
1497 duplex = ETH_LINK_HALF_DUPLEX;
1498 } else if (!strcmp(duplexstr, "full")) {
1499 duplex = ETH_LINK_FULL_DUPLEX;
1500 } else if (!strcmp(duplexstr, "auto")) {
1501 duplex = ETH_LINK_FULL_DUPLEX;
1503 printf("Unknown duplex parameter\n");
1507 if (!strcmp(speedstr, "10")) {
1508 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1509 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1510 } else if (!strcmp(speedstr, "100")) {
1511 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1512 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1514 if (duplex != ETH_LINK_FULL_DUPLEX) {
1515 printf("Invalid speed/duplex parameters\n");
1518 if (!strcmp(speedstr, "1000")) {
1519 *speed = ETH_LINK_SPEED_1G;
1520 } else if (!strcmp(speedstr, "10000")) {
1521 *speed = ETH_LINK_SPEED_10G;
1522 } else if (!strcmp(speedstr, "25000")) {
1523 *speed = ETH_LINK_SPEED_25G;
1524 } else if (!strcmp(speedstr, "40000")) {
1525 *speed = ETH_LINK_SPEED_40G;
1526 } else if (!strcmp(speedstr, "50000")) {
1527 *speed = ETH_LINK_SPEED_50G;
1528 } else if (!strcmp(speedstr, "100000")) {
1529 *speed = ETH_LINK_SPEED_100G;
1530 } else if (!strcmp(speedstr, "200000")) {
1531 *speed = ETH_LINK_SPEED_200G;
1532 } else if (!strcmp(speedstr, "auto")) {
1533 *speed = ETH_LINK_SPEED_AUTONEG;
1535 printf("Unknown speed parameter\n");
1540 if (*speed != ETH_LINK_SPEED_AUTONEG)
1541 *speed |= ETH_LINK_SPEED_FIXED;
1547 cmd_config_speed_all_parsed(void *parsed_result,
1548 __rte_unused struct cmdline *cl,
1549 __rte_unused void *data)
1551 struct cmd_config_speed_all *res = parsed_result;
1552 uint32_t link_speed;
1555 if (!all_ports_stopped()) {
1556 printf("Please stop all ports first\n");
1560 if (parse_and_check_speed_duplex(res->value1, res->value2,
1564 RTE_ETH_FOREACH_DEV(pid) {
1565 ports[pid].dev_conf.link_speeds = link_speed;
1568 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1571 cmdline_parse_token_string_t cmd_config_speed_all_port =
1572 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1573 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1576 cmdline_parse_token_string_t cmd_config_speed_all_all =
1577 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1578 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1579 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1580 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1582 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1583 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1584 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1585 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1589 cmdline_parse_inst_t cmd_config_speed_all = {
1590 .f = cmd_config_speed_all_parsed,
1592 .help_str = "port config all speed "
1593 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1596 (void *)&cmd_config_speed_all_port,
1597 (void *)&cmd_config_speed_all_keyword,
1598 (void *)&cmd_config_speed_all_all,
1599 (void *)&cmd_config_speed_all_item1,
1600 (void *)&cmd_config_speed_all_value1,
1601 (void *)&cmd_config_speed_all_item2,
1602 (void *)&cmd_config_speed_all_value2,
1607 /* *** configure speed for specific port *** */
1608 struct cmd_config_speed_specific {
1609 cmdline_fixed_string_t port;
1610 cmdline_fixed_string_t keyword;
1612 cmdline_fixed_string_t item1;
1613 cmdline_fixed_string_t item2;
1614 cmdline_fixed_string_t value1;
1615 cmdline_fixed_string_t value2;
1619 cmd_config_speed_specific_parsed(void *parsed_result,
1620 __rte_unused struct cmdline *cl,
1621 __rte_unused void *data)
1623 struct cmd_config_speed_specific *res = parsed_result;
1624 uint32_t link_speed;
1626 if (!all_ports_stopped()) {
1627 printf("Please stop all ports first\n");
1631 if (port_id_is_invalid(res->id, ENABLED_WARN))
1634 if (parse_and_check_speed_duplex(res->value1, res->value2,
1638 ports[res->id].dev_conf.link_speeds = link_speed;
1640 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1644 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1647 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1648 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1650 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1651 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1652 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1655 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1657 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1658 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1661 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1665 cmdline_parse_inst_t cmd_config_speed_specific = {
1666 .f = cmd_config_speed_specific_parsed,
1668 .help_str = "port config <port_id> speed "
1669 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1672 (void *)&cmd_config_speed_specific_port,
1673 (void *)&cmd_config_speed_specific_keyword,
1674 (void *)&cmd_config_speed_specific_id,
1675 (void *)&cmd_config_speed_specific_item1,
1676 (void *)&cmd_config_speed_specific_value1,
1677 (void *)&cmd_config_speed_specific_item2,
1678 (void *)&cmd_config_speed_specific_value2,
1683 /* *** configure loopback for all ports *** */
1684 struct cmd_config_loopback_all {
1685 cmdline_fixed_string_t port;
1686 cmdline_fixed_string_t keyword;
1687 cmdline_fixed_string_t all;
1688 cmdline_fixed_string_t item;
1693 cmd_config_loopback_all_parsed(void *parsed_result,
1694 __rte_unused struct cmdline *cl,
1695 __rte_unused void *data)
1697 struct cmd_config_loopback_all *res = parsed_result;
1700 if (!all_ports_stopped()) {
1701 printf("Please stop all ports first\n");
1705 RTE_ETH_FOREACH_DEV(pid) {
1706 ports[pid].dev_conf.lpbk_mode = res->mode;
1709 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1712 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1713 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1714 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1717 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1719 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1722 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1723 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1725 cmdline_parse_inst_t cmd_config_loopback_all = {
1726 .f = cmd_config_loopback_all_parsed,
1728 .help_str = "port config all loopback <mode>",
1730 (void *)&cmd_config_loopback_all_port,
1731 (void *)&cmd_config_loopback_all_keyword,
1732 (void *)&cmd_config_loopback_all_all,
1733 (void *)&cmd_config_loopback_all_item,
1734 (void *)&cmd_config_loopback_all_mode,
1739 /* *** configure loopback for specific port *** */
1740 struct cmd_config_loopback_specific {
1741 cmdline_fixed_string_t port;
1742 cmdline_fixed_string_t keyword;
1744 cmdline_fixed_string_t item;
1749 cmd_config_loopback_specific_parsed(void *parsed_result,
1750 __rte_unused struct cmdline *cl,
1751 __rte_unused void *data)
1753 struct cmd_config_loopback_specific *res = parsed_result;
1755 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1758 if (!port_is_stopped(res->port_id)) {
1759 printf("Please stop port %u first\n", res->port_id);
1763 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1765 cmd_reconfig_device_queue(res->port_id, 1, 1);
1769 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1772 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1773 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1775 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1776 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1778 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1779 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1781 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1782 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1785 cmdline_parse_inst_t cmd_config_loopback_specific = {
1786 .f = cmd_config_loopback_specific_parsed,
1788 .help_str = "port config <port_id> loopback <mode>",
1790 (void *)&cmd_config_loopback_specific_port,
1791 (void *)&cmd_config_loopback_specific_keyword,
1792 (void *)&cmd_config_loopback_specific_id,
1793 (void *)&cmd_config_loopback_specific_item,
1794 (void *)&cmd_config_loopback_specific_mode,
1799 /* *** configure txq/rxq, txd/rxd *** */
1800 struct cmd_config_rx_tx {
1801 cmdline_fixed_string_t port;
1802 cmdline_fixed_string_t keyword;
1803 cmdline_fixed_string_t all;
1804 cmdline_fixed_string_t name;
1809 cmd_config_rx_tx_parsed(void *parsed_result,
1810 __rte_unused struct cmdline *cl,
1811 __rte_unused void *data)
1813 struct cmd_config_rx_tx *res = parsed_result;
1815 if (!all_ports_stopped()) {
1816 printf("Please stop all ports first\n");
1819 if (!strcmp(res->name, "rxq")) {
1820 if (!res->value && !nb_txq) {
1821 printf("Warning: Either rx or tx queues should be non zero\n");
1824 if (check_nb_rxq(res->value) != 0)
1826 nb_rxq = res->value;
1828 else if (!strcmp(res->name, "txq")) {
1829 if (!res->value && !nb_rxq) {
1830 printf("Warning: Either rx or tx queues should be non zero\n");
1833 if (check_nb_txq(res->value) != 0)
1835 nb_txq = res->value;
1837 else if (!strcmp(res->name, "rxd")) {
1838 if (check_nb_rxd(res->value) != 0)
1840 nb_rxd = res->value;
1841 } else if (!strcmp(res->name, "txd")) {
1842 if (check_nb_txd(res->value) != 0)
1845 nb_txd = res->value;
1847 printf("Unknown parameter\n");
1855 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1858 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1859 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1860 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1862 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1863 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1864 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1865 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1867 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1868 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1870 cmdline_parse_inst_t cmd_config_rx_tx = {
1871 .f = cmd_config_rx_tx_parsed,
1873 .help_str = "port config all rxq|txq|rxd|txd <value>",
1875 (void *)&cmd_config_rx_tx_port,
1876 (void *)&cmd_config_rx_tx_keyword,
1877 (void *)&cmd_config_rx_tx_all,
1878 (void *)&cmd_config_rx_tx_name,
1879 (void *)&cmd_config_rx_tx_value,
1884 /* *** config max packet length *** */
1885 struct cmd_config_max_pkt_len_result {
1886 cmdline_fixed_string_t port;
1887 cmdline_fixed_string_t keyword;
1888 cmdline_fixed_string_t all;
1889 cmdline_fixed_string_t name;
1894 cmd_config_max_pkt_len_parsed(void *parsed_result,
1895 __rte_unused struct cmdline *cl,
1896 __rte_unused void *data)
1898 struct cmd_config_max_pkt_len_result *res = parsed_result;
1899 uint32_t max_rx_pkt_len_backup = 0;
1903 if (!all_ports_stopped()) {
1904 printf("Please stop all ports first\n");
1908 RTE_ETH_FOREACH_DEV(pid) {
1909 struct rte_port *port = &ports[pid];
1911 if (!strcmp(res->name, "max-pkt-len")) {
1912 if (res->value < RTE_ETHER_MIN_LEN) {
1913 printf("max-pkt-len can not be less than %d\n",
1917 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1920 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1922 printf("rte_eth_dev_info_get() failed for port %u\n",
1927 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1929 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1930 if (update_jumbo_frame_offload(pid) != 0)
1931 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1933 printf("Unknown parameter\n");
1940 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1943 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1944 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1946 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1947 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1949 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1950 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1952 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1955 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1956 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1959 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1960 .f = cmd_config_max_pkt_len_parsed,
1962 .help_str = "port config all max-pkt-len <value>",
1964 (void *)&cmd_config_max_pkt_len_port,
1965 (void *)&cmd_config_max_pkt_len_keyword,
1966 (void *)&cmd_config_max_pkt_len_all,
1967 (void *)&cmd_config_max_pkt_len_name,
1968 (void *)&cmd_config_max_pkt_len_value,
1973 /* *** config max LRO aggregated packet size *** */
1974 struct cmd_config_max_lro_pkt_size_result {
1975 cmdline_fixed_string_t port;
1976 cmdline_fixed_string_t keyword;
1977 cmdline_fixed_string_t all;
1978 cmdline_fixed_string_t name;
1983 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1984 __rte_unused struct cmdline *cl,
1985 __rte_unused void *data)
1987 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1990 if (!all_ports_stopped()) {
1991 printf("Please stop all ports first\n");
1995 RTE_ETH_FOREACH_DEV(pid) {
1996 struct rte_port *port = &ports[pid];
1998 if (!strcmp(res->name, "max-lro-pkt-size")) {
2000 port->dev_conf.rxmode.max_lro_pkt_size)
2003 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2005 printf("Unknown parameter\n");
2012 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2015 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2016 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2018 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2019 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2021 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2022 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2024 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2025 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2026 name, "max-lro-pkt-size");
2027 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2028 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2031 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2032 .f = cmd_config_max_lro_pkt_size_parsed,
2034 .help_str = "port config all max-lro-pkt-size <value>",
2036 (void *)&cmd_config_max_lro_pkt_size_port,
2037 (void *)&cmd_config_max_lro_pkt_size_keyword,
2038 (void *)&cmd_config_max_lro_pkt_size_all,
2039 (void *)&cmd_config_max_lro_pkt_size_name,
2040 (void *)&cmd_config_max_lro_pkt_size_value,
2045 /* *** configure port MTU *** */
2046 struct cmd_config_mtu_result {
2047 cmdline_fixed_string_t port;
2048 cmdline_fixed_string_t keyword;
2049 cmdline_fixed_string_t mtu;
2055 cmd_config_mtu_parsed(void *parsed_result,
2056 __rte_unused struct cmdline *cl,
2057 __rte_unused void *data)
2059 struct cmd_config_mtu_result *res = parsed_result;
2061 if (res->value < RTE_ETHER_MIN_LEN) {
2062 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2065 port_mtu_set(res->port_id, res->value);
2068 cmdline_parse_token_string_t cmd_config_mtu_port =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2071 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2074 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2075 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2077 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2078 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2080 cmdline_parse_token_num_t cmd_config_mtu_value =
2081 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2084 cmdline_parse_inst_t cmd_config_mtu = {
2085 .f = cmd_config_mtu_parsed,
2087 .help_str = "port config mtu <port_id> <value>",
2089 (void *)&cmd_config_mtu_port,
2090 (void *)&cmd_config_mtu_keyword,
2091 (void *)&cmd_config_mtu_mtu,
2092 (void *)&cmd_config_mtu_port_id,
2093 (void *)&cmd_config_mtu_value,
2098 /* *** configure rx mode *** */
2099 struct cmd_config_rx_mode_flag {
2100 cmdline_fixed_string_t port;
2101 cmdline_fixed_string_t keyword;
2102 cmdline_fixed_string_t all;
2103 cmdline_fixed_string_t name;
2104 cmdline_fixed_string_t value;
2108 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2109 __rte_unused struct cmdline *cl,
2110 __rte_unused void *data)
2112 struct cmd_config_rx_mode_flag *res = parsed_result;
2114 if (!all_ports_stopped()) {
2115 printf("Please stop all ports first\n");
2119 if (!strcmp(res->name, "drop-en")) {
2120 if (!strcmp(res->value, "on"))
2122 else if (!strcmp(res->value, "off"))
2125 printf("Unknown parameter\n");
2129 printf("Unknown parameter\n");
2135 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2138 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2139 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2140 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2141 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2143 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2144 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2145 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2146 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2148 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2152 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2153 .f = cmd_config_rx_mode_flag_parsed,
2155 .help_str = "port config all drop-en on|off",
2157 (void *)&cmd_config_rx_mode_flag_port,
2158 (void *)&cmd_config_rx_mode_flag_keyword,
2159 (void *)&cmd_config_rx_mode_flag_all,
2160 (void *)&cmd_config_rx_mode_flag_name,
2161 (void *)&cmd_config_rx_mode_flag_value,
2166 /* *** configure rss *** */
2167 struct cmd_config_rss {
2168 cmdline_fixed_string_t port;
2169 cmdline_fixed_string_t keyword;
2170 cmdline_fixed_string_t all;
2171 cmdline_fixed_string_t name;
2172 cmdline_fixed_string_t value;
2176 cmd_config_rss_parsed(void *parsed_result,
2177 __rte_unused struct cmdline *cl,
2178 __rte_unused void *data)
2180 struct cmd_config_rss *res = parsed_result;
2181 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2182 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2183 int use_default = 0;
2184 int all_updated = 1;
2189 if (!strcmp(res->value, "all"))
2190 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2191 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2192 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2193 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2195 else if (!strcmp(res->value, "eth"))
2196 rss_conf.rss_hf = ETH_RSS_ETH;
2197 else if (!strcmp(res->value, "vlan"))
2198 rss_conf.rss_hf = ETH_RSS_VLAN;
2199 else if (!strcmp(res->value, "ip"))
2200 rss_conf.rss_hf = ETH_RSS_IP;
2201 else if (!strcmp(res->value, "udp"))
2202 rss_conf.rss_hf = ETH_RSS_UDP;
2203 else if (!strcmp(res->value, "tcp"))
2204 rss_conf.rss_hf = ETH_RSS_TCP;
2205 else if (!strcmp(res->value, "sctp"))
2206 rss_conf.rss_hf = ETH_RSS_SCTP;
2207 else if (!strcmp(res->value, "ether"))
2208 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2209 else if (!strcmp(res->value, "port"))
2210 rss_conf.rss_hf = ETH_RSS_PORT;
2211 else if (!strcmp(res->value, "vxlan"))
2212 rss_conf.rss_hf = ETH_RSS_VXLAN;
2213 else if (!strcmp(res->value, "geneve"))
2214 rss_conf.rss_hf = ETH_RSS_GENEVE;
2215 else if (!strcmp(res->value, "nvgre"))
2216 rss_conf.rss_hf = ETH_RSS_NVGRE;
2217 else if (!strcmp(res->value, "l3-pre32"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2219 else if (!strcmp(res->value, "l3-pre40"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2221 else if (!strcmp(res->value, "l3-pre48"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2223 else if (!strcmp(res->value, "l3-pre56"))
2224 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2225 else if (!strcmp(res->value, "l3-pre64"))
2226 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2227 else if (!strcmp(res->value, "l3-pre96"))
2228 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2229 else if (!strcmp(res->value, "l3-src-only"))
2230 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2231 else if (!strcmp(res->value, "l3-dst-only"))
2232 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2233 else if (!strcmp(res->value, "l4-src-only"))
2234 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2235 else if (!strcmp(res->value, "l4-dst-only"))
2236 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2237 else if (!strcmp(res->value, "l2-src-only"))
2238 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2239 else if (!strcmp(res->value, "l2-dst-only"))
2240 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2241 else if (!strcmp(res->value, "l2tpv3"))
2242 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2243 else if (!strcmp(res->value, "esp"))
2244 rss_conf.rss_hf = ETH_RSS_ESP;
2245 else if (!strcmp(res->value, "ah"))
2246 rss_conf.rss_hf = ETH_RSS_AH;
2247 else if (!strcmp(res->value, "pfcp"))
2248 rss_conf.rss_hf = ETH_RSS_PFCP;
2249 else if (!strcmp(res->value, "pppoe"))
2250 rss_conf.rss_hf = ETH_RSS_PPPOE;
2251 else if (!strcmp(res->value, "gtpu"))
2252 rss_conf.rss_hf = ETH_RSS_GTPU;
2253 else if (!strcmp(res->value, "ecpri"))
2254 rss_conf.rss_hf = ETH_RSS_ECPRI;
2255 else if (!strcmp(res->value, "mpls"))
2256 rss_conf.rss_hf = ETH_RSS_MPLS;
2257 else if (!strcmp(res->value, "none"))
2258 rss_conf.rss_hf = 0;
2259 else if (!strcmp(res->value, "level-default")) {
2260 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2261 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2262 } else if (!strcmp(res->value, "level-outer")) {
2263 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2264 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2265 } else if (!strcmp(res->value, "level-inner")) {
2266 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2267 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2268 } else if (!strcmp(res->value, "default"))
2270 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2271 atoi(res->value) < 64)
2272 rss_conf.rss_hf = 1ULL << atoi(res->value);
2274 printf("Unknown parameter\n");
2277 rss_conf.rss_key = NULL;
2278 /* Update global configuration for RSS types. */
2279 RTE_ETH_FOREACH_DEV(i) {
2280 struct rte_eth_rss_conf local_rss_conf;
2282 ret = eth_dev_info_get_print_err(i, &dev_info);
2287 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2289 local_rss_conf = rss_conf;
2290 local_rss_conf.rss_hf = rss_conf.rss_hf &
2291 dev_info.flow_type_rss_offloads;
2292 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2293 printf("Port %u modified RSS hash function based on hardware support,"
2294 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2295 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2297 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2300 printf("Configuration of RSS hash at ethernet port %d "
2301 "failed with error (%d): %s.\n",
2302 i, -diag, strerror(-diag));
2305 if (all_updated && !use_default) {
2306 rss_hf = rss_conf.rss_hf;
2307 printf("rss_hf %#"PRIx64"\n", rss_hf);
2311 cmdline_parse_token_string_t cmd_config_rss_port =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2313 cmdline_parse_token_string_t cmd_config_rss_keyword =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2315 cmdline_parse_token_string_t cmd_config_rss_all =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2317 cmdline_parse_token_string_t cmd_config_rss_name =
2318 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2319 cmdline_parse_token_string_t cmd_config_rss_value =
2320 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2322 cmdline_parse_inst_t cmd_config_rss = {
2323 .f = cmd_config_rss_parsed,
2325 .help_str = "port config all rss "
2326 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2327 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2328 "level-outer|level-inner|<flowtype_id>",
2330 (void *)&cmd_config_rss_port,
2331 (void *)&cmd_config_rss_keyword,
2332 (void *)&cmd_config_rss_all,
2333 (void *)&cmd_config_rss_name,
2334 (void *)&cmd_config_rss_value,
2339 /* *** configure rss hash key *** */
2340 struct cmd_config_rss_hash_key {
2341 cmdline_fixed_string_t port;
2342 cmdline_fixed_string_t config;
2344 cmdline_fixed_string_t rss_hash_key;
2345 cmdline_fixed_string_t rss_type;
2346 cmdline_fixed_string_t key;
2350 hexa_digit_to_value(char hexa_digit)
2352 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2353 return (uint8_t) (hexa_digit - '0');
2354 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2355 return (uint8_t) ((hexa_digit - 'a') + 10);
2356 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2357 return (uint8_t) ((hexa_digit - 'A') + 10);
2358 /* Invalid hexa digit */
2363 parse_and_check_key_hexa_digit(char *key, int idx)
2367 hexa_v = hexa_digit_to_value(key[idx]);
2369 printf("invalid key: character %c at position %d is not a "
2370 "valid hexa digit\n", key[idx], idx);
2375 cmd_config_rss_hash_key_parsed(void *parsed_result,
2376 __rte_unused struct cmdline *cl,
2377 __rte_unused void *data)
2379 struct cmd_config_rss_hash_key *res = parsed_result;
2380 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2384 struct rte_eth_dev_info dev_info;
2385 uint8_t hash_key_size;
2389 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2393 if (dev_info.hash_key_size > 0 &&
2394 dev_info.hash_key_size <= sizeof(hash_key))
2395 hash_key_size = dev_info.hash_key_size;
2397 printf("dev_info did not provide a valid hash key size\n");
2400 /* Check the length of the RSS hash key */
2401 key_len = strlen(res->key);
2402 if (key_len != (hash_key_size * 2)) {
2403 printf("key length: %d invalid - key must be a string of %d"
2404 " hexa-decimal numbers\n",
2405 (int) key_len, hash_key_size * 2);
2408 /* Translate RSS hash key into binary representation */
2409 for (i = 0; i < hash_key_size; i++) {
2410 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2413 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2416 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2418 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2422 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2423 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2425 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2427 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2428 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2430 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2431 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2432 rss_hash_key, "rss-hash-key");
2433 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2434 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2435 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2436 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2437 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2438 "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 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2443 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2445 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2446 .f = cmd_config_rss_hash_key_parsed,
2448 .help_str = "port config <port_id> rss-hash-key "
2449 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2450 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2451 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2452 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2453 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2454 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2455 "<string of hex digits (variable length, NIC dependent)>",
2457 (void *)&cmd_config_rss_hash_key_port,
2458 (void *)&cmd_config_rss_hash_key_config,
2459 (void *)&cmd_config_rss_hash_key_port_id,
2460 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2461 (void *)&cmd_config_rss_hash_key_rss_type,
2462 (void *)&cmd_config_rss_hash_key_value,
2467 /* *** cleanup txq mbufs *** */
2468 struct cmd_cleanup_txq_mbufs_result {
2469 cmdline_fixed_string_t port;
2470 cmdline_fixed_string_t keyword;
2471 cmdline_fixed_string_t name;
2478 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2479 __rte_unused struct cmdline *cl,
2480 __rte_unused void *data)
2482 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2483 uint16_t port_id = res->port_id;
2484 uint16_t queue_id = res->queue_id;
2485 uint32_t free_cnt = res->free_cnt;
2486 struct rte_eth_txq_info qinfo;
2489 if (test_done == 0) {
2490 printf("Please stop forwarding first\n");
2494 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2495 printf("Failed to get port %u Tx queue %u info\n",
2500 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2501 printf("Tx queue %u not started\n", queue_id);
2505 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2507 printf("Failed to cleanup mbuf for port %u Tx queue %u "
2508 "error desc: %s(%d)\n",
2509 port_id, queue_id, strerror(-ret), ret);
2513 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2514 port_id, queue_id, ret);
2517 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2518 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2520 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2521 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2523 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2524 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2526 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2527 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2529 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2530 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2532 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2533 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2536 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2537 .f = cmd_cleanup_txq_mbufs_parsed,
2539 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2541 (void *)&cmd_cleanup_txq_mbufs_port,
2542 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2543 (void *)&cmd_cleanup_txq_mbufs_port_id,
2544 (void *)&cmd_cleanup_txq_mbufs_txq,
2545 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2546 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2551 /* *** configure port rxq/txq ring size *** */
2552 struct cmd_config_rxtx_ring_size {
2553 cmdline_fixed_string_t port;
2554 cmdline_fixed_string_t config;
2556 cmdline_fixed_string_t rxtxq;
2558 cmdline_fixed_string_t rsize;
2563 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2564 __rte_unused struct cmdline *cl,
2565 __rte_unused void *data)
2567 struct cmd_config_rxtx_ring_size *res = parsed_result;
2568 struct rte_port *port;
2571 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2574 if (res->portid == (portid_t)RTE_PORT_ALL) {
2575 printf("Invalid port id\n");
2579 port = &ports[res->portid];
2581 if (!strcmp(res->rxtxq, "rxq"))
2583 else if (!strcmp(res->rxtxq, "txq"))
2586 printf("Unknown parameter\n");
2590 if (isrx && rx_queue_id_is_invalid(res->qid))
2592 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2595 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2596 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2602 port->nb_rx_desc[res->qid] = res->size;
2604 port->nb_tx_desc[res->qid] = res->size;
2606 cmd_reconfig_device_queue(res->portid, 0, 1);
2609 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2610 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2612 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2613 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2615 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2616 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2617 portid, RTE_UINT16);
2618 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2619 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2621 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2622 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2624 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2625 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2626 rsize, "ring_size");
2627 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2628 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2631 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2632 .f = cmd_config_rxtx_ring_size_parsed,
2634 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2636 (void *)&cmd_config_rxtx_ring_size_port,
2637 (void *)&cmd_config_rxtx_ring_size_config,
2638 (void *)&cmd_config_rxtx_ring_size_portid,
2639 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2640 (void *)&cmd_config_rxtx_ring_size_qid,
2641 (void *)&cmd_config_rxtx_ring_size_rsize,
2642 (void *)&cmd_config_rxtx_ring_size_size,
2647 /* *** configure port rxq/txq start/stop *** */
2648 struct cmd_config_rxtx_queue {
2649 cmdline_fixed_string_t port;
2651 cmdline_fixed_string_t rxtxq;
2653 cmdline_fixed_string_t opname;
2657 cmd_config_rxtx_queue_parsed(void *parsed_result,
2658 __rte_unused struct cmdline *cl,
2659 __rte_unused void *data)
2661 struct cmd_config_rxtx_queue *res = parsed_result;
2666 if (test_done == 0) {
2667 printf("Please stop forwarding first\n");
2671 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2674 if (port_is_started(res->portid) != 1) {
2675 printf("Please start port %u first\n", res->portid);
2679 if (!strcmp(res->rxtxq, "rxq"))
2681 else if (!strcmp(res->rxtxq, "txq"))
2684 printf("Unknown parameter\n");
2688 if (isrx && rx_queue_id_is_invalid(res->qid))
2690 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2693 if (!strcmp(res->opname, "start"))
2695 else if (!strcmp(res->opname, "stop"))
2698 printf("Unknown parameter\n");
2702 if (isstart && isrx)
2703 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2704 else if (!isstart && isrx)
2705 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2706 else if (isstart && !isrx)
2707 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2709 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2711 if (ret == -ENOTSUP)
2712 printf("Function not supported in PMD driver\n");
2715 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2716 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2717 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2718 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2719 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2720 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2721 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2722 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2723 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2724 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2727 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2728 .f = cmd_config_rxtx_queue_parsed,
2730 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2732 (void *)&cmd_config_rxtx_queue_port,
2733 (void *)&cmd_config_rxtx_queue_portid,
2734 (void *)&cmd_config_rxtx_queue_rxtxq,
2735 (void *)&cmd_config_rxtx_queue_qid,
2736 (void *)&cmd_config_rxtx_queue_opname,
2741 /* *** configure port rxq/txq deferred start on/off *** */
2742 struct cmd_config_deferred_start_rxtx_queue {
2743 cmdline_fixed_string_t port;
2745 cmdline_fixed_string_t rxtxq;
2747 cmdline_fixed_string_t opname;
2748 cmdline_fixed_string_t state;
2752 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2753 __rte_unused struct cmdline *cl,
2754 __rte_unused void *data)
2756 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2757 struct rte_port *port;
2760 uint8_t needreconfig = 0;
2762 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2765 if (port_is_started(res->port_id) != 0) {
2766 printf("Please stop port %u first\n", res->port_id);
2770 port = &ports[res->port_id];
2772 isrx = !strcmp(res->rxtxq, "rxq");
2774 if (isrx && rx_queue_id_is_invalid(res->qid))
2776 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2779 ison = !strcmp(res->state, "on");
2781 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2782 port->rx_conf[res->qid].rx_deferred_start = ison;
2784 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2785 port->tx_conf[res->qid].tx_deferred_start = ison;
2790 cmd_reconfig_device_queue(res->port_id, 0, 1);
2793 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2794 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2796 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2797 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2798 port_id, RTE_UINT16);
2799 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2800 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2802 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2803 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2805 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2806 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2807 opname, "deferred_start");
2808 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2809 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2812 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2813 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2815 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2817 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2818 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2819 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2820 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2821 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2822 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2827 /* *** configure port rxq/txq setup *** */
2828 struct cmd_setup_rxtx_queue {
2829 cmdline_fixed_string_t port;
2831 cmdline_fixed_string_t rxtxq;
2833 cmdline_fixed_string_t setup;
2836 /* Common CLI fields for queue setup */
2837 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2838 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2839 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2840 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2841 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2842 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2843 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2844 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2845 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2846 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2849 cmd_setup_rxtx_queue_parsed(
2850 void *parsed_result,
2851 __rte_unused struct cmdline *cl,
2852 __rte_unused void *data)
2854 struct cmd_setup_rxtx_queue *res = parsed_result;
2855 struct rte_port *port;
2856 struct rte_mempool *mp;
2857 unsigned int socket_id;
2861 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2864 if (res->portid == (portid_t)RTE_PORT_ALL) {
2865 printf("Invalid port id\n");
2869 if (!strcmp(res->rxtxq, "rxq"))
2871 else if (!strcmp(res->rxtxq, "txq"))
2874 printf("Unknown parameter\n");
2878 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2879 printf("Invalid rx queue\n");
2881 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2882 printf("Invalid tx queue\n");
2886 port = &ports[res->portid];
2888 socket_id = rxring_numa[res->portid];
2889 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2890 socket_id = port->socket_id;
2892 mp = mbuf_pool_find(socket_id, 0);
2894 printf("Failed to setup RX queue: "
2895 "No mempool allocation"
2896 " on the socket %d\n",
2897 rxring_numa[res->portid]);
2900 ret = rx_queue_setup(res->portid,
2902 port->nb_rx_desc[res->qid],
2904 &port->rx_conf[res->qid],
2907 printf("Failed to setup RX queue\n");
2909 socket_id = txring_numa[res->portid];
2910 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2911 socket_id = port->socket_id;
2913 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2914 printf("Failed to setup TX queue: not enough descriptors\n");
2917 ret = rte_eth_tx_queue_setup(res->portid,
2919 port->nb_tx_desc[res->qid],
2921 &port->tx_conf[res->qid]);
2923 printf("Failed to setup TX queue\n");
2927 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2928 .f = cmd_setup_rxtx_queue_parsed,
2930 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2932 (void *)&cmd_setup_rxtx_queue_port,
2933 (void *)&cmd_setup_rxtx_queue_portid,
2934 (void *)&cmd_setup_rxtx_queue_rxtxq,
2935 (void *)&cmd_setup_rxtx_queue_qid,
2936 (void *)&cmd_setup_rxtx_queue_setup,
2942 /* *** Configure RSS RETA *** */
2943 struct cmd_config_rss_reta {
2944 cmdline_fixed_string_t port;
2945 cmdline_fixed_string_t keyword;
2947 cmdline_fixed_string_t name;
2948 cmdline_fixed_string_t list_name;
2949 cmdline_fixed_string_t list_of_items;
2953 parse_reta_config(const char *str,
2954 struct rte_eth_rss_reta_entry64 *reta_conf,
2955 uint16_t nb_entries)
2959 uint16_t hash_index, idx, shift;
2962 const char *p, *p0 = str;
2969 unsigned long int_fld[_NUM_FLD];
2970 char *str_fld[_NUM_FLD];
2972 while ((p = strchr(p0,'(')) != NULL) {
2974 if((p0 = strchr(p,')')) == NULL)
2978 if(size >= sizeof(s))
2981 snprintf(s, sizeof(s), "%.*s", size, p);
2982 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2984 for (i = 0; i < _NUM_FLD; i++) {
2986 int_fld[i] = strtoul(str_fld[i], &end, 0);
2987 if (errno != 0 || end == str_fld[i] ||
2992 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2993 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2995 if (hash_index >= nb_entries) {
2996 printf("Invalid RETA hash index=%d\n", hash_index);
3000 idx = hash_index / RTE_RETA_GROUP_SIZE;
3001 shift = hash_index % RTE_RETA_GROUP_SIZE;
3002 reta_conf[idx].mask |= (1ULL << shift);
3003 reta_conf[idx].reta[shift] = nb_queue;
3010 cmd_set_rss_reta_parsed(void *parsed_result,
3011 __rte_unused struct cmdline *cl,
3012 __rte_unused void *data)
3015 struct rte_eth_dev_info dev_info;
3016 struct rte_eth_rss_reta_entry64 reta_conf[8];
3017 struct cmd_config_rss_reta *res = parsed_result;
3019 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3023 if (dev_info.reta_size == 0) {
3024 printf("Redirection table size is 0 which is "
3025 "invalid for RSS\n");
3028 printf("The reta size of port %d is %u\n",
3029 res->port_id, dev_info.reta_size);
3030 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3031 printf("Currently do not support more than %u entries of "
3032 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3036 memset(reta_conf, 0, sizeof(reta_conf));
3037 if (!strcmp(res->list_name, "reta")) {
3038 if (parse_reta_config(res->list_of_items, reta_conf,
3039 dev_info.reta_size)) {
3040 printf("Invalid RSS Redirection Table "
3041 "config entered\n");
3044 ret = rte_eth_dev_rss_reta_update(res->port_id,
3045 reta_conf, dev_info.reta_size);
3047 printf("Bad redirection table parameter, "
3048 "return code = %d \n", ret);
3052 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3054 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3056 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3057 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3058 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3060 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3062 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3065 cmdline_parse_inst_t cmd_config_rss_reta = {
3066 .f = cmd_set_rss_reta_parsed,
3068 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3070 (void *)&cmd_config_rss_reta_port,
3071 (void *)&cmd_config_rss_reta_keyword,
3072 (void *)&cmd_config_rss_reta_port_id,
3073 (void *)&cmd_config_rss_reta_name,
3074 (void *)&cmd_config_rss_reta_list_name,
3075 (void *)&cmd_config_rss_reta_list_of_items,
3080 /* *** SHOW PORT RETA INFO *** */
3081 struct cmd_showport_reta {
3082 cmdline_fixed_string_t show;
3083 cmdline_fixed_string_t port;
3085 cmdline_fixed_string_t rss;
3086 cmdline_fixed_string_t reta;
3088 cmdline_fixed_string_t list_of_items;
3092 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3093 uint16_t nb_entries,
3097 const char *p, *p0 = str;
3102 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3103 RTE_RETA_GROUP_SIZE;
3106 p = strchr(p0, '(');
3110 p0 = strchr(p, ')');
3114 if (size >= sizeof(s)) {
3115 printf("The string size exceeds the internal buffer size\n");
3118 snprintf(s, sizeof(s), "%.*s", size, p);
3119 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3120 if (ret <= 0 || ret != num) {
3121 printf("The bits of masks do not match the number of "
3122 "reta entries: %u\n", num);
3125 for (i = 0; i < ret; i++)
3126 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3132 cmd_showport_reta_parsed(void *parsed_result,
3133 __rte_unused struct cmdline *cl,
3134 __rte_unused void *data)
3136 struct cmd_showport_reta *res = parsed_result;
3137 struct rte_eth_rss_reta_entry64 reta_conf[8];
3138 struct rte_eth_dev_info dev_info;
3139 uint16_t max_reta_size;
3142 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3146 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3147 if (res->size == 0 || res->size > max_reta_size) {
3148 printf("Invalid redirection table size: %u (1-%u)\n",
3149 res->size, max_reta_size);
3153 memset(reta_conf, 0, sizeof(reta_conf));
3154 if (showport_parse_reta_config(reta_conf, res->size,
3155 res->list_of_items) < 0) {
3156 printf("Invalid string: %s for reta masks\n",
3157 res->list_of_items);
3160 port_rss_reta_info(res->port_id, reta_conf, res->size);
3163 cmdline_parse_token_string_t cmd_showport_reta_show =
3164 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3165 cmdline_parse_token_string_t cmd_showport_reta_port =
3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3167 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3168 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3169 cmdline_parse_token_string_t cmd_showport_reta_rss =
3170 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3171 cmdline_parse_token_string_t cmd_showport_reta_reta =
3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3173 cmdline_parse_token_num_t cmd_showport_reta_size =
3174 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3175 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3176 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3177 list_of_items, NULL);
3179 cmdline_parse_inst_t cmd_showport_reta = {
3180 .f = cmd_showport_reta_parsed,
3182 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3184 (void *)&cmd_showport_reta_show,
3185 (void *)&cmd_showport_reta_port,
3186 (void *)&cmd_showport_reta_port_id,
3187 (void *)&cmd_showport_reta_rss,
3188 (void *)&cmd_showport_reta_reta,
3189 (void *)&cmd_showport_reta_size,
3190 (void *)&cmd_showport_reta_list_of_items,
3195 /* *** Show RSS hash configuration *** */
3196 struct cmd_showport_rss_hash {
3197 cmdline_fixed_string_t show;
3198 cmdline_fixed_string_t port;
3200 cmdline_fixed_string_t rss_hash;
3201 cmdline_fixed_string_t rss_type;
3202 cmdline_fixed_string_t key; /* optional argument */
3205 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3206 __rte_unused struct cmdline *cl,
3209 struct cmd_showport_rss_hash *res = parsed_result;
3211 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3214 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3215 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3216 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3217 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3218 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3219 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3221 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3222 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3224 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3225 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3227 cmdline_parse_inst_t cmd_showport_rss_hash = {
3228 .f = cmd_showport_rss_hash_parsed,
3230 .help_str = "show port <port_id> rss-hash",
3232 (void *)&cmd_showport_rss_hash_show,
3233 (void *)&cmd_showport_rss_hash_port,
3234 (void *)&cmd_showport_rss_hash_port_id,
3235 (void *)&cmd_showport_rss_hash_rss_hash,
3240 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3241 .f = cmd_showport_rss_hash_parsed,
3243 .help_str = "show port <port_id> rss-hash key",
3245 (void *)&cmd_showport_rss_hash_show,
3246 (void *)&cmd_showport_rss_hash_port,
3247 (void *)&cmd_showport_rss_hash_port_id,
3248 (void *)&cmd_showport_rss_hash_rss_hash,
3249 (void *)&cmd_showport_rss_hash_rss_key,
3254 /* *** Configure DCB *** */
3255 struct cmd_config_dcb {
3256 cmdline_fixed_string_t port;
3257 cmdline_fixed_string_t config;
3259 cmdline_fixed_string_t dcb;
3260 cmdline_fixed_string_t vt;
3261 cmdline_fixed_string_t vt_en;
3263 cmdline_fixed_string_t pfc;
3264 cmdline_fixed_string_t pfc_en;
3268 cmd_config_dcb_parsed(void *parsed_result,
3269 __rte_unused struct cmdline *cl,
3270 __rte_unused void *data)
3272 struct cmd_config_dcb *res = parsed_result;
3273 struct rte_eth_dcb_info dcb_info;
3274 portid_t port_id = res->port_id;
3275 struct rte_port *port;
3279 port = &ports[port_id];
3280 /** Check if the port is not started **/
3281 if (port->port_status != RTE_PORT_STOPPED) {
3282 printf("Please stop port %d first\n", port_id);
3286 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3287 printf("The invalid number of traffic class,"
3288 " only 4 or 8 allowed.\n");
3292 if (nb_fwd_lcores < res->num_tcs) {
3293 printf("nb_cores shouldn't be less than number of TCs.\n");
3297 /* Check whether the port supports the report of DCB info. */
3298 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3299 if (ret == -ENOTSUP) {
3300 printf("rte_eth_dev_get_dcb_info not supported.\n");
3304 if (!strncmp(res->pfc_en, "on", 2))
3309 /* DCB in VT mode */
3310 if (!strncmp(res->vt_en, "on", 2))
3311 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3312 (enum rte_eth_nb_tcs)res->num_tcs,
3315 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3316 (enum rte_eth_nb_tcs)res->num_tcs,
3319 printf("Cannot initialize network ports.\n");
3325 cmd_reconfig_device_queue(port_id, 1, 1);
3328 cmdline_parse_token_string_t cmd_config_dcb_port =
3329 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3330 cmdline_parse_token_string_t cmd_config_dcb_config =
3331 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3332 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3333 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3334 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3336 cmdline_parse_token_string_t cmd_config_dcb_vt =
3337 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3338 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3339 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3340 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3341 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3342 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3343 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3344 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3345 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3347 cmdline_parse_inst_t cmd_config_dcb = {
3348 .f = cmd_config_dcb_parsed,
3350 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3352 (void *)&cmd_config_dcb_port,
3353 (void *)&cmd_config_dcb_config,
3354 (void *)&cmd_config_dcb_port_id,
3355 (void *)&cmd_config_dcb_dcb,
3356 (void *)&cmd_config_dcb_vt,
3357 (void *)&cmd_config_dcb_vt_en,
3358 (void *)&cmd_config_dcb_num_tcs,
3359 (void *)&cmd_config_dcb_pfc,
3360 (void *)&cmd_config_dcb_pfc_en,
3365 /* *** configure number of packets per burst *** */
3366 struct cmd_config_burst {
3367 cmdline_fixed_string_t port;
3368 cmdline_fixed_string_t keyword;
3369 cmdline_fixed_string_t all;
3370 cmdline_fixed_string_t name;
3375 cmd_config_burst_parsed(void *parsed_result,
3376 __rte_unused struct cmdline *cl,
3377 __rte_unused void *data)
3379 struct cmd_config_burst *res = parsed_result;
3380 struct rte_eth_dev_info dev_info;
3381 uint16_t rec_nb_pkts;
3384 if (!all_ports_stopped()) {
3385 printf("Please stop all ports first\n");
3389 if (!strcmp(res->name, "burst")) {
3390 if (res->value == 0) {
3391 /* If user gives a value of zero, query the PMD for
3392 * its recommended Rx burst size. Testpmd uses a single
3393 * size for all ports, so assume all ports are the same
3394 * NIC model and use the values from Port 0.
3396 ret = eth_dev_info_get_print_err(0, &dev_info);
3400 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3402 if (rec_nb_pkts == 0) {
3403 printf("PMD does not recommend a burst size.\n"
3404 "User provided value must be between"
3405 " 1 and %d\n", MAX_PKT_BURST);
3407 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3408 printf("PMD recommended burst size of %d"
3409 " exceeds maximum value of %d\n",
3410 rec_nb_pkts, MAX_PKT_BURST);
3413 printf("Using PMD-provided burst value of %d\n",
3415 nb_pkt_per_burst = rec_nb_pkts;
3416 } else if (res->value > MAX_PKT_BURST) {
3417 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3420 nb_pkt_per_burst = res->value;
3422 printf("Unknown parameter\n");
3428 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3431 cmdline_parse_token_string_t cmd_config_burst_port =
3432 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3433 cmdline_parse_token_string_t cmd_config_burst_keyword =
3434 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3435 cmdline_parse_token_string_t cmd_config_burst_all =
3436 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3437 cmdline_parse_token_string_t cmd_config_burst_name =
3438 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3439 cmdline_parse_token_num_t cmd_config_burst_value =
3440 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3442 cmdline_parse_inst_t cmd_config_burst = {
3443 .f = cmd_config_burst_parsed,
3445 .help_str = "port config all burst <value>",
3447 (void *)&cmd_config_burst_port,
3448 (void *)&cmd_config_burst_keyword,
3449 (void *)&cmd_config_burst_all,
3450 (void *)&cmd_config_burst_name,
3451 (void *)&cmd_config_burst_value,
3456 /* *** configure rx/tx queues *** */
3457 struct cmd_config_thresh {
3458 cmdline_fixed_string_t port;
3459 cmdline_fixed_string_t keyword;
3460 cmdline_fixed_string_t all;
3461 cmdline_fixed_string_t name;
3466 cmd_config_thresh_parsed(void *parsed_result,
3467 __rte_unused struct cmdline *cl,
3468 __rte_unused void *data)
3470 struct cmd_config_thresh *res = parsed_result;
3472 if (!all_ports_stopped()) {
3473 printf("Please stop all ports first\n");
3477 if (!strcmp(res->name, "txpt"))
3478 tx_pthresh = res->value;
3479 else if(!strcmp(res->name, "txht"))
3480 tx_hthresh = res->value;
3481 else if(!strcmp(res->name, "txwt"))
3482 tx_wthresh = res->value;
3483 else if(!strcmp(res->name, "rxpt"))
3484 rx_pthresh = res->value;
3485 else if(!strcmp(res->name, "rxht"))
3486 rx_hthresh = res->value;
3487 else if(!strcmp(res->name, "rxwt"))
3488 rx_wthresh = res->value;
3490 printf("Unknown parameter\n");
3496 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3499 cmdline_parse_token_string_t cmd_config_thresh_port =
3500 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3501 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3502 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3503 cmdline_parse_token_string_t cmd_config_thresh_all =
3504 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3505 cmdline_parse_token_string_t cmd_config_thresh_name =
3506 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3507 "txpt#txht#txwt#rxpt#rxht#rxwt");
3508 cmdline_parse_token_num_t cmd_config_thresh_value =
3509 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3511 cmdline_parse_inst_t cmd_config_thresh = {
3512 .f = cmd_config_thresh_parsed,
3514 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3516 (void *)&cmd_config_thresh_port,
3517 (void *)&cmd_config_thresh_keyword,
3518 (void *)&cmd_config_thresh_all,
3519 (void *)&cmd_config_thresh_name,
3520 (void *)&cmd_config_thresh_value,
3525 /* *** configure free/rs threshold *** */
3526 struct cmd_config_threshold {
3527 cmdline_fixed_string_t port;
3528 cmdline_fixed_string_t keyword;
3529 cmdline_fixed_string_t all;
3530 cmdline_fixed_string_t name;
3535 cmd_config_threshold_parsed(void *parsed_result,
3536 __rte_unused struct cmdline *cl,
3537 __rte_unused void *data)
3539 struct cmd_config_threshold *res = parsed_result;
3541 if (!all_ports_stopped()) {
3542 printf("Please stop all ports first\n");
3546 if (!strcmp(res->name, "txfreet"))
3547 tx_free_thresh = res->value;
3548 else if (!strcmp(res->name, "txrst"))
3549 tx_rs_thresh = res->value;
3550 else if (!strcmp(res->name, "rxfreet"))
3551 rx_free_thresh = res->value;
3553 printf("Unknown parameter\n");
3559 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3562 cmdline_parse_token_string_t cmd_config_threshold_port =
3563 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3564 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3565 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3567 cmdline_parse_token_string_t cmd_config_threshold_all =
3568 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3569 cmdline_parse_token_string_t cmd_config_threshold_name =
3570 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3571 "txfreet#txrst#rxfreet");
3572 cmdline_parse_token_num_t cmd_config_threshold_value =
3573 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3575 cmdline_parse_inst_t cmd_config_threshold = {
3576 .f = cmd_config_threshold_parsed,
3578 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3580 (void *)&cmd_config_threshold_port,
3581 (void *)&cmd_config_threshold_keyword,
3582 (void *)&cmd_config_threshold_all,
3583 (void *)&cmd_config_threshold_name,
3584 (void *)&cmd_config_threshold_value,
3590 struct cmd_stop_result {
3591 cmdline_fixed_string_t stop;
3594 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3595 __rte_unused struct cmdline *cl,
3596 __rte_unused void *data)
3598 stop_packet_forwarding();
3601 cmdline_parse_token_string_t cmd_stop_stop =
3602 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3604 cmdline_parse_inst_t cmd_stop = {
3605 .f = cmd_stop_parsed,
3607 .help_str = "stop: Stop packet forwarding",
3609 (void *)&cmd_stop_stop,
3614 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3617 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3618 unsigned int *parsed_items, int check_unique_values)
3620 unsigned int nb_item;
3628 * First parse all items in the list and store their value.
3633 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3635 if ((c >= '0') && (c <= '9')) {
3636 value = (unsigned int) (value * 10 + (c - '0'));
3641 printf("character %c is not a decimal digit\n", c);
3645 printf("No valid value before comma\n");
3648 if (nb_item < max_items) {
3649 parsed_items[nb_item] = value;
3655 if (nb_item >= max_items) {
3656 printf("Number of %s = %u > %u (maximum items)\n",
3657 item_name, nb_item + 1, max_items);
3660 parsed_items[nb_item++] = value;
3661 if (! check_unique_values)
3665 * Then, check that all values in the list are differents.
3666 * No optimization here...
3668 for (i = 0; i < nb_item; i++) {
3669 for (j = i + 1; j < nb_item; j++) {
3670 if (parsed_items[j] == parsed_items[i]) {
3671 printf("duplicated %s %u at index %u and %u\n",
3672 item_name, parsed_items[i], i, j);
3680 struct cmd_set_list_result {
3681 cmdline_fixed_string_t cmd_keyword;
3682 cmdline_fixed_string_t list_name;
3683 cmdline_fixed_string_t list_of_items;
3686 static void cmd_set_list_parsed(void *parsed_result,
3687 __rte_unused struct cmdline *cl,
3688 __rte_unused void *data)
3690 struct cmd_set_list_result *res;
3692 unsigned int lcorelist[RTE_MAX_LCORE];
3693 unsigned int portlist[RTE_MAX_ETHPORTS];
3695 unsigned int nb_item;
3697 if (test_done == 0) {
3698 printf("Please stop forwarding first\n");
3702 res = parsed_result;
3703 if (!strcmp(res->list_name, "corelist")) {
3704 nb_item = parse_item_list(res->list_of_items, "core",
3706 parsed_items.lcorelist, 1);
3708 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3713 if (!strcmp(res->list_name, "portlist")) {
3714 nb_item = parse_item_list(res->list_of_items, "port",
3716 parsed_items.portlist, 1);
3718 set_fwd_ports_list(parsed_items.portlist, nb_item);
3724 cmdline_parse_token_string_t cmd_set_list_keyword =
3725 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3727 cmdline_parse_token_string_t cmd_set_list_name =
3728 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3729 "corelist#portlist");
3730 cmdline_parse_token_string_t cmd_set_list_of_items =
3731 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3734 cmdline_parse_inst_t cmd_set_fwd_list = {
3735 .f = cmd_set_list_parsed,
3737 .help_str = "set corelist|portlist <list0[,list1]*>",
3739 (void *)&cmd_set_list_keyword,
3740 (void *)&cmd_set_list_name,
3741 (void *)&cmd_set_list_of_items,
3746 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3748 struct cmd_setmask_result {
3749 cmdline_fixed_string_t set;
3750 cmdline_fixed_string_t mask;
3754 static void cmd_set_mask_parsed(void *parsed_result,
3755 __rte_unused struct cmdline *cl,
3756 __rte_unused void *data)
3758 struct cmd_setmask_result *res = parsed_result;
3760 if (test_done == 0) {
3761 printf("Please stop forwarding first\n");
3764 if (!strcmp(res->mask, "coremask")) {
3765 set_fwd_lcores_mask(res->hexavalue);
3767 } else if (!strcmp(res->mask, "portmask")) {
3768 set_fwd_ports_mask(res->hexavalue);
3773 cmdline_parse_token_string_t cmd_setmask_set =
3774 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3775 cmdline_parse_token_string_t cmd_setmask_mask =
3776 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3777 "coremask#portmask");
3778 cmdline_parse_token_num_t cmd_setmask_value =
3779 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3781 cmdline_parse_inst_t cmd_set_fwd_mask = {
3782 .f = cmd_set_mask_parsed,
3784 .help_str = "set coremask|portmask <hexadecimal value>",
3786 (void *)&cmd_setmask_set,
3787 (void *)&cmd_setmask_mask,
3788 (void *)&cmd_setmask_value,
3794 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3796 struct cmd_set_result {
3797 cmdline_fixed_string_t set;
3798 cmdline_fixed_string_t what;
3802 static void cmd_set_parsed(void *parsed_result,
3803 __rte_unused struct cmdline *cl,
3804 __rte_unused void *data)
3806 struct cmd_set_result *res = parsed_result;
3807 if (!strcmp(res->what, "nbport")) {
3808 set_fwd_ports_number(res->value);
3810 } else if (!strcmp(res->what, "nbcore")) {
3811 set_fwd_lcores_number(res->value);
3813 } else if (!strcmp(res->what, "burst"))
3814 set_nb_pkt_per_burst(res->value);
3815 else if (!strcmp(res->what, "verbose"))
3816 set_verbose_level(res->value);
3819 cmdline_parse_token_string_t cmd_set_set =
3820 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3821 cmdline_parse_token_string_t cmd_set_what =
3822 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3823 "nbport#nbcore#burst#verbose");
3824 cmdline_parse_token_num_t cmd_set_value =
3825 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3827 cmdline_parse_inst_t cmd_set_numbers = {
3828 .f = cmd_set_parsed,
3830 .help_str = "set nbport|nbcore|burst|verbose <value>",
3832 (void *)&cmd_set_set,
3833 (void *)&cmd_set_what,
3834 (void *)&cmd_set_value,
3839 /* *** SET LOG LEVEL CONFIGURATION *** */
3841 struct cmd_set_log_result {
3842 cmdline_fixed_string_t set;
3843 cmdline_fixed_string_t log;
3844 cmdline_fixed_string_t type;
3849 cmd_set_log_parsed(void *parsed_result,
3850 __rte_unused struct cmdline *cl,
3851 __rte_unused void *data)
3853 struct cmd_set_log_result *res;
3856 res = parsed_result;
3857 if (!strcmp(res->type, "global"))
3858 rte_log_set_global_level(res->level);
3860 ret = rte_log_set_level_regexp(res->type, res->level);
3862 printf("Unable to set log level\n");
3866 cmdline_parse_token_string_t cmd_set_log_set =
3867 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3868 cmdline_parse_token_string_t cmd_set_log_log =
3869 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3870 cmdline_parse_token_string_t cmd_set_log_type =
3871 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3872 cmdline_parse_token_num_t cmd_set_log_level =
3873 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3875 cmdline_parse_inst_t cmd_set_log = {
3876 .f = cmd_set_log_parsed,
3878 .help_str = "set log global|<type> <level>",
3880 (void *)&cmd_set_log_set,
3881 (void *)&cmd_set_log_log,
3882 (void *)&cmd_set_log_type,
3883 (void *)&cmd_set_log_level,
3888 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3890 struct cmd_set_rxoffs_result {
3891 cmdline_fixed_string_t cmd_keyword;
3892 cmdline_fixed_string_t rxoffs;
3893 cmdline_fixed_string_t seg_offsets;
3897 cmd_set_rxoffs_parsed(void *parsed_result,
3898 __rte_unused struct cmdline *cl,
3899 __rte_unused void *data)
3901 struct cmd_set_rxoffs_result *res;
3902 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3903 unsigned int nb_segs;
3905 res = parsed_result;
3906 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3907 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3909 set_rx_pkt_offsets(seg_offsets, nb_segs);
3910 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3913 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3914 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3915 cmd_keyword, "set");
3916 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3917 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3919 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3920 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3923 cmdline_parse_inst_t cmd_set_rxoffs = {
3924 .f = cmd_set_rxoffs_parsed,
3926 .help_str = "set rxoffs <len0[,len1]*>",
3928 (void *)&cmd_set_rxoffs_keyword,
3929 (void *)&cmd_set_rxoffs_name,
3930 (void *)&cmd_set_rxoffs_offsets,
3935 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3937 struct cmd_set_rxpkts_result {
3938 cmdline_fixed_string_t cmd_keyword;
3939 cmdline_fixed_string_t rxpkts;
3940 cmdline_fixed_string_t seg_lengths;
3944 cmd_set_rxpkts_parsed(void *parsed_result,
3945 __rte_unused struct cmdline *cl,
3946 __rte_unused void *data)
3948 struct cmd_set_rxpkts_result *res;
3949 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3950 unsigned int nb_segs;
3952 res = parsed_result;
3953 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3954 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3956 set_rx_pkt_segments(seg_lengths, nb_segs);
3957 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3960 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3961 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3962 cmd_keyword, "set");
3963 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3964 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3966 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3967 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3970 cmdline_parse_inst_t cmd_set_rxpkts = {
3971 .f = cmd_set_rxpkts_parsed,
3973 .help_str = "set rxpkts <len0[,len1]*>",
3975 (void *)&cmd_set_rxpkts_keyword,
3976 (void *)&cmd_set_rxpkts_name,
3977 (void *)&cmd_set_rxpkts_lengths,
3982 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3984 struct cmd_set_txpkts_result {
3985 cmdline_fixed_string_t cmd_keyword;
3986 cmdline_fixed_string_t txpkts;
3987 cmdline_fixed_string_t seg_lengths;
3991 cmd_set_txpkts_parsed(void *parsed_result,
3992 __rte_unused struct cmdline *cl,
3993 __rte_unused void *data)
3995 struct cmd_set_txpkts_result *res;
3996 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3997 unsigned int nb_segs;
3999 res = parsed_result;
4000 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4001 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4003 set_tx_pkt_segments(seg_lengths, nb_segs);
4006 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4007 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4008 cmd_keyword, "set");
4009 cmdline_parse_token_string_t cmd_set_txpkts_name =
4010 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4012 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4013 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4016 cmdline_parse_inst_t cmd_set_txpkts = {
4017 .f = cmd_set_txpkts_parsed,
4019 .help_str = "set txpkts <len0[,len1]*>",
4021 (void *)&cmd_set_txpkts_keyword,
4022 (void *)&cmd_set_txpkts_name,
4023 (void *)&cmd_set_txpkts_lengths,
4028 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4030 struct cmd_set_txsplit_result {
4031 cmdline_fixed_string_t cmd_keyword;
4032 cmdline_fixed_string_t txsplit;
4033 cmdline_fixed_string_t mode;
4037 cmd_set_txsplit_parsed(void *parsed_result,
4038 __rte_unused struct cmdline *cl,
4039 __rte_unused void *data)
4041 struct cmd_set_txsplit_result *res;
4043 res = parsed_result;
4044 set_tx_pkt_split(res->mode);
4047 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4048 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4049 cmd_keyword, "set");
4050 cmdline_parse_token_string_t cmd_set_txsplit_name =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4052 txsplit, "txsplit");
4053 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4054 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4057 cmdline_parse_inst_t cmd_set_txsplit = {
4058 .f = cmd_set_txsplit_parsed,
4060 .help_str = "set txsplit on|off|rand",
4062 (void *)&cmd_set_txsplit_keyword,
4063 (void *)&cmd_set_txsplit_name,
4064 (void *)&cmd_set_txsplit_mode,
4069 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4071 struct cmd_set_txtimes_result {
4072 cmdline_fixed_string_t cmd_keyword;
4073 cmdline_fixed_string_t txtimes;
4074 cmdline_fixed_string_t tx_times;
4078 cmd_set_txtimes_parsed(void *parsed_result,
4079 __rte_unused struct cmdline *cl,
4080 __rte_unused void *data)
4082 struct cmd_set_txtimes_result *res;
4083 unsigned int tx_times[2] = {0, 0};
4084 unsigned int n_times;
4086 res = parsed_result;
4087 n_times = parse_item_list(res->tx_times, "tx times",
4090 set_tx_pkt_times(tx_times);
4093 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4094 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4095 cmd_keyword, "set");
4096 cmdline_parse_token_string_t cmd_set_txtimes_name =
4097 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4098 txtimes, "txtimes");
4099 cmdline_parse_token_string_t cmd_set_txtimes_value =
4100 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4103 cmdline_parse_inst_t cmd_set_txtimes = {
4104 .f = cmd_set_txtimes_parsed,
4106 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4108 (void *)&cmd_set_txtimes_keyword,
4109 (void *)&cmd_set_txtimes_name,
4110 (void *)&cmd_set_txtimes_value,
4115 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4116 struct cmd_rx_vlan_filter_all_result {
4117 cmdline_fixed_string_t rx_vlan;
4118 cmdline_fixed_string_t what;
4119 cmdline_fixed_string_t all;
4124 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4125 __rte_unused struct cmdline *cl,
4126 __rte_unused void *data)
4128 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4130 if (!strcmp(res->what, "add"))
4131 rx_vlan_all_filter_set(res->port_id, 1);
4133 rx_vlan_all_filter_set(res->port_id, 0);
4136 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4137 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4138 rx_vlan, "rx_vlan");
4139 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4140 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4142 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4143 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4145 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4146 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4147 port_id, RTE_UINT16);
4149 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4150 .f = cmd_rx_vlan_filter_all_parsed,
4152 .help_str = "rx_vlan add|rm all <port_id>: "
4153 "Add/Remove all identifiers to/from the set of VLAN "
4154 "identifiers filtered by a port",
4156 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4157 (void *)&cmd_rx_vlan_filter_all_what,
4158 (void *)&cmd_rx_vlan_filter_all_all,
4159 (void *)&cmd_rx_vlan_filter_all_portid,
4164 /* *** VLAN OFFLOAD SET ON A PORT *** */
4165 struct cmd_vlan_offload_result {
4166 cmdline_fixed_string_t vlan;
4167 cmdline_fixed_string_t set;
4168 cmdline_fixed_string_t vlan_type;
4169 cmdline_fixed_string_t what;
4170 cmdline_fixed_string_t on;
4171 cmdline_fixed_string_t port_id;
4175 cmd_vlan_offload_parsed(void *parsed_result,
4176 __rte_unused struct cmdline *cl,
4177 __rte_unused void *data)
4180 struct cmd_vlan_offload_result *res = parsed_result;
4183 portid_t port_id = 0;
4187 len = strnlen(str, STR_TOKEN_SIZE);
4189 /* Get port_id first */
4197 tmp = strtoul(str, NULL, 0);
4198 /* If port_id greater that what portid_t can represent, return */
4199 if(tmp >= RTE_MAX_ETHPORTS)
4201 port_id = (portid_t)tmp;
4203 if (!strcmp(res->on, "on"))
4208 if (!strcmp(res->what, "strip"))
4209 rx_vlan_strip_set(port_id, on);
4210 else if(!strcmp(res->what, "stripq")){
4211 uint16_t queue_id = 0;
4213 /* No queue_id, return */
4215 printf("must specify (port,queue_id)\n");
4218 tmp = strtoul(str + i + 1, NULL, 0);
4219 /* If queue_id greater that what 16-bits can represent, return */
4223 queue_id = (uint16_t)tmp;
4224 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4226 else if (!strcmp(res->what, "filter"))
4227 rx_vlan_filter_set(port_id, on);
4228 else if (!strcmp(res->what, "qinq_strip"))
4229 rx_vlan_qinq_strip_set(port_id, on);
4231 vlan_extend_set(port_id, on);
4236 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4237 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4239 cmdline_parse_token_string_t cmd_vlan_offload_set =
4240 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4242 cmdline_parse_token_string_t cmd_vlan_offload_what =
4243 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4244 what, "strip#filter#qinq_strip#extend#stripq");
4245 cmdline_parse_token_string_t cmd_vlan_offload_on =
4246 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4248 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4249 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4252 cmdline_parse_inst_t cmd_vlan_offload = {
4253 .f = cmd_vlan_offload_parsed,
4255 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4256 "<port_id[,queue_id]>: "
4257 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4259 (void *)&cmd_vlan_offload_vlan,
4260 (void *)&cmd_vlan_offload_set,
4261 (void *)&cmd_vlan_offload_what,
4262 (void *)&cmd_vlan_offload_on,
4263 (void *)&cmd_vlan_offload_portid,
4268 /* *** VLAN TPID SET ON A PORT *** */
4269 struct cmd_vlan_tpid_result {
4270 cmdline_fixed_string_t vlan;
4271 cmdline_fixed_string_t set;
4272 cmdline_fixed_string_t vlan_type;
4273 cmdline_fixed_string_t what;
4279 cmd_vlan_tpid_parsed(void *parsed_result,
4280 __rte_unused struct cmdline *cl,
4281 __rte_unused void *data)
4283 struct cmd_vlan_tpid_result *res = parsed_result;
4284 enum rte_vlan_type vlan_type;
4286 if (!strcmp(res->vlan_type, "inner"))
4287 vlan_type = ETH_VLAN_TYPE_INNER;
4288 else if (!strcmp(res->vlan_type, "outer"))
4289 vlan_type = ETH_VLAN_TYPE_OUTER;
4291 printf("Unknown vlan type\n");
4294 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4297 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4298 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4300 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4301 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4303 cmdline_parse_token_string_t cmd_vlan_type =
4304 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4305 vlan_type, "inner#outer");
4306 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4307 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4309 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4310 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4312 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4313 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4314 port_id, RTE_UINT16);
4316 cmdline_parse_inst_t cmd_vlan_tpid = {
4317 .f = cmd_vlan_tpid_parsed,
4319 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4320 "Set the VLAN Ether type",
4322 (void *)&cmd_vlan_tpid_vlan,
4323 (void *)&cmd_vlan_tpid_set,
4324 (void *)&cmd_vlan_type,
4325 (void *)&cmd_vlan_tpid_what,
4326 (void *)&cmd_vlan_tpid_tpid,
4327 (void *)&cmd_vlan_tpid_portid,
4332 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4333 struct cmd_rx_vlan_filter_result {
4334 cmdline_fixed_string_t rx_vlan;
4335 cmdline_fixed_string_t what;
4341 cmd_rx_vlan_filter_parsed(void *parsed_result,
4342 __rte_unused struct cmdline *cl,
4343 __rte_unused void *data)
4345 struct cmd_rx_vlan_filter_result *res = parsed_result;
4347 if (!strcmp(res->what, "add"))
4348 rx_vft_set(res->port_id, res->vlan_id, 1);
4350 rx_vft_set(res->port_id, res->vlan_id, 0);
4353 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4354 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4355 rx_vlan, "rx_vlan");
4356 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4357 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4359 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4360 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4361 vlan_id, RTE_UINT16);
4362 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4363 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4364 port_id, RTE_UINT16);
4366 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4367 .f = cmd_rx_vlan_filter_parsed,
4369 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4370 "Add/Remove a VLAN identifier to/from the set of VLAN "
4371 "identifiers filtered by a port",
4373 (void *)&cmd_rx_vlan_filter_rx_vlan,
4374 (void *)&cmd_rx_vlan_filter_what,
4375 (void *)&cmd_rx_vlan_filter_vlanid,
4376 (void *)&cmd_rx_vlan_filter_portid,
4381 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4382 struct cmd_tx_vlan_set_result {
4383 cmdline_fixed_string_t tx_vlan;
4384 cmdline_fixed_string_t set;
4390 cmd_tx_vlan_set_parsed(void *parsed_result,
4391 __rte_unused struct cmdline *cl,
4392 __rte_unused void *data)
4394 struct cmd_tx_vlan_set_result *res = parsed_result;
4396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4399 if (!port_is_stopped(res->port_id)) {
4400 printf("Please stop port %d first\n", res->port_id);
4404 tx_vlan_set(res->port_id, res->vlan_id);
4406 cmd_reconfig_device_queue(res->port_id, 1, 1);
4409 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4410 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4411 tx_vlan, "tx_vlan");
4412 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4413 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4415 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4416 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4417 port_id, RTE_UINT16);
4418 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4419 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4420 vlan_id, RTE_UINT16);
4422 cmdline_parse_inst_t cmd_tx_vlan_set = {
4423 .f = cmd_tx_vlan_set_parsed,
4425 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4426 "Enable hardware insertion of a single VLAN header "
4427 "with a given TAG Identifier in packets sent on a port",
4429 (void *)&cmd_tx_vlan_set_tx_vlan,
4430 (void *)&cmd_tx_vlan_set_set,
4431 (void *)&cmd_tx_vlan_set_portid,
4432 (void *)&cmd_tx_vlan_set_vlanid,
4437 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4438 struct cmd_tx_vlan_set_qinq_result {
4439 cmdline_fixed_string_t tx_vlan;
4440 cmdline_fixed_string_t set;
4443 uint16_t vlan_id_outer;
4447 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4448 __rte_unused struct cmdline *cl,
4449 __rte_unused void *data)
4451 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4453 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4456 if (!port_is_stopped(res->port_id)) {
4457 printf("Please stop port %d first\n", res->port_id);
4461 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4463 cmd_reconfig_device_queue(res->port_id, 1, 1);
4466 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4467 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4468 tx_vlan, "tx_vlan");
4469 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4470 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4472 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4473 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4474 port_id, RTE_UINT16);
4475 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4476 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4477 vlan_id, RTE_UINT16);
4478 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4479 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4480 vlan_id_outer, RTE_UINT16);
4482 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4483 .f = cmd_tx_vlan_set_qinq_parsed,
4485 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4486 "Enable hardware insertion of double VLAN header "
4487 "with given TAG Identifiers in packets sent on a port",
4489 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4490 (void *)&cmd_tx_vlan_set_qinq_set,
4491 (void *)&cmd_tx_vlan_set_qinq_portid,
4492 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4493 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4498 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4499 struct cmd_tx_vlan_set_pvid_result {
4500 cmdline_fixed_string_t tx_vlan;
4501 cmdline_fixed_string_t set;
4502 cmdline_fixed_string_t pvid;
4505 cmdline_fixed_string_t mode;
4509 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4510 __rte_unused struct cmdline *cl,
4511 __rte_unused void *data)
4513 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4515 if (strcmp(res->mode, "on") == 0)
4516 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4518 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4521 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4522 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4523 tx_vlan, "tx_vlan");
4524 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4525 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4527 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4528 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4530 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4531 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4532 port_id, RTE_UINT16);
4533 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4534 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4535 vlan_id, RTE_UINT16);
4536 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4537 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4540 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4541 .f = cmd_tx_vlan_set_pvid_parsed,
4543 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4545 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4546 (void *)&cmd_tx_vlan_set_pvid_set,
4547 (void *)&cmd_tx_vlan_set_pvid_pvid,
4548 (void *)&cmd_tx_vlan_set_pvid_port_id,
4549 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4550 (void *)&cmd_tx_vlan_set_pvid_mode,
4555 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4556 struct cmd_tx_vlan_reset_result {
4557 cmdline_fixed_string_t tx_vlan;
4558 cmdline_fixed_string_t reset;
4563 cmd_tx_vlan_reset_parsed(void *parsed_result,
4564 __rte_unused struct cmdline *cl,
4565 __rte_unused void *data)
4567 struct cmd_tx_vlan_reset_result *res = parsed_result;
4569 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4572 if (!port_is_stopped(res->port_id)) {
4573 printf("Please stop port %d first\n", res->port_id);
4577 tx_vlan_reset(res->port_id);
4579 cmd_reconfig_device_queue(res->port_id, 1, 1);
4582 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4583 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4584 tx_vlan, "tx_vlan");
4585 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4586 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4588 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4589 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4590 port_id, RTE_UINT16);
4592 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4593 .f = cmd_tx_vlan_reset_parsed,
4595 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4596 "VLAN header in packets sent on a port",
4598 (void *)&cmd_tx_vlan_reset_tx_vlan,
4599 (void *)&cmd_tx_vlan_reset_reset,
4600 (void *)&cmd_tx_vlan_reset_portid,
4606 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4607 struct cmd_csum_result {
4608 cmdline_fixed_string_t csum;
4609 cmdline_fixed_string_t mode;
4610 cmdline_fixed_string_t proto;
4611 cmdline_fixed_string_t hwsw;
4616 csum_show(int port_id)
4618 struct rte_eth_dev_info dev_info;
4619 uint64_t tx_offloads;
4622 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4623 printf("Parse tunnel is %s\n",
4624 (ports[port_id].parse_tunnel) ? "on" : "off");
4625 printf("IP checksum offload is %s\n",
4626 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4627 printf("UDP checksum offload is %s\n",
4628 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4629 printf("TCP checksum offload is %s\n",
4630 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4631 printf("SCTP checksum offload is %s\n",
4632 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4633 printf("Outer-Ip checksum offload is %s\n",
4634 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4635 printf("Outer-Udp checksum offload is %s\n",
4636 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4638 /* display warnings if configuration is not supported by the NIC */
4639 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4643 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4644 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4645 printf("Warning: hardware IP checksum enabled but not "
4646 "supported by port %d\n", port_id);
4648 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4649 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4650 printf("Warning: hardware UDP checksum enabled but not "
4651 "supported by port %d\n", port_id);
4653 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4654 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4655 printf("Warning: hardware TCP checksum enabled but not "
4656 "supported by port %d\n", port_id);
4658 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4659 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4660 printf("Warning: hardware SCTP checksum enabled but not "
4661 "supported by port %d\n", port_id);
4663 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4664 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4665 printf("Warning: hardware outer IP checksum enabled but not "
4666 "supported by port %d\n", port_id);
4668 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4669 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4671 printf("Warning: hardware outer UDP checksum enabled but not "
4672 "supported by port %d\n", port_id);
4677 cmd_config_queue_tx_offloads(struct rte_port *port)
4681 /* Apply queue tx offloads configuration */
4682 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4683 port->tx_conf[k].offloads =
4684 port->dev_conf.txmode.offloads;
4688 cmd_csum_parsed(void *parsed_result,
4689 __rte_unused struct cmdline *cl,
4690 __rte_unused void *data)
4692 struct cmd_csum_result *res = parsed_result;
4694 uint64_t csum_offloads = 0;
4695 struct rte_eth_dev_info dev_info;
4698 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4699 printf("invalid port %d\n", res->port_id);
4702 if (!port_is_stopped(res->port_id)) {
4703 printf("Please stop port %d first\n", res->port_id);
4707 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4711 if (!strcmp(res->mode, "set")) {
4713 if (!strcmp(res->hwsw, "hw"))
4716 if (!strcmp(res->proto, "ip")) {
4717 if (hw == 0 || (dev_info.tx_offload_capa &
4718 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4719 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4721 printf("IP checksum offload is not supported "
4722 "by port %u\n", res->port_id);
4724 } else if (!strcmp(res->proto, "udp")) {
4725 if (hw == 0 || (dev_info.tx_offload_capa &
4726 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4727 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4729 printf("UDP checksum offload is not supported "
4730 "by port %u\n", res->port_id);
4732 } else if (!strcmp(res->proto, "tcp")) {
4733 if (hw == 0 || (dev_info.tx_offload_capa &
4734 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4735 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4737 printf("TCP checksum offload is not supported "
4738 "by port %u\n", res->port_id);
4740 } else if (!strcmp(res->proto, "sctp")) {
4741 if (hw == 0 || (dev_info.tx_offload_capa &
4742 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4743 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4745 printf("SCTP checksum offload is not supported "
4746 "by port %u\n", res->port_id);
4748 } else if (!strcmp(res->proto, "outer-ip")) {
4749 if (hw == 0 || (dev_info.tx_offload_capa &
4750 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4752 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4754 printf("Outer IP checksum offload is not "
4755 "supported by port %u\n", res->port_id);
4757 } else if (!strcmp(res->proto, "outer-udp")) {
4758 if (hw == 0 || (dev_info.tx_offload_capa &
4759 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4761 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4763 printf("Outer UDP checksum offload is not "
4764 "supported by port %u\n", res->port_id);
4769 ports[res->port_id].dev_conf.txmode.offloads |=
4772 ports[res->port_id].dev_conf.txmode.offloads &=
4775 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4777 csum_show(res->port_id);
4779 cmd_reconfig_device_queue(res->port_id, 1, 1);
4782 cmdline_parse_token_string_t cmd_csum_csum =
4783 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4785 cmdline_parse_token_string_t cmd_csum_mode =
4786 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4788 cmdline_parse_token_string_t cmd_csum_proto =
4789 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4790 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4791 cmdline_parse_token_string_t cmd_csum_hwsw =
4792 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4794 cmdline_parse_token_num_t cmd_csum_portid =
4795 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4796 port_id, RTE_UINT16);
4798 cmdline_parse_inst_t cmd_csum_set = {
4799 .f = cmd_csum_parsed,
4801 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4802 "Enable/Disable hardware calculation of L3/L4 checksum when "
4803 "using csum forward engine",
4805 (void *)&cmd_csum_csum,
4806 (void *)&cmd_csum_mode,
4807 (void *)&cmd_csum_proto,
4808 (void *)&cmd_csum_hwsw,
4809 (void *)&cmd_csum_portid,
4814 cmdline_parse_token_string_t cmd_csum_mode_show =
4815 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4818 cmdline_parse_inst_t cmd_csum_show = {
4819 .f = cmd_csum_parsed,
4821 .help_str = "csum show <port_id>: Show checksum offload configuration",
4823 (void *)&cmd_csum_csum,
4824 (void *)&cmd_csum_mode_show,
4825 (void *)&cmd_csum_portid,
4830 /* Enable/disable tunnel parsing */
4831 struct cmd_csum_tunnel_result {
4832 cmdline_fixed_string_t csum;
4833 cmdline_fixed_string_t parse;
4834 cmdline_fixed_string_t onoff;
4839 cmd_csum_tunnel_parsed(void *parsed_result,
4840 __rte_unused struct cmdline *cl,
4841 __rte_unused void *data)
4843 struct cmd_csum_tunnel_result *res = parsed_result;
4845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4848 if (!strcmp(res->onoff, "on"))
4849 ports[res->port_id].parse_tunnel = 1;
4851 ports[res->port_id].parse_tunnel = 0;
4853 csum_show(res->port_id);
4856 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4857 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4859 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4860 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4861 parse, "parse-tunnel");
4862 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4863 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4865 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4866 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4867 port_id, RTE_UINT16);
4869 cmdline_parse_inst_t cmd_csum_tunnel = {
4870 .f = cmd_csum_tunnel_parsed,
4872 .help_str = "csum parse-tunnel on|off <port_id>: "
4873 "Enable/Disable parsing of tunnels for csum engine",
4875 (void *)&cmd_csum_tunnel_csum,
4876 (void *)&cmd_csum_tunnel_parse,
4877 (void *)&cmd_csum_tunnel_onoff,
4878 (void *)&cmd_csum_tunnel_portid,
4883 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4884 struct cmd_tso_set_result {
4885 cmdline_fixed_string_t tso;
4886 cmdline_fixed_string_t mode;
4892 cmd_tso_set_parsed(void *parsed_result,
4893 __rte_unused struct cmdline *cl,
4894 __rte_unused void *data)
4896 struct cmd_tso_set_result *res = parsed_result;
4897 struct rte_eth_dev_info dev_info;
4900 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4902 if (!port_is_stopped(res->port_id)) {
4903 printf("Please stop port %d first\n", res->port_id);
4907 if (!strcmp(res->mode, "set"))
4908 ports[res->port_id].tso_segsz = res->tso_segsz;
4910 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4914 if ((ports[res->port_id].tso_segsz != 0) &&
4915 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4916 printf("Error: TSO is not supported by port %d\n",
4921 if (ports[res->port_id].tso_segsz == 0) {
4922 ports[res->port_id].dev_conf.txmode.offloads &=
4923 ~DEV_TX_OFFLOAD_TCP_TSO;
4924 printf("TSO for non-tunneled packets is disabled\n");
4926 ports[res->port_id].dev_conf.txmode.offloads |=
4927 DEV_TX_OFFLOAD_TCP_TSO;
4928 printf("TSO segment size for non-tunneled packets is %d\n",
4929 ports[res->port_id].tso_segsz);
4931 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4933 /* display warnings if configuration is not supported by the NIC */
4934 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4938 if ((ports[res->port_id].tso_segsz != 0) &&
4939 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4940 printf("Warning: TSO enabled but not "
4941 "supported by port %d\n", res->port_id);
4944 cmd_reconfig_device_queue(res->port_id, 1, 1);
4947 cmdline_parse_token_string_t cmd_tso_set_tso =
4948 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4950 cmdline_parse_token_string_t cmd_tso_set_mode =
4951 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4953 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4954 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4955 tso_segsz, RTE_UINT16);
4956 cmdline_parse_token_num_t cmd_tso_set_portid =
4957 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4958 port_id, RTE_UINT16);
4960 cmdline_parse_inst_t cmd_tso_set = {
4961 .f = cmd_tso_set_parsed,
4963 .help_str = "tso set <tso_segsz> <port_id>: "
4964 "Set TSO segment size of non-tunneled packets for csum engine "
4967 (void *)&cmd_tso_set_tso,
4968 (void *)&cmd_tso_set_mode,
4969 (void *)&cmd_tso_set_tso_segsz,
4970 (void *)&cmd_tso_set_portid,
4975 cmdline_parse_token_string_t cmd_tso_show_mode =
4976 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4980 cmdline_parse_inst_t cmd_tso_show = {
4981 .f = cmd_tso_set_parsed,
4983 .help_str = "tso show <port_id>: "
4984 "Show TSO segment size of non-tunneled packets for csum engine",
4986 (void *)&cmd_tso_set_tso,
4987 (void *)&cmd_tso_show_mode,
4988 (void *)&cmd_tso_set_portid,
4993 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4994 struct cmd_tunnel_tso_set_result {
4995 cmdline_fixed_string_t tso;
4996 cmdline_fixed_string_t mode;
5001 static struct rte_eth_dev_info
5002 check_tunnel_tso_nic_support(portid_t port_id)
5004 struct rte_eth_dev_info dev_info;
5006 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5009 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5010 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5011 "not enabled for port %d\n", port_id);
5012 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5013 printf("Warning: GRE TUNNEL TSO not supported therefore "
5014 "not enabled for port %d\n", port_id);
5015 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5016 printf("Warning: IPIP TUNNEL TSO not supported therefore "
5017 "not enabled for port %d\n", port_id);
5018 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5019 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5020 "not enabled for port %d\n", port_id);
5021 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5022 printf("Warning: IP TUNNEL TSO not supported therefore "
5023 "not enabled for port %d\n", port_id);
5024 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5025 printf("Warning: UDP TUNNEL TSO not supported therefore "
5026 "not enabled for port %d\n", port_id);
5031 cmd_tunnel_tso_set_parsed(void *parsed_result,
5032 __rte_unused struct cmdline *cl,
5033 __rte_unused void *data)
5035 struct cmd_tunnel_tso_set_result *res = parsed_result;
5036 struct rte_eth_dev_info dev_info;
5038 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5040 if (!port_is_stopped(res->port_id)) {
5041 printf("Please stop port %d first\n", res->port_id);
5045 if (!strcmp(res->mode, "set"))
5046 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5048 dev_info = check_tunnel_tso_nic_support(res->port_id);
5049 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5050 ports[res->port_id].dev_conf.txmode.offloads &=
5051 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5052 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5053 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5054 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5055 DEV_TX_OFFLOAD_IP_TNL_TSO |
5056 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5057 printf("TSO for tunneled packets is disabled\n");
5059 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5060 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5061 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5062 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5063 DEV_TX_OFFLOAD_IP_TNL_TSO |
5064 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5066 ports[res->port_id].dev_conf.txmode.offloads |=
5067 (tso_offloads & dev_info.tx_offload_capa);
5068 printf("TSO segment size for tunneled packets is %d\n",
5069 ports[res->port_id].tunnel_tso_segsz);
5071 /* Below conditions are needed to make it work:
5072 * (1) tunnel TSO is supported by the NIC;
5073 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5075 * (3) for tunneled pkts with outer L3 of IPv4,
5076 * "csum set outer-ip" must be set to hw, because after tso,
5077 * total_len of outer IP header is changed, and the checksum
5078 * of outer IP header calculated by sw should be wrong; that
5079 * is not necessary for IPv6 tunneled pkts because there's no
5080 * checksum in IP header anymore.
5083 if (!ports[res->port_id].parse_tunnel)
5084 printf("Warning: csum parse_tunnel must be set "
5085 "so that tunneled packets are recognized\n");
5086 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5087 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5088 printf("Warning: csum set outer-ip must be set to hw "
5089 "if outer L3 is IPv4; not necessary for IPv6\n");
5092 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5093 cmd_reconfig_device_queue(res->port_id, 1, 1);
5096 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5097 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5099 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5100 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5102 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5103 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5104 tso_segsz, RTE_UINT16);
5105 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5106 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5107 port_id, RTE_UINT16);
5109 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5110 .f = cmd_tunnel_tso_set_parsed,
5112 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5113 "Set TSO segment size of tunneled packets for csum engine "
5116 (void *)&cmd_tunnel_tso_set_tso,
5117 (void *)&cmd_tunnel_tso_set_mode,
5118 (void *)&cmd_tunnel_tso_set_tso_segsz,
5119 (void *)&cmd_tunnel_tso_set_portid,
5124 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5125 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5129 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5130 .f = cmd_tunnel_tso_set_parsed,
5132 .help_str = "tunnel_tso show <port_id> "
5133 "Show TSO segment size of tunneled packets for csum engine",
5135 (void *)&cmd_tunnel_tso_set_tso,
5136 (void *)&cmd_tunnel_tso_show_mode,
5137 (void *)&cmd_tunnel_tso_set_portid,
5142 /* *** SET GRO FOR A PORT *** */
5143 struct cmd_gro_enable_result {
5144 cmdline_fixed_string_t cmd_set;
5145 cmdline_fixed_string_t cmd_port;
5146 cmdline_fixed_string_t cmd_keyword;
5147 cmdline_fixed_string_t cmd_onoff;
5152 cmd_gro_enable_parsed(void *parsed_result,
5153 __rte_unused struct cmdline *cl,
5154 __rte_unused void *data)
5156 struct cmd_gro_enable_result *res;
5158 res = parsed_result;
5159 if (!strcmp(res->cmd_keyword, "gro"))
5160 setup_gro(res->cmd_onoff, res->cmd_pid);
5163 cmdline_parse_token_string_t cmd_gro_enable_set =
5164 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5166 cmdline_parse_token_string_t cmd_gro_enable_port =
5167 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5168 cmd_keyword, "port");
5169 cmdline_parse_token_num_t cmd_gro_enable_pid =
5170 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5171 cmd_pid, RTE_UINT16);
5172 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5173 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5174 cmd_keyword, "gro");
5175 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5176 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5177 cmd_onoff, "on#off");
5179 cmdline_parse_inst_t cmd_gro_enable = {
5180 .f = cmd_gro_enable_parsed,
5182 .help_str = "set port <port_id> gro on|off",
5184 (void *)&cmd_gro_enable_set,
5185 (void *)&cmd_gro_enable_port,
5186 (void *)&cmd_gro_enable_pid,
5187 (void *)&cmd_gro_enable_keyword,
5188 (void *)&cmd_gro_enable_onoff,
5193 /* *** DISPLAY GRO CONFIGURATION *** */
5194 struct cmd_gro_show_result {
5195 cmdline_fixed_string_t cmd_show;
5196 cmdline_fixed_string_t cmd_port;
5197 cmdline_fixed_string_t cmd_keyword;
5202 cmd_gro_show_parsed(void *parsed_result,
5203 __rte_unused struct cmdline *cl,
5204 __rte_unused void *data)
5206 struct cmd_gro_show_result *res;
5208 res = parsed_result;
5209 if (!strcmp(res->cmd_keyword, "gro"))
5210 show_gro(res->cmd_pid);
5213 cmdline_parse_token_string_t cmd_gro_show_show =
5214 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5216 cmdline_parse_token_string_t cmd_gro_show_port =
5217 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5219 cmdline_parse_token_num_t cmd_gro_show_pid =
5220 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5221 cmd_pid, RTE_UINT16);
5222 cmdline_parse_token_string_t cmd_gro_show_keyword =
5223 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5224 cmd_keyword, "gro");
5226 cmdline_parse_inst_t cmd_gro_show = {
5227 .f = cmd_gro_show_parsed,
5229 .help_str = "show port <port_id> gro",
5231 (void *)&cmd_gro_show_show,
5232 (void *)&cmd_gro_show_port,
5233 (void *)&cmd_gro_show_pid,
5234 (void *)&cmd_gro_show_keyword,
5239 /* *** SET FLUSH CYCLES FOR GRO *** */
5240 struct cmd_gro_flush_result {
5241 cmdline_fixed_string_t cmd_set;
5242 cmdline_fixed_string_t cmd_keyword;
5243 cmdline_fixed_string_t cmd_flush;
5248 cmd_gro_flush_parsed(void *parsed_result,
5249 __rte_unused struct cmdline *cl,
5250 __rte_unused void *data)
5252 struct cmd_gro_flush_result *res;
5254 res = parsed_result;
5255 if ((!strcmp(res->cmd_keyword, "gro")) &&
5256 (!strcmp(res->cmd_flush, "flush")))
5257 setup_gro_flush_cycles(res->cmd_cycles);
5260 cmdline_parse_token_string_t cmd_gro_flush_set =
5261 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5263 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5264 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5265 cmd_keyword, "gro");
5266 cmdline_parse_token_string_t cmd_gro_flush_flush =
5267 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5268 cmd_flush, "flush");
5269 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5270 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5271 cmd_cycles, RTE_UINT8);
5273 cmdline_parse_inst_t cmd_gro_flush = {
5274 .f = cmd_gro_flush_parsed,
5276 .help_str = "set gro flush <cycles>",
5278 (void *)&cmd_gro_flush_set,
5279 (void *)&cmd_gro_flush_keyword,
5280 (void *)&cmd_gro_flush_flush,
5281 (void *)&cmd_gro_flush_cycles,
5286 /* *** ENABLE/DISABLE GSO *** */
5287 struct cmd_gso_enable_result {
5288 cmdline_fixed_string_t cmd_set;
5289 cmdline_fixed_string_t cmd_port;
5290 cmdline_fixed_string_t cmd_keyword;
5291 cmdline_fixed_string_t cmd_mode;
5296 cmd_gso_enable_parsed(void *parsed_result,
5297 __rte_unused struct cmdline *cl,
5298 __rte_unused void *data)
5300 struct cmd_gso_enable_result *res;
5302 res = parsed_result;
5303 if (!strcmp(res->cmd_keyword, "gso"))
5304 setup_gso(res->cmd_mode, res->cmd_pid);
5307 cmdline_parse_token_string_t cmd_gso_enable_set =
5308 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5310 cmdline_parse_token_string_t cmd_gso_enable_port =
5311 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5313 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5314 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5315 cmd_keyword, "gso");
5316 cmdline_parse_token_string_t cmd_gso_enable_mode =
5317 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5318 cmd_mode, "on#off");
5319 cmdline_parse_token_num_t cmd_gso_enable_pid =
5320 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5321 cmd_pid, RTE_UINT16);
5323 cmdline_parse_inst_t cmd_gso_enable = {
5324 .f = cmd_gso_enable_parsed,
5326 .help_str = "set port <port_id> gso on|off",
5328 (void *)&cmd_gso_enable_set,
5329 (void *)&cmd_gso_enable_port,
5330 (void *)&cmd_gso_enable_pid,
5331 (void *)&cmd_gso_enable_keyword,
5332 (void *)&cmd_gso_enable_mode,
5337 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5338 struct cmd_gso_size_result {
5339 cmdline_fixed_string_t cmd_set;
5340 cmdline_fixed_string_t cmd_keyword;
5341 cmdline_fixed_string_t cmd_segsz;
5346 cmd_gso_size_parsed(void *parsed_result,
5347 __rte_unused struct cmdline *cl,
5348 __rte_unused void *data)
5350 struct cmd_gso_size_result *res = parsed_result;
5352 if (test_done == 0) {
5353 printf("Before setting GSO segsz, please first"
5354 " stop forwarding\n");
5358 if (!strcmp(res->cmd_keyword, "gso") &&
5359 !strcmp(res->cmd_segsz, "segsz")) {
5360 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5361 printf("gso_size should be larger than %zu."
5362 " Please input a legal value\n",
5363 RTE_GSO_SEG_SIZE_MIN);
5365 gso_max_segment_size = res->cmd_size;
5369 cmdline_parse_token_string_t cmd_gso_size_set =
5370 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5372 cmdline_parse_token_string_t cmd_gso_size_keyword =
5373 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5374 cmd_keyword, "gso");
5375 cmdline_parse_token_string_t cmd_gso_size_segsz =
5376 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5377 cmd_segsz, "segsz");
5378 cmdline_parse_token_num_t cmd_gso_size_size =
5379 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5380 cmd_size, RTE_UINT16);
5382 cmdline_parse_inst_t cmd_gso_size = {
5383 .f = cmd_gso_size_parsed,
5385 .help_str = "set gso segsz <length>",
5387 (void *)&cmd_gso_size_set,
5388 (void *)&cmd_gso_size_keyword,
5389 (void *)&cmd_gso_size_segsz,
5390 (void *)&cmd_gso_size_size,
5395 /* *** SHOW GSO CONFIGURATION *** */
5396 struct cmd_gso_show_result {
5397 cmdline_fixed_string_t cmd_show;
5398 cmdline_fixed_string_t cmd_port;
5399 cmdline_fixed_string_t cmd_keyword;
5404 cmd_gso_show_parsed(void *parsed_result,
5405 __rte_unused struct cmdline *cl,
5406 __rte_unused void *data)
5408 struct cmd_gso_show_result *res = parsed_result;
5410 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5411 printf("invalid port id %u\n", res->cmd_pid);
5414 if (!strcmp(res->cmd_keyword, "gso")) {
5415 if (gso_ports[res->cmd_pid].enable) {
5416 printf("Max GSO'd packet size: %uB\n"
5417 "Supported GSO types: TCP/IPv4, "
5418 "UDP/IPv4, VxLAN with inner "
5419 "TCP/IPv4 packet, GRE with inner "
5420 "TCP/IPv4 packet\n",
5421 gso_max_segment_size);
5423 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5427 cmdline_parse_token_string_t cmd_gso_show_show =
5428 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5430 cmdline_parse_token_string_t cmd_gso_show_port =
5431 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5433 cmdline_parse_token_string_t cmd_gso_show_keyword =
5434 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5435 cmd_keyword, "gso");
5436 cmdline_parse_token_num_t cmd_gso_show_pid =
5437 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5438 cmd_pid, RTE_UINT16);
5440 cmdline_parse_inst_t cmd_gso_show = {
5441 .f = cmd_gso_show_parsed,
5443 .help_str = "show port <port_id> gso",
5445 (void *)&cmd_gso_show_show,
5446 (void *)&cmd_gso_show_port,
5447 (void *)&cmd_gso_show_pid,
5448 (void *)&cmd_gso_show_keyword,
5453 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5454 struct cmd_set_flush_rx {
5455 cmdline_fixed_string_t set;
5456 cmdline_fixed_string_t flush_rx;
5457 cmdline_fixed_string_t mode;
5461 cmd_set_flush_rx_parsed(void *parsed_result,
5462 __rte_unused struct cmdline *cl,
5463 __rte_unused void *data)
5465 struct cmd_set_flush_rx *res = parsed_result;
5466 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5469 cmdline_parse_token_string_t cmd_setflushrx_set =
5470 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5472 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5473 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5474 flush_rx, "flush_rx");
5475 cmdline_parse_token_string_t cmd_setflushrx_mode =
5476 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5480 cmdline_parse_inst_t cmd_set_flush_rx = {
5481 .f = cmd_set_flush_rx_parsed,
5482 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5485 (void *)&cmd_setflushrx_set,
5486 (void *)&cmd_setflushrx_flush_rx,
5487 (void *)&cmd_setflushrx_mode,
5492 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5493 struct cmd_set_link_check {
5494 cmdline_fixed_string_t set;
5495 cmdline_fixed_string_t link_check;
5496 cmdline_fixed_string_t mode;
5500 cmd_set_link_check_parsed(void *parsed_result,
5501 __rte_unused struct cmdline *cl,
5502 __rte_unused void *data)
5504 struct cmd_set_link_check *res = parsed_result;
5505 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5508 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5509 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5511 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5512 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5513 link_check, "link_check");
5514 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5515 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5519 cmdline_parse_inst_t cmd_set_link_check = {
5520 .f = cmd_set_link_check_parsed,
5521 .help_str = "set link_check on|off: Enable/Disable link status check "
5522 "when starting/stopping a port",
5525 (void *)&cmd_setlinkcheck_set,
5526 (void *)&cmd_setlinkcheck_link_check,
5527 (void *)&cmd_setlinkcheck_mode,
5532 /* *** SET NIC BYPASS MODE *** */
5533 struct cmd_set_bypass_mode_result {
5534 cmdline_fixed_string_t set;
5535 cmdline_fixed_string_t bypass;
5536 cmdline_fixed_string_t mode;
5537 cmdline_fixed_string_t value;
5542 cmd_set_bypass_mode_parsed(void *parsed_result,
5543 __rte_unused struct cmdline *cl,
5544 __rte_unused void *data)
5546 struct cmd_set_bypass_mode_result *res = parsed_result;
5547 portid_t port_id = res->port_id;
5548 int32_t rc = -EINVAL;
5550 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5551 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5553 if (!strcmp(res->value, "bypass"))
5554 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5555 else if (!strcmp(res->value, "isolate"))
5556 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5558 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5560 /* Set the bypass mode for the relevant port. */
5561 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5564 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5567 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5568 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5570 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5571 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5573 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5574 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5576 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5577 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5578 value, "normal#bypass#isolate");
5579 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5580 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5581 port_id, RTE_UINT16);
5583 cmdline_parse_inst_t cmd_set_bypass_mode = {
5584 .f = cmd_set_bypass_mode_parsed,
5585 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5586 "Set the NIC bypass mode for port_id",
5589 (void *)&cmd_setbypass_mode_set,
5590 (void *)&cmd_setbypass_mode_bypass,
5591 (void *)&cmd_setbypass_mode_mode,
5592 (void *)&cmd_setbypass_mode_value,
5593 (void *)&cmd_setbypass_mode_port,
5598 /* *** SET NIC BYPASS EVENT *** */
5599 struct cmd_set_bypass_event_result {
5600 cmdline_fixed_string_t set;
5601 cmdline_fixed_string_t bypass;
5602 cmdline_fixed_string_t event;
5603 cmdline_fixed_string_t event_value;
5604 cmdline_fixed_string_t mode;
5605 cmdline_fixed_string_t mode_value;
5610 cmd_set_bypass_event_parsed(void *parsed_result,
5611 __rte_unused struct cmdline *cl,
5612 __rte_unused void *data)
5614 int32_t rc = -EINVAL;
5615 struct cmd_set_bypass_event_result *res = parsed_result;
5616 portid_t port_id = res->port_id;
5618 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5619 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5620 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5622 if (!strcmp(res->event_value, "timeout"))
5623 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5624 else if (!strcmp(res->event_value, "os_on"))
5625 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5626 else if (!strcmp(res->event_value, "os_off"))
5627 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5628 else if (!strcmp(res->event_value, "power_on"))
5629 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5630 else if (!strcmp(res->event_value, "power_off"))
5631 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5633 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5635 if (!strcmp(res->mode_value, "bypass"))
5636 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5637 else if (!strcmp(res->mode_value, "isolate"))
5638 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5640 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5642 /* Set the watchdog timeout. */
5643 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5646 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5647 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5651 printf("Failed to set timeout value %u "
5652 "for port %d, errto code: %d.\n",
5653 bypass_timeout, port_id, rc);
5657 /* Set the bypass event to transition to bypass mode. */
5658 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5663 printf("\t Failed to set bypass event for port = %d.\n",
5667 cmdline_parse_token_string_t cmd_setbypass_event_set =
5668 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5670 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5671 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5673 cmdline_parse_token_string_t cmd_setbypass_event_event =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5676 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5677 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5678 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5679 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5680 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5682 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5683 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5684 mode_value, "normal#bypass#isolate");
5685 cmdline_parse_token_num_t cmd_setbypass_event_port =
5686 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5687 port_id, RTE_UINT16);
5689 cmdline_parse_inst_t cmd_set_bypass_event = {
5690 .f = cmd_set_bypass_event_parsed,
5691 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5692 "power_off mode normal|bypass|isolate <port_id>: "
5693 "Set the NIC bypass event mode for port_id",
5696 (void *)&cmd_setbypass_event_set,
5697 (void *)&cmd_setbypass_event_bypass,
5698 (void *)&cmd_setbypass_event_event,
5699 (void *)&cmd_setbypass_event_event_value,
5700 (void *)&cmd_setbypass_event_mode,
5701 (void *)&cmd_setbypass_event_mode_value,
5702 (void *)&cmd_setbypass_event_port,
5708 /* *** SET NIC BYPASS TIMEOUT *** */
5709 struct cmd_set_bypass_timeout_result {
5710 cmdline_fixed_string_t set;
5711 cmdline_fixed_string_t bypass;
5712 cmdline_fixed_string_t timeout;
5713 cmdline_fixed_string_t value;
5717 cmd_set_bypass_timeout_parsed(void *parsed_result,
5718 __rte_unused struct cmdline *cl,
5719 __rte_unused void *data)
5721 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5723 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5724 if (!strcmp(res->value, "1.5"))
5725 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5726 else if (!strcmp(res->value, "2"))
5727 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5728 else if (!strcmp(res->value, "3"))
5729 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5730 else if (!strcmp(res->value, "4"))
5731 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5732 else if (!strcmp(res->value, "8"))
5733 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5734 else if (!strcmp(res->value, "16"))
5735 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5736 else if (!strcmp(res->value, "32"))
5737 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5739 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5743 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5744 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5746 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5749 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5751 timeout, "timeout");
5752 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5753 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5754 value, "0#1.5#2#3#4#8#16#32");
5756 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5757 .f = cmd_set_bypass_timeout_parsed,
5758 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5759 "Set the NIC bypass watchdog timeout in seconds",
5762 (void *)&cmd_setbypass_timeout_set,
5763 (void *)&cmd_setbypass_timeout_bypass,
5764 (void *)&cmd_setbypass_timeout_timeout,
5765 (void *)&cmd_setbypass_timeout_value,
5770 /* *** SHOW NIC BYPASS MODE *** */
5771 struct cmd_show_bypass_config_result {
5772 cmdline_fixed_string_t show;
5773 cmdline_fixed_string_t bypass;
5774 cmdline_fixed_string_t config;
5779 cmd_show_bypass_config_parsed(void *parsed_result,
5780 __rte_unused struct cmdline *cl,
5781 __rte_unused void *data)
5783 struct cmd_show_bypass_config_result *res = parsed_result;
5784 portid_t port_id = res->port_id;
5786 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5787 uint32_t event_mode;
5788 uint32_t bypass_mode;
5789 uint32_t timeout = bypass_timeout;
5792 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5793 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5794 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5795 {"UNKNOWN", "normal", "bypass", "isolate"};
5796 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5804 /* Display the bypass mode.*/
5805 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5806 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5810 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5811 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5813 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5816 /* Display the bypass timeout.*/
5817 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5818 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5820 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5822 /* Display the bypass events and associated modes. */
5823 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5825 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5826 printf("\tFailed to get bypass mode for event = %s\n",
5829 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5830 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5832 printf("\tbypass event: %-16s = %s\n", events[i],
5838 printf("\tFailed to get bypass configuration for port = %d\n",
5842 cmdline_parse_token_string_t cmd_showbypass_config_show =
5843 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5845 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5846 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5848 cmdline_parse_token_string_t cmd_showbypass_config_config =
5849 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5851 cmdline_parse_token_num_t cmd_showbypass_config_port =
5852 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5853 port_id, RTE_UINT16);
5855 cmdline_parse_inst_t cmd_show_bypass_config = {
5856 .f = cmd_show_bypass_config_parsed,
5857 .help_str = "show bypass config <port_id>: "
5858 "Show the NIC bypass config for port_id",
5861 (void *)&cmd_showbypass_config_show,
5862 (void *)&cmd_showbypass_config_bypass,
5863 (void *)&cmd_showbypass_config_config,
5864 (void *)&cmd_showbypass_config_port,
5870 /* *** SET BONDING MODE *** */
5871 struct cmd_set_bonding_mode_result {
5872 cmdline_fixed_string_t set;
5873 cmdline_fixed_string_t bonding;
5874 cmdline_fixed_string_t mode;
5879 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5880 __rte_unused struct cmdline *cl,
5881 __rte_unused void *data)
5883 struct cmd_set_bonding_mode_result *res = parsed_result;
5884 portid_t port_id = res->port_id;
5886 /* Set the bonding mode for the relevant port. */
5887 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5888 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5891 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5892 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5894 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5895 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5896 bonding, "bonding");
5897 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5898 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5900 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5901 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5903 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5904 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5905 port_id, RTE_UINT16);
5907 cmdline_parse_inst_t cmd_set_bonding_mode = {
5908 .f = cmd_set_bonding_mode_parsed,
5909 .help_str = "set bonding mode <mode_value> <port_id>: "
5910 "Set the bonding mode for port_id",
5913 (void *) &cmd_setbonding_mode_set,
5914 (void *) &cmd_setbonding_mode_bonding,
5915 (void *) &cmd_setbonding_mode_mode,
5916 (void *) &cmd_setbonding_mode_value,
5917 (void *) &cmd_setbonding_mode_port,
5922 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5923 struct cmd_set_bonding_lacp_dedicated_queues_result {
5924 cmdline_fixed_string_t set;
5925 cmdline_fixed_string_t bonding;
5926 cmdline_fixed_string_t lacp;
5927 cmdline_fixed_string_t dedicated_queues;
5929 cmdline_fixed_string_t mode;
5932 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5933 __rte_unused struct cmdline *cl,
5934 __rte_unused void *data)
5936 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5937 portid_t port_id = res->port_id;
5938 struct rte_port *port;
5940 port = &ports[port_id];
5942 /** Check if the port is not started **/
5943 if (port->port_status != RTE_PORT_STOPPED) {
5944 printf("Please stop port %d first\n", port_id);
5948 if (!strcmp(res->mode, "enable")) {
5949 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5950 printf("Dedicate queues for LACP control packets"
5953 printf("Enabling dedicate queues for LACP control "
5954 "packets on port %d failed\n", port_id);
5955 } else if (!strcmp(res->mode, "disable")) {
5956 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5957 printf("Dedicated queues for LACP control packets "
5960 printf("Disabling dedicated queues for LACP control "
5961 "traffic on port %d failed\n", port_id);
5965 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5966 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5968 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5969 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5970 bonding, "bonding");
5971 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5972 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5974 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5975 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5976 dedicated_queues, "dedicated_queues");
5977 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5978 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5979 port_id, RTE_UINT16);
5980 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5981 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5982 mode, "enable#disable");
5984 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5985 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5986 .help_str = "set bonding lacp dedicated_queues <port_id> "
5988 "Enable/disable dedicated queues for LACP control traffic for port_id",
5991 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5992 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5993 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5994 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5995 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5996 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6001 /* *** SET BALANCE XMIT POLICY *** */
6002 struct cmd_set_bonding_balance_xmit_policy_result {
6003 cmdline_fixed_string_t set;
6004 cmdline_fixed_string_t bonding;
6005 cmdline_fixed_string_t balance_xmit_policy;
6007 cmdline_fixed_string_t policy;
6010 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6011 __rte_unused struct cmdline *cl,
6012 __rte_unused void *data)
6014 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6015 portid_t port_id = res->port_id;
6018 if (!strcmp(res->policy, "l2")) {
6019 policy = BALANCE_XMIT_POLICY_LAYER2;
6020 } else if (!strcmp(res->policy, "l23")) {
6021 policy = BALANCE_XMIT_POLICY_LAYER23;
6022 } else if (!strcmp(res->policy, "l34")) {
6023 policy = BALANCE_XMIT_POLICY_LAYER34;
6025 printf("\t Invalid xmit policy selection");
6029 /* Set the bonding mode for the relevant port. */
6030 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6031 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6036 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6037 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6039 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6040 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6041 bonding, "bonding");
6042 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6043 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6044 balance_xmit_policy, "balance_xmit_policy");
6045 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6046 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6047 port_id, RTE_UINT16);
6048 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6049 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6050 policy, "l2#l23#l34");
6052 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6053 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6054 .help_str = "set bonding balance_xmit_policy <port_id> "
6056 "Set the bonding balance_xmit_policy for port_id",
6059 (void *)&cmd_setbonding_balance_xmit_policy_set,
6060 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6061 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6062 (void *)&cmd_setbonding_balance_xmit_policy_port,
6063 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6068 /* *** SHOW NIC BONDING CONFIGURATION *** */
6069 struct cmd_show_bonding_config_result {
6070 cmdline_fixed_string_t show;
6071 cmdline_fixed_string_t bonding;
6072 cmdline_fixed_string_t config;
6076 static void cmd_show_bonding_config_parsed(void *parsed_result,
6077 __rte_unused struct cmdline *cl,
6078 __rte_unused void *data)
6080 struct cmd_show_bonding_config_result *res = parsed_result;
6081 int bonding_mode, agg_mode;
6082 portid_t slaves[RTE_MAX_ETHPORTS];
6083 int num_slaves, num_active_slaves;
6086 portid_t port_id = res->port_id;
6088 /* Display the bonding mode.*/
6089 bonding_mode = rte_eth_bond_mode_get(port_id);
6090 if (bonding_mode < 0) {
6091 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6094 printf("\tBonding mode: %d\n", bonding_mode);
6096 if (bonding_mode == BONDING_MODE_BALANCE) {
6097 int balance_xmit_policy;
6099 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6100 if (balance_xmit_policy < 0) {
6101 printf("\tFailed to get balance xmit policy for port = %d\n",
6105 printf("\tBalance Xmit Policy: ");
6107 switch (balance_xmit_policy) {
6108 case BALANCE_XMIT_POLICY_LAYER2:
6109 printf("BALANCE_XMIT_POLICY_LAYER2");
6111 case BALANCE_XMIT_POLICY_LAYER23:
6112 printf("BALANCE_XMIT_POLICY_LAYER23");
6114 case BALANCE_XMIT_POLICY_LAYER34:
6115 printf("BALANCE_XMIT_POLICY_LAYER34");
6122 if (bonding_mode == BONDING_MODE_8023AD) {
6123 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6124 printf("\tIEEE802.3AD Aggregator Mode: ");
6127 printf("bandwidth");
6139 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6141 if (num_slaves < 0) {
6142 printf("\tFailed to get slave list for port = %d\n", port_id);
6145 if (num_slaves > 0) {
6146 printf("\tSlaves (%d): [", num_slaves);
6147 for (i = 0; i < num_slaves - 1; i++)
6148 printf("%d ", slaves[i]);
6150 printf("%d]\n", slaves[num_slaves - 1]);
6152 printf("\tSlaves: []\n");
6156 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6159 if (num_active_slaves < 0) {
6160 printf("\tFailed to get active slave list for port = %d\n", port_id);
6163 if (num_active_slaves > 0) {
6164 printf("\tActive Slaves (%d): [", num_active_slaves);
6165 for (i = 0; i < num_active_slaves - 1; i++)
6166 printf("%d ", slaves[i]);
6168 printf("%d]\n", slaves[num_active_slaves - 1]);
6171 printf("\tActive Slaves: []\n");
6175 primary_id = rte_eth_bond_primary_get(port_id);
6176 if (primary_id < 0) {
6177 printf("\tFailed to get primary slave for port = %d\n", port_id);
6180 printf("\tPrimary: [%d]\n", primary_id);
6184 cmdline_parse_token_string_t cmd_showbonding_config_show =
6185 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6187 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6188 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6189 bonding, "bonding");
6190 cmdline_parse_token_string_t cmd_showbonding_config_config =
6191 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6193 cmdline_parse_token_num_t cmd_showbonding_config_port =
6194 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6195 port_id, RTE_UINT16);
6197 cmdline_parse_inst_t cmd_show_bonding_config = {
6198 .f = cmd_show_bonding_config_parsed,
6199 .help_str = "show bonding config <port_id>: "
6200 "Show the bonding config for port_id",
6203 (void *)&cmd_showbonding_config_show,
6204 (void *)&cmd_showbonding_config_bonding,
6205 (void *)&cmd_showbonding_config_config,
6206 (void *)&cmd_showbonding_config_port,
6211 /* *** SET BONDING PRIMARY *** */
6212 struct cmd_set_bonding_primary_result {
6213 cmdline_fixed_string_t set;
6214 cmdline_fixed_string_t bonding;
6215 cmdline_fixed_string_t primary;
6220 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6221 __rte_unused struct cmdline *cl,
6222 __rte_unused void *data)
6224 struct cmd_set_bonding_primary_result *res = parsed_result;
6225 portid_t master_port_id = res->port_id;
6226 portid_t slave_port_id = res->slave_id;
6228 /* Set the primary slave for a bonded device. */
6229 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6230 printf("\t Failed to set primary slave for port = %d.\n",
6237 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6238 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6240 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6241 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6242 bonding, "bonding");
6243 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6244 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6245 primary, "primary");
6246 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6247 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6248 slave_id, RTE_UINT16);
6249 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6250 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6251 port_id, RTE_UINT16);
6253 cmdline_parse_inst_t cmd_set_bonding_primary = {
6254 .f = cmd_set_bonding_primary_parsed,
6255 .help_str = "set bonding primary <slave_id> <port_id>: "
6256 "Set the primary slave for port_id",
6259 (void *)&cmd_setbonding_primary_set,
6260 (void *)&cmd_setbonding_primary_bonding,
6261 (void *)&cmd_setbonding_primary_primary,
6262 (void *)&cmd_setbonding_primary_slave,
6263 (void *)&cmd_setbonding_primary_port,
6268 /* *** ADD SLAVE *** */
6269 struct cmd_add_bonding_slave_result {
6270 cmdline_fixed_string_t add;
6271 cmdline_fixed_string_t bonding;
6272 cmdline_fixed_string_t slave;
6277 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6278 __rte_unused struct cmdline *cl,
6279 __rte_unused void *data)
6281 struct cmd_add_bonding_slave_result *res = parsed_result;
6282 portid_t master_port_id = res->port_id;
6283 portid_t slave_port_id = res->slave_id;
6285 /* add the slave for a bonded device. */
6286 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6287 printf("\t Failed to add slave %d to master port = %d.\n",
6288 slave_port_id, master_port_id);
6292 set_port_slave_flag(slave_port_id);
6295 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6296 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6298 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6299 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6300 bonding, "bonding");
6301 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6302 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6304 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6305 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6306 slave_id, RTE_UINT16);
6307 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6308 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6309 port_id, RTE_UINT16);
6311 cmdline_parse_inst_t cmd_add_bonding_slave = {
6312 .f = cmd_add_bonding_slave_parsed,
6313 .help_str = "add bonding slave <slave_id> <port_id>: "
6314 "Add a slave device to a bonded device",
6317 (void *)&cmd_addbonding_slave_add,
6318 (void *)&cmd_addbonding_slave_bonding,
6319 (void *)&cmd_addbonding_slave_slave,
6320 (void *)&cmd_addbonding_slave_slaveid,
6321 (void *)&cmd_addbonding_slave_port,
6326 /* *** REMOVE SLAVE *** */
6327 struct cmd_remove_bonding_slave_result {
6328 cmdline_fixed_string_t remove;
6329 cmdline_fixed_string_t bonding;
6330 cmdline_fixed_string_t slave;
6335 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6336 __rte_unused struct cmdline *cl,
6337 __rte_unused void *data)
6339 struct cmd_remove_bonding_slave_result *res = parsed_result;
6340 portid_t master_port_id = res->port_id;
6341 portid_t slave_port_id = res->slave_id;
6343 /* remove the slave from a bonded device. */
6344 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6345 printf("\t Failed to remove slave %d from master port = %d.\n",
6346 slave_port_id, master_port_id);
6350 clear_port_slave_flag(slave_port_id);
6353 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6354 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6356 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6357 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6358 bonding, "bonding");
6359 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6360 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6362 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6363 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6364 slave_id, RTE_UINT16);
6365 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6366 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6367 port_id, RTE_UINT16);
6369 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6370 .f = cmd_remove_bonding_slave_parsed,
6371 .help_str = "remove bonding slave <slave_id> <port_id>: "
6372 "Remove a slave device from a bonded device",
6375 (void *)&cmd_removebonding_slave_remove,
6376 (void *)&cmd_removebonding_slave_bonding,
6377 (void *)&cmd_removebonding_slave_slave,
6378 (void *)&cmd_removebonding_slave_slaveid,
6379 (void *)&cmd_removebonding_slave_port,
6384 /* *** CREATE BONDED DEVICE *** */
6385 struct cmd_create_bonded_device_result {
6386 cmdline_fixed_string_t create;
6387 cmdline_fixed_string_t bonded;
6388 cmdline_fixed_string_t device;
6393 static int bond_dev_num = 0;
6395 static void cmd_create_bonded_device_parsed(void *parsed_result,
6396 __rte_unused struct cmdline *cl,
6397 __rte_unused void *data)
6399 struct cmd_create_bonded_device_result *res = parsed_result;
6400 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6404 if (test_done == 0) {
6405 printf("Please stop forwarding first\n");
6409 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6412 /* Create a new bonded device. */
6413 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6415 printf("\t Failed to create bonded device.\n");
6418 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6421 /* Update number of ports */
6422 nb_ports = rte_eth_dev_count_avail();
6423 reconfig(port_id, res->socket);
6424 ret = rte_eth_promiscuous_enable(port_id);
6426 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6427 port_id, rte_strerror(-ret));
6429 ports[port_id].need_setup = 0;
6430 ports[port_id].port_status = RTE_PORT_STOPPED;
6435 cmdline_parse_token_string_t cmd_createbonded_device_create =
6436 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6438 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6439 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6441 cmdline_parse_token_string_t cmd_createbonded_device_device =
6442 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6444 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6445 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6447 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6448 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6451 cmdline_parse_inst_t cmd_create_bonded_device = {
6452 .f = cmd_create_bonded_device_parsed,
6453 .help_str = "create bonded device <mode> <socket>: "
6454 "Create a new bonded device with specific bonding mode and socket",
6457 (void *)&cmd_createbonded_device_create,
6458 (void *)&cmd_createbonded_device_bonded,
6459 (void *)&cmd_createbonded_device_device,
6460 (void *)&cmd_createbonded_device_mode,
6461 (void *)&cmd_createbonded_device_socket,
6466 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6467 struct cmd_set_bond_mac_addr_result {
6468 cmdline_fixed_string_t set;
6469 cmdline_fixed_string_t bonding;
6470 cmdline_fixed_string_t mac_addr;
6472 struct rte_ether_addr address;
6475 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6476 __rte_unused struct cmdline *cl,
6477 __rte_unused void *data)
6479 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6482 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6485 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6487 /* check the return value and print it if is < 0 */
6489 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6492 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6493 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6494 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6495 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6497 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6498 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6500 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6501 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6502 port_num, RTE_UINT16);
6503 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6504 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6506 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6507 .f = cmd_set_bond_mac_addr_parsed,
6509 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6511 (void *)&cmd_set_bond_mac_addr_set,
6512 (void *)&cmd_set_bond_mac_addr_bonding,
6513 (void *)&cmd_set_bond_mac_addr_mac,
6514 (void *)&cmd_set_bond_mac_addr_portnum,
6515 (void *)&cmd_set_bond_mac_addr_addr,
6521 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6522 struct cmd_set_bond_mon_period_result {
6523 cmdline_fixed_string_t set;
6524 cmdline_fixed_string_t bonding;
6525 cmdline_fixed_string_t mon_period;
6530 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6531 __rte_unused struct cmdline *cl,
6532 __rte_unused void *data)
6534 struct cmd_set_bond_mon_period_result *res = parsed_result;
6537 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6539 /* check the return value and print it if is < 0 */
6541 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6544 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6545 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6547 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6548 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6549 bonding, "bonding");
6550 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6551 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6552 mon_period, "mon_period");
6553 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6554 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6555 port_num, RTE_UINT16);
6556 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6557 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6558 period_ms, RTE_UINT32);
6560 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6561 .f = cmd_set_bond_mon_period_parsed,
6563 .help_str = "set bonding mon_period <port_id> <period_ms>",
6565 (void *)&cmd_set_bond_mon_period_set,
6566 (void *)&cmd_set_bond_mon_period_bonding,
6567 (void *)&cmd_set_bond_mon_period_mon_period,
6568 (void *)&cmd_set_bond_mon_period_portnum,
6569 (void *)&cmd_set_bond_mon_period_period_ms,
6576 struct cmd_set_bonding_agg_mode_policy_result {
6577 cmdline_fixed_string_t set;
6578 cmdline_fixed_string_t bonding;
6579 cmdline_fixed_string_t agg_mode;
6581 cmdline_fixed_string_t policy;
6586 cmd_set_bonding_agg_mode(void *parsed_result,
6587 __rte_unused struct cmdline *cl,
6588 __rte_unused void *data)
6590 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6591 uint8_t policy = AGG_BANDWIDTH;
6593 if (!strcmp(res->policy, "bandwidth"))
6594 policy = AGG_BANDWIDTH;
6595 else if (!strcmp(res->policy, "stable"))
6596 policy = AGG_STABLE;
6597 else if (!strcmp(res->policy, "count"))
6600 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6604 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6605 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6607 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6608 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6609 bonding, "bonding");
6611 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6612 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6613 agg_mode, "agg_mode");
6615 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6616 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6617 port_num, RTE_UINT16);
6619 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6620 TOKEN_STRING_INITIALIZER(
6621 struct cmd_set_bonding_balance_xmit_policy_result,
6622 policy, "stable#bandwidth#count");
6624 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6625 .f = cmd_set_bonding_agg_mode,
6627 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6629 (void *)&cmd_set_bonding_agg_mode_set,
6630 (void *)&cmd_set_bonding_agg_mode_bonding,
6631 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6632 (void *)&cmd_set_bonding_agg_mode_portnum,
6633 (void *)&cmd_set_bonding_agg_mode_policy_string,
6639 #endif /* RTE_NET_BOND */
6641 /* *** SET FORWARDING MODE *** */
6642 struct cmd_set_fwd_mode_result {
6643 cmdline_fixed_string_t set;
6644 cmdline_fixed_string_t fwd;
6645 cmdline_fixed_string_t mode;
6648 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6649 __rte_unused struct cmdline *cl,
6650 __rte_unused void *data)
6652 struct cmd_set_fwd_mode_result *res = parsed_result;
6655 set_pkt_forwarding_mode(res->mode);
6658 cmdline_parse_token_string_t cmd_setfwd_set =
6659 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6660 cmdline_parse_token_string_t cmd_setfwd_fwd =
6661 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6662 cmdline_parse_token_string_t cmd_setfwd_mode =
6663 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6664 "" /* defined at init */);
6666 cmdline_parse_inst_t cmd_set_fwd_mode = {
6667 .f = cmd_set_fwd_mode_parsed,
6669 .help_str = NULL, /* defined at init */
6671 (void *)&cmd_setfwd_set,
6672 (void *)&cmd_setfwd_fwd,
6673 (void *)&cmd_setfwd_mode,
6678 static void cmd_set_fwd_mode_init(void)
6681 static char token[128];
6682 static char help[256];
6683 cmdline_parse_token_string_t *token_struct;
6685 modes = list_pkt_forwarding_modes();
6686 snprintf(help, sizeof(help), "set fwd %s: "
6687 "Set packet forwarding mode", modes);
6688 cmd_set_fwd_mode.help_str = help;
6690 /* string token separator is # */
6691 for (c = token; *modes != '\0'; modes++)
6696 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6697 token_struct->string_data.str = token;
6700 /* *** SET RETRY FORWARDING MODE *** */
6701 struct cmd_set_fwd_retry_mode_result {
6702 cmdline_fixed_string_t set;
6703 cmdline_fixed_string_t fwd;
6704 cmdline_fixed_string_t mode;
6705 cmdline_fixed_string_t retry;
6708 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6709 __rte_unused struct cmdline *cl,
6710 __rte_unused void *data)
6712 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6715 set_pkt_forwarding_mode(res->mode);
6718 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6719 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6721 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6722 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6724 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6725 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6727 "" /* defined at init */);
6728 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6732 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6733 .f = cmd_set_fwd_retry_mode_parsed,
6735 .help_str = NULL, /* defined at init */
6737 (void *)&cmd_setfwd_retry_set,
6738 (void *)&cmd_setfwd_retry_fwd,
6739 (void *)&cmd_setfwd_retry_mode,
6740 (void *)&cmd_setfwd_retry_retry,
6745 static void cmd_set_fwd_retry_mode_init(void)
6748 static char token[128];
6749 static char help[256];
6750 cmdline_parse_token_string_t *token_struct;
6752 modes = list_pkt_forwarding_retry_modes();
6753 snprintf(help, sizeof(help), "set fwd %s retry: "
6754 "Set packet forwarding mode with retry", modes);
6755 cmd_set_fwd_retry_mode.help_str = help;
6757 /* string token separator is # */
6758 for (c = token; *modes != '\0'; modes++)
6763 token_struct = (cmdline_parse_token_string_t *)
6764 cmd_set_fwd_retry_mode.tokens[2];
6765 token_struct->string_data.str = token;
6768 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6769 struct cmd_set_burst_tx_retry_result {
6770 cmdline_fixed_string_t set;
6771 cmdline_fixed_string_t burst;
6772 cmdline_fixed_string_t tx;
6773 cmdline_fixed_string_t delay;
6775 cmdline_fixed_string_t retry;
6779 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6780 __rte_unused struct cmdline *cl,
6781 __rte_unused void *data)
6783 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6785 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6786 && !strcmp(res->tx, "tx")) {
6787 if (!strcmp(res->delay, "delay"))
6788 burst_tx_delay_time = res->time;
6789 if (!strcmp(res->retry, "retry"))
6790 burst_tx_retry_num = res->retry_num;
6795 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6796 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6797 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6798 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6800 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6801 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6802 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6804 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6805 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6807 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6808 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6809 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6810 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6813 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6814 .f = cmd_set_burst_tx_retry_parsed,
6815 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6817 (void *)&cmd_set_burst_tx_retry_set,
6818 (void *)&cmd_set_burst_tx_retry_burst,
6819 (void *)&cmd_set_burst_tx_retry_tx,
6820 (void *)&cmd_set_burst_tx_retry_delay,
6821 (void *)&cmd_set_burst_tx_retry_time,
6822 (void *)&cmd_set_burst_tx_retry_retry,
6823 (void *)&cmd_set_burst_tx_retry_retry_num,
6828 /* *** SET PROMISC MODE *** */
6829 struct cmd_set_promisc_mode_result {
6830 cmdline_fixed_string_t set;
6831 cmdline_fixed_string_t promisc;
6832 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6833 uint16_t port_num; /* valid if "allports" argument == 0 */
6834 cmdline_fixed_string_t mode;
6837 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6838 __rte_unused struct cmdline *cl,
6841 struct cmd_set_promisc_mode_result *res = parsed_result;
6845 if (!strcmp(res->mode, "on"))
6852 RTE_ETH_FOREACH_DEV(i)
6853 eth_set_promisc_mode(i, enable);
6855 eth_set_promisc_mode(res->port_num, enable);
6859 cmdline_parse_token_string_t cmd_setpromisc_set =
6860 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6861 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6862 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6864 cmdline_parse_token_string_t cmd_setpromisc_portall =
6865 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6867 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6868 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6870 cmdline_parse_token_string_t cmd_setpromisc_mode =
6871 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6874 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6875 .f = cmd_set_promisc_mode_parsed,
6877 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6879 (void *)&cmd_setpromisc_set,
6880 (void *)&cmd_setpromisc_promisc,
6881 (void *)&cmd_setpromisc_portall,
6882 (void *)&cmd_setpromisc_mode,
6887 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6888 .f = cmd_set_promisc_mode_parsed,
6890 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6892 (void *)&cmd_setpromisc_set,
6893 (void *)&cmd_setpromisc_promisc,
6894 (void *)&cmd_setpromisc_portnum,
6895 (void *)&cmd_setpromisc_mode,
6900 /* *** SET ALLMULTI MODE *** */
6901 struct cmd_set_allmulti_mode_result {
6902 cmdline_fixed_string_t set;
6903 cmdline_fixed_string_t allmulti;
6904 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6905 uint16_t port_num; /* valid if "allports" argument == 0 */
6906 cmdline_fixed_string_t mode;
6909 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6910 __rte_unused struct cmdline *cl,
6913 struct cmd_set_allmulti_mode_result *res = parsed_result;
6917 if (!strcmp(res->mode, "on"))
6924 RTE_ETH_FOREACH_DEV(i) {
6925 eth_set_allmulticast_mode(i, enable);
6929 eth_set_allmulticast_mode(res->port_num, enable);
6933 cmdline_parse_token_string_t cmd_setallmulti_set =
6934 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6935 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6936 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6938 cmdline_parse_token_string_t cmd_setallmulti_portall =
6939 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6941 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6942 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6944 cmdline_parse_token_string_t cmd_setallmulti_mode =
6945 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6948 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6949 .f = cmd_set_allmulti_mode_parsed,
6951 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6953 (void *)&cmd_setallmulti_set,
6954 (void *)&cmd_setallmulti_allmulti,
6955 (void *)&cmd_setallmulti_portall,
6956 (void *)&cmd_setallmulti_mode,
6961 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6962 .f = cmd_set_allmulti_mode_parsed,
6964 .help_str = "set allmulti <port_id> on|off: "
6965 "Set allmulti mode on port_id",
6967 (void *)&cmd_setallmulti_set,
6968 (void *)&cmd_setallmulti_allmulti,
6969 (void *)&cmd_setallmulti_portnum,
6970 (void *)&cmd_setallmulti_mode,
6975 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6976 struct cmd_link_flow_ctrl_show {
6977 cmdline_fixed_string_t show;
6978 cmdline_fixed_string_t port;
6980 cmdline_fixed_string_t flow_ctrl;
6983 cmdline_parse_token_string_t cmd_lfc_show_show =
6984 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6986 cmdline_parse_token_string_t cmd_lfc_show_port =
6987 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6989 cmdline_parse_token_num_t cmd_lfc_show_portid =
6990 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6991 port_id, RTE_UINT16);
6992 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6993 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6994 flow_ctrl, "flow_ctrl");
6997 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6998 __rte_unused struct cmdline *cl,
6999 __rte_unused void *data)
7001 struct cmd_link_flow_ctrl_show *res = parsed_result;
7002 static const char *info_border = "*********************";
7003 struct rte_eth_fc_conf fc_conf;
7004 bool rx_fc_en = false;
7005 bool tx_fc_en = false;
7008 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7010 printf("Failed to get current flow ctrl information: err = %d\n",
7015 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7017 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7020 printf("\n%s Flow control infos for port %-2d %s\n",
7021 info_border, res->port_id, info_border);
7022 printf("FC mode:\n");
7023 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7024 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7025 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7026 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7027 printf("High waterline: 0x%x\n", fc_conf.high_water);
7028 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7029 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7030 printf("Forward MAC control frames: %s\n",
7031 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7032 printf("\n%s************** End ***********%s\n",
7033 info_border, info_border);
7036 cmdline_parse_inst_t cmd_link_flow_control_show = {
7037 .f = cmd_link_flow_ctrl_show_parsed,
7039 .help_str = "show port <port_id> flow_ctrl",
7041 (void *)&cmd_lfc_show_show,
7042 (void *)&cmd_lfc_show_port,
7043 (void *)&cmd_lfc_show_portid,
7044 (void *)&cmd_lfc_show_flow_ctrl,
7049 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7050 struct cmd_link_flow_ctrl_set_result {
7051 cmdline_fixed_string_t set;
7052 cmdline_fixed_string_t flow_ctrl;
7053 cmdline_fixed_string_t rx;
7054 cmdline_fixed_string_t rx_lfc_mode;
7055 cmdline_fixed_string_t tx;
7056 cmdline_fixed_string_t tx_lfc_mode;
7057 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7058 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7059 cmdline_fixed_string_t autoneg_str;
7060 cmdline_fixed_string_t autoneg;
7061 cmdline_fixed_string_t hw_str;
7062 uint32_t high_water;
7063 cmdline_fixed_string_t lw_str;
7065 cmdline_fixed_string_t pt_str;
7066 uint16_t pause_time;
7067 cmdline_fixed_string_t xon_str;
7072 cmdline_parse_token_string_t cmd_lfc_set_set =
7073 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7075 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7076 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7077 flow_ctrl, "flow_ctrl");
7078 cmdline_parse_token_string_t cmd_lfc_set_rx =
7079 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7081 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7082 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7083 rx_lfc_mode, "on#off");
7084 cmdline_parse_token_string_t cmd_lfc_set_tx =
7085 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7087 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7088 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7089 tx_lfc_mode, "on#off");
7090 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7091 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7092 hw_str, "high_water");
7093 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7094 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7095 high_water, RTE_UINT32);
7096 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7097 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7098 lw_str, "low_water");
7099 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7100 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7101 low_water, RTE_UINT32);
7102 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7103 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7104 pt_str, "pause_time");
7105 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7106 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7107 pause_time, RTE_UINT16);
7108 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7109 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7110 xon_str, "send_xon");
7111 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7112 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7113 send_xon, RTE_UINT16);
7114 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7115 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7116 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7117 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7118 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7119 mac_ctrl_frame_fwd_mode, "on#off");
7120 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7121 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7122 autoneg_str, "autoneg");
7123 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7124 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7126 cmdline_parse_token_num_t cmd_lfc_set_portid =
7127 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7128 port_id, RTE_UINT16);
7130 /* forward declaration */
7132 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7135 cmdline_parse_inst_t cmd_link_flow_control_set = {
7136 .f = cmd_link_flow_ctrl_set_parsed,
7138 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7139 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7140 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7142 (void *)&cmd_lfc_set_set,
7143 (void *)&cmd_lfc_set_flow_ctrl,
7144 (void *)&cmd_lfc_set_rx,
7145 (void *)&cmd_lfc_set_rx_mode,
7146 (void *)&cmd_lfc_set_tx,
7147 (void *)&cmd_lfc_set_tx_mode,
7148 (void *)&cmd_lfc_set_high_water,
7149 (void *)&cmd_lfc_set_low_water,
7150 (void *)&cmd_lfc_set_pause_time,
7151 (void *)&cmd_lfc_set_send_xon,
7152 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7153 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7154 (void *)&cmd_lfc_set_autoneg_str,
7155 (void *)&cmd_lfc_set_autoneg,
7156 (void *)&cmd_lfc_set_portid,
7161 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7162 .f = cmd_link_flow_ctrl_set_parsed,
7163 .data = (void *)&cmd_link_flow_control_set_rx,
7164 .help_str = "set flow_ctrl rx on|off <port_id>: "
7165 "Change rx flow control parameter",
7167 (void *)&cmd_lfc_set_set,
7168 (void *)&cmd_lfc_set_flow_ctrl,
7169 (void *)&cmd_lfc_set_rx,
7170 (void *)&cmd_lfc_set_rx_mode,
7171 (void *)&cmd_lfc_set_portid,
7176 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7177 .f = cmd_link_flow_ctrl_set_parsed,
7178 .data = (void *)&cmd_link_flow_control_set_tx,
7179 .help_str = "set flow_ctrl tx on|off <port_id>: "
7180 "Change tx flow control parameter",
7182 (void *)&cmd_lfc_set_set,
7183 (void *)&cmd_lfc_set_flow_ctrl,
7184 (void *)&cmd_lfc_set_tx,
7185 (void *)&cmd_lfc_set_tx_mode,
7186 (void *)&cmd_lfc_set_portid,
7191 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7192 .f = cmd_link_flow_ctrl_set_parsed,
7193 .data = (void *)&cmd_link_flow_control_set_hw,
7194 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7195 "Change high water flow control parameter",
7197 (void *)&cmd_lfc_set_set,
7198 (void *)&cmd_lfc_set_flow_ctrl,
7199 (void *)&cmd_lfc_set_high_water_str,
7200 (void *)&cmd_lfc_set_high_water,
7201 (void *)&cmd_lfc_set_portid,
7206 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7207 .f = cmd_link_flow_ctrl_set_parsed,
7208 .data = (void *)&cmd_link_flow_control_set_lw,
7209 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7210 "Change low water flow control parameter",
7212 (void *)&cmd_lfc_set_set,
7213 (void *)&cmd_lfc_set_flow_ctrl,
7214 (void *)&cmd_lfc_set_low_water_str,
7215 (void *)&cmd_lfc_set_low_water,
7216 (void *)&cmd_lfc_set_portid,
7221 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7222 .f = cmd_link_flow_ctrl_set_parsed,
7223 .data = (void *)&cmd_link_flow_control_set_pt,
7224 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7225 "Change pause time flow control parameter",
7227 (void *)&cmd_lfc_set_set,
7228 (void *)&cmd_lfc_set_flow_ctrl,
7229 (void *)&cmd_lfc_set_pause_time_str,
7230 (void *)&cmd_lfc_set_pause_time,
7231 (void *)&cmd_lfc_set_portid,
7236 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7237 .f = cmd_link_flow_ctrl_set_parsed,
7238 .data = (void *)&cmd_link_flow_control_set_xon,
7239 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7240 "Change send_xon flow control parameter",
7242 (void *)&cmd_lfc_set_set,
7243 (void *)&cmd_lfc_set_flow_ctrl,
7244 (void *)&cmd_lfc_set_send_xon_str,
7245 (void *)&cmd_lfc_set_send_xon,
7246 (void *)&cmd_lfc_set_portid,
7251 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7252 .f = cmd_link_flow_ctrl_set_parsed,
7253 .data = (void *)&cmd_link_flow_control_set_macfwd,
7254 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7255 "Change mac ctrl fwd flow control parameter",
7257 (void *)&cmd_lfc_set_set,
7258 (void *)&cmd_lfc_set_flow_ctrl,
7259 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7260 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7261 (void *)&cmd_lfc_set_portid,
7266 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7267 .f = cmd_link_flow_ctrl_set_parsed,
7268 .data = (void *)&cmd_link_flow_control_set_autoneg,
7269 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7270 "Change autoneg flow control parameter",
7272 (void *)&cmd_lfc_set_set,
7273 (void *)&cmd_lfc_set_flow_ctrl,
7274 (void *)&cmd_lfc_set_autoneg_str,
7275 (void *)&cmd_lfc_set_autoneg,
7276 (void *)&cmd_lfc_set_portid,
7282 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7283 __rte_unused struct cmdline *cl,
7286 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7287 cmdline_parse_inst_t *cmd = data;
7288 struct rte_eth_fc_conf fc_conf;
7294 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7295 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7296 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7297 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7299 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7300 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7303 /* Partial command line, retrieve current configuration */
7305 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7307 printf("cannot get current flow ctrl parameters, return"
7308 "code = %d\n", ret);
7312 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7313 (fc_conf.mode == RTE_FC_FULL))
7315 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7316 (fc_conf.mode == RTE_FC_FULL))
7320 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7321 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7323 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7324 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7326 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7328 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7329 fc_conf.high_water = res->high_water;
7331 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7332 fc_conf.low_water = res->low_water;
7334 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7335 fc_conf.pause_time = res->pause_time;
7337 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7338 fc_conf.send_xon = res->send_xon;
7340 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7341 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7342 fc_conf.mac_ctrl_frame_fwd = 1;
7344 fc_conf.mac_ctrl_frame_fwd = 0;
7347 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7348 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7350 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7352 printf("bad flow contrl parameter, return code = %d \n", ret);
7355 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7356 struct cmd_priority_flow_ctrl_set_result {
7357 cmdline_fixed_string_t set;
7358 cmdline_fixed_string_t pfc_ctrl;
7359 cmdline_fixed_string_t rx;
7360 cmdline_fixed_string_t rx_pfc_mode;
7361 cmdline_fixed_string_t tx;
7362 cmdline_fixed_string_t tx_pfc_mode;
7363 uint32_t high_water;
7365 uint16_t pause_time;
7371 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7372 __rte_unused struct cmdline *cl,
7373 __rte_unused void *data)
7375 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7376 struct rte_eth_pfc_conf pfc_conf;
7377 int rx_fc_enable, tx_fc_enable;
7381 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7382 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7383 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7384 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7386 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7387 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7390 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7391 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7392 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7393 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7394 pfc_conf.fc.high_water = res->high_water;
7395 pfc_conf.fc.low_water = res->low_water;
7396 pfc_conf.fc.pause_time = res->pause_time;
7397 pfc_conf.priority = res->priority;
7399 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7401 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7404 cmdline_parse_token_string_t cmd_pfc_set_set =
7405 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7407 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7408 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7409 pfc_ctrl, "pfc_ctrl");
7410 cmdline_parse_token_string_t cmd_pfc_set_rx =
7411 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7413 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7414 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7415 rx_pfc_mode, "on#off");
7416 cmdline_parse_token_string_t cmd_pfc_set_tx =
7417 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7419 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7420 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7421 tx_pfc_mode, "on#off");
7422 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7423 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7424 high_water, RTE_UINT32);
7425 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7426 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7427 low_water, RTE_UINT32);
7428 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7429 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7430 pause_time, RTE_UINT16);
7431 cmdline_parse_token_num_t cmd_pfc_set_priority =
7432 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7433 priority, RTE_UINT8);
7434 cmdline_parse_token_num_t cmd_pfc_set_portid =
7435 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7436 port_id, RTE_UINT16);
7438 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7439 .f = cmd_priority_flow_ctrl_set_parsed,
7441 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7442 "<pause_time> <priority> <port_id>: "
7443 "Configure the Ethernet priority flow control",
7445 (void *)&cmd_pfc_set_set,
7446 (void *)&cmd_pfc_set_flow_ctrl,
7447 (void *)&cmd_pfc_set_rx,
7448 (void *)&cmd_pfc_set_rx_mode,
7449 (void *)&cmd_pfc_set_tx,
7450 (void *)&cmd_pfc_set_tx_mode,
7451 (void *)&cmd_pfc_set_high_water,
7452 (void *)&cmd_pfc_set_low_water,
7453 (void *)&cmd_pfc_set_pause_time,
7454 (void *)&cmd_pfc_set_priority,
7455 (void *)&cmd_pfc_set_portid,
7460 /* *** RESET CONFIGURATION *** */
7461 struct cmd_reset_result {
7462 cmdline_fixed_string_t reset;
7463 cmdline_fixed_string_t def;
7466 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7468 __rte_unused void *data)
7470 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7471 set_def_fwd_config();
7474 cmdline_parse_token_string_t cmd_reset_set =
7475 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7476 cmdline_parse_token_string_t cmd_reset_def =
7477 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7480 cmdline_parse_inst_t cmd_reset = {
7481 .f = cmd_reset_parsed,
7483 .help_str = "set default: Reset default forwarding configuration",
7485 (void *)&cmd_reset_set,
7486 (void *)&cmd_reset_def,
7491 /* *** START FORWARDING *** */
7492 struct cmd_start_result {
7493 cmdline_fixed_string_t start;
7496 cmdline_parse_token_string_t cmd_start_start =
7497 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7499 static void cmd_start_parsed(__rte_unused void *parsed_result,
7500 __rte_unused struct cmdline *cl,
7501 __rte_unused void *data)
7503 start_packet_forwarding(0);
7506 cmdline_parse_inst_t cmd_start = {
7507 .f = cmd_start_parsed,
7509 .help_str = "start: Start packet forwarding",
7511 (void *)&cmd_start_start,
7516 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7517 struct cmd_start_tx_first_result {
7518 cmdline_fixed_string_t start;
7519 cmdline_fixed_string_t tx_first;
7523 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7524 __rte_unused struct cmdline *cl,
7525 __rte_unused void *data)
7527 start_packet_forwarding(1);
7530 cmdline_parse_token_string_t cmd_start_tx_first_start =
7531 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7533 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7534 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7535 tx_first, "tx_first");
7537 cmdline_parse_inst_t cmd_start_tx_first = {
7538 .f = cmd_start_tx_first_parsed,
7540 .help_str = "start tx_first: Start packet forwarding, "
7541 "after sending 1 burst of packets",
7543 (void *)&cmd_start_tx_first_start,
7544 (void *)&cmd_start_tx_first_tx_first,
7549 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7550 struct cmd_start_tx_first_n_result {
7551 cmdline_fixed_string_t start;
7552 cmdline_fixed_string_t tx_first;
7557 cmd_start_tx_first_n_parsed(void *parsed_result,
7558 __rte_unused struct cmdline *cl,
7559 __rte_unused void *data)
7561 struct cmd_start_tx_first_n_result *res = parsed_result;
7563 start_packet_forwarding(res->tx_num);
7566 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7567 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7569 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7570 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7571 tx_first, "tx_first");
7572 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7573 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7574 tx_num, RTE_UINT32);
7576 cmdline_parse_inst_t cmd_start_tx_first_n = {
7577 .f = cmd_start_tx_first_n_parsed,
7579 .help_str = "start tx_first <num>: "
7580 "packet forwarding, after sending <num> bursts of packets",
7582 (void *)&cmd_start_tx_first_n_start,
7583 (void *)&cmd_start_tx_first_n_tx_first,
7584 (void *)&cmd_start_tx_first_n_tx_num,
7589 /* *** SET LINK UP *** */
7590 struct cmd_set_link_up_result {
7591 cmdline_fixed_string_t set;
7592 cmdline_fixed_string_t link_up;
7593 cmdline_fixed_string_t port;
7597 cmdline_parse_token_string_t cmd_set_link_up_set =
7598 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7599 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7600 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7602 cmdline_parse_token_string_t cmd_set_link_up_port =
7603 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7604 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7605 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7608 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7609 __rte_unused struct cmdline *cl,
7610 __rte_unused void *data)
7612 struct cmd_set_link_up_result *res = parsed_result;
7613 dev_set_link_up(res->port_id);
7616 cmdline_parse_inst_t cmd_set_link_up = {
7617 .f = cmd_set_link_up_parsed,
7619 .help_str = "set link-up port <port id>",
7621 (void *)&cmd_set_link_up_set,
7622 (void *)&cmd_set_link_up_link_up,
7623 (void *)&cmd_set_link_up_port,
7624 (void *)&cmd_set_link_up_port_id,
7629 /* *** SET LINK DOWN *** */
7630 struct cmd_set_link_down_result {
7631 cmdline_fixed_string_t set;
7632 cmdline_fixed_string_t link_down;
7633 cmdline_fixed_string_t port;
7637 cmdline_parse_token_string_t cmd_set_link_down_set =
7638 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7639 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7640 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7642 cmdline_parse_token_string_t cmd_set_link_down_port =
7643 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7644 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7645 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7648 static void cmd_set_link_down_parsed(
7649 __rte_unused void *parsed_result,
7650 __rte_unused struct cmdline *cl,
7651 __rte_unused void *data)
7653 struct cmd_set_link_down_result *res = parsed_result;
7654 dev_set_link_down(res->port_id);
7657 cmdline_parse_inst_t cmd_set_link_down = {
7658 .f = cmd_set_link_down_parsed,
7660 .help_str = "set link-down port <port id>",
7662 (void *)&cmd_set_link_down_set,
7663 (void *)&cmd_set_link_down_link_down,
7664 (void *)&cmd_set_link_down_port,
7665 (void *)&cmd_set_link_down_port_id,
7670 /* *** SHOW CFG *** */
7671 struct cmd_showcfg_result {
7672 cmdline_fixed_string_t show;
7673 cmdline_fixed_string_t cfg;
7674 cmdline_fixed_string_t what;
7677 static void cmd_showcfg_parsed(void *parsed_result,
7678 __rte_unused struct cmdline *cl,
7679 __rte_unused void *data)
7681 struct cmd_showcfg_result *res = parsed_result;
7682 if (!strcmp(res->what, "rxtx"))
7683 rxtx_config_display();
7684 else if (!strcmp(res->what, "cores"))
7685 fwd_lcores_config_display();
7686 else if (!strcmp(res->what, "fwd"))
7687 pkt_fwd_config_display(&cur_fwd_config);
7688 else if (!strcmp(res->what, "rxoffs"))
7689 show_rx_pkt_offsets();
7690 else if (!strcmp(res->what, "rxpkts"))
7691 show_rx_pkt_segments();
7692 else if (!strcmp(res->what, "txpkts"))
7693 show_tx_pkt_segments();
7694 else if (!strcmp(res->what, "txtimes"))
7695 show_tx_pkt_times();
7698 cmdline_parse_token_string_t cmd_showcfg_show =
7699 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7700 cmdline_parse_token_string_t cmd_showcfg_port =
7701 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7702 cmdline_parse_token_string_t cmd_showcfg_what =
7703 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7704 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7706 cmdline_parse_inst_t cmd_showcfg = {
7707 .f = cmd_showcfg_parsed,
7709 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7711 (void *)&cmd_showcfg_show,
7712 (void *)&cmd_showcfg_port,
7713 (void *)&cmd_showcfg_what,
7718 /* *** SHOW ALL PORT INFO *** */
7719 struct cmd_showportall_result {
7720 cmdline_fixed_string_t show;
7721 cmdline_fixed_string_t port;
7722 cmdline_fixed_string_t what;
7723 cmdline_fixed_string_t all;
7726 static void cmd_showportall_parsed(void *parsed_result,
7727 __rte_unused struct cmdline *cl,
7728 __rte_unused void *data)
7732 struct cmd_showportall_result *res = parsed_result;
7733 if (!strcmp(res->show, "clear")) {
7734 if (!strcmp(res->what, "stats"))
7735 RTE_ETH_FOREACH_DEV(i)
7737 else if (!strcmp(res->what, "xstats"))
7738 RTE_ETH_FOREACH_DEV(i)
7739 nic_xstats_clear(i);
7740 } else if (!strcmp(res->what, "info"))
7741 RTE_ETH_FOREACH_DEV(i)
7742 port_infos_display(i);
7743 else if (!strcmp(res->what, "summary")) {
7744 port_summary_header_display();
7745 RTE_ETH_FOREACH_DEV(i)
7746 port_summary_display(i);
7748 else if (!strcmp(res->what, "stats"))
7749 RTE_ETH_FOREACH_DEV(i)
7750 nic_stats_display(i);
7751 else if (!strcmp(res->what, "xstats"))
7752 RTE_ETH_FOREACH_DEV(i)
7753 nic_xstats_display(i);
7754 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7755 else if (!strcmp(res->what, "fdir"))
7756 RTE_ETH_FOREACH_DEV(i)
7759 else if (!strcmp(res->what, "dcb_tc"))
7760 RTE_ETH_FOREACH_DEV(i)
7761 port_dcb_info_display(i);
7764 cmdline_parse_token_string_t cmd_showportall_show =
7765 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7767 cmdline_parse_token_string_t cmd_showportall_port =
7768 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7769 cmdline_parse_token_string_t cmd_showportall_what =
7770 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7771 "info#summary#stats#xstats#fdir#dcb_tc");
7772 cmdline_parse_token_string_t cmd_showportall_all =
7773 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7774 cmdline_parse_inst_t cmd_showportall = {
7775 .f = cmd_showportall_parsed,
7777 .help_str = "show|clear port "
7778 "info|summary|stats|xstats|fdir|dcb_tc all",
7780 (void *)&cmd_showportall_show,
7781 (void *)&cmd_showportall_port,
7782 (void *)&cmd_showportall_what,
7783 (void *)&cmd_showportall_all,
7788 /* *** SHOW PORT INFO *** */
7789 struct cmd_showport_result {
7790 cmdline_fixed_string_t show;
7791 cmdline_fixed_string_t port;
7792 cmdline_fixed_string_t what;
7796 static void cmd_showport_parsed(void *parsed_result,
7797 __rte_unused struct cmdline *cl,
7798 __rte_unused void *data)
7800 struct cmd_showport_result *res = parsed_result;
7801 if (!strcmp(res->show, "clear")) {
7802 if (!strcmp(res->what, "stats"))
7803 nic_stats_clear(res->portnum);
7804 else if (!strcmp(res->what, "xstats"))
7805 nic_xstats_clear(res->portnum);
7806 } else if (!strcmp(res->what, "info"))
7807 port_infos_display(res->portnum);
7808 else if (!strcmp(res->what, "summary")) {
7809 port_summary_header_display();
7810 port_summary_display(res->portnum);
7812 else if (!strcmp(res->what, "stats"))
7813 nic_stats_display(res->portnum);
7814 else if (!strcmp(res->what, "xstats"))
7815 nic_xstats_display(res->portnum);
7816 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7817 else if (!strcmp(res->what, "fdir"))
7818 fdir_get_infos(res->portnum);
7820 else if (!strcmp(res->what, "dcb_tc"))
7821 port_dcb_info_display(res->portnum);
7824 cmdline_parse_token_string_t cmd_showport_show =
7825 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7827 cmdline_parse_token_string_t cmd_showport_port =
7828 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7829 cmdline_parse_token_string_t cmd_showport_what =
7830 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7831 "info#summary#stats#xstats#fdir#dcb_tc");
7832 cmdline_parse_token_num_t cmd_showport_portnum =
7833 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7835 cmdline_parse_inst_t cmd_showport = {
7836 .f = cmd_showport_parsed,
7838 .help_str = "show|clear port "
7839 "info|summary|stats|xstats|fdir|dcb_tc "
7842 (void *)&cmd_showport_show,
7843 (void *)&cmd_showport_port,
7844 (void *)&cmd_showport_what,
7845 (void *)&cmd_showport_portnum,
7850 /* *** SHOW DEVICE INFO *** */
7851 struct cmd_showdevice_result {
7852 cmdline_fixed_string_t show;
7853 cmdline_fixed_string_t device;
7854 cmdline_fixed_string_t what;
7855 cmdline_fixed_string_t identifier;
7858 static void cmd_showdevice_parsed(void *parsed_result,
7859 __rte_unused struct cmdline *cl,
7860 __rte_unused void *data)
7862 struct cmd_showdevice_result *res = parsed_result;
7863 if (!strcmp(res->what, "info")) {
7864 if (!strcmp(res->identifier, "all"))
7865 device_infos_display(NULL);
7867 device_infos_display(res->identifier);
7871 cmdline_parse_token_string_t cmd_showdevice_show =
7872 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7874 cmdline_parse_token_string_t cmd_showdevice_device =
7875 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7876 cmdline_parse_token_string_t cmd_showdevice_what =
7877 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7879 cmdline_parse_token_string_t cmd_showdevice_identifier =
7880 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7883 cmdline_parse_inst_t cmd_showdevice = {
7884 .f = cmd_showdevice_parsed,
7886 .help_str = "show device info <identifier>|all",
7888 (void *)&cmd_showdevice_show,
7889 (void *)&cmd_showdevice_device,
7890 (void *)&cmd_showdevice_what,
7891 (void *)&cmd_showdevice_identifier,
7896 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7897 struct cmd_showeeprom_result {
7898 cmdline_fixed_string_t show;
7899 cmdline_fixed_string_t port;
7901 cmdline_fixed_string_t type;
7904 static void cmd_showeeprom_parsed(void *parsed_result,
7905 __rte_unused struct cmdline *cl,
7906 __rte_unused void *data)
7908 struct cmd_showeeprom_result *res = parsed_result;
7910 if (!strcmp(res->type, "eeprom"))
7911 port_eeprom_display(res->portnum);
7912 else if (!strcmp(res->type, "module_eeprom"))
7913 port_module_eeprom_display(res->portnum);
7915 printf("Unknown argument\n");
7918 cmdline_parse_token_string_t cmd_showeeprom_show =
7919 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7920 cmdline_parse_token_string_t cmd_showeeprom_port =
7921 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7922 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7923 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7925 cmdline_parse_token_string_t cmd_showeeprom_type =
7926 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7928 cmdline_parse_inst_t cmd_showeeprom = {
7929 .f = cmd_showeeprom_parsed,
7931 .help_str = "show port <port_id> module_eeprom|eeprom",
7933 (void *)&cmd_showeeprom_show,
7934 (void *)&cmd_showeeprom_port,
7935 (void *)&cmd_showeeprom_portnum,
7936 (void *)&cmd_showeeprom_type,
7941 /* *** SHOW QUEUE INFO *** */
7942 struct cmd_showqueue_result {
7943 cmdline_fixed_string_t show;
7944 cmdline_fixed_string_t type;
7945 cmdline_fixed_string_t what;
7951 cmd_showqueue_parsed(void *parsed_result,
7952 __rte_unused struct cmdline *cl,
7953 __rte_unused void *data)
7955 struct cmd_showqueue_result *res = parsed_result;
7957 if (!strcmp(res->type, "rxq"))
7958 rx_queue_infos_display(res->portnum, res->queuenum);
7959 else if (!strcmp(res->type, "txq"))
7960 tx_queue_infos_display(res->portnum, res->queuenum);
7963 cmdline_parse_token_string_t cmd_showqueue_show =
7964 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7965 cmdline_parse_token_string_t cmd_showqueue_type =
7966 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7967 cmdline_parse_token_string_t cmd_showqueue_what =
7968 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7969 cmdline_parse_token_num_t cmd_showqueue_portnum =
7970 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7972 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7973 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7976 cmdline_parse_inst_t cmd_showqueue = {
7977 .f = cmd_showqueue_parsed,
7979 .help_str = "show rxq|txq info <port_id> <queue_id>",
7981 (void *)&cmd_showqueue_show,
7982 (void *)&cmd_showqueue_type,
7983 (void *)&cmd_showqueue_what,
7984 (void *)&cmd_showqueue_portnum,
7985 (void *)&cmd_showqueue_queuenum,
7990 /* show/clear fwd engine statistics */
7992 cmdline_fixed_string_t action;
7993 cmdline_fixed_string_t fwd;
7994 cmdline_fixed_string_t stats;
7995 cmdline_fixed_string_t all;
7998 cmdline_parse_token_string_t cmd_fwd_action =
7999 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8000 cmdline_parse_token_string_t cmd_fwd_fwd =
8001 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8002 cmdline_parse_token_string_t cmd_fwd_stats =
8003 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8004 cmdline_parse_token_string_t cmd_fwd_all =
8005 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8008 cmd_showfwdall_parsed(void *parsed_result,
8009 __rte_unused struct cmdline *cl,
8010 __rte_unused void *data)
8012 struct fwd_result *res = parsed_result;
8014 if (!strcmp(res->action, "show"))
8015 fwd_stats_display();
8020 static cmdline_parse_inst_t cmd_showfwdall = {
8021 .f = cmd_showfwdall_parsed,
8023 .help_str = "show|clear fwd stats all",
8025 (void *)&cmd_fwd_action,
8026 (void *)&cmd_fwd_fwd,
8027 (void *)&cmd_fwd_stats,
8028 (void *)&cmd_fwd_all,
8033 /* *** READ PORT REGISTER *** */
8034 struct cmd_read_reg_result {
8035 cmdline_fixed_string_t read;
8036 cmdline_fixed_string_t reg;
8042 cmd_read_reg_parsed(void *parsed_result,
8043 __rte_unused struct cmdline *cl,
8044 __rte_unused void *data)
8046 struct cmd_read_reg_result *res = parsed_result;
8047 port_reg_display(res->port_id, res->reg_off);
8050 cmdline_parse_token_string_t cmd_read_reg_read =
8051 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8052 cmdline_parse_token_string_t cmd_read_reg_reg =
8053 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8054 cmdline_parse_token_num_t cmd_read_reg_port_id =
8055 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8056 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8057 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8059 cmdline_parse_inst_t cmd_read_reg = {
8060 .f = cmd_read_reg_parsed,
8062 .help_str = "read reg <port_id> <reg_off>",
8064 (void *)&cmd_read_reg_read,
8065 (void *)&cmd_read_reg_reg,
8066 (void *)&cmd_read_reg_port_id,
8067 (void *)&cmd_read_reg_reg_off,
8072 /* *** READ PORT REGISTER BIT FIELD *** */
8073 struct cmd_read_reg_bit_field_result {
8074 cmdline_fixed_string_t read;
8075 cmdline_fixed_string_t regfield;
8083 cmd_read_reg_bit_field_parsed(void *parsed_result,
8084 __rte_unused struct cmdline *cl,
8085 __rte_unused void *data)
8087 struct cmd_read_reg_bit_field_result *res = parsed_result;
8088 port_reg_bit_field_display(res->port_id, res->reg_off,
8089 res->bit1_pos, res->bit2_pos);
8092 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8093 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8095 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8096 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8097 regfield, "regfield");
8098 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8099 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8101 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8102 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8104 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8105 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8107 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8108 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8111 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8112 .f = cmd_read_reg_bit_field_parsed,
8114 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8115 "Read register bit field between bit_x and bit_y included",
8117 (void *)&cmd_read_reg_bit_field_read,
8118 (void *)&cmd_read_reg_bit_field_regfield,
8119 (void *)&cmd_read_reg_bit_field_port_id,
8120 (void *)&cmd_read_reg_bit_field_reg_off,
8121 (void *)&cmd_read_reg_bit_field_bit1_pos,
8122 (void *)&cmd_read_reg_bit_field_bit2_pos,
8127 /* *** READ PORT REGISTER BIT *** */
8128 struct cmd_read_reg_bit_result {
8129 cmdline_fixed_string_t read;
8130 cmdline_fixed_string_t regbit;
8137 cmd_read_reg_bit_parsed(void *parsed_result,
8138 __rte_unused struct cmdline *cl,
8139 __rte_unused void *data)
8141 struct cmd_read_reg_bit_result *res = parsed_result;
8142 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8145 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8146 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8147 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8148 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8150 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8151 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8153 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8154 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8156 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8157 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8160 cmdline_parse_inst_t cmd_read_reg_bit = {
8161 .f = cmd_read_reg_bit_parsed,
8163 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8165 (void *)&cmd_read_reg_bit_read,
8166 (void *)&cmd_read_reg_bit_regbit,
8167 (void *)&cmd_read_reg_bit_port_id,
8168 (void *)&cmd_read_reg_bit_reg_off,
8169 (void *)&cmd_read_reg_bit_bit_pos,
8174 /* *** WRITE PORT REGISTER *** */
8175 struct cmd_write_reg_result {
8176 cmdline_fixed_string_t write;
8177 cmdline_fixed_string_t reg;
8184 cmd_write_reg_parsed(void *parsed_result,
8185 __rte_unused struct cmdline *cl,
8186 __rte_unused void *data)
8188 struct cmd_write_reg_result *res = parsed_result;
8189 port_reg_set(res->port_id, res->reg_off, res->value);
8192 cmdline_parse_token_string_t cmd_write_reg_write =
8193 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8194 cmdline_parse_token_string_t cmd_write_reg_reg =
8195 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8196 cmdline_parse_token_num_t cmd_write_reg_port_id =
8197 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8198 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8199 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8200 cmdline_parse_token_num_t cmd_write_reg_value =
8201 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8203 cmdline_parse_inst_t cmd_write_reg = {
8204 .f = cmd_write_reg_parsed,
8206 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8208 (void *)&cmd_write_reg_write,
8209 (void *)&cmd_write_reg_reg,
8210 (void *)&cmd_write_reg_port_id,
8211 (void *)&cmd_write_reg_reg_off,
8212 (void *)&cmd_write_reg_value,
8217 /* *** WRITE PORT REGISTER BIT FIELD *** */
8218 struct cmd_write_reg_bit_field_result {
8219 cmdline_fixed_string_t write;
8220 cmdline_fixed_string_t regfield;
8229 cmd_write_reg_bit_field_parsed(void *parsed_result,
8230 __rte_unused struct cmdline *cl,
8231 __rte_unused void *data)
8233 struct cmd_write_reg_bit_field_result *res = parsed_result;
8234 port_reg_bit_field_set(res->port_id, res->reg_off,
8235 res->bit1_pos, res->bit2_pos, res->value);
8238 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8239 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8241 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8242 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8243 regfield, "regfield");
8244 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8245 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8247 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8248 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8250 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8251 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8253 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8254 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8256 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8257 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8260 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8261 .f = cmd_write_reg_bit_field_parsed,
8263 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8265 "Set register bit field between bit_x and bit_y included",
8267 (void *)&cmd_write_reg_bit_field_write,
8268 (void *)&cmd_write_reg_bit_field_regfield,
8269 (void *)&cmd_write_reg_bit_field_port_id,
8270 (void *)&cmd_write_reg_bit_field_reg_off,
8271 (void *)&cmd_write_reg_bit_field_bit1_pos,
8272 (void *)&cmd_write_reg_bit_field_bit2_pos,
8273 (void *)&cmd_write_reg_bit_field_value,
8278 /* *** WRITE PORT REGISTER BIT *** */
8279 struct cmd_write_reg_bit_result {
8280 cmdline_fixed_string_t write;
8281 cmdline_fixed_string_t regbit;
8289 cmd_write_reg_bit_parsed(void *parsed_result,
8290 __rte_unused struct cmdline *cl,
8291 __rte_unused void *data)
8293 struct cmd_write_reg_bit_result *res = parsed_result;
8294 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8297 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8298 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8300 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8301 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8303 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8304 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8306 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8307 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8309 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8310 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8312 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8313 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8316 cmdline_parse_inst_t cmd_write_reg_bit = {
8317 .f = cmd_write_reg_bit_parsed,
8319 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8322 (void *)&cmd_write_reg_bit_write,
8323 (void *)&cmd_write_reg_bit_regbit,
8324 (void *)&cmd_write_reg_bit_port_id,
8325 (void *)&cmd_write_reg_bit_reg_off,
8326 (void *)&cmd_write_reg_bit_bit_pos,
8327 (void *)&cmd_write_reg_bit_value,
8332 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8333 struct cmd_read_rxd_txd_result {
8334 cmdline_fixed_string_t read;
8335 cmdline_fixed_string_t rxd_txd;
8342 cmd_read_rxd_txd_parsed(void *parsed_result,
8343 __rte_unused struct cmdline *cl,
8344 __rte_unused void *data)
8346 struct cmd_read_rxd_txd_result *res = parsed_result;
8348 if (!strcmp(res->rxd_txd, "rxd"))
8349 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8350 else if (!strcmp(res->rxd_txd, "txd"))
8351 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8354 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8355 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8356 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8357 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8359 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8360 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8362 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8363 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8365 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8366 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8369 cmdline_parse_inst_t cmd_read_rxd_txd = {
8370 .f = cmd_read_rxd_txd_parsed,
8372 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8374 (void *)&cmd_read_rxd_txd_read,
8375 (void *)&cmd_read_rxd_txd_rxd_txd,
8376 (void *)&cmd_read_rxd_txd_port_id,
8377 (void *)&cmd_read_rxd_txd_queue_id,
8378 (void *)&cmd_read_rxd_txd_desc_id,
8384 struct cmd_quit_result {
8385 cmdline_fixed_string_t quit;
8388 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8390 __rte_unused void *data)
8395 cmdline_parse_token_string_t cmd_quit_quit =
8396 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8398 cmdline_parse_inst_t cmd_quit = {
8399 .f = cmd_quit_parsed,
8401 .help_str = "quit: Exit application",
8403 (void *)&cmd_quit_quit,
8408 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8409 struct cmd_mac_addr_result {
8410 cmdline_fixed_string_t mac_addr_cmd;
8411 cmdline_fixed_string_t what;
8413 struct rte_ether_addr address;
8416 static void cmd_mac_addr_parsed(void *parsed_result,
8417 __rte_unused struct cmdline *cl,
8418 __rte_unused void *data)
8420 struct cmd_mac_addr_result *res = parsed_result;
8423 if (strcmp(res->what, "add") == 0)
8424 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8425 else if (strcmp(res->what, "set") == 0)
8426 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8429 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8431 /* check the return value and print it if is < 0 */
8433 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8437 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8438 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8440 cmdline_parse_token_string_t cmd_mac_addr_what =
8441 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8443 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8444 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8446 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8447 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8449 cmdline_parse_inst_t cmd_mac_addr = {
8450 .f = cmd_mac_addr_parsed,
8452 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8453 "Add/Remove/Set MAC address on port_id",
8455 (void *)&cmd_mac_addr_cmd,
8456 (void *)&cmd_mac_addr_what,
8457 (void *)&cmd_mac_addr_portnum,
8458 (void *)&cmd_mac_addr_addr,
8463 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8464 struct cmd_eth_peer_result {
8465 cmdline_fixed_string_t set;
8466 cmdline_fixed_string_t eth_peer;
8468 cmdline_fixed_string_t peer_addr;
8471 static void cmd_set_eth_peer_parsed(void *parsed_result,
8472 __rte_unused struct cmdline *cl,
8473 __rte_unused void *data)
8475 struct cmd_eth_peer_result *res = parsed_result;
8477 if (test_done == 0) {
8478 printf("Please stop forwarding first\n");
8481 if (!strcmp(res->eth_peer, "eth-peer")) {
8482 set_fwd_eth_peer(res->port_id, res->peer_addr);
8486 cmdline_parse_token_string_t cmd_eth_peer_set =
8487 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8488 cmdline_parse_token_string_t cmd_eth_peer =
8489 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8490 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8491 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8493 cmdline_parse_token_string_t cmd_eth_peer_addr =
8494 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8496 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8497 .f = cmd_set_eth_peer_parsed,
8499 .help_str = "set eth-peer <port_id> <peer_mac>",
8501 (void *)&cmd_eth_peer_set,
8502 (void *)&cmd_eth_peer,
8503 (void *)&cmd_eth_peer_port_id,
8504 (void *)&cmd_eth_peer_addr,
8509 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8510 struct cmd_set_qmap_result {
8511 cmdline_fixed_string_t set;
8512 cmdline_fixed_string_t qmap;
8513 cmdline_fixed_string_t what;
8520 cmd_set_qmap_parsed(void *parsed_result,
8521 __rte_unused struct cmdline *cl,
8522 __rte_unused void *data)
8524 struct cmd_set_qmap_result *res = parsed_result;
8525 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8527 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8530 cmdline_parse_token_string_t cmd_setqmap_set =
8531 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8533 cmdline_parse_token_string_t cmd_setqmap_qmap =
8534 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8536 cmdline_parse_token_string_t cmd_setqmap_what =
8537 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8539 cmdline_parse_token_num_t cmd_setqmap_portid =
8540 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8541 port_id, RTE_UINT16);
8542 cmdline_parse_token_num_t cmd_setqmap_queueid =
8543 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8544 queue_id, RTE_UINT16);
8545 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8546 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8547 map_value, RTE_UINT8);
8549 cmdline_parse_inst_t cmd_set_qmap = {
8550 .f = cmd_set_qmap_parsed,
8552 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8553 "Set statistics mapping value on tx|rx queue_id of port_id",
8555 (void *)&cmd_setqmap_set,
8556 (void *)&cmd_setqmap_qmap,
8557 (void *)&cmd_setqmap_what,
8558 (void *)&cmd_setqmap_portid,
8559 (void *)&cmd_setqmap_queueid,
8560 (void *)&cmd_setqmap_mapvalue,
8565 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8566 struct cmd_set_xstats_hide_zero_result {
8567 cmdline_fixed_string_t keyword;
8568 cmdline_fixed_string_t name;
8569 cmdline_fixed_string_t on_off;
8573 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8574 __rte_unused struct cmdline *cl,
8575 __rte_unused void *data)
8577 struct cmd_set_xstats_hide_zero_result *res;
8578 uint16_t on_off = 0;
8580 res = parsed_result;
8581 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8582 set_xstats_hide_zero(on_off);
8585 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8586 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8588 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8589 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8590 name, "xstats-hide-zero");
8591 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8592 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8595 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8596 .f = cmd_set_xstats_hide_zero_parsed,
8598 .help_str = "set xstats-hide-zero on|off",
8600 (void *)&cmd_set_xstats_hide_zero_keyword,
8601 (void *)&cmd_set_xstats_hide_zero_name,
8602 (void *)&cmd_set_xstats_hide_zero_on_off,
8607 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8608 struct cmd_set_record_core_cycles_result {
8609 cmdline_fixed_string_t keyword;
8610 cmdline_fixed_string_t name;
8611 cmdline_fixed_string_t on_off;
8615 cmd_set_record_core_cycles_parsed(void *parsed_result,
8616 __rte_unused struct cmdline *cl,
8617 __rte_unused void *data)
8619 struct cmd_set_record_core_cycles_result *res;
8620 uint16_t on_off = 0;
8622 res = parsed_result;
8623 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8624 set_record_core_cycles(on_off);
8627 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8628 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8630 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8631 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8632 name, "record-core-cycles");
8633 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8634 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8637 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8638 .f = cmd_set_record_core_cycles_parsed,
8640 .help_str = "set record-core-cycles on|off",
8642 (void *)&cmd_set_record_core_cycles_keyword,
8643 (void *)&cmd_set_record_core_cycles_name,
8644 (void *)&cmd_set_record_core_cycles_on_off,
8649 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8650 struct cmd_set_record_burst_stats_result {
8651 cmdline_fixed_string_t keyword;
8652 cmdline_fixed_string_t name;
8653 cmdline_fixed_string_t on_off;
8657 cmd_set_record_burst_stats_parsed(void *parsed_result,
8658 __rte_unused struct cmdline *cl,
8659 __rte_unused void *data)
8661 struct cmd_set_record_burst_stats_result *res;
8662 uint16_t on_off = 0;
8664 res = parsed_result;
8665 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8666 set_record_burst_stats(on_off);
8669 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8670 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8672 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8673 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8674 name, "record-burst-stats");
8675 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8676 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8679 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8680 .f = cmd_set_record_burst_stats_parsed,
8682 .help_str = "set record-burst-stats on|off",
8684 (void *)&cmd_set_record_burst_stats_keyword,
8685 (void *)&cmd_set_record_burst_stats_name,
8686 (void *)&cmd_set_record_burst_stats_on_off,
8691 /* *** CONFIGURE UNICAST HASH TABLE *** */
8692 struct cmd_set_uc_hash_table {
8693 cmdline_fixed_string_t set;
8694 cmdline_fixed_string_t port;
8696 cmdline_fixed_string_t what;
8697 struct rte_ether_addr address;
8698 cmdline_fixed_string_t mode;
8702 cmd_set_uc_hash_parsed(void *parsed_result,
8703 __rte_unused struct cmdline *cl,
8704 __rte_unused void *data)
8707 struct cmd_set_uc_hash_table *res = parsed_result;
8709 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8711 if (strcmp(res->what, "uta") == 0)
8712 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8713 &res->address,(uint8_t)is_on);
8715 printf("bad unicast hash table parameter, return code = %d \n", ret);
8719 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8720 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8722 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8723 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8725 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8726 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8727 port_id, RTE_UINT16);
8728 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8729 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8731 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8732 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8734 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8735 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8738 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8739 .f = cmd_set_uc_hash_parsed,
8741 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8743 (void *)&cmd_set_uc_hash_set,
8744 (void *)&cmd_set_uc_hash_port,
8745 (void *)&cmd_set_uc_hash_portid,
8746 (void *)&cmd_set_uc_hash_what,
8747 (void *)&cmd_set_uc_hash_mac,
8748 (void *)&cmd_set_uc_hash_mode,
8753 struct cmd_set_uc_all_hash_table {
8754 cmdline_fixed_string_t set;
8755 cmdline_fixed_string_t port;
8757 cmdline_fixed_string_t what;
8758 cmdline_fixed_string_t value;
8759 cmdline_fixed_string_t mode;
8763 cmd_set_uc_all_hash_parsed(void *parsed_result,
8764 __rte_unused struct cmdline *cl,
8765 __rte_unused void *data)
8768 struct cmd_set_uc_all_hash_table *res = parsed_result;
8770 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8772 if ((strcmp(res->what, "uta") == 0) &&
8773 (strcmp(res->value, "all") == 0))
8774 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8776 printf("bad unicast hash table parameter,"
8777 "return code = %d \n", ret);
8780 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8781 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8783 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8784 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8786 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8787 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8788 port_id, RTE_UINT16);
8789 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8790 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8792 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8793 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8795 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8796 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8799 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8800 .f = cmd_set_uc_all_hash_parsed,
8802 .help_str = "set port <port_id> uta all on|off",
8804 (void *)&cmd_set_uc_all_hash_set,
8805 (void *)&cmd_set_uc_all_hash_port,
8806 (void *)&cmd_set_uc_all_hash_portid,
8807 (void *)&cmd_set_uc_all_hash_what,
8808 (void *)&cmd_set_uc_all_hash_value,
8809 (void *)&cmd_set_uc_all_hash_mode,
8814 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8815 struct cmd_set_vf_traffic {
8816 cmdline_fixed_string_t set;
8817 cmdline_fixed_string_t port;
8819 cmdline_fixed_string_t vf;
8821 cmdline_fixed_string_t what;
8822 cmdline_fixed_string_t mode;
8826 cmd_set_vf_traffic_parsed(void *parsed_result,
8827 __rte_unused struct cmdline *cl,
8828 __rte_unused void *data)
8830 struct cmd_set_vf_traffic *res = parsed_result;
8831 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8832 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8834 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8837 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8838 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8840 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8841 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8843 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8844 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8845 port_id, RTE_UINT16);
8846 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8847 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8849 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8850 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8852 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8853 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8855 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8856 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8859 cmdline_parse_inst_t cmd_set_vf_traffic = {
8860 .f = cmd_set_vf_traffic_parsed,
8862 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8864 (void *)&cmd_setvf_traffic_set,
8865 (void *)&cmd_setvf_traffic_port,
8866 (void *)&cmd_setvf_traffic_portid,
8867 (void *)&cmd_setvf_traffic_vf,
8868 (void *)&cmd_setvf_traffic_vfid,
8869 (void *)&cmd_setvf_traffic_what,
8870 (void *)&cmd_setvf_traffic_mode,
8875 /* *** CONFIGURE VF RECEIVE MODE *** */
8876 struct cmd_set_vf_rxmode {
8877 cmdline_fixed_string_t set;
8878 cmdline_fixed_string_t port;
8880 cmdline_fixed_string_t vf;
8882 cmdline_fixed_string_t what;
8883 cmdline_fixed_string_t mode;
8884 cmdline_fixed_string_t on;
8888 cmd_set_vf_rxmode_parsed(void *parsed_result,
8889 __rte_unused struct cmdline *cl,
8890 __rte_unused void *data)
8893 uint16_t vf_rxmode = 0;
8894 struct cmd_set_vf_rxmode *res = parsed_result;
8896 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8897 if (!strcmp(res->what,"rxmode")) {
8898 if (!strcmp(res->mode, "AUPE"))
8899 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8900 else if (!strcmp(res->mode, "ROPE"))
8901 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8902 else if (!strcmp(res->mode, "BAM"))
8903 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8904 else if (!strncmp(res->mode, "MPE",3))
8905 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8908 RTE_SET_USED(is_on);
8910 #ifdef RTE_NET_IXGBE
8911 if (ret == -ENOTSUP)
8912 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8913 vf_rxmode, (uint8_t)is_on);
8916 if (ret == -ENOTSUP)
8917 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8918 vf_rxmode, (uint8_t)is_on);
8921 printf("bad VF receive mode parameter, return code = %d \n",
8925 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8926 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8928 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8929 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8931 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8932 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8933 port_id, RTE_UINT16);
8934 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8935 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8937 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8938 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8940 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8941 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8943 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8944 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8945 mode, "AUPE#ROPE#BAM#MPE");
8946 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8947 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8950 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8951 .f = cmd_set_vf_rxmode_parsed,
8953 .help_str = "set port <port_id> vf <vf_id> rxmode "
8954 "AUPE|ROPE|BAM|MPE on|off",
8956 (void *)&cmd_set_vf_rxmode_set,
8957 (void *)&cmd_set_vf_rxmode_port,
8958 (void *)&cmd_set_vf_rxmode_portid,
8959 (void *)&cmd_set_vf_rxmode_vf,
8960 (void *)&cmd_set_vf_rxmode_vfid,
8961 (void *)&cmd_set_vf_rxmode_what,
8962 (void *)&cmd_set_vf_rxmode_mode,
8963 (void *)&cmd_set_vf_rxmode_on,
8968 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8969 struct cmd_vf_mac_addr_result {
8970 cmdline_fixed_string_t mac_addr_cmd;
8971 cmdline_fixed_string_t what;
8972 cmdline_fixed_string_t port;
8974 cmdline_fixed_string_t vf;
8976 struct rte_ether_addr address;
8979 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8980 __rte_unused struct cmdline *cl,
8981 __rte_unused void *data)
8983 struct cmd_vf_mac_addr_result *res = parsed_result;
8986 if (strcmp(res->what, "add") != 0)
8990 if (ret == -ENOTSUP)
8991 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8995 if (ret == -ENOTSUP)
8996 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9001 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9005 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9006 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9007 mac_addr_cmd,"mac_addr");
9008 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9009 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9011 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9012 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9014 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9015 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9016 port_num, RTE_UINT16);
9017 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9018 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9020 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9021 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9023 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9024 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9027 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9028 .f = cmd_vf_mac_addr_parsed,
9030 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9031 "Add MAC address filtering for a VF on port_id",
9033 (void *)&cmd_vf_mac_addr_cmd,
9034 (void *)&cmd_vf_mac_addr_what,
9035 (void *)&cmd_vf_mac_addr_port,
9036 (void *)&cmd_vf_mac_addr_portnum,
9037 (void *)&cmd_vf_mac_addr_vf,
9038 (void *)&cmd_vf_mac_addr_vfnum,
9039 (void *)&cmd_vf_mac_addr_addr,
9044 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9045 struct cmd_vf_rx_vlan_filter {
9046 cmdline_fixed_string_t rx_vlan;
9047 cmdline_fixed_string_t what;
9049 cmdline_fixed_string_t port;
9051 cmdline_fixed_string_t vf;
9056 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9057 __rte_unused struct cmdline *cl,
9058 __rte_unused void *data)
9060 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9063 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9065 #ifdef RTE_NET_IXGBE
9066 if (ret == -ENOTSUP)
9067 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9068 res->vlan_id, res->vf_mask, is_add);
9071 if (ret == -ENOTSUP)
9072 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9073 res->vlan_id, res->vf_mask, is_add);
9076 if (ret == -ENOTSUP)
9077 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9078 res->vlan_id, res->vf_mask, is_add);
9085 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9086 res->vlan_id, res->vf_mask);
9089 printf("invalid port_id %d\n", res->port_id);
9092 printf("function not implemented or supported\n");
9095 printf("programming error: (%s)\n", strerror(-ret));
9099 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9100 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9101 rx_vlan, "rx_vlan");
9102 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9103 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9105 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9106 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9107 vlan_id, RTE_UINT16);
9108 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9109 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9111 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9112 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9113 port_id, RTE_UINT16);
9114 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9115 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9117 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9118 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9119 vf_mask, RTE_UINT64);
9121 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9122 .f = cmd_vf_rx_vlan_filter_parsed,
9124 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9125 "(vf_mask = hexadecimal VF mask)",
9127 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9128 (void *)&cmd_vf_rx_vlan_filter_what,
9129 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9130 (void *)&cmd_vf_rx_vlan_filter_port,
9131 (void *)&cmd_vf_rx_vlan_filter_portid,
9132 (void *)&cmd_vf_rx_vlan_filter_vf,
9133 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9138 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9139 struct cmd_queue_rate_limit_result {
9140 cmdline_fixed_string_t set;
9141 cmdline_fixed_string_t port;
9143 cmdline_fixed_string_t queue;
9145 cmdline_fixed_string_t rate;
9149 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9150 __rte_unused struct cmdline *cl,
9151 __rte_unused void *data)
9153 struct cmd_queue_rate_limit_result *res = parsed_result;
9156 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9157 && (strcmp(res->queue, "queue") == 0)
9158 && (strcmp(res->rate, "rate") == 0))
9159 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9162 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9166 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9167 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9169 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9170 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9172 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9173 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9174 port_num, RTE_UINT16);
9175 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9176 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9178 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9179 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9180 queue_num, RTE_UINT8);
9181 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9182 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9184 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9185 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9186 rate_num, RTE_UINT16);
9188 cmdline_parse_inst_t cmd_queue_rate_limit = {
9189 .f = cmd_queue_rate_limit_parsed,
9191 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9192 "Set rate limit for a queue on port_id",
9194 (void *)&cmd_queue_rate_limit_set,
9195 (void *)&cmd_queue_rate_limit_port,
9196 (void *)&cmd_queue_rate_limit_portnum,
9197 (void *)&cmd_queue_rate_limit_queue,
9198 (void *)&cmd_queue_rate_limit_queuenum,
9199 (void *)&cmd_queue_rate_limit_rate,
9200 (void *)&cmd_queue_rate_limit_ratenum,
9205 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9206 struct cmd_vf_rate_limit_result {
9207 cmdline_fixed_string_t set;
9208 cmdline_fixed_string_t port;
9210 cmdline_fixed_string_t vf;
9212 cmdline_fixed_string_t rate;
9214 cmdline_fixed_string_t q_msk;
9218 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9219 __rte_unused struct cmdline *cl,
9220 __rte_unused void *data)
9222 struct cmd_vf_rate_limit_result *res = parsed_result;
9225 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9226 && (strcmp(res->vf, "vf") == 0)
9227 && (strcmp(res->rate, "rate") == 0)
9228 && (strcmp(res->q_msk, "queue_mask") == 0))
9229 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9230 res->rate_num, res->q_msk_val);
9232 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9236 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9237 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9239 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9240 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9242 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9243 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9244 port_num, RTE_UINT16);
9245 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9246 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9248 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9249 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9251 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9252 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9254 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9255 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9256 rate_num, RTE_UINT16);
9257 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9258 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9259 q_msk, "queue_mask");
9260 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9261 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9262 q_msk_val, RTE_UINT64);
9264 cmdline_parse_inst_t cmd_vf_rate_limit = {
9265 .f = cmd_vf_rate_limit_parsed,
9267 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9268 "queue_mask <queue_mask_value>: "
9269 "Set rate limit for queues of VF on port_id",
9271 (void *)&cmd_vf_rate_limit_set,
9272 (void *)&cmd_vf_rate_limit_port,
9273 (void *)&cmd_vf_rate_limit_portnum,
9274 (void *)&cmd_vf_rate_limit_vf,
9275 (void *)&cmd_vf_rate_limit_vfnum,
9276 (void *)&cmd_vf_rate_limit_rate,
9277 (void *)&cmd_vf_rate_limit_ratenum,
9278 (void *)&cmd_vf_rate_limit_q_msk,
9279 (void *)&cmd_vf_rate_limit_q_msk_val,
9284 /* *** CONFIGURE TUNNEL UDP PORT *** */
9285 struct cmd_tunnel_udp_config {
9286 cmdline_fixed_string_t rx_vxlan_port;
9287 cmdline_fixed_string_t what;
9293 cmd_tunnel_udp_config_parsed(void *parsed_result,
9294 __rte_unused struct cmdline *cl,
9295 __rte_unused void *data)
9297 struct cmd_tunnel_udp_config *res = parsed_result;
9298 struct rte_eth_udp_tunnel tunnel_udp;
9301 tunnel_udp.udp_port = res->udp_port;
9302 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9304 if (!strcmp(res->what, "add"))
9305 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9308 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9312 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9315 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9316 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9317 rx_vxlan_port, "rx_vxlan_port");
9318 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9319 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9321 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9322 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9323 udp_port, RTE_UINT16);
9324 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9325 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9326 port_id, RTE_UINT16);
9328 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9329 .f = cmd_tunnel_udp_config_parsed,
9331 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9332 "Add/Remove a tunneling UDP port filter",
9334 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9335 (void *)&cmd_tunnel_udp_config_what,
9336 (void *)&cmd_tunnel_udp_config_udp_port,
9337 (void *)&cmd_tunnel_udp_config_port_id,
9342 struct cmd_config_tunnel_udp_port {
9343 cmdline_fixed_string_t port;
9344 cmdline_fixed_string_t config;
9346 cmdline_fixed_string_t udp_tunnel_port;
9347 cmdline_fixed_string_t action;
9348 cmdline_fixed_string_t tunnel_type;
9353 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9354 __rte_unused struct cmdline *cl,
9355 __rte_unused void *data)
9357 struct cmd_config_tunnel_udp_port *res = parsed_result;
9358 struct rte_eth_udp_tunnel tunnel_udp;
9361 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9364 tunnel_udp.udp_port = res->udp_port;
9366 if (!strcmp(res->tunnel_type, "vxlan")) {
9367 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9368 } else if (!strcmp(res->tunnel_type, "geneve")) {
9369 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9370 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9371 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9372 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9373 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9375 printf("Invalid tunnel type\n");
9379 if (!strcmp(res->action, "add"))
9380 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9383 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9387 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9390 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9391 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9393 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9394 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9396 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9397 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9399 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9400 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9403 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9404 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9406 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9407 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9408 "vxlan#geneve#vxlan-gpe#ecpri");
9409 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9410 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9413 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9414 .f = cmd_cfg_tunnel_udp_port_parsed,
9416 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9417 "geneve|vxlan-gpe|ecpri <udp_port>",
9419 (void *)&cmd_config_tunnel_udp_port_port,
9420 (void *)&cmd_config_tunnel_udp_port_config,
9421 (void *)&cmd_config_tunnel_udp_port_port_id,
9422 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9423 (void *)&cmd_config_tunnel_udp_port_action,
9424 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9425 (void *)&cmd_config_tunnel_udp_port_value,
9430 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9431 struct cmd_set_mirror_mask_result {
9432 cmdline_fixed_string_t set;
9433 cmdline_fixed_string_t port;
9435 cmdline_fixed_string_t mirror;
9437 cmdline_fixed_string_t what;
9438 cmdline_fixed_string_t value;
9439 cmdline_fixed_string_t dstpool;
9441 cmdline_fixed_string_t on;
9444 cmdline_parse_token_string_t cmd_mirror_mask_set =
9445 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9447 cmdline_parse_token_string_t cmd_mirror_mask_port =
9448 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9450 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9451 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9452 port_id, RTE_UINT16);
9453 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9454 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9455 mirror, "mirror-rule");
9456 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9457 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9458 rule_id, RTE_UINT8);
9459 cmdline_parse_token_string_t cmd_mirror_mask_what =
9460 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9461 what, "pool-mirror-up#pool-mirror-down"
9463 cmdline_parse_token_string_t cmd_mirror_mask_value =
9464 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9466 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9467 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9468 dstpool, "dst-pool");
9469 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9470 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9471 dstpool_id, RTE_UINT8);
9472 cmdline_parse_token_string_t cmd_mirror_mask_on =
9473 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9477 cmd_set_mirror_mask_parsed(void *parsed_result,
9478 __rte_unused struct cmdline *cl,
9479 __rte_unused void *data)
9482 struct cmd_set_mirror_mask_result *res = parsed_result;
9483 struct rte_eth_mirror_conf mr_conf;
9485 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9487 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9489 mr_conf.dst_pool = res->dstpool_id;
9491 if (!strcmp(res->what, "pool-mirror-up")) {
9492 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9493 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9494 } else if (!strcmp(res->what, "pool-mirror-down")) {
9495 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9496 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9497 } else if (!strcmp(res->what, "vlan-mirror")) {
9498 mr_conf.rule_type = ETH_MIRROR_VLAN;
9499 nb_item = parse_item_list(res->value, "vlan",
9500 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9504 for (i = 0; i < nb_item; i++) {
9505 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9506 printf("Invalid vlan_id: must be < 4096\n");
9510 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9511 mr_conf.vlan.vlan_mask |= 1ULL << i;
9515 if (!strcmp(res->on, "on"))
9516 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9519 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9522 printf("mirror rule add error: (%s)\n", strerror(-ret));
9525 cmdline_parse_inst_t cmd_set_mirror_mask = {
9526 .f = cmd_set_mirror_mask_parsed,
9528 .help_str = "set port <port_id> mirror-rule <rule_id> "
9529 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9530 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9532 (void *)&cmd_mirror_mask_set,
9533 (void *)&cmd_mirror_mask_port,
9534 (void *)&cmd_mirror_mask_portid,
9535 (void *)&cmd_mirror_mask_mirror,
9536 (void *)&cmd_mirror_mask_ruleid,
9537 (void *)&cmd_mirror_mask_what,
9538 (void *)&cmd_mirror_mask_value,
9539 (void *)&cmd_mirror_mask_dstpool,
9540 (void *)&cmd_mirror_mask_poolid,
9541 (void *)&cmd_mirror_mask_on,
9546 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9547 struct cmd_set_mirror_link_result {
9548 cmdline_fixed_string_t set;
9549 cmdline_fixed_string_t port;
9551 cmdline_fixed_string_t mirror;
9553 cmdline_fixed_string_t what;
9554 cmdline_fixed_string_t dstpool;
9556 cmdline_fixed_string_t on;
9559 cmdline_parse_token_string_t cmd_mirror_link_set =
9560 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9562 cmdline_parse_token_string_t cmd_mirror_link_port =
9563 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9565 cmdline_parse_token_num_t cmd_mirror_link_portid =
9566 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9567 port_id, RTE_UINT16);
9568 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9569 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9570 mirror, "mirror-rule");
9571 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9572 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9573 rule_id, RTE_UINT8);
9574 cmdline_parse_token_string_t cmd_mirror_link_what =
9575 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9576 what, "uplink-mirror#downlink-mirror");
9577 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9578 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9579 dstpool, "dst-pool");
9580 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9581 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9582 dstpool_id, RTE_UINT8);
9583 cmdline_parse_token_string_t cmd_mirror_link_on =
9584 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9588 cmd_set_mirror_link_parsed(void *parsed_result,
9589 __rte_unused struct cmdline *cl,
9590 __rte_unused void *data)
9593 struct cmd_set_mirror_link_result *res = parsed_result;
9594 struct rte_eth_mirror_conf mr_conf;
9596 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9597 if (!strcmp(res->what, "uplink-mirror"))
9598 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9600 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9602 mr_conf.dst_pool = res->dstpool_id;
9604 if (!strcmp(res->on, "on"))
9605 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9608 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9611 /* check the return value and print it if is < 0 */
9613 printf("mirror rule add error: (%s)\n", strerror(-ret));
9617 cmdline_parse_inst_t cmd_set_mirror_link = {
9618 .f = cmd_set_mirror_link_parsed,
9620 .help_str = "set port <port_id> mirror-rule <rule_id> "
9621 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9623 (void *)&cmd_mirror_link_set,
9624 (void *)&cmd_mirror_link_port,
9625 (void *)&cmd_mirror_link_portid,
9626 (void *)&cmd_mirror_link_mirror,
9627 (void *)&cmd_mirror_link_ruleid,
9628 (void *)&cmd_mirror_link_what,
9629 (void *)&cmd_mirror_link_dstpool,
9630 (void *)&cmd_mirror_link_poolid,
9631 (void *)&cmd_mirror_link_on,
9636 /* *** RESET VM MIRROR RULE *** */
9637 struct cmd_rm_mirror_rule_result {
9638 cmdline_fixed_string_t reset;
9639 cmdline_fixed_string_t port;
9641 cmdline_fixed_string_t mirror;
9645 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9646 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9648 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9649 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9651 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9652 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9653 port_id, RTE_UINT16);
9654 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9655 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9656 mirror, "mirror-rule");
9657 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9658 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9659 rule_id, RTE_UINT8);
9662 cmd_reset_mirror_rule_parsed(void *parsed_result,
9663 __rte_unused struct cmdline *cl,
9664 __rte_unused void *data)
9667 struct cmd_set_mirror_link_result *res = parsed_result;
9669 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9671 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9674 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9675 .f = cmd_reset_mirror_rule_parsed,
9677 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9679 (void *)&cmd_rm_mirror_rule_reset,
9680 (void *)&cmd_rm_mirror_rule_port,
9681 (void *)&cmd_rm_mirror_rule_portid,
9682 (void *)&cmd_rm_mirror_rule_mirror,
9683 (void *)&cmd_rm_mirror_rule_ruleid,
9688 /* ******************************************************************************** */
9690 struct cmd_dump_result {
9691 cmdline_fixed_string_t dump;
9695 dump_struct_sizes(void)
9697 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9698 DUMP_SIZE(struct rte_mbuf);
9699 DUMP_SIZE(struct rte_mempool);
9700 DUMP_SIZE(struct rte_ring);
9705 /* Dump the socket memory statistics on console */
9707 dump_socket_mem(FILE *f)
9709 struct rte_malloc_socket_stats socket_stats;
9714 unsigned int n_alloc = 0;
9715 unsigned int n_free = 0;
9716 static size_t last_allocs;
9717 static size_t last_total;
9720 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9721 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9722 !socket_stats.heap_totalsz_bytes)
9724 total += socket_stats.heap_totalsz_bytes;
9725 alloc += socket_stats.heap_allocsz_bytes;
9726 free += socket_stats.heap_freesz_bytes;
9727 n_alloc += socket_stats.alloc_count;
9728 n_free += socket_stats.free_count;
9730 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9732 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9733 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9734 (double)socket_stats.heap_allocsz_bytes * 100 /
9735 (double)socket_stats.heap_totalsz_bytes,
9736 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9737 socket_stats.alloc_count,
9738 socket_stats.free_count);
9741 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9742 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9743 total ? ((double)alloc * 100 / (double)total) : 0,
9744 (double)free / (1024 * 1024),
9747 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9748 ((double)total - (double)last_total) / (1024 * 1024),
9749 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9750 last_allocs = alloc;
9754 static void cmd_dump_parsed(void *parsed_result,
9755 __rte_unused struct cmdline *cl,
9756 __rte_unused void *data)
9758 struct cmd_dump_result *res = parsed_result;
9760 if (!strcmp(res->dump, "dump_physmem"))
9761 rte_dump_physmem_layout(stdout);
9762 else if (!strcmp(res->dump, "dump_socket_mem"))
9763 dump_socket_mem(stdout);
9764 else if (!strcmp(res->dump, "dump_memzone"))
9765 rte_memzone_dump(stdout);
9766 else if (!strcmp(res->dump, "dump_struct_sizes"))
9767 dump_struct_sizes();
9768 else if (!strcmp(res->dump, "dump_ring"))
9769 rte_ring_list_dump(stdout);
9770 else if (!strcmp(res->dump, "dump_mempool"))
9771 rte_mempool_list_dump(stdout);
9772 else if (!strcmp(res->dump, "dump_devargs"))
9773 rte_devargs_dump(stdout);
9774 else if (!strcmp(res->dump, "dump_log_types"))
9775 rte_log_dump(stdout);
9778 cmdline_parse_token_string_t cmd_dump_dump =
9779 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9783 "dump_struct_sizes#"
9789 cmdline_parse_inst_t cmd_dump = {
9790 .f = cmd_dump_parsed, /* function to call */
9791 .data = NULL, /* 2nd arg of func */
9792 .help_str = "Dump status",
9793 .tokens = { /* token list, NULL terminated */
9794 (void *)&cmd_dump_dump,
9799 /* ******************************************************************************** */
9801 struct cmd_dump_one_result {
9802 cmdline_fixed_string_t dump;
9803 cmdline_fixed_string_t name;
9806 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9807 __rte_unused void *data)
9809 struct cmd_dump_one_result *res = parsed_result;
9811 if (!strcmp(res->dump, "dump_ring")) {
9813 r = rte_ring_lookup(res->name);
9815 cmdline_printf(cl, "Cannot find ring\n");
9818 rte_ring_dump(stdout, r);
9819 } else if (!strcmp(res->dump, "dump_mempool")) {
9820 struct rte_mempool *mp;
9821 mp = rte_mempool_lookup(res->name);
9823 cmdline_printf(cl, "Cannot find mempool\n");
9826 rte_mempool_dump(stdout, mp);
9830 cmdline_parse_token_string_t cmd_dump_one_dump =
9831 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9832 "dump_ring#dump_mempool");
9834 cmdline_parse_token_string_t cmd_dump_one_name =
9835 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9837 cmdline_parse_inst_t cmd_dump_one = {
9838 .f = cmd_dump_one_parsed, /* function to call */
9839 .data = NULL, /* 2nd arg of func */
9840 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9841 .tokens = { /* token list, NULL terminated */
9842 (void *)&cmd_dump_one_dump,
9843 (void *)&cmd_dump_one_name,
9848 /* *** queue region set *** */
9849 struct cmd_queue_region_result {
9850 cmdline_fixed_string_t set;
9851 cmdline_fixed_string_t port;
9853 cmdline_fixed_string_t cmd;
9854 cmdline_fixed_string_t region;
9856 cmdline_fixed_string_t queue_start_index;
9858 cmdline_fixed_string_t queue_num;
9859 uint8_t queue_num_value;
9863 cmd_queue_region_parsed(void *parsed_result,
9864 __rte_unused struct cmdline *cl,
9865 __rte_unused void *data)
9867 struct cmd_queue_region_result *res = parsed_result;
9870 struct rte_pmd_i40e_queue_region_conf region_conf;
9871 enum rte_pmd_i40e_queue_region_op op_type;
9874 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9878 memset(®ion_conf, 0, sizeof(region_conf));
9879 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9880 region_conf.region_id = res->region_id;
9881 region_conf.queue_num = res->queue_num_value;
9882 region_conf.queue_start_index = res->queue_id;
9884 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9885 op_type, ®ion_conf);
9892 printf("function not implemented or supported\n");
9895 printf("queue region config error: (%s)\n", strerror(-ret));
9899 cmdline_parse_token_string_t cmd_queue_region_set =
9900 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9902 cmdline_parse_token_string_t cmd_queue_region_port =
9903 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9904 cmdline_parse_token_num_t cmd_queue_region_port_id =
9905 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9906 port_id, RTE_UINT16);
9907 cmdline_parse_token_string_t cmd_queue_region_cmd =
9908 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9909 cmd, "queue-region");
9910 cmdline_parse_token_string_t cmd_queue_region_id =
9911 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9912 region, "region_id");
9913 cmdline_parse_token_num_t cmd_queue_region_index =
9914 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9915 region_id, RTE_UINT8);
9916 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9917 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9918 queue_start_index, "queue_start_index");
9919 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9920 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9921 queue_id, RTE_UINT8);
9922 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9923 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9924 queue_num, "queue_num");
9925 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9926 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9927 queue_num_value, RTE_UINT8);
9929 cmdline_parse_inst_t cmd_queue_region = {
9930 .f = cmd_queue_region_parsed,
9932 .help_str = "set port <port_id> queue-region region_id <value> "
9933 "queue_start_index <value> queue_num <value>: Set a queue region",
9935 (void *)&cmd_queue_region_set,
9936 (void *)&cmd_queue_region_port,
9937 (void *)&cmd_queue_region_port_id,
9938 (void *)&cmd_queue_region_cmd,
9939 (void *)&cmd_queue_region_id,
9940 (void *)&cmd_queue_region_index,
9941 (void *)&cmd_queue_region_queue_start_index,
9942 (void *)&cmd_queue_region_queue_id,
9943 (void *)&cmd_queue_region_queue_num,
9944 (void *)&cmd_queue_region_queue_num_value,
9949 /* *** queue region and flowtype set *** */
9950 struct cmd_region_flowtype_result {
9951 cmdline_fixed_string_t set;
9952 cmdline_fixed_string_t port;
9954 cmdline_fixed_string_t cmd;
9955 cmdline_fixed_string_t region;
9957 cmdline_fixed_string_t flowtype;
9958 uint8_t flowtype_id;
9962 cmd_region_flowtype_parsed(void *parsed_result,
9963 __rte_unused struct cmdline *cl,
9964 __rte_unused void *data)
9966 struct cmd_region_flowtype_result *res = parsed_result;
9969 struct rte_pmd_i40e_queue_region_conf region_conf;
9970 enum rte_pmd_i40e_queue_region_op op_type;
9973 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9977 memset(®ion_conf, 0, sizeof(region_conf));
9979 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9980 region_conf.region_id = res->region_id;
9981 region_conf.hw_flowtype = res->flowtype_id;
9983 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9984 op_type, ®ion_conf);
9991 printf("function not implemented or supported\n");
9994 printf("region flowtype config error: (%s)\n", strerror(-ret));
9998 cmdline_parse_token_string_t cmd_region_flowtype_set =
9999 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10001 cmdline_parse_token_string_t cmd_region_flowtype_port =
10002 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10004 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10005 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10006 port_id, RTE_UINT16);
10007 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10008 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10009 cmd, "queue-region");
10010 cmdline_parse_token_string_t cmd_region_flowtype_index =
10011 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10012 region, "region_id");
10013 cmdline_parse_token_num_t cmd_region_flowtype_id =
10014 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10015 region_id, RTE_UINT8);
10016 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10017 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10018 flowtype, "flowtype");
10019 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10020 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10021 flowtype_id, RTE_UINT8);
10022 cmdline_parse_inst_t cmd_region_flowtype = {
10023 .f = cmd_region_flowtype_parsed,
10025 .help_str = "set port <port_id> queue-region region_id <value> "
10026 "flowtype <value>: Set a flowtype region index",
10028 (void *)&cmd_region_flowtype_set,
10029 (void *)&cmd_region_flowtype_port,
10030 (void *)&cmd_region_flowtype_port_index,
10031 (void *)&cmd_region_flowtype_cmd,
10032 (void *)&cmd_region_flowtype_index,
10033 (void *)&cmd_region_flowtype_id,
10034 (void *)&cmd_region_flowtype_flow_index,
10035 (void *)&cmd_region_flowtype_flow_id,
10040 /* *** User Priority (UP) to queue region (region_id) set *** */
10041 struct cmd_user_priority_region_result {
10042 cmdline_fixed_string_t set;
10043 cmdline_fixed_string_t port;
10045 cmdline_fixed_string_t cmd;
10046 cmdline_fixed_string_t user_priority;
10047 uint8_t user_priority_id;
10048 cmdline_fixed_string_t region;
10053 cmd_user_priority_region_parsed(void *parsed_result,
10054 __rte_unused struct cmdline *cl,
10055 __rte_unused void *data)
10057 struct cmd_user_priority_region_result *res = parsed_result;
10058 int ret = -ENOTSUP;
10059 #ifdef RTE_NET_I40E
10060 struct rte_pmd_i40e_queue_region_conf region_conf;
10061 enum rte_pmd_i40e_queue_region_op op_type;
10064 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10067 #ifdef RTE_NET_I40E
10068 memset(®ion_conf, 0, sizeof(region_conf));
10069 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10070 region_conf.user_priority = res->user_priority_id;
10071 region_conf.region_id = res->region_id;
10073 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10074 op_type, ®ion_conf);
10081 printf("function not implemented or supported\n");
10084 printf("user_priority region config error: (%s)\n",
10089 cmdline_parse_token_string_t cmd_user_priority_region_set =
10090 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10092 cmdline_parse_token_string_t cmd_user_priority_region_port =
10093 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10095 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10096 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10097 port_id, RTE_UINT16);
10098 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10099 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10100 cmd, "queue-region");
10101 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10102 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10103 user_priority, "UP");
10104 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10105 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10106 user_priority_id, RTE_UINT8);
10107 cmdline_parse_token_string_t cmd_user_priority_region_region =
10108 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10109 region, "region_id");
10110 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10111 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10112 region_id, RTE_UINT8);
10114 cmdline_parse_inst_t cmd_user_priority_region = {
10115 .f = cmd_user_priority_region_parsed,
10117 .help_str = "set port <port_id> queue-region UP <value> "
10118 "region_id <value>: Set the mapping of User Priority (UP) "
10119 "to queue region (region_id) ",
10121 (void *)&cmd_user_priority_region_set,
10122 (void *)&cmd_user_priority_region_port,
10123 (void *)&cmd_user_priority_region_port_index,
10124 (void *)&cmd_user_priority_region_cmd,
10125 (void *)&cmd_user_priority_region_UP,
10126 (void *)&cmd_user_priority_region_UP_id,
10127 (void *)&cmd_user_priority_region_region,
10128 (void *)&cmd_user_priority_region_region_id,
10133 /* *** flush all queue region related configuration *** */
10134 struct cmd_flush_queue_region_result {
10135 cmdline_fixed_string_t set;
10136 cmdline_fixed_string_t port;
10138 cmdline_fixed_string_t cmd;
10139 cmdline_fixed_string_t flush;
10140 cmdline_fixed_string_t what;
10144 cmd_flush_queue_region_parsed(void *parsed_result,
10145 __rte_unused struct cmdline *cl,
10146 __rte_unused void *data)
10148 struct cmd_flush_queue_region_result *res = parsed_result;
10149 int ret = -ENOTSUP;
10150 #ifdef RTE_NET_I40E
10151 struct rte_pmd_i40e_queue_region_conf region_conf;
10152 enum rte_pmd_i40e_queue_region_op op_type;
10155 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10158 #ifdef RTE_NET_I40E
10159 memset(®ion_conf, 0, sizeof(region_conf));
10161 if (strcmp(res->what, "on") == 0)
10162 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10164 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10166 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10167 op_type, ®ion_conf);
10174 printf("function not implemented or supported\n");
10177 printf("queue region config flush error: (%s)\n",
10182 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10183 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10185 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10186 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10188 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10189 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10190 port_id, RTE_UINT16);
10191 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10192 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10193 cmd, "queue-region");
10194 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10195 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10197 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10198 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10201 cmdline_parse_inst_t cmd_flush_queue_region = {
10202 .f = cmd_flush_queue_region_parsed,
10204 .help_str = "set port <port_id> queue-region flush on|off"
10205 ": flush all queue region related configuration",
10207 (void *)&cmd_flush_queue_region_set,
10208 (void *)&cmd_flush_queue_region_port,
10209 (void *)&cmd_flush_queue_region_port_index,
10210 (void *)&cmd_flush_queue_region_cmd,
10211 (void *)&cmd_flush_queue_region_flush,
10212 (void *)&cmd_flush_queue_region_what,
10217 /* *** get all queue region related configuration info *** */
10218 struct cmd_show_queue_region_info {
10219 cmdline_fixed_string_t show;
10220 cmdline_fixed_string_t port;
10222 cmdline_fixed_string_t cmd;
10226 cmd_show_queue_region_info_parsed(void *parsed_result,
10227 __rte_unused struct cmdline *cl,
10228 __rte_unused void *data)
10230 struct cmd_show_queue_region_info *res = parsed_result;
10231 int ret = -ENOTSUP;
10232 #ifdef RTE_NET_I40E
10233 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10234 enum rte_pmd_i40e_queue_region_op op_type;
10237 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10240 #ifdef RTE_NET_I40E
10241 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10243 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10245 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10246 op_type, &rte_pmd_regions);
10248 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10255 printf("function not implemented or supported\n");
10258 printf("queue region config info show error: (%s)\n",
10263 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10264 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10266 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10267 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10269 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10270 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10271 port_id, RTE_UINT16);
10272 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10273 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10274 cmd, "queue-region");
10276 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10277 .f = cmd_show_queue_region_info_parsed,
10279 .help_str = "show port <port_id> queue-region"
10280 ": show all queue region related configuration info",
10282 (void *)&cmd_show_queue_region_info_get,
10283 (void *)&cmd_show_queue_region_info_port,
10284 (void *)&cmd_show_queue_region_info_port_index,
10285 (void *)&cmd_show_queue_region_info_cmd,
10290 /* *** Filters Control *** */
10292 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10294 if ((ip_addr).family == AF_INET) \
10295 (ip) = (ip_addr).addr.ipv4.s_addr; \
10297 printf("invalid parameter.\n"); \
10302 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10304 if ((ip_addr).family == AF_INET6) \
10305 rte_memcpy(&(ip), \
10306 &((ip_addr).addr.ipv6), \
10307 sizeof(struct in6_addr)); \
10309 printf("invalid parameter.\n"); \
10314 #ifdef RTE_NET_I40E
10317 str2flowtype(char *string)
10320 static const struct {
10323 } flowtype_str[] = {
10324 {"raw", RTE_ETH_FLOW_RAW},
10325 {"ipv4", RTE_ETH_FLOW_IPV4},
10326 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10327 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10328 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10329 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10330 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10331 {"ipv6", RTE_ETH_FLOW_IPV6},
10332 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10333 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10334 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10335 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10336 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10337 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10340 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10341 if (!strcmp(flowtype_str[i].str, string))
10342 return flowtype_str[i].type;
10345 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10346 return (uint16_t)atoi(string);
10348 return RTE_ETH_FLOW_UNKNOWN;
10351 /* *** deal with flow director filter *** */
10352 struct cmd_flow_director_result {
10353 cmdline_fixed_string_t flow_director_filter;
10355 cmdline_fixed_string_t mode;
10356 cmdline_fixed_string_t mode_value;
10357 cmdline_fixed_string_t ops;
10358 cmdline_fixed_string_t flow;
10359 cmdline_fixed_string_t flow_type;
10360 cmdline_fixed_string_t drop;
10361 cmdline_fixed_string_t queue;
10363 cmdline_fixed_string_t fd_id;
10364 uint32_t fd_id_value;
10365 cmdline_fixed_string_t packet;
10370 cmd_flow_director_filter_parsed(void *parsed_result,
10371 __rte_unused struct cmdline *cl,
10372 __rte_unused void *data)
10374 struct cmd_flow_director_result *res = parsed_result;
10376 struct rte_pmd_i40e_flow_type_mapping
10377 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10378 struct rte_pmd_i40e_pkt_template_conf conf;
10379 uint16_t flow_type = str2flowtype(res->flow_type);
10380 uint16_t i, port = res->port_id;
10383 memset(&conf, 0, sizeof(conf));
10385 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10386 printf("Invalid flow type specified.\n");
10389 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10393 if (mapping[flow_type].pctype == 0ULL) {
10394 printf("Invalid flow type specified.\n");
10397 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10398 if (mapping[flow_type].pctype & (1ULL << i)) {
10399 conf.input.pctype = i;
10404 conf.input.packet = open_file(res->filepath,
10405 &conf.input.length);
10406 if (!conf.input.packet)
10408 if (!strcmp(res->drop, "drop"))
10409 conf.action.behavior =
10410 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10412 conf.action.behavior =
10413 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10414 conf.action.report_status =
10415 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10416 conf.action.rx_queue = res->queue_id;
10417 conf.soft_id = res->fd_id_value;
10418 add = strcmp(res->ops, "del") ? 1 : 0;
10419 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10423 printf("flow director config error: (%s)\n",
10425 close_file(conf.input.packet);
10428 cmdline_parse_token_string_t cmd_flow_director_filter =
10429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10430 flow_director_filter, "flow_director_filter");
10431 cmdline_parse_token_num_t cmd_flow_director_port_id =
10432 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10433 port_id, RTE_UINT16);
10434 cmdline_parse_token_string_t cmd_flow_director_ops =
10435 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10436 ops, "add#del#update");
10437 cmdline_parse_token_string_t cmd_flow_director_flow =
10438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10440 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10441 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10443 cmdline_parse_token_string_t cmd_flow_director_drop =
10444 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10446 cmdline_parse_token_string_t cmd_flow_director_queue =
10447 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10449 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10450 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10451 queue_id, RTE_UINT16);
10452 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10453 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10455 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10456 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10457 fd_id_value, RTE_UINT32);
10459 cmdline_parse_token_string_t cmd_flow_director_mode =
10460 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10462 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10463 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10464 mode_value, "raw");
10465 cmdline_parse_token_string_t cmd_flow_director_packet =
10466 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10468 cmdline_parse_token_string_t cmd_flow_director_filepath =
10469 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10472 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10473 .f = cmd_flow_director_filter_parsed,
10475 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10476 "director entry on NIC",
10478 (void *)&cmd_flow_director_filter,
10479 (void *)&cmd_flow_director_port_id,
10480 (void *)&cmd_flow_director_mode,
10481 (void *)&cmd_flow_director_mode_raw,
10482 (void *)&cmd_flow_director_ops,
10483 (void *)&cmd_flow_director_flow,
10484 (void *)&cmd_flow_director_flow_type,
10485 (void *)&cmd_flow_director_drop,
10486 (void *)&cmd_flow_director_queue,
10487 (void *)&cmd_flow_director_queue_id,
10488 (void *)&cmd_flow_director_fd_id,
10489 (void *)&cmd_flow_director_fd_id_value,
10490 (void *)&cmd_flow_director_packet,
10491 (void *)&cmd_flow_director_filepath,
10496 #endif /* RTE_NET_I40E */
10498 /* *** deal with flow director mask *** */
10499 struct cmd_flow_director_mask_result {
10500 cmdline_fixed_string_t flow_director_mask;
10502 cmdline_fixed_string_t mode;
10503 cmdline_fixed_string_t mode_value;
10504 cmdline_fixed_string_t vlan;
10505 uint16_t vlan_mask;
10506 cmdline_fixed_string_t src_mask;
10507 cmdline_ipaddr_t ipv4_src;
10508 cmdline_ipaddr_t ipv6_src;
10510 cmdline_fixed_string_t dst_mask;
10511 cmdline_ipaddr_t ipv4_dst;
10512 cmdline_ipaddr_t ipv6_dst;
10514 cmdline_fixed_string_t mac;
10515 uint8_t mac_addr_byte_mask;
10516 cmdline_fixed_string_t tunnel_id;
10517 uint32_t tunnel_id_mask;
10518 cmdline_fixed_string_t tunnel_type;
10519 uint8_t tunnel_type_mask;
10523 cmd_flow_director_mask_parsed(void *parsed_result,
10524 __rte_unused struct cmdline *cl,
10525 __rte_unused void *data)
10527 struct cmd_flow_director_mask_result *res = parsed_result;
10528 struct rte_eth_fdir_masks *mask;
10529 struct rte_port *port;
10531 port = &ports[res->port_id];
10532 /** Check if the port is not started **/
10533 if (port->port_status != RTE_PORT_STOPPED) {
10534 printf("Please stop port %d first\n", res->port_id);
10538 mask = &port->dev_conf.fdir_conf.mask;
10540 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10541 if (strcmp(res->mode_value, "MAC-VLAN")) {
10542 printf("Please set mode to MAC-VLAN.\n");
10546 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10547 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10548 if (strcmp(res->mode_value, "Tunnel")) {
10549 printf("Please set mode to Tunnel.\n");
10553 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10554 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10555 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10556 mask->tunnel_type_mask = res->tunnel_type_mask;
10558 if (strcmp(res->mode_value, "IP")) {
10559 printf("Please set mode to IP.\n");
10563 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10564 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10565 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10566 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10567 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10568 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10569 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10572 cmd_reconfig_device_queue(res->port_id, 1, 1);
10575 cmdline_parse_token_string_t cmd_flow_director_mask =
10576 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10577 flow_director_mask, "flow_director_mask");
10578 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10579 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10580 port_id, RTE_UINT16);
10581 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10582 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10584 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10585 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10586 vlan_mask, RTE_UINT16);
10587 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10588 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10589 src_mask, "src_mask");
10590 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10591 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10593 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10594 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10596 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10597 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10598 port_src, RTE_UINT16);
10599 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10600 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10601 dst_mask, "dst_mask");
10602 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10603 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10605 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10606 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10608 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10609 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10610 port_dst, RTE_UINT16);
10612 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10613 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10615 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10616 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10618 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10619 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10620 mode_value, "MAC-VLAN");
10621 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10622 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10623 mode_value, "Tunnel");
10624 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10625 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10627 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10628 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10629 mac_addr_byte_mask, RTE_UINT8);
10630 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10631 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10632 tunnel_type, "tunnel-type");
10633 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10634 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10635 tunnel_type_mask, RTE_UINT8);
10636 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10637 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10638 tunnel_id, "tunnel-id");
10639 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10640 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10641 tunnel_id_mask, RTE_UINT32);
10643 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10644 .f = cmd_flow_director_mask_parsed,
10646 .help_str = "flow_director_mask ... : "
10647 "Set IP mode 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_ip,
10653 (void *)&cmd_flow_director_mask_vlan,
10654 (void *)&cmd_flow_director_mask_vlan_value,
10655 (void *)&cmd_flow_director_mask_src,
10656 (void *)&cmd_flow_director_mask_ipv4_src,
10657 (void *)&cmd_flow_director_mask_ipv6_src,
10658 (void *)&cmd_flow_director_mask_port_src,
10659 (void *)&cmd_flow_director_mask_dst,
10660 (void *)&cmd_flow_director_mask_ipv4_dst,
10661 (void *)&cmd_flow_director_mask_ipv6_dst,
10662 (void *)&cmd_flow_director_mask_port_dst,
10667 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10668 .f = cmd_flow_director_mask_parsed,
10670 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10671 "flow director's mask on NIC",
10673 (void *)&cmd_flow_director_mask,
10674 (void *)&cmd_flow_director_mask_port_id,
10675 (void *)&cmd_flow_director_mask_mode,
10676 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10677 (void *)&cmd_flow_director_mask_vlan,
10678 (void *)&cmd_flow_director_mask_vlan_value,
10683 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10684 .f = cmd_flow_director_mask_parsed,
10686 .help_str = "flow_director_mask ... : Set tunnel mode "
10687 "flow director's mask on NIC",
10689 (void *)&cmd_flow_director_mask,
10690 (void *)&cmd_flow_director_mask_port_id,
10691 (void *)&cmd_flow_director_mask_mode,
10692 (void *)&cmd_flow_director_mask_mode_tunnel,
10693 (void *)&cmd_flow_director_mask_vlan,
10694 (void *)&cmd_flow_director_mask_vlan_value,
10695 (void *)&cmd_flow_director_mask_mac,
10696 (void *)&cmd_flow_director_mask_mac_value,
10697 (void *)&cmd_flow_director_mask_tunnel_type,
10698 (void *)&cmd_flow_director_mask_tunnel_type_value,
10699 (void *)&cmd_flow_director_mask_tunnel_id,
10700 (void *)&cmd_flow_director_mask_tunnel_id_value,
10705 /* *** deal with flow director flexible payload configuration *** */
10706 struct cmd_flow_director_flexpayload_result {
10707 cmdline_fixed_string_t flow_director_flexpayload;
10709 cmdline_fixed_string_t payload_layer;
10710 cmdline_fixed_string_t payload_cfg;
10714 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10717 const char *p, *p0 = q_arg;
10719 unsigned long int_fld;
10720 char *str_fld[max_num];
10725 p = strchr(p0, '(');
10729 p0 = strchr(p, ')');
10734 if (size >= sizeof(s))
10737 snprintf(s, sizeof(s), "%.*s", size, p);
10738 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10739 if (ret < 0 || ret > max_num)
10741 for (i = 0; i < ret; i++) {
10743 int_fld = strtoul(str_fld[i], &end, 0);
10744 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10746 offsets[i] = (uint16_t)int_fld;
10752 cmd_flow_director_flxpld_parsed(void *parsed_result,
10753 __rte_unused struct cmdline *cl,
10754 __rte_unused void *data)
10756 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10757 struct rte_eth_flex_payload_cfg flex_cfg;
10758 struct rte_port *port;
10761 port = &ports[res->port_id];
10762 /** Check if the port is not started **/
10763 if (port->port_status != RTE_PORT_STOPPED) {
10764 printf("Please stop port %d first\n", res->port_id);
10768 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10770 if (!strcmp(res->payload_layer, "raw"))
10771 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10772 else if (!strcmp(res->payload_layer, "l2"))
10773 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10774 else if (!strcmp(res->payload_layer, "l3"))
10775 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10776 else if (!strcmp(res->payload_layer, "l4"))
10777 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10779 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10780 RTE_ETH_FDIR_MAX_FLEXLEN);
10782 printf("error: Cannot parse flex payload input.\n");
10786 fdir_set_flex_payload(res->port_id, &flex_cfg);
10787 cmd_reconfig_device_queue(res->port_id, 1, 1);
10790 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10792 flow_director_flexpayload,
10793 "flow_director_flex_payload");
10794 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10795 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10796 port_id, RTE_UINT16);
10797 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10798 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10799 payload_layer, "raw#l2#l3#l4");
10800 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10802 payload_cfg, NULL);
10804 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10805 .f = cmd_flow_director_flxpld_parsed,
10807 .help_str = "flow_director_flexpayload ... : "
10808 "Set flow director's flex payload on NIC",
10810 (void *)&cmd_flow_director_flexpayload,
10811 (void *)&cmd_flow_director_flexpayload_port_id,
10812 (void *)&cmd_flow_director_flexpayload_payload_layer,
10813 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10818 /* Generic flow interface command. */
10819 extern cmdline_parse_inst_t cmd_flow;
10821 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10822 struct cmd_mcast_addr_result {
10823 cmdline_fixed_string_t mcast_addr_cmd;
10824 cmdline_fixed_string_t what;
10826 struct rte_ether_addr mc_addr;
10829 static void cmd_mcast_addr_parsed(void *parsed_result,
10830 __rte_unused struct cmdline *cl,
10831 __rte_unused void *data)
10833 struct cmd_mcast_addr_result *res = parsed_result;
10835 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10836 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10837 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10838 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10839 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10842 if (strcmp(res->what, "add") == 0)
10843 mcast_addr_add(res->port_num, &res->mc_addr);
10845 mcast_addr_remove(res->port_num, &res->mc_addr);
10848 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10849 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10850 mcast_addr_cmd, "mcast_addr");
10851 cmdline_parse_token_string_t cmd_mcast_addr_what =
10852 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10854 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10855 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10857 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10858 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10860 cmdline_parse_inst_t cmd_mcast_addr = {
10861 .f = cmd_mcast_addr_parsed,
10863 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10864 "Add/Remove multicast MAC address on port_id",
10866 (void *)&cmd_mcast_addr_cmd,
10867 (void *)&cmd_mcast_addr_what,
10868 (void *)&cmd_mcast_addr_portnum,
10869 (void *)&cmd_mcast_addr_addr,
10874 /* vf vlan anti spoof configuration */
10876 /* Common result structure for vf vlan anti spoof */
10877 struct cmd_vf_vlan_anti_spoof_result {
10878 cmdline_fixed_string_t set;
10879 cmdline_fixed_string_t vf;
10880 cmdline_fixed_string_t vlan;
10881 cmdline_fixed_string_t antispoof;
10884 cmdline_fixed_string_t on_off;
10887 /* Common CLI fields for vf vlan anti spoof enable disable */
10888 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10889 TOKEN_STRING_INITIALIZER
10890 (struct cmd_vf_vlan_anti_spoof_result,
10892 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10893 TOKEN_STRING_INITIALIZER
10894 (struct cmd_vf_vlan_anti_spoof_result,
10896 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10897 TOKEN_STRING_INITIALIZER
10898 (struct cmd_vf_vlan_anti_spoof_result,
10900 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10901 TOKEN_STRING_INITIALIZER
10902 (struct cmd_vf_vlan_anti_spoof_result,
10903 antispoof, "antispoof");
10904 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10905 TOKEN_NUM_INITIALIZER
10906 (struct cmd_vf_vlan_anti_spoof_result,
10907 port_id, RTE_UINT16);
10908 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10909 TOKEN_NUM_INITIALIZER
10910 (struct cmd_vf_vlan_anti_spoof_result,
10911 vf_id, RTE_UINT32);
10912 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10913 TOKEN_STRING_INITIALIZER
10914 (struct cmd_vf_vlan_anti_spoof_result,
10918 cmd_set_vf_vlan_anti_spoof_parsed(
10919 void *parsed_result,
10920 __rte_unused struct cmdline *cl,
10921 __rte_unused void *data)
10923 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10924 int ret = -ENOTSUP;
10926 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10928 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10931 #ifdef RTE_NET_IXGBE
10932 if (ret == -ENOTSUP)
10933 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10934 res->vf_id, is_on);
10936 #ifdef RTE_NET_I40E
10937 if (ret == -ENOTSUP)
10938 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10939 res->vf_id, is_on);
10941 #ifdef RTE_NET_BNXT
10942 if (ret == -ENOTSUP)
10943 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10944 res->vf_id, is_on);
10951 printf("invalid vf_id %d\n", res->vf_id);
10954 printf("invalid port_id %d\n", res->port_id);
10957 printf("function not implemented\n");
10960 printf("programming error: (%s)\n", strerror(-ret));
10964 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10965 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10967 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10969 (void *)&cmd_vf_vlan_anti_spoof_set,
10970 (void *)&cmd_vf_vlan_anti_spoof_vf,
10971 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10972 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10973 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10974 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10975 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10980 /* vf mac anti spoof configuration */
10982 /* Common result structure for vf mac anti spoof */
10983 struct cmd_vf_mac_anti_spoof_result {
10984 cmdline_fixed_string_t set;
10985 cmdline_fixed_string_t vf;
10986 cmdline_fixed_string_t mac;
10987 cmdline_fixed_string_t antispoof;
10990 cmdline_fixed_string_t on_off;
10993 /* Common CLI fields for vf mac anti spoof enable disable */
10994 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10995 TOKEN_STRING_INITIALIZER
10996 (struct cmd_vf_mac_anti_spoof_result,
10998 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10999 TOKEN_STRING_INITIALIZER
11000 (struct cmd_vf_mac_anti_spoof_result,
11002 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11003 TOKEN_STRING_INITIALIZER
11004 (struct cmd_vf_mac_anti_spoof_result,
11006 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11007 TOKEN_STRING_INITIALIZER
11008 (struct cmd_vf_mac_anti_spoof_result,
11009 antispoof, "antispoof");
11010 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11011 TOKEN_NUM_INITIALIZER
11012 (struct cmd_vf_mac_anti_spoof_result,
11013 port_id, RTE_UINT16);
11014 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11015 TOKEN_NUM_INITIALIZER
11016 (struct cmd_vf_mac_anti_spoof_result,
11017 vf_id, RTE_UINT32);
11018 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11019 TOKEN_STRING_INITIALIZER
11020 (struct cmd_vf_mac_anti_spoof_result,
11024 cmd_set_vf_mac_anti_spoof_parsed(
11025 void *parsed_result,
11026 __rte_unused struct cmdline *cl,
11027 __rte_unused void *data)
11029 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11030 int ret = -ENOTSUP;
11032 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11034 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11037 #ifdef RTE_NET_IXGBE
11038 if (ret == -ENOTSUP)
11039 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11040 res->vf_id, is_on);
11042 #ifdef RTE_NET_I40E
11043 if (ret == -ENOTSUP)
11044 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11045 res->vf_id, is_on);
11047 #ifdef RTE_NET_BNXT
11048 if (ret == -ENOTSUP)
11049 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11050 res->vf_id, is_on);
11057 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11060 printf("invalid port_id %d\n", res->port_id);
11063 printf("function not implemented\n");
11066 printf("programming error: (%s)\n", strerror(-ret));
11070 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11071 .f = cmd_set_vf_mac_anti_spoof_parsed,
11073 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11075 (void *)&cmd_vf_mac_anti_spoof_set,
11076 (void *)&cmd_vf_mac_anti_spoof_vf,
11077 (void *)&cmd_vf_mac_anti_spoof_mac,
11078 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11079 (void *)&cmd_vf_mac_anti_spoof_port_id,
11080 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11081 (void *)&cmd_vf_mac_anti_spoof_on_off,
11086 /* vf vlan strip queue configuration */
11088 /* Common result structure for vf mac anti spoof */
11089 struct cmd_vf_vlan_stripq_result {
11090 cmdline_fixed_string_t set;
11091 cmdline_fixed_string_t vf;
11092 cmdline_fixed_string_t vlan;
11093 cmdline_fixed_string_t stripq;
11096 cmdline_fixed_string_t on_off;
11099 /* Common CLI fields for vf vlan strip enable disable */
11100 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11101 TOKEN_STRING_INITIALIZER
11102 (struct cmd_vf_vlan_stripq_result,
11104 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11105 TOKEN_STRING_INITIALIZER
11106 (struct cmd_vf_vlan_stripq_result,
11108 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11109 TOKEN_STRING_INITIALIZER
11110 (struct cmd_vf_vlan_stripq_result,
11112 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11113 TOKEN_STRING_INITIALIZER
11114 (struct cmd_vf_vlan_stripq_result,
11116 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11117 TOKEN_NUM_INITIALIZER
11118 (struct cmd_vf_vlan_stripq_result,
11119 port_id, RTE_UINT16);
11120 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11121 TOKEN_NUM_INITIALIZER
11122 (struct cmd_vf_vlan_stripq_result,
11123 vf_id, RTE_UINT16);
11124 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11125 TOKEN_STRING_INITIALIZER
11126 (struct cmd_vf_vlan_stripq_result,
11130 cmd_set_vf_vlan_stripq_parsed(
11131 void *parsed_result,
11132 __rte_unused struct cmdline *cl,
11133 __rte_unused void *data)
11135 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11136 int ret = -ENOTSUP;
11138 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11140 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11143 #ifdef RTE_NET_IXGBE
11144 if (ret == -ENOTSUP)
11145 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11146 res->vf_id, is_on);
11148 #ifdef RTE_NET_I40E
11149 if (ret == -ENOTSUP)
11150 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11151 res->vf_id, is_on);
11153 #ifdef RTE_NET_BNXT
11154 if (ret == -ENOTSUP)
11155 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11156 res->vf_id, is_on);
11163 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11166 printf("invalid port_id %d\n", res->port_id);
11169 printf("function not implemented\n");
11172 printf("programming error: (%s)\n", strerror(-ret));
11176 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11177 .f = cmd_set_vf_vlan_stripq_parsed,
11179 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11181 (void *)&cmd_vf_vlan_stripq_set,
11182 (void *)&cmd_vf_vlan_stripq_vf,
11183 (void *)&cmd_vf_vlan_stripq_vlan,
11184 (void *)&cmd_vf_vlan_stripq_stripq,
11185 (void *)&cmd_vf_vlan_stripq_port_id,
11186 (void *)&cmd_vf_vlan_stripq_vf_id,
11187 (void *)&cmd_vf_vlan_stripq_on_off,
11192 /* vf vlan insert configuration */
11194 /* Common result structure for vf vlan insert */
11195 struct cmd_vf_vlan_insert_result {
11196 cmdline_fixed_string_t set;
11197 cmdline_fixed_string_t vf;
11198 cmdline_fixed_string_t vlan;
11199 cmdline_fixed_string_t insert;
11205 /* Common CLI fields for vf vlan insert enable disable */
11206 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11207 TOKEN_STRING_INITIALIZER
11208 (struct cmd_vf_vlan_insert_result,
11210 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11211 TOKEN_STRING_INITIALIZER
11212 (struct cmd_vf_vlan_insert_result,
11214 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11215 TOKEN_STRING_INITIALIZER
11216 (struct cmd_vf_vlan_insert_result,
11218 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11219 TOKEN_STRING_INITIALIZER
11220 (struct cmd_vf_vlan_insert_result,
11222 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11223 TOKEN_NUM_INITIALIZER
11224 (struct cmd_vf_vlan_insert_result,
11225 port_id, RTE_UINT16);
11226 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11227 TOKEN_NUM_INITIALIZER
11228 (struct cmd_vf_vlan_insert_result,
11229 vf_id, RTE_UINT16);
11230 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11231 TOKEN_NUM_INITIALIZER
11232 (struct cmd_vf_vlan_insert_result,
11233 vlan_id, RTE_UINT16);
11236 cmd_set_vf_vlan_insert_parsed(
11237 void *parsed_result,
11238 __rte_unused struct cmdline *cl,
11239 __rte_unused void *data)
11241 struct cmd_vf_vlan_insert_result *res = parsed_result;
11242 int ret = -ENOTSUP;
11244 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11247 #ifdef RTE_NET_IXGBE
11248 if (ret == -ENOTSUP)
11249 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11252 #ifdef RTE_NET_I40E
11253 if (ret == -ENOTSUP)
11254 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11257 #ifdef RTE_NET_BNXT
11258 if (ret == -ENOTSUP)
11259 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11267 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11270 printf("invalid port_id %d\n", res->port_id);
11273 printf("function not implemented\n");
11276 printf("programming error: (%s)\n", strerror(-ret));
11280 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11281 .f = cmd_set_vf_vlan_insert_parsed,
11283 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11285 (void *)&cmd_vf_vlan_insert_set,
11286 (void *)&cmd_vf_vlan_insert_vf,
11287 (void *)&cmd_vf_vlan_insert_vlan,
11288 (void *)&cmd_vf_vlan_insert_insert,
11289 (void *)&cmd_vf_vlan_insert_port_id,
11290 (void *)&cmd_vf_vlan_insert_vf_id,
11291 (void *)&cmd_vf_vlan_insert_vlan_id,
11296 /* tx loopback configuration */
11298 /* Common result structure for tx loopback */
11299 struct cmd_tx_loopback_result {
11300 cmdline_fixed_string_t set;
11301 cmdline_fixed_string_t tx;
11302 cmdline_fixed_string_t loopback;
11304 cmdline_fixed_string_t on_off;
11307 /* Common CLI fields for tx loopback enable disable */
11308 cmdline_parse_token_string_t cmd_tx_loopback_set =
11309 TOKEN_STRING_INITIALIZER
11310 (struct cmd_tx_loopback_result,
11312 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11313 TOKEN_STRING_INITIALIZER
11314 (struct cmd_tx_loopback_result,
11316 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11317 TOKEN_STRING_INITIALIZER
11318 (struct cmd_tx_loopback_result,
11319 loopback, "loopback");
11320 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11321 TOKEN_NUM_INITIALIZER
11322 (struct cmd_tx_loopback_result,
11323 port_id, RTE_UINT16);
11324 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11325 TOKEN_STRING_INITIALIZER
11326 (struct cmd_tx_loopback_result,
11330 cmd_set_tx_loopback_parsed(
11331 void *parsed_result,
11332 __rte_unused struct cmdline *cl,
11333 __rte_unused void *data)
11335 struct cmd_tx_loopback_result *res = parsed_result;
11336 int ret = -ENOTSUP;
11338 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11340 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11343 #ifdef RTE_NET_IXGBE
11344 if (ret == -ENOTSUP)
11345 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11347 #ifdef RTE_NET_I40E
11348 if (ret == -ENOTSUP)
11349 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11351 #ifdef RTE_NET_BNXT
11352 if (ret == -ENOTSUP)
11353 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11355 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11356 if (ret == -ENOTSUP)
11357 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11364 printf("invalid is_on %d\n", is_on);
11367 printf("invalid port_id %d\n", res->port_id);
11370 printf("function not implemented\n");
11373 printf("programming error: (%s)\n", strerror(-ret));
11377 cmdline_parse_inst_t cmd_set_tx_loopback = {
11378 .f = cmd_set_tx_loopback_parsed,
11380 .help_str = "set tx loopback <port_id> on|off",
11382 (void *)&cmd_tx_loopback_set,
11383 (void *)&cmd_tx_loopback_tx,
11384 (void *)&cmd_tx_loopback_loopback,
11385 (void *)&cmd_tx_loopback_port_id,
11386 (void *)&cmd_tx_loopback_on_off,
11391 /* all queues drop enable configuration */
11393 /* Common result structure for all queues drop enable */
11394 struct cmd_all_queues_drop_en_result {
11395 cmdline_fixed_string_t set;
11396 cmdline_fixed_string_t all;
11397 cmdline_fixed_string_t queues;
11398 cmdline_fixed_string_t drop;
11400 cmdline_fixed_string_t on_off;
11403 /* Common CLI fields for tx loopback enable disable */
11404 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11405 TOKEN_STRING_INITIALIZER
11406 (struct cmd_all_queues_drop_en_result,
11408 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11409 TOKEN_STRING_INITIALIZER
11410 (struct cmd_all_queues_drop_en_result,
11412 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11413 TOKEN_STRING_INITIALIZER
11414 (struct cmd_all_queues_drop_en_result,
11416 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11417 TOKEN_STRING_INITIALIZER
11418 (struct cmd_all_queues_drop_en_result,
11420 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11421 TOKEN_NUM_INITIALIZER
11422 (struct cmd_all_queues_drop_en_result,
11423 port_id, RTE_UINT16);
11424 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11425 TOKEN_STRING_INITIALIZER
11426 (struct cmd_all_queues_drop_en_result,
11430 cmd_set_all_queues_drop_en_parsed(
11431 void *parsed_result,
11432 __rte_unused struct cmdline *cl,
11433 __rte_unused void *data)
11435 struct cmd_all_queues_drop_en_result *res = parsed_result;
11436 int ret = -ENOTSUP;
11437 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11439 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11442 #ifdef RTE_NET_IXGBE
11443 if (ret == -ENOTSUP)
11444 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11446 #ifdef RTE_NET_BNXT
11447 if (ret == -ENOTSUP)
11448 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11454 printf("invalid is_on %d\n", is_on);
11457 printf("invalid port_id %d\n", res->port_id);
11460 printf("function not implemented\n");
11463 printf("programming error: (%s)\n", strerror(-ret));
11467 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11468 .f = cmd_set_all_queues_drop_en_parsed,
11470 .help_str = "set all queues drop <port_id> on|off",
11472 (void *)&cmd_all_queues_drop_en_set,
11473 (void *)&cmd_all_queues_drop_en_all,
11474 (void *)&cmd_all_queues_drop_en_queues,
11475 (void *)&cmd_all_queues_drop_en_drop,
11476 (void *)&cmd_all_queues_drop_en_port_id,
11477 (void *)&cmd_all_queues_drop_en_on_off,
11482 /* vf split drop enable configuration */
11484 /* Common result structure for vf split drop enable */
11485 struct cmd_vf_split_drop_en_result {
11486 cmdline_fixed_string_t set;
11487 cmdline_fixed_string_t vf;
11488 cmdline_fixed_string_t split;
11489 cmdline_fixed_string_t drop;
11492 cmdline_fixed_string_t on_off;
11495 /* Common CLI fields for vf split drop enable disable */
11496 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11497 TOKEN_STRING_INITIALIZER
11498 (struct cmd_vf_split_drop_en_result,
11500 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11501 TOKEN_STRING_INITIALIZER
11502 (struct cmd_vf_split_drop_en_result,
11504 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11505 TOKEN_STRING_INITIALIZER
11506 (struct cmd_vf_split_drop_en_result,
11508 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11509 TOKEN_STRING_INITIALIZER
11510 (struct cmd_vf_split_drop_en_result,
11512 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11513 TOKEN_NUM_INITIALIZER
11514 (struct cmd_vf_split_drop_en_result,
11515 port_id, RTE_UINT16);
11516 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11517 TOKEN_NUM_INITIALIZER
11518 (struct cmd_vf_split_drop_en_result,
11519 vf_id, RTE_UINT16);
11520 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11521 TOKEN_STRING_INITIALIZER
11522 (struct cmd_vf_split_drop_en_result,
11526 cmd_set_vf_split_drop_en_parsed(
11527 void *parsed_result,
11528 __rte_unused struct cmdline *cl,
11529 __rte_unused void *data)
11531 struct cmd_vf_split_drop_en_result *res = parsed_result;
11532 int ret = -ENOTSUP;
11533 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11535 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11538 #ifdef RTE_NET_IXGBE
11539 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11546 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11549 printf("invalid port_id %d\n", res->port_id);
11552 printf("not supported on port %d\n", res->port_id);
11555 printf("programming error: (%s)\n", strerror(-ret));
11559 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11560 .f = cmd_set_vf_split_drop_en_parsed,
11562 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11564 (void *)&cmd_vf_split_drop_en_set,
11565 (void *)&cmd_vf_split_drop_en_vf,
11566 (void *)&cmd_vf_split_drop_en_split,
11567 (void *)&cmd_vf_split_drop_en_drop,
11568 (void *)&cmd_vf_split_drop_en_port_id,
11569 (void *)&cmd_vf_split_drop_en_vf_id,
11570 (void *)&cmd_vf_split_drop_en_on_off,
11575 /* vf mac address configuration */
11577 /* Common result structure for vf mac address */
11578 struct cmd_set_vf_mac_addr_result {
11579 cmdline_fixed_string_t set;
11580 cmdline_fixed_string_t vf;
11581 cmdline_fixed_string_t mac;
11582 cmdline_fixed_string_t addr;
11585 struct rte_ether_addr mac_addr;
11589 /* Common CLI fields for vf split drop enable disable */
11590 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11591 TOKEN_STRING_INITIALIZER
11592 (struct cmd_set_vf_mac_addr_result,
11594 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11595 TOKEN_STRING_INITIALIZER
11596 (struct cmd_set_vf_mac_addr_result,
11598 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11599 TOKEN_STRING_INITIALIZER
11600 (struct cmd_set_vf_mac_addr_result,
11602 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11603 TOKEN_STRING_INITIALIZER
11604 (struct cmd_set_vf_mac_addr_result,
11606 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11607 TOKEN_NUM_INITIALIZER
11608 (struct cmd_set_vf_mac_addr_result,
11609 port_id, RTE_UINT16);
11610 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11611 TOKEN_NUM_INITIALIZER
11612 (struct cmd_set_vf_mac_addr_result,
11613 vf_id, RTE_UINT16);
11614 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11615 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11619 cmd_set_vf_mac_addr_parsed(
11620 void *parsed_result,
11621 __rte_unused struct cmdline *cl,
11622 __rte_unused void *data)
11624 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11625 int ret = -ENOTSUP;
11627 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11630 #ifdef RTE_NET_IXGBE
11631 if (ret == -ENOTSUP)
11632 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11635 #ifdef RTE_NET_I40E
11636 if (ret == -ENOTSUP)
11637 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11640 #ifdef RTE_NET_BNXT
11641 if (ret == -ENOTSUP)
11642 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11650 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11653 printf("invalid port_id %d\n", res->port_id);
11656 printf("function not implemented\n");
11659 printf("programming error: (%s)\n", strerror(-ret));
11663 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11664 .f = cmd_set_vf_mac_addr_parsed,
11666 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11668 (void *)&cmd_set_vf_mac_addr_set,
11669 (void *)&cmd_set_vf_mac_addr_vf,
11670 (void *)&cmd_set_vf_mac_addr_mac,
11671 (void *)&cmd_set_vf_mac_addr_addr,
11672 (void *)&cmd_set_vf_mac_addr_port_id,
11673 (void *)&cmd_set_vf_mac_addr_vf_id,
11674 (void *)&cmd_set_vf_mac_addr_mac_addr,
11679 /* MACsec configuration */
11681 /* Common result structure for MACsec offload enable */
11682 struct cmd_macsec_offload_on_result {
11683 cmdline_fixed_string_t set;
11684 cmdline_fixed_string_t macsec;
11685 cmdline_fixed_string_t offload;
11687 cmdline_fixed_string_t on;
11688 cmdline_fixed_string_t encrypt;
11689 cmdline_fixed_string_t en_on_off;
11690 cmdline_fixed_string_t replay_protect;
11691 cmdline_fixed_string_t rp_on_off;
11694 /* Common CLI fields for MACsec offload disable */
11695 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11696 TOKEN_STRING_INITIALIZER
11697 (struct cmd_macsec_offload_on_result,
11699 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11700 TOKEN_STRING_INITIALIZER
11701 (struct cmd_macsec_offload_on_result,
11703 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11704 TOKEN_STRING_INITIALIZER
11705 (struct cmd_macsec_offload_on_result,
11706 offload, "offload");
11707 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11708 TOKEN_NUM_INITIALIZER
11709 (struct cmd_macsec_offload_on_result,
11710 port_id, RTE_UINT16);
11711 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11712 TOKEN_STRING_INITIALIZER
11713 (struct cmd_macsec_offload_on_result,
11715 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11716 TOKEN_STRING_INITIALIZER
11717 (struct cmd_macsec_offload_on_result,
11718 encrypt, "encrypt");
11719 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11720 TOKEN_STRING_INITIALIZER
11721 (struct cmd_macsec_offload_on_result,
11722 en_on_off, "on#off");
11723 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11724 TOKEN_STRING_INITIALIZER
11725 (struct cmd_macsec_offload_on_result,
11726 replay_protect, "replay-protect");
11727 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11728 TOKEN_STRING_INITIALIZER
11729 (struct cmd_macsec_offload_on_result,
11730 rp_on_off, "on#off");
11733 cmd_set_macsec_offload_on_parsed(
11734 void *parsed_result,
11735 __rte_unused struct cmdline *cl,
11736 __rte_unused void *data)
11738 struct cmd_macsec_offload_on_result *res = parsed_result;
11739 int ret = -ENOTSUP;
11740 portid_t port_id = res->port_id;
11741 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11742 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11743 struct rte_eth_dev_info dev_info;
11745 if (port_id_is_invalid(port_id, ENABLED_WARN))
11747 if (!port_is_stopped(port_id)) {
11748 printf("Please stop port %d first\n", port_id);
11752 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11756 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11757 #ifdef RTE_NET_IXGBE
11758 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11766 ports[port_id].dev_conf.txmode.offloads |=
11767 DEV_TX_OFFLOAD_MACSEC_INSERT;
11768 cmd_reconfig_device_queue(port_id, 1, 1);
11771 printf("invalid port_id %d\n", port_id);
11774 printf("not supported on port %d\n", port_id);
11777 printf("programming error: (%s)\n", strerror(-ret));
11781 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11782 .f = cmd_set_macsec_offload_on_parsed,
11784 .help_str = "set macsec offload <port_id> on "
11785 "encrypt on|off replay-protect on|off",
11787 (void *)&cmd_macsec_offload_on_set,
11788 (void *)&cmd_macsec_offload_on_macsec,
11789 (void *)&cmd_macsec_offload_on_offload,
11790 (void *)&cmd_macsec_offload_on_port_id,
11791 (void *)&cmd_macsec_offload_on_on,
11792 (void *)&cmd_macsec_offload_on_encrypt,
11793 (void *)&cmd_macsec_offload_on_en_on_off,
11794 (void *)&cmd_macsec_offload_on_replay_protect,
11795 (void *)&cmd_macsec_offload_on_rp_on_off,
11800 /* Common result structure for MACsec offload disable */
11801 struct cmd_macsec_offload_off_result {
11802 cmdline_fixed_string_t set;
11803 cmdline_fixed_string_t macsec;
11804 cmdline_fixed_string_t offload;
11806 cmdline_fixed_string_t off;
11809 /* Common CLI fields for MACsec offload disable */
11810 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11811 TOKEN_STRING_INITIALIZER
11812 (struct cmd_macsec_offload_off_result,
11814 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11815 TOKEN_STRING_INITIALIZER
11816 (struct cmd_macsec_offload_off_result,
11818 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11819 TOKEN_STRING_INITIALIZER
11820 (struct cmd_macsec_offload_off_result,
11821 offload, "offload");
11822 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11823 TOKEN_NUM_INITIALIZER
11824 (struct cmd_macsec_offload_off_result,
11825 port_id, RTE_UINT16);
11826 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11827 TOKEN_STRING_INITIALIZER
11828 (struct cmd_macsec_offload_off_result,
11832 cmd_set_macsec_offload_off_parsed(
11833 void *parsed_result,
11834 __rte_unused struct cmdline *cl,
11835 __rte_unused void *data)
11837 struct cmd_macsec_offload_off_result *res = parsed_result;
11838 int ret = -ENOTSUP;
11839 struct rte_eth_dev_info dev_info;
11840 portid_t port_id = res->port_id;
11842 if (port_id_is_invalid(port_id, ENABLED_WARN))
11844 if (!port_is_stopped(port_id)) {
11845 printf("Please stop port %d first\n", port_id);
11849 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11853 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11854 #ifdef RTE_NET_IXGBE
11855 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11860 ports[port_id].dev_conf.txmode.offloads &=
11861 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11862 cmd_reconfig_device_queue(port_id, 1, 1);
11865 printf("invalid port_id %d\n", port_id);
11868 printf("not supported on port %d\n", port_id);
11871 printf("programming error: (%s)\n", strerror(-ret));
11875 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11876 .f = cmd_set_macsec_offload_off_parsed,
11878 .help_str = "set macsec offload <port_id> off",
11880 (void *)&cmd_macsec_offload_off_set,
11881 (void *)&cmd_macsec_offload_off_macsec,
11882 (void *)&cmd_macsec_offload_off_offload,
11883 (void *)&cmd_macsec_offload_off_port_id,
11884 (void *)&cmd_macsec_offload_off_off,
11889 /* Common result structure for MACsec secure connection configure */
11890 struct cmd_macsec_sc_result {
11891 cmdline_fixed_string_t set;
11892 cmdline_fixed_string_t macsec;
11893 cmdline_fixed_string_t sc;
11894 cmdline_fixed_string_t tx_rx;
11896 struct rte_ether_addr mac;
11900 /* Common CLI fields for MACsec secure connection configure */
11901 cmdline_parse_token_string_t cmd_macsec_sc_set =
11902 TOKEN_STRING_INITIALIZER
11903 (struct cmd_macsec_sc_result,
11905 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11906 TOKEN_STRING_INITIALIZER
11907 (struct cmd_macsec_sc_result,
11909 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11910 TOKEN_STRING_INITIALIZER
11911 (struct cmd_macsec_sc_result,
11913 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11914 TOKEN_STRING_INITIALIZER
11915 (struct cmd_macsec_sc_result,
11917 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11918 TOKEN_NUM_INITIALIZER
11919 (struct cmd_macsec_sc_result,
11920 port_id, RTE_UINT16);
11921 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11922 TOKEN_ETHERADDR_INITIALIZER
11923 (struct cmd_macsec_sc_result,
11925 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11926 TOKEN_NUM_INITIALIZER
11927 (struct cmd_macsec_sc_result,
11931 cmd_set_macsec_sc_parsed(
11932 void *parsed_result,
11933 __rte_unused struct cmdline *cl,
11934 __rte_unused void *data)
11936 struct cmd_macsec_sc_result *res = parsed_result;
11937 int ret = -ENOTSUP;
11938 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11940 #ifdef RTE_NET_IXGBE
11942 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11943 res->mac.addr_bytes) :
11944 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11945 res->mac.addr_bytes, res->pi);
11947 RTE_SET_USED(is_tx);
11953 printf("invalid port_id %d\n", res->port_id);
11956 printf("not supported on port %d\n", res->port_id);
11959 printf("programming error: (%s)\n", strerror(-ret));
11963 cmdline_parse_inst_t cmd_set_macsec_sc = {
11964 .f = cmd_set_macsec_sc_parsed,
11966 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11968 (void *)&cmd_macsec_sc_set,
11969 (void *)&cmd_macsec_sc_macsec,
11970 (void *)&cmd_macsec_sc_sc,
11971 (void *)&cmd_macsec_sc_tx_rx,
11972 (void *)&cmd_macsec_sc_port_id,
11973 (void *)&cmd_macsec_sc_mac,
11974 (void *)&cmd_macsec_sc_pi,
11979 /* Common result structure for MACsec secure connection configure */
11980 struct cmd_macsec_sa_result {
11981 cmdline_fixed_string_t set;
11982 cmdline_fixed_string_t macsec;
11983 cmdline_fixed_string_t sa;
11984 cmdline_fixed_string_t tx_rx;
11989 cmdline_fixed_string_t key;
11992 /* Common CLI fields for MACsec secure connection configure */
11993 cmdline_parse_token_string_t cmd_macsec_sa_set =
11994 TOKEN_STRING_INITIALIZER
11995 (struct cmd_macsec_sa_result,
11997 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11998 TOKEN_STRING_INITIALIZER
11999 (struct cmd_macsec_sa_result,
12001 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12002 TOKEN_STRING_INITIALIZER
12003 (struct cmd_macsec_sa_result,
12005 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12006 TOKEN_STRING_INITIALIZER
12007 (struct cmd_macsec_sa_result,
12009 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12010 TOKEN_NUM_INITIALIZER
12011 (struct cmd_macsec_sa_result,
12012 port_id, RTE_UINT16);
12013 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12014 TOKEN_NUM_INITIALIZER
12015 (struct cmd_macsec_sa_result,
12017 cmdline_parse_token_num_t cmd_macsec_sa_an =
12018 TOKEN_NUM_INITIALIZER
12019 (struct cmd_macsec_sa_result,
12021 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12022 TOKEN_NUM_INITIALIZER
12023 (struct cmd_macsec_sa_result,
12025 cmdline_parse_token_string_t cmd_macsec_sa_key =
12026 TOKEN_STRING_INITIALIZER
12027 (struct cmd_macsec_sa_result,
12031 cmd_set_macsec_sa_parsed(
12032 void *parsed_result,
12033 __rte_unused struct cmdline *cl,
12034 __rte_unused void *data)
12036 struct cmd_macsec_sa_result *res = parsed_result;
12037 int ret = -ENOTSUP;
12038 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12039 uint8_t key[16] = { 0 };
12045 key_len = strlen(res->key) / 2;
12049 for (i = 0; i < key_len; i++) {
12050 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12053 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12056 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12059 #ifdef RTE_NET_IXGBE
12061 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12062 res->idx, res->an, res->pn, key) :
12063 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12064 res->idx, res->an, res->pn, key);
12066 RTE_SET_USED(is_tx);
12073 printf("invalid idx %d or an %d\n", res->idx, res->an);
12076 printf("invalid port_id %d\n", res->port_id);
12079 printf("not supported on port %d\n", res->port_id);
12082 printf("programming error: (%s)\n", strerror(-ret));
12086 cmdline_parse_inst_t cmd_set_macsec_sa = {
12087 .f = cmd_set_macsec_sa_parsed,
12089 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12091 (void *)&cmd_macsec_sa_set,
12092 (void *)&cmd_macsec_sa_macsec,
12093 (void *)&cmd_macsec_sa_sa,
12094 (void *)&cmd_macsec_sa_tx_rx,
12095 (void *)&cmd_macsec_sa_port_id,
12096 (void *)&cmd_macsec_sa_idx,
12097 (void *)&cmd_macsec_sa_an,
12098 (void *)&cmd_macsec_sa_pn,
12099 (void *)&cmd_macsec_sa_key,
12104 /* VF unicast promiscuous mode configuration */
12106 /* Common result structure for VF unicast promiscuous mode */
12107 struct cmd_vf_promisc_result {
12108 cmdline_fixed_string_t set;
12109 cmdline_fixed_string_t vf;
12110 cmdline_fixed_string_t promisc;
12113 cmdline_fixed_string_t on_off;
12116 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12117 cmdline_parse_token_string_t cmd_vf_promisc_set =
12118 TOKEN_STRING_INITIALIZER
12119 (struct cmd_vf_promisc_result,
12121 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12122 TOKEN_STRING_INITIALIZER
12123 (struct cmd_vf_promisc_result,
12125 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12126 TOKEN_STRING_INITIALIZER
12127 (struct cmd_vf_promisc_result,
12128 promisc, "promisc");
12129 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12130 TOKEN_NUM_INITIALIZER
12131 (struct cmd_vf_promisc_result,
12132 port_id, RTE_UINT16);
12133 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12134 TOKEN_NUM_INITIALIZER
12135 (struct cmd_vf_promisc_result,
12136 vf_id, RTE_UINT32);
12137 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12138 TOKEN_STRING_INITIALIZER
12139 (struct cmd_vf_promisc_result,
12143 cmd_set_vf_promisc_parsed(
12144 void *parsed_result,
12145 __rte_unused struct cmdline *cl,
12146 __rte_unused void *data)
12148 struct cmd_vf_promisc_result *res = parsed_result;
12149 int ret = -ENOTSUP;
12151 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12153 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12156 #ifdef RTE_NET_I40E
12157 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12158 res->vf_id, is_on);
12165 printf("invalid vf_id %d\n", res->vf_id);
12168 printf("invalid port_id %d\n", res->port_id);
12171 printf("function not implemented\n");
12174 printf("programming error: (%s)\n", strerror(-ret));
12178 cmdline_parse_inst_t cmd_set_vf_promisc = {
12179 .f = cmd_set_vf_promisc_parsed,
12181 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12182 "Set unicast promiscuous mode for a VF from the PF",
12184 (void *)&cmd_vf_promisc_set,
12185 (void *)&cmd_vf_promisc_vf,
12186 (void *)&cmd_vf_promisc_promisc,
12187 (void *)&cmd_vf_promisc_port_id,
12188 (void *)&cmd_vf_promisc_vf_id,
12189 (void *)&cmd_vf_promisc_on_off,
12194 /* VF multicast promiscuous mode configuration */
12196 /* Common result structure for VF multicast promiscuous mode */
12197 struct cmd_vf_allmulti_result {
12198 cmdline_fixed_string_t set;
12199 cmdline_fixed_string_t vf;
12200 cmdline_fixed_string_t allmulti;
12203 cmdline_fixed_string_t on_off;
12206 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12207 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12208 TOKEN_STRING_INITIALIZER
12209 (struct cmd_vf_allmulti_result,
12211 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12212 TOKEN_STRING_INITIALIZER
12213 (struct cmd_vf_allmulti_result,
12215 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12216 TOKEN_STRING_INITIALIZER
12217 (struct cmd_vf_allmulti_result,
12218 allmulti, "allmulti");
12219 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12220 TOKEN_NUM_INITIALIZER
12221 (struct cmd_vf_allmulti_result,
12222 port_id, RTE_UINT16);
12223 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12224 TOKEN_NUM_INITIALIZER
12225 (struct cmd_vf_allmulti_result,
12226 vf_id, RTE_UINT32);
12227 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12228 TOKEN_STRING_INITIALIZER
12229 (struct cmd_vf_allmulti_result,
12233 cmd_set_vf_allmulti_parsed(
12234 void *parsed_result,
12235 __rte_unused struct cmdline *cl,
12236 __rte_unused void *data)
12238 struct cmd_vf_allmulti_result *res = parsed_result;
12239 int ret = -ENOTSUP;
12241 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12243 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12246 #ifdef RTE_NET_I40E
12247 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12248 res->vf_id, is_on);
12255 printf("invalid vf_id %d\n", res->vf_id);
12258 printf("invalid port_id %d\n", res->port_id);
12261 printf("function not implemented\n");
12264 printf("programming error: (%s)\n", strerror(-ret));
12268 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12269 .f = cmd_set_vf_allmulti_parsed,
12271 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12272 "Set multicast promiscuous mode for a VF from the PF",
12274 (void *)&cmd_vf_allmulti_set,
12275 (void *)&cmd_vf_allmulti_vf,
12276 (void *)&cmd_vf_allmulti_allmulti,
12277 (void *)&cmd_vf_allmulti_port_id,
12278 (void *)&cmd_vf_allmulti_vf_id,
12279 (void *)&cmd_vf_allmulti_on_off,
12284 /* vf broadcast mode configuration */
12286 /* Common result structure for vf broadcast */
12287 struct cmd_set_vf_broadcast_result {
12288 cmdline_fixed_string_t set;
12289 cmdline_fixed_string_t vf;
12290 cmdline_fixed_string_t broadcast;
12293 cmdline_fixed_string_t on_off;
12296 /* Common CLI fields for vf broadcast enable disable */
12297 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12298 TOKEN_STRING_INITIALIZER
12299 (struct cmd_set_vf_broadcast_result,
12301 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12302 TOKEN_STRING_INITIALIZER
12303 (struct cmd_set_vf_broadcast_result,
12305 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12306 TOKEN_STRING_INITIALIZER
12307 (struct cmd_set_vf_broadcast_result,
12308 broadcast, "broadcast");
12309 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12310 TOKEN_NUM_INITIALIZER
12311 (struct cmd_set_vf_broadcast_result,
12312 port_id, RTE_UINT16);
12313 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12314 TOKEN_NUM_INITIALIZER
12315 (struct cmd_set_vf_broadcast_result,
12316 vf_id, RTE_UINT16);
12317 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12318 TOKEN_STRING_INITIALIZER
12319 (struct cmd_set_vf_broadcast_result,
12323 cmd_set_vf_broadcast_parsed(
12324 void *parsed_result,
12325 __rte_unused struct cmdline *cl,
12326 __rte_unused void *data)
12328 struct cmd_set_vf_broadcast_result *res = parsed_result;
12329 int ret = -ENOTSUP;
12331 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12333 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12336 #ifdef RTE_NET_I40E
12337 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12338 res->vf_id, is_on);
12345 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12348 printf("invalid port_id %d\n", res->port_id);
12351 printf("function not implemented\n");
12354 printf("programming error: (%s)\n", strerror(-ret));
12358 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12359 .f = cmd_set_vf_broadcast_parsed,
12361 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12363 (void *)&cmd_set_vf_broadcast_set,
12364 (void *)&cmd_set_vf_broadcast_vf,
12365 (void *)&cmd_set_vf_broadcast_broadcast,
12366 (void *)&cmd_set_vf_broadcast_port_id,
12367 (void *)&cmd_set_vf_broadcast_vf_id,
12368 (void *)&cmd_set_vf_broadcast_on_off,
12373 /* vf vlan tag configuration */
12375 /* Common result structure for vf vlan tag */
12376 struct cmd_set_vf_vlan_tag_result {
12377 cmdline_fixed_string_t set;
12378 cmdline_fixed_string_t vf;
12379 cmdline_fixed_string_t vlan;
12380 cmdline_fixed_string_t tag;
12383 cmdline_fixed_string_t on_off;
12386 /* Common CLI fields for vf vlan tag enable disable */
12387 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12388 TOKEN_STRING_INITIALIZER
12389 (struct cmd_set_vf_vlan_tag_result,
12391 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12392 TOKEN_STRING_INITIALIZER
12393 (struct cmd_set_vf_vlan_tag_result,
12395 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12396 TOKEN_STRING_INITIALIZER
12397 (struct cmd_set_vf_vlan_tag_result,
12399 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12400 TOKEN_STRING_INITIALIZER
12401 (struct cmd_set_vf_vlan_tag_result,
12403 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12404 TOKEN_NUM_INITIALIZER
12405 (struct cmd_set_vf_vlan_tag_result,
12406 port_id, RTE_UINT16);
12407 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12408 TOKEN_NUM_INITIALIZER
12409 (struct cmd_set_vf_vlan_tag_result,
12410 vf_id, RTE_UINT16);
12411 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12412 TOKEN_STRING_INITIALIZER
12413 (struct cmd_set_vf_vlan_tag_result,
12417 cmd_set_vf_vlan_tag_parsed(
12418 void *parsed_result,
12419 __rte_unused struct cmdline *cl,
12420 __rte_unused void *data)
12422 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12423 int ret = -ENOTSUP;
12425 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12427 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12430 #ifdef RTE_NET_I40E
12431 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12432 res->vf_id, is_on);
12439 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12442 printf("invalid port_id %d\n", res->port_id);
12445 printf("function not implemented\n");
12448 printf("programming error: (%s)\n", strerror(-ret));
12452 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12453 .f = cmd_set_vf_vlan_tag_parsed,
12455 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12457 (void *)&cmd_set_vf_vlan_tag_set,
12458 (void *)&cmd_set_vf_vlan_tag_vf,
12459 (void *)&cmd_set_vf_vlan_tag_vlan,
12460 (void *)&cmd_set_vf_vlan_tag_tag,
12461 (void *)&cmd_set_vf_vlan_tag_port_id,
12462 (void *)&cmd_set_vf_vlan_tag_vf_id,
12463 (void *)&cmd_set_vf_vlan_tag_on_off,
12468 /* Common definition of VF and TC TX bandwidth configuration */
12469 struct cmd_vf_tc_bw_result {
12470 cmdline_fixed_string_t set;
12471 cmdline_fixed_string_t vf;
12472 cmdline_fixed_string_t tc;
12473 cmdline_fixed_string_t tx;
12474 cmdline_fixed_string_t min_bw;
12475 cmdline_fixed_string_t max_bw;
12476 cmdline_fixed_string_t strict_link_prio;
12481 cmdline_fixed_string_t bw_list;
12485 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12486 TOKEN_STRING_INITIALIZER
12487 (struct cmd_vf_tc_bw_result,
12489 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12490 TOKEN_STRING_INITIALIZER
12491 (struct cmd_vf_tc_bw_result,
12493 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12494 TOKEN_STRING_INITIALIZER
12495 (struct cmd_vf_tc_bw_result,
12497 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12498 TOKEN_STRING_INITIALIZER
12499 (struct cmd_vf_tc_bw_result,
12501 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12502 TOKEN_STRING_INITIALIZER
12503 (struct cmd_vf_tc_bw_result,
12504 strict_link_prio, "strict-link-priority");
12505 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12506 TOKEN_STRING_INITIALIZER
12507 (struct cmd_vf_tc_bw_result,
12508 min_bw, "min-bandwidth");
12509 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12510 TOKEN_STRING_INITIALIZER
12511 (struct cmd_vf_tc_bw_result,
12512 max_bw, "max-bandwidth");
12513 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12514 TOKEN_NUM_INITIALIZER
12515 (struct cmd_vf_tc_bw_result,
12516 port_id, RTE_UINT16);
12517 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12518 TOKEN_NUM_INITIALIZER
12519 (struct cmd_vf_tc_bw_result,
12520 vf_id, RTE_UINT16);
12521 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12522 TOKEN_NUM_INITIALIZER
12523 (struct cmd_vf_tc_bw_result,
12525 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12526 TOKEN_NUM_INITIALIZER
12527 (struct cmd_vf_tc_bw_result,
12529 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12530 TOKEN_STRING_INITIALIZER
12531 (struct cmd_vf_tc_bw_result,
12533 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12534 TOKEN_NUM_INITIALIZER
12535 (struct cmd_vf_tc_bw_result,
12536 tc_map, RTE_UINT8);
12538 /* VF max bandwidth setting */
12540 cmd_vf_max_bw_parsed(
12541 void *parsed_result,
12542 __rte_unused struct cmdline *cl,
12543 __rte_unused void *data)
12545 struct cmd_vf_tc_bw_result *res = parsed_result;
12546 int ret = -ENOTSUP;
12548 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12551 #ifdef RTE_NET_I40E
12552 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12553 res->vf_id, res->bw);
12560 printf("invalid vf_id %d or bandwidth %d\n",
12561 res->vf_id, res->bw);
12564 printf("invalid port_id %d\n", res->port_id);
12567 printf("function not implemented\n");
12570 printf("programming error: (%s)\n", strerror(-ret));
12574 cmdline_parse_inst_t cmd_vf_max_bw = {
12575 .f = cmd_vf_max_bw_parsed,
12577 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12579 (void *)&cmd_vf_tc_bw_set,
12580 (void *)&cmd_vf_tc_bw_vf,
12581 (void *)&cmd_vf_tc_bw_tx,
12582 (void *)&cmd_vf_tc_bw_max_bw,
12583 (void *)&cmd_vf_tc_bw_port_id,
12584 (void *)&cmd_vf_tc_bw_vf_id,
12585 (void *)&cmd_vf_tc_bw_bw,
12591 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12596 const char *p, *p0 = str;
12603 p = strchr(p0, '(');
12605 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12609 p0 = strchr(p, ')');
12611 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12615 if (size >= sizeof(s)) {
12616 printf("The string size exceeds the internal buffer size\n");
12619 snprintf(s, sizeof(s), "%.*s", size, p);
12620 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12622 printf("Failed to get the bandwidth list. ");
12626 for (i = 0; i < ret; i++)
12627 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12632 /* TC min bandwidth setting */
12634 cmd_vf_tc_min_bw_parsed(
12635 void *parsed_result,
12636 __rte_unused struct cmdline *cl,
12637 __rte_unused void *data)
12639 struct cmd_vf_tc_bw_result *res = parsed_result;
12642 int ret = -ENOTSUP;
12644 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12647 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12651 #ifdef RTE_NET_I40E
12652 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12660 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12663 printf("invalid port_id %d\n", res->port_id);
12666 printf("function not implemented\n");
12669 printf("programming error: (%s)\n", strerror(-ret));
12673 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12674 .f = cmd_vf_tc_min_bw_parsed,
12676 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12677 " <bw1, bw2, ...>",
12679 (void *)&cmd_vf_tc_bw_set,
12680 (void *)&cmd_vf_tc_bw_vf,
12681 (void *)&cmd_vf_tc_bw_tc,
12682 (void *)&cmd_vf_tc_bw_tx,
12683 (void *)&cmd_vf_tc_bw_min_bw,
12684 (void *)&cmd_vf_tc_bw_port_id,
12685 (void *)&cmd_vf_tc_bw_vf_id,
12686 (void *)&cmd_vf_tc_bw_bw_list,
12692 cmd_tc_min_bw_parsed(
12693 void *parsed_result,
12694 __rte_unused struct cmdline *cl,
12695 __rte_unused void *data)
12697 struct cmd_vf_tc_bw_result *res = parsed_result;
12698 struct rte_port *port;
12701 int ret = -ENOTSUP;
12703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12706 port = &ports[res->port_id];
12707 /** Check if the port is not started **/
12708 if (port->port_status != RTE_PORT_STOPPED) {
12709 printf("Please stop port %d first\n", res->port_id);
12713 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12717 #ifdef RTE_NET_IXGBE
12718 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12725 printf("invalid bandwidth\n");
12728 printf("invalid port_id %d\n", res->port_id);
12731 printf("function not implemented\n");
12734 printf("programming error: (%s)\n", strerror(-ret));
12738 cmdline_parse_inst_t cmd_tc_min_bw = {
12739 .f = cmd_tc_min_bw_parsed,
12741 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12743 (void *)&cmd_vf_tc_bw_set,
12744 (void *)&cmd_vf_tc_bw_tc,
12745 (void *)&cmd_vf_tc_bw_tx,
12746 (void *)&cmd_vf_tc_bw_min_bw,
12747 (void *)&cmd_vf_tc_bw_port_id,
12748 (void *)&cmd_vf_tc_bw_bw_list,
12753 /* TC max bandwidth setting */
12755 cmd_vf_tc_max_bw_parsed(
12756 void *parsed_result,
12757 __rte_unused struct cmdline *cl,
12758 __rte_unused void *data)
12760 struct cmd_vf_tc_bw_result *res = parsed_result;
12761 int ret = -ENOTSUP;
12763 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12766 #ifdef RTE_NET_I40E
12767 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12768 res->tc_no, res->bw);
12775 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12776 res->vf_id, res->tc_no, res->bw);
12779 printf("invalid port_id %d\n", res->port_id);
12782 printf("function not implemented\n");
12785 printf("programming error: (%s)\n", strerror(-ret));
12789 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12790 .f = cmd_vf_tc_max_bw_parsed,
12792 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12795 (void *)&cmd_vf_tc_bw_set,
12796 (void *)&cmd_vf_tc_bw_vf,
12797 (void *)&cmd_vf_tc_bw_tc,
12798 (void *)&cmd_vf_tc_bw_tx,
12799 (void *)&cmd_vf_tc_bw_max_bw,
12800 (void *)&cmd_vf_tc_bw_port_id,
12801 (void *)&cmd_vf_tc_bw_vf_id,
12802 (void *)&cmd_vf_tc_bw_tc_no,
12803 (void *)&cmd_vf_tc_bw_bw,
12808 /** Set VXLAN encapsulation details */
12809 struct cmd_set_vxlan_result {
12810 cmdline_fixed_string_t set;
12811 cmdline_fixed_string_t vxlan;
12812 cmdline_fixed_string_t pos_token;
12813 cmdline_fixed_string_t ip_version;
12814 uint32_t vlan_present:1;
12818 cmdline_ipaddr_t ip_src;
12819 cmdline_ipaddr_t ip_dst;
12823 struct rte_ether_addr eth_src;
12824 struct rte_ether_addr eth_dst;
12827 cmdline_parse_token_string_t cmd_set_vxlan_set =
12828 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12829 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12830 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12831 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12832 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12834 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12835 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12836 "vxlan-with-vlan");
12837 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12838 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12840 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12841 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12843 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12844 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12846 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12847 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12848 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12849 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12851 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12852 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12853 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12854 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12856 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12857 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12858 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12859 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12861 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12862 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12863 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12864 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12866 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12867 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12868 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12869 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12871 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12872 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12873 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12874 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12876 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12877 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12878 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12879 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12881 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12882 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12883 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12884 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12886 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12887 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12888 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12889 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12891 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12892 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12894 static void cmd_set_vxlan_parsed(void *parsed_result,
12895 __rte_unused struct cmdline *cl,
12896 __rte_unused void *data)
12898 struct cmd_set_vxlan_result *res = parsed_result;
12903 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12906 vxlan_encap_conf.select_tos_ttl = 0;
12907 if (strcmp(res->vxlan, "vxlan") == 0)
12908 vxlan_encap_conf.select_vlan = 0;
12909 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12910 vxlan_encap_conf.select_vlan = 1;
12911 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12912 vxlan_encap_conf.select_vlan = 0;
12913 vxlan_encap_conf.select_tos_ttl = 1;
12915 if (strcmp(res->ip_version, "ipv4") == 0)
12916 vxlan_encap_conf.select_ipv4 = 1;
12917 else if (strcmp(res->ip_version, "ipv6") == 0)
12918 vxlan_encap_conf.select_ipv4 = 0;
12921 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12922 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12923 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12924 vxlan_encap_conf.ip_tos = res->tos;
12925 vxlan_encap_conf.ip_ttl = res->ttl;
12926 if (vxlan_encap_conf.select_ipv4) {
12927 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12928 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12930 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12931 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12933 if (vxlan_encap_conf.select_vlan)
12934 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12935 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12936 RTE_ETHER_ADDR_LEN);
12937 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12938 RTE_ETHER_ADDR_LEN);
12941 cmdline_parse_inst_t cmd_set_vxlan = {
12942 .f = cmd_set_vxlan_parsed,
12944 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12945 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12946 " eth-src <eth-src> eth-dst <eth-dst>",
12948 (void *)&cmd_set_vxlan_set,
12949 (void *)&cmd_set_vxlan_vxlan,
12950 (void *)&cmd_set_vxlan_ip_version,
12951 (void *)&cmd_set_vxlan_ip_version_value,
12952 (void *)&cmd_set_vxlan_vni,
12953 (void *)&cmd_set_vxlan_vni_value,
12954 (void *)&cmd_set_vxlan_udp_src,
12955 (void *)&cmd_set_vxlan_udp_src_value,
12956 (void *)&cmd_set_vxlan_udp_dst,
12957 (void *)&cmd_set_vxlan_udp_dst_value,
12958 (void *)&cmd_set_vxlan_ip_src,
12959 (void *)&cmd_set_vxlan_ip_src_value,
12960 (void *)&cmd_set_vxlan_ip_dst,
12961 (void *)&cmd_set_vxlan_ip_dst_value,
12962 (void *)&cmd_set_vxlan_eth_src,
12963 (void *)&cmd_set_vxlan_eth_src_value,
12964 (void *)&cmd_set_vxlan_eth_dst,
12965 (void *)&cmd_set_vxlan_eth_dst_value,
12970 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12971 .f = cmd_set_vxlan_parsed,
12973 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12974 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12975 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12976 " eth-dst <eth-dst>",
12978 (void *)&cmd_set_vxlan_set,
12979 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12980 (void *)&cmd_set_vxlan_ip_version,
12981 (void *)&cmd_set_vxlan_ip_version_value,
12982 (void *)&cmd_set_vxlan_vni,
12983 (void *)&cmd_set_vxlan_vni_value,
12984 (void *)&cmd_set_vxlan_udp_src,
12985 (void *)&cmd_set_vxlan_udp_src_value,
12986 (void *)&cmd_set_vxlan_udp_dst,
12987 (void *)&cmd_set_vxlan_udp_dst_value,
12988 (void *)&cmd_set_vxlan_ip_tos,
12989 (void *)&cmd_set_vxlan_ip_tos_value,
12990 (void *)&cmd_set_vxlan_ip_ttl,
12991 (void *)&cmd_set_vxlan_ip_ttl_value,
12992 (void *)&cmd_set_vxlan_ip_src,
12993 (void *)&cmd_set_vxlan_ip_src_value,
12994 (void *)&cmd_set_vxlan_ip_dst,
12995 (void *)&cmd_set_vxlan_ip_dst_value,
12996 (void *)&cmd_set_vxlan_eth_src,
12997 (void *)&cmd_set_vxlan_eth_src_value,
12998 (void *)&cmd_set_vxlan_eth_dst,
12999 (void *)&cmd_set_vxlan_eth_dst_value,
13004 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13005 .f = cmd_set_vxlan_parsed,
13007 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13008 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13009 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13012 (void *)&cmd_set_vxlan_set,
13013 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13014 (void *)&cmd_set_vxlan_ip_version,
13015 (void *)&cmd_set_vxlan_ip_version_value,
13016 (void *)&cmd_set_vxlan_vni,
13017 (void *)&cmd_set_vxlan_vni_value,
13018 (void *)&cmd_set_vxlan_udp_src,
13019 (void *)&cmd_set_vxlan_udp_src_value,
13020 (void *)&cmd_set_vxlan_udp_dst,
13021 (void *)&cmd_set_vxlan_udp_dst_value,
13022 (void *)&cmd_set_vxlan_ip_src,
13023 (void *)&cmd_set_vxlan_ip_src_value,
13024 (void *)&cmd_set_vxlan_ip_dst,
13025 (void *)&cmd_set_vxlan_ip_dst_value,
13026 (void *)&cmd_set_vxlan_vlan,
13027 (void *)&cmd_set_vxlan_vlan_value,
13028 (void *)&cmd_set_vxlan_eth_src,
13029 (void *)&cmd_set_vxlan_eth_src_value,
13030 (void *)&cmd_set_vxlan_eth_dst,
13031 (void *)&cmd_set_vxlan_eth_dst_value,
13036 /** Set NVGRE encapsulation details */
13037 struct cmd_set_nvgre_result {
13038 cmdline_fixed_string_t set;
13039 cmdline_fixed_string_t nvgre;
13040 cmdline_fixed_string_t pos_token;
13041 cmdline_fixed_string_t ip_version;
13043 cmdline_ipaddr_t ip_src;
13044 cmdline_ipaddr_t ip_dst;
13046 struct rte_ether_addr eth_src;
13047 struct rte_ether_addr eth_dst;
13050 cmdline_parse_token_string_t cmd_set_nvgre_set =
13051 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13052 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13053 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13054 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13055 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13056 "nvgre-with-vlan");
13057 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13058 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13060 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13061 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13063 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13064 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13066 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13067 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13068 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13069 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13071 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13072 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13073 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13074 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13076 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13077 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13078 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13079 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13081 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13082 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13083 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13084 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13086 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13087 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13088 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13089 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13091 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13092 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13094 static void cmd_set_nvgre_parsed(void *parsed_result,
13095 __rte_unused struct cmdline *cl,
13096 __rte_unused void *data)
13098 struct cmd_set_nvgre_result *res = parsed_result;
13100 uint32_t nvgre_tni;
13103 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13106 if (strcmp(res->nvgre, "nvgre") == 0)
13107 nvgre_encap_conf.select_vlan = 0;
13108 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13109 nvgre_encap_conf.select_vlan = 1;
13110 if (strcmp(res->ip_version, "ipv4") == 0)
13111 nvgre_encap_conf.select_ipv4 = 1;
13112 else if (strcmp(res->ip_version, "ipv6") == 0)
13113 nvgre_encap_conf.select_ipv4 = 0;
13116 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13117 if (nvgre_encap_conf.select_ipv4) {
13118 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13119 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13121 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13122 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13124 if (nvgre_encap_conf.select_vlan)
13125 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13126 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13127 RTE_ETHER_ADDR_LEN);
13128 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13129 RTE_ETHER_ADDR_LEN);
13132 cmdline_parse_inst_t cmd_set_nvgre = {
13133 .f = cmd_set_nvgre_parsed,
13135 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13136 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13137 " eth-dst <eth-dst>",
13139 (void *)&cmd_set_nvgre_set,
13140 (void *)&cmd_set_nvgre_nvgre,
13141 (void *)&cmd_set_nvgre_ip_version,
13142 (void *)&cmd_set_nvgre_ip_version_value,
13143 (void *)&cmd_set_nvgre_tni,
13144 (void *)&cmd_set_nvgre_tni_value,
13145 (void *)&cmd_set_nvgre_ip_src,
13146 (void *)&cmd_set_nvgre_ip_src_value,
13147 (void *)&cmd_set_nvgre_ip_dst,
13148 (void *)&cmd_set_nvgre_ip_dst_value,
13149 (void *)&cmd_set_nvgre_eth_src,
13150 (void *)&cmd_set_nvgre_eth_src_value,
13151 (void *)&cmd_set_nvgre_eth_dst,
13152 (void *)&cmd_set_nvgre_eth_dst_value,
13157 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13158 .f = cmd_set_nvgre_parsed,
13160 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13161 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13162 " eth-src <eth-src> eth-dst <eth-dst>",
13164 (void *)&cmd_set_nvgre_set,
13165 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13166 (void *)&cmd_set_nvgre_ip_version,
13167 (void *)&cmd_set_nvgre_ip_version_value,
13168 (void *)&cmd_set_nvgre_tni,
13169 (void *)&cmd_set_nvgre_tni_value,
13170 (void *)&cmd_set_nvgre_ip_src,
13171 (void *)&cmd_set_nvgre_ip_src_value,
13172 (void *)&cmd_set_nvgre_ip_dst,
13173 (void *)&cmd_set_nvgre_ip_dst_value,
13174 (void *)&cmd_set_nvgre_vlan,
13175 (void *)&cmd_set_nvgre_vlan_value,
13176 (void *)&cmd_set_nvgre_eth_src,
13177 (void *)&cmd_set_nvgre_eth_src_value,
13178 (void *)&cmd_set_nvgre_eth_dst,
13179 (void *)&cmd_set_nvgre_eth_dst_value,
13184 /** Set L2 encapsulation details */
13185 struct cmd_set_l2_encap_result {
13186 cmdline_fixed_string_t set;
13187 cmdline_fixed_string_t l2_encap;
13188 cmdline_fixed_string_t pos_token;
13189 cmdline_fixed_string_t ip_version;
13190 uint32_t vlan_present:1;
13192 struct rte_ether_addr eth_src;
13193 struct rte_ether_addr eth_dst;
13196 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13197 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13198 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13199 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13200 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13201 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13202 "l2_encap-with-vlan");
13203 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13204 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13206 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13207 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13209 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13210 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13212 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13213 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13214 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13215 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13217 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13218 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13219 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13220 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13222 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13223 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13225 static void cmd_set_l2_encap_parsed(void *parsed_result,
13226 __rte_unused struct cmdline *cl,
13227 __rte_unused void *data)
13229 struct cmd_set_l2_encap_result *res = parsed_result;
13231 if (strcmp(res->l2_encap, "l2_encap") == 0)
13232 l2_encap_conf.select_vlan = 0;
13233 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13234 l2_encap_conf.select_vlan = 1;
13235 if (strcmp(res->ip_version, "ipv4") == 0)
13236 l2_encap_conf.select_ipv4 = 1;
13237 else if (strcmp(res->ip_version, "ipv6") == 0)
13238 l2_encap_conf.select_ipv4 = 0;
13241 if (l2_encap_conf.select_vlan)
13242 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13243 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13244 RTE_ETHER_ADDR_LEN);
13245 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13246 RTE_ETHER_ADDR_LEN);
13249 cmdline_parse_inst_t cmd_set_l2_encap = {
13250 .f = cmd_set_l2_encap_parsed,
13252 .help_str = "set l2_encap ip-version ipv4|ipv6"
13253 " eth-src <eth-src> eth-dst <eth-dst>",
13255 (void *)&cmd_set_l2_encap_set,
13256 (void *)&cmd_set_l2_encap_l2_encap,
13257 (void *)&cmd_set_l2_encap_ip_version,
13258 (void *)&cmd_set_l2_encap_ip_version_value,
13259 (void *)&cmd_set_l2_encap_eth_src,
13260 (void *)&cmd_set_l2_encap_eth_src_value,
13261 (void *)&cmd_set_l2_encap_eth_dst,
13262 (void *)&cmd_set_l2_encap_eth_dst_value,
13267 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13268 .f = cmd_set_l2_encap_parsed,
13270 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13271 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13273 (void *)&cmd_set_l2_encap_set,
13274 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13275 (void *)&cmd_set_l2_encap_ip_version,
13276 (void *)&cmd_set_l2_encap_ip_version_value,
13277 (void *)&cmd_set_l2_encap_vlan,
13278 (void *)&cmd_set_l2_encap_vlan_value,
13279 (void *)&cmd_set_l2_encap_eth_src,
13280 (void *)&cmd_set_l2_encap_eth_src_value,
13281 (void *)&cmd_set_l2_encap_eth_dst,
13282 (void *)&cmd_set_l2_encap_eth_dst_value,
13287 /** Set L2 decapsulation details */
13288 struct cmd_set_l2_decap_result {
13289 cmdline_fixed_string_t set;
13290 cmdline_fixed_string_t l2_decap;
13291 cmdline_fixed_string_t pos_token;
13292 uint32_t vlan_present:1;
13295 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13296 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13297 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13298 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13300 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13301 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13302 "l2_decap-with-vlan");
13304 static void cmd_set_l2_decap_parsed(void *parsed_result,
13305 __rte_unused struct cmdline *cl,
13306 __rte_unused void *data)
13308 struct cmd_set_l2_decap_result *res = parsed_result;
13310 if (strcmp(res->l2_decap, "l2_decap") == 0)
13311 l2_decap_conf.select_vlan = 0;
13312 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13313 l2_decap_conf.select_vlan = 1;
13316 cmdline_parse_inst_t cmd_set_l2_decap = {
13317 .f = cmd_set_l2_decap_parsed,
13319 .help_str = "set l2_decap",
13321 (void *)&cmd_set_l2_decap_set,
13322 (void *)&cmd_set_l2_decap_l2_decap,
13327 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13328 .f = cmd_set_l2_decap_parsed,
13330 .help_str = "set l2_decap-with-vlan",
13332 (void *)&cmd_set_l2_decap_set,
13333 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13338 /** Set MPLSoGRE encapsulation details */
13339 struct cmd_set_mplsogre_encap_result {
13340 cmdline_fixed_string_t set;
13341 cmdline_fixed_string_t mplsogre;
13342 cmdline_fixed_string_t pos_token;
13343 cmdline_fixed_string_t ip_version;
13344 uint32_t vlan_present:1;
13346 cmdline_ipaddr_t ip_src;
13347 cmdline_ipaddr_t ip_dst;
13349 struct rte_ether_addr eth_src;
13350 struct rte_ether_addr eth_dst;
13353 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13354 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13356 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13357 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13359 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13360 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13361 mplsogre, "mplsogre_encap-with-vlan");
13362 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13363 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13364 pos_token, "ip-version");
13365 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13366 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13367 ip_version, "ipv4#ipv6");
13368 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13369 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13370 pos_token, "label");
13371 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13372 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13374 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13375 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13376 pos_token, "ip-src");
13377 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13378 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13379 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13380 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13381 pos_token, "ip-dst");
13382 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13383 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13384 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13385 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13386 pos_token, "vlan-tci");
13387 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13388 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13390 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13391 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13392 pos_token, "eth-src");
13393 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13394 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13396 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13397 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13398 pos_token, "eth-dst");
13399 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13400 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13403 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13404 __rte_unused struct cmdline *cl,
13405 __rte_unused void *data)
13407 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13409 uint32_t mplsogre_label;
13412 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13415 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13416 mplsogre_encap_conf.select_vlan = 0;
13417 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13418 mplsogre_encap_conf.select_vlan = 1;
13419 if (strcmp(res->ip_version, "ipv4") == 0)
13420 mplsogre_encap_conf.select_ipv4 = 1;
13421 else if (strcmp(res->ip_version, "ipv6") == 0)
13422 mplsogre_encap_conf.select_ipv4 = 0;
13425 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13426 if (mplsogre_encap_conf.select_ipv4) {
13427 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13428 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13430 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13431 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13433 if (mplsogre_encap_conf.select_vlan)
13434 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13435 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13436 RTE_ETHER_ADDR_LEN);
13437 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13438 RTE_ETHER_ADDR_LEN);
13441 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13442 .f = cmd_set_mplsogre_encap_parsed,
13444 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13445 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13446 " eth-dst <eth-dst>",
13448 (void *)&cmd_set_mplsogre_encap_set,
13449 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13450 (void *)&cmd_set_mplsogre_encap_ip_version,
13451 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13452 (void *)&cmd_set_mplsogre_encap_label,
13453 (void *)&cmd_set_mplsogre_encap_label_value,
13454 (void *)&cmd_set_mplsogre_encap_ip_src,
13455 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13456 (void *)&cmd_set_mplsogre_encap_ip_dst,
13457 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13458 (void *)&cmd_set_mplsogre_encap_eth_src,
13459 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13460 (void *)&cmd_set_mplsogre_encap_eth_dst,
13461 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13466 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13467 .f = cmd_set_mplsogre_encap_parsed,
13469 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13470 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13471 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13473 (void *)&cmd_set_mplsogre_encap_set,
13474 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13475 (void *)&cmd_set_mplsogre_encap_ip_version,
13476 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13477 (void *)&cmd_set_mplsogre_encap_label,
13478 (void *)&cmd_set_mplsogre_encap_label_value,
13479 (void *)&cmd_set_mplsogre_encap_ip_src,
13480 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13481 (void *)&cmd_set_mplsogre_encap_ip_dst,
13482 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13483 (void *)&cmd_set_mplsogre_encap_vlan,
13484 (void *)&cmd_set_mplsogre_encap_vlan_value,
13485 (void *)&cmd_set_mplsogre_encap_eth_src,
13486 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13487 (void *)&cmd_set_mplsogre_encap_eth_dst,
13488 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13493 /** Set MPLSoGRE decapsulation details */
13494 struct cmd_set_mplsogre_decap_result {
13495 cmdline_fixed_string_t set;
13496 cmdline_fixed_string_t mplsogre;
13497 cmdline_fixed_string_t pos_token;
13498 cmdline_fixed_string_t ip_version;
13499 uint32_t vlan_present:1;
13502 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13503 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13505 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13506 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13508 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13509 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13510 mplsogre, "mplsogre_decap-with-vlan");
13511 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13512 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13513 pos_token, "ip-version");
13514 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13515 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13516 ip_version, "ipv4#ipv6");
13518 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13519 __rte_unused struct cmdline *cl,
13520 __rte_unused void *data)
13522 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13524 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13525 mplsogre_decap_conf.select_vlan = 0;
13526 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13527 mplsogre_decap_conf.select_vlan = 1;
13528 if (strcmp(res->ip_version, "ipv4") == 0)
13529 mplsogre_decap_conf.select_ipv4 = 1;
13530 else if (strcmp(res->ip_version, "ipv6") == 0)
13531 mplsogre_decap_conf.select_ipv4 = 0;
13534 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13535 .f = cmd_set_mplsogre_decap_parsed,
13537 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13539 (void *)&cmd_set_mplsogre_decap_set,
13540 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13541 (void *)&cmd_set_mplsogre_decap_ip_version,
13542 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13547 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13548 .f = cmd_set_mplsogre_decap_parsed,
13550 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13552 (void *)&cmd_set_mplsogre_decap_set,
13553 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13554 (void *)&cmd_set_mplsogre_decap_ip_version,
13555 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13560 /** Set MPLSoUDP encapsulation details */
13561 struct cmd_set_mplsoudp_encap_result {
13562 cmdline_fixed_string_t set;
13563 cmdline_fixed_string_t mplsoudp;
13564 cmdline_fixed_string_t pos_token;
13565 cmdline_fixed_string_t ip_version;
13566 uint32_t vlan_present:1;
13570 cmdline_ipaddr_t ip_src;
13571 cmdline_ipaddr_t ip_dst;
13573 struct rte_ether_addr eth_src;
13574 struct rte_ether_addr eth_dst;
13577 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13578 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13580 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13581 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13583 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13584 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13585 mplsoudp, "mplsoudp_encap-with-vlan");
13586 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13587 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13588 pos_token, "ip-version");
13589 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13590 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13591 ip_version, "ipv4#ipv6");
13592 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13593 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13594 pos_token, "label");
13595 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13596 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13598 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13599 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13600 pos_token, "udp-src");
13601 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13602 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13604 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13605 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13606 pos_token, "udp-dst");
13607 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13608 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13610 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13611 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13612 pos_token, "ip-src");
13613 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13614 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13615 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13616 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13617 pos_token, "ip-dst");
13618 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13619 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13620 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13621 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13622 pos_token, "vlan-tci");
13623 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13624 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13626 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13627 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13628 pos_token, "eth-src");
13629 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13630 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13632 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13633 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13634 pos_token, "eth-dst");
13635 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13636 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13639 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13640 __rte_unused struct cmdline *cl,
13641 __rte_unused void *data)
13643 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13645 uint32_t mplsoudp_label;
13648 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13651 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13652 mplsoudp_encap_conf.select_vlan = 0;
13653 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13654 mplsoudp_encap_conf.select_vlan = 1;
13655 if (strcmp(res->ip_version, "ipv4") == 0)
13656 mplsoudp_encap_conf.select_ipv4 = 1;
13657 else if (strcmp(res->ip_version, "ipv6") == 0)
13658 mplsoudp_encap_conf.select_ipv4 = 0;
13661 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13662 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13663 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13664 if (mplsoudp_encap_conf.select_ipv4) {
13665 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13666 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13668 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13669 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13671 if (mplsoudp_encap_conf.select_vlan)
13672 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13673 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13674 RTE_ETHER_ADDR_LEN);
13675 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13676 RTE_ETHER_ADDR_LEN);
13679 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13680 .f = cmd_set_mplsoudp_encap_parsed,
13682 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13683 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13684 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13686 (void *)&cmd_set_mplsoudp_encap_set,
13687 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13688 (void *)&cmd_set_mplsoudp_encap_ip_version,
13689 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13690 (void *)&cmd_set_mplsoudp_encap_label,
13691 (void *)&cmd_set_mplsoudp_encap_label_value,
13692 (void *)&cmd_set_mplsoudp_encap_udp_src,
13693 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13694 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13695 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13696 (void *)&cmd_set_mplsoudp_encap_ip_src,
13697 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13698 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13699 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13700 (void *)&cmd_set_mplsoudp_encap_eth_src,
13701 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13702 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13703 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13708 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13709 .f = cmd_set_mplsoudp_encap_parsed,
13711 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13712 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13713 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13714 " eth-src <eth-src> eth-dst <eth-dst>",
13716 (void *)&cmd_set_mplsoudp_encap_set,
13717 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13718 (void *)&cmd_set_mplsoudp_encap_ip_version,
13719 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13720 (void *)&cmd_set_mplsoudp_encap_label,
13721 (void *)&cmd_set_mplsoudp_encap_label_value,
13722 (void *)&cmd_set_mplsoudp_encap_udp_src,
13723 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13724 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13725 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13726 (void *)&cmd_set_mplsoudp_encap_ip_src,
13727 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13728 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13729 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13730 (void *)&cmd_set_mplsoudp_encap_vlan,
13731 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13732 (void *)&cmd_set_mplsoudp_encap_eth_src,
13733 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13734 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13735 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13740 /** Set MPLSoUDP decapsulation details */
13741 struct cmd_set_mplsoudp_decap_result {
13742 cmdline_fixed_string_t set;
13743 cmdline_fixed_string_t mplsoudp;
13744 cmdline_fixed_string_t pos_token;
13745 cmdline_fixed_string_t ip_version;
13746 uint32_t vlan_present:1;
13749 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13750 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13752 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13753 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13755 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13756 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13757 mplsoudp, "mplsoudp_decap-with-vlan");
13758 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13759 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13760 pos_token, "ip-version");
13761 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13762 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13763 ip_version, "ipv4#ipv6");
13765 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13766 __rte_unused struct cmdline *cl,
13767 __rte_unused void *data)
13769 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13771 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13772 mplsoudp_decap_conf.select_vlan = 0;
13773 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13774 mplsoudp_decap_conf.select_vlan = 1;
13775 if (strcmp(res->ip_version, "ipv4") == 0)
13776 mplsoudp_decap_conf.select_ipv4 = 1;
13777 else if (strcmp(res->ip_version, "ipv6") == 0)
13778 mplsoudp_decap_conf.select_ipv4 = 0;
13781 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13782 .f = cmd_set_mplsoudp_decap_parsed,
13784 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13786 (void *)&cmd_set_mplsoudp_decap_set,
13787 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13788 (void *)&cmd_set_mplsoudp_decap_ip_version,
13789 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13794 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13795 .f = cmd_set_mplsoudp_decap_parsed,
13797 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13799 (void *)&cmd_set_mplsoudp_decap_set,
13800 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13801 (void *)&cmd_set_mplsoudp_decap_ip_version,
13802 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13807 /** Set connection tracking object common details */
13808 struct cmd_set_conntrack_common_result {
13809 cmdline_fixed_string_t set;
13810 cmdline_fixed_string_t conntrack;
13811 cmdline_fixed_string_t common;
13812 cmdline_fixed_string_t peer;
13813 cmdline_fixed_string_t is_orig;
13814 cmdline_fixed_string_t enable;
13815 cmdline_fixed_string_t live;
13816 cmdline_fixed_string_t sack;
13817 cmdline_fixed_string_t cack;
13818 cmdline_fixed_string_t last_dir;
13819 cmdline_fixed_string_t liberal;
13820 cmdline_fixed_string_t state;
13821 cmdline_fixed_string_t max_ack_win;
13822 cmdline_fixed_string_t retrans;
13823 cmdline_fixed_string_t last_win;
13824 cmdline_fixed_string_t last_seq;
13825 cmdline_fixed_string_t last_ack;
13826 cmdline_fixed_string_t last_end;
13827 cmdline_fixed_string_t last_index;
13830 uint16_t peer_port;
13831 uint32_t is_original;
13846 cmdline_parse_token_string_t cmd_set_conntrack_set =
13847 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13849 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13850 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13851 conntrack, "conntrack");
13852 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13853 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13855 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13856 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13858 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13859 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13860 peer_port, RTE_UINT16);
13861 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13862 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13863 is_orig, "is_orig");
13864 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13865 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13866 is_original, RTE_UINT32);
13867 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13868 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13870 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13871 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13873 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13874 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13876 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13877 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13878 is_live, RTE_UINT32);
13879 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13880 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13882 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13883 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13884 s_ack, RTE_UINT32);
13885 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13886 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13888 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13889 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13890 c_ack, RTE_UINT32);
13891 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13892 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13893 last_dir, "last_dir");
13894 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13895 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13897 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13898 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13899 liberal, "liberal");
13900 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13901 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13903 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13904 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13906 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13907 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13909 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13910 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13911 max_ack_win, "max_ack_win");
13912 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13913 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13914 factor, RTE_UINT8);
13915 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13916 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13918 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13919 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13920 re_num, RTE_UINT8);
13921 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13922 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13923 last_win, "last_win");
13924 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13925 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13927 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13928 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13929 last_seq, "last_seq");
13930 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13931 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13933 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13934 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13935 last_ack, "last_ack");
13936 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13937 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13939 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13940 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13941 last_end, "last_end");
13942 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13943 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13945 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13946 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13947 last_index, "last_index");
13948 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13949 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13952 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13953 __rte_unused struct cmdline *cl,
13954 __rte_unused void *data)
13956 struct cmd_set_conntrack_common_result *res = parsed_result;
13958 /* No need to swap to big endian. */
13959 conntrack_context.peer_port = res->peer_port;
13960 conntrack_context.is_original_dir = res->is_original;
13961 conntrack_context.enable = res->en;
13962 conntrack_context.live_connection = res->is_live;
13963 conntrack_context.selective_ack = res->s_ack;
13964 conntrack_context.challenge_ack_passed = res->c_ack;
13965 conntrack_context.last_direction = res->ld;
13966 conntrack_context.liberal_mode = res->lb;
13967 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13968 conntrack_context.max_ack_window = res->factor;
13969 conntrack_context.retransmission_limit = res->re_num;
13970 conntrack_context.last_window = res->lw;
13971 conntrack_context.last_index =
13972 (enum rte_flow_conntrack_tcp_last_index)res->li;
13973 conntrack_context.last_seq = res->ls;
13974 conntrack_context.last_ack = res->la;
13975 conntrack_context.last_end = res->le;
13978 cmdline_parse_inst_t cmd_set_conntrack_common = {
13979 .f = cmd_set_conntrack_common_parsed,
13981 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13982 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13983 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13984 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13985 " last_index <flag>",
13987 (void *)&cmd_set_conntrack_set,
13988 (void *)&cmd_set_conntrack_conntrack,
13989 (void *)&cmd_set_conntrack_common_com,
13990 (void *)&cmd_set_conntrack_common_peer,
13991 (void *)&cmd_set_conntrack_common_peer_value,
13992 (void *)&cmd_set_conntrack_common_is_orig,
13993 (void *)&cmd_set_conntrack_common_is_orig_value,
13994 (void *)&cmd_set_conntrack_common_enable,
13995 (void *)&cmd_set_conntrack_common_enable_value,
13996 (void *)&cmd_set_conntrack_common_live,
13997 (void *)&cmd_set_conntrack_common_live_value,
13998 (void *)&cmd_set_conntrack_common_sack,
13999 (void *)&cmd_set_conntrack_common_sack_value,
14000 (void *)&cmd_set_conntrack_common_cack,
14001 (void *)&cmd_set_conntrack_common_cack_value,
14002 (void *)&cmd_set_conntrack_common_last_dir,
14003 (void *)&cmd_set_conntrack_common_last_dir_value,
14004 (void *)&cmd_set_conntrack_common_liberal,
14005 (void *)&cmd_set_conntrack_common_liberal_value,
14006 (void *)&cmd_set_conntrack_common_state,
14007 (void *)&cmd_set_conntrack_common_state_value,
14008 (void *)&cmd_set_conntrack_common_max_ackwin,
14009 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14010 (void *)&cmd_set_conntrack_common_retrans,
14011 (void *)&cmd_set_conntrack_common_retrans_value,
14012 (void *)&cmd_set_conntrack_common_last_win,
14013 (void *)&cmd_set_conntrack_common_last_win_value,
14014 (void *)&cmd_set_conntrack_common_last_seq,
14015 (void *)&cmd_set_conntrack_common_last_seq_value,
14016 (void *)&cmd_set_conntrack_common_last_ack,
14017 (void *)&cmd_set_conntrack_common_last_ack_value,
14018 (void *)&cmd_set_conntrack_common_last_end,
14019 (void *)&cmd_set_conntrack_common_last_end_value,
14020 (void *)&cmd_set_conntrack_common_last_index,
14021 (void *)&cmd_set_conntrack_common_last_index_value,
14026 /** Set connection tracking object both directions' details */
14027 struct cmd_set_conntrack_dir_result {
14028 cmdline_fixed_string_t set;
14029 cmdline_fixed_string_t conntrack;
14030 cmdline_fixed_string_t dir;
14031 cmdline_fixed_string_t scale;
14032 cmdline_fixed_string_t fin;
14033 cmdline_fixed_string_t ack_seen;
14034 cmdline_fixed_string_t unack;
14035 cmdline_fixed_string_t sent_end;
14036 cmdline_fixed_string_t reply_end;
14037 cmdline_fixed_string_t max_win;
14038 cmdline_fixed_string_t max_ack;
14049 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14050 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14052 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14053 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14054 conntrack, "conntrack");
14055 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14056 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14058 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14059 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14061 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14062 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14063 factor, RTE_UINT32);
14064 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14065 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14067 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14068 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14070 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14071 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14072 ack_seen, "acked");
14073 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14074 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14076 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14077 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14078 unack, "unack_data");
14079 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14080 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14082 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14083 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14084 sent_end, "sent_end");
14085 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14086 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14088 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14089 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14090 reply_end, "reply_end");
14091 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14092 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14094 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14095 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14096 max_win, "max_win");
14097 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14098 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14100 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14101 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14102 max_ack, "max_ack");
14103 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14104 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14107 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14108 __rte_unused struct cmdline *cl,
14109 __rte_unused void *data)
14111 struct cmd_set_conntrack_dir_result *res = parsed_result;
14112 struct rte_flow_tcp_dir_param *dir = NULL;
14114 if (strcmp(res->dir, "orig") == 0)
14115 dir = &conntrack_context.original_dir;
14116 else if (strcmp(res->dir, "rply") == 0)
14117 dir = &conntrack_context.reply_dir;
14120 dir->scale = res->factor;
14121 dir->close_initiated = res->f;
14122 dir->last_ack_seen = res->as;
14123 dir->data_unacked = res->un;
14124 dir->sent_end = res->se;
14125 dir->reply_end = res->re;
14126 dir->max_ack = res->ma;
14127 dir->max_win = res->mw;
14130 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14131 .f = cmd_set_conntrack_dir_parsed,
14133 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14134 " acked <seen> unack_data <unack> sent_end <sent>"
14135 " reply_end <reply> max_win <win> max_ack <ack>",
14137 (void *)&cmd_set_conntrack_set,
14138 (void *)&cmd_set_conntrack_conntrack,
14139 (void *)&cmd_set_conntrack_dir_dir,
14140 (void *)&cmd_set_conntrack_dir_scale,
14141 (void *)&cmd_set_conntrack_dir_scale_value,
14142 (void *)&cmd_set_conntrack_dir_fin,
14143 (void *)&cmd_set_conntrack_dir_fin_value,
14144 (void *)&cmd_set_conntrack_dir_ack,
14145 (void *)&cmd_set_conntrack_dir_ack_value,
14146 (void *)&cmd_set_conntrack_dir_unack_data,
14147 (void *)&cmd_set_conntrack_dir_unack_data_value,
14148 (void *)&cmd_set_conntrack_dir_sent_end,
14149 (void *)&cmd_set_conntrack_dir_sent_end_value,
14150 (void *)&cmd_set_conntrack_dir_reply_end,
14151 (void *)&cmd_set_conntrack_dir_reply_end_value,
14152 (void *)&cmd_set_conntrack_dir_max_win,
14153 (void *)&cmd_set_conntrack_dir_max_win_value,
14154 (void *)&cmd_set_conntrack_dir_max_ack,
14155 (void *)&cmd_set_conntrack_dir_max_ack_value,
14160 /* Strict link priority scheduling mode setting */
14162 cmd_strict_link_prio_parsed(
14163 void *parsed_result,
14164 __rte_unused struct cmdline *cl,
14165 __rte_unused void *data)
14167 struct cmd_vf_tc_bw_result *res = parsed_result;
14168 int ret = -ENOTSUP;
14170 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14173 #ifdef RTE_NET_I40E
14174 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14181 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14184 printf("invalid port_id %d\n", res->port_id);
14187 printf("function not implemented\n");
14190 printf("programming error: (%s)\n", strerror(-ret));
14194 cmdline_parse_inst_t cmd_strict_link_prio = {
14195 .f = cmd_strict_link_prio_parsed,
14197 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14199 (void *)&cmd_vf_tc_bw_set,
14200 (void *)&cmd_vf_tc_bw_tx,
14201 (void *)&cmd_vf_tc_bw_strict_link_prio,
14202 (void *)&cmd_vf_tc_bw_port_id,
14203 (void *)&cmd_vf_tc_bw_tc_map,
14208 /* Load dynamic device personalization*/
14209 struct cmd_ddp_add_result {
14210 cmdline_fixed_string_t ddp;
14211 cmdline_fixed_string_t add;
14216 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14217 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14218 cmdline_parse_token_string_t cmd_ddp_add_add =
14219 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14220 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14221 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14223 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14224 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14227 cmd_ddp_add_parsed(
14228 void *parsed_result,
14229 __rte_unused struct cmdline *cl,
14230 __rte_unused void *data)
14232 struct cmd_ddp_add_result *res = parsed_result;
14238 int ret = -ENOTSUP;
14240 if (!all_ports_stopped()) {
14241 printf("Please stop all ports first\n");
14245 filepath = strdup(res->filepath);
14246 if (filepath == NULL) {
14247 printf("Failed to allocate memory\n");
14250 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14252 buff = open_file(file_fld[0], &size);
14254 free((void *)filepath);
14258 #ifdef RTE_NET_I40E
14259 if (ret == -ENOTSUP)
14260 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14262 RTE_PMD_I40E_PKG_OP_WR_ADD);
14265 if (ret == -EEXIST)
14266 printf("Profile has already existed.\n");
14268 printf("Failed to load profile.\n");
14269 else if (file_num == 2)
14270 save_file(file_fld[1], buff, size);
14273 free((void *)filepath);
14276 cmdline_parse_inst_t cmd_ddp_add = {
14277 .f = cmd_ddp_add_parsed,
14279 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14281 (void *)&cmd_ddp_add_ddp,
14282 (void *)&cmd_ddp_add_add,
14283 (void *)&cmd_ddp_add_port_id,
14284 (void *)&cmd_ddp_add_filepath,
14289 /* Delete dynamic device personalization*/
14290 struct cmd_ddp_del_result {
14291 cmdline_fixed_string_t ddp;
14292 cmdline_fixed_string_t del;
14297 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14298 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14299 cmdline_parse_token_string_t cmd_ddp_del_del =
14300 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14301 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14302 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14303 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14304 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14307 cmd_ddp_del_parsed(
14308 void *parsed_result,
14309 __rte_unused struct cmdline *cl,
14310 __rte_unused void *data)
14312 struct cmd_ddp_del_result *res = parsed_result;
14315 int ret = -ENOTSUP;
14317 if (!all_ports_stopped()) {
14318 printf("Please stop all ports first\n");
14322 buff = open_file(res->filepath, &size);
14326 #ifdef RTE_NET_I40E
14327 if (ret == -ENOTSUP)
14328 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14330 RTE_PMD_I40E_PKG_OP_WR_DEL);
14333 if (ret == -EACCES)
14334 printf("Profile does not exist.\n");
14336 printf("Failed to delete profile.\n");
14341 cmdline_parse_inst_t cmd_ddp_del = {
14342 .f = cmd_ddp_del_parsed,
14344 .help_str = "ddp del <port_id> <backup_profile_path>",
14346 (void *)&cmd_ddp_del_ddp,
14347 (void *)&cmd_ddp_del_del,
14348 (void *)&cmd_ddp_del_port_id,
14349 (void *)&cmd_ddp_del_filepath,
14354 /* Get dynamic device personalization profile info */
14355 struct cmd_ddp_info_result {
14356 cmdline_fixed_string_t ddp;
14357 cmdline_fixed_string_t get;
14358 cmdline_fixed_string_t info;
14362 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14363 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14364 cmdline_parse_token_string_t cmd_ddp_info_get =
14365 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14366 cmdline_parse_token_string_t cmd_ddp_info_info =
14367 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14368 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14369 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14372 cmd_ddp_info_parsed(
14373 void *parsed_result,
14374 __rte_unused struct cmdline *cl,
14375 __rte_unused void *data)
14377 struct cmd_ddp_info_result *res = parsed_result;
14380 int ret = -ENOTSUP;
14381 #ifdef RTE_NET_I40E
14384 uint32_t buff_size = 0;
14385 struct rte_pmd_i40e_profile_info info;
14386 uint32_t dev_num = 0;
14387 struct rte_pmd_i40e_ddp_device_id *devs;
14388 uint32_t proto_num = 0;
14389 struct rte_pmd_i40e_proto_info *proto = NULL;
14390 uint32_t pctype_num = 0;
14391 struct rte_pmd_i40e_ptype_info *pctype;
14392 uint32_t ptype_num = 0;
14393 struct rte_pmd_i40e_ptype_info *ptype;
14398 pkg = open_file(res->filepath, &pkg_size);
14402 #ifdef RTE_NET_I40E
14403 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14404 (uint8_t *)&info, sizeof(info),
14405 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14407 printf("Global Track id: 0x%x\n", info.track_id);
14408 printf("Global Version: %d.%d.%d.%d\n",
14409 info.version.major,
14410 info.version.minor,
14411 info.version.update,
14412 info.version.draft);
14413 printf("Global Package name: %s\n\n", info.name);
14416 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14417 (uint8_t *)&info, sizeof(info),
14418 RTE_PMD_I40E_PKG_INFO_HEADER);
14420 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14421 printf("i40e Profile Version: %d.%d.%d.%d\n",
14422 info.version.major,
14423 info.version.minor,
14424 info.version.update,
14425 info.version.draft);
14426 printf("i40e Profile name: %s\n\n", info.name);
14429 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14430 (uint8_t *)&buff_size, sizeof(buff_size),
14431 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14432 if (!ret && buff_size) {
14433 buff = (uint8_t *)malloc(buff_size);
14435 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14437 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14439 printf("Package Notes:\n%s\n\n", buff);
14444 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14445 (uint8_t *)&dev_num, sizeof(dev_num),
14446 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14447 if (!ret && dev_num) {
14448 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14449 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14451 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14452 (uint8_t *)devs, buff_size,
14453 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14455 printf("List of supported devices:\n");
14456 for (i = 0; i < dev_num; i++) {
14457 printf(" %04X:%04X %04X:%04X\n",
14458 devs[i].vendor_dev_id >> 16,
14459 devs[i].vendor_dev_id & 0xFFFF,
14460 devs[i].sub_vendor_dev_id >> 16,
14461 devs[i].sub_vendor_dev_id & 0xFFFF);
14469 /* get information about protocols and packet types */
14470 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14471 (uint8_t *)&proto_num, sizeof(proto_num),
14472 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14473 if (ret || !proto_num)
14474 goto no_print_return;
14476 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14477 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14479 goto no_print_return;
14481 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14483 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14485 printf("List of used protocols:\n");
14486 for (i = 0; i < proto_num; i++)
14487 printf(" %2u: %s\n", proto[i].proto_id,
14491 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14492 (uint8_t *)&pctype_num, sizeof(pctype_num),
14493 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14494 if (ret || !pctype_num)
14495 goto no_print_pctypes;
14497 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14498 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14500 goto no_print_pctypes;
14502 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14504 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14507 goto no_print_pctypes;
14510 printf("List of defined packet classification types:\n");
14511 for (i = 0; i < pctype_num; i++) {
14512 printf(" %2u:", pctype[i].ptype_id);
14513 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14514 proto_id = pctype[i].protocols[j];
14515 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14516 for (n = 0; n < proto_num; n++) {
14517 if (proto[n].proto_id == proto_id) {
14518 printf(" %s", proto[n].name);
14531 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14533 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14534 if (ret || !ptype_num)
14535 goto no_print_return;
14537 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14538 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14540 goto no_print_return;
14542 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14544 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14547 goto no_print_return;
14549 printf("List of defined packet types:\n");
14550 for (i = 0; i < ptype_num; i++) {
14551 printf(" %2u:", ptype[i].ptype_id);
14552 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14553 proto_id = ptype[i].protocols[j];
14554 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14555 for (n = 0; n < proto_num; n++) {
14556 if (proto[n].proto_id == proto_id) {
14557 printf(" %s", proto[n].name);
14573 if (ret == -ENOTSUP)
14574 printf("Function not supported in PMD driver\n");
14578 cmdline_parse_inst_t cmd_ddp_get_info = {
14579 .f = cmd_ddp_info_parsed,
14581 .help_str = "ddp get info <profile_path>",
14583 (void *)&cmd_ddp_info_ddp,
14584 (void *)&cmd_ddp_info_get,
14585 (void *)&cmd_ddp_info_info,
14586 (void *)&cmd_ddp_info_filepath,
14591 /* Get dynamic device personalization profile info list*/
14592 #define PROFILE_INFO_SIZE 48
14593 #define MAX_PROFILE_NUM 16
14595 struct cmd_ddp_get_list_result {
14596 cmdline_fixed_string_t ddp;
14597 cmdline_fixed_string_t get;
14598 cmdline_fixed_string_t list;
14602 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14603 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14604 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14605 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14606 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14607 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14608 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14609 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14613 cmd_ddp_get_list_parsed(
14614 __rte_unused void *parsed_result,
14615 __rte_unused struct cmdline *cl,
14616 __rte_unused void *data)
14618 #ifdef RTE_NET_I40E
14619 struct cmd_ddp_get_list_result *res = parsed_result;
14620 struct rte_pmd_i40e_profile_list *p_list;
14621 struct rte_pmd_i40e_profile_info *p_info;
14626 int ret = -ENOTSUP;
14628 #ifdef RTE_NET_I40E
14629 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14630 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14632 printf("%s: Failed to malloc buffer\n", __func__);
14636 if (ret == -ENOTSUP)
14637 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14638 (uint8_t *)p_list, size);
14641 p_num = p_list->p_count;
14642 printf("Profile number is: %d\n\n", p_num);
14644 for (i = 0; i < p_num; i++) {
14645 p_info = &p_list->p_info[i];
14646 printf("Profile %d:\n", i);
14647 printf("Track id: 0x%x\n", p_info->track_id);
14648 printf("Version: %d.%d.%d.%d\n",
14649 p_info->version.major,
14650 p_info->version.minor,
14651 p_info->version.update,
14652 p_info->version.draft);
14653 printf("Profile name: %s\n\n", p_info->name);
14661 printf("Failed to get ddp list\n");
14664 cmdline_parse_inst_t cmd_ddp_get_list = {
14665 .f = cmd_ddp_get_list_parsed,
14667 .help_str = "ddp get list <port_id>",
14669 (void *)&cmd_ddp_get_list_ddp,
14670 (void *)&cmd_ddp_get_list_get,
14671 (void *)&cmd_ddp_get_list_list,
14672 (void *)&cmd_ddp_get_list_port_id,
14677 /* Configure input set */
14678 struct cmd_cfg_input_set_result {
14679 cmdline_fixed_string_t port;
14680 cmdline_fixed_string_t cfg;
14682 cmdline_fixed_string_t pctype;
14684 cmdline_fixed_string_t inset_type;
14685 cmdline_fixed_string_t opt;
14686 cmdline_fixed_string_t field;
14691 cmd_cfg_input_set_parsed(
14692 __rte_unused void *parsed_result,
14693 __rte_unused struct cmdline *cl,
14694 __rte_unused void *data)
14696 #ifdef RTE_NET_I40E
14697 struct cmd_cfg_input_set_result *res = parsed_result;
14698 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14699 struct rte_pmd_i40e_inset inset;
14701 int ret = -ENOTSUP;
14703 if (!all_ports_stopped()) {
14704 printf("Please stop all ports first\n");
14708 #ifdef RTE_NET_I40E
14709 if (!strcmp(res->inset_type, "hash_inset"))
14710 inset_type = INSET_HASH;
14711 else if (!strcmp(res->inset_type, "fdir_inset"))
14712 inset_type = INSET_FDIR;
14713 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14714 inset_type = INSET_FDIR_FLX;
14715 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14716 &inset, inset_type);
14718 printf("Failed to get input set.\n");
14722 if (!strcmp(res->opt, "get")) {
14723 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14726 printf("Field index %d is enabled.\n", res->field_idx);
14728 printf("Field index %d is disabled.\n", res->field_idx);
14730 } else if (!strcmp(res->opt, "set"))
14731 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14733 else if (!strcmp(res->opt, "clear"))
14734 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14737 printf("Failed to configure input set field.\n");
14741 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14742 &inset, inset_type);
14744 printf("Failed to set input set.\n");
14749 if (ret == -ENOTSUP)
14750 printf("Function not supported\n");
14753 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14754 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14756 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14757 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14759 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14760 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14761 port_id, RTE_UINT16);
14762 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14763 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14765 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14766 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14767 pctype_id, RTE_UINT8);
14768 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14769 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14771 "hash_inset#fdir_inset#fdir_flx_inset");
14772 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14773 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14774 opt, "get#set#clear");
14775 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14776 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14778 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14779 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14780 field_idx, RTE_UINT8);
14782 cmdline_parse_inst_t cmd_cfg_input_set = {
14783 .f = cmd_cfg_input_set_parsed,
14785 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14786 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14788 (void *)&cmd_cfg_input_set_port,
14789 (void *)&cmd_cfg_input_set_cfg,
14790 (void *)&cmd_cfg_input_set_port_id,
14791 (void *)&cmd_cfg_input_set_pctype,
14792 (void *)&cmd_cfg_input_set_pctype_id,
14793 (void *)&cmd_cfg_input_set_inset_type,
14794 (void *)&cmd_cfg_input_set_opt,
14795 (void *)&cmd_cfg_input_set_field,
14796 (void *)&cmd_cfg_input_set_field_idx,
14801 /* Clear input set */
14802 struct cmd_clear_input_set_result {
14803 cmdline_fixed_string_t port;
14804 cmdline_fixed_string_t cfg;
14806 cmdline_fixed_string_t pctype;
14808 cmdline_fixed_string_t inset_type;
14809 cmdline_fixed_string_t clear;
14810 cmdline_fixed_string_t all;
14814 cmd_clear_input_set_parsed(
14815 __rte_unused void *parsed_result,
14816 __rte_unused struct cmdline *cl,
14817 __rte_unused void *data)
14819 #ifdef RTE_NET_I40E
14820 struct cmd_clear_input_set_result *res = parsed_result;
14821 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14822 struct rte_pmd_i40e_inset inset;
14824 int ret = -ENOTSUP;
14826 if (!all_ports_stopped()) {
14827 printf("Please stop all ports first\n");
14831 #ifdef RTE_NET_I40E
14832 if (!strcmp(res->inset_type, "hash_inset"))
14833 inset_type = INSET_HASH;
14834 else if (!strcmp(res->inset_type, "fdir_inset"))
14835 inset_type = INSET_FDIR;
14836 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14837 inset_type = INSET_FDIR_FLX;
14839 memset(&inset, 0, sizeof(inset));
14841 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14842 &inset, inset_type);
14844 printf("Failed to clear input set.\n");
14850 if (ret == -ENOTSUP)
14851 printf("Function not supported\n");
14854 cmdline_parse_token_string_t cmd_clear_input_set_port =
14855 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14857 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14858 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14860 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14861 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14862 port_id, RTE_UINT16);
14863 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14864 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14866 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14867 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14868 pctype_id, RTE_UINT8);
14869 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14870 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14872 "hash_inset#fdir_inset#fdir_flx_inset");
14873 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14874 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14876 cmdline_parse_token_string_t cmd_clear_input_set_all =
14877 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14880 cmdline_parse_inst_t cmd_clear_input_set = {
14881 .f = cmd_clear_input_set_parsed,
14883 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14884 "fdir_inset|fdir_flx_inset clear all",
14886 (void *)&cmd_clear_input_set_port,
14887 (void *)&cmd_clear_input_set_cfg,
14888 (void *)&cmd_clear_input_set_port_id,
14889 (void *)&cmd_clear_input_set_pctype,
14890 (void *)&cmd_clear_input_set_pctype_id,
14891 (void *)&cmd_clear_input_set_inset_type,
14892 (void *)&cmd_clear_input_set_clear,
14893 (void *)&cmd_clear_input_set_all,
14898 /* show vf stats */
14900 /* Common result structure for show vf stats */
14901 struct cmd_show_vf_stats_result {
14902 cmdline_fixed_string_t show;
14903 cmdline_fixed_string_t vf;
14904 cmdline_fixed_string_t stats;
14909 /* Common CLI fields show vf stats*/
14910 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14911 TOKEN_STRING_INITIALIZER
14912 (struct cmd_show_vf_stats_result,
14914 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14915 TOKEN_STRING_INITIALIZER
14916 (struct cmd_show_vf_stats_result,
14918 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14919 TOKEN_STRING_INITIALIZER
14920 (struct cmd_show_vf_stats_result,
14922 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14923 TOKEN_NUM_INITIALIZER
14924 (struct cmd_show_vf_stats_result,
14925 port_id, RTE_UINT16);
14926 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14927 TOKEN_NUM_INITIALIZER
14928 (struct cmd_show_vf_stats_result,
14929 vf_id, RTE_UINT16);
14932 cmd_show_vf_stats_parsed(
14933 void *parsed_result,
14934 __rte_unused struct cmdline *cl,
14935 __rte_unused void *data)
14937 struct cmd_show_vf_stats_result *res = parsed_result;
14938 struct rte_eth_stats stats;
14939 int ret = -ENOTSUP;
14940 static const char *nic_stats_border = "########################";
14942 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14945 memset(&stats, 0, sizeof(stats));
14947 #ifdef RTE_NET_I40E
14948 if (ret == -ENOTSUP)
14949 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14953 #ifdef RTE_NET_BNXT
14954 if (ret == -ENOTSUP)
14955 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14964 printf("invalid vf_id %d\n", res->vf_id);
14967 printf("invalid port_id %d\n", res->port_id);
14970 printf("function not implemented\n");
14973 printf("programming error: (%s)\n", strerror(-ret));
14976 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14977 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14979 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14981 stats.ipackets, stats.imissed, stats.ibytes);
14982 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14983 printf(" RX-nombuf: %-10"PRIu64"\n",
14985 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14987 stats.opackets, stats.oerrors, stats.obytes);
14989 printf(" %s############################%s\n",
14990 nic_stats_border, nic_stats_border);
14993 cmdline_parse_inst_t cmd_show_vf_stats = {
14994 .f = cmd_show_vf_stats_parsed,
14996 .help_str = "show vf stats <port_id> <vf_id>",
14998 (void *)&cmd_show_vf_stats_show,
14999 (void *)&cmd_show_vf_stats_vf,
15000 (void *)&cmd_show_vf_stats_stats,
15001 (void *)&cmd_show_vf_stats_port_id,
15002 (void *)&cmd_show_vf_stats_vf_id,
15007 /* clear vf stats */
15009 /* Common result structure for clear vf stats */
15010 struct cmd_clear_vf_stats_result {
15011 cmdline_fixed_string_t clear;
15012 cmdline_fixed_string_t vf;
15013 cmdline_fixed_string_t stats;
15018 /* Common CLI fields clear vf stats*/
15019 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15020 TOKEN_STRING_INITIALIZER
15021 (struct cmd_clear_vf_stats_result,
15023 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15024 TOKEN_STRING_INITIALIZER
15025 (struct cmd_clear_vf_stats_result,
15027 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15028 TOKEN_STRING_INITIALIZER
15029 (struct cmd_clear_vf_stats_result,
15031 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15032 TOKEN_NUM_INITIALIZER
15033 (struct cmd_clear_vf_stats_result,
15034 port_id, RTE_UINT16);
15035 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15036 TOKEN_NUM_INITIALIZER
15037 (struct cmd_clear_vf_stats_result,
15038 vf_id, RTE_UINT16);
15041 cmd_clear_vf_stats_parsed(
15042 void *parsed_result,
15043 __rte_unused struct cmdline *cl,
15044 __rte_unused void *data)
15046 struct cmd_clear_vf_stats_result *res = parsed_result;
15047 int ret = -ENOTSUP;
15049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15052 #ifdef RTE_NET_I40E
15053 if (ret == -ENOTSUP)
15054 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15057 #ifdef RTE_NET_BNXT
15058 if (ret == -ENOTSUP)
15059 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15067 printf("invalid vf_id %d\n", res->vf_id);
15070 printf("invalid port_id %d\n", res->port_id);
15073 printf("function not implemented\n");
15076 printf("programming error: (%s)\n", strerror(-ret));
15080 cmdline_parse_inst_t cmd_clear_vf_stats = {
15081 .f = cmd_clear_vf_stats_parsed,
15083 .help_str = "clear vf stats <port_id> <vf_id>",
15085 (void *)&cmd_clear_vf_stats_clear,
15086 (void *)&cmd_clear_vf_stats_vf,
15087 (void *)&cmd_clear_vf_stats_stats,
15088 (void *)&cmd_clear_vf_stats_port_id,
15089 (void *)&cmd_clear_vf_stats_vf_id,
15094 /* port config pctype mapping reset */
15096 /* Common result structure for port config pctype mapping reset */
15097 struct cmd_pctype_mapping_reset_result {
15098 cmdline_fixed_string_t port;
15099 cmdline_fixed_string_t config;
15101 cmdline_fixed_string_t pctype;
15102 cmdline_fixed_string_t mapping;
15103 cmdline_fixed_string_t reset;
15106 /* Common CLI fields for port config pctype mapping reset*/
15107 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15108 TOKEN_STRING_INITIALIZER
15109 (struct cmd_pctype_mapping_reset_result,
15111 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15112 TOKEN_STRING_INITIALIZER
15113 (struct cmd_pctype_mapping_reset_result,
15115 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15116 TOKEN_NUM_INITIALIZER
15117 (struct cmd_pctype_mapping_reset_result,
15118 port_id, RTE_UINT16);
15119 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15120 TOKEN_STRING_INITIALIZER
15121 (struct cmd_pctype_mapping_reset_result,
15123 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15124 TOKEN_STRING_INITIALIZER
15125 (struct cmd_pctype_mapping_reset_result,
15126 mapping, "mapping");
15127 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15128 TOKEN_STRING_INITIALIZER
15129 (struct cmd_pctype_mapping_reset_result,
15133 cmd_pctype_mapping_reset_parsed(
15134 void *parsed_result,
15135 __rte_unused struct cmdline *cl,
15136 __rte_unused void *data)
15138 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15139 int ret = -ENOTSUP;
15141 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15144 #ifdef RTE_NET_I40E
15145 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15152 printf("invalid port_id %d\n", res->port_id);
15155 printf("function not implemented\n");
15158 printf("programming error: (%s)\n", strerror(-ret));
15162 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15163 .f = cmd_pctype_mapping_reset_parsed,
15165 .help_str = "port config <port_id> pctype mapping reset",
15167 (void *)&cmd_pctype_mapping_reset_port,
15168 (void *)&cmd_pctype_mapping_reset_config,
15169 (void *)&cmd_pctype_mapping_reset_port_id,
15170 (void *)&cmd_pctype_mapping_reset_pctype,
15171 (void *)&cmd_pctype_mapping_reset_mapping,
15172 (void *)&cmd_pctype_mapping_reset_reset,
15177 /* show port pctype mapping */
15179 /* Common result structure for show port pctype mapping */
15180 struct cmd_pctype_mapping_get_result {
15181 cmdline_fixed_string_t show;
15182 cmdline_fixed_string_t port;
15184 cmdline_fixed_string_t pctype;
15185 cmdline_fixed_string_t mapping;
15188 /* Common CLI fields for pctype mapping get */
15189 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15190 TOKEN_STRING_INITIALIZER
15191 (struct cmd_pctype_mapping_get_result,
15193 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15194 TOKEN_STRING_INITIALIZER
15195 (struct cmd_pctype_mapping_get_result,
15197 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15198 TOKEN_NUM_INITIALIZER
15199 (struct cmd_pctype_mapping_get_result,
15200 port_id, RTE_UINT16);
15201 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15202 TOKEN_STRING_INITIALIZER
15203 (struct cmd_pctype_mapping_get_result,
15205 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15206 TOKEN_STRING_INITIALIZER
15207 (struct cmd_pctype_mapping_get_result,
15208 mapping, "mapping");
15211 cmd_pctype_mapping_get_parsed(
15212 void *parsed_result,
15213 __rte_unused struct cmdline *cl,
15214 __rte_unused void *data)
15216 struct cmd_pctype_mapping_get_result *res = parsed_result;
15217 int ret = -ENOTSUP;
15218 #ifdef RTE_NET_I40E
15219 struct rte_pmd_i40e_flow_type_mapping
15220 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15221 int i, j, first_pctype;
15224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15227 #ifdef RTE_NET_I40E
15228 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15235 printf("invalid port_id %d\n", res->port_id);
15238 printf("function not implemented\n");
15241 printf("programming error: (%s)\n", strerror(-ret));
15245 #ifdef RTE_NET_I40E
15246 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15247 if (mapping[i].pctype != 0ULL) {
15250 printf("pctype: ");
15251 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15252 if (mapping[i].pctype & (1ULL << j)) {
15253 printf(first_pctype ?
15254 "%02d" : ",%02d", j);
15258 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15264 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15265 .f = cmd_pctype_mapping_get_parsed,
15267 .help_str = "show port <port_id> pctype mapping",
15269 (void *)&cmd_pctype_mapping_get_show,
15270 (void *)&cmd_pctype_mapping_get_port,
15271 (void *)&cmd_pctype_mapping_get_port_id,
15272 (void *)&cmd_pctype_mapping_get_pctype,
15273 (void *)&cmd_pctype_mapping_get_mapping,
15278 /* port config pctype mapping update */
15280 /* Common result structure for port config pctype mapping update */
15281 struct cmd_pctype_mapping_update_result {
15282 cmdline_fixed_string_t port;
15283 cmdline_fixed_string_t config;
15285 cmdline_fixed_string_t pctype;
15286 cmdline_fixed_string_t mapping;
15287 cmdline_fixed_string_t update;
15288 cmdline_fixed_string_t pctype_list;
15289 uint16_t flow_type;
15292 /* Common CLI fields for pctype mapping update*/
15293 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15294 TOKEN_STRING_INITIALIZER
15295 (struct cmd_pctype_mapping_update_result,
15297 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15298 TOKEN_STRING_INITIALIZER
15299 (struct cmd_pctype_mapping_update_result,
15301 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15302 TOKEN_NUM_INITIALIZER
15303 (struct cmd_pctype_mapping_update_result,
15304 port_id, RTE_UINT16);
15305 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15306 TOKEN_STRING_INITIALIZER
15307 (struct cmd_pctype_mapping_update_result,
15309 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15310 TOKEN_STRING_INITIALIZER
15311 (struct cmd_pctype_mapping_update_result,
15312 mapping, "mapping");
15313 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15314 TOKEN_STRING_INITIALIZER
15315 (struct cmd_pctype_mapping_update_result,
15317 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15318 TOKEN_STRING_INITIALIZER
15319 (struct cmd_pctype_mapping_update_result,
15320 pctype_list, NULL);
15321 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15322 TOKEN_NUM_INITIALIZER
15323 (struct cmd_pctype_mapping_update_result,
15324 flow_type, RTE_UINT16);
15327 cmd_pctype_mapping_update_parsed(
15328 void *parsed_result,
15329 __rte_unused struct cmdline *cl,
15330 __rte_unused void *data)
15332 struct cmd_pctype_mapping_update_result *res = parsed_result;
15333 int ret = -ENOTSUP;
15334 #ifdef RTE_NET_I40E
15335 struct rte_pmd_i40e_flow_type_mapping mapping;
15337 unsigned int nb_item;
15338 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15341 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15344 #ifdef RTE_NET_I40E
15345 nb_item = parse_item_list(res->pctype_list, "pctypes",
15346 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15347 mapping.flow_type = res->flow_type;
15348 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15349 mapping.pctype |= (1ULL << pctype_list[i]);
15350 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15360 printf("invalid pctype or flow type\n");
15363 printf("invalid port_id %d\n", res->port_id);
15366 printf("function not implemented\n");
15369 printf("programming error: (%s)\n", strerror(-ret));
15373 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15374 .f = cmd_pctype_mapping_update_parsed,
15376 .help_str = "port config <port_id> pctype mapping update"
15377 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15379 (void *)&cmd_pctype_mapping_update_port,
15380 (void *)&cmd_pctype_mapping_update_config,
15381 (void *)&cmd_pctype_mapping_update_port_id,
15382 (void *)&cmd_pctype_mapping_update_pctype,
15383 (void *)&cmd_pctype_mapping_update_mapping,
15384 (void *)&cmd_pctype_mapping_update_update,
15385 (void *)&cmd_pctype_mapping_update_pc_type,
15386 (void *)&cmd_pctype_mapping_update_flow_type,
15391 /* ptype mapping get */
15393 /* Common result structure for ptype mapping get */
15394 struct cmd_ptype_mapping_get_result {
15395 cmdline_fixed_string_t ptype;
15396 cmdline_fixed_string_t mapping;
15397 cmdline_fixed_string_t get;
15399 uint8_t valid_only;
15402 /* Common CLI fields for ptype mapping get */
15403 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15404 TOKEN_STRING_INITIALIZER
15405 (struct cmd_ptype_mapping_get_result,
15407 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15408 TOKEN_STRING_INITIALIZER
15409 (struct cmd_ptype_mapping_get_result,
15410 mapping, "mapping");
15411 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15412 TOKEN_STRING_INITIALIZER
15413 (struct cmd_ptype_mapping_get_result,
15415 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15416 TOKEN_NUM_INITIALIZER
15417 (struct cmd_ptype_mapping_get_result,
15418 port_id, RTE_UINT16);
15419 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15420 TOKEN_NUM_INITIALIZER
15421 (struct cmd_ptype_mapping_get_result,
15422 valid_only, RTE_UINT8);
15425 cmd_ptype_mapping_get_parsed(
15426 void *parsed_result,
15427 __rte_unused struct cmdline *cl,
15428 __rte_unused void *data)
15430 struct cmd_ptype_mapping_get_result *res = parsed_result;
15431 int ret = -ENOTSUP;
15432 #ifdef RTE_NET_I40E
15433 int max_ptype_num = 256;
15434 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15439 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15442 #ifdef RTE_NET_I40E
15443 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15454 printf("invalid port_id %d\n", res->port_id);
15457 printf("function not implemented\n");
15460 printf("programming error: (%s)\n", strerror(-ret));
15463 #ifdef RTE_NET_I40E
15465 for (i = 0; i < count; i++)
15466 printf("%3d\t0x%08x\n",
15467 mapping[i].hw_ptype, mapping[i].sw_ptype);
15472 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15473 .f = cmd_ptype_mapping_get_parsed,
15475 .help_str = "ptype mapping get <port_id> <valid_only>",
15477 (void *)&cmd_ptype_mapping_get_ptype,
15478 (void *)&cmd_ptype_mapping_get_mapping,
15479 (void *)&cmd_ptype_mapping_get_get,
15480 (void *)&cmd_ptype_mapping_get_port_id,
15481 (void *)&cmd_ptype_mapping_get_valid_only,
15486 /* ptype mapping replace */
15488 /* Common result structure for ptype mapping replace */
15489 struct cmd_ptype_mapping_replace_result {
15490 cmdline_fixed_string_t ptype;
15491 cmdline_fixed_string_t mapping;
15492 cmdline_fixed_string_t replace;
15499 /* Common CLI fields for ptype mapping replace */
15500 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15501 TOKEN_STRING_INITIALIZER
15502 (struct cmd_ptype_mapping_replace_result,
15504 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15505 TOKEN_STRING_INITIALIZER
15506 (struct cmd_ptype_mapping_replace_result,
15507 mapping, "mapping");
15508 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15509 TOKEN_STRING_INITIALIZER
15510 (struct cmd_ptype_mapping_replace_result,
15511 replace, "replace");
15512 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15513 TOKEN_NUM_INITIALIZER
15514 (struct cmd_ptype_mapping_replace_result,
15515 port_id, RTE_UINT16);
15516 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15517 TOKEN_NUM_INITIALIZER
15518 (struct cmd_ptype_mapping_replace_result,
15519 target, RTE_UINT32);
15520 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15521 TOKEN_NUM_INITIALIZER
15522 (struct cmd_ptype_mapping_replace_result,
15524 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15525 TOKEN_NUM_INITIALIZER
15526 (struct cmd_ptype_mapping_replace_result,
15527 pkt_type, RTE_UINT32);
15530 cmd_ptype_mapping_replace_parsed(
15531 void *parsed_result,
15532 __rte_unused struct cmdline *cl,
15533 __rte_unused void *data)
15535 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15536 int ret = -ENOTSUP;
15538 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15541 #ifdef RTE_NET_I40E
15542 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15552 printf("invalid ptype 0x%8x or 0x%8x\n",
15553 res->target, res->pkt_type);
15556 printf("invalid port_id %d\n", res->port_id);
15559 printf("function not implemented\n");
15562 printf("programming error: (%s)\n", strerror(-ret));
15566 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15567 .f = cmd_ptype_mapping_replace_parsed,
15570 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15572 (void *)&cmd_ptype_mapping_replace_ptype,
15573 (void *)&cmd_ptype_mapping_replace_mapping,
15574 (void *)&cmd_ptype_mapping_replace_replace,
15575 (void *)&cmd_ptype_mapping_replace_port_id,
15576 (void *)&cmd_ptype_mapping_replace_target,
15577 (void *)&cmd_ptype_mapping_replace_mask,
15578 (void *)&cmd_ptype_mapping_replace_pkt_type,
15583 /* ptype mapping reset */
15585 /* Common result structure for ptype mapping reset */
15586 struct cmd_ptype_mapping_reset_result {
15587 cmdline_fixed_string_t ptype;
15588 cmdline_fixed_string_t mapping;
15589 cmdline_fixed_string_t reset;
15593 /* Common CLI fields for ptype mapping reset*/
15594 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15595 TOKEN_STRING_INITIALIZER
15596 (struct cmd_ptype_mapping_reset_result,
15598 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15599 TOKEN_STRING_INITIALIZER
15600 (struct cmd_ptype_mapping_reset_result,
15601 mapping, "mapping");
15602 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15603 TOKEN_STRING_INITIALIZER
15604 (struct cmd_ptype_mapping_reset_result,
15606 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15607 TOKEN_NUM_INITIALIZER
15608 (struct cmd_ptype_mapping_reset_result,
15609 port_id, RTE_UINT16);
15612 cmd_ptype_mapping_reset_parsed(
15613 void *parsed_result,
15614 __rte_unused struct cmdline *cl,
15615 __rte_unused void *data)
15617 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15618 int ret = -ENOTSUP;
15620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15623 #ifdef RTE_NET_I40E
15624 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15631 printf("invalid port_id %d\n", res->port_id);
15634 printf("function not implemented\n");
15637 printf("programming error: (%s)\n", strerror(-ret));
15641 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15642 .f = cmd_ptype_mapping_reset_parsed,
15644 .help_str = "ptype mapping reset <port_id>",
15646 (void *)&cmd_ptype_mapping_reset_ptype,
15647 (void *)&cmd_ptype_mapping_reset_mapping,
15648 (void *)&cmd_ptype_mapping_reset_reset,
15649 (void *)&cmd_ptype_mapping_reset_port_id,
15654 /* ptype mapping update */
15656 /* Common result structure for ptype mapping update */
15657 struct cmd_ptype_mapping_update_result {
15658 cmdline_fixed_string_t ptype;
15659 cmdline_fixed_string_t mapping;
15660 cmdline_fixed_string_t reset;
15666 /* Common CLI fields for ptype mapping update*/
15667 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15668 TOKEN_STRING_INITIALIZER
15669 (struct cmd_ptype_mapping_update_result,
15671 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15672 TOKEN_STRING_INITIALIZER
15673 (struct cmd_ptype_mapping_update_result,
15674 mapping, "mapping");
15675 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15676 TOKEN_STRING_INITIALIZER
15677 (struct cmd_ptype_mapping_update_result,
15679 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15680 TOKEN_NUM_INITIALIZER
15681 (struct cmd_ptype_mapping_update_result,
15682 port_id, RTE_UINT16);
15683 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15684 TOKEN_NUM_INITIALIZER
15685 (struct cmd_ptype_mapping_update_result,
15686 hw_ptype, RTE_UINT8);
15687 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15688 TOKEN_NUM_INITIALIZER
15689 (struct cmd_ptype_mapping_update_result,
15690 sw_ptype, RTE_UINT32);
15693 cmd_ptype_mapping_update_parsed(
15694 void *parsed_result,
15695 __rte_unused struct cmdline *cl,
15696 __rte_unused void *data)
15698 struct cmd_ptype_mapping_update_result *res = parsed_result;
15699 int ret = -ENOTSUP;
15700 #ifdef RTE_NET_I40E
15701 struct rte_pmd_i40e_ptype_mapping mapping;
15703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15706 #ifdef RTE_NET_I40E
15707 mapping.hw_ptype = res->hw_ptype;
15708 mapping.sw_ptype = res->sw_ptype;
15709 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15719 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15722 printf("invalid port_id %d\n", res->port_id);
15725 printf("function not implemented\n");
15728 printf("programming error: (%s)\n", strerror(-ret));
15732 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15733 .f = cmd_ptype_mapping_update_parsed,
15735 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15737 (void *)&cmd_ptype_mapping_update_ptype,
15738 (void *)&cmd_ptype_mapping_update_mapping,
15739 (void *)&cmd_ptype_mapping_update_update,
15740 (void *)&cmd_ptype_mapping_update_port_id,
15741 (void *)&cmd_ptype_mapping_update_hw_ptype,
15742 (void *)&cmd_ptype_mapping_update_sw_ptype,
15747 /* Common result structure for file commands */
15748 struct cmd_cmdfile_result {
15749 cmdline_fixed_string_t load;
15750 cmdline_fixed_string_t filename;
15753 /* Common CLI fields for file commands */
15754 cmdline_parse_token_string_t cmd_load_cmdfile =
15755 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15756 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15757 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15760 cmd_load_from_file_parsed(
15761 void *parsed_result,
15762 __rte_unused struct cmdline *cl,
15763 __rte_unused void *data)
15765 struct cmd_cmdfile_result *res = parsed_result;
15767 cmdline_read_from_file(res->filename);
15770 cmdline_parse_inst_t cmd_load_from_file = {
15771 .f = cmd_load_from_file_parsed,
15773 .help_str = "load <filename>",
15775 (void *)&cmd_load_cmdfile,
15776 (void *)&cmd_load_cmdfile_filename,
15781 /* Get Rx offloads capabilities */
15782 struct cmd_rx_offload_get_capa_result {
15783 cmdline_fixed_string_t show;
15784 cmdline_fixed_string_t port;
15786 cmdline_fixed_string_t rx_offload;
15787 cmdline_fixed_string_t capabilities;
15790 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15791 TOKEN_STRING_INITIALIZER
15792 (struct cmd_rx_offload_get_capa_result,
15794 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15795 TOKEN_STRING_INITIALIZER
15796 (struct cmd_rx_offload_get_capa_result,
15798 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15799 TOKEN_NUM_INITIALIZER
15800 (struct cmd_rx_offload_get_capa_result,
15801 port_id, RTE_UINT16);
15802 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15803 TOKEN_STRING_INITIALIZER
15804 (struct cmd_rx_offload_get_capa_result,
15805 rx_offload, "rx_offload");
15806 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15807 TOKEN_STRING_INITIALIZER
15808 (struct cmd_rx_offload_get_capa_result,
15809 capabilities, "capabilities");
15812 print_rx_offloads(uint64_t offloads)
15814 uint64_t single_offload;
15822 begin = __builtin_ctzll(offloads);
15823 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15825 single_offload = 1ULL << begin;
15826 for (bit = begin; bit < end; bit++) {
15827 if (offloads & single_offload)
15829 rte_eth_dev_rx_offload_name(single_offload));
15830 single_offload <<= 1;
15835 cmd_rx_offload_get_capa_parsed(
15836 void *parsed_result,
15837 __rte_unused struct cmdline *cl,
15838 __rte_unused void *data)
15840 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15841 struct rte_eth_dev_info dev_info;
15842 portid_t port_id = res->port_id;
15843 uint64_t queue_offloads;
15844 uint64_t port_offloads;
15847 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15851 queue_offloads = dev_info.rx_queue_offload_capa;
15852 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15854 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15855 printf(" Per Queue :");
15856 print_rx_offloads(queue_offloads);
15859 printf(" Per Port :");
15860 print_rx_offloads(port_offloads);
15864 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15865 .f = cmd_rx_offload_get_capa_parsed,
15867 .help_str = "show port <port_id> rx_offload capabilities",
15869 (void *)&cmd_rx_offload_get_capa_show,
15870 (void *)&cmd_rx_offload_get_capa_port,
15871 (void *)&cmd_rx_offload_get_capa_port_id,
15872 (void *)&cmd_rx_offload_get_capa_rx_offload,
15873 (void *)&cmd_rx_offload_get_capa_capabilities,
15878 /* Get Rx offloads configuration */
15879 struct cmd_rx_offload_get_configuration_result {
15880 cmdline_fixed_string_t show;
15881 cmdline_fixed_string_t port;
15883 cmdline_fixed_string_t rx_offload;
15884 cmdline_fixed_string_t configuration;
15887 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15888 TOKEN_STRING_INITIALIZER
15889 (struct cmd_rx_offload_get_configuration_result,
15891 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15892 TOKEN_STRING_INITIALIZER
15893 (struct cmd_rx_offload_get_configuration_result,
15895 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15896 TOKEN_NUM_INITIALIZER
15897 (struct cmd_rx_offload_get_configuration_result,
15898 port_id, RTE_UINT16);
15899 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15900 TOKEN_STRING_INITIALIZER
15901 (struct cmd_rx_offload_get_configuration_result,
15902 rx_offload, "rx_offload");
15903 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15904 TOKEN_STRING_INITIALIZER
15905 (struct cmd_rx_offload_get_configuration_result,
15906 configuration, "configuration");
15909 cmd_rx_offload_get_configuration_parsed(
15910 void *parsed_result,
15911 __rte_unused struct cmdline *cl,
15912 __rte_unused void *data)
15914 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15915 struct rte_eth_dev_info dev_info;
15916 portid_t port_id = res->port_id;
15917 struct rte_port *port = &ports[port_id];
15918 uint64_t port_offloads;
15919 uint64_t queue_offloads;
15920 uint16_t nb_rx_queues;
15924 printf("Rx Offloading Configuration of port %d :\n", port_id);
15926 port_offloads = port->dev_conf.rxmode.offloads;
15928 print_rx_offloads(port_offloads);
15931 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15935 nb_rx_queues = dev_info.nb_rx_queues;
15936 for (q = 0; q < nb_rx_queues; q++) {
15937 queue_offloads = port->rx_conf[q].offloads;
15938 printf(" Queue[%2d] :", q);
15939 print_rx_offloads(queue_offloads);
15945 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15946 .f = cmd_rx_offload_get_configuration_parsed,
15948 .help_str = "show port <port_id> rx_offload configuration",
15950 (void *)&cmd_rx_offload_get_configuration_show,
15951 (void *)&cmd_rx_offload_get_configuration_port,
15952 (void *)&cmd_rx_offload_get_configuration_port_id,
15953 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15954 (void *)&cmd_rx_offload_get_configuration_configuration,
15959 /* Enable/Disable a per port offloading */
15960 struct cmd_config_per_port_rx_offload_result {
15961 cmdline_fixed_string_t port;
15962 cmdline_fixed_string_t config;
15964 cmdline_fixed_string_t rx_offload;
15965 cmdline_fixed_string_t offload;
15966 cmdline_fixed_string_t on_off;
15969 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15970 TOKEN_STRING_INITIALIZER
15971 (struct cmd_config_per_port_rx_offload_result,
15973 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15974 TOKEN_STRING_INITIALIZER
15975 (struct cmd_config_per_port_rx_offload_result,
15977 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15978 TOKEN_NUM_INITIALIZER
15979 (struct cmd_config_per_port_rx_offload_result,
15980 port_id, RTE_UINT16);
15981 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15982 TOKEN_STRING_INITIALIZER
15983 (struct cmd_config_per_port_rx_offload_result,
15984 rx_offload, "rx_offload");
15985 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15986 TOKEN_STRING_INITIALIZER
15987 (struct cmd_config_per_port_rx_offload_result,
15988 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15989 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15990 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15991 "scatter#buffer_split#timestamp#security#"
15992 "keep_crc#rss_hash");
15993 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15994 TOKEN_STRING_INITIALIZER
15995 (struct cmd_config_per_port_rx_offload_result,
15999 search_rx_offload(const char *name)
16001 uint64_t single_offload;
16002 const char *single_name;
16006 single_offload = 1;
16007 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16008 single_name = rte_eth_dev_rx_offload_name(single_offload);
16009 if (!strcasecmp(single_name, name)) {
16013 single_offload <<= 1;
16017 return single_offload;
16023 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16024 __rte_unused struct cmdline *cl,
16025 __rte_unused void *data)
16027 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16028 portid_t port_id = res->port_id;
16029 struct rte_eth_dev_info dev_info;
16030 struct rte_port *port = &ports[port_id];
16031 uint64_t single_offload;
16032 uint16_t nb_rx_queues;
16036 if (port->port_status != RTE_PORT_STOPPED) {
16037 printf("Error: Can't config offload when Port %d "
16038 "is not stopped\n", port_id);
16042 single_offload = search_rx_offload(res->offload);
16043 if (single_offload == 0) {
16044 printf("Unknown offload name: %s\n", res->offload);
16048 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16052 nb_rx_queues = dev_info.nb_rx_queues;
16053 if (!strcmp(res->on_off, "on")) {
16054 port->dev_conf.rxmode.offloads |= single_offload;
16055 for (q = 0; q < nb_rx_queues; q++)
16056 port->rx_conf[q].offloads |= single_offload;
16058 port->dev_conf.rxmode.offloads &= ~single_offload;
16059 for (q = 0; q < nb_rx_queues; q++)
16060 port->rx_conf[q].offloads &= ~single_offload;
16063 cmd_reconfig_device_queue(port_id, 1, 1);
16066 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16067 .f = cmd_config_per_port_rx_offload_parsed,
16069 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16070 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16071 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16072 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16073 "keep_crc|rss_hash on|off",
16075 (void *)&cmd_config_per_port_rx_offload_result_port,
16076 (void *)&cmd_config_per_port_rx_offload_result_config,
16077 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16078 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16079 (void *)&cmd_config_per_port_rx_offload_result_offload,
16080 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16085 /* Enable/Disable a per queue offloading */
16086 struct cmd_config_per_queue_rx_offload_result {
16087 cmdline_fixed_string_t port;
16089 cmdline_fixed_string_t rxq;
16091 cmdline_fixed_string_t rx_offload;
16092 cmdline_fixed_string_t offload;
16093 cmdline_fixed_string_t on_off;
16096 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16097 TOKEN_STRING_INITIALIZER
16098 (struct cmd_config_per_queue_rx_offload_result,
16100 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16101 TOKEN_NUM_INITIALIZER
16102 (struct cmd_config_per_queue_rx_offload_result,
16103 port_id, RTE_UINT16);
16104 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16105 TOKEN_STRING_INITIALIZER
16106 (struct cmd_config_per_queue_rx_offload_result,
16108 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16109 TOKEN_NUM_INITIALIZER
16110 (struct cmd_config_per_queue_rx_offload_result,
16111 queue_id, RTE_UINT16);
16112 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16113 TOKEN_STRING_INITIALIZER
16114 (struct cmd_config_per_queue_rx_offload_result,
16115 rx_offload, "rx_offload");
16116 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16117 TOKEN_STRING_INITIALIZER
16118 (struct cmd_config_per_queue_rx_offload_result,
16119 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16120 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16121 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16122 "scatter#buffer_split#timestamp#security#keep_crc");
16123 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16124 TOKEN_STRING_INITIALIZER
16125 (struct cmd_config_per_queue_rx_offload_result,
16129 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16130 __rte_unused struct cmdline *cl,
16131 __rte_unused void *data)
16133 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16134 struct rte_eth_dev_info dev_info;
16135 portid_t port_id = res->port_id;
16136 uint16_t queue_id = res->queue_id;
16137 struct rte_port *port = &ports[port_id];
16138 uint64_t single_offload;
16141 if (port->port_status != RTE_PORT_STOPPED) {
16142 printf("Error: Can't config offload when Port %d "
16143 "is not stopped\n", port_id);
16147 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16151 if (queue_id >= dev_info.nb_rx_queues) {
16152 printf("Error: input queue_id should be 0 ... "
16153 "%d\n", dev_info.nb_rx_queues - 1);
16157 single_offload = search_rx_offload(res->offload);
16158 if (single_offload == 0) {
16159 printf("Unknown offload name: %s\n", res->offload);
16163 if (!strcmp(res->on_off, "on"))
16164 port->rx_conf[queue_id].offloads |= single_offload;
16166 port->rx_conf[queue_id].offloads &= ~single_offload;
16168 cmd_reconfig_device_queue(port_id, 1, 1);
16171 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16172 .f = cmd_config_per_queue_rx_offload_parsed,
16174 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16175 "vlan_strip|ipv4_cksum|"
16176 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16177 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16178 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16181 (void *)&cmd_config_per_queue_rx_offload_result_port,
16182 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16183 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16184 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16185 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16186 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16187 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16192 /* Get Tx offloads capabilities */
16193 struct cmd_tx_offload_get_capa_result {
16194 cmdline_fixed_string_t show;
16195 cmdline_fixed_string_t port;
16197 cmdline_fixed_string_t tx_offload;
16198 cmdline_fixed_string_t capabilities;
16201 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16202 TOKEN_STRING_INITIALIZER
16203 (struct cmd_tx_offload_get_capa_result,
16205 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16206 TOKEN_STRING_INITIALIZER
16207 (struct cmd_tx_offload_get_capa_result,
16209 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16210 TOKEN_NUM_INITIALIZER
16211 (struct cmd_tx_offload_get_capa_result,
16212 port_id, RTE_UINT16);
16213 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16214 TOKEN_STRING_INITIALIZER
16215 (struct cmd_tx_offload_get_capa_result,
16216 tx_offload, "tx_offload");
16217 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16218 TOKEN_STRING_INITIALIZER
16219 (struct cmd_tx_offload_get_capa_result,
16220 capabilities, "capabilities");
16223 print_tx_offloads(uint64_t offloads)
16225 uint64_t single_offload;
16233 begin = __builtin_ctzll(offloads);
16234 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16236 single_offload = 1ULL << begin;
16237 for (bit = begin; bit < end; bit++) {
16238 if (offloads & single_offload)
16240 rte_eth_dev_tx_offload_name(single_offload));
16241 single_offload <<= 1;
16246 cmd_tx_offload_get_capa_parsed(
16247 void *parsed_result,
16248 __rte_unused struct cmdline *cl,
16249 __rte_unused void *data)
16251 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16252 struct rte_eth_dev_info dev_info;
16253 portid_t port_id = res->port_id;
16254 uint64_t queue_offloads;
16255 uint64_t port_offloads;
16258 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16262 queue_offloads = dev_info.tx_queue_offload_capa;
16263 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16265 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16266 printf(" Per Queue :");
16267 print_tx_offloads(queue_offloads);
16270 printf(" Per Port :");
16271 print_tx_offloads(port_offloads);
16275 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16276 .f = cmd_tx_offload_get_capa_parsed,
16278 .help_str = "show port <port_id> tx_offload capabilities",
16280 (void *)&cmd_tx_offload_get_capa_show,
16281 (void *)&cmd_tx_offload_get_capa_port,
16282 (void *)&cmd_tx_offload_get_capa_port_id,
16283 (void *)&cmd_tx_offload_get_capa_tx_offload,
16284 (void *)&cmd_tx_offload_get_capa_capabilities,
16289 /* Get Tx offloads configuration */
16290 struct cmd_tx_offload_get_configuration_result {
16291 cmdline_fixed_string_t show;
16292 cmdline_fixed_string_t port;
16294 cmdline_fixed_string_t tx_offload;
16295 cmdline_fixed_string_t configuration;
16298 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16299 TOKEN_STRING_INITIALIZER
16300 (struct cmd_tx_offload_get_configuration_result,
16302 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16303 TOKEN_STRING_INITIALIZER
16304 (struct cmd_tx_offload_get_configuration_result,
16306 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16307 TOKEN_NUM_INITIALIZER
16308 (struct cmd_tx_offload_get_configuration_result,
16309 port_id, RTE_UINT16);
16310 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16311 TOKEN_STRING_INITIALIZER
16312 (struct cmd_tx_offload_get_configuration_result,
16313 tx_offload, "tx_offload");
16314 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16315 TOKEN_STRING_INITIALIZER
16316 (struct cmd_tx_offload_get_configuration_result,
16317 configuration, "configuration");
16320 cmd_tx_offload_get_configuration_parsed(
16321 void *parsed_result,
16322 __rte_unused struct cmdline *cl,
16323 __rte_unused void *data)
16325 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16326 struct rte_eth_dev_info dev_info;
16327 portid_t port_id = res->port_id;
16328 struct rte_port *port = &ports[port_id];
16329 uint64_t port_offloads;
16330 uint64_t queue_offloads;
16331 uint16_t nb_tx_queues;
16335 printf("Tx Offloading Configuration of port %d :\n", port_id);
16337 port_offloads = port->dev_conf.txmode.offloads;
16339 print_tx_offloads(port_offloads);
16342 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16346 nb_tx_queues = dev_info.nb_tx_queues;
16347 for (q = 0; q < nb_tx_queues; q++) {
16348 queue_offloads = port->tx_conf[q].offloads;
16349 printf(" Queue[%2d] :", q);
16350 print_tx_offloads(queue_offloads);
16356 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16357 .f = cmd_tx_offload_get_configuration_parsed,
16359 .help_str = "show port <port_id> tx_offload configuration",
16361 (void *)&cmd_tx_offload_get_configuration_show,
16362 (void *)&cmd_tx_offload_get_configuration_port,
16363 (void *)&cmd_tx_offload_get_configuration_port_id,
16364 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16365 (void *)&cmd_tx_offload_get_configuration_configuration,
16370 /* Enable/Disable a per port offloading */
16371 struct cmd_config_per_port_tx_offload_result {
16372 cmdline_fixed_string_t port;
16373 cmdline_fixed_string_t config;
16375 cmdline_fixed_string_t tx_offload;
16376 cmdline_fixed_string_t offload;
16377 cmdline_fixed_string_t on_off;
16380 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16381 TOKEN_STRING_INITIALIZER
16382 (struct cmd_config_per_port_tx_offload_result,
16384 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16385 TOKEN_STRING_INITIALIZER
16386 (struct cmd_config_per_port_tx_offload_result,
16388 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16389 TOKEN_NUM_INITIALIZER
16390 (struct cmd_config_per_port_tx_offload_result,
16391 port_id, RTE_UINT16);
16392 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16393 TOKEN_STRING_INITIALIZER
16394 (struct cmd_config_per_port_tx_offload_result,
16395 tx_offload, "tx_offload");
16396 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16397 TOKEN_STRING_INITIALIZER
16398 (struct cmd_config_per_port_tx_offload_result,
16399 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16400 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16401 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16402 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16403 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16404 "send_on_timestamp");
16405 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16406 TOKEN_STRING_INITIALIZER
16407 (struct cmd_config_per_port_tx_offload_result,
16411 search_tx_offload(const char *name)
16413 uint64_t single_offload;
16414 const char *single_name;
16418 single_offload = 1;
16419 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16420 single_name = rte_eth_dev_tx_offload_name(single_offload);
16421 if (single_name == NULL)
16423 if (!strcasecmp(single_name, name)) {
16426 } else if (!strcasecmp(single_name, "UNKNOWN"))
16428 single_offload <<= 1;
16432 return single_offload;
16438 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16439 __rte_unused struct cmdline *cl,
16440 __rte_unused void *data)
16442 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16443 portid_t port_id = res->port_id;
16444 struct rte_eth_dev_info dev_info;
16445 struct rte_port *port = &ports[port_id];
16446 uint64_t single_offload;
16447 uint16_t nb_tx_queues;
16451 if (port->port_status != RTE_PORT_STOPPED) {
16452 printf("Error: Can't config offload when Port %d "
16453 "is not stopped\n", port_id);
16457 single_offload = search_tx_offload(res->offload);
16458 if (single_offload == 0) {
16459 printf("Unknown offload name: %s\n", res->offload);
16463 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16467 nb_tx_queues = dev_info.nb_tx_queues;
16468 if (!strcmp(res->on_off, "on")) {
16469 port->dev_conf.txmode.offloads |= single_offload;
16470 for (q = 0; q < nb_tx_queues; q++)
16471 port->tx_conf[q].offloads |= single_offload;
16473 port->dev_conf.txmode.offloads &= ~single_offload;
16474 for (q = 0; q < nb_tx_queues; q++)
16475 port->tx_conf[q].offloads &= ~single_offload;
16478 cmd_reconfig_device_queue(port_id, 1, 1);
16481 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16482 .f = cmd_config_per_port_tx_offload_parsed,
16484 .help_str = "port config <port_id> tx_offload "
16485 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16486 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16487 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16488 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16489 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16490 "send_on_timestamp on|off",
16492 (void *)&cmd_config_per_port_tx_offload_result_port,
16493 (void *)&cmd_config_per_port_tx_offload_result_config,
16494 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16495 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16496 (void *)&cmd_config_per_port_tx_offload_result_offload,
16497 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16502 /* Enable/Disable a per queue offloading */
16503 struct cmd_config_per_queue_tx_offload_result {
16504 cmdline_fixed_string_t port;
16506 cmdline_fixed_string_t txq;
16508 cmdline_fixed_string_t tx_offload;
16509 cmdline_fixed_string_t offload;
16510 cmdline_fixed_string_t on_off;
16513 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16514 TOKEN_STRING_INITIALIZER
16515 (struct cmd_config_per_queue_tx_offload_result,
16517 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16518 TOKEN_NUM_INITIALIZER
16519 (struct cmd_config_per_queue_tx_offload_result,
16520 port_id, RTE_UINT16);
16521 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16522 TOKEN_STRING_INITIALIZER
16523 (struct cmd_config_per_queue_tx_offload_result,
16525 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16526 TOKEN_NUM_INITIALIZER
16527 (struct cmd_config_per_queue_tx_offload_result,
16528 queue_id, RTE_UINT16);
16529 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16530 TOKEN_STRING_INITIALIZER
16531 (struct cmd_config_per_queue_tx_offload_result,
16532 tx_offload, "tx_offload");
16533 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16534 TOKEN_STRING_INITIALIZER
16535 (struct cmd_config_per_queue_tx_offload_result,
16536 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16537 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16538 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16539 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16540 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16541 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16542 TOKEN_STRING_INITIALIZER
16543 (struct cmd_config_per_queue_tx_offload_result,
16547 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16548 __rte_unused struct cmdline *cl,
16549 __rte_unused void *data)
16551 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16552 struct rte_eth_dev_info dev_info;
16553 portid_t port_id = res->port_id;
16554 uint16_t queue_id = res->queue_id;
16555 struct rte_port *port = &ports[port_id];
16556 uint64_t single_offload;
16559 if (port->port_status != RTE_PORT_STOPPED) {
16560 printf("Error: Can't config offload when Port %d "
16561 "is not stopped\n", port_id);
16565 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16569 if (queue_id >= dev_info.nb_tx_queues) {
16570 printf("Error: input queue_id should be 0 ... "
16571 "%d\n", dev_info.nb_tx_queues - 1);
16575 single_offload = search_tx_offload(res->offload);
16576 if (single_offload == 0) {
16577 printf("Unknown offload name: %s\n", res->offload);
16581 if (!strcmp(res->on_off, "on"))
16582 port->tx_conf[queue_id].offloads |= single_offload;
16584 port->tx_conf[queue_id].offloads &= ~single_offload;
16586 cmd_reconfig_device_queue(port_id, 1, 1);
16589 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16590 .f = cmd_config_per_queue_tx_offload_parsed,
16592 .help_str = "port <port_id> txq <queue_id> tx_offload "
16593 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16594 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16595 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16596 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16597 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16600 (void *)&cmd_config_per_queue_tx_offload_result_port,
16601 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16602 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16603 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16604 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16605 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16606 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16611 /* *** configure tx_metadata for specific port *** */
16612 struct cmd_config_tx_metadata_specific_result {
16613 cmdline_fixed_string_t port;
16614 cmdline_fixed_string_t keyword;
16616 cmdline_fixed_string_t item;
16621 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16622 __rte_unused struct cmdline *cl,
16623 __rte_unused void *data)
16625 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16627 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16629 ports[res->port_id].tx_metadata = res->value;
16630 /* Add/remove callback to insert valid metadata in every Tx packet. */
16631 if (ports[res->port_id].tx_metadata)
16632 add_tx_md_callback(res->port_id);
16634 remove_tx_md_callback(res->port_id);
16635 rte_flow_dynf_metadata_register();
16638 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16639 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16641 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16642 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16643 keyword, "config");
16644 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16645 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16646 port_id, RTE_UINT16);
16647 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16648 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16649 item, "tx_metadata");
16650 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16651 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16652 value, RTE_UINT32);
16654 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16655 .f = cmd_config_tx_metadata_specific_parsed,
16657 .help_str = "port config <port_id> tx_metadata <value>",
16659 (void *)&cmd_config_tx_metadata_specific_port,
16660 (void *)&cmd_config_tx_metadata_specific_keyword,
16661 (void *)&cmd_config_tx_metadata_specific_id,
16662 (void *)&cmd_config_tx_metadata_specific_item,
16663 (void *)&cmd_config_tx_metadata_specific_value,
16668 /* *** set dynf *** */
16669 struct cmd_config_tx_dynf_specific_result {
16670 cmdline_fixed_string_t port;
16671 cmdline_fixed_string_t keyword;
16673 cmdline_fixed_string_t item;
16674 cmdline_fixed_string_t name;
16675 cmdline_fixed_string_t value;
16679 cmd_config_dynf_specific_parsed(void *parsed_result,
16680 __rte_unused struct cmdline *cl,
16681 __rte_unused void *data)
16683 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16684 struct rte_mbuf_dynflag desc_flag;
16686 uint64_t old_port_flags;
16688 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16690 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16692 if (strlcpy(desc_flag.name, res->name,
16693 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16694 printf("Flag name too long\n");
16697 desc_flag.flags = 0;
16698 flag = rte_mbuf_dynflag_register(&desc_flag);
16700 printf("Can't register flag\n");
16703 strcpy(dynf_names[flag], desc_flag.name);
16705 old_port_flags = ports[res->port_id].mbuf_dynf;
16706 if (!strcmp(res->value, "set")) {
16707 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16708 if (old_port_flags == 0)
16709 add_tx_dynf_callback(res->port_id);
16711 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16712 if (ports[res->port_id].mbuf_dynf == 0)
16713 remove_tx_dynf_callback(res->port_id);
16717 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16718 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16720 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16721 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16722 keyword, "config");
16723 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16724 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16725 port_id, RTE_UINT16);
16726 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16727 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16729 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16730 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16732 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16733 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16734 value, "set#clear");
16736 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16737 .f = cmd_config_dynf_specific_parsed,
16739 .help_str = "port config <port id> dynf <name> set|clear",
16741 (void *)&cmd_config_tx_dynf_specific_port,
16742 (void *)&cmd_config_tx_dynf_specific_keyword,
16743 (void *)&cmd_config_tx_dynf_specific_port_id,
16744 (void *)&cmd_config_tx_dynf_specific_item,
16745 (void *)&cmd_config_tx_dynf_specific_name,
16746 (void *)&cmd_config_tx_dynf_specific_value,
16751 /* *** display tx_metadata per port configuration *** */
16752 struct cmd_show_tx_metadata_result {
16753 cmdline_fixed_string_t cmd_show;
16754 cmdline_fixed_string_t cmd_port;
16755 cmdline_fixed_string_t cmd_keyword;
16760 cmd_show_tx_metadata_parsed(void *parsed_result,
16761 __rte_unused struct cmdline *cl,
16762 __rte_unused void *data)
16764 struct cmd_show_tx_metadata_result *res = parsed_result;
16766 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16767 printf("invalid port id %u\n", res->cmd_pid);
16770 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16771 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16772 ports[res->cmd_pid].tx_metadata);
16776 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16777 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16779 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16780 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16782 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16783 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16784 cmd_pid, RTE_UINT16);
16785 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16786 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16787 cmd_keyword, "tx_metadata");
16789 cmdline_parse_inst_t cmd_show_tx_metadata = {
16790 .f = cmd_show_tx_metadata_parsed,
16792 .help_str = "show port <port_id> tx_metadata",
16794 (void *)&cmd_show_tx_metadata_show,
16795 (void *)&cmd_show_tx_metadata_port,
16796 (void *)&cmd_show_tx_metadata_pid,
16797 (void *)&cmd_show_tx_metadata_keyword,
16802 /* *** show fec capability per port configuration *** */
16803 struct cmd_show_fec_capability_result {
16804 cmdline_fixed_string_t cmd_show;
16805 cmdline_fixed_string_t cmd_port;
16806 cmdline_fixed_string_t cmd_fec;
16807 cmdline_fixed_string_t cmd_keyword;
16812 cmd_show_fec_capability_parsed(void *parsed_result,
16813 __rte_unused struct cmdline *cl,
16814 __rte_unused void *data)
16816 struct cmd_show_fec_capability_result *res = parsed_result;
16817 struct rte_eth_fec_capa *speed_fec_capa;
16821 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16822 printf("Invalid port id %u\n", res->cmd_pid);
16826 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16827 if (ret == -ENOTSUP) {
16828 printf("Function not implemented\n");
16830 } else if (ret < 0) {
16831 printf("Get FEC capability failed: %d\n", ret);
16835 num = (unsigned int)ret;
16836 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16837 if (speed_fec_capa == NULL) {
16838 printf("Failed to alloc FEC capability buffer\n");
16842 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16844 printf("Error getting FEC capability: %d\n", ret);
16848 show_fec_capability(num, speed_fec_capa);
16850 free(speed_fec_capa);
16853 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16854 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16856 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16857 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16859 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16860 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16861 cmd_pid, RTE_UINT16);
16862 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16863 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16865 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16866 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16867 cmd_keyword, "capabilities");
16869 cmdline_parse_inst_t cmd_show_capability = {
16870 .f = cmd_show_fec_capability_parsed,
16872 .help_str = "show port <port_id> fec capabilities",
16874 (void *)&cmd_show_fec_capability_show,
16875 (void *)&cmd_show_fec_capability_port,
16876 (void *)&cmd_show_fec_capability_pid,
16877 (void *)&cmd_show_fec_capability_fec,
16878 (void *)&cmd_show_fec_capability_keyword,
16883 /* *** show fec mode per port configuration *** */
16884 struct cmd_show_fec_metadata_result {
16885 cmdline_fixed_string_t cmd_show;
16886 cmdline_fixed_string_t cmd_port;
16887 cmdline_fixed_string_t cmd_keyword;
16892 cmd_show_fec_mode_parsed(void *parsed_result,
16893 __rte_unused struct cmdline *cl,
16894 __rte_unused void *data)
16896 #define FEC_NAME_SIZE 16
16897 struct cmd_show_fec_metadata_result *res = parsed_result;
16899 char buf[FEC_NAME_SIZE];
16902 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16903 printf("Invalid port id %u\n", res->cmd_pid);
16906 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16907 if (ret == -ENOTSUP) {
16908 printf("Function not implemented\n");
16910 } else if (ret < 0) {
16911 printf("Get FEC mode failed\n");
16916 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16917 strlcpy(buf, "off", sizeof(buf));
16919 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16920 strlcpy(buf, "auto", sizeof(buf));
16922 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16923 strlcpy(buf, "baser", sizeof(buf));
16925 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16926 strlcpy(buf, "rs", sizeof(buf));
16932 printf("%s\n", buf);
16935 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16936 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16938 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16939 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16941 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16942 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16943 cmd_pid, RTE_UINT16);
16944 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16945 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16946 cmd_keyword, "fec_mode");
16948 cmdline_parse_inst_t cmd_show_fec_mode = {
16949 .f = cmd_show_fec_mode_parsed,
16951 .help_str = "show port <port_id> fec_mode",
16953 (void *)&cmd_show_fec_mode_show,
16954 (void *)&cmd_show_fec_mode_port,
16955 (void *)&cmd_show_fec_mode_pid,
16956 (void *)&cmd_show_fec_mode_keyword,
16961 /* *** set fec mode per port configuration *** */
16962 struct cmd_set_port_fec_mode {
16963 cmdline_fixed_string_t set;
16964 cmdline_fixed_string_t port;
16966 cmdline_fixed_string_t fec_mode;
16967 cmdline_fixed_string_t fec_value;
16970 /* Common CLI fields for set fec mode */
16971 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16972 TOKEN_STRING_INITIALIZER
16973 (struct cmd_set_port_fec_mode,
16975 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16976 TOKEN_STRING_INITIALIZER
16977 (struct cmd_set_port_fec_mode,
16979 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16980 TOKEN_NUM_INITIALIZER
16981 (struct cmd_set_port_fec_mode,
16982 port_id, RTE_UINT16);
16983 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16984 TOKEN_STRING_INITIALIZER
16985 (struct cmd_set_port_fec_mode,
16986 fec_mode, "fec_mode");
16987 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16988 TOKEN_STRING_INITIALIZER
16989 (struct cmd_set_port_fec_mode,
16993 cmd_set_port_fec_mode_parsed(
16994 void *parsed_result,
16995 __rte_unused struct cmdline *cl,
16996 __rte_unused void *data)
16998 struct cmd_set_port_fec_mode *res = parsed_result;
16999 uint16_t port_id = res->port_id;
17003 ret = parse_fec_mode(res->fec_value, &mode);
17005 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
17010 ret = rte_eth_fec_set(port_id, mode);
17011 if (ret == -ENOTSUP) {
17012 printf("Function not implemented\n");
17014 } else if (ret < 0) {
17015 printf("Set FEC mode failed\n");
17020 cmdline_parse_inst_t cmd_set_fec_mode = {
17021 .f = cmd_set_port_fec_mode_parsed,
17023 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17025 (void *)&cmd_set_port_fec_mode_set,
17026 (void *)&cmd_set_port_fec_mode_port,
17027 (void *)&cmd_set_port_fec_mode_port_id,
17028 (void *)&cmd_set_port_fec_mode_str,
17029 (void *)&cmd_set_port_fec_mode_value,
17034 /* show port supported ptypes */
17036 /* Common result structure for show port ptypes */
17037 struct cmd_show_port_supported_ptypes_result {
17038 cmdline_fixed_string_t show;
17039 cmdline_fixed_string_t port;
17041 cmdline_fixed_string_t ptypes;
17044 /* Common CLI fields for show port ptypes */
17045 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17046 TOKEN_STRING_INITIALIZER
17047 (struct cmd_show_port_supported_ptypes_result,
17049 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17050 TOKEN_STRING_INITIALIZER
17051 (struct cmd_show_port_supported_ptypes_result,
17053 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17054 TOKEN_NUM_INITIALIZER
17055 (struct cmd_show_port_supported_ptypes_result,
17056 port_id, RTE_UINT16);
17057 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17058 TOKEN_STRING_INITIALIZER
17059 (struct cmd_show_port_supported_ptypes_result,
17063 cmd_show_port_supported_ptypes_parsed(
17064 void *parsed_result,
17065 __rte_unused struct cmdline *cl,
17066 __rte_unused void *data)
17068 #define RSVD_PTYPE_MASK 0xf0000000
17069 #define MAX_PTYPES_PER_LAYER 16
17070 #define LTYPE_NAMESIZE 32
17071 #define PTYPE_NAMESIZE 256
17072 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17073 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17074 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17075 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17076 uint16_t port_id = res->port_id;
17079 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17083 while (ptype_mask != RSVD_PTYPE_MASK) {
17085 switch (ptype_mask) {
17086 case RTE_PTYPE_L2_MASK:
17087 strlcpy(ltype, "L2", sizeof(ltype));
17089 case RTE_PTYPE_L3_MASK:
17090 strlcpy(ltype, "L3", sizeof(ltype));
17092 case RTE_PTYPE_L4_MASK:
17093 strlcpy(ltype, "L4", sizeof(ltype));
17095 case RTE_PTYPE_TUNNEL_MASK:
17096 strlcpy(ltype, "Tunnel", sizeof(ltype));
17098 case RTE_PTYPE_INNER_L2_MASK:
17099 strlcpy(ltype, "Inner L2", sizeof(ltype));
17101 case RTE_PTYPE_INNER_L3_MASK:
17102 strlcpy(ltype, "Inner L3", sizeof(ltype));
17104 case RTE_PTYPE_INNER_L4_MASK:
17105 strlcpy(ltype, "Inner L4", sizeof(ltype));
17111 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17112 ptype_mask, ptypes,
17113 MAX_PTYPES_PER_LAYER);
17116 printf("Supported %s ptypes:\n", ltype);
17118 printf("%s ptypes unsupported\n", ltype);
17120 for (i = 0; i < ret; ++i) {
17121 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17122 printf("%s\n", buf);
17129 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17130 .f = cmd_show_port_supported_ptypes_parsed,
17132 .help_str = "show port <port_id> ptypes",
17134 (void *)&cmd_show_port_supported_ptypes_show,
17135 (void *)&cmd_show_port_supported_ptypes_port,
17136 (void *)&cmd_show_port_supported_ptypes_port_id,
17137 (void *)&cmd_show_port_supported_ptypes_ptypes,
17142 /* *** display rx/tx descriptor status *** */
17143 struct cmd_show_rx_tx_desc_status_result {
17144 cmdline_fixed_string_t cmd_show;
17145 cmdline_fixed_string_t cmd_port;
17146 cmdline_fixed_string_t cmd_keyword;
17147 cmdline_fixed_string_t cmd_desc;
17148 cmdline_fixed_string_t cmd_status;
17155 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17156 __rte_unused struct cmdline *cl,
17157 __rte_unused void *data)
17159 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17162 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17163 printf("invalid port id %u\n", res->cmd_pid);
17167 if (!strcmp(res->cmd_keyword, "rxq")) {
17168 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17171 printf("Invalid input: queue id = %d, desc id = %d\n",
17172 res->cmd_qid, res->cmd_did);
17175 if (rc == RTE_ETH_RX_DESC_AVAIL)
17176 printf("Desc status = AVAILABLE\n");
17177 else if (rc == RTE_ETH_RX_DESC_DONE)
17178 printf("Desc status = DONE\n");
17180 printf("Desc status = UNAVAILABLE\n");
17181 } else if (!strcmp(res->cmd_keyword, "txq")) {
17182 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17185 printf("Invalid input: queue id = %d, desc id = %d\n",
17186 res->cmd_qid, res->cmd_did);
17189 if (rc == RTE_ETH_TX_DESC_FULL)
17190 printf("Desc status = FULL\n");
17191 else if (rc == RTE_ETH_TX_DESC_DONE)
17192 printf("Desc status = DONE\n");
17194 printf("Desc status = UNAVAILABLE\n");
17198 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17199 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17201 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17202 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17204 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17205 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17206 cmd_pid, RTE_UINT16);
17207 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17208 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17209 cmd_keyword, "rxq#txq");
17210 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17211 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17212 cmd_qid, RTE_UINT16);
17213 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17214 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17216 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17217 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17218 cmd_did, RTE_UINT16);
17219 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17220 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17221 cmd_status, "status");
17222 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17223 .f = cmd_show_rx_tx_desc_status_parsed,
17225 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17228 (void *)&cmd_show_rx_tx_desc_status_show,
17229 (void *)&cmd_show_rx_tx_desc_status_port,
17230 (void *)&cmd_show_rx_tx_desc_status_pid,
17231 (void *)&cmd_show_rx_tx_desc_status_keyword,
17232 (void *)&cmd_show_rx_tx_desc_status_qid,
17233 (void *)&cmd_show_rx_tx_desc_status_desc,
17234 (void *)&cmd_show_rx_tx_desc_status_did,
17235 (void *)&cmd_show_rx_tx_desc_status_status,
17240 /* *** display rx queue desc used count *** */
17241 struct cmd_show_rx_queue_desc_used_count_result {
17242 cmdline_fixed_string_t cmd_show;
17243 cmdline_fixed_string_t cmd_port;
17244 cmdline_fixed_string_t cmd_rxq;
17245 cmdline_fixed_string_t cmd_desc;
17246 cmdline_fixed_string_t cmd_used;
17247 cmdline_fixed_string_t cmd_count;
17253 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17254 __rte_unused struct cmdline *cl,
17255 __rte_unused void *data)
17257 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17260 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17261 printf("invalid port id %u\n", res->cmd_pid);
17265 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17267 printf("Invalid queueid = %d\n", res->cmd_qid);
17270 printf("Used desc count = %d\n", rc);
17273 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17274 TOKEN_STRING_INITIALIZER
17275 (struct cmd_show_rx_queue_desc_used_count_result,
17277 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17278 TOKEN_STRING_INITIALIZER
17279 (struct cmd_show_rx_queue_desc_used_count_result,
17281 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17282 TOKEN_NUM_INITIALIZER
17283 (struct cmd_show_rx_queue_desc_used_count_result,
17284 cmd_pid, RTE_UINT16);
17285 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17286 TOKEN_STRING_INITIALIZER
17287 (struct cmd_show_rx_queue_desc_used_count_result,
17289 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17290 TOKEN_NUM_INITIALIZER
17291 (struct cmd_show_rx_queue_desc_used_count_result,
17292 cmd_qid, RTE_UINT16);
17293 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17294 TOKEN_STRING_INITIALIZER
17295 (struct cmd_show_rx_queue_desc_used_count_result,
17296 cmd_count, "desc");
17297 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17298 TOKEN_STRING_INITIALIZER
17299 (struct cmd_show_rx_queue_desc_used_count_result,
17300 cmd_count, "used");
17301 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17302 TOKEN_STRING_INITIALIZER
17303 (struct cmd_show_rx_queue_desc_used_count_result,
17304 cmd_count, "count");
17305 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17306 .f = cmd_show_rx_queue_desc_used_count_parsed,
17308 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17310 (void *)&cmd_show_rx_queue_desc_used_count_show,
17311 (void *)&cmd_show_rx_queue_desc_used_count_port,
17312 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17313 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17314 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17315 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17316 (void *)&cmd_show_rx_queue_desc_used_count_used,
17317 (void *)&cmd_show_rx_queue_desc_used_count_count,
17322 /* Common result structure for set port ptypes */
17323 struct cmd_set_port_ptypes_result {
17324 cmdline_fixed_string_t set;
17325 cmdline_fixed_string_t port;
17327 cmdline_fixed_string_t ptype_mask;
17331 /* Common CLI fields for set port ptypes */
17332 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17333 TOKEN_STRING_INITIALIZER
17334 (struct cmd_set_port_ptypes_result,
17336 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17337 TOKEN_STRING_INITIALIZER
17338 (struct cmd_set_port_ptypes_result,
17340 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17341 TOKEN_NUM_INITIALIZER
17342 (struct cmd_set_port_ptypes_result,
17343 port_id, RTE_UINT16);
17344 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17345 TOKEN_STRING_INITIALIZER
17346 (struct cmd_set_port_ptypes_result,
17347 ptype_mask, "ptype_mask");
17348 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17349 TOKEN_NUM_INITIALIZER
17350 (struct cmd_set_port_ptypes_result,
17354 cmd_set_port_ptypes_parsed(
17355 void *parsed_result,
17356 __rte_unused struct cmdline *cl,
17357 __rte_unused void *data)
17359 struct cmd_set_port_ptypes_result *res = parsed_result;
17360 #define PTYPE_NAMESIZE 256
17361 char ptype_name[PTYPE_NAMESIZE];
17362 uint16_t port_id = res->port_id;
17363 uint32_t ptype_mask = res->mask;
17366 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17369 printf("Port %d doesn't support any ptypes.\n", port_id);
17373 uint32_t ptypes[ret];
17375 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17377 printf("Unable to set requested ptypes for Port %d\n", port_id);
17381 printf("Successfully set following ptypes for Port %d\n", port_id);
17382 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17383 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17384 printf("%s\n", ptype_name);
17387 clear_ptypes = false;
17390 cmdline_parse_inst_t cmd_set_port_ptypes = {
17391 .f = cmd_set_port_ptypes_parsed,
17393 .help_str = "set port <port_id> ptype_mask <mask>",
17395 (void *)&cmd_set_port_ptypes_set,
17396 (void *)&cmd_set_port_ptypes_port,
17397 (void *)&cmd_set_port_ptypes_port_id,
17398 (void *)&cmd_set_port_ptypes_mask_str,
17399 (void *)&cmd_set_port_ptypes_mask_u32,
17404 /* *** display mac addresses added to a port *** */
17405 struct cmd_showport_macs_result {
17406 cmdline_fixed_string_t cmd_show;
17407 cmdline_fixed_string_t cmd_port;
17408 cmdline_fixed_string_t cmd_keyword;
17413 cmd_showport_macs_parsed(void *parsed_result,
17414 __rte_unused struct cmdline *cl,
17415 __rte_unused void *data)
17417 struct cmd_showport_macs_result *res = parsed_result;
17419 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17422 if (!strcmp(res->cmd_keyword, "macs"))
17423 show_macs(res->cmd_pid);
17424 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17425 show_mcast_macs(res->cmd_pid);
17428 cmdline_parse_token_string_t cmd_showport_macs_show =
17429 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17431 cmdline_parse_token_string_t cmd_showport_macs_port =
17432 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17434 cmdline_parse_token_num_t cmd_showport_macs_pid =
17435 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17436 cmd_pid, RTE_UINT16);
17437 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17438 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17439 cmd_keyword, "macs#mcast_macs");
17441 cmdline_parse_inst_t cmd_showport_macs = {
17442 .f = cmd_showport_macs_parsed,
17444 .help_str = "show port <port_id> macs|mcast_macs",
17446 (void *)&cmd_showport_macs_show,
17447 (void *)&cmd_showport_macs_port,
17448 (void *)&cmd_showport_macs_pid,
17449 (void *)&cmd_showport_macs_keyword,
17454 /* ******************************************************************************** */
17456 /* list of instructions */
17457 cmdline_parse_ctx_t main_ctx[] = {
17458 (cmdline_parse_inst_t *)&cmd_help_brief,
17459 (cmdline_parse_inst_t *)&cmd_help_long,
17460 (cmdline_parse_inst_t *)&cmd_quit,
17461 (cmdline_parse_inst_t *)&cmd_load_from_file,
17462 (cmdline_parse_inst_t *)&cmd_showport,
17463 (cmdline_parse_inst_t *)&cmd_showqueue,
17464 (cmdline_parse_inst_t *)&cmd_showeeprom,
17465 (cmdline_parse_inst_t *)&cmd_showportall,
17466 (cmdline_parse_inst_t *)&cmd_showdevice,
17467 (cmdline_parse_inst_t *)&cmd_showcfg,
17468 (cmdline_parse_inst_t *)&cmd_showfwdall,
17469 (cmdline_parse_inst_t *)&cmd_start,
17470 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17471 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17472 (cmdline_parse_inst_t *)&cmd_set_link_up,
17473 (cmdline_parse_inst_t *)&cmd_set_link_down,
17474 (cmdline_parse_inst_t *)&cmd_reset,
17475 (cmdline_parse_inst_t *)&cmd_set_numbers,
17476 (cmdline_parse_inst_t *)&cmd_set_log,
17477 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17478 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17479 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17480 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17481 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17482 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17483 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17484 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17485 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17486 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17487 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17488 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17489 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17490 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17491 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17492 (cmdline_parse_inst_t *)&cmd_set_link_check,
17493 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17494 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17495 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17496 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17497 #ifdef RTE_NET_BOND
17498 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17499 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17500 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17501 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17502 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17503 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17504 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17505 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17506 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17507 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17508 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17510 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17511 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17512 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17513 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17514 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17515 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17516 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17517 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17518 (cmdline_parse_inst_t *)&cmd_csum_set,
17519 (cmdline_parse_inst_t *)&cmd_csum_show,
17520 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17521 (cmdline_parse_inst_t *)&cmd_tso_set,
17522 (cmdline_parse_inst_t *)&cmd_tso_show,
17523 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17524 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17525 (cmdline_parse_inst_t *)&cmd_gro_enable,
17526 (cmdline_parse_inst_t *)&cmd_gro_flush,
17527 (cmdline_parse_inst_t *)&cmd_gro_show,
17528 (cmdline_parse_inst_t *)&cmd_gso_enable,
17529 (cmdline_parse_inst_t *)&cmd_gso_size,
17530 (cmdline_parse_inst_t *)&cmd_gso_show,
17531 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17532 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17533 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17534 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17535 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17536 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17537 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17538 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17539 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17540 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17541 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17542 (cmdline_parse_inst_t *)&cmd_config_dcb,
17543 (cmdline_parse_inst_t *)&cmd_read_reg,
17544 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17545 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17546 (cmdline_parse_inst_t *)&cmd_write_reg,
17547 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17548 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17549 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17550 (cmdline_parse_inst_t *)&cmd_stop,
17551 (cmdline_parse_inst_t *)&cmd_mac_addr,
17552 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17553 (cmdline_parse_inst_t *)&cmd_set_qmap,
17554 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17555 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17556 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17557 (cmdline_parse_inst_t *)&cmd_operate_port,
17558 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17559 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17560 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17561 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17562 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17563 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17564 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17565 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17566 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17567 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17568 (cmdline_parse_inst_t *)&cmd_config_mtu,
17569 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17570 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17571 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17572 (cmdline_parse_inst_t *)&cmd_config_rss,
17573 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17574 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17575 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17576 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17577 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17578 (cmdline_parse_inst_t *)&cmd_showport_reta,
17579 (cmdline_parse_inst_t *)&cmd_showport_macs,
17580 (cmdline_parse_inst_t *)&cmd_config_burst,
17581 (cmdline_parse_inst_t *)&cmd_config_thresh,
17582 (cmdline_parse_inst_t *)&cmd_config_threshold,
17583 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17584 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17585 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17586 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17587 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17588 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17589 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17590 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17591 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17592 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17593 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17594 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17595 (cmdline_parse_inst_t *)&cmd_dump,
17596 (cmdline_parse_inst_t *)&cmd_dump_one,
17597 #ifdef RTE_NET_I40E
17598 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17600 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17601 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17602 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17603 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17604 (cmdline_parse_inst_t *)&cmd_flow,
17605 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17606 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17607 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17608 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17609 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17610 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17611 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17612 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17613 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17614 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17615 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17616 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17617 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17618 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17619 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17620 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17621 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17622 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17623 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17624 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17625 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17626 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17627 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17628 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17629 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17630 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17631 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17632 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17633 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17634 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17635 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17636 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17637 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17638 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17639 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17640 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17641 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17642 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17643 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17644 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17645 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17646 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17647 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17648 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17649 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17650 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17651 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17652 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17653 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17654 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17655 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17656 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17657 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17658 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17659 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17660 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17661 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17662 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17663 (cmdline_parse_inst_t *)&cmd_ddp_add,
17664 (cmdline_parse_inst_t *)&cmd_ddp_del,
17665 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17666 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17667 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17668 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17669 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17670 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17671 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17672 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17673 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17674 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17675 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17676 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17678 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17679 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17680 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17681 (cmdline_parse_inst_t *)&cmd_queue_region,
17682 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17683 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17684 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17685 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17686 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17687 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17688 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17689 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17690 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17691 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17692 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17693 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17694 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17695 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17696 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17697 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17698 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17699 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17700 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17701 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17702 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17703 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17704 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17705 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17706 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17707 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17708 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17709 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17710 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17711 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17712 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17713 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17714 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17715 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17716 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17717 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17719 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17720 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17722 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17723 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17724 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17725 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17726 (cmdline_parse_inst_t *)&cmd_set_raw,
17727 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17728 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17729 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17730 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17731 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17732 (cmdline_parse_inst_t *)&cmd_show_capability,
17736 /* read cmdline commands from file */
17738 cmdline_read_from_file(const char *filename)
17740 struct cmdline *cl;
17742 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17744 printf("Failed to create file based cmdline context: %s\n",
17749 cmdline_interact(cl);
17754 printf("Read CLI commands from %s\n", filename);
17757 /* prompt function, called from main on MAIN lcore */
17762 /* initialize non-constant commands */
17763 cmd_set_fwd_mode_init();
17764 cmd_set_fwd_retry_mode_init();
17766 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17767 if (testpmd_cl == NULL)
17770 ret = atexit(prompt_exit);
17772 printf("Cannot set exit function for cmdline\n");
17774 cmdline_interact(testpmd_cl);
17776 cmdline_stdin_exit(testpmd_cl);
17782 if (testpmd_cl != NULL) {
17783 cmdline_quit(testpmd_cl);
17784 cmdline_stdin_exit(testpmd_cl);
17789 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17791 if (id == (portid_t)RTE_PORT_ALL) {
17794 RTE_ETH_FOREACH_DEV(pid) {
17795 /* check if need_reconfig has been set to 1 */
17796 if (ports[pid].need_reconfig == 0)
17797 ports[pid].need_reconfig = dev;
17798 /* check if need_reconfig_queues has been set to 1 */
17799 if (ports[pid].need_reconfig_queues == 0)
17800 ports[pid].need_reconfig_queues = queue;
17802 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17803 /* check if need_reconfig has been set to 1 */
17804 if (ports[id].need_reconfig == 0)
17805 ports[id].need_reconfig = dev;
17806 /* check if need_reconfig_queues has been set to 1 */
17807 if (ports[id].need_reconfig_queues == 0)
17808 ports[id].need_reconfig_queues = queue;