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 portid_t port_id = res->port_id;
3274 struct rte_port *port;
3278 port = &ports[port_id];
3279 /** Check if the port is not started **/
3280 if (port->port_status != RTE_PORT_STOPPED) {
3281 printf("Please stop port %d first\n", port_id);
3285 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3286 printf("The invalid number of traffic class,"
3287 " only 4 or 8 allowed.\n");
3291 if (nb_fwd_lcores < res->num_tcs) {
3292 printf("nb_cores shouldn't be less than number of TCs.\n");
3295 if (!strncmp(res->pfc_en, "on", 2))
3300 /* DCB in VT mode */
3301 if (!strncmp(res->vt_en, "on", 2))
3302 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3303 (enum rte_eth_nb_tcs)res->num_tcs,
3306 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3307 (enum rte_eth_nb_tcs)res->num_tcs,
3312 printf("Cannot initialize network ports.\n");
3316 cmd_reconfig_device_queue(port_id, 1, 1);
3319 cmdline_parse_token_string_t cmd_config_dcb_port =
3320 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3321 cmdline_parse_token_string_t cmd_config_dcb_config =
3322 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3323 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3324 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3325 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3326 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3327 cmdline_parse_token_string_t cmd_config_dcb_vt =
3328 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3329 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3330 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3331 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3332 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3333 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3334 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3335 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3336 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3338 cmdline_parse_inst_t cmd_config_dcb = {
3339 .f = cmd_config_dcb_parsed,
3341 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3343 (void *)&cmd_config_dcb_port,
3344 (void *)&cmd_config_dcb_config,
3345 (void *)&cmd_config_dcb_port_id,
3346 (void *)&cmd_config_dcb_dcb,
3347 (void *)&cmd_config_dcb_vt,
3348 (void *)&cmd_config_dcb_vt_en,
3349 (void *)&cmd_config_dcb_num_tcs,
3350 (void *)&cmd_config_dcb_pfc,
3351 (void *)&cmd_config_dcb_pfc_en,
3356 /* *** configure number of packets per burst *** */
3357 struct cmd_config_burst {
3358 cmdline_fixed_string_t port;
3359 cmdline_fixed_string_t keyword;
3360 cmdline_fixed_string_t all;
3361 cmdline_fixed_string_t name;
3366 cmd_config_burst_parsed(void *parsed_result,
3367 __rte_unused struct cmdline *cl,
3368 __rte_unused void *data)
3370 struct cmd_config_burst *res = parsed_result;
3371 struct rte_eth_dev_info dev_info;
3372 uint16_t rec_nb_pkts;
3375 if (!all_ports_stopped()) {
3376 printf("Please stop all ports first\n");
3380 if (!strcmp(res->name, "burst")) {
3381 if (res->value == 0) {
3382 /* If user gives a value of zero, query the PMD for
3383 * its recommended Rx burst size. Testpmd uses a single
3384 * size for all ports, so assume all ports are the same
3385 * NIC model and use the values from Port 0.
3387 ret = eth_dev_info_get_print_err(0, &dev_info);
3391 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3393 if (rec_nb_pkts == 0) {
3394 printf("PMD does not recommend a burst size.\n"
3395 "User provided value must be between"
3396 " 1 and %d\n", MAX_PKT_BURST);
3398 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3399 printf("PMD recommended burst size of %d"
3400 " exceeds maximum value of %d\n",
3401 rec_nb_pkts, MAX_PKT_BURST);
3404 printf("Using PMD-provided burst value of %d\n",
3406 nb_pkt_per_burst = rec_nb_pkts;
3407 } else if (res->value > MAX_PKT_BURST) {
3408 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3411 nb_pkt_per_burst = res->value;
3413 printf("Unknown parameter\n");
3419 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3422 cmdline_parse_token_string_t cmd_config_burst_port =
3423 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3424 cmdline_parse_token_string_t cmd_config_burst_keyword =
3425 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3426 cmdline_parse_token_string_t cmd_config_burst_all =
3427 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3428 cmdline_parse_token_string_t cmd_config_burst_name =
3429 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3430 cmdline_parse_token_num_t cmd_config_burst_value =
3431 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3433 cmdline_parse_inst_t cmd_config_burst = {
3434 .f = cmd_config_burst_parsed,
3436 .help_str = "port config all burst <value>",
3438 (void *)&cmd_config_burst_port,
3439 (void *)&cmd_config_burst_keyword,
3440 (void *)&cmd_config_burst_all,
3441 (void *)&cmd_config_burst_name,
3442 (void *)&cmd_config_burst_value,
3447 /* *** configure rx/tx queues *** */
3448 struct cmd_config_thresh {
3449 cmdline_fixed_string_t port;
3450 cmdline_fixed_string_t keyword;
3451 cmdline_fixed_string_t all;
3452 cmdline_fixed_string_t name;
3457 cmd_config_thresh_parsed(void *parsed_result,
3458 __rte_unused struct cmdline *cl,
3459 __rte_unused void *data)
3461 struct cmd_config_thresh *res = parsed_result;
3463 if (!all_ports_stopped()) {
3464 printf("Please stop all ports first\n");
3468 if (!strcmp(res->name, "txpt"))
3469 tx_pthresh = res->value;
3470 else if(!strcmp(res->name, "txht"))
3471 tx_hthresh = res->value;
3472 else if(!strcmp(res->name, "txwt"))
3473 tx_wthresh = res->value;
3474 else if(!strcmp(res->name, "rxpt"))
3475 rx_pthresh = res->value;
3476 else if(!strcmp(res->name, "rxht"))
3477 rx_hthresh = res->value;
3478 else if(!strcmp(res->name, "rxwt"))
3479 rx_wthresh = res->value;
3481 printf("Unknown parameter\n");
3487 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3490 cmdline_parse_token_string_t cmd_config_thresh_port =
3491 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3492 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3493 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3494 cmdline_parse_token_string_t cmd_config_thresh_all =
3495 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3496 cmdline_parse_token_string_t cmd_config_thresh_name =
3497 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3498 "txpt#txht#txwt#rxpt#rxht#rxwt");
3499 cmdline_parse_token_num_t cmd_config_thresh_value =
3500 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3502 cmdline_parse_inst_t cmd_config_thresh = {
3503 .f = cmd_config_thresh_parsed,
3505 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3507 (void *)&cmd_config_thresh_port,
3508 (void *)&cmd_config_thresh_keyword,
3509 (void *)&cmd_config_thresh_all,
3510 (void *)&cmd_config_thresh_name,
3511 (void *)&cmd_config_thresh_value,
3516 /* *** configure free/rs threshold *** */
3517 struct cmd_config_threshold {
3518 cmdline_fixed_string_t port;
3519 cmdline_fixed_string_t keyword;
3520 cmdline_fixed_string_t all;
3521 cmdline_fixed_string_t name;
3526 cmd_config_threshold_parsed(void *parsed_result,
3527 __rte_unused struct cmdline *cl,
3528 __rte_unused void *data)
3530 struct cmd_config_threshold *res = parsed_result;
3532 if (!all_ports_stopped()) {
3533 printf("Please stop all ports first\n");
3537 if (!strcmp(res->name, "txfreet"))
3538 tx_free_thresh = res->value;
3539 else if (!strcmp(res->name, "txrst"))
3540 tx_rs_thresh = res->value;
3541 else if (!strcmp(res->name, "rxfreet"))
3542 rx_free_thresh = res->value;
3544 printf("Unknown parameter\n");
3550 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3553 cmdline_parse_token_string_t cmd_config_threshold_port =
3554 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3555 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3556 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3558 cmdline_parse_token_string_t cmd_config_threshold_all =
3559 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3560 cmdline_parse_token_string_t cmd_config_threshold_name =
3561 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3562 "txfreet#txrst#rxfreet");
3563 cmdline_parse_token_num_t cmd_config_threshold_value =
3564 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3566 cmdline_parse_inst_t cmd_config_threshold = {
3567 .f = cmd_config_threshold_parsed,
3569 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3571 (void *)&cmd_config_threshold_port,
3572 (void *)&cmd_config_threshold_keyword,
3573 (void *)&cmd_config_threshold_all,
3574 (void *)&cmd_config_threshold_name,
3575 (void *)&cmd_config_threshold_value,
3581 struct cmd_stop_result {
3582 cmdline_fixed_string_t stop;
3585 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3586 __rte_unused struct cmdline *cl,
3587 __rte_unused void *data)
3589 stop_packet_forwarding();
3592 cmdline_parse_token_string_t cmd_stop_stop =
3593 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3595 cmdline_parse_inst_t cmd_stop = {
3596 .f = cmd_stop_parsed,
3598 .help_str = "stop: Stop packet forwarding",
3600 (void *)&cmd_stop_stop,
3605 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3608 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3609 unsigned int *parsed_items, int check_unique_values)
3611 unsigned int nb_item;
3619 * First parse all items in the list and store their value.
3624 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3626 if ((c >= '0') && (c <= '9')) {
3627 value = (unsigned int) (value * 10 + (c - '0'));
3632 printf("character %c is not a decimal digit\n", c);
3636 printf("No valid value before comma\n");
3639 if (nb_item < max_items) {
3640 parsed_items[nb_item] = value;
3646 if (nb_item >= max_items) {
3647 printf("Number of %s = %u > %u (maximum items)\n",
3648 item_name, nb_item + 1, max_items);
3651 parsed_items[nb_item++] = value;
3652 if (! check_unique_values)
3656 * Then, check that all values in the list are differents.
3657 * No optimization here...
3659 for (i = 0; i < nb_item; i++) {
3660 for (j = i + 1; j < nb_item; j++) {
3661 if (parsed_items[j] == parsed_items[i]) {
3662 printf("duplicated %s %u at index %u and %u\n",
3663 item_name, parsed_items[i], i, j);
3671 struct cmd_set_list_result {
3672 cmdline_fixed_string_t cmd_keyword;
3673 cmdline_fixed_string_t list_name;
3674 cmdline_fixed_string_t list_of_items;
3677 static void cmd_set_list_parsed(void *parsed_result,
3678 __rte_unused struct cmdline *cl,
3679 __rte_unused void *data)
3681 struct cmd_set_list_result *res;
3683 unsigned int lcorelist[RTE_MAX_LCORE];
3684 unsigned int portlist[RTE_MAX_ETHPORTS];
3686 unsigned int nb_item;
3688 if (test_done == 0) {
3689 printf("Please stop forwarding first\n");
3693 res = parsed_result;
3694 if (!strcmp(res->list_name, "corelist")) {
3695 nb_item = parse_item_list(res->list_of_items, "core",
3697 parsed_items.lcorelist, 1);
3699 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3704 if (!strcmp(res->list_name, "portlist")) {
3705 nb_item = parse_item_list(res->list_of_items, "port",
3707 parsed_items.portlist, 1);
3709 set_fwd_ports_list(parsed_items.portlist, nb_item);
3715 cmdline_parse_token_string_t cmd_set_list_keyword =
3716 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3718 cmdline_parse_token_string_t cmd_set_list_name =
3719 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3720 "corelist#portlist");
3721 cmdline_parse_token_string_t cmd_set_list_of_items =
3722 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3725 cmdline_parse_inst_t cmd_set_fwd_list = {
3726 .f = cmd_set_list_parsed,
3728 .help_str = "set corelist|portlist <list0[,list1]*>",
3730 (void *)&cmd_set_list_keyword,
3731 (void *)&cmd_set_list_name,
3732 (void *)&cmd_set_list_of_items,
3737 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3739 struct cmd_setmask_result {
3740 cmdline_fixed_string_t set;
3741 cmdline_fixed_string_t mask;
3745 static void cmd_set_mask_parsed(void *parsed_result,
3746 __rte_unused struct cmdline *cl,
3747 __rte_unused void *data)
3749 struct cmd_setmask_result *res = parsed_result;
3751 if (test_done == 0) {
3752 printf("Please stop forwarding first\n");
3755 if (!strcmp(res->mask, "coremask")) {
3756 set_fwd_lcores_mask(res->hexavalue);
3758 } else if (!strcmp(res->mask, "portmask")) {
3759 set_fwd_ports_mask(res->hexavalue);
3764 cmdline_parse_token_string_t cmd_setmask_set =
3765 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3766 cmdline_parse_token_string_t cmd_setmask_mask =
3767 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3768 "coremask#portmask");
3769 cmdline_parse_token_num_t cmd_setmask_value =
3770 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3772 cmdline_parse_inst_t cmd_set_fwd_mask = {
3773 .f = cmd_set_mask_parsed,
3775 .help_str = "set coremask|portmask <hexadecimal value>",
3777 (void *)&cmd_setmask_set,
3778 (void *)&cmd_setmask_mask,
3779 (void *)&cmd_setmask_value,
3785 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3787 struct cmd_set_result {
3788 cmdline_fixed_string_t set;
3789 cmdline_fixed_string_t what;
3793 static void cmd_set_parsed(void *parsed_result,
3794 __rte_unused struct cmdline *cl,
3795 __rte_unused void *data)
3797 struct cmd_set_result *res = parsed_result;
3798 if (!strcmp(res->what, "nbport")) {
3799 set_fwd_ports_number(res->value);
3801 } else if (!strcmp(res->what, "nbcore")) {
3802 set_fwd_lcores_number(res->value);
3804 } else if (!strcmp(res->what, "burst"))
3805 set_nb_pkt_per_burst(res->value);
3806 else if (!strcmp(res->what, "verbose"))
3807 set_verbose_level(res->value);
3810 cmdline_parse_token_string_t cmd_set_set =
3811 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3812 cmdline_parse_token_string_t cmd_set_what =
3813 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3814 "nbport#nbcore#burst#verbose");
3815 cmdline_parse_token_num_t cmd_set_value =
3816 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3818 cmdline_parse_inst_t cmd_set_numbers = {
3819 .f = cmd_set_parsed,
3821 .help_str = "set nbport|nbcore|burst|verbose <value>",
3823 (void *)&cmd_set_set,
3824 (void *)&cmd_set_what,
3825 (void *)&cmd_set_value,
3830 /* *** SET LOG LEVEL CONFIGURATION *** */
3832 struct cmd_set_log_result {
3833 cmdline_fixed_string_t set;
3834 cmdline_fixed_string_t log;
3835 cmdline_fixed_string_t type;
3840 cmd_set_log_parsed(void *parsed_result,
3841 __rte_unused struct cmdline *cl,
3842 __rte_unused void *data)
3844 struct cmd_set_log_result *res;
3847 res = parsed_result;
3848 if (!strcmp(res->type, "global"))
3849 rte_log_set_global_level(res->level);
3851 ret = rte_log_set_level_regexp(res->type, res->level);
3853 printf("Unable to set log level\n");
3857 cmdline_parse_token_string_t cmd_set_log_set =
3858 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3859 cmdline_parse_token_string_t cmd_set_log_log =
3860 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3861 cmdline_parse_token_string_t cmd_set_log_type =
3862 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3863 cmdline_parse_token_num_t cmd_set_log_level =
3864 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3866 cmdline_parse_inst_t cmd_set_log = {
3867 .f = cmd_set_log_parsed,
3869 .help_str = "set log global|<type> <level>",
3871 (void *)&cmd_set_log_set,
3872 (void *)&cmd_set_log_log,
3873 (void *)&cmd_set_log_type,
3874 (void *)&cmd_set_log_level,
3879 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3881 struct cmd_set_rxoffs_result {
3882 cmdline_fixed_string_t cmd_keyword;
3883 cmdline_fixed_string_t rxoffs;
3884 cmdline_fixed_string_t seg_offsets;
3888 cmd_set_rxoffs_parsed(void *parsed_result,
3889 __rte_unused struct cmdline *cl,
3890 __rte_unused void *data)
3892 struct cmd_set_rxoffs_result *res;
3893 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3894 unsigned int nb_segs;
3896 res = parsed_result;
3897 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3898 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3900 set_rx_pkt_offsets(seg_offsets, nb_segs);
3901 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3904 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3905 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3906 cmd_keyword, "set");
3907 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3908 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3910 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3911 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3914 cmdline_parse_inst_t cmd_set_rxoffs = {
3915 .f = cmd_set_rxoffs_parsed,
3917 .help_str = "set rxoffs <len0[,len1]*>",
3919 (void *)&cmd_set_rxoffs_keyword,
3920 (void *)&cmd_set_rxoffs_name,
3921 (void *)&cmd_set_rxoffs_offsets,
3926 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3928 struct cmd_set_rxpkts_result {
3929 cmdline_fixed_string_t cmd_keyword;
3930 cmdline_fixed_string_t rxpkts;
3931 cmdline_fixed_string_t seg_lengths;
3935 cmd_set_rxpkts_parsed(void *parsed_result,
3936 __rte_unused struct cmdline *cl,
3937 __rte_unused void *data)
3939 struct cmd_set_rxpkts_result *res;
3940 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3941 unsigned int nb_segs;
3943 res = parsed_result;
3944 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3945 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3947 set_rx_pkt_segments(seg_lengths, nb_segs);
3948 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3951 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3952 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3953 cmd_keyword, "set");
3954 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3955 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3957 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3958 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3961 cmdline_parse_inst_t cmd_set_rxpkts = {
3962 .f = cmd_set_rxpkts_parsed,
3964 .help_str = "set rxpkts <len0[,len1]*>",
3966 (void *)&cmd_set_rxpkts_keyword,
3967 (void *)&cmd_set_rxpkts_name,
3968 (void *)&cmd_set_rxpkts_lengths,
3973 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3975 struct cmd_set_txpkts_result {
3976 cmdline_fixed_string_t cmd_keyword;
3977 cmdline_fixed_string_t txpkts;
3978 cmdline_fixed_string_t seg_lengths;
3982 cmd_set_txpkts_parsed(void *parsed_result,
3983 __rte_unused struct cmdline *cl,
3984 __rte_unused void *data)
3986 struct cmd_set_txpkts_result *res;
3987 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3988 unsigned int nb_segs;
3990 res = parsed_result;
3991 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3992 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3994 set_tx_pkt_segments(seg_lengths, nb_segs);
3997 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3998 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3999 cmd_keyword, "set");
4000 cmdline_parse_token_string_t cmd_set_txpkts_name =
4001 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4003 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4004 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4007 cmdline_parse_inst_t cmd_set_txpkts = {
4008 .f = cmd_set_txpkts_parsed,
4010 .help_str = "set txpkts <len0[,len1]*>",
4012 (void *)&cmd_set_txpkts_keyword,
4013 (void *)&cmd_set_txpkts_name,
4014 (void *)&cmd_set_txpkts_lengths,
4019 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4021 struct cmd_set_txsplit_result {
4022 cmdline_fixed_string_t cmd_keyword;
4023 cmdline_fixed_string_t txsplit;
4024 cmdline_fixed_string_t mode;
4028 cmd_set_txsplit_parsed(void *parsed_result,
4029 __rte_unused struct cmdline *cl,
4030 __rte_unused void *data)
4032 struct cmd_set_txsplit_result *res;
4034 res = parsed_result;
4035 set_tx_pkt_split(res->mode);
4038 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4039 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4040 cmd_keyword, "set");
4041 cmdline_parse_token_string_t cmd_set_txsplit_name =
4042 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4043 txsplit, "txsplit");
4044 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4045 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4048 cmdline_parse_inst_t cmd_set_txsplit = {
4049 .f = cmd_set_txsplit_parsed,
4051 .help_str = "set txsplit on|off|rand",
4053 (void *)&cmd_set_txsplit_keyword,
4054 (void *)&cmd_set_txsplit_name,
4055 (void *)&cmd_set_txsplit_mode,
4060 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4062 struct cmd_set_txtimes_result {
4063 cmdline_fixed_string_t cmd_keyword;
4064 cmdline_fixed_string_t txtimes;
4065 cmdline_fixed_string_t tx_times;
4069 cmd_set_txtimes_parsed(void *parsed_result,
4070 __rte_unused struct cmdline *cl,
4071 __rte_unused void *data)
4073 struct cmd_set_txtimes_result *res;
4074 unsigned int tx_times[2] = {0, 0};
4075 unsigned int n_times;
4077 res = parsed_result;
4078 n_times = parse_item_list(res->tx_times, "tx times",
4081 set_tx_pkt_times(tx_times);
4084 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4085 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4086 cmd_keyword, "set");
4087 cmdline_parse_token_string_t cmd_set_txtimes_name =
4088 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4089 txtimes, "txtimes");
4090 cmdline_parse_token_string_t cmd_set_txtimes_value =
4091 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4094 cmdline_parse_inst_t cmd_set_txtimes = {
4095 .f = cmd_set_txtimes_parsed,
4097 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4099 (void *)&cmd_set_txtimes_keyword,
4100 (void *)&cmd_set_txtimes_name,
4101 (void *)&cmd_set_txtimes_value,
4106 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4107 struct cmd_rx_vlan_filter_all_result {
4108 cmdline_fixed_string_t rx_vlan;
4109 cmdline_fixed_string_t what;
4110 cmdline_fixed_string_t all;
4115 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4116 __rte_unused struct cmdline *cl,
4117 __rte_unused void *data)
4119 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4121 if (!strcmp(res->what, "add"))
4122 rx_vlan_all_filter_set(res->port_id, 1);
4124 rx_vlan_all_filter_set(res->port_id, 0);
4127 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4128 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4129 rx_vlan, "rx_vlan");
4130 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4131 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4133 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4134 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4136 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4137 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4138 port_id, RTE_UINT16);
4140 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4141 .f = cmd_rx_vlan_filter_all_parsed,
4143 .help_str = "rx_vlan add|rm all <port_id>: "
4144 "Add/Remove all identifiers to/from the set of VLAN "
4145 "identifiers filtered by a port",
4147 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4148 (void *)&cmd_rx_vlan_filter_all_what,
4149 (void *)&cmd_rx_vlan_filter_all_all,
4150 (void *)&cmd_rx_vlan_filter_all_portid,
4155 /* *** VLAN OFFLOAD SET ON A PORT *** */
4156 struct cmd_vlan_offload_result {
4157 cmdline_fixed_string_t vlan;
4158 cmdline_fixed_string_t set;
4159 cmdline_fixed_string_t vlan_type;
4160 cmdline_fixed_string_t what;
4161 cmdline_fixed_string_t on;
4162 cmdline_fixed_string_t port_id;
4166 cmd_vlan_offload_parsed(void *parsed_result,
4167 __rte_unused struct cmdline *cl,
4168 __rte_unused void *data)
4171 struct cmd_vlan_offload_result *res = parsed_result;
4174 portid_t port_id = 0;
4178 len = strnlen(str, STR_TOKEN_SIZE);
4180 /* Get port_id first */
4188 tmp = strtoul(str, NULL, 0);
4189 /* If port_id greater that what portid_t can represent, return */
4190 if(tmp >= RTE_MAX_ETHPORTS)
4192 port_id = (portid_t)tmp;
4194 if (!strcmp(res->on, "on"))
4199 if (!strcmp(res->what, "strip"))
4200 rx_vlan_strip_set(port_id, on);
4201 else if(!strcmp(res->what, "stripq")){
4202 uint16_t queue_id = 0;
4204 /* No queue_id, return */
4206 printf("must specify (port,queue_id)\n");
4209 tmp = strtoul(str + i + 1, NULL, 0);
4210 /* If queue_id greater that what 16-bits can represent, return */
4214 queue_id = (uint16_t)tmp;
4215 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4217 else if (!strcmp(res->what, "filter"))
4218 rx_vlan_filter_set(port_id, on);
4219 else if (!strcmp(res->what, "qinq_strip"))
4220 rx_vlan_qinq_strip_set(port_id, on);
4222 vlan_extend_set(port_id, on);
4227 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4228 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4230 cmdline_parse_token_string_t cmd_vlan_offload_set =
4231 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4233 cmdline_parse_token_string_t cmd_vlan_offload_what =
4234 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4235 what, "strip#filter#qinq_strip#extend#stripq");
4236 cmdline_parse_token_string_t cmd_vlan_offload_on =
4237 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4239 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4240 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4243 cmdline_parse_inst_t cmd_vlan_offload = {
4244 .f = cmd_vlan_offload_parsed,
4246 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4247 "<port_id[,queue_id]>: "
4248 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4250 (void *)&cmd_vlan_offload_vlan,
4251 (void *)&cmd_vlan_offload_set,
4252 (void *)&cmd_vlan_offload_what,
4253 (void *)&cmd_vlan_offload_on,
4254 (void *)&cmd_vlan_offload_portid,
4259 /* *** VLAN TPID SET ON A PORT *** */
4260 struct cmd_vlan_tpid_result {
4261 cmdline_fixed_string_t vlan;
4262 cmdline_fixed_string_t set;
4263 cmdline_fixed_string_t vlan_type;
4264 cmdline_fixed_string_t what;
4270 cmd_vlan_tpid_parsed(void *parsed_result,
4271 __rte_unused struct cmdline *cl,
4272 __rte_unused void *data)
4274 struct cmd_vlan_tpid_result *res = parsed_result;
4275 enum rte_vlan_type vlan_type;
4277 if (!strcmp(res->vlan_type, "inner"))
4278 vlan_type = ETH_VLAN_TYPE_INNER;
4279 else if (!strcmp(res->vlan_type, "outer"))
4280 vlan_type = ETH_VLAN_TYPE_OUTER;
4282 printf("Unknown vlan type\n");
4285 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4288 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4289 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4291 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4292 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4294 cmdline_parse_token_string_t cmd_vlan_type =
4295 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4296 vlan_type, "inner#outer");
4297 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4298 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4300 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4301 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4303 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4304 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4305 port_id, RTE_UINT16);
4307 cmdline_parse_inst_t cmd_vlan_tpid = {
4308 .f = cmd_vlan_tpid_parsed,
4310 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4311 "Set the VLAN Ether type",
4313 (void *)&cmd_vlan_tpid_vlan,
4314 (void *)&cmd_vlan_tpid_set,
4315 (void *)&cmd_vlan_type,
4316 (void *)&cmd_vlan_tpid_what,
4317 (void *)&cmd_vlan_tpid_tpid,
4318 (void *)&cmd_vlan_tpid_portid,
4323 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4324 struct cmd_rx_vlan_filter_result {
4325 cmdline_fixed_string_t rx_vlan;
4326 cmdline_fixed_string_t what;
4332 cmd_rx_vlan_filter_parsed(void *parsed_result,
4333 __rte_unused struct cmdline *cl,
4334 __rte_unused void *data)
4336 struct cmd_rx_vlan_filter_result *res = parsed_result;
4338 if (!strcmp(res->what, "add"))
4339 rx_vft_set(res->port_id, res->vlan_id, 1);
4341 rx_vft_set(res->port_id, res->vlan_id, 0);
4344 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4345 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4346 rx_vlan, "rx_vlan");
4347 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4348 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4350 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4351 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4352 vlan_id, RTE_UINT16);
4353 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4354 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4355 port_id, RTE_UINT16);
4357 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4358 .f = cmd_rx_vlan_filter_parsed,
4360 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4361 "Add/Remove a VLAN identifier to/from the set of VLAN "
4362 "identifiers filtered by a port",
4364 (void *)&cmd_rx_vlan_filter_rx_vlan,
4365 (void *)&cmd_rx_vlan_filter_what,
4366 (void *)&cmd_rx_vlan_filter_vlanid,
4367 (void *)&cmd_rx_vlan_filter_portid,
4372 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4373 struct cmd_tx_vlan_set_result {
4374 cmdline_fixed_string_t tx_vlan;
4375 cmdline_fixed_string_t set;
4381 cmd_tx_vlan_set_parsed(void *parsed_result,
4382 __rte_unused struct cmdline *cl,
4383 __rte_unused void *data)
4385 struct cmd_tx_vlan_set_result *res = parsed_result;
4387 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4390 if (!port_is_stopped(res->port_id)) {
4391 printf("Please stop port %d first\n", res->port_id);
4395 tx_vlan_set(res->port_id, res->vlan_id);
4397 cmd_reconfig_device_queue(res->port_id, 1, 1);
4400 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4401 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4402 tx_vlan, "tx_vlan");
4403 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4404 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4406 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4407 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4408 port_id, RTE_UINT16);
4409 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4410 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4411 vlan_id, RTE_UINT16);
4413 cmdline_parse_inst_t cmd_tx_vlan_set = {
4414 .f = cmd_tx_vlan_set_parsed,
4416 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4417 "Enable hardware insertion of a single VLAN header "
4418 "with a given TAG Identifier in packets sent on a port",
4420 (void *)&cmd_tx_vlan_set_tx_vlan,
4421 (void *)&cmd_tx_vlan_set_set,
4422 (void *)&cmd_tx_vlan_set_portid,
4423 (void *)&cmd_tx_vlan_set_vlanid,
4428 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4429 struct cmd_tx_vlan_set_qinq_result {
4430 cmdline_fixed_string_t tx_vlan;
4431 cmdline_fixed_string_t set;
4434 uint16_t vlan_id_outer;
4438 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4439 __rte_unused struct cmdline *cl,
4440 __rte_unused void *data)
4442 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4444 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4447 if (!port_is_stopped(res->port_id)) {
4448 printf("Please stop port %d first\n", res->port_id);
4452 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4454 cmd_reconfig_device_queue(res->port_id, 1, 1);
4457 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4458 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4459 tx_vlan, "tx_vlan");
4460 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4461 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4463 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4464 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4465 port_id, RTE_UINT16);
4466 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4467 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4468 vlan_id, RTE_UINT16);
4469 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4470 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4471 vlan_id_outer, RTE_UINT16);
4473 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4474 .f = cmd_tx_vlan_set_qinq_parsed,
4476 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4477 "Enable hardware insertion of double VLAN header "
4478 "with given TAG Identifiers in packets sent on a port",
4480 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4481 (void *)&cmd_tx_vlan_set_qinq_set,
4482 (void *)&cmd_tx_vlan_set_qinq_portid,
4483 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4484 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4489 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4490 struct cmd_tx_vlan_set_pvid_result {
4491 cmdline_fixed_string_t tx_vlan;
4492 cmdline_fixed_string_t set;
4493 cmdline_fixed_string_t pvid;
4496 cmdline_fixed_string_t mode;
4500 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4501 __rte_unused struct cmdline *cl,
4502 __rte_unused void *data)
4504 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4506 if (strcmp(res->mode, "on") == 0)
4507 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4509 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4512 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4513 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4514 tx_vlan, "tx_vlan");
4515 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4516 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4518 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4519 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4521 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4522 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4523 port_id, RTE_UINT16);
4524 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4525 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4526 vlan_id, RTE_UINT16);
4527 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4528 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4531 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4532 .f = cmd_tx_vlan_set_pvid_parsed,
4534 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4536 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4537 (void *)&cmd_tx_vlan_set_pvid_set,
4538 (void *)&cmd_tx_vlan_set_pvid_pvid,
4539 (void *)&cmd_tx_vlan_set_pvid_port_id,
4540 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4541 (void *)&cmd_tx_vlan_set_pvid_mode,
4546 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4547 struct cmd_tx_vlan_reset_result {
4548 cmdline_fixed_string_t tx_vlan;
4549 cmdline_fixed_string_t reset;
4554 cmd_tx_vlan_reset_parsed(void *parsed_result,
4555 __rte_unused struct cmdline *cl,
4556 __rte_unused void *data)
4558 struct cmd_tx_vlan_reset_result *res = parsed_result;
4560 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4563 if (!port_is_stopped(res->port_id)) {
4564 printf("Please stop port %d first\n", res->port_id);
4568 tx_vlan_reset(res->port_id);
4570 cmd_reconfig_device_queue(res->port_id, 1, 1);
4573 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4574 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4575 tx_vlan, "tx_vlan");
4576 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4577 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4579 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4580 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4581 port_id, RTE_UINT16);
4583 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4584 .f = cmd_tx_vlan_reset_parsed,
4586 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4587 "VLAN header in packets sent on a port",
4589 (void *)&cmd_tx_vlan_reset_tx_vlan,
4590 (void *)&cmd_tx_vlan_reset_reset,
4591 (void *)&cmd_tx_vlan_reset_portid,
4597 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4598 struct cmd_csum_result {
4599 cmdline_fixed_string_t csum;
4600 cmdline_fixed_string_t mode;
4601 cmdline_fixed_string_t proto;
4602 cmdline_fixed_string_t hwsw;
4607 csum_show(int port_id)
4609 struct rte_eth_dev_info dev_info;
4610 uint64_t tx_offloads;
4613 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4614 printf("Parse tunnel is %s\n",
4615 (ports[port_id].parse_tunnel) ? "on" : "off");
4616 printf("IP checksum offload is %s\n",
4617 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4618 printf("UDP checksum offload is %s\n",
4619 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4620 printf("TCP checksum offload is %s\n",
4621 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4622 printf("SCTP checksum offload is %s\n",
4623 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4624 printf("Outer-Ip checksum offload is %s\n",
4625 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4626 printf("Outer-Udp checksum offload is %s\n",
4627 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4629 /* display warnings if configuration is not supported by the NIC */
4630 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4634 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4635 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4636 printf("Warning: hardware IP checksum enabled but not "
4637 "supported by port %d\n", port_id);
4639 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4640 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4641 printf("Warning: hardware UDP checksum enabled but not "
4642 "supported by port %d\n", port_id);
4644 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4645 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4646 printf("Warning: hardware TCP checksum enabled but not "
4647 "supported by port %d\n", port_id);
4649 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4650 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4651 printf("Warning: hardware SCTP checksum enabled but not "
4652 "supported by port %d\n", port_id);
4654 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4655 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4656 printf("Warning: hardware outer IP checksum enabled but not "
4657 "supported by port %d\n", port_id);
4659 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4660 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4662 printf("Warning: hardware outer UDP checksum enabled but not "
4663 "supported by port %d\n", port_id);
4668 cmd_config_queue_tx_offloads(struct rte_port *port)
4672 /* Apply queue tx offloads configuration */
4673 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4674 port->tx_conf[k].offloads =
4675 port->dev_conf.txmode.offloads;
4679 cmd_csum_parsed(void *parsed_result,
4680 __rte_unused struct cmdline *cl,
4681 __rte_unused void *data)
4683 struct cmd_csum_result *res = parsed_result;
4685 uint64_t csum_offloads = 0;
4686 struct rte_eth_dev_info dev_info;
4689 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4690 printf("invalid port %d\n", res->port_id);
4693 if (!port_is_stopped(res->port_id)) {
4694 printf("Please stop port %d first\n", res->port_id);
4698 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4702 if (!strcmp(res->mode, "set")) {
4704 if (!strcmp(res->hwsw, "hw"))
4707 if (!strcmp(res->proto, "ip")) {
4708 if (hw == 0 || (dev_info.tx_offload_capa &
4709 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4710 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4712 printf("IP checksum offload is not supported "
4713 "by port %u\n", res->port_id);
4715 } else if (!strcmp(res->proto, "udp")) {
4716 if (hw == 0 || (dev_info.tx_offload_capa &
4717 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4718 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4720 printf("UDP checksum offload is not supported "
4721 "by port %u\n", res->port_id);
4723 } else if (!strcmp(res->proto, "tcp")) {
4724 if (hw == 0 || (dev_info.tx_offload_capa &
4725 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4726 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4728 printf("TCP checksum offload is not supported "
4729 "by port %u\n", res->port_id);
4731 } else if (!strcmp(res->proto, "sctp")) {
4732 if (hw == 0 || (dev_info.tx_offload_capa &
4733 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4734 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4736 printf("SCTP checksum offload is not supported "
4737 "by port %u\n", res->port_id);
4739 } else if (!strcmp(res->proto, "outer-ip")) {
4740 if (hw == 0 || (dev_info.tx_offload_capa &
4741 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4743 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4745 printf("Outer IP checksum offload is not "
4746 "supported by port %u\n", res->port_id);
4748 } else if (!strcmp(res->proto, "outer-udp")) {
4749 if (hw == 0 || (dev_info.tx_offload_capa &
4750 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4752 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4754 printf("Outer UDP checksum offload is not "
4755 "supported by port %u\n", res->port_id);
4760 ports[res->port_id].dev_conf.txmode.offloads |=
4763 ports[res->port_id].dev_conf.txmode.offloads &=
4766 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4768 csum_show(res->port_id);
4770 cmd_reconfig_device_queue(res->port_id, 1, 1);
4773 cmdline_parse_token_string_t cmd_csum_csum =
4774 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4776 cmdline_parse_token_string_t cmd_csum_mode =
4777 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4779 cmdline_parse_token_string_t cmd_csum_proto =
4780 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4781 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4782 cmdline_parse_token_string_t cmd_csum_hwsw =
4783 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4785 cmdline_parse_token_num_t cmd_csum_portid =
4786 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4787 port_id, RTE_UINT16);
4789 cmdline_parse_inst_t cmd_csum_set = {
4790 .f = cmd_csum_parsed,
4792 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4793 "Enable/Disable hardware calculation of L3/L4 checksum when "
4794 "using csum forward engine",
4796 (void *)&cmd_csum_csum,
4797 (void *)&cmd_csum_mode,
4798 (void *)&cmd_csum_proto,
4799 (void *)&cmd_csum_hwsw,
4800 (void *)&cmd_csum_portid,
4805 cmdline_parse_token_string_t cmd_csum_mode_show =
4806 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4809 cmdline_parse_inst_t cmd_csum_show = {
4810 .f = cmd_csum_parsed,
4812 .help_str = "csum show <port_id>: Show checksum offload configuration",
4814 (void *)&cmd_csum_csum,
4815 (void *)&cmd_csum_mode_show,
4816 (void *)&cmd_csum_portid,
4821 /* Enable/disable tunnel parsing */
4822 struct cmd_csum_tunnel_result {
4823 cmdline_fixed_string_t csum;
4824 cmdline_fixed_string_t parse;
4825 cmdline_fixed_string_t onoff;
4830 cmd_csum_tunnel_parsed(void *parsed_result,
4831 __rte_unused struct cmdline *cl,
4832 __rte_unused void *data)
4834 struct cmd_csum_tunnel_result *res = parsed_result;
4836 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4839 if (!strcmp(res->onoff, "on"))
4840 ports[res->port_id].parse_tunnel = 1;
4842 ports[res->port_id].parse_tunnel = 0;
4844 csum_show(res->port_id);
4847 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4848 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4850 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4851 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4852 parse, "parse-tunnel");
4853 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4854 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4856 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4857 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4858 port_id, RTE_UINT16);
4860 cmdline_parse_inst_t cmd_csum_tunnel = {
4861 .f = cmd_csum_tunnel_parsed,
4863 .help_str = "csum parse-tunnel on|off <port_id>: "
4864 "Enable/Disable parsing of tunnels for csum engine",
4866 (void *)&cmd_csum_tunnel_csum,
4867 (void *)&cmd_csum_tunnel_parse,
4868 (void *)&cmd_csum_tunnel_onoff,
4869 (void *)&cmd_csum_tunnel_portid,
4874 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4875 struct cmd_tso_set_result {
4876 cmdline_fixed_string_t tso;
4877 cmdline_fixed_string_t mode;
4883 cmd_tso_set_parsed(void *parsed_result,
4884 __rte_unused struct cmdline *cl,
4885 __rte_unused void *data)
4887 struct cmd_tso_set_result *res = parsed_result;
4888 struct rte_eth_dev_info dev_info;
4891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4893 if (!port_is_stopped(res->port_id)) {
4894 printf("Please stop port %d first\n", res->port_id);
4898 if (!strcmp(res->mode, "set"))
4899 ports[res->port_id].tso_segsz = res->tso_segsz;
4901 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4905 if ((ports[res->port_id].tso_segsz != 0) &&
4906 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4907 printf("Error: TSO is not supported by port %d\n",
4912 if (ports[res->port_id].tso_segsz == 0) {
4913 ports[res->port_id].dev_conf.txmode.offloads &=
4914 ~DEV_TX_OFFLOAD_TCP_TSO;
4915 printf("TSO for non-tunneled packets is disabled\n");
4917 ports[res->port_id].dev_conf.txmode.offloads |=
4918 DEV_TX_OFFLOAD_TCP_TSO;
4919 printf("TSO segment size for non-tunneled packets is %d\n",
4920 ports[res->port_id].tso_segsz);
4922 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4924 /* display warnings if configuration is not supported by the NIC */
4925 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4929 if ((ports[res->port_id].tso_segsz != 0) &&
4930 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4931 printf("Warning: TSO enabled but not "
4932 "supported by port %d\n", res->port_id);
4935 cmd_reconfig_device_queue(res->port_id, 1, 1);
4938 cmdline_parse_token_string_t cmd_tso_set_tso =
4939 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4941 cmdline_parse_token_string_t cmd_tso_set_mode =
4942 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4944 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4945 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4946 tso_segsz, RTE_UINT16);
4947 cmdline_parse_token_num_t cmd_tso_set_portid =
4948 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4949 port_id, RTE_UINT16);
4951 cmdline_parse_inst_t cmd_tso_set = {
4952 .f = cmd_tso_set_parsed,
4954 .help_str = "tso set <tso_segsz> <port_id>: "
4955 "Set TSO segment size of non-tunneled packets for csum engine "
4958 (void *)&cmd_tso_set_tso,
4959 (void *)&cmd_tso_set_mode,
4960 (void *)&cmd_tso_set_tso_segsz,
4961 (void *)&cmd_tso_set_portid,
4966 cmdline_parse_token_string_t cmd_tso_show_mode =
4967 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4971 cmdline_parse_inst_t cmd_tso_show = {
4972 .f = cmd_tso_set_parsed,
4974 .help_str = "tso show <port_id>: "
4975 "Show TSO segment size of non-tunneled packets for csum engine",
4977 (void *)&cmd_tso_set_tso,
4978 (void *)&cmd_tso_show_mode,
4979 (void *)&cmd_tso_set_portid,
4984 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4985 struct cmd_tunnel_tso_set_result {
4986 cmdline_fixed_string_t tso;
4987 cmdline_fixed_string_t mode;
4992 static struct rte_eth_dev_info
4993 check_tunnel_tso_nic_support(portid_t port_id)
4995 struct rte_eth_dev_info dev_info;
4997 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5000 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5001 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5002 "not enabled for port %d\n", port_id);
5003 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5004 printf("Warning: GRE TUNNEL TSO not supported therefore "
5005 "not enabled for port %d\n", port_id);
5006 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5007 printf("Warning: IPIP TUNNEL TSO not supported therefore "
5008 "not enabled for port %d\n", port_id);
5009 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5010 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5011 "not enabled for port %d\n", port_id);
5012 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5013 printf("Warning: IP TUNNEL TSO not supported therefore "
5014 "not enabled for port %d\n", port_id);
5015 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5016 printf("Warning: UDP TUNNEL TSO not supported therefore "
5017 "not enabled for port %d\n", port_id);
5022 cmd_tunnel_tso_set_parsed(void *parsed_result,
5023 __rte_unused struct cmdline *cl,
5024 __rte_unused void *data)
5026 struct cmd_tunnel_tso_set_result *res = parsed_result;
5027 struct rte_eth_dev_info dev_info;
5029 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5031 if (!port_is_stopped(res->port_id)) {
5032 printf("Please stop port %d first\n", res->port_id);
5036 if (!strcmp(res->mode, "set"))
5037 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5039 dev_info = check_tunnel_tso_nic_support(res->port_id);
5040 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5041 ports[res->port_id].dev_conf.txmode.offloads &=
5042 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5043 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5044 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5045 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5046 DEV_TX_OFFLOAD_IP_TNL_TSO |
5047 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5048 printf("TSO for tunneled packets is disabled\n");
5050 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5051 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5052 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5053 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5054 DEV_TX_OFFLOAD_IP_TNL_TSO |
5055 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5057 ports[res->port_id].dev_conf.txmode.offloads |=
5058 (tso_offloads & dev_info.tx_offload_capa);
5059 printf("TSO segment size for tunneled packets is %d\n",
5060 ports[res->port_id].tunnel_tso_segsz);
5062 /* Below conditions are needed to make it work:
5063 * (1) tunnel TSO is supported by the NIC;
5064 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5066 * (3) for tunneled pkts with outer L3 of IPv4,
5067 * "csum set outer-ip" must be set to hw, because after tso,
5068 * total_len of outer IP header is changed, and the checksum
5069 * of outer IP header calculated by sw should be wrong; that
5070 * is not necessary for IPv6 tunneled pkts because there's no
5071 * checksum in IP header anymore.
5074 if (!ports[res->port_id].parse_tunnel)
5075 printf("Warning: csum parse_tunnel must be set "
5076 "so that tunneled packets are recognized\n");
5077 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5078 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5079 printf("Warning: csum set outer-ip must be set to hw "
5080 "if outer L3 is IPv4; not necessary for IPv6\n");
5083 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5084 cmd_reconfig_device_queue(res->port_id, 1, 1);
5087 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5088 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5090 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5091 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5093 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5094 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5095 tso_segsz, RTE_UINT16);
5096 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5097 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5098 port_id, RTE_UINT16);
5100 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5101 .f = cmd_tunnel_tso_set_parsed,
5103 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5104 "Set TSO segment size of tunneled packets for csum engine "
5107 (void *)&cmd_tunnel_tso_set_tso,
5108 (void *)&cmd_tunnel_tso_set_mode,
5109 (void *)&cmd_tunnel_tso_set_tso_segsz,
5110 (void *)&cmd_tunnel_tso_set_portid,
5115 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5116 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5120 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5121 .f = cmd_tunnel_tso_set_parsed,
5123 .help_str = "tunnel_tso show <port_id> "
5124 "Show TSO segment size of tunneled packets for csum engine",
5126 (void *)&cmd_tunnel_tso_set_tso,
5127 (void *)&cmd_tunnel_tso_show_mode,
5128 (void *)&cmd_tunnel_tso_set_portid,
5133 /* *** SET GRO FOR A PORT *** */
5134 struct cmd_gro_enable_result {
5135 cmdline_fixed_string_t cmd_set;
5136 cmdline_fixed_string_t cmd_port;
5137 cmdline_fixed_string_t cmd_keyword;
5138 cmdline_fixed_string_t cmd_onoff;
5143 cmd_gro_enable_parsed(void *parsed_result,
5144 __rte_unused struct cmdline *cl,
5145 __rte_unused void *data)
5147 struct cmd_gro_enable_result *res;
5149 res = parsed_result;
5150 if (!strcmp(res->cmd_keyword, "gro"))
5151 setup_gro(res->cmd_onoff, res->cmd_pid);
5154 cmdline_parse_token_string_t cmd_gro_enable_set =
5155 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5157 cmdline_parse_token_string_t cmd_gro_enable_port =
5158 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5159 cmd_keyword, "port");
5160 cmdline_parse_token_num_t cmd_gro_enable_pid =
5161 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5162 cmd_pid, RTE_UINT16);
5163 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5164 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5165 cmd_keyword, "gro");
5166 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5167 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5168 cmd_onoff, "on#off");
5170 cmdline_parse_inst_t cmd_gro_enable = {
5171 .f = cmd_gro_enable_parsed,
5173 .help_str = "set port <port_id> gro on|off",
5175 (void *)&cmd_gro_enable_set,
5176 (void *)&cmd_gro_enable_port,
5177 (void *)&cmd_gro_enable_pid,
5178 (void *)&cmd_gro_enable_keyword,
5179 (void *)&cmd_gro_enable_onoff,
5184 /* *** DISPLAY GRO CONFIGURATION *** */
5185 struct cmd_gro_show_result {
5186 cmdline_fixed_string_t cmd_show;
5187 cmdline_fixed_string_t cmd_port;
5188 cmdline_fixed_string_t cmd_keyword;
5193 cmd_gro_show_parsed(void *parsed_result,
5194 __rte_unused struct cmdline *cl,
5195 __rte_unused void *data)
5197 struct cmd_gro_show_result *res;
5199 res = parsed_result;
5200 if (!strcmp(res->cmd_keyword, "gro"))
5201 show_gro(res->cmd_pid);
5204 cmdline_parse_token_string_t cmd_gro_show_show =
5205 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5207 cmdline_parse_token_string_t cmd_gro_show_port =
5208 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5210 cmdline_parse_token_num_t cmd_gro_show_pid =
5211 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5212 cmd_pid, RTE_UINT16);
5213 cmdline_parse_token_string_t cmd_gro_show_keyword =
5214 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5215 cmd_keyword, "gro");
5217 cmdline_parse_inst_t cmd_gro_show = {
5218 .f = cmd_gro_show_parsed,
5220 .help_str = "show port <port_id> gro",
5222 (void *)&cmd_gro_show_show,
5223 (void *)&cmd_gro_show_port,
5224 (void *)&cmd_gro_show_pid,
5225 (void *)&cmd_gro_show_keyword,
5230 /* *** SET FLUSH CYCLES FOR GRO *** */
5231 struct cmd_gro_flush_result {
5232 cmdline_fixed_string_t cmd_set;
5233 cmdline_fixed_string_t cmd_keyword;
5234 cmdline_fixed_string_t cmd_flush;
5239 cmd_gro_flush_parsed(void *parsed_result,
5240 __rte_unused struct cmdline *cl,
5241 __rte_unused void *data)
5243 struct cmd_gro_flush_result *res;
5245 res = parsed_result;
5246 if ((!strcmp(res->cmd_keyword, "gro")) &&
5247 (!strcmp(res->cmd_flush, "flush")))
5248 setup_gro_flush_cycles(res->cmd_cycles);
5251 cmdline_parse_token_string_t cmd_gro_flush_set =
5252 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5254 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5255 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5256 cmd_keyword, "gro");
5257 cmdline_parse_token_string_t cmd_gro_flush_flush =
5258 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5259 cmd_flush, "flush");
5260 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5261 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5262 cmd_cycles, RTE_UINT8);
5264 cmdline_parse_inst_t cmd_gro_flush = {
5265 .f = cmd_gro_flush_parsed,
5267 .help_str = "set gro flush <cycles>",
5269 (void *)&cmd_gro_flush_set,
5270 (void *)&cmd_gro_flush_keyword,
5271 (void *)&cmd_gro_flush_flush,
5272 (void *)&cmd_gro_flush_cycles,
5277 /* *** ENABLE/DISABLE GSO *** */
5278 struct cmd_gso_enable_result {
5279 cmdline_fixed_string_t cmd_set;
5280 cmdline_fixed_string_t cmd_port;
5281 cmdline_fixed_string_t cmd_keyword;
5282 cmdline_fixed_string_t cmd_mode;
5287 cmd_gso_enable_parsed(void *parsed_result,
5288 __rte_unused struct cmdline *cl,
5289 __rte_unused void *data)
5291 struct cmd_gso_enable_result *res;
5293 res = parsed_result;
5294 if (!strcmp(res->cmd_keyword, "gso"))
5295 setup_gso(res->cmd_mode, res->cmd_pid);
5298 cmdline_parse_token_string_t cmd_gso_enable_set =
5299 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5301 cmdline_parse_token_string_t cmd_gso_enable_port =
5302 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5304 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5305 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5306 cmd_keyword, "gso");
5307 cmdline_parse_token_string_t cmd_gso_enable_mode =
5308 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5309 cmd_mode, "on#off");
5310 cmdline_parse_token_num_t cmd_gso_enable_pid =
5311 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5312 cmd_pid, RTE_UINT16);
5314 cmdline_parse_inst_t cmd_gso_enable = {
5315 .f = cmd_gso_enable_parsed,
5317 .help_str = "set port <port_id> gso on|off",
5319 (void *)&cmd_gso_enable_set,
5320 (void *)&cmd_gso_enable_port,
5321 (void *)&cmd_gso_enable_pid,
5322 (void *)&cmd_gso_enable_keyword,
5323 (void *)&cmd_gso_enable_mode,
5328 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5329 struct cmd_gso_size_result {
5330 cmdline_fixed_string_t cmd_set;
5331 cmdline_fixed_string_t cmd_keyword;
5332 cmdline_fixed_string_t cmd_segsz;
5337 cmd_gso_size_parsed(void *parsed_result,
5338 __rte_unused struct cmdline *cl,
5339 __rte_unused void *data)
5341 struct cmd_gso_size_result *res = parsed_result;
5343 if (test_done == 0) {
5344 printf("Before setting GSO segsz, please first"
5345 " stop forwarding\n");
5349 if (!strcmp(res->cmd_keyword, "gso") &&
5350 !strcmp(res->cmd_segsz, "segsz")) {
5351 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5352 printf("gso_size should be larger than %zu."
5353 " Please input a legal value\n",
5354 RTE_GSO_SEG_SIZE_MIN);
5356 gso_max_segment_size = res->cmd_size;
5360 cmdline_parse_token_string_t cmd_gso_size_set =
5361 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5363 cmdline_parse_token_string_t cmd_gso_size_keyword =
5364 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5365 cmd_keyword, "gso");
5366 cmdline_parse_token_string_t cmd_gso_size_segsz =
5367 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5368 cmd_segsz, "segsz");
5369 cmdline_parse_token_num_t cmd_gso_size_size =
5370 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5371 cmd_size, RTE_UINT16);
5373 cmdline_parse_inst_t cmd_gso_size = {
5374 .f = cmd_gso_size_parsed,
5376 .help_str = "set gso segsz <length>",
5378 (void *)&cmd_gso_size_set,
5379 (void *)&cmd_gso_size_keyword,
5380 (void *)&cmd_gso_size_segsz,
5381 (void *)&cmd_gso_size_size,
5386 /* *** SHOW GSO CONFIGURATION *** */
5387 struct cmd_gso_show_result {
5388 cmdline_fixed_string_t cmd_show;
5389 cmdline_fixed_string_t cmd_port;
5390 cmdline_fixed_string_t cmd_keyword;
5395 cmd_gso_show_parsed(void *parsed_result,
5396 __rte_unused struct cmdline *cl,
5397 __rte_unused void *data)
5399 struct cmd_gso_show_result *res = parsed_result;
5401 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5402 printf("invalid port id %u\n", res->cmd_pid);
5405 if (!strcmp(res->cmd_keyword, "gso")) {
5406 if (gso_ports[res->cmd_pid].enable) {
5407 printf("Max GSO'd packet size: %uB\n"
5408 "Supported GSO types: TCP/IPv4, "
5409 "UDP/IPv4, VxLAN with inner "
5410 "TCP/IPv4 packet, GRE with inner "
5411 "TCP/IPv4 packet\n",
5412 gso_max_segment_size);
5414 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5418 cmdline_parse_token_string_t cmd_gso_show_show =
5419 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5421 cmdline_parse_token_string_t cmd_gso_show_port =
5422 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5424 cmdline_parse_token_string_t cmd_gso_show_keyword =
5425 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5426 cmd_keyword, "gso");
5427 cmdline_parse_token_num_t cmd_gso_show_pid =
5428 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5429 cmd_pid, RTE_UINT16);
5431 cmdline_parse_inst_t cmd_gso_show = {
5432 .f = cmd_gso_show_parsed,
5434 .help_str = "show port <port_id> gso",
5436 (void *)&cmd_gso_show_show,
5437 (void *)&cmd_gso_show_port,
5438 (void *)&cmd_gso_show_pid,
5439 (void *)&cmd_gso_show_keyword,
5444 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5445 struct cmd_set_flush_rx {
5446 cmdline_fixed_string_t set;
5447 cmdline_fixed_string_t flush_rx;
5448 cmdline_fixed_string_t mode;
5452 cmd_set_flush_rx_parsed(void *parsed_result,
5453 __rte_unused struct cmdline *cl,
5454 __rte_unused void *data)
5456 struct cmd_set_flush_rx *res = parsed_result;
5457 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5460 cmdline_parse_token_string_t cmd_setflushrx_set =
5461 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5463 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5464 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5465 flush_rx, "flush_rx");
5466 cmdline_parse_token_string_t cmd_setflushrx_mode =
5467 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5471 cmdline_parse_inst_t cmd_set_flush_rx = {
5472 .f = cmd_set_flush_rx_parsed,
5473 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5476 (void *)&cmd_setflushrx_set,
5477 (void *)&cmd_setflushrx_flush_rx,
5478 (void *)&cmd_setflushrx_mode,
5483 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5484 struct cmd_set_link_check {
5485 cmdline_fixed_string_t set;
5486 cmdline_fixed_string_t link_check;
5487 cmdline_fixed_string_t mode;
5491 cmd_set_link_check_parsed(void *parsed_result,
5492 __rte_unused struct cmdline *cl,
5493 __rte_unused void *data)
5495 struct cmd_set_link_check *res = parsed_result;
5496 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5499 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5500 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5502 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5503 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5504 link_check, "link_check");
5505 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5506 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5510 cmdline_parse_inst_t cmd_set_link_check = {
5511 .f = cmd_set_link_check_parsed,
5512 .help_str = "set link_check on|off: Enable/Disable link status check "
5513 "when starting/stopping a port",
5516 (void *)&cmd_setlinkcheck_set,
5517 (void *)&cmd_setlinkcheck_link_check,
5518 (void *)&cmd_setlinkcheck_mode,
5523 /* *** SET NIC BYPASS MODE *** */
5524 struct cmd_set_bypass_mode_result {
5525 cmdline_fixed_string_t set;
5526 cmdline_fixed_string_t bypass;
5527 cmdline_fixed_string_t mode;
5528 cmdline_fixed_string_t value;
5533 cmd_set_bypass_mode_parsed(void *parsed_result,
5534 __rte_unused struct cmdline *cl,
5535 __rte_unused void *data)
5537 struct cmd_set_bypass_mode_result *res = parsed_result;
5538 portid_t port_id = res->port_id;
5539 int32_t rc = -EINVAL;
5541 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5542 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5544 if (!strcmp(res->value, "bypass"))
5545 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5546 else if (!strcmp(res->value, "isolate"))
5547 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5549 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5551 /* Set the bypass mode for the relevant port. */
5552 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5555 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5558 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5559 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5561 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5562 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5564 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5565 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5567 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5568 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5569 value, "normal#bypass#isolate");
5570 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5571 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5572 port_id, RTE_UINT16);
5574 cmdline_parse_inst_t cmd_set_bypass_mode = {
5575 .f = cmd_set_bypass_mode_parsed,
5576 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5577 "Set the NIC bypass mode for port_id",
5580 (void *)&cmd_setbypass_mode_set,
5581 (void *)&cmd_setbypass_mode_bypass,
5582 (void *)&cmd_setbypass_mode_mode,
5583 (void *)&cmd_setbypass_mode_value,
5584 (void *)&cmd_setbypass_mode_port,
5589 /* *** SET NIC BYPASS EVENT *** */
5590 struct cmd_set_bypass_event_result {
5591 cmdline_fixed_string_t set;
5592 cmdline_fixed_string_t bypass;
5593 cmdline_fixed_string_t event;
5594 cmdline_fixed_string_t event_value;
5595 cmdline_fixed_string_t mode;
5596 cmdline_fixed_string_t mode_value;
5601 cmd_set_bypass_event_parsed(void *parsed_result,
5602 __rte_unused struct cmdline *cl,
5603 __rte_unused void *data)
5605 int32_t rc = -EINVAL;
5606 struct cmd_set_bypass_event_result *res = parsed_result;
5607 portid_t port_id = res->port_id;
5609 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5610 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5611 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5613 if (!strcmp(res->event_value, "timeout"))
5614 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5615 else if (!strcmp(res->event_value, "os_on"))
5616 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5617 else if (!strcmp(res->event_value, "os_off"))
5618 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5619 else if (!strcmp(res->event_value, "power_on"))
5620 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5621 else if (!strcmp(res->event_value, "power_off"))
5622 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5624 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5626 if (!strcmp(res->mode_value, "bypass"))
5627 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5628 else if (!strcmp(res->mode_value, "isolate"))
5629 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5631 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5633 /* Set the watchdog timeout. */
5634 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5637 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5638 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5642 printf("Failed to set timeout value %u "
5643 "for port %d, errto code: %d.\n",
5644 bypass_timeout, port_id, rc);
5648 /* Set the bypass event to transition to bypass mode. */
5649 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5654 printf("\t Failed to set bypass event for port = %d.\n",
5658 cmdline_parse_token_string_t cmd_setbypass_event_set =
5659 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5661 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5662 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5664 cmdline_parse_token_string_t cmd_setbypass_event_event =
5665 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5667 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5668 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5669 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5670 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5671 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5673 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5675 mode_value, "normal#bypass#isolate");
5676 cmdline_parse_token_num_t cmd_setbypass_event_port =
5677 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5678 port_id, RTE_UINT16);
5680 cmdline_parse_inst_t cmd_set_bypass_event = {
5681 .f = cmd_set_bypass_event_parsed,
5682 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5683 "power_off mode normal|bypass|isolate <port_id>: "
5684 "Set the NIC bypass event mode for port_id",
5687 (void *)&cmd_setbypass_event_set,
5688 (void *)&cmd_setbypass_event_bypass,
5689 (void *)&cmd_setbypass_event_event,
5690 (void *)&cmd_setbypass_event_event_value,
5691 (void *)&cmd_setbypass_event_mode,
5692 (void *)&cmd_setbypass_event_mode_value,
5693 (void *)&cmd_setbypass_event_port,
5699 /* *** SET NIC BYPASS TIMEOUT *** */
5700 struct cmd_set_bypass_timeout_result {
5701 cmdline_fixed_string_t set;
5702 cmdline_fixed_string_t bypass;
5703 cmdline_fixed_string_t timeout;
5704 cmdline_fixed_string_t value;
5708 cmd_set_bypass_timeout_parsed(void *parsed_result,
5709 __rte_unused struct cmdline *cl,
5710 __rte_unused void *data)
5712 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5714 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5715 if (!strcmp(res->value, "1.5"))
5716 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5717 else if (!strcmp(res->value, "2"))
5718 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5719 else if (!strcmp(res->value, "3"))
5720 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5721 else if (!strcmp(res->value, "4"))
5722 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5723 else if (!strcmp(res->value, "8"))
5724 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5725 else if (!strcmp(res->value, "16"))
5726 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5727 else if (!strcmp(res->value, "32"))
5728 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5730 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5734 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5735 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5737 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5738 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5740 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5741 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5742 timeout, "timeout");
5743 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5744 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5745 value, "0#1.5#2#3#4#8#16#32");
5747 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5748 .f = cmd_set_bypass_timeout_parsed,
5749 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5750 "Set the NIC bypass watchdog timeout in seconds",
5753 (void *)&cmd_setbypass_timeout_set,
5754 (void *)&cmd_setbypass_timeout_bypass,
5755 (void *)&cmd_setbypass_timeout_timeout,
5756 (void *)&cmd_setbypass_timeout_value,
5761 /* *** SHOW NIC BYPASS MODE *** */
5762 struct cmd_show_bypass_config_result {
5763 cmdline_fixed_string_t show;
5764 cmdline_fixed_string_t bypass;
5765 cmdline_fixed_string_t config;
5770 cmd_show_bypass_config_parsed(void *parsed_result,
5771 __rte_unused struct cmdline *cl,
5772 __rte_unused void *data)
5774 struct cmd_show_bypass_config_result *res = parsed_result;
5775 portid_t port_id = res->port_id;
5777 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5778 uint32_t event_mode;
5779 uint32_t bypass_mode;
5780 uint32_t timeout = bypass_timeout;
5783 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5784 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5785 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5786 {"UNKNOWN", "normal", "bypass", "isolate"};
5787 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5795 /* Display the bypass mode.*/
5796 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5797 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5801 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5802 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5804 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5807 /* Display the bypass timeout.*/
5808 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5809 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5811 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5813 /* Display the bypass events and associated modes. */
5814 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5816 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5817 printf("\tFailed to get bypass mode for event = %s\n",
5820 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5821 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5823 printf("\tbypass event: %-16s = %s\n", events[i],
5829 printf("\tFailed to get bypass configuration for port = %d\n",
5833 cmdline_parse_token_string_t cmd_showbypass_config_show =
5834 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5836 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5837 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5839 cmdline_parse_token_string_t cmd_showbypass_config_config =
5840 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5842 cmdline_parse_token_num_t cmd_showbypass_config_port =
5843 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5844 port_id, RTE_UINT16);
5846 cmdline_parse_inst_t cmd_show_bypass_config = {
5847 .f = cmd_show_bypass_config_parsed,
5848 .help_str = "show bypass config <port_id>: "
5849 "Show the NIC bypass config for port_id",
5852 (void *)&cmd_showbypass_config_show,
5853 (void *)&cmd_showbypass_config_bypass,
5854 (void *)&cmd_showbypass_config_config,
5855 (void *)&cmd_showbypass_config_port,
5861 /* *** SET BONDING MODE *** */
5862 struct cmd_set_bonding_mode_result {
5863 cmdline_fixed_string_t set;
5864 cmdline_fixed_string_t bonding;
5865 cmdline_fixed_string_t mode;
5870 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5871 __rte_unused struct cmdline *cl,
5872 __rte_unused void *data)
5874 struct cmd_set_bonding_mode_result *res = parsed_result;
5875 portid_t port_id = res->port_id;
5877 /* Set the bonding mode for the relevant port. */
5878 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5879 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5882 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5883 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5885 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5886 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5887 bonding, "bonding");
5888 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5889 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5891 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5892 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5894 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5895 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5896 port_id, RTE_UINT16);
5898 cmdline_parse_inst_t cmd_set_bonding_mode = {
5899 .f = cmd_set_bonding_mode_parsed,
5900 .help_str = "set bonding mode <mode_value> <port_id>: "
5901 "Set the bonding mode for port_id",
5904 (void *) &cmd_setbonding_mode_set,
5905 (void *) &cmd_setbonding_mode_bonding,
5906 (void *) &cmd_setbonding_mode_mode,
5907 (void *) &cmd_setbonding_mode_value,
5908 (void *) &cmd_setbonding_mode_port,
5913 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5914 struct cmd_set_bonding_lacp_dedicated_queues_result {
5915 cmdline_fixed_string_t set;
5916 cmdline_fixed_string_t bonding;
5917 cmdline_fixed_string_t lacp;
5918 cmdline_fixed_string_t dedicated_queues;
5920 cmdline_fixed_string_t mode;
5923 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5924 __rte_unused struct cmdline *cl,
5925 __rte_unused void *data)
5927 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5928 portid_t port_id = res->port_id;
5929 struct rte_port *port;
5931 port = &ports[port_id];
5933 /** Check if the port is not started **/
5934 if (port->port_status != RTE_PORT_STOPPED) {
5935 printf("Please stop port %d first\n", port_id);
5939 if (!strcmp(res->mode, "enable")) {
5940 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5941 printf("Dedicate queues for LACP control packets"
5944 printf("Enabling dedicate queues for LACP control "
5945 "packets on port %d failed\n", port_id);
5946 } else if (!strcmp(res->mode, "disable")) {
5947 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5948 printf("Dedicated queues for LACP control packets "
5951 printf("Disabling dedicated queues for LACP control "
5952 "traffic on port %d failed\n", port_id);
5956 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5957 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5959 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5960 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5961 bonding, "bonding");
5962 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5963 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5965 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5966 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5967 dedicated_queues, "dedicated_queues");
5968 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5969 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5970 port_id, RTE_UINT16);
5971 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5972 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5973 mode, "enable#disable");
5975 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5976 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5977 .help_str = "set bonding lacp dedicated_queues <port_id> "
5979 "Enable/disable dedicated queues for LACP control traffic for port_id",
5982 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5983 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5984 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5985 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5986 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5987 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5992 /* *** SET BALANCE XMIT POLICY *** */
5993 struct cmd_set_bonding_balance_xmit_policy_result {
5994 cmdline_fixed_string_t set;
5995 cmdline_fixed_string_t bonding;
5996 cmdline_fixed_string_t balance_xmit_policy;
5998 cmdline_fixed_string_t policy;
6001 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6002 __rte_unused struct cmdline *cl,
6003 __rte_unused void *data)
6005 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6006 portid_t port_id = res->port_id;
6009 if (!strcmp(res->policy, "l2")) {
6010 policy = BALANCE_XMIT_POLICY_LAYER2;
6011 } else if (!strcmp(res->policy, "l23")) {
6012 policy = BALANCE_XMIT_POLICY_LAYER23;
6013 } else if (!strcmp(res->policy, "l34")) {
6014 policy = BALANCE_XMIT_POLICY_LAYER34;
6016 printf("\t Invalid xmit policy selection");
6020 /* Set the bonding mode for the relevant port. */
6021 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6022 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6027 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6028 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6030 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6031 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6032 bonding, "bonding");
6033 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6034 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6035 balance_xmit_policy, "balance_xmit_policy");
6036 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6037 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6038 port_id, RTE_UINT16);
6039 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6040 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6041 policy, "l2#l23#l34");
6043 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6044 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6045 .help_str = "set bonding balance_xmit_policy <port_id> "
6047 "Set the bonding balance_xmit_policy for port_id",
6050 (void *)&cmd_setbonding_balance_xmit_policy_set,
6051 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6052 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6053 (void *)&cmd_setbonding_balance_xmit_policy_port,
6054 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6059 /* *** SHOW NIC BONDING CONFIGURATION *** */
6060 struct cmd_show_bonding_config_result {
6061 cmdline_fixed_string_t show;
6062 cmdline_fixed_string_t bonding;
6063 cmdline_fixed_string_t config;
6067 static void cmd_show_bonding_config_parsed(void *parsed_result,
6068 __rte_unused struct cmdline *cl,
6069 __rte_unused void *data)
6071 struct cmd_show_bonding_config_result *res = parsed_result;
6072 int bonding_mode, agg_mode;
6073 portid_t slaves[RTE_MAX_ETHPORTS];
6074 int num_slaves, num_active_slaves;
6077 portid_t port_id = res->port_id;
6079 /* Display the bonding mode.*/
6080 bonding_mode = rte_eth_bond_mode_get(port_id);
6081 if (bonding_mode < 0) {
6082 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6085 printf("\tBonding mode: %d\n", bonding_mode);
6087 if (bonding_mode == BONDING_MODE_BALANCE) {
6088 int balance_xmit_policy;
6090 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6091 if (balance_xmit_policy < 0) {
6092 printf("\tFailed to get balance xmit policy for port = %d\n",
6096 printf("\tBalance Xmit Policy: ");
6098 switch (balance_xmit_policy) {
6099 case BALANCE_XMIT_POLICY_LAYER2:
6100 printf("BALANCE_XMIT_POLICY_LAYER2");
6102 case BALANCE_XMIT_POLICY_LAYER23:
6103 printf("BALANCE_XMIT_POLICY_LAYER23");
6105 case BALANCE_XMIT_POLICY_LAYER34:
6106 printf("BALANCE_XMIT_POLICY_LAYER34");
6113 if (bonding_mode == BONDING_MODE_8023AD) {
6114 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6115 printf("\tIEEE802.3AD Aggregator Mode: ");
6118 printf("bandwidth");
6130 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6132 if (num_slaves < 0) {
6133 printf("\tFailed to get slave list for port = %d\n", port_id);
6136 if (num_slaves > 0) {
6137 printf("\tSlaves (%d): [", num_slaves);
6138 for (i = 0; i < num_slaves - 1; i++)
6139 printf("%d ", slaves[i]);
6141 printf("%d]\n", slaves[num_slaves - 1]);
6143 printf("\tSlaves: []\n");
6147 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6150 if (num_active_slaves < 0) {
6151 printf("\tFailed to get active slave list for port = %d\n", port_id);
6154 if (num_active_slaves > 0) {
6155 printf("\tActive Slaves (%d): [", num_active_slaves);
6156 for (i = 0; i < num_active_slaves - 1; i++)
6157 printf("%d ", slaves[i]);
6159 printf("%d]\n", slaves[num_active_slaves - 1]);
6162 printf("\tActive Slaves: []\n");
6166 primary_id = rte_eth_bond_primary_get(port_id);
6167 if (primary_id < 0) {
6168 printf("\tFailed to get primary slave for port = %d\n", port_id);
6171 printf("\tPrimary: [%d]\n", primary_id);
6175 cmdline_parse_token_string_t cmd_showbonding_config_show =
6176 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6178 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6179 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6180 bonding, "bonding");
6181 cmdline_parse_token_string_t cmd_showbonding_config_config =
6182 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6184 cmdline_parse_token_num_t cmd_showbonding_config_port =
6185 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6186 port_id, RTE_UINT16);
6188 cmdline_parse_inst_t cmd_show_bonding_config = {
6189 .f = cmd_show_bonding_config_parsed,
6190 .help_str = "show bonding config <port_id>: "
6191 "Show the bonding config for port_id",
6194 (void *)&cmd_showbonding_config_show,
6195 (void *)&cmd_showbonding_config_bonding,
6196 (void *)&cmd_showbonding_config_config,
6197 (void *)&cmd_showbonding_config_port,
6202 /* *** SET BONDING PRIMARY *** */
6203 struct cmd_set_bonding_primary_result {
6204 cmdline_fixed_string_t set;
6205 cmdline_fixed_string_t bonding;
6206 cmdline_fixed_string_t primary;
6211 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6212 __rte_unused struct cmdline *cl,
6213 __rte_unused void *data)
6215 struct cmd_set_bonding_primary_result *res = parsed_result;
6216 portid_t master_port_id = res->port_id;
6217 portid_t slave_port_id = res->slave_id;
6219 /* Set the primary slave for a bonded device. */
6220 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6221 printf("\t Failed to set primary slave for port = %d.\n",
6228 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6231 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6232 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6233 bonding, "bonding");
6234 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6235 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6236 primary, "primary");
6237 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6238 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6239 slave_id, RTE_UINT16);
6240 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6241 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6242 port_id, RTE_UINT16);
6244 cmdline_parse_inst_t cmd_set_bonding_primary = {
6245 .f = cmd_set_bonding_primary_parsed,
6246 .help_str = "set bonding primary <slave_id> <port_id>: "
6247 "Set the primary slave for port_id",
6250 (void *)&cmd_setbonding_primary_set,
6251 (void *)&cmd_setbonding_primary_bonding,
6252 (void *)&cmd_setbonding_primary_primary,
6253 (void *)&cmd_setbonding_primary_slave,
6254 (void *)&cmd_setbonding_primary_port,
6259 /* *** ADD SLAVE *** */
6260 struct cmd_add_bonding_slave_result {
6261 cmdline_fixed_string_t add;
6262 cmdline_fixed_string_t bonding;
6263 cmdline_fixed_string_t slave;
6268 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6269 __rte_unused struct cmdline *cl,
6270 __rte_unused void *data)
6272 struct cmd_add_bonding_slave_result *res = parsed_result;
6273 portid_t master_port_id = res->port_id;
6274 portid_t slave_port_id = res->slave_id;
6276 /* add the slave for a bonded device. */
6277 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6278 printf("\t Failed to add slave %d to master port = %d.\n",
6279 slave_port_id, master_port_id);
6283 set_port_slave_flag(slave_port_id);
6286 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6287 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6289 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6290 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6291 bonding, "bonding");
6292 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6293 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6295 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6296 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6297 slave_id, RTE_UINT16);
6298 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6299 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6300 port_id, RTE_UINT16);
6302 cmdline_parse_inst_t cmd_add_bonding_slave = {
6303 .f = cmd_add_bonding_slave_parsed,
6304 .help_str = "add bonding slave <slave_id> <port_id>: "
6305 "Add a slave device to a bonded device",
6308 (void *)&cmd_addbonding_slave_add,
6309 (void *)&cmd_addbonding_slave_bonding,
6310 (void *)&cmd_addbonding_slave_slave,
6311 (void *)&cmd_addbonding_slave_slaveid,
6312 (void *)&cmd_addbonding_slave_port,
6317 /* *** REMOVE SLAVE *** */
6318 struct cmd_remove_bonding_slave_result {
6319 cmdline_fixed_string_t remove;
6320 cmdline_fixed_string_t bonding;
6321 cmdline_fixed_string_t slave;
6326 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6327 __rte_unused struct cmdline *cl,
6328 __rte_unused void *data)
6330 struct cmd_remove_bonding_slave_result *res = parsed_result;
6331 portid_t master_port_id = res->port_id;
6332 portid_t slave_port_id = res->slave_id;
6334 /* remove the slave from a bonded device. */
6335 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6336 printf("\t Failed to remove slave %d from master port = %d.\n",
6337 slave_port_id, master_port_id);
6341 clear_port_slave_flag(slave_port_id);
6344 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6345 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6347 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6348 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6349 bonding, "bonding");
6350 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6351 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6353 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6354 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6355 slave_id, RTE_UINT16);
6356 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6357 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6358 port_id, RTE_UINT16);
6360 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6361 .f = cmd_remove_bonding_slave_parsed,
6362 .help_str = "remove bonding slave <slave_id> <port_id>: "
6363 "Remove a slave device from a bonded device",
6366 (void *)&cmd_removebonding_slave_remove,
6367 (void *)&cmd_removebonding_slave_bonding,
6368 (void *)&cmd_removebonding_slave_slave,
6369 (void *)&cmd_removebonding_slave_slaveid,
6370 (void *)&cmd_removebonding_slave_port,
6375 /* *** CREATE BONDED DEVICE *** */
6376 struct cmd_create_bonded_device_result {
6377 cmdline_fixed_string_t create;
6378 cmdline_fixed_string_t bonded;
6379 cmdline_fixed_string_t device;
6384 static int bond_dev_num = 0;
6386 static void cmd_create_bonded_device_parsed(void *parsed_result,
6387 __rte_unused struct cmdline *cl,
6388 __rte_unused void *data)
6390 struct cmd_create_bonded_device_result *res = parsed_result;
6391 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6395 if (test_done == 0) {
6396 printf("Please stop forwarding first\n");
6400 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6403 /* Create a new bonded device. */
6404 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6406 printf("\t Failed to create bonded device.\n");
6409 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6412 /* Update number of ports */
6413 nb_ports = rte_eth_dev_count_avail();
6414 reconfig(port_id, res->socket);
6415 ret = rte_eth_promiscuous_enable(port_id);
6417 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6418 port_id, rte_strerror(-ret));
6420 ports[port_id].need_setup = 0;
6421 ports[port_id].port_status = RTE_PORT_STOPPED;
6426 cmdline_parse_token_string_t cmd_createbonded_device_create =
6427 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6429 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6430 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6432 cmdline_parse_token_string_t cmd_createbonded_device_device =
6433 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6435 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6436 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6438 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6439 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6442 cmdline_parse_inst_t cmd_create_bonded_device = {
6443 .f = cmd_create_bonded_device_parsed,
6444 .help_str = "create bonded device <mode> <socket>: "
6445 "Create a new bonded device with specific bonding mode and socket",
6448 (void *)&cmd_createbonded_device_create,
6449 (void *)&cmd_createbonded_device_bonded,
6450 (void *)&cmd_createbonded_device_device,
6451 (void *)&cmd_createbonded_device_mode,
6452 (void *)&cmd_createbonded_device_socket,
6457 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6458 struct cmd_set_bond_mac_addr_result {
6459 cmdline_fixed_string_t set;
6460 cmdline_fixed_string_t bonding;
6461 cmdline_fixed_string_t mac_addr;
6463 struct rte_ether_addr address;
6466 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6467 __rte_unused struct cmdline *cl,
6468 __rte_unused void *data)
6470 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6473 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6476 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6478 /* check the return value and print it if is < 0 */
6480 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6483 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6485 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6486 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6488 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6491 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6492 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6493 port_num, RTE_UINT16);
6494 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6495 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6497 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6498 .f = cmd_set_bond_mac_addr_parsed,
6500 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6502 (void *)&cmd_set_bond_mac_addr_set,
6503 (void *)&cmd_set_bond_mac_addr_bonding,
6504 (void *)&cmd_set_bond_mac_addr_mac,
6505 (void *)&cmd_set_bond_mac_addr_portnum,
6506 (void *)&cmd_set_bond_mac_addr_addr,
6512 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6513 struct cmd_set_bond_mon_period_result {
6514 cmdline_fixed_string_t set;
6515 cmdline_fixed_string_t bonding;
6516 cmdline_fixed_string_t mon_period;
6521 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6522 __rte_unused struct cmdline *cl,
6523 __rte_unused void *data)
6525 struct cmd_set_bond_mon_period_result *res = parsed_result;
6528 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6530 /* check the return value and print it if is < 0 */
6532 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6535 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6536 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6538 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6539 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6540 bonding, "bonding");
6541 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6542 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6543 mon_period, "mon_period");
6544 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6545 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6546 port_num, RTE_UINT16);
6547 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6548 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6549 period_ms, RTE_UINT32);
6551 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6552 .f = cmd_set_bond_mon_period_parsed,
6554 .help_str = "set bonding mon_period <port_id> <period_ms>",
6556 (void *)&cmd_set_bond_mon_period_set,
6557 (void *)&cmd_set_bond_mon_period_bonding,
6558 (void *)&cmd_set_bond_mon_period_mon_period,
6559 (void *)&cmd_set_bond_mon_period_portnum,
6560 (void *)&cmd_set_bond_mon_period_period_ms,
6567 struct cmd_set_bonding_agg_mode_policy_result {
6568 cmdline_fixed_string_t set;
6569 cmdline_fixed_string_t bonding;
6570 cmdline_fixed_string_t agg_mode;
6572 cmdline_fixed_string_t policy;
6577 cmd_set_bonding_agg_mode(void *parsed_result,
6578 __rte_unused struct cmdline *cl,
6579 __rte_unused void *data)
6581 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6582 uint8_t policy = AGG_BANDWIDTH;
6584 if (!strcmp(res->policy, "bandwidth"))
6585 policy = AGG_BANDWIDTH;
6586 else if (!strcmp(res->policy, "stable"))
6587 policy = AGG_STABLE;
6588 else if (!strcmp(res->policy, "count"))
6591 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6595 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6596 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6598 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6599 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6600 bonding, "bonding");
6602 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6603 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6604 agg_mode, "agg_mode");
6606 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6607 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6608 port_num, RTE_UINT16);
6610 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6611 TOKEN_STRING_INITIALIZER(
6612 struct cmd_set_bonding_balance_xmit_policy_result,
6613 policy, "stable#bandwidth#count");
6615 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6616 .f = cmd_set_bonding_agg_mode,
6618 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6620 (void *)&cmd_set_bonding_agg_mode_set,
6621 (void *)&cmd_set_bonding_agg_mode_bonding,
6622 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6623 (void *)&cmd_set_bonding_agg_mode_portnum,
6624 (void *)&cmd_set_bonding_agg_mode_policy_string,
6630 #endif /* RTE_NET_BOND */
6632 /* *** SET FORWARDING MODE *** */
6633 struct cmd_set_fwd_mode_result {
6634 cmdline_fixed_string_t set;
6635 cmdline_fixed_string_t fwd;
6636 cmdline_fixed_string_t mode;
6639 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6640 __rte_unused struct cmdline *cl,
6641 __rte_unused void *data)
6643 struct cmd_set_fwd_mode_result *res = parsed_result;
6646 set_pkt_forwarding_mode(res->mode);
6649 cmdline_parse_token_string_t cmd_setfwd_set =
6650 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6651 cmdline_parse_token_string_t cmd_setfwd_fwd =
6652 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6653 cmdline_parse_token_string_t cmd_setfwd_mode =
6654 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6655 "" /* defined at init */);
6657 cmdline_parse_inst_t cmd_set_fwd_mode = {
6658 .f = cmd_set_fwd_mode_parsed,
6660 .help_str = NULL, /* defined at init */
6662 (void *)&cmd_setfwd_set,
6663 (void *)&cmd_setfwd_fwd,
6664 (void *)&cmd_setfwd_mode,
6669 static void cmd_set_fwd_mode_init(void)
6672 static char token[128];
6673 static char help[256];
6674 cmdline_parse_token_string_t *token_struct;
6676 modes = list_pkt_forwarding_modes();
6677 snprintf(help, sizeof(help), "set fwd %s: "
6678 "Set packet forwarding mode", modes);
6679 cmd_set_fwd_mode.help_str = help;
6681 /* string token separator is # */
6682 for (c = token; *modes != '\0'; modes++)
6687 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6688 token_struct->string_data.str = token;
6691 /* *** SET RETRY FORWARDING MODE *** */
6692 struct cmd_set_fwd_retry_mode_result {
6693 cmdline_fixed_string_t set;
6694 cmdline_fixed_string_t fwd;
6695 cmdline_fixed_string_t mode;
6696 cmdline_fixed_string_t retry;
6699 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6700 __rte_unused struct cmdline *cl,
6701 __rte_unused void *data)
6703 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6706 set_pkt_forwarding_mode(res->mode);
6709 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6710 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6712 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6713 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6715 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6716 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6718 "" /* defined at init */);
6719 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6720 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6723 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6724 .f = cmd_set_fwd_retry_mode_parsed,
6726 .help_str = NULL, /* defined at init */
6728 (void *)&cmd_setfwd_retry_set,
6729 (void *)&cmd_setfwd_retry_fwd,
6730 (void *)&cmd_setfwd_retry_mode,
6731 (void *)&cmd_setfwd_retry_retry,
6736 static void cmd_set_fwd_retry_mode_init(void)
6739 static char token[128];
6740 static char help[256];
6741 cmdline_parse_token_string_t *token_struct;
6743 modes = list_pkt_forwarding_retry_modes();
6744 snprintf(help, sizeof(help), "set fwd %s retry: "
6745 "Set packet forwarding mode with retry", modes);
6746 cmd_set_fwd_retry_mode.help_str = help;
6748 /* string token separator is # */
6749 for (c = token; *modes != '\0'; modes++)
6754 token_struct = (cmdline_parse_token_string_t *)
6755 cmd_set_fwd_retry_mode.tokens[2];
6756 token_struct->string_data.str = token;
6759 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6760 struct cmd_set_burst_tx_retry_result {
6761 cmdline_fixed_string_t set;
6762 cmdline_fixed_string_t burst;
6763 cmdline_fixed_string_t tx;
6764 cmdline_fixed_string_t delay;
6766 cmdline_fixed_string_t retry;
6770 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6771 __rte_unused struct cmdline *cl,
6772 __rte_unused void *data)
6774 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6776 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6777 && !strcmp(res->tx, "tx")) {
6778 if (!strcmp(res->delay, "delay"))
6779 burst_tx_delay_time = res->time;
6780 if (!strcmp(res->retry, "retry"))
6781 burst_tx_retry_num = res->retry_num;
6786 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6787 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6788 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6789 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6791 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6792 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6793 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6794 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6795 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6796 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6798 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6799 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6800 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6801 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6804 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6805 .f = cmd_set_burst_tx_retry_parsed,
6806 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6808 (void *)&cmd_set_burst_tx_retry_set,
6809 (void *)&cmd_set_burst_tx_retry_burst,
6810 (void *)&cmd_set_burst_tx_retry_tx,
6811 (void *)&cmd_set_burst_tx_retry_delay,
6812 (void *)&cmd_set_burst_tx_retry_time,
6813 (void *)&cmd_set_burst_tx_retry_retry,
6814 (void *)&cmd_set_burst_tx_retry_retry_num,
6819 /* *** SET PROMISC MODE *** */
6820 struct cmd_set_promisc_mode_result {
6821 cmdline_fixed_string_t set;
6822 cmdline_fixed_string_t promisc;
6823 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6824 uint16_t port_num; /* valid if "allports" argument == 0 */
6825 cmdline_fixed_string_t mode;
6828 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6829 __rte_unused struct cmdline *cl,
6832 struct cmd_set_promisc_mode_result *res = parsed_result;
6836 if (!strcmp(res->mode, "on"))
6843 RTE_ETH_FOREACH_DEV(i)
6844 eth_set_promisc_mode(i, enable);
6846 eth_set_promisc_mode(res->port_num, enable);
6850 cmdline_parse_token_string_t cmd_setpromisc_set =
6851 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6852 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6853 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6855 cmdline_parse_token_string_t cmd_setpromisc_portall =
6856 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6858 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6859 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6861 cmdline_parse_token_string_t cmd_setpromisc_mode =
6862 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6865 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6866 .f = cmd_set_promisc_mode_parsed,
6868 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6870 (void *)&cmd_setpromisc_set,
6871 (void *)&cmd_setpromisc_promisc,
6872 (void *)&cmd_setpromisc_portall,
6873 (void *)&cmd_setpromisc_mode,
6878 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6879 .f = cmd_set_promisc_mode_parsed,
6881 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6883 (void *)&cmd_setpromisc_set,
6884 (void *)&cmd_setpromisc_promisc,
6885 (void *)&cmd_setpromisc_portnum,
6886 (void *)&cmd_setpromisc_mode,
6891 /* *** SET ALLMULTI MODE *** */
6892 struct cmd_set_allmulti_mode_result {
6893 cmdline_fixed_string_t set;
6894 cmdline_fixed_string_t allmulti;
6895 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6896 uint16_t port_num; /* valid if "allports" argument == 0 */
6897 cmdline_fixed_string_t mode;
6900 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6901 __rte_unused struct cmdline *cl,
6904 struct cmd_set_allmulti_mode_result *res = parsed_result;
6908 if (!strcmp(res->mode, "on"))
6915 RTE_ETH_FOREACH_DEV(i) {
6916 eth_set_allmulticast_mode(i, enable);
6920 eth_set_allmulticast_mode(res->port_num, enable);
6924 cmdline_parse_token_string_t cmd_setallmulti_set =
6925 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6926 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6927 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6929 cmdline_parse_token_string_t cmd_setallmulti_portall =
6930 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6932 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6933 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6935 cmdline_parse_token_string_t cmd_setallmulti_mode =
6936 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6939 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6940 .f = cmd_set_allmulti_mode_parsed,
6942 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6944 (void *)&cmd_setallmulti_set,
6945 (void *)&cmd_setallmulti_allmulti,
6946 (void *)&cmd_setallmulti_portall,
6947 (void *)&cmd_setallmulti_mode,
6952 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6953 .f = cmd_set_allmulti_mode_parsed,
6955 .help_str = "set allmulti <port_id> on|off: "
6956 "Set allmulti mode on port_id",
6958 (void *)&cmd_setallmulti_set,
6959 (void *)&cmd_setallmulti_allmulti,
6960 (void *)&cmd_setallmulti_portnum,
6961 (void *)&cmd_setallmulti_mode,
6966 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6967 struct cmd_link_flow_ctrl_show {
6968 cmdline_fixed_string_t show;
6969 cmdline_fixed_string_t port;
6971 cmdline_fixed_string_t flow_ctrl;
6974 cmdline_parse_token_string_t cmd_lfc_show_show =
6975 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6977 cmdline_parse_token_string_t cmd_lfc_show_port =
6978 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6980 cmdline_parse_token_num_t cmd_lfc_show_portid =
6981 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6982 port_id, RTE_UINT16);
6983 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6984 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6985 flow_ctrl, "flow_ctrl");
6988 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6989 __rte_unused struct cmdline *cl,
6990 __rte_unused void *data)
6992 struct cmd_link_flow_ctrl_show *res = parsed_result;
6993 static const char *info_border = "*********************";
6994 struct rte_eth_fc_conf fc_conf;
6995 bool rx_fc_en = false;
6996 bool tx_fc_en = false;
6999 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7001 printf("Failed to get current flow ctrl information: err = %d\n",
7006 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7008 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7011 printf("\n%s Flow control infos for port %-2d %s\n",
7012 info_border, res->port_id, info_border);
7013 printf("FC mode:\n");
7014 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7015 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7016 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7017 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7018 printf("High waterline: 0x%x\n", fc_conf.high_water);
7019 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7020 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7021 printf("Forward MAC control frames: %s\n",
7022 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7023 printf("\n%s************** End ***********%s\n",
7024 info_border, info_border);
7027 cmdline_parse_inst_t cmd_link_flow_control_show = {
7028 .f = cmd_link_flow_ctrl_show_parsed,
7030 .help_str = "show port <port_id> flow_ctrl",
7032 (void *)&cmd_lfc_show_show,
7033 (void *)&cmd_lfc_show_port,
7034 (void *)&cmd_lfc_show_portid,
7035 (void *)&cmd_lfc_show_flow_ctrl,
7040 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7041 struct cmd_link_flow_ctrl_set_result {
7042 cmdline_fixed_string_t set;
7043 cmdline_fixed_string_t flow_ctrl;
7044 cmdline_fixed_string_t rx;
7045 cmdline_fixed_string_t rx_lfc_mode;
7046 cmdline_fixed_string_t tx;
7047 cmdline_fixed_string_t tx_lfc_mode;
7048 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7049 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7050 cmdline_fixed_string_t autoneg_str;
7051 cmdline_fixed_string_t autoneg;
7052 cmdline_fixed_string_t hw_str;
7053 uint32_t high_water;
7054 cmdline_fixed_string_t lw_str;
7056 cmdline_fixed_string_t pt_str;
7057 uint16_t pause_time;
7058 cmdline_fixed_string_t xon_str;
7063 cmdline_parse_token_string_t cmd_lfc_set_set =
7064 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7066 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7067 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7068 flow_ctrl, "flow_ctrl");
7069 cmdline_parse_token_string_t cmd_lfc_set_rx =
7070 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7072 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7073 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7074 rx_lfc_mode, "on#off");
7075 cmdline_parse_token_string_t cmd_lfc_set_tx =
7076 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7078 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7079 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7080 tx_lfc_mode, "on#off");
7081 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7082 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7083 hw_str, "high_water");
7084 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7085 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7086 high_water, RTE_UINT32);
7087 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7088 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7089 lw_str, "low_water");
7090 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7091 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7092 low_water, RTE_UINT32);
7093 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7094 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7095 pt_str, "pause_time");
7096 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7097 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7098 pause_time, RTE_UINT16);
7099 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7100 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7101 xon_str, "send_xon");
7102 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7103 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7104 send_xon, RTE_UINT16);
7105 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7106 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7107 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7108 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7109 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7110 mac_ctrl_frame_fwd_mode, "on#off");
7111 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7112 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7113 autoneg_str, "autoneg");
7114 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7115 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7117 cmdline_parse_token_num_t cmd_lfc_set_portid =
7118 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7119 port_id, RTE_UINT16);
7121 /* forward declaration */
7123 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7126 cmdline_parse_inst_t cmd_link_flow_control_set = {
7127 .f = cmd_link_flow_ctrl_set_parsed,
7129 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7130 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7131 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7133 (void *)&cmd_lfc_set_set,
7134 (void *)&cmd_lfc_set_flow_ctrl,
7135 (void *)&cmd_lfc_set_rx,
7136 (void *)&cmd_lfc_set_rx_mode,
7137 (void *)&cmd_lfc_set_tx,
7138 (void *)&cmd_lfc_set_tx_mode,
7139 (void *)&cmd_lfc_set_high_water,
7140 (void *)&cmd_lfc_set_low_water,
7141 (void *)&cmd_lfc_set_pause_time,
7142 (void *)&cmd_lfc_set_send_xon,
7143 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7144 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7145 (void *)&cmd_lfc_set_autoneg_str,
7146 (void *)&cmd_lfc_set_autoneg,
7147 (void *)&cmd_lfc_set_portid,
7152 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7153 .f = cmd_link_flow_ctrl_set_parsed,
7154 .data = (void *)&cmd_link_flow_control_set_rx,
7155 .help_str = "set flow_ctrl rx on|off <port_id>: "
7156 "Change rx flow control parameter",
7158 (void *)&cmd_lfc_set_set,
7159 (void *)&cmd_lfc_set_flow_ctrl,
7160 (void *)&cmd_lfc_set_rx,
7161 (void *)&cmd_lfc_set_rx_mode,
7162 (void *)&cmd_lfc_set_portid,
7167 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7168 .f = cmd_link_flow_ctrl_set_parsed,
7169 .data = (void *)&cmd_link_flow_control_set_tx,
7170 .help_str = "set flow_ctrl tx on|off <port_id>: "
7171 "Change tx flow control parameter",
7173 (void *)&cmd_lfc_set_set,
7174 (void *)&cmd_lfc_set_flow_ctrl,
7175 (void *)&cmd_lfc_set_tx,
7176 (void *)&cmd_lfc_set_tx_mode,
7177 (void *)&cmd_lfc_set_portid,
7182 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7183 .f = cmd_link_flow_ctrl_set_parsed,
7184 .data = (void *)&cmd_link_flow_control_set_hw,
7185 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7186 "Change high water flow control parameter",
7188 (void *)&cmd_lfc_set_set,
7189 (void *)&cmd_lfc_set_flow_ctrl,
7190 (void *)&cmd_lfc_set_high_water_str,
7191 (void *)&cmd_lfc_set_high_water,
7192 (void *)&cmd_lfc_set_portid,
7197 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7198 .f = cmd_link_flow_ctrl_set_parsed,
7199 .data = (void *)&cmd_link_flow_control_set_lw,
7200 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7201 "Change low water flow control parameter",
7203 (void *)&cmd_lfc_set_set,
7204 (void *)&cmd_lfc_set_flow_ctrl,
7205 (void *)&cmd_lfc_set_low_water_str,
7206 (void *)&cmd_lfc_set_low_water,
7207 (void *)&cmd_lfc_set_portid,
7212 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7213 .f = cmd_link_flow_ctrl_set_parsed,
7214 .data = (void *)&cmd_link_flow_control_set_pt,
7215 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7216 "Change pause time flow control parameter",
7218 (void *)&cmd_lfc_set_set,
7219 (void *)&cmd_lfc_set_flow_ctrl,
7220 (void *)&cmd_lfc_set_pause_time_str,
7221 (void *)&cmd_lfc_set_pause_time,
7222 (void *)&cmd_lfc_set_portid,
7227 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7228 .f = cmd_link_flow_ctrl_set_parsed,
7229 .data = (void *)&cmd_link_flow_control_set_xon,
7230 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7231 "Change send_xon flow control parameter",
7233 (void *)&cmd_lfc_set_set,
7234 (void *)&cmd_lfc_set_flow_ctrl,
7235 (void *)&cmd_lfc_set_send_xon_str,
7236 (void *)&cmd_lfc_set_send_xon,
7237 (void *)&cmd_lfc_set_portid,
7242 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7243 .f = cmd_link_flow_ctrl_set_parsed,
7244 .data = (void *)&cmd_link_flow_control_set_macfwd,
7245 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7246 "Change mac ctrl fwd flow control parameter",
7248 (void *)&cmd_lfc_set_set,
7249 (void *)&cmd_lfc_set_flow_ctrl,
7250 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7251 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7252 (void *)&cmd_lfc_set_portid,
7257 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7258 .f = cmd_link_flow_ctrl_set_parsed,
7259 .data = (void *)&cmd_link_flow_control_set_autoneg,
7260 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7261 "Change autoneg flow control parameter",
7263 (void *)&cmd_lfc_set_set,
7264 (void *)&cmd_lfc_set_flow_ctrl,
7265 (void *)&cmd_lfc_set_autoneg_str,
7266 (void *)&cmd_lfc_set_autoneg,
7267 (void *)&cmd_lfc_set_portid,
7273 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7274 __rte_unused struct cmdline *cl,
7277 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7278 cmdline_parse_inst_t *cmd = data;
7279 struct rte_eth_fc_conf fc_conf;
7285 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7286 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7287 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7288 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7290 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7291 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7294 /* Partial command line, retrieve current configuration */
7296 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7298 printf("cannot get current flow ctrl parameters, return"
7299 "code = %d\n", ret);
7303 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7304 (fc_conf.mode == RTE_FC_FULL))
7306 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7307 (fc_conf.mode == RTE_FC_FULL))
7311 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7312 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7314 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7315 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7317 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7319 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7320 fc_conf.high_water = res->high_water;
7322 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7323 fc_conf.low_water = res->low_water;
7325 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7326 fc_conf.pause_time = res->pause_time;
7328 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7329 fc_conf.send_xon = res->send_xon;
7331 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7332 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7333 fc_conf.mac_ctrl_frame_fwd = 1;
7335 fc_conf.mac_ctrl_frame_fwd = 0;
7338 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7339 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7341 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7343 printf("bad flow contrl parameter, return code = %d \n", ret);
7346 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7347 struct cmd_priority_flow_ctrl_set_result {
7348 cmdline_fixed_string_t set;
7349 cmdline_fixed_string_t pfc_ctrl;
7350 cmdline_fixed_string_t rx;
7351 cmdline_fixed_string_t rx_pfc_mode;
7352 cmdline_fixed_string_t tx;
7353 cmdline_fixed_string_t tx_pfc_mode;
7354 uint32_t high_water;
7356 uint16_t pause_time;
7362 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7363 __rte_unused struct cmdline *cl,
7364 __rte_unused void *data)
7366 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7367 struct rte_eth_pfc_conf pfc_conf;
7368 int rx_fc_enable, tx_fc_enable;
7372 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7373 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7374 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7375 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7377 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7378 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7381 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7382 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7383 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7384 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7385 pfc_conf.fc.high_water = res->high_water;
7386 pfc_conf.fc.low_water = res->low_water;
7387 pfc_conf.fc.pause_time = res->pause_time;
7388 pfc_conf.priority = res->priority;
7390 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7392 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7395 cmdline_parse_token_string_t cmd_pfc_set_set =
7396 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7398 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7399 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7400 pfc_ctrl, "pfc_ctrl");
7401 cmdline_parse_token_string_t cmd_pfc_set_rx =
7402 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7404 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7405 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7406 rx_pfc_mode, "on#off");
7407 cmdline_parse_token_string_t cmd_pfc_set_tx =
7408 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7410 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7411 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7412 tx_pfc_mode, "on#off");
7413 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7414 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7415 high_water, RTE_UINT32);
7416 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7417 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7418 low_water, RTE_UINT32);
7419 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7420 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7421 pause_time, RTE_UINT16);
7422 cmdline_parse_token_num_t cmd_pfc_set_priority =
7423 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7424 priority, RTE_UINT8);
7425 cmdline_parse_token_num_t cmd_pfc_set_portid =
7426 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7427 port_id, RTE_UINT16);
7429 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7430 .f = cmd_priority_flow_ctrl_set_parsed,
7432 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7433 "<pause_time> <priority> <port_id>: "
7434 "Configure the Ethernet priority flow control",
7436 (void *)&cmd_pfc_set_set,
7437 (void *)&cmd_pfc_set_flow_ctrl,
7438 (void *)&cmd_pfc_set_rx,
7439 (void *)&cmd_pfc_set_rx_mode,
7440 (void *)&cmd_pfc_set_tx,
7441 (void *)&cmd_pfc_set_tx_mode,
7442 (void *)&cmd_pfc_set_high_water,
7443 (void *)&cmd_pfc_set_low_water,
7444 (void *)&cmd_pfc_set_pause_time,
7445 (void *)&cmd_pfc_set_priority,
7446 (void *)&cmd_pfc_set_portid,
7451 /* *** RESET CONFIGURATION *** */
7452 struct cmd_reset_result {
7453 cmdline_fixed_string_t reset;
7454 cmdline_fixed_string_t def;
7457 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7459 __rte_unused void *data)
7461 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7462 set_def_fwd_config();
7465 cmdline_parse_token_string_t cmd_reset_set =
7466 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7467 cmdline_parse_token_string_t cmd_reset_def =
7468 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7471 cmdline_parse_inst_t cmd_reset = {
7472 .f = cmd_reset_parsed,
7474 .help_str = "set default: Reset default forwarding configuration",
7476 (void *)&cmd_reset_set,
7477 (void *)&cmd_reset_def,
7482 /* *** START FORWARDING *** */
7483 struct cmd_start_result {
7484 cmdline_fixed_string_t start;
7487 cmdline_parse_token_string_t cmd_start_start =
7488 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7490 static void cmd_start_parsed(__rte_unused void *parsed_result,
7491 __rte_unused struct cmdline *cl,
7492 __rte_unused void *data)
7494 start_packet_forwarding(0);
7497 cmdline_parse_inst_t cmd_start = {
7498 .f = cmd_start_parsed,
7500 .help_str = "start: Start packet forwarding",
7502 (void *)&cmd_start_start,
7507 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7508 struct cmd_start_tx_first_result {
7509 cmdline_fixed_string_t start;
7510 cmdline_fixed_string_t tx_first;
7514 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7515 __rte_unused struct cmdline *cl,
7516 __rte_unused void *data)
7518 start_packet_forwarding(1);
7521 cmdline_parse_token_string_t cmd_start_tx_first_start =
7522 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7524 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7525 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7526 tx_first, "tx_first");
7528 cmdline_parse_inst_t cmd_start_tx_first = {
7529 .f = cmd_start_tx_first_parsed,
7531 .help_str = "start tx_first: Start packet forwarding, "
7532 "after sending 1 burst of packets",
7534 (void *)&cmd_start_tx_first_start,
7535 (void *)&cmd_start_tx_first_tx_first,
7540 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7541 struct cmd_start_tx_first_n_result {
7542 cmdline_fixed_string_t start;
7543 cmdline_fixed_string_t tx_first;
7548 cmd_start_tx_first_n_parsed(void *parsed_result,
7549 __rte_unused struct cmdline *cl,
7550 __rte_unused void *data)
7552 struct cmd_start_tx_first_n_result *res = parsed_result;
7554 start_packet_forwarding(res->tx_num);
7557 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7558 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7560 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7561 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7562 tx_first, "tx_first");
7563 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7564 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7565 tx_num, RTE_UINT32);
7567 cmdline_parse_inst_t cmd_start_tx_first_n = {
7568 .f = cmd_start_tx_first_n_parsed,
7570 .help_str = "start tx_first <num>: "
7571 "packet forwarding, after sending <num> bursts of packets",
7573 (void *)&cmd_start_tx_first_n_start,
7574 (void *)&cmd_start_tx_first_n_tx_first,
7575 (void *)&cmd_start_tx_first_n_tx_num,
7580 /* *** SET LINK UP *** */
7581 struct cmd_set_link_up_result {
7582 cmdline_fixed_string_t set;
7583 cmdline_fixed_string_t link_up;
7584 cmdline_fixed_string_t port;
7588 cmdline_parse_token_string_t cmd_set_link_up_set =
7589 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7590 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7591 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7593 cmdline_parse_token_string_t cmd_set_link_up_port =
7594 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7595 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7596 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7599 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7600 __rte_unused struct cmdline *cl,
7601 __rte_unused void *data)
7603 struct cmd_set_link_up_result *res = parsed_result;
7604 dev_set_link_up(res->port_id);
7607 cmdline_parse_inst_t cmd_set_link_up = {
7608 .f = cmd_set_link_up_parsed,
7610 .help_str = "set link-up port <port id>",
7612 (void *)&cmd_set_link_up_set,
7613 (void *)&cmd_set_link_up_link_up,
7614 (void *)&cmd_set_link_up_port,
7615 (void *)&cmd_set_link_up_port_id,
7620 /* *** SET LINK DOWN *** */
7621 struct cmd_set_link_down_result {
7622 cmdline_fixed_string_t set;
7623 cmdline_fixed_string_t link_down;
7624 cmdline_fixed_string_t port;
7628 cmdline_parse_token_string_t cmd_set_link_down_set =
7629 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7630 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7631 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7633 cmdline_parse_token_string_t cmd_set_link_down_port =
7634 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7635 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7636 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7639 static void cmd_set_link_down_parsed(
7640 __rte_unused void *parsed_result,
7641 __rte_unused struct cmdline *cl,
7642 __rte_unused void *data)
7644 struct cmd_set_link_down_result *res = parsed_result;
7645 dev_set_link_down(res->port_id);
7648 cmdline_parse_inst_t cmd_set_link_down = {
7649 .f = cmd_set_link_down_parsed,
7651 .help_str = "set link-down port <port id>",
7653 (void *)&cmd_set_link_down_set,
7654 (void *)&cmd_set_link_down_link_down,
7655 (void *)&cmd_set_link_down_port,
7656 (void *)&cmd_set_link_down_port_id,
7661 /* *** SHOW CFG *** */
7662 struct cmd_showcfg_result {
7663 cmdline_fixed_string_t show;
7664 cmdline_fixed_string_t cfg;
7665 cmdline_fixed_string_t what;
7668 static void cmd_showcfg_parsed(void *parsed_result,
7669 __rte_unused struct cmdline *cl,
7670 __rte_unused void *data)
7672 struct cmd_showcfg_result *res = parsed_result;
7673 if (!strcmp(res->what, "rxtx"))
7674 rxtx_config_display();
7675 else if (!strcmp(res->what, "cores"))
7676 fwd_lcores_config_display();
7677 else if (!strcmp(res->what, "fwd"))
7678 pkt_fwd_config_display(&cur_fwd_config);
7679 else if (!strcmp(res->what, "rxoffs"))
7680 show_rx_pkt_offsets();
7681 else if (!strcmp(res->what, "rxpkts"))
7682 show_rx_pkt_segments();
7683 else if (!strcmp(res->what, "txpkts"))
7684 show_tx_pkt_segments();
7685 else if (!strcmp(res->what, "txtimes"))
7686 show_tx_pkt_times();
7689 cmdline_parse_token_string_t cmd_showcfg_show =
7690 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7691 cmdline_parse_token_string_t cmd_showcfg_port =
7692 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7693 cmdline_parse_token_string_t cmd_showcfg_what =
7694 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7695 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7697 cmdline_parse_inst_t cmd_showcfg = {
7698 .f = cmd_showcfg_parsed,
7700 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7702 (void *)&cmd_showcfg_show,
7703 (void *)&cmd_showcfg_port,
7704 (void *)&cmd_showcfg_what,
7709 /* *** SHOW ALL PORT INFO *** */
7710 struct cmd_showportall_result {
7711 cmdline_fixed_string_t show;
7712 cmdline_fixed_string_t port;
7713 cmdline_fixed_string_t what;
7714 cmdline_fixed_string_t all;
7717 static void cmd_showportall_parsed(void *parsed_result,
7718 __rte_unused struct cmdline *cl,
7719 __rte_unused void *data)
7723 struct cmd_showportall_result *res = parsed_result;
7724 if (!strcmp(res->show, "clear")) {
7725 if (!strcmp(res->what, "stats"))
7726 RTE_ETH_FOREACH_DEV(i)
7728 else if (!strcmp(res->what, "xstats"))
7729 RTE_ETH_FOREACH_DEV(i)
7730 nic_xstats_clear(i);
7731 } else if (!strcmp(res->what, "info"))
7732 RTE_ETH_FOREACH_DEV(i)
7733 port_infos_display(i);
7734 else if (!strcmp(res->what, "summary")) {
7735 port_summary_header_display();
7736 RTE_ETH_FOREACH_DEV(i)
7737 port_summary_display(i);
7739 else if (!strcmp(res->what, "stats"))
7740 RTE_ETH_FOREACH_DEV(i)
7741 nic_stats_display(i);
7742 else if (!strcmp(res->what, "xstats"))
7743 RTE_ETH_FOREACH_DEV(i)
7744 nic_xstats_display(i);
7745 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7746 else if (!strcmp(res->what, "fdir"))
7747 RTE_ETH_FOREACH_DEV(i)
7750 else if (!strcmp(res->what, "dcb_tc"))
7751 RTE_ETH_FOREACH_DEV(i)
7752 port_dcb_info_display(i);
7755 cmdline_parse_token_string_t cmd_showportall_show =
7756 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7758 cmdline_parse_token_string_t cmd_showportall_port =
7759 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7760 cmdline_parse_token_string_t cmd_showportall_what =
7761 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7762 "info#summary#stats#xstats#fdir#dcb_tc");
7763 cmdline_parse_token_string_t cmd_showportall_all =
7764 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7765 cmdline_parse_inst_t cmd_showportall = {
7766 .f = cmd_showportall_parsed,
7768 .help_str = "show|clear port "
7769 "info|summary|stats|xstats|fdir|dcb_tc all",
7771 (void *)&cmd_showportall_show,
7772 (void *)&cmd_showportall_port,
7773 (void *)&cmd_showportall_what,
7774 (void *)&cmd_showportall_all,
7779 /* *** SHOW PORT INFO *** */
7780 struct cmd_showport_result {
7781 cmdline_fixed_string_t show;
7782 cmdline_fixed_string_t port;
7783 cmdline_fixed_string_t what;
7787 static void cmd_showport_parsed(void *parsed_result,
7788 __rte_unused struct cmdline *cl,
7789 __rte_unused void *data)
7791 struct cmd_showport_result *res = parsed_result;
7792 if (!strcmp(res->show, "clear")) {
7793 if (!strcmp(res->what, "stats"))
7794 nic_stats_clear(res->portnum);
7795 else if (!strcmp(res->what, "xstats"))
7796 nic_xstats_clear(res->portnum);
7797 } else if (!strcmp(res->what, "info"))
7798 port_infos_display(res->portnum);
7799 else if (!strcmp(res->what, "summary")) {
7800 port_summary_header_display();
7801 port_summary_display(res->portnum);
7803 else if (!strcmp(res->what, "stats"))
7804 nic_stats_display(res->portnum);
7805 else if (!strcmp(res->what, "xstats"))
7806 nic_xstats_display(res->portnum);
7807 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7808 else if (!strcmp(res->what, "fdir"))
7809 fdir_get_infos(res->portnum);
7811 else if (!strcmp(res->what, "dcb_tc"))
7812 port_dcb_info_display(res->portnum);
7815 cmdline_parse_token_string_t cmd_showport_show =
7816 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7818 cmdline_parse_token_string_t cmd_showport_port =
7819 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7820 cmdline_parse_token_string_t cmd_showport_what =
7821 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7822 "info#summary#stats#xstats#fdir#dcb_tc");
7823 cmdline_parse_token_num_t cmd_showport_portnum =
7824 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7826 cmdline_parse_inst_t cmd_showport = {
7827 .f = cmd_showport_parsed,
7829 .help_str = "show|clear port "
7830 "info|summary|stats|xstats|fdir|dcb_tc "
7833 (void *)&cmd_showport_show,
7834 (void *)&cmd_showport_port,
7835 (void *)&cmd_showport_what,
7836 (void *)&cmd_showport_portnum,
7841 /* *** SHOW DEVICE INFO *** */
7842 struct cmd_showdevice_result {
7843 cmdline_fixed_string_t show;
7844 cmdline_fixed_string_t device;
7845 cmdline_fixed_string_t what;
7846 cmdline_fixed_string_t identifier;
7849 static void cmd_showdevice_parsed(void *parsed_result,
7850 __rte_unused struct cmdline *cl,
7851 __rte_unused void *data)
7853 struct cmd_showdevice_result *res = parsed_result;
7854 if (!strcmp(res->what, "info")) {
7855 if (!strcmp(res->identifier, "all"))
7856 device_infos_display(NULL);
7858 device_infos_display(res->identifier);
7862 cmdline_parse_token_string_t cmd_showdevice_show =
7863 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7865 cmdline_parse_token_string_t cmd_showdevice_device =
7866 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7867 cmdline_parse_token_string_t cmd_showdevice_what =
7868 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7870 cmdline_parse_token_string_t cmd_showdevice_identifier =
7871 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7874 cmdline_parse_inst_t cmd_showdevice = {
7875 .f = cmd_showdevice_parsed,
7877 .help_str = "show device info <identifier>|all",
7879 (void *)&cmd_showdevice_show,
7880 (void *)&cmd_showdevice_device,
7881 (void *)&cmd_showdevice_what,
7882 (void *)&cmd_showdevice_identifier,
7887 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7888 struct cmd_showeeprom_result {
7889 cmdline_fixed_string_t show;
7890 cmdline_fixed_string_t port;
7892 cmdline_fixed_string_t type;
7895 static void cmd_showeeprom_parsed(void *parsed_result,
7896 __rte_unused struct cmdline *cl,
7897 __rte_unused void *data)
7899 struct cmd_showeeprom_result *res = parsed_result;
7901 if (!strcmp(res->type, "eeprom"))
7902 port_eeprom_display(res->portnum);
7903 else if (!strcmp(res->type, "module_eeprom"))
7904 port_module_eeprom_display(res->portnum);
7906 printf("Unknown argument\n");
7909 cmdline_parse_token_string_t cmd_showeeprom_show =
7910 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7911 cmdline_parse_token_string_t cmd_showeeprom_port =
7912 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7913 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7914 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7916 cmdline_parse_token_string_t cmd_showeeprom_type =
7917 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7919 cmdline_parse_inst_t cmd_showeeprom = {
7920 .f = cmd_showeeprom_parsed,
7922 .help_str = "show port <port_id> module_eeprom|eeprom",
7924 (void *)&cmd_showeeprom_show,
7925 (void *)&cmd_showeeprom_port,
7926 (void *)&cmd_showeeprom_portnum,
7927 (void *)&cmd_showeeprom_type,
7932 /* *** SHOW QUEUE INFO *** */
7933 struct cmd_showqueue_result {
7934 cmdline_fixed_string_t show;
7935 cmdline_fixed_string_t type;
7936 cmdline_fixed_string_t what;
7942 cmd_showqueue_parsed(void *parsed_result,
7943 __rte_unused struct cmdline *cl,
7944 __rte_unused void *data)
7946 struct cmd_showqueue_result *res = parsed_result;
7948 if (!strcmp(res->type, "rxq"))
7949 rx_queue_infos_display(res->portnum, res->queuenum);
7950 else if (!strcmp(res->type, "txq"))
7951 tx_queue_infos_display(res->portnum, res->queuenum);
7954 cmdline_parse_token_string_t cmd_showqueue_show =
7955 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7956 cmdline_parse_token_string_t cmd_showqueue_type =
7957 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7958 cmdline_parse_token_string_t cmd_showqueue_what =
7959 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7960 cmdline_parse_token_num_t cmd_showqueue_portnum =
7961 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7963 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7964 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7967 cmdline_parse_inst_t cmd_showqueue = {
7968 .f = cmd_showqueue_parsed,
7970 .help_str = "show rxq|txq info <port_id> <queue_id>",
7972 (void *)&cmd_showqueue_show,
7973 (void *)&cmd_showqueue_type,
7974 (void *)&cmd_showqueue_what,
7975 (void *)&cmd_showqueue_portnum,
7976 (void *)&cmd_showqueue_queuenum,
7981 /* show/clear fwd engine statistics */
7983 cmdline_fixed_string_t action;
7984 cmdline_fixed_string_t fwd;
7985 cmdline_fixed_string_t stats;
7986 cmdline_fixed_string_t all;
7989 cmdline_parse_token_string_t cmd_fwd_action =
7990 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7991 cmdline_parse_token_string_t cmd_fwd_fwd =
7992 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7993 cmdline_parse_token_string_t cmd_fwd_stats =
7994 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7995 cmdline_parse_token_string_t cmd_fwd_all =
7996 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7999 cmd_showfwdall_parsed(void *parsed_result,
8000 __rte_unused struct cmdline *cl,
8001 __rte_unused void *data)
8003 struct fwd_result *res = parsed_result;
8005 if (!strcmp(res->action, "show"))
8006 fwd_stats_display();
8011 static cmdline_parse_inst_t cmd_showfwdall = {
8012 .f = cmd_showfwdall_parsed,
8014 .help_str = "show|clear fwd stats all",
8016 (void *)&cmd_fwd_action,
8017 (void *)&cmd_fwd_fwd,
8018 (void *)&cmd_fwd_stats,
8019 (void *)&cmd_fwd_all,
8024 /* *** READ PORT REGISTER *** */
8025 struct cmd_read_reg_result {
8026 cmdline_fixed_string_t read;
8027 cmdline_fixed_string_t reg;
8033 cmd_read_reg_parsed(void *parsed_result,
8034 __rte_unused struct cmdline *cl,
8035 __rte_unused void *data)
8037 struct cmd_read_reg_result *res = parsed_result;
8038 port_reg_display(res->port_id, res->reg_off);
8041 cmdline_parse_token_string_t cmd_read_reg_read =
8042 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8043 cmdline_parse_token_string_t cmd_read_reg_reg =
8044 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8045 cmdline_parse_token_num_t cmd_read_reg_port_id =
8046 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8047 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8048 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8050 cmdline_parse_inst_t cmd_read_reg = {
8051 .f = cmd_read_reg_parsed,
8053 .help_str = "read reg <port_id> <reg_off>",
8055 (void *)&cmd_read_reg_read,
8056 (void *)&cmd_read_reg_reg,
8057 (void *)&cmd_read_reg_port_id,
8058 (void *)&cmd_read_reg_reg_off,
8063 /* *** READ PORT REGISTER BIT FIELD *** */
8064 struct cmd_read_reg_bit_field_result {
8065 cmdline_fixed_string_t read;
8066 cmdline_fixed_string_t regfield;
8074 cmd_read_reg_bit_field_parsed(void *parsed_result,
8075 __rte_unused struct cmdline *cl,
8076 __rte_unused void *data)
8078 struct cmd_read_reg_bit_field_result *res = parsed_result;
8079 port_reg_bit_field_display(res->port_id, res->reg_off,
8080 res->bit1_pos, res->bit2_pos);
8083 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8084 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8086 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8087 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8088 regfield, "regfield");
8089 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8090 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8092 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8093 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8095 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8096 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8098 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8099 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8102 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8103 .f = cmd_read_reg_bit_field_parsed,
8105 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8106 "Read register bit field between bit_x and bit_y included",
8108 (void *)&cmd_read_reg_bit_field_read,
8109 (void *)&cmd_read_reg_bit_field_regfield,
8110 (void *)&cmd_read_reg_bit_field_port_id,
8111 (void *)&cmd_read_reg_bit_field_reg_off,
8112 (void *)&cmd_read_reg_bit_field_bit1_pos,
8113 (void *)&cmd_read_reg_bit_field_bit2_pos,
8118 /* *** READ PORT REGISTER BIT *** */
8119 struct cmd_read_reg_bit_result {
8120 cmdline_fixed_string_t read;
8121 cmdline_fixed_string_t regbit;
8128 cmd_read_reg_bit_parsed(void *parsed_result,
8129 __rte_unused struct cmdline *cl,
8130 __rte_unused void *data)
8132 struct cmd_read_reg_bit_result *res = parsed_result;
8133 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8136 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8137 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8138 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8139 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8141 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8142 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8144 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8145 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8147 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8148 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8151 cmdline_parse_inst_t cmd_read_reg_bit = {
8152 .f = cmd_read_reg_bit_parsed,
8154 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8156 (void *)&cmd_read_reg_bit_read,
8157 (void *)&cmd_read_reg_bit_regbit,
8158 (void *)&cmd_read_reg_bit_port_id,
8159 (void *)&cmd_read_reg_bit_reg_off,
8160 (void *)&cmd_read_reg_bit_bit_pos,
8165 /* *** WRITE PORT REGISTER *** */
8166 struct cmd_write_reg_result {
8167 cmdline_fixed_string_t write;
8168 cmdline_fixed_string_t reg;
8175 cmd_write_reg_parsed(void *parsed_result,
8176 __rte_unused struct cmdline *cl,
8177 __rte_unused void *data)
8179 struct cmd_write_reg_result *res = parsed_result;
8180 port_reg_set(res->port_id, res->reg_off, res->value);
8183 cmdline_parse_token_string_t cmd_write_reg_write =
8184 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8185 cmdline_parse_token_string_t cmd_write_reg_reg =
8186 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8187 cmdline_parse_token_num_t cmd_write_reg_port_id =
8188 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8189 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8190 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8191 cmdline_parse_token_num_t cmd_write_reg_value =
8192 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8194 cmdline_parse_inst_t cmd_write_reg = {
8195 .f = cmd_write_reg_parsed,
8197 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8199 (void *)&cmd_write_reg_write,
8200 (void *)&cmd_write_reg_reg,
8201 (void *)&cmd_write_reg_port_id,
8202 (void *)&cmd_write_reg_reg_off,
8203 (void *)&cmd_write_reg_value,
8208 /* *** WRITE PORT REGISTER BIT FIELD *** */
8209 struct cmd_write_reg_bit_field_result {
8210 cmdline_fixed_string_t write;
8211 cmdline_fixed_string_t regfield;
8220 cmd_write_reg_bit_field_parsed(void *parsed_result,
8221 __rte_unused struct cmdline *cl,
8222 __rte_unused void *data)
8224 struct cmd_write_reg_bit_field_result *res = parsed_result;
8225 port_reg_bit_field_set(res->port_id, res->reg_off,
8226 res->bit1_pos, res->bit2_pos, res->value);
8229 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8230 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8232 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8233 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8234 regfield, "regfield");
8235 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8236 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8238 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8239 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8241 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8242 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8244 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8245 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8247 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8248 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8251 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8252 .f = cmd_write_reg_bit_field_parsed,
8254 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8256 "Set register bit field between bit_x and bit_y included",
8258 (void *)&cmd_write_reg_bit_field_write,
8259 (void *)&cmd_write_reg_bit_field_regfield,
8260 (void *)&cmd_write_reg_bit_field_port_id,
8261 (void *)&cmd_write_reg_bit_field_reg_off,
8262 (void *)&cmd_write_reg_bit_field_bit1_pos,
8263 (void *)&cmd_write_reg_bit_field_bit2_pos,
8264 (void *)&cmd_write_reg_bit_field_value,
8269 /* *** WRITE PORT REGISTER BIT *** */
8270 struct cmd_write_reg_bit_result {
8271 cmdline_fixed_string_t write;
8272 cmdline_fixed_string_t regbit;
8280 cmd_write_reg_bit_parsed(void *parsed_result,
8281 __rte_unused struct cmdline *cl,
8282 __rte_unused void *data)
8284 struct cmd_write_reg_bit_result *res = parsed_result;
8285 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8288 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8289 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8291 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8292 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8294 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8295 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8297 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8298 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8300 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8301 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8303 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8304 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8307 cmdline_parse_inst_t cmd_write_reg_bit = {
8308 .f = cmd_write_reg_bit_parsed,
8310 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8313 (void *)&cmd_write_reg_bit_write,
8314 (void *)&cmd_write_reg_bit_regbit,
8315 (void *)&cmd_write_reg_bit_port_id,
8316 (void *)&cmd_write_reg_bit_reg_off,
8317 (void *)&cmd_write_reg_bit_bit_pos,
8318 (void *)&cmd_write_reg_bit_value,
8323 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8324 struct cmd_read_rxd_txd_result {
8325 cmdline_fixed_string_t read;
8326 cmdline_fixed_string_t rxd_txd;
8333 cmd_read_rxd_txd_parsed(void *parsed_result,
8334 __rte_unused struct cmdline *cl,
8335 __rte_unused void *data)
8337 struct cmd_read_rxd_txd_result *res = parsed_result;
8339 if (!strcmp(res->rxd_txd, "rxd"))
8340 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8341 else if (!strcmp(res->rxd_txd, "txd"))
8342 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8345 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8346 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8347 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8348 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8350 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8351 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8353 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8354 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8356 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8357 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8360 cmdline_parse_inst_t cmd_read_rxd_txd = {
8361 .f = cmd_read_rxd_txd_parsed,
8363 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8365 (void *)&cmd_read_rxd_txd_read,
8366 (void *)&cmd_read_rxd_txd_rxd_txd,
8367 (void *)&cmd_read_rxd_txd_port_id,
8368 (void *)&cmd_read_rxd_txd_queue_id,
8369 (void *)&cmd_read_rxd_txd_desc_id,
8375 struct cmd_quit_result {
8376 cmdline_fixed_string_t quit;
8379 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8381 __rte_unused void *data)
8386 cmdline_parse_token_string_t cmd_quit_quit =
8387 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8389 cmdline_parse_inst_t cmd_quit = {
8390 .f = cmd_quit_parsed,
8392 .help_str = "quit: Exit application",
8394 (void *)&cmd_quit_quit,
8399 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8400 struct cmd_mac_addr_result {
8401 cmdline_fixed_string_t mac_addr_cmd;
8402 cmdline_fixed_string_t what;
8404 struct rte_ether_addr address;
8407 static void cmd_mac_addr_parsed(void *parsed_result,
8408 __rte_unused struct cmdline *cl,
8409 __rte_unused void *data)
8411 struct cmd_mac_addr_result *res = parsed_result;
8414 if (strcmp(res->what, "add") == 0)
8415 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8416 else if (strcmp(res->what, "set") == 0)
8417 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8420 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8422 /* check the return value and print it if is < 0 */
8424 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8428 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8429 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8431 cmdline_parse_token_string_t cmd_mac_addr_what =
8432 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8434 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8435 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8437 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8438 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8440 cmdline_parse_inst_t cmd_mac_addr = {
8441 .f = cmd_mac_addr_parsed,
8443 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8444 "Add/Remove/Set MAC address on port_id",
8446 (void *)&cmd_mac_addr_cmd,
8447 (void *)&cmd_mac_addr_what,
8448 (void *)&cmd_mac_addr_portnum,
8449 (void *)&cmd_mac_addr_addr,
8454 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8455 struct cmd_eth_peer_result {
8456 cmdline_fixed_string_t set;
8457 cmdline_fixed_string_t eth_peer;
8459 cmdline_fixed_string_t peer_addr;
8462 static void cmd_set_eth_peer_parsed(void *parsed_result,
8463 __rte_unused struct cmdline *cl,
8464 __rte_unused void *data)
8466 struct cmd_eth_peer_result *res = parsed_result;
8468 if (test_done == 0) {
8469 printf("Please stop forwarding first\n");
8472 if (!strcmp(res->eth_peer, "eth-peer")) {
8473 set_fwd_eth_peer(res->port_id, res->peer_addr);
8477 cmdline_parse_token_string_t cmd_eth_peer_set =
8478 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8479 cmdline_parse_token_string_t cmd_eth_peer =
8480 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8481 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8482 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8484 cmdline_parse_token_string_t cmd_eth_peer_addr =
8485 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8487 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8488 .f = cmd_set_eth_peer_parsed,
8490 .help_str = "set eth-peer <port_id> <peer_mac>",
8492 (void *)&cmd_eth_peer_set,
8493 (void *)&cmd_eth_peer,
8494 (void *)&cmd_eth_peer_port_id,
8495 (void *)&cmd_eth_peer_addr,
8500 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8501 struct cmd_set_qmap_result {
8502 cmdline_fixed_string_t set;
8503 cmdline_fixed_string_t qmap;
8504 cmdline_fixed_string_t what;
8511 cmd_set_qmap_parsed(void *parsed_result,
8512 __rte_unused struct cmdline *cl,
8513 __rte_unused void *data)
8515 struct cmd_set_qmap_result *res = parsed_result;
8516 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8518 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8521 cmdline_parse_token_string_t cmd_setqmap_set =
8522 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8524 cmdline_parse_token_string_t cmd_setqmap_qmap =
8525 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8527 cmdline_parse_token_string_t cmd_setqmap_what =
8528 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8530 cmdline_parse_token_num_t cmd_setqmap_portid =
8531 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8532 port_id, RTE_UINT16);
8533 cmdline_parse_token_num_t cmd_setqmap_queueid =
8534 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8535 queue_id, RTE_UINT16);
8536 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8537 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8538 map_value, RTE_UINT8);
8540 cmdline_parse_inst_t cmd_set_qmap = {
8541 .f = cmd_set_qmap_parsed,
8543 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8544 "Set statistics mapping value on tx|rx queue_id of port_id",
8546 (void *)&cmd_setqmap_set,
8547 (void *)&cmd_setqmap_qmap,
8548 (void *)&cmd_setqmap_what,
8549 (void *)&cmd_setqmap_portid,
8550 (void *)&cmd_setqmap_queueid,
8551 (void *)&cmd_setqmap_mapvalue,
8556 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8557 struct cmd_set_xstats_hide_zero_result {
8558 cmdline_fixed_string_t keyword;
8559 cmdline_fixed_string_t name;
8560 cmdline_fixed_string_t on_off;
8564 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8565 __rte_unused struct cmdline *cl,
8566 __rte_unused void *data)
8568 struct cmd_set_xstats_hide_zero_result *res;
8569 uint16_t on_off = 0;
8571 res = parsed_result;
8572 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8573 set_xstats_hide_zero(on_off);
8576 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8577 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8579 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8580 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8581 name, "xstats-hide-zero");
8582 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8583 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8586 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8587 .f = cmd_set_xstats_hide_zero_parsed,
8589 .help_str = "set xstats-hide-zero on|off",
8591 (void *)&cmd_set_xstats_hide_zero_keyword,
8592 (void *)&cmd_set_xstats_hide_zero_name,
8593 (void *)&cmd_set_xstats_hide_zero_on_off,
8598 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8599 struct cmd_set_record_core_cycles_result {
8600 cmdline_fixed_string_t keyword;
8601 cmdline_fixed_string_t name;
8602 cmdline_fixed_string_t on_off;
8606 cmd_set_record_core_cycles_parsed(void *parsed_result,
8607 __rte_unused struct cmdline *cl,
8608 __rte_unused void *data)
8610 struct cmd_set_record_core_cycles_result *res;
8611 uint16_t on_off = 0;
8613 res = parsed_result;
8614 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8615 set_record_core_cycles(on_off);
8618 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8619 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8621 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8622 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8623 name, "record-core-cycles");
8624 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8625 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8628 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8629 .f = cmd_set_record_core_cycles_parsed,
8631 .help_str = "set record-core-cycles on|off",
8633 (void *)&cmd_set_record_core_cycles_keyword,
8634 (void *)&cmd_set_record_core_cycles_name,
8635 (void *)&cmd_set_record_core_cycles_on_off,
8640 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8641 struct cmd_set_record_burst_stats_result {
8642 cmdline_fixed_string_t keyword;
8643 cmdline_fixed_string_t name;
8644 cmdline_fixed_string_t on_off;
8648 cmd_set_record_burst_stats_parsed(void *parsed_result,
8649 __rte_unused struct cmdline *cl,
8650 __rte_unused void *data)
8652 struct cmd_set_record_burst_stats_result *res;
8653 uint16_t on_off = 0;
8655 res = parsed_result;
8656 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8657 set_record_burst_stats(on_off);
8660 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8661 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8663 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8664 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8665 name, "record-burst-stats");
8666 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8667 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8670 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8671 .f = cmd_set_record_burst_stats_parsed,
8673 .help_str = "set record-burst-stats on|off",
8675 (void *)&cmd_set_record_burst_stats_keyword,
8676 (void *)&cmd_set_record_burst_stats_name,
8677 (void *)&cmd_set_record_burst_stats_on_off,
8682 /* *** CONFIGURE UNICAST HASH TABLE *** */
8683 struct cmd_set_uc_hash_table {
8684 cmdline_fixed_string_t set;
8685 cmdline_fixed_string_t port;
8687 cmdline_fixed_string_t what;
8688 struct rte_ether_addr address;
8689 cmdline_fixed_string_t mode;
8693 cmd_set_uc_hash_parsed(void *parsed_result,
8694 __rte_unused struct cmdline *cl,
8695 __rte_unused void *data)
8698 struct cmd_set_uc_hash_table *res = parsed_result;
8700 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8702 if (strcmp(res->what, "uta") == 0)
8703 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8704 &res->address,(uint8_t)is_on);
8706 printf("bad unicast hash table parameter, return code = %d \n", ret);
8710 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8711 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8713 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8714 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8716 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8717 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8718 port_id, RTE_UINT16);
8719 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8720 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8722 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8723 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8725 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8726 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8729 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8730 .f = cmd_set_uc_hash_parsed,
8732 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8734 (void *)&cmd_set_uc_hash_set,
8735 (void *)&cmd_set_uc_hash_port,
8736 (void *)&cmd_set_uc_hash_portid,
8737 (void *)&cmd_set_uc_hash_what,
8738 (void *)&cmd_set_uc_hash_mac,
8739 (void *)&cmd_set_uc_hash_mode,
8744 struct cmd_set_uc_all_hash_table {
8745 cmdline_fixed_string_t set;
8746 cmdline_fixed_string_t port;
8748 cmdline_fixed_string_t what;
8749 cmdline_fixed_string_t value;
8750 cmdline_fixed_string_t mode;
8754 cmd_set_uc_all_hash_parsed(void *parsed_result,
8755 __rte_unused struct cmdline *cl,
8756 __rte_unused void *data)
8759 struct cmd_set_uc_all_hash_table *res = parsed_result;
8761 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8763 if ((strcmp(res->what, "uta") == 0) &&
8764 (strcmp(res->value, "all") == 0))
8765 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8767 printf("bad unicast hash table parameter,"
8768 "return code = %d \n", ret);
8771 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8772 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8774 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8775 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8777 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8778 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8779 port_id, RTE_UINT16);
8780 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8781 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8783 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8784 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8786 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8787 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8790 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8791 .f = cmd_set_uc_all_hash_parsed,
8793 .help_str = "set port <port_id> uta all on|off",
8795 (void *)&cmd_set_uc_all_hash_set,
8796 (void *)&cmd_set_uc_all_hash_port,
8797 (void *)&cmd_set_uc_all_hash_portid,
8798 (void *)&cmd_set_uc_all_hash_what,
8799 (void *)&cmd_set_uc_all_hash_value,
8800 (void *)&cmd_set_uc_all_hash_mode,
8805 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8806 struct cmd_set_vf_traffic {
8807 cmdline_fixed_string_t set;
8808 cmdline_fixed_string_t port;
8810 cmdline_fixed_string_t vf;
8812 cmdline_fixed_string_t what;
8813 cmdline_fixed_string_t mode;
8817 cmd_set_vf_traffic_parsed(void *parsed_result,
8818 __rte_unused struct cmdline *cl,
8819 __rte_unused void *data)
8821 struct cmd_set_vf_traffic *res = parsed_result;
8822 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8823 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8825 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8828 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8829 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8831 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8832 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8834 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8835 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8836 port_id, RTE_UINT16);
8837 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8838 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8840 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8841 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8843 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8844 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8846 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8847 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8850 cmdline_parse_inst_t cmd_set_vf_traffic = {
8851 .f = cmd_set_vf_traffic_parsed,
8853 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8855 (void *)&cmd_setvf_traffic_set,
8856 (void *)&cmd_setvf_traffic_port,
8857 (void *)&cmd_setvf_traffic_portid,
8858 (void *)&cmd_setvf_traffic_vf,
8859 (void *)&cmd_setvf_traffic_vfid,
8860 (void *)&cmd_setvf_traffic_what,
8861 (void *)&cmd_setvf_traffic_mode,
8866 /* *** CONFIGURE VF RECEIVE MODE *** */
8867 struct cmd_set_vf_rxmode {
8868 cmdline_fixed_string_t set;
8869 cmdline_fixed_string_t port;
8871 cmdline_fixed_string_t vf;
8873 cmdline_fixed_string_t what;
8874 cmdline_fixed_string_t mode;
8875 cmdline_fixed_string_t on;
8879 cmd_set_vf_rxmode_parsed(void *parsed_result,
8880 __rte_unused struct cmdline *cl,
8881 __rte_unused void *data)
8884 uint16_t vf_rxmode = 0;
8885 struct cmd_set_vf_rxmode *res = parsed_result;
8887 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8888 if (!strcmp(res->what,"rxmode")) {
8889 if (!strcmp(res->mode, "AUPE"))
8890 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8891 else if (!strcmp(res->mode, "ROPE"))
8892 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8893 else if (!strcmp(res->mode, "BAM"))
8894 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8895 else if (!strncmp(res->mode, "MPE",3))
8896 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8899 RTE_SET_USED(is_on);
8901 #ifdef RTE_NET_IXGBE
8902 if (ret == -ENOTSUP)
8903 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8904 vf_rxmode, (uint8_t)is_on);
8907 if (ret == -ENOTSUP)
8908 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8909 vf_rxmode, (uint8_t)is_on);
8912 printf("bad VF receive mode parameter, return code = %d \n",
8916 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8917 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8919 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8920 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8922 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8923 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8924 port_id, RTE_UINT16);
8925 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8926 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8928 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8929 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8931 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8932 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8934 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8935 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8936 mode, "AUPE#ROPE#BAM#MPE");
8937 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8938 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8941 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8942 .f = cmd_set_vf_rxmode_parsed,
8944 .help_str = "set port <port_id> vf <vf_id> rxmode "
8945 "AUPE|ROPE|BAM|MPE on|off",
8947 (void *)&cmd_set_vf_rxmode_set,
8948 (void *)&cmd_set_vf_rxmode_port,
8949 (void *)&cmd_set_vf_rxmode_portid,
8950 (void *)&cmd_set_vf_rxmode_vf,
8951 (void *)&cmd_set_vf_rxmode_vfid,
8952 (void *)&cmd_set_vf_rxmode_what,
8953 (void *)&cmd_set_vf_rxmode_mode,
8954 (void *)&cmd_set_vf_rxmode_on,
8959 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8960 struct cmd_vf_mac_addr_result {
8961 cmdline_fixed_string_t mac_addr_cmd;
8962 cmdline_fixed_string_t what;
8963 cmdline_fixed_string_t port;
8965 cmdline_fixed_string_t vf;
8967 struct rte_ether_addr address;
8970 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8971 __rte_unused struct cmdline *cl,
8972 __rte_unused void *data)
8974 struct cmd_vf_mac_addr_result *res = parsed_result;
8977 if (strcmp(res->what, "add") != 0)
8981 if (ret == -ENOTSUP)
8982 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8986 if (ret == -ENOTSUP)
8987 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8992 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8996 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8997 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8998 mac_addr_cmd,"mac_addr");
8999 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9000 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9002 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9003 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9005 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9006 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9007 port_num, RTE_UINT16);
9008 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9009 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9011 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9012 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9014 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9015 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9018 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9019 .f = cmd_vf_mac_addr_parsed,
9021 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9022 "Add MAC address filtering for a VF on port_id",
9024 (void *)&cmd_vf_mac_addr_cmd,
9025 (void *)&cmd_vf_mac_addr_what,
9026 (void *)&cmd_vf_mac_addr_port,
9027 (void *)&cmd_vf_mac_addr_portnum,
9028 (void *)&cmd_vf_mac_addr_vf,
9029 (void *)&cmd_vf_mac_addr_vfnum,
9030 (void *)&cmd_vf_mac_addr_addr,
9035 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9036 struct cmd_vf_rx_vlan_filter {
9037 cmdline_fixed_string_t rx_vlan;
9038 cmdline_fixed_string_t what;
9040 cmdline_fixed_string_t port;
9042 cmdline_fixed_string_t vf;
9047 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9048 __rte_unused struct cmdline *cl,
9049 __rte_unused void *data)
9051 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9054 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9056 #ifdef RTE_NET_IXGBE
9057 if (ret == -ENOTSUP)
9058 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9059 res->vlan_id, res->vf_mask, is_add);
9062 if (ret == -ENOTSUP)
9063 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9064 res->vlan_id, res->vf_mask, is_add);
9067 if (ret == -ENOTSUP)
9068 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9069 res->vlan_id, res->vf_mask, is_add);
9076 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9077 res->vlan_id, res->vf_mask);
9080 printf("invalid port_id %d\n", res->port_id);
9083 printf("function not implemented or supported\n");
9086 printf("programming error: (%s)\n", strerror(-ret));
9090 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9091 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9092 rx_vlan, "rx_vlan");
9093 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9094 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9096 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9097 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9098 vlan_id, RTE_UINT16);
9099 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9100 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9102 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9103 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9104 port_id, RTE_UINT16);
9105 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9106 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9108 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9109 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9110 vf_mask, RTE_UINT64);
9112 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9113 .f = cmd_vf_rx_vlan_filter_parsed,
9115 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9116 "(vf_mask = hexadecimal VF mask)",
9118 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9119 (void *)&cmd_vf_rx_vlan_filter_what,
9120 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9121 (void *)&cmd_vf_rx_vlan_filter_port,
9122 (void *)&cmd_vf_rx_vlan_filter_portid,
9123 (void *)&cmd_vf_rx_vlan_filter_vf,
9124 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9129 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9130 struct cmd_queue_rate_limit_result {
9131 cmdline_fixed_string_t set;
9132 cmdline_fixed_string_t port;
9134 cmdline_fixed_string_t queue;
9136 cmdline_fixed_string_t rate;
9140 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9141 __rte_unused struct cmdline *cl,
9142 __rte_unused void *data)
9144 struct cmd_queue_rate_limit_result *res = parsed_result;
9147 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9148 && (strcmp(res->queue, "queue") == 0)
9149 && (strcmp(res->rate, "rate") == 0))
9150 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9153 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9157 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9158 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9160 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9161 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9163 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9164 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9165 port_num, RTE_UINT16);
9166 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9167 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9169 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9170 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9171 queue_num, RTE_UINT8);
9172 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9173 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9175 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9176 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9177 rate_num, RTE_UINT16);
9179 cmdline_parse_inst_t cmd_queue_rate_limit = {
9180 .f = cmd_queue_rate_limit_parsed,
9182 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9183 "Set rate limit for a queue on port_id",
9185 (void *)&cmd_queue_rate_limit_set,
9186 (void *)&cmd_queue_rate_limit_port,
9187 (void *)&cmd_queue_rate_limit_portnum,
9188 (void *)&cmd_queue_rate_limit_queue,
9189 (void *)&cmd_queue_rate_limit_queuenum,
9190 (void *)&cmd_queue_rate_limit_rate,
9191 (void *)&cmd_queue_rate_limit_ratenum,
9196 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9197 struct cmd_vf_rate_limit_result {
9198 cmdline_fixed_string_t set;
9199 cmdline_fixed_string_t port;
9201 cmdline_fixed_string_t vf;
9203 cmdline_fixed_string_t rate;
9205 cmdline_fixed_string_t q_msk;
9209 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9210 __rte_unused struct cmdline *cl,
9211 __rte_unused void *data)
9213 struct cmd_vf_rate_limit_result *res = parsed_result;
9216 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9217 && (strcmp(res->vf, "vf") == 0)
9218 && (strcmp(res->rate, "rate") == 0)
9219 && (strcmp(res->q_msk, "queue_mask") == 0))
9220 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9221 res->rate_num, res->q_msk_val);
9223 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9227 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9228 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9230 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9231 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9233 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9234 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9235 port_num, RTE_UINT16);
9236 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9237 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9239 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9240 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9242 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9243 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9245 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9246 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9247 rate_num, RTE_UINT16);
9248 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9249 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9250 q_msk, "queue_mask");
9251 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9252 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9253 q_msk_val, RTE_UINT64);
9255 cmdline_parse_inst_t cmd_vf_rate_limit = {
9256 .f = cmd_vf_rate_limit_parsed,
9258 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9259 "queue_mask <queue_mask_value>: "
9260 "Set rate limit for queues of VF on port_id",
9262 (void *)&cmd_vf_rate_limit_set,
9263 (void *)&cmd_vf_rate_limit_port,
9264 (void *)&cmd_vf_rate_limit_portnum,
9265 (void *)&cmd_vf_rate_limit_vf,
9266 (void *)&cmd_vf_rate_limit_vfnum,
9267 (void *)&cmd_vf_rate_limit_rate,
9268 (void *)&cmd_vf_rate_limit_ratenum,
9269 (void *)&cmd_vf_rate_limit_q_msk,
9270 (void *)&cmd_vf_rate_limit_q_msk_val,
9275 /* *** CONFIGURE TUNNEL UDP PORT *** */
9276 struct cmd_tunnel_udp_config {
9277 cmdline_fixed_string_t rx_vxlan_port;
9278 cmdline_fixed_string_t what;
9284 cmd_tunnel_udp_config_parsed(void *parsed_result,
9285 __rte_unused struct cmdline *cl,
9286 __rte_unused void *data)
9288 struct cmd_tunnel_udp_config *res = parsed_result;
9289 struct rte_eth_udp_tunnel tunnel_udp;
9292 tunnel_udp.udp_port = res->udp_port;
9293 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9295 if (!strcmp(res->what, "add"))
9296 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9299 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9303 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9306 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9307 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9308 rx_vxlan_port, "rx_vxlan_port");
9309 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9310 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9312 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9313 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9314 udp_port, RTE_UINT16);
9315 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9316 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9317 port_id, RTE_UINT16);
9319 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9320 .f = cmd_tunnel_udp_config_parsed,
9322 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9323 "Add/Remove a tunneling UDP port filter",
9325 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9326 (void *)&cmd_tunnel_udp_config_what,
9327 (void *)&cmd_tunnel_udp_config_udp_port,
9328 (void *)&cmd_tunnel_udp_config_port_id,
9333 struct cmd_config_tunnel_udp_port {
9334 cmdline_fixed_string_t port;
9335 cmdline_fixed_string_t config;
9337 cmdline_fixed_string_t udp_tunnel_port;
9338 cmdline_fixed_string_t action;
9339 cmdline_fixed_string_t tunnel_type;
9344 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9345 __rte_unused struct cmdline *cl,
9346 __rte_unused void *data)
9348 struct cmd_config_tunnel_udp_port *res = parsed_result;
9349 struct rte_eth_udp_tunnel tunnel_udp;
9352 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9355 tunnel_udp.udp_port = res->udp_port;
9357 if (!strcmp(res->tunnel_type, "vxlan")) {
9358 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9359 } else if (!strcmp(res->tunnel_type, "geneve")) {
9360 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9361 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9362 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9363 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9364 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9366 printf("Invalid tunnel type\n");
9370 if (!strcmp(res->action, "add"))
9371 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9374 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9378 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9381 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9382 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9384 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9385 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9387 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9388 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9390 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9391 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9394 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9395 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9397 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9398 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9399 "vxlan#geneve#vxlan-gpe#ecpri");
9400 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9401 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9404 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9405 .f = cmd_cfg_tunnel_udp_port_parsed,
9407 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9408 "geneve|vxlan-gpe|ecpri <udp_port>",
9410 (void *)&cmd_config_tunnel_udp_port_port,
9411 (void *)&cmd_config_tunnel_udp_port_config,
9412 (void *)&cmd_config_tunnel_udp_port_port_id,
9413 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9414 (void *)&cmd_config_tunnel_udp_port_action,
9415 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9416 (void *)&cmd_config_tunnel_udp_port_value,
9421 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9422 struct cmd_set_mirror_mask_result {
9423 cmdline_fixed_string_t set;
9424 cmdline_fixed_string_t port;
9426 cmdline_fixed_string_t mirror;
9428 cmdline_fixed_string_t what;
9429 cmdline_fixed_string_t value;
9430 cmdline_fixed_string_t dstpool;
9432 cmdline_fixed_string_t on;
9435 cmdline_parse_token_string_t cmd_mirror_mask_set =
9436 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9438 cmdline_parse_token_string_t cmd_mirror_mask_port =
9439 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9441 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9442 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9443 port_id, RTE_UINT16);
9444 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9445 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9446 mirror, "mirror-rule");
9447 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9448 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9449 rule_id, RTE_UINT8);
9450 cmdline_parse_token_string_t cmd_mirror_mask_what =
9451 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9452 what, "pool-mirror-up#pool-mirror-down"
9454 cmdline_parse_token_string_t cmd_mirror_mask_value =
9455 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9457 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9458 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9459 dstpool, "dst-pool");
9460 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9461 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9462 dstpool_id, RTE_UINT8);
9463 cmdline_parse_token_string_t cmd_mirror_mask_on =
9464 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9468 cmd_set_mirror_mask_parsed(void *parsed_result,
9469 __rte_unused struct cmdline *cl,
9470 __rte_unused void *data)
9473 struct cmd_set_mirror_mask_result *res = parsed_result;
9474 struct rte_eth_mirror_conf mr_conf;
9476 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9478 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9480 mr_conf.dst_pool = res->dstpool_id;
9482 if (!strcmp(res->what, "pool-mirror-up")) {
9483 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9484 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9485 } else if (!strcmp(res->what, "pool-mirror-down")) {
9486 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9487 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9488 } else if (!strcmp(res->what, "vlan-mirror")) {
9489 mr_conf.rule_type = ETH_MIRROR_VLAN;
9490 nb_item = parse_item_list(res->value, "vlan",
9491 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9495 for (i = 0; i < nb_item; i++) {
9496 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9497 printf("Invalid vlan_id: must be < 4096\n");
9501 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9502 mr_conf.vlan.vlan_mask |= 1ULL << i;
9506 if (!strcmp(res->on, "on"))
9507 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9510 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9513 printf("mirror rule add error: (%s)\n", strerror(-ret));
9516 cmdline_parse_inst_t cmd_set_mirror_mask = {
9517 .f = cmd_set_mirror_mask_parsed,
9519 .help_str = "set port <port_id> mirror-rule <rule_id> "
9520 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9521 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9523 (void *)&cmd_mirror_mask_set,
9524 (void *)&cmd_mirror_mask_port,
9525 (void *)&cmd_mirror_mask_portid,
9526 (void *)&cmd_mirror_mask_mirror,
9527 (void *)&cmd_mirror_mask_ruleid,
9528 (void *)&cmd_mirror_mask_what,
9529 (void *)&cmd_mirror_mask_value,
9530 (void *)&cmd_mirror_mask_dstpool,
9531 (void *)&cmd_mirror_mask_poolid,
9532 (void *)&cmd_mirror_mask_on,
9537 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9538 struct cmd_set_mirror_link_result {
9539 cmdline_fixed_string_t set;
9540 cmdline_fixed_string_t port;
9542 cmdline_fixed_string_t mirror;
9544 cmdline_fixed_string_t what;
9545 cmdline_fixed_string_t dstpool;
9547 cmdline_fixed_string_t on;
9550 cmdline_parse_token_string_t cmd_mirror_link_set =
9551 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9553 cmdline_parse_token_string_t cmd_mirror_link_port =
9554 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9556 cmdline_parse_token_num_t cmd_mirror_link_portid =
9557 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9558 port_id, RTE_UINT16);
9559 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9560 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9561 mirror, "mirror-rule");
9562 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9563 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9564 rule_id, RTE_UINT8);
9565 cmdline_parse_token_string_t cmd_mirror_link_what =
9566 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9567 what, "uplink-mirror#downlink-mirror");
9568 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9569 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9570 dstpool, "dst-pool");
9571 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9572 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9573 dstpool_id, RTE_UINT8);
9574 cmdline_parse_token_string_t cmd_mirror_link_on =
9575 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9579 cmd_set_mirror_link_parsed(void *parsed_result,
9580 __rte_unused struct cmdline *cl,
9581 __rte_unused void *data)
9584 struct cmd_set_mirror_link_result *res = parsed_result;
9585 struct rte_eth_mirror_conf mr_conf;
9587 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9588 if (!strcmp(res->what, "uplink-mirror"))
9589 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9591 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9593 mr_conf.dst_pool = res->dstpool_id;
9595 if (!strcmp(res->on, "on"))
9596 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9599 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9602 /* check the return value and print it if is < 0 */
9604 printf("mirror rule add error: (%s)\n", strerror(-ret));
9608 cmdline_parse_inst_t cmd_set_mirror_link = {
9609 .f = cmd_set_mirror_link_parsed,
9611 .help_str = "set port <port_id> mirror-rule <rule_id> "
9612 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9614 (void *)&cmd_mirror_link_set,
9615 (void *)&cmd_mirror_link_port,
9616 (void *)&cmd_mirror_link_portid,
9617 (void *)&cmd_mirror_link_mirror,
9618 (void *)&cmd_mirror_link_ruleid,
9619 (void *)&cmd_mirror_link_what,
9620 (void *)&cmd_mirror_link_dstpool,
9621 (void *)&cmd_mirror_link_poolid,
9622 (void *)&cmd_mirror_link_on,
9627 /* *** RESET VM MIRROR RULE *** */
9628 struct cmd_rm_mirror_rule_result {
9629 cmdline_fixed_string_t reset;
9630 cmdline_fixed_string_t port;
9632 cmdline_fixed_string_t mirror;
9636 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9637 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9639 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9640 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9642 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9643 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9644 port_id, RTE_UINT16);
9645 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9646 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9647 mirror, "mirror-rule");
9648 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9649 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9650 rule_id, RTE_UINT8);
9653 cmd_reset_mirror_rule_parsed(void *parsed_result,
9654 __rte_unused struct cmdline *cl,
9655 __rte_unused void *data)
9658 struct cmd_set_mirror_link_result *res = parsed_result;
9660 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9662 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9665 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9666 .f = cmd_reset_mirror_rule_parsed,
9668 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9670 (void *)&cmd_rm_mirror_rule_reset,
9671 (void *)&cmd_rm_mirror_rule_port,
9672 (void *)&cmd_rm_mirror_rule_portid,
9673 (void *)&cmd_rm_mirror_rule_mirror,
9674 (void *)&cmd_rm_mirror_rule_ruleid,
9679 /* ******************************************************************************** */
9681 struct cmd_dump_result {
9682 cmdline_fixed_string_t dump;
9686 dump_struct_sizes(void)
9688 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9689 DUMP_SIZE(struct rte_mbuf);
9690 DUMP_SIZE(struct rte_mempool);
9691 DUMP_SIZE(struct rte_ring);
9696 /* Dump the socket memory statistics on console */
9698 dump_socket_mem(FILE *f)
9700 struct rte_malloc_socket_stats socket_stats;
9705 unsigned int n_alloc = 0;
9706 unsigned int n_free = 0;
9707 static size_t last_allocs;
9708 static size_t last_total;
9711 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9712 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9713 !socket_stats.heap_totalsz_bytes)
9715 total += socket_stats.heap_totalsz_bytes;
9716 alloc += socket_stats.heap_allocsz_bytes;
9717 free += socket_stats.heap_freesz_bytes;
9718 n_alloc += socket_stats.alloc_count;
9719 n_free += socket_stats.free_count;
9721 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9723 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9724 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9725 (double)socket_stats.heap_allocsz_bytes * 100 /
9726 (double)socket_stats.heap_totalsz_bytes,
9727 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9728 socket_stats.alloc_count,
9729 socket_stats.free_count);
9732 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9733 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9734 total ? ((double)alloc * 100 / (double)total) : 0,
9735 (double)free / (1024 * 1024),
9738 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9739 ((double)total - (double)last_total) / (1024 * 1024),
9740 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9741 last_allocs = alloc;
9745 static void cmd_dump_parsed(void *parsed_result,
9746 __rte_unused struct cmdline *cl,
9747 __rte_unused void *data)
9749 struct cmd_dump_result *res = parsed_result;
9751 if (!strcmp(res->dump, "dump_physmem"))
9752 rte_dump_physmem_layout(stdout);
9753 else if (!strcmp(res->dump, "dump_socket_mem"))
9754 dump_socket_mem(stdout);
9755 else if (!strcmp(res->dump, "dump_memzone"))
9756 rte_memzone_dump(stdout);
9757 else if (!strcmp(res->dump, "dump_struct_sizes"))
9758 dump_struct_sizes();
9759 else if (!strcmp(res->dump, "dump_ring"))
9760 rte_ring_list_dump(stdout);
9761 else if (!strcmp(res->dump, "dump_mempool"))
9762 rte_mempool_list_dump(stdout);
9763 else if (!strcmp(res->dump, "dump_devargs"))
9764 rte_devargs_dump(stdout);
9765 else if (!strcmp(res->dump, "dump_log_types"))
9766 rte_log_dump(stdout);
9769 cmdline_parse_token_string_t cmd_dump_dump =
9770 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9774 "dump_struct_sizes#"
9780 cmdline_parse_inst_t cmd_dump = {
9781 .f = cmd_dump_parsed, /* function to call */
9782 .data = NULL, /* 2nd arg of func */
9783 .help_str = "Dump status",
9784 .tokens = { /* token list, NULL terminated */
9785 (void *)&cmd_dump_dump,
9790 /* ******************************************************************************** */
9792 struct cmd_dump_one_result {
9793 cmdline_fixed_string_t dump;
9794 cmdline_fixed_string_t name;
9797 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9798 __rte_unused void *data)
9800 struct cmd_dump_one_result *res = parsed_result;
9802 if (!strcmp(res->dump, "dump_ring")) {
9804 r = rte_ring_lookup(res->name);
9806 cmdline_printf(cl, "Cannot find ring\n");
9809 rte_ring_dump(stdout, r);
9810 } else if (!strcmp(res->dump, "dump_mempool")) {
9811 struct rte_mempool *mp;
9812 mp = rte_mempool_lookup(res->name);
9814 cmdline_printf(cl, "Cannot find mempool\n");
9817 rte_mempool_dump(stdout, mp);
9821 cmdline_parse_token_string_t cmd_dump_one_dump =
9822 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9823 "dump_ring#dump_mempool");
9825 cmdline_parse_token_string_t cmd_dump_one_name =
9826 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9828 cmdline_parse_inst_t cmd_dump_one = {
9829 .f = cmd_dump_one_parsed, /* function to call */
9830 .data = NULL, /* 2nd arg of func */
9831 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9832 .tokens = { /* token list, NULL terminated */
9833 (void *)&cmd_dump_one_dump,
9834 (void *)&cmd_dump_one_name,
9839 /* *** queue region set *** */
9840 struct cmd_queue_region_result {
9841 cmdline_fixed_string_t set;
9842 cmdline_fixed_string_t port;
9844 cmdline_fixed_string_t cmd;
9845 cmdline_fixed_string_t region;
9847 cmdline_fixed_string_t queue_start_index;
9849 cmdline_fixed_string_t queue_num;
9850 uint8_t queue_num_value;
9854 cmd_queue_region_parsed(void *parsed_result,
9855 __rte_unused struct cmdline *cl,
9856 __rte_unused void *data)
9858 struct cmd_queue_region_result *res = parsed_result;
9861 struct rte_pmd_i40e_queue_region_conf region_conf;
9862 enum rte_pmd_i40e_queue_region_op op_type;
9865 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9869 memset(®ion_conf, 0, sizeof(region_conf));
9870 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9871 region_conf.region_id = res->region_id;
9872 region_conf.queue_num = res->queue_num_value;
9873 region_conf.queue_start_index = res->queue_id;
9875 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9876 op_type, ®ion_conf);
9883 printf("function not implemented or supported\n");
9886 printf("queue region config error: (%s)\n", strerror(-ret));
9890 cmdline_parse_token_string_t cmd_queue_region_set =
9891 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9893 cmdline_parse_token_string_t cmd_queue_region_port =
9894 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9895 cmdline_parse_token_num_t cmd_queue_region_port_id =
9896 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9897 port_id, RTE_UINT16);
9898 cmdline_parse_token_string_t cmd_queue_region_cmd =
9899 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9900 cmd, "queue-region");
9901 cmdline_parse_token_string_t cmd_queue_region_id =
9902 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9903 region, "region_id");
9904 cmdline_parse_token_num_t cmd_queue_region_index =
9905 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9906 region_id, RTE_UINT8);
9907 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9908 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9909 queue_start_index, "queue_start_index");
9910 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9911 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9912 queue_id, RTE_UINT8);
9913 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9914 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9915 queue_num, "queue_num");
9916 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9917 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9918 queue_num_value, RTE_UINT8);
9920 cmdline_parse_inst_t cmd_queue_region = {
9921 .f = cmd_queue_region_parsed,
9923 .help_str = "set port <port_id> queue-region region_id <value> "
9924 "queue_start_index <value> queue_num <value>: Set a queue region",
9926 (void *)&cmd_queue_region_set,
9927 (void *)&cmd_queue_region_port,
9928 (void *)&cmd_queue_region_port_id,
9929 (void *)&cmd_queue_region_cmd,
9930 (void *)&cmd_queue_region_id,
9931 (void *)&cmd_queue_region_index,
9932 (void *)&cmd_queue_region_queue_start_index,
9933 (void *)&cmd_queue_region_queue_id,
9934 (void *)&cmd_queue_region_queue_num,
9935 (void *)&cmd_queue_region_queue_num_value,
9940 /* *** queue region and flowtype set *** */
9941 struct cmd_region_flowtype_result {
9942 cmdline_fixed_string_t set;
9943 cmdline_fixed_string_t port;
9945 cmdline_fixed_string_t cmd;
9946 cmdline_fixed_string_t region;
9948 cmdline_fixed_string_t flowtype;
9949 uint8_t flowtype_id;
9953 cmd_region_flowtype_parsed(void *parsed_result,
9954 __rte_unused struct cmdline *cl,
9955 __rte_unused void *data)
9957 struct cmd_region_flowtype_result *res = parsed_result;
9960 struct rte_pmd_i40e_queue_region_conf region_conf;
9961 enum rte_pmd_i40e_queue_region_op op_type;
9964 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9968 memset(®ion_conf, 0, sizeof(region_conf));
9970 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9971 region_conf.region_id = res->region_id;
9972 region_conf.hw_flowtype = res->flowtype_id;
9974 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9975 op_type, ®ion_conf);
9982 printf("function not implemented or supported\n");
9985 printf("region flowtype config error: (%s)\n", strerror(-ret));
9989 cmdline_parse_token_string_t cmd_region_flowtype_set =
9990 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9992 cmdline_parse_token_string_t cmd_region_flowtype_port =
9993 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9995 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9996 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9997 port_id, RTE_UINT16);
9998 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9999 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10000 cmd, "queue-region");
10001 cmdline_parse_token_string_t cmd_region_flowtype_index =
10002 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10003 region, "region_id");
10004 cmdline_parse_token_num_t cmd_region_flowtype_id =
10005 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10006 region_id, RTE_UINT8);
10007 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10008 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10009 flowtype, "flowtype");
10010 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10011 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10012 flowtype_id, RTE_UINT8);
10013 cmdline_parse_inst_t cmd_region_flowtype = {
10014 .f = cmd_region_flowtype_parsed,
10016 .help_str = "set port <port_id> queue-region region_id <value> "
10017 "flowtype <value>: Set a flowtype region index",
10019 (void *)&cmd_region_flowtype_set,
10020 (void *)&cmd_region_flowtype_port,
10021 (void *)&cmd_region_flowtype_port_index,
10022 (void *)&cmd_region_flowtype_cmd,
10023 (void *)&cmd_region_flowtype_index,
10024 (void *)&cmd_region_flowtype_id,
10025 (void *)&cmd_region_flowtype_flow_index,
10026 (void *)&cmd_region_flowtype_flow_id,
10031 /* *** User Priority (UP) to queue region (region_id) set *** */
10032 struct cmd_user_priority_region_result {
10033 cmdline_fixed_string_t set;
10034 cmdline_fixed_string_t port;
10036 cmdline_fixed_string_t cmd;
10037 cmdline_fixed_string_t user_priority;
10038 uint8_t user_priority_id;
10039 cmdline_fixed_string_t region;
10044 cmd_user_priority_region_parsed(void *parsed_result,
10045 __rte_unused struct cmdline *cl,
10046 __rte_unused void *data)
10048 struct cmd_user_priority_region_result *res = parsed_result;
10049 int ret = -ENOTSUP;
10050 #ifdef RTE_NET_I40E
10051 struct rte_pmd_i40e_queue_region_conf region_conf;
10052 enum rte_pmd_i40e_queue_region_op op_type;
10055 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10058 #ifdef RTE_NET_I40E
10059 memset(®ion_conf, 0, sizeof(region_conf));
10060 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10061 region_conf.user_priority = res->user_priority_id;
10062 region_conf.region_id = res->region_id;
10064 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10065 op_type, ®ion_conf);
10072 printf("function not implemented or supported\n");
10075 printf("user_priority region config error: (%s)\n",
10080 cmdline_parse_token_string_t cmd_user_priority_region_set =
10081 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10083 cmdline_parse_token_string_t cmd_user_priority_region_port =
10084 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10086 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10087 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10088 port_id, RTE_UINT16);
10089 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10090 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10091 cmd, "queue-region");
10092 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10093 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10094 user_priority, "UP");
10095 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10096 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10097 user_priority_id, RTE_UINT8);
10098 cmdline_parse_token_string_t cmd_user_priority_region_region =
10099 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10100 region, "region_id");
10101 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10102 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10103 region_id, RTE_UINT8);
10105 cmdline_parse_inst_t cmd_user_priority_region = {
10106 .f = cmd_user_priority_region_parsed,
10108 .help_str = "set port <port_id> queue-region UP <value> "
10109 "region_id <value>: Set the mapping of User Priority (UP) "
10110 "to queue region (region_id) ",
10112 (void *)&cmd_user_priority_region_set,
10113 (void *)&cmd_user_priority_region_port,
10114 (void *)&cmd_user_priority_region_port_index,
10115 (void *)&cmd_user_priority_region_cmd,
10116 (void *)&cmd_user_priority_region_UP,
10117 (void *)&cmd_user_priority_region_UP_id,
10118 (void *)&cmd_user_priority_region_region,
10119 (void *)&cmd_user_priority_region_region_id,
10124 /* *** flush all queue region related configuration *** */
10125 struct cmd_flush_queue_region_result {
10126 cmdline_fixed_string_t set;
10127 cmdline_fixed_string_t port;
10129 cmdline_fixed_string_t cmd;
10130 cmdline_fixed_string_t flush;
10131 cmdline_fixed_string_t what;
10135 cmd_flush_queue_region_parsed(void *parsed_result,
10136 __rte_unused struct cmdline *cl,
10137 __rte_unused void *data)
10139 struct cmd_flush_queue_region_result *res = parsed_result;
10140 int ret = -ENOTSUP;
10141 #ifdef RTE_NET_I40E
10142 struct rte_pmd_i40e_queue_region_conf region_conf;
10143 enum rte_pmd_i40e_queue_region_op op_type;
10146 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10149 #ifdef RTE_NET_I40E
10150 memset(®ion_conf, 0, sizeof(region_conf));
10152 if (strcmp(res->what, "on") == 0)
10153 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10155 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10157 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10158 op_type, ®ion_conf);
10165 printf("function not implemented or supported\n");
10168 printf("queue region config flush error: (%s)\n",
10173 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10174 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10176 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10177 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10179 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10180 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10181 port_id, RTE_UINT16);
10182 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10183 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10184 cmd, "queue-region");
10185 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10186 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10188 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10189 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10192 cmdline_parse_inst_t cmd_flush_queue_region = {
10193 .f = cmd_flush_queue_region_parsed,
10195 .help_str = "set port <port_id> queue-region flush on|off"
10196 ": flush all queue region related configuration",
10198 (void *)&cmd_flush_queue_region_set,
10199 (void *)&cmd_flush_queue_region_port,
10200 (void *)&cmd_flush_queue_region_port_index,
10201 (void *)&cmd_flush_queue_region_cmd,
10202 (void *)&cmd_flush_queue_region_flush,
10203 (void *)&cmd_flush_queue_region_what,
10208 /* *** get all queue region related configuration info *** */
10209 struct cmd_show_queue_region_info {
10210 cmdline_fixed_string_t show;
10211 cmdline_fixed_string_t port;
10213 cmdline_fixed_string_t cmd;
10217 cmd_show_queue_region_info_parsed(void *parsed_result,
10218 __rte_unused struct cmdline *cl,
10219 __rte_unused void *data)
10221 struct cmd_show_queue_region_info *res = parsed_result;
10222 int ret = -ENOTSUP;
10223 #ifdef RTE_NET_I40E
10224 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10225 enum rte_pmd_i40e_queue_region_op op_type;
10228 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10231 #ifdef RTE_NET_I40E
10232 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10234 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10236 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10237 op_type, &rte_pmd_regions);
10239 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10246 printf("function not implemented or supported\n");
10249 printf("queue region config info show error: (%s)\n",
10254 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10255 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10257 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10258 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10260 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10261 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10262 port_id, RTE_UINT16);
10263 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10264 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10265 cmd, "queue-region");
10267 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10268 .f = cmd_show_queue_region_info_parsed,
10270 .help_str = "show port <port_id> queue-region"
10271 ": show all queue region related configuration info",
10273 (void *)&cmd_show_queue_region_info_get,
10274 (void *)&cmd_show_queue_region_info_port,
10275 (void *)&cmd_show_queue_region_info_port_index,
10276 (void *)&cmd_show_queue_region_info_cmd,
10281 /* *** Filters Control *** */
10283 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10285 if ((ip_addr).family == AF_INET) \
10286 (ip) = (ip_addr).addr.ipv4.s_addr; \
10288 printf("invalid parameter.\n"); \
10293 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10295 if ((ip_addr).family == AF_INET6) \
10296 rte_memcpy(&(ip), \
10297 &((ip_addr).addr.ipv6), \
10298 sizeof(struct in6_addr)); \
10300 printf("invalid parameter.\n"); \
10305 #ifdef RTE_NET_I40E
10308 str2flowtype(char *string)
10311 static const struct {
10314 } flowtype_str[] = {
10315 {"raw", RTE_ETH_FLOW_RAW},
10316 {"ipv4", RTE_ETH_FLOW_IPV4},
10317 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10318 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10319 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10320 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10321 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10322 {"ipv6", RTE_ETH_FLOW_IPV6},
10323 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10324 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10325 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10326 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10327 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10328 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10331 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10332 if (!strcmp(flowtype_str[i].str, string))
10333 return flowtype_str[i].type;
10336 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10337 return (uint16_t)atoi(string);
10339 return RTE_ETH_FLOW_UNKNOWN;
10342 /* *** deal with flow director filter *** */
10343 struct cmd_flow_director_result {
10344 cmdline_fixed_string_t flow_director_filter;
10346 cmdline_fixed_string_t mode;
10347 cmdline_fixed_string_t mode_value;
10348 cmdline_fixed_string_t ops;
10349 cmdline_fixed_string_t flow;
10350 cmdline_fixed_string_t flow_type;
10351 cmdline_fixed_string_t drop;
10352 cmdline_fixed_string_t queue;
10354 cmdline_fixed_string_t fd_id;
10355 uint32_t fd_id_value;
10356 cmdline_fixed_string_t packet;
10361 cmd_flow_director_filter_parsed(void *parsed_result,
10362 __rte_unused struct cmdline *cl,
10363 __rte_unused void *data)
10365 struct cmd_flow_director_result *res = parsed_result;
10367 struct rte_pmd_i40e_flow_type_mapping
10368 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10369 struct rte_pmd_i40e_pkt_template_conf conf;
10370 uint16_t flow_type = str2flowtype(res->flow_type);
10371 uint16_t i, port = res->port_id;
10374 memset(&conf, 0, sizeof(conf));
10376 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10377 printf("Invalid flow type specified.\n");
10380 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10384 if (mapping[flow_type].pctype == 0ULL) {
10385 printf("Invalid flow type specified.\n");
10388 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10389 if (mapping[flow_type].pctype & (1ULL << i)) {
10390 conf.input.pctype = i;
10395 conf.input.packet = open_file(res->filepath,
10396 &conf.input.length);
10397 if (!conf.input.packet)
10399 if (!strcmp(res->drop, "drop"))
10400 conf.action.behavior =
10401 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10403 conf.action.behavior =
10404 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10405 conf.action.report_status =
10406 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10407 conf.action.rx_queue = res->queue_id;
10408 conf.soft_id = res->fd_id_value;
10409 add = strcmp(res->ops, "del") ? 1 : 0;
10410 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10414 printf("flow director config error: (%s)\n",
10416 close_file(conf.input.packet);
10419 cmdline_parse_token_string_t cmd_flow_director_filter =
10420 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10421 flow_director_filter, "flow_director_filter");
10422 cmdline_parse_token_num_t cmd_flow_director_port_id =
10423 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10424 port_id, RTE_UINT16);
10425 cmdline_parse_token_string_t cmd_flow_director_ops =
10426 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10427 ops, "add#del#update");
10428 cmdline_parse_token_string_t cmd_flow_director_flow =
10429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10431 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10432 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10434 cmdline_parse_token_string_t cmd_flow_director_drop =
10435 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10437 cmdline_parse_token_string_t cmd_flow_director_queue =
10438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10440 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10441 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10442 queue_id, RTE_UINT16);
10443 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10444 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10446 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10447 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10448 fd_id_value, RTE_UINT32);
10450 cmdline_parse_token_string_t cmd_flow_director_mode =
10451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10453 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10455 mode_value, "raw");
10456 cmdline_parse_token_string_t cmd_flow_director_packet =
10457 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10459 cmdline_parse_token_string_t cmd_flow_director_filepath =
10460 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10463 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10464 .f = cmd_flow_director_filter_parsed,
10466 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10467 "director entry on NIC",
10469 (void *)&cmd_flow_director_filter,
10470 (void *)&cmd_flow_director_port_id,
10471 (void *)&cmd_flow_director_mode,
10472 (void *)&cmd_flow_director_mode_raw,
10473 (void *)&cmd_flow_director_ops,
10474 (void *)&cmd_flow_director_flow,
10475 (void *)&cmd_flow_director_flow_type,
10476 (void *)&cmd_flow_director_drop,
10477 (void *)&cmd_flow_director_queue,
10478 (void *)&cmd_flow_director_queue_id,
10479 (void *)&cmd_flow_director_fd_id,
10480 (void *)&cmd_flow_director_fd_id_value,
10481 (void *)&cmd_flow_director_packet,
10482 (void *)&cmd_flow_director_filepath,
10487 #endif /* RTE_NET_I40E */
10489 /* *** deal with flow director mask *** */
10490 struct cmd_flow_director_mask_result {
10491 cmdline_fixed_string_t flow_director_mask;
10493 cmdline_fixed_string_t mode;
10494 cmdline_fixed_string_t mode_value;
10495 cmdline_fixed_string_t vlan;
10496 uint16_t vlan_mask;
10497 cmdline_fixed_string_t src_mask;
10498 cmdline_ipaddr_t ipv4_src;
10499 cmdline_ipaddr_t ipv6_src;
10501 cmdline_fixed_string_t dst_mask;
10502 cmdline_ipaddr_t ipv4_dst;
10503 cmdline_ipaddr_t ipv6_dst;
10505 cmdline_fixed_string_t mac;
10506 uint8_t mac_addr_byte_mask;
10507 cmdline_fixed_string_t tunnel_id;
10508 uint32_t tunnel_id_mask;
10509 cmdline_fixed_string_t tunnel_type;
10510 uint8_t tunnel_type_mask;
10514 cmd_flow_director_mask_parsed(void *parsed_result,
10515 __rte_unused struct cmdline *cl,
10516 __rte_unused void *data)
10518 struct cmd_flow_director_mask_result *res = parsed_result;
10519 struct rte_eth_fdir_masks *mask;
10520 struct rte_port *port;
10522 port = &ports[res->port_id];
10523 /** Check if the port is not started **/
10524 if (port->port_status != RTE_PORT_STOPPED) {
10525 printf("Please stop port %d first\n", res->port_id);
10529 mask = &port->dev_conf.fdir_conf.mask;
10531 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10532 if (strcmp(res->mode_value, "MAC-VLAN")) {
10533 printf("Please set mode to MAC-VLAN.\n");
10537 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10538 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10539 if (strcmp(res->mode_value, "Tunnel")) {
10540 printf("Please set mode to Tunnel.\n");
10544 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10545 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10546 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10547 mask->tunnel_type_mask = res->tunnel_type_mask;
10549 if (strcmp(res->mode_value, "IP")) {
10550 printf("Please set mode to IP.\n");
10554 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10555 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10556 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10557 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10558 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10559 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10560 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10563 cmd_reconfig_device_queue(res->port_id, 1, 1);
10566 cmdline_parse_token_string_t cmd_flow_director_mask =
10567 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10568 flow_director_mask, "flow_director_mask");
10569 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10570 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10571 port_id, RTE_UINT16);
10572 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10575 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10576 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10577 vlan_mask, RTE_UINT16);
10578 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10580 src_mask, "src_mask");
10581 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10582 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10584 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10585 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10587 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10588 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10589 port_src, RTE_UINT16);
10590 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10592 dst_mask, "dst_mask");
10593 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10594 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10596 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10597 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10599 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10600 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10601 port_dst, RTE_UINT16);
10603 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10604 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10606 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10607 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10609 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10610 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10611 mode_value, "MAC-VLAN");
10612 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10613 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10614 mode_value, "Tunnel");
10615 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10616 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10618 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10619 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10620 mac_addr_byte_mask, RTE_UINT8);
10621 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10622 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10623 tunnel_type, "tunnel-type");
10624 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10625 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10626 tunnel_type_mask, RTE_UINT8);
10627 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10628 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10629 tunnel_id, "tunnel-id");
10630 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10631 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10632 tunnel_id_mask, RTE_UINT32);
10634 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10635 .f = cmd_flow_director_mask_parsed,
10637 .help_str = "flow_director_mask ... : "
10638 "Set IP mode flow director's mask on NIC",
10640 (void *)&cmd_flow_director_mask,
10641 (void *)&cmd_flow_director_mask_port_id,
10642 (void *)&cmd_flow_director_mask_mode,
10643 (void *)&cmd_flow_director_mask_mode_ip,
10644 (void *)&cmd_flow_director_mask_vlan,
10645 (void *)&cmd_flow_director_mask_vlan_value,
10646 (void *)&cmd_flow_director_mask_src,
10647 (void *)&cmd_flow_director_mask_ipv4_src,
10648 (void *)&cmd_flow_director_mask_ipv6_src,
10649 (void *)&cmd_flow_director_mask_port_src,
10650 (void *)&cmd_flow_director_mask_dst,
10651 (void *)&cmd_flow_director_mask_ipv4_dst,
10652 (void *)&cmd_flow_director_mask_ipv6_dst,
10653 (void *)&cmd_flow_director_mask_port_dst,
10658 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10659 .f = cmd_flow_director_mask_parsed,
10661 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10662 "flow director's mask on NIC",
10664 (void *)&cmd_flow_director_mask,
10665 (void *)&cmd_flow_director_mask_port_id,
10666 (void *)&cmd_flow_director_mask_mode,
10667 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10668 (void *)&cmd_flow_director_mask_vlan,
10669 (void *)&cmd_flow_director_mask_vlan_value,
10674 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10675 .f = cmd_flow_director_mask_parsed,
10677 .help_str = "flow_director_mask ... : Set tunnel mode "
10678 "flow director's mask on NIC",
10680 (void *)&cmd_flow_director_mask,
10681 (void *)&cmd_flow_director_mask_port_id,
10682 (void *)&cmd_flow_director_mask_mode,
10683 (void *)&cmd_flow_director_mask_mode_tunnel,
10684 (void *)&cmd_flow_director_mask_vlan,
10685 (void *)&cmd_flow_director_mask_vlan_value,
10686 (void *)&cmd_flow_director_mask_mac,
10687 (void *)&cmd_flow_director_mask_mac_value,
10688 (void *)&cmd_flow_director_mask_tunnel_type,
10689 (void *)&cmd_flow_director_mask_tunnel_type_value,
10690 (void *)&cmd_flow_director_mask_tunnel_id,
10691 (void *)&cmd_flow_director_mask_tunnel_id_value,
10696 /* *** deal with flow director flexible payload configuration *** */
10697 struct cmd_flow_director_flexpayload_result {
10698 cmdline_fixed_string_t flow_director_flexpayload;
10700 cmdline_fixed_string_t payload_layer;
10701 cmdline_fixed_string_t payload_cfg;
10705 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10708 const char *p, *p0 = q_arg;
10710 unsigned long int_fld;
10711 char *str_fld[max_num];
10716 p = strchr(p0, '(');
10720 p0 = strchr(p, ')');
10725 if (size >= sizeof(s))
10728 snprintf(s, sizeof(s), "%.*s", size, p);
10729 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10730 if (ret < 0 || ret > max_num)
10732 for (i = 0; i < ret; i++) {
10734 int_fld = strtoul(str_fld[i], &end, 0);
10735 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10737 offsets[i] = (uint16_t)int_fld;
10743 cmd_flow_director_flxpld_parsed(void *parsed_result,
10744 __rte_unused struct cmdline *cl,
10745 __rte_unused void *data)
10747 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10748 struct rte_eth_flex_payload_cfg flex_cfg;
10749 struct rte_port *port;
10752 port = &ports[res->port_id];
10753 /** Check if the port is not started **/
10754 if (port->port_status != RTE_PORT_STOPPED) {
10755 printf("Please stop port %d first\n", res->port_id);
10759 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10761 if (!strcmp(res->payload_layer, "raw"))
10762 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10763 else if (!strcmp(res->payload_layer, "l2"))
10764 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10765 else if (!strcmp(res->payload_layer, "l3"))
10766 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10767 else if (!strcmp(res->payload_layer, "l4"))
10768 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10770 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10771 RTE_ETH_FDIR_MAX_FLEXLEN);
10773 printf("error: Cannot parse flex payload input.\n");
10777 fdir_set_flex_payload(res->port_id, &flex_cfg);
10778 cmd_reconfig_device_queue(res->port_id, 1, 1);
10781 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10782 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10783 flow_director_flexpayload,
10784 "flow_director_flex_payload");
10785 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10786 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10787 port_id, RTE_UINT16);
10788 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10789 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10790 payload_layer, "raw#l2#l3#l4");
10791 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10792 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10793 payload_cfg, NULL);
10795 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10796 .f = cmd_flow_director_flxpld_parsed,
10798 .help_str = "flow_director_flexpayload ... : "
10799 "Set flow director's flex payload on NIC",
10801 (void *)&cmd_flow_director_flexpayload,
10802 (void *)&cmd_flow_director_flexpayload_port_id,
10803 (void *)&cmd_flow_director_flexpayload_payload_layer,
10804 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10809 /* Generic flow interface command. */
10810 extern cmdline_parse_inst_t cmd_flow;
10812 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10813 struct cmd_mcast_addr_result {
10814 cmdline_fixed_string_t mcast_addr_cmd;
10815 cmdline_fixed_string_t what;
10817 struct rte_ether_addr mc_addr;
10820 static void cmd_mcast_addr_parsed(void *parsed_result,
10821 __rte_unused struct cmdline *cl,
10822 __rte_unused void *data)
10824 struct cmd_mcast_addr_result *res = parsed_result;
10826 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10827 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10828 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10829 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10830 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10833 if (strcmp(res->what, "add") == 0)
10834 mcast_addr_add(res->port_num, &res->mc_addr);
10836 mcast_addr_remove(res->port_num, &res->mc_addr);
10839 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10840 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10841 mcast_addr_cmd, "mcast_addr");
10842 cmdline_parse_token_string_t cmd_mcast_addr_what =
10843 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10845 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10846 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10848 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10849 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10851 cmdline_parse_inst_t cmd_mcast_addr = {
10852 .f = cmd_mcast_addr_parsed,
10854 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10855 "Add/Remove multicast MAC address on port_id",
10857 (void *)&cmd_mcast_addr_cmd,
10858 (void *)&cmd_mcast_addr_what,
10859 (void *)&cmd_mcast_addr_portnum,
10860 (void *)&cmd_mcast_addr_addr,
10865 /* vf vlan anti spoof configuration */
10867 /* Common result structure for vf vlan anti spoof */
10868 struct cmd_vf_vlan_anti_spoof_result {
10869 cmdline_fixed_string_t set;
10870 cmdline_fixed_string_t vf;
10871 cmdline_fixed_string_t vlan;
10872 cmdline_fixed_string_t antispoof;
10875 cmdline_fixed_string_t on_off;
10878 /* Common CLI fields for vf vlan anti spoof enable disable */
10879 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10880 TOKEN_STRING_INITIALIZER
10881 (struct cmd_vf_vlan_anti_spoof_result,
10883 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10884 TOKEN_STRING_INITIALIZER
10885 (struct cmd_vf_vlan_anti_spoof_result,
10887 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10888 TOKEN_STRING_INITIALIZER
10889 (struct cmd_vf_vlan_anti_spoof_result,
10891 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10892 TOKEN_STRING_INITIALIZER
10893 (struct cmd_vf_vlan_anti_spoof_result,
10894 antispoof, "antispoof");
10895 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10896 TOKEN_NUM_INITIALIZER
10897 (struct cmd_vf_vlan_anti_spoof_result,
10898 port_id, RTE_UINT16);
10899 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10900 TOKEN_NUM_INITIALIZER
10901 (struct cmd_vf_vlan_anti_spoof_result,
10902 vf_id, RTE_UINT32);
10903 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10904 TOKEN_STRING_INITIALIZER
10905 (struct cmd_vf_vlan_anti_spoof_result,
10909 cmd_set_vf_vlan_anti_spoof_parsed(
10910 void *parsed_result,
10911 __rte_unused struct cmdline *cl,
10912 __rte_unused void *data)
10914 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10915 int ret = -ENOTSUP;
10917 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10919 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10922 #ifdef RTE_NET_IXGBE
10923 if (ret == -ENOTSUP)
10924 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10925 res->vf_id, is_on);
10927 #ifdef RTE_NET_I40E
10928 if (ret == -ENOTSUP)
10929 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10930 res->vf_id, is_on);
10932 #ifdef RTE_NET_BNXT
10933 if (ret == -ENOTSUP)
10934 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10935 res->vf_id, is_on);
10942 printf("invalid vf_id %d\n", res->vf_id);
10945 printf("invalid port_id %d\n", res->port_id);
10948 printf("function not implemented\n");
10951 printf("programming error: (%s)\n", strerror(-ret));
10955 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10956 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10958 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10960 (void *)&cmd_vf_vlan_anti_spoof_set,
10961 (void *)&cmd_vf_vlan_anti_spoof_vf,
10962 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10963 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10964 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10965 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10966 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10971 /* vf mac anti spoof configuration */
10973 /* Common result structure for vf mac anti spoof */
10974 struct cmd_vf_mac_anti_spoof_result {
10975 cmdline_fixed_string_t set;
10976 cmdline_fixed_string_t vf;
10977 cmdline_fixed_string_t mac;
10978 cmdline_fixed_string_t antispoof;
10981 cmdline_fixed_string_t on_off;
10984 /* Common CLI fields for vf mac anti spoof enable disable */
10985 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10986 TOKEN_STRING_INITIALIZER
10987 (struct cmd_vf_mac_anti_spoof_result,
10989 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10990 TOKEN_STRING_INITIALIZER
10991 (struct cmd_vf_mac_anti_spoof_result,
10993 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10994 TOKEN_STRING_INITIALIZER
10995 (struct cmd_vf_mac_anti_spoof_result,
10997 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10998 TOKEN_STRING_INITIALIZER
10999 (struct cmd_vf_mac_anti_spoof_result,
11000 antispoof, "antispoof");
11001 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11002 TOKEN_NUM_INITIALIZER
11003 (struct cmd_vf_mac_anti_spoof_result,
11004 port_id, RTE_UINT16);
11005 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11006 TOKEN_NUM_INITIALIZER
11007 (struct cmd_vf_mac_anti_spoof_result,
11008 vf_id, RTE_UINT32);
11009 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11010 TOKEN_STRING_INITIALIZER
11011 (struct cmd_vf_mac_anti_spoof_result,
11015 cmd_set_vf_mac_anti_spoof_parsed(
11016 void *parsed_result,
11017 __rte_unused struct cmdline *cl,
11018 __rte_unused void *data)
11020 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11021 int ret = -ENOTSUP;
11023 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11025 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11028 #ifdef RTE_NET_IXGBE
11029 if (ret == -ENOTSUP)
11030 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11031 res->vf_id, is_on);
11033 #ifdef RTE_NET_I40E
11034 if (ret == -ENOTSUP)
11035 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11036 res->vf_id, is_on);
11038 #ifdef RTE_NET_BNXT
11039 if (ret == -ENOTSUP)
11040 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11041 res->vf_id, is_on);
11048 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11051 printf("invalid port_id %d\n", res->port_id);
11054 printf("function not implemented\n");
11057 printf("programming error: (%s)\n", strerror(-ret));
11061 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11062 .f = cmd_set_vf_mac_anti_spoof_parsed,
11064 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11066 (void *)&cmd_vf_mac_anti_spoof_set,
11067 (void *)&cmd_vf_mac_anti_spoof_vf,
11068 (void *)&cmd_vf_mac_anti_spoof_mac,
11069 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11070 (void *)&cmd_vf_mac_anti_spoof_port_id,
11071 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11072 (void *)&cmd_vf_mac_anti_spoof_on_off,
11077 /* vf vlan strip queue configuration */
11079 /* Common result structure for vf mac anti spoof */
11080 struct cmd_vf_vlan_stripq_result {
11081 cmdline_fixed_string_t set;
11082 cmdline_fixed_string_t vf;
11083 cmdline_fixed_string_t vlan;
11084 cmdline_fixed_string_t stripq;
11087 cmdline_fixed_string_t on_off;
11090 /* Common CLI fields for vf vlan strip enable disable */
11091 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11092 TOKEN_STRING_INITIALIZER
11093 (struct cmd_vf_vlan_stripq_result,
11095 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11096 TOKEN_STRING_INITIALIZER
11097 (struct cmd_vf_vlan_stripq_result,
11099 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11100 TOKEN_STRING_INITIALIZER
11101 (struct cmd_vf_vlan_stripq_result,
11103 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11104 TOKEN_STRING_INITIALIZER
11105 (struct cmd_vf_vlan_stripq_result,
11107 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11108 TOKEN_NUM_INITIALIZER
11109 (struct cmd_vf_vlan_stripq_result,
11110 port_id, RTE_UINT16);
11111 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11112 TOKEN_NUM_INITIALIZER
11113 (struct cmd_vf_vlan_stripq_result,
11114 vf_id, RTE_UINT16);
11115 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11116 TOKEN_STRING_INITIALIZER
11117 (struct cmd_vf_vlan_stripq_result,
11121 cmd_set_vf_vlan_stripq_parsed(
11122 void *parsed_result,
11123 __rte_unused struct cmdline *cl,
11124 __rte_unused void *data)
11126 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11127 int ret = -ENOTSUP;
11129 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11131 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11134 #ifdef RTE_NET_IXGBE
11135 if (ret == -ENOTSUP)
11136 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11137 res->vf_id, is_on);
11139 #ifdef RTE_NET_I40E
11140 if (ret == -ENOTSUP)
11141 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11142 res->vf_id, is_on);
11144 #ifdef RTE_NET_BNXT
11145 if (ret == -ENOTSUP)
11146 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11147 res->vf_id, is_on);
11154 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11157 printf("invalid port_id %d\n", res->port_id);
11160 printf("function not implemented\n");
11163 printf("programming error: (%s)\n", strerror(-ret));
11167 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11168 .f = cmd_set_vf_vlan_stripq_parsed,
11170 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11172 (void *)&cmd_vf_vlan_stripq_set,
11173 (void *)&cmd_vf_vlan_stripq_vf,
11174 (void *)&cmd_vf_vlan_stripq_vlan,
11175 (void *)&cmd_vf_vlan_stripq_stripq,
11176 (void *)&cmd_vf_vlan_stripq_port_id,
11177 (void *)&cmd_vf_vlan_stripq_vf_id,
11178 (void *)&cmd_vf_vlan_stripq_on_off,
11183 /* vf vlan insert configuration */
11185 /* Common result structure for vf vlan insert */
11186 struct cmd_vf_vlan_insert_result {
11187 cmdline_fixed_string_t set;
11188 cmdline_fixed_string_t vf;
11189 cmdline_fixed_string_t vlan;
11190 cmdline_fixed_string_t insert;
11196 /* Common CLI fields for vf vlan insert enable disable */
11197 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11198 TOKEN_STRING_INITIALIZER
11199 (struct cmd_vf_vlan_insert_result,
11201 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11202 TOKEN_STRING_INITIALIZER
11203 (struct cmd_vf_vlan_insert_result,
11205 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11206 TOKEN_STRING_INITIALIZER
11207 (struct cmd_vf_vlan_insert_result,
11209 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11210 TOKEN_STRING_INITIALIZER
11211 (struct cmd_vf_vlan_insert_result,
11213 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11214 TOKEN_NUM_INITIALIZER
11215 (struct cmd_vf_vlan_insert_result,
11216 port_id, RTE_UINT16);
11217 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11218 TOKEN_NUM_INITIALIZER
11219 (struct cmd_vf_vlan_insert_result,
11220 vf_id, RTE_UINT16);
11221 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11222 TOKEN_NUM_INITIALIZER
11223 (struct cmd_vf_vlan_insert_result,
11224 vlan_id, RTE_UINT16);
11227 cmd_set_vf_vlan_insert_parsed(
11228 void *parsed_result,
11229 __rte_unused struct cmdline *cl,
11230 __rte_unused void *data)
11232 struct cmd_vf_vlan_insert_result *res = parsed_result;
11233 int ret = -ENOTSUP;
11235 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11238 #ifdef RTE_NET_IXGBE
11239 if (ret == -ENOTSUP)
11240 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11243 #ifdef RTE_NET_I40E
11244 if (ret == -ENOTSUP)
11245 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11248 #ifdef RTE_NET_BNXT
11249 if (ret == -ENOTSUP)
11250 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11258 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11261 printf("invalid port_id %d\n", res->port_id);
11264 printf("function not implemented\n");
11267 printf("programming error: (%s)\n", strerror(-ret));
11271 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11272 .f = cmd_set_vf_vlan_insert_parsed,
11274 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11276 (void *)&cmd_vf_vlan_insert_set,
11277 (void *)&cmd_vf_vlan_insert_vf,
11278 (void *)&cmd_vf_vlan_insert_vlan,
11279 (void *)&cmd_vf_vlan_insert_insert,
11280 (void *)&cmd_vf_vlan_insert_port_id,
11281 (void *)&cmd_vf_vlan_insert_vf_id,
11282 (void *)&cmd_vf_vlan_insert_vlan_id,
11287 /* tx loopback configuration */
11289 /* Common result structure for tx loopback */
11290 struct cmd_tx_loopback_result {
11291 cmdline_fixed_string_t set;
11292 cmdline_fixed_string_t tx;
11293 cmdline_fixed_string_t loopback;
11295 cmdline_fixed_string_t on_off;
11298 /* Common CLI fields for tx loopback enable disable */
11299 cmdline_parse_token_string_t cmd_tx_loopback_set =
11300 TOKEN_STRING_INITIALIZER
11301 (struct cmd_tx_loopback_result,
11303 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11304 TOKEN_STRING_INITIALIZER
11305 (struct cmd_tx_loopback_result,
11307 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11308 TOKEN_STRING_INITIALIZER
11309 (struct cmd_tx_loopback_result,
11310 loopback, "loopback");
11311 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11312 TOKEN_NUM_INITIALIZER
11313 (struct cmd_tx_loopback_result,
11314 port_id, RTE_UINT16);
11315 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11316 TOKEN_STRING_INITIALIZER
11317 (struct cmd_tx_loopback_result,
11321 cmd_set_tx_loopback_parsed(
11322 void *parsed_result,
11323 __rte_unused struct cmdline *cl,
11324 __rte_unused void *data)
11326 struct cmd_tx_loopback_result *res = parsed_result;
11327 int ret = -ENOTSUP;
11329 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11331 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11334 #ifdef RTE_NET_IXGBE
11335 if (ret == -ENOTSUP)
11336 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11338 #ifdef RTE_NET_I40E
11339 if (ret == -ENOTSUP)
11340 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11342 #ifdef RTE_NET_BNXT
11343 if (ret == -ENOTSUP)
11344 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11346 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11347 if (ret == -ENOTSUP)
11348 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11355 printf("invalid is_on %d\n", is_on);
11358 printf("invalid port_id %d\n", res->port_id);
11361 printf("function not implemented\n");
11364 printf("programming error: (%s)\n", strerror(-ret));
11368 cmdline_parse_inst_t cmd_set_tx_loopback = {
11369 .f = cmd_set_tx_loopback_parsed,
11371 .help_str = "set tx loopback <port_id> on|off",
11373 (void *)&cmd_tx_loopback_set,
11374 (void *)&cmd_tx_loopback_tx,
11375 (void *)&cmd_tx_loopback_loopback,
11376 (void *)&cmd_tx_loopback_port_id,
11377 (void *)&cmd_tx_loopback_on_off,
11382 /* all queues drop enable configuration */
11384 /* Common result structure for all queues drop enable */
11385 struct cmd_all_queues_drop_en_result {
11386 cmdline_fixed_string_t set;
11387 cmdline_fixed_string_t all;
11388 cmdline_fixed_string_t queues;
11389 cmdline_fixed_string_t drop;
11391 cmdline_fixed_string_t on_off;
11394 /* Common CLI fields for tx loopback enable disable */
11395 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11396 TOKEN_STRING_INITIALIZER
11397 (struct cmd_all_queues_drop_en_result,
11399 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11400 TOKEN_STRING_INITIALIZER
11401 (struct cmd_all_queues_drop_en_result,
11403 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11404 TOKEN_STRING_INITIALIZER
11405 (struct cmd_all_queues_drop_en_result,
11407 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11408 TOKEN_STRING_INITIALIZER
11409 (struct cmd_all_queues_drop_en_result,
11411 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11412 TOKEN_NUM_INITIALIZER
11413 (struct cmd_all_queues_drop_en_result,
11414 port_id, RTE_UINT16);
11415 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11416 TOKEN_STRING_INITIALIZER
11417 (struct cmd_all_queues_drop_en_result,
11421 cmd_set_all_queues_drop_en_parsed(
11422 void *parsed_result,
11423 __rte_unused struct cmdline *cl,
11424 __rte_unused void *data)
11426 struct cmd_all_queues_drop_en_result *res = parsed_result;
11427 int ret = -ENOTSUP;
11428 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11430 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11433 #ifdef RTE_NET_IXGBE
11434 if (ret == -ENOTSUP)
11435 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11437 #ifdef RTE_NET_BNXT
11438 if (ret == -ENOTSUP)
11439 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11445 printf("invalid is_on %d\n", is_on);
11448 printf("invalid port_id %d\n", res->port_id);
11451 printf("function not implemented\n");
11454 printf("programming error: (%s)\n", strerror(-ret));
11458 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11459 .f = cmd_set_all_queues_drop_en_parsed,
11461 .help_str = "set all queues drop <port_id> on|off",
11463 (void *)&cmd_all_queues_drop_en_set,
11464 (void *)&cmd_all_queues_drop_en_all,
11465 (void *)&cmd_all_queues_drop_en_queues,
11466 (void *)&cmd_all_queues_drop_en_drop,
11467 (void *)&cmd_all_queues_drop_en_port_id,
11468 (void *)&cmd_all_queues_drop_en_on_off,
11473 /* vf split drop enable configuration */
11475 /* Common result structure for vf split drop enable */
11476 struct cmd_vf_split_drop_en_result {
11477 cmdline_fixed_string_t set;
11478 cmdline_fixed_string_t vf;
11479 cmdline_fixed_string_t split;
11480 cmdline_fixed_string_t drop;
11483 cmdline_fixed_string_t on_off;
11486 /* Common CLI fields for vf split drop enable disable */
11487 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11488 TOKEN_STRING_INITIALIZER
11489 (struct cmd_vf_split_drop_en_result,
11491 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11492 TOKEN_STRING_INITIALIZER
11493 (struct cmd_vf_split_drop_en_result,
11495 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11496 TOKEN_STRING_INITIALIZER
11497 (struct cmd_vf_split_drop_en_result,
11499 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11500 TOKEN_STRING_INITIALIZER
11501 (struct cmd_vf_split_drop_en_result,
11503 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11504 TOKEN_NUM_INITIALIZER
11505 (struct cmd_vf_split_drop_en_result,
11506 port_id, RTE_UINT16);
11507 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11508 TOKEN_NUM_INITIALIZER
11509 (struct cmd_vf_split_drop_en_result,
11510 vf_id, RTE_UINT16);
11511 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11512 TOKEN_STRING_INITIALIZER
11513 (struct cmd_vf_split_drop_en_result,
11517 cmd_set_vf_split_drop_en_parsed(
11518 void *parsed_result,
11519 __rte_unused struct cmdline *cl,
11520 __rte_unused void *data)
11522 struct cmd_vf_split_drop_en_result *res = parsed_result;
11523 int ret = -ENOTSUP;
11524 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11526 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11529 #ifdef RTE_NET_IXGBE
11530 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11537 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11540 printf("invalid port_id %d\n", res->port_id);
11543 printf("not supported on port %d\n", res->port_id);
11546 printf("programming error: (%s)\n", strerror(-ret));
11550 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11551 .f = cmd_set_vf_split_drop_en_parsed,
11553 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11555 (void *)&cmd_vf_split_drop_en_set,
11556 (void *)&cmd_vf_split_drop_en_vf,
11557 (void *)&cmd_vf_split_drop_en_split,
11558 (void *)&cmd_vf_split_drop_en_drop,
11559 (void *)&cmd_vf_split_drop_en_port_id,
11560 (void *)&cmd_vf_split_drop_en_vf_id,
11561 (void *)&cmd_vf_split_drop_en_on_off,
11566 /* vf mac address configuration */
11568 /* Common result structure for vf mac address */
11569 struct cmd_set_vf_mac_addr_result {
11570 cmdline_fixed_string_t set;
11571 cmdline_fixed_string_t vf;
11572 cmdline_fixed_string_t mac;
11573 cmdline_fixed_string_t addr;
11576 struct rte_ether_addr mac_addr;
11580 /* Common CLI fields for vf split drop enable disable */
11581 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11582 TOKEN_STRING_INITIALIZER
11583 (struct cmd_set_vf_mac_addr_result,
11585 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11586 TOKEN_STRING_INITIALIZER
11587 (struct cmd_set_vf_mac_addr_result,
11589 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11590 TOKEN_STRING_INITIALIZER
11591 (struct cmd_set_vf_mac_addr_result,
11593 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11594 TOKEN_STRING_INITIALIZER
11595 (struct cmd_set_vf_mac_addr_result,
11597 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11598 TOKEN_NUM_INITIALIZER
11599 (struct cmd_set_vf_mac_addr_result,
11600 port_id, RTE_UINT16);
11601 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11602 TOKEN_NUM_INITIALIZER
11603 (struct cmd_set_vf_mac_addr_result,
11604 vf_id, RTE_UINT16);
11605 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11606 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11610 cmd_set_vf_mac_addr_parsed(
11611 void *parsed_result,
11612 __rte_unused struct cmdline *cl,
11613 __rte_unused void *data)
11615 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11616 int ret = -ENOTSUP;
11618 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11621 #ifdef RTE_NET_IXGBE
11622 if (ret == -ENOTSUP)
11623 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11626 #ifdef RTE_NET_I40E
11627 if (ret == -ENOTSUP)
11628 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11631 #ifdef RTE_NET_BNXT
11632 if (ret == -ENOTSUP)
11633 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11641 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11644 printf("invalid port_id %d\n", res->port_id);
11647 printf("function not implemented\n");
11650 printf("programming error: (%s)\n", strerror(-ret));
11654 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11655 .f = cmd_set_vf_mac_addr_parsed,
11657 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11659 (void *)&cmd_set_vf_mac_addr_set,
11660 (void *)&cmd_set_vf_mac_addr_vf,
11661 (void *)&cmd_set_vf_mac_addr_mac,
11662 (void *)&cmd_set_vf_mac_addr_addr,
11663 (void *)&cmd_set_vf_mac_addr_port_id,
11664 (void *)&cmd_set_vf_mac_addr_vf_id,
11665 (void *)&cmd_set_vf_mac_addr_mac_addr,
11670 /* MACsec configuration */
11672 /* Common result structure for MACsec offload enable */
11673 struct cmd_macsec_offload_on_result {
11674 cmdline_fixed_string_t set;
11675 cmdline_fixed_string_t macsec;
11676 cmdline_fixed_string_t offload;
11678 cmdline_fixed_string_t on;
11679 cmdline_fixed_string_t encrypt;
11680 cmdline_fixed_string_t en_on_off;
11681 cmdline_fixed_string_t replay_protect;
11682 cmdline_fixed_string_t rp_on_off;
11685 /* Common CLI fields for MACsec offload disable */
11686 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11687 TOKEN_STRING_INITIALIZER
11688 (struct cmd_macsec_offload_on_result,
11690 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11691 TOKEN_STRING_INITIALIZER
11692 (struct cmd_macsec_offload_on_result,
11694 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11695 TOKEN_STRING_INITIALIZER
11696 (struct cmd_macsec_offload_on_result,
11697 offload, "offload");
11698 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11699 TOKEN_NUM_INITIALIZER
11700 (struct cmd_macsec_offload_on_result,
11701 port_id, RTE_UINT16);
11702 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11703 TOKEN_STRING_INITIALIZER
11704 (struct cmd_macsec_offload_on_result,
11706 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11707 TOKEN_STRING_INITIALIZER
11708 (struct cmd_macsec_offload_on_result,
11709 encrypt, "encrypt");
11710 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11711 TOKEN_STRING_INITIALIZER
11712 (struct cmd_macsec_offload_on_result,
11713 en_on_off, "on#off");
11714 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11715 TOKEN_STRING_INITIALIZER
11716 (struct cmd_macsec_offload_on_result,
11717 replay_protect, "replay-protect");
11718 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11719 TOKEN_STRING_INITIALIZER
11720 (struct cmd_macsec_offload_on_result,
11721 rp_on_off, "on#off");
11724 cmd_set_macsec_offload_on_parsed(
11725 void *parsed_result,
11726 __rte_unused struct cmdline *cl,
11727 __rte_unused void *data)
11729 struct cmd_macsec_offload_on_result *res = parsed_result;
11730 int ret = -ENOTSUP;
11731 portid_t port_id = res->port_id;
11732 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11733 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11734 struct rte_eth_dev_info dev_info;
11736 if (port_id_is_invalid(port_id, ENABLED_WARN))
11738 if (!port_is_stopped(port_id)) {
11739 printf("Please stop port %d first\n", port_id);
11743 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11747 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11748 #ifdef RTE_NET_IXGBE
11749 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11757 ports[port_id].dev_conf.txmode.offloads |=
11758 DEV_TX_OFFLOAD_MACSEC_INSERT;
11759 cmd_reconfig_device_queue(port_id, 1, 1);
11762 printf("invalid port_id %d\n", port_id);
11765 printf("not supported on port %d\n", port_id);
11768 printf("programming error: (%s)\n", strerror(-ret));
11772 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11773 .f = cmd_set_macsec_offload_on_parsed,
11775 .help_str = "set macsec offload <port_id> on "
11776 "encrypt on|off replay-protect on|off",
11778 (void *)&cmd_macsec_offload_on_set,
11779 (void *)&cmd_macsec_offload_on_macsec,
11780 (void *)&cmd_macsec_offload_on_offload,
11781 (void *)&cmd_macsec_offload_on_port_id,
11782 (void *)&cmd_macsec_offload_on_on,
11783 (void *)&cmd_macsec_offload_on_encrypt,
11784 (void *)&cmd_macsec_offload_on_en_on_off,
11785 (void *)&cmd_macsec_offload_on_replay_protect,
11786 (void *)&cmd_macsec_offload_on_rp_on_off,
11791 /* Common result structure for MACsec offload disable */
11792 struct cmd_macsec_offload_off_result {
11793 cmdline_fixed_string_t set;
11794 cmdline_fixed_string_t macsec;
11795 cmdline_fixed_string_t offload;
11797 cmdline_fixed_string_t off;
11800 /* Common CLI fields for MACsec offload disable */
11801 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11802 TOKEN_STRING_INITIALIZER
11803 (struct cmd_macsec_offload_off_result,
11805 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11806 TOKEN_STRING_INITIALIZER
11807 (struct cmd_macsec_offload_off_result,
11809 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11810 TOKEN_STRING_INITIALIZER
11811 (struct cmd_macsec_offload_off_result,
11812 offload, "offload");
11813 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11814 TOKEN_NUM_INITIALIZER
11815 (struct cmd_macsec_offload_off_result,
11816 port_id, RTE_UINT16);
11817 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11818 TOKEN_STRING_INITIALIZER
11819 (struct cmd_macsec_offload_off_result,
11823 cmd_set_macsec_offload_off_parsed(
11824 void *parsed_result,
11825 __rte_unused struct cmdline *cl,
11826 __rte_unused void *data)
11828 struct cmd_macsec_offload_off_result *res = parsed_result;
11829 int ret = -ENOTSUP;
11830 struct rte_eth_dev_info dev_info;
11831 portid_t port_id = res->port_id;
11833 if (port_id_is_invalid(port_id, ENABLED_WARN))
11835 if (!port_is_stopped(port_id)) {
11836 printf("Please stop port %d first\n", port_id);
11840 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11844 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11845 #ifdef RTE_NET_IXGBE
11846 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11851 ports[port_id].dev_conf.txmode.offloads &=
11852 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11853 cmd_reconfig_device_queue(port_id, 1, 1);
11856 printf("invalid port_id %d\n", port_id);
11859 printf("not supported on port %d\n", port_id);
11862 printf("programming error: (%s)\n", strerror(-ret));
11866 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11867 .f = cmd_set_macsec_offload_off_parsed,
11869 .help_str = "set macsec offload <port_id> off",
11871 (void *)&cmd_macsec_offload_off_set,
11872 (void *)&cmd_macsec_offload_off_macsec,
11873 (void *)&cmd_macsec_offload_off_offload,
11874 (void *)&cmd_macsec_offload_off_port_id,
11875 (void *)&cmd_macsec_offload_off_off,
11880 /* Common result structure for MACsec secure connection configure */
11881 struct cmd_macsec_sc_result {
11882 cmdline_fixed_string_t set;
11883 cmdline_fixed_string_t macsec;
11884 cmdline_fixed_string_t sc;
11885 cmdline_fixed_string_t tx_rx;
11887 struct rte_ether_addr mac;
11891 /* Common CLI fields for MACsec secure connection configure */
11892 cmdline_parse_token_string_t cmd_macsec_sc_set =
11893 TOKEN_STRING_INITIALIZER
11894 (struct cmd_macsec_sc_result,
11896 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11897 TOKEN_STRING_INITIALIZER
11898 (struct cmd_macsec_sc_result,
11900 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11901 TOKEN_STRING_INITIALIZER
11902 (struct cmd_macsec_sc_result,
11904 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11905 TOKEN_STRING_INITIALIZER
11906 (struct cmd_macsec_sc_result,
11908 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11909 TOKEN_NUM_INITIALIZER
11910 (struct cmd_macsec_sc_result,
11911 port_id, RTE_UINT16);
11912 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11913 TOKEN_ETHERADDR_INITIALIZER
11914 (struct cmd_macsec_sc_result,
11916 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11917 TOKEN_NUM_INITIALIZER
11918 (struct cmd_macsec_sc_result,
11922 cmd_set_macsec_sc_parsed(
11923 void *parsed_result,
11924 __rte_unused struct cmdline *cl,
11925 __rte_unused void *data)
11927 struct cmd_macsec_sc_result *res = parsed_result;
11928 int ret = -ENOTSUP;
11929 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11931 #ifdef RTE_NET_IXGBE
11933 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11934 res->mac.addr_bytes) :
11935 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11936 res->mac.addr_bytes, res->pi);
11938 RTE_SET_USED(is_tx);
11944 printf("invalid port_id %d\n", res->port_id);
11947 printf("not supported on port %d\n", res->port_id);
11950 printf("programming error: (%s)\n", strerror(-ret));
11954 cmdline_parse_inst_t cmd_set_macsec_sc = {
11955 .f = cmd_set_macsec_sc_parsed,
11957 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11959 (void *)&cmd_macsec_sc_set,
11960 (void *)&cmd_macsec_sc_macsec,
11961 (void *)&cmd_macsec_sc_sc,
11962 (void *)&cmd_macsec_sc_tx_rx,
11963 (void *)&cmd_macsec_sc_port_id,
11964 (void *)&cmd_macsec_sc_mac,
11965 (void *)&cmd_macsec_sc_pi,
11970 /* Common result structure for MACsec secure connection configure */
11971 struct cmd_macsec_sa_result {
11972 cmdline_fixed_string_t set;
11973 cmdline_fixed_string_t macsec;
11974 cmdline_fixed_string_t sa;
11975 cmdline_fixed_string_t tx_rx;
11980 cmdline_fixed_string_t key;
11983 /* Common CLI fields for MACsec secure connection configure */
11984 cmdline_parse_token_string_t cmd_macsec_sa_set =
11985 TOKEN_STRING_INITIALIZER
11986 (struct cmd_macsec_sa_result,
11988 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11989 TOKEN_STRING_INITIALIZER
11990 (struct cmd_macsec_sa_result,
11992 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11993 TOKEN_STRING_INITIALIZER
11994 (struct cmd_macsec_sa_result,
11996 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11997 TOKEN_STRING_INITIALIZER
11998 (struct cmd_macsec_sa_result,
12000 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12001 TOKEN_NUM_INITIALIZER
12002 (struct cmd_macsec_sa_result,
12003 port_id, RTE_UINT16);
12004 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12005 TOKEN_NUM_INITIALIZER
12006 (struct cmd_macsec_sa_result,
12008 cmdline_parse_token_num_t cmd_macsec_sa_an =
12009 TOKEN_NUM_INITIALIZER
12010 (struct cmd_macsec_sa_result,
12012 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12013 TOKEN_NUM_INITIALIZER
12014 (struct cmd_macsec_sa_result,
12016 cmdline_parse_token_string_t cmd_macsec_sa_key =
12017 TOKEN_STRING_INITIALIZER
12018 (struct cmd_macsec_sa_result,
12022 cmd_set_macsec_sa_parsed(
12023 void *parsed_result,
12024 __rte_unused struct cmdline *cl,
12025 __rte_unused void *data)
12027 struct cmd_macsec_sa_result *res = parsed_result;
12028 int ret = -ENOTSUP;
12029 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12030 uint8_t key[16] = { 0 };
12036 key_len = strlen(res->key) / 2;
12040 for (i = 0; i < key_len; i++) {
12041 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12044 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12047 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12050 #ifdef RTE_NET_IXGBE
12052 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12053 res->idx, res->an, res->pn, key) :
12054 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12055 res->idx, res->an, res->pn, key);
12057 RTE_SET_USED(is_tx);
12064 printf("invalid idx %d or an %d\n", res->idx, res->an);
12067 printf("invalid port_id %d\n", res->port_id);
12070 printf("not supported on port %d\n", res->port_id);
12073 printf("programming error: (%s)\n", strerror(-ret));
12077 cmdline_parse_inst_t cmd_set_macsec_sa = {
12078 .f = cmd_set_macsec_sa_parsed,
12080 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12082 (void *)&cmd_macsec_sa_set,
12083 (void *)&cmd_macsec_sa_macsec,
12084 (void *)&cmd_macsec_sa_sa,
12085 (void *)&cmd_macsec_sa_tx_rx,
12086 (void *)&cmd_macsec_sa_port_id,
12087 (void *)&cmd_macsec_sa_idx,
12088 (void *)&cmd_macsec_sa_an,
12089 (void *)&cmd_macsec_sa_pn,
12090 (void *)&cmd_macsec_sa_key,
12095 /* VF unicast promiscuous mode configuration */
12097 /* Common result structure for VF unicast promiscuous mode */
12098 struct cmd_vf_promisc_result {
12099 cmdline_fixed_string_t set;
12100 cmdline_fixed_string_t vf;
12101 cmdline_fixed_string_t promisc;
12104 cmdline_fixed_string_t on_off;
12107 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12108 cmdline_parse_token_string_t cmd_vf_promisc_set =
12109 TOKEN_STRING_INITIALIZER
12110 (struct cmd_vf_promisc_result,
12112 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12113 TOKEN_STRING_INITIALIZER
12114 (struct cmd_vf_promisc_result,
12116 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12117 TOKEN_STRING_INITIALIZER
12118 (struct cmd_vf_promisc_result,
12119 promisc, "promisc");
12120 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12121 TOKEN_NUM_INITIALIZER
12122 (struct cmd_vf_promisc_result,
12123 port_id, RTE_UINT16);
12124 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12125 TOKEN_NUM_INITIALIZER
12126 (struct cmd_vf_promisc_result,
12127 vf_id, RTE_UINT32);
12128 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12129 TOKEN_STRING_INITIALIZER
12130 (struct cmd_vf_promisc_result,
12134 cmd_set_vf_promisc_parsed(
12135 void *parsed_result,
12136 __rte_unused struct cmdline *cl,
12137 __rte_unused void *data)
12139 struct cmd_vf_promisc_result *res = parsed_result;
12140 int ret = -ENOTSUP;
12142 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12144 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12147 #ifdef RTE_NET_I40E
12148 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12149 res->vf_id, is_on);
12156 printf("invalid vf_id %d\n", res->vf_id);
12159 printf("invalid port_id %d\n", res->port_id);
12162 printf("function not implemented\n");
12165 printf("programming error: (%s)\n", strerror(-ret));
12169 cmdline_parse_inst_t cmd_set_vf_promisc = {
12170 .f = cmd_set_vf_promisc_parsed,
12172 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12173 "Set unicast promiscuous mode for a VF from the PF",
12175 (void *)&cmd_vf_promisc_set,
12176 (void *)&cmd_vf_promisc_vf,
12177 (void *)&cmd_vf_promisc_promisc,
12178 (void *)&cmd_vf_promisc_port_id,
12179 (void *)&cmd_vf_promisc_vf_id,
12180 (void *)&cmd_vf_promisc_on_off,
12185 /* VF multicast promiscuous mode configuration */
12187 /* Common result structure for VF multicast promiscuous mode */
12188 struct cmd_vf_allmulti_result {
12189 cmdline_fixed_string_t set;
12190 cmdline_fixed_string_t vf;
12191 cmdline_fixed_string_t allmulti;
12194 cmdline_fixed_string_t on_off;
12197 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12198 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12199 TOKEN_STRING_INITIALIZER
12200 (struct cmd_vf_allmulti_result,
12202 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12203 TOKEN_STRING_INITIALIZER
12204 (struct cmd_vf_allmulti_result,
12206 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12207 TOKEN_STRING_INITIALIZER
12208 (struct cmd_vf_allmulti_result,
12209 allmulti, "allmulti");
12210 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12211 TOKEN_NUM_INITIALIZER
12212 (struct cmd_vf_allmulti_result,
12213 port_id, RTE_UINT16);
12214 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12215 TOKEN_NUM_INITIALIZER
12216 (struct cmd_vf_allmulti_result,
12217 vf_id, RTE_UINT32);
12218 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12219 TOKEN_STRING_INITIALIZER
12220 (struct cmd_vf_allmulti_result,
12224 cmd_set_vf_allmulti_parsed(
12225 void *parsed_result,
12226 __rte_unused struct cmdline *cl,
12227 __rte_unused void *data)
12229 struct cmd_vf_allmulti_result *res = parsed_result;
12230 int ret = -ENOTSUP;
12232 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12234 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12237 #ifdef RTE_NET_I40E
12238 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12239 res->vf_id, is_on);
12246 printf("invalid vf_id %d\n", res->vf_id);
12249 printf("invalid port_id %d\n", res->port_id);
12252 printf("function not implemented\n");
12255 printf("programming error: (%s)\n", strerror(-ret));
12259 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12260 .f = cmd_set_vf_allmulti_parsed,
12262 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12263 "Set multicast promiscuous mode for a VF from the PF",
12265 (void *)&cmd_vf_allmulti_set,
12266 (void *)&cmd_vf_allmulti_vf,
12267 (void *)&cmd_vf_allmulti_allmulti,
12268 (void *)&cmd_vf_allmulti_port_id,
12269 (void *)&cmd_vf_allmulti_vf_id,
12270 (void *)&cmd_vf_allmulti_on_off,
12275 /* vf broadcast mode configuration */
12277 /* Common result structure for vf broadcast */
12278 struct cmd_set_vf_broadcast_result {
12279 cmdline_fixed_string_t set;
12280 cmdline_fixed_string_t vf;
12281 cmdline_fixed_string_t broadcast;
12284 cmdline_fixed_string_t on_off;
12287 /* Common CLI fields for vf broadcast enable disable */
12288 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12289 TOKEN_STRING_INITIALIZER
12290 (struct cmd_set_vf_broadcast_result,
12292 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12293 TOKEN_STRING_INITIALIZER
12294 (struct cmd_set_vf_broadcast_result,
12296 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12297 TOKEN_STRING_INITIALIZER
12298 (struct cmd_set_vf_broadcast_result,
12299 broadcast, "broadcast");
12300 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12301 TOKEN_NUM_INITIALIZER
12302 (struct cmd_set_vf_broadcast_result,
12303 port_id, RTE_UINT16);
12304 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12305 TOKEN_NUM_INITIALIZER
12306 (struct cmd_set_vf_broadcast_result,
12307 vf_id, RTE_UINT16);
12308 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12309 TOKEN_STRING_INITIALIZER
12310 (struct cmd_set_vf_broadcast_result,
12314 cmd_set_vf_broadcast_parsed(
12315 void *parsed_result,
12316 __rte_unused struct cmdline *cl,
12317 __rte_unused void *data)
12319 struct cmd_set_vf_broadcast_result *res = parsed_result;
12320 int ret = -ENOTSUP;
12322 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12324 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12327 #ifdef RTE_NET_I40E
12328 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12329 res->vf_id, is_on);
12336 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12339 printf("invalid port_id %d\n", res->port_id);
12342 printf("function not implemented\n");
12345 printf("programming error: (%s)\n", strerror(-ret));
12349 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12350 .f = cmd_set_vf_broadcast_parsed,
12352 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12354 (void *)&cmd_set_vf_broadcast_set,
12355 (void *)&cmd_set_vf_broadcast_vf,
12356 (void *)&cmd_set_vf_broadcast_broadcast,
12357 (void *)&cmd_set_vf_broadcast_port_id,
12358 (void *)&cmd_set_vf_broadcast_vf_id,
12359 (void *)&cmd_set_vf_broadcast_on_off,
12364 /* vf vlan tag configuration */
12366 /* Common result structure for vf vlan tag */
12367 struct cmd_set_vf_vlan_tag_result {
12368 cmdline_fixed_string_t set;
12369 cmdline_fixed_string_t vf;
12370 cmdline_fixed_string_t vlan;
12371 cmdline_fixed_string_t tag;
12374 cmdline_fixed_string_t on_off;
12377 /* Common CLI fields for vf vlan tag enable disable */
12378 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12379 TOKEN_STRING_INITIALIZER
12380 (struct cmd_set_vf_vlan_tag_result,
12382 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12383 TOKEN_STRING_INITIALIZER
12384 (struct cmd_set_vf_vlan_tag_result,
12386 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12387 TOKEN_STRING_INITIALIZER
12388 (struct cmd_set_vf_vlan_tag_result,
12390 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12391 TOKEN_STRING_INITIALIZER
12392 (struct cmd_set_vf_vlan_tag_result,
12394 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12395 TOKEN_NUM_INITIALIZER
12396 (struct cmd_set_vf_vlan_tag_result,
12397 port_id, RTE_UINT16);
12398 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12399 TOKEN_NUM_INITIALIZER
12400 (struct cmd_set_vf_vlan_tag_result,
12401 vf_id, RTE_UINT16);
12402 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12403 TOKEN_STRING_INITIALIZER
12404 (struct cmd_set_vf_vlan_tag_result,
12408 cmd_set_vf_vlan_tag_parsed(
12409 void *parsed_result,
12410 __rte_unused struct cmdline *cl,
12411 __rte_unused void *data)
12413 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12414 int ret = -ENOTSUP;
12416 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12418 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12421 #ifdef RTE_NET_I40E
12422 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12423 res->vf_id, is_on);
12430 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12433 printf("invalid port_id %d\n", res->port_id);
12436 printf("function not implemented\n");
12439 printf("programming error: (%s)\n", strerror(-ret));
12443 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12444 .f = cmd_set_vf_vlan_tag_parsed,
12446 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12448 (void *)&cmd_set_vf_vlan_tag_set,
12449 (void *)&cmd_set_vf_vlan_tag_vf,
12450 (void *)&cmd_set_vf_vlan_tag_vlan,
12451 (void *)&cmd_set_vf_vlan_tag_tag,
12452 (void *)&cmd_set_vf_vlan_tag_port_id,
12453 (void *)&cmd_set_vf_vlan_tag_vf_id,
12454 (void *)&cmd_set_vf_vlan_tag_on_off,
12459 /* Common definition of VF and TC TX bandwidth configuration */
12460 struct cmd_vf_tc_bw_result {
12461 cmdline_fixed_string_t set;
12462 cmdline_fixed_string_t vf;
12463 cmdline_fixed_string_t tc;
12464 cmdline_fixed_string_t tx;
12465 cmdline_fixed_string_t min_bw;
12466 cmdline_fixed_string_t max_bw;
12467 cmdline_fixed_string_t strict_link_prio;
12472 cmdline_fixed_string_t bw_list;
12476 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_vf_tc_bw_result,
12480 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12481 TOKEN_STRING_INITIALIZER
12482 (struct cmd_vf_tc_bw_result,
12484 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12485 TOKEN_STRING_INITIALIZER
12486 (struct cmd_vf_tc_bw_result,
12488 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_vf_tc_bw_result,
12492 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12493 TOKEN_STRING_INITIALIZER
12494 (struct cmd_vf_tc_bw_result,
12495 strict_link_prio, "strict-link-priority");
12496 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12497 TOKEN_STRING_INITIALIZER
12498 (struct cmd_vf_tc_bw_result,
12499 min_bw, "min-bandwidth");
12500 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12501 TOKEN_STRING_INITIALIZER
12502 (struct cmd_vf_tc_bw_result,
12503 max_bw, "max-bandwidth");
12504 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12505 TOKEN_NUM_INITIALIZER
12506 (struct cmd_vf_tc_bw_result,
12507 port_id, RTE_UINT16);
12508 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12509 TOKEN_NUM_INITIALIZER
12510 (struct cmd_vf_tc_bw_result,
12511 vf_id, RTE_UINT16);
12512 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12513 TOKEN_NUM_INITIALIZER
12514 (struct cmd_vf_tc_bw_result,
12516 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12517 TOKEN_NUM_INITIALIZER
12518 (struct cmd_vf_tc_bw_result,
12520 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12521 TOKEN_STRING_INITIALIZER
12522 (struct cmd_vf_tc_bw_result,
12524 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12525 TOKEN_NUM_INITIALIZER
12526 (struct cmd_vf_tc_bw_result,
12527 tc_map, RTE_UINT8);
12529 /* VF max bandwidth setting */
12531 cmd_vf_max_bw_parsed(
12532 void *parsed_result,
12533 __rte_unused struct cmdline *cl,
12534 __rte_unused void *data)
12536 struct cmd_vf_tc_bw_result *res = parsed_result;
12537 int ret = -ENOTSUP;
12539 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12542 #ifdef RTE_NET_I40E
12543 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12544 res->vf_id, res->bw);
12551 printf("invalid vf_id %d or bandwidth %d\n",
12552 res->vf_id, res->bw);
12555 printf("invalid port_id %d\n", res->port_id);
12558 printf("function not implemented\n");
12561 printf("programming error: (%s)\n", strerror(-ret));
12565 cmdline_parse_inst_t cmd_vf_max_bw = {
12566 .f = cmd_vf_max_bw_parsed,
12568 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12570 (void *)&cmd_vf_tc_bw_set,
12571 (void *)&cmd_vf_tc_bw_vf,
12572 (void *)&cmd_vf_tc_bw_tx,
12573 (void *)&cmd_vf_tc_bw_max_bw,
12574 (void *)&cmd_vf_tc_bw_port_id,
12575 (void *)&cmd_vf_tc_bw_vf_id,
12576 (void *)&cmd_vf_tc_bw_bw,
12582 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12587 const char *p, *p0 = str;
12594 p = strchr(p0, '(');
12596 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12600 p0 = strchr(p, ')');
12602 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12606 if (size >= sizeof(s)) {
12607 printf("The string size exceeds the internal buffer size\n");
12610 snprintf(s, sizeof(s), "%.*s", size, p);
12611 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12613 printf("Failed to get the bandwidth list. ");
12617 for (i = 0; i < ret; i++)
12618 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12623 /* TC min bandwidth setting */
12625 cmd_vf_tc_min_bw_parsed(
12626 void *parsed_result,
12627 __rte_unused struct cmdline *cl,
12628 __rte_unused void *data)
12630 struct cmd_vf_tc_bw_result *res = parsed_result;
12633 int ret = -ENOTSUP;
12635 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12638 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12642 #ifdef RTE_NET_I40E
12643 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12651 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12654 printf("invalid port_id %d\n", res->port_id);
12657 printf("function not implemented\n");
12660 printf("programming error: (%s)\n", strerror(-ret));
12664 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12665 .f = cmd_vf_tc_min_bw_parsed,
12667 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12668 " <bw1, bw2, ...>",
12670 (void *)&cmd_vf_tc_bw_set,
12671 (void *)&cmd_vf_tc_bw_vf,
12672 (void *)&cmd_vf_tc_bw_tc,
12673 (void *)&cmd_vf_tc_bw_tx,
12674 (void *)&cmd_vf_tc_bw_min_bw,
12675 (void *)&cmd_vf_tc_bw_port_id,
12676 (void *)&cmd_vf_tc_bw_vf_id,
12677 (void *)&cmd_vf_tc_bw_bw_list,
12683 cmd_tc_min_bw_parsed(
12684 void *parsed_result,
12685 __rte_unused struct cmdline *cl,
12686 __rte_unused void *data)
12688 struct cmd_vf_tc_bw_result *res = parsed_result;
12689 struct rte_port *port;
12692 int ret = -ENOTSUP;
12694 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12697 port = &ports[res->port_id];
12698 /** Check if the port is not started **/
12699 if (port->port_status != RTE_PORT_STOPPED) {
12700 printf("Please stop port %d first\n", res->port_id);
12704 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12708 #ifdef RTE_NET_IXGBE
12709 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12716 printf("invalid bandwidth\n");
12719 printf("invalid port_id %d\n", res->port_id);
12722 printf("function not implemented\n");
12725 printf("programming error: (%s)\n", strerror(-ret));
12729 cmdline_parse_inst_t cmd_tc_min_bw = {
12730 .f = cmd_tc_min_bw_parsed,
12732 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12734 (void *)&cmd_vf_tc_bw_set,
12735 (void *)&cmd_vf_tc_bw_tc,
12736 (void *)&cmd_vf_tc_bw_tx,
12737 (void *)&cmd_vf_tc_bw_min_bw,
12738 (void *)&cmd_vf_tc_bw_port_id,
12739 (void *)&cmd_vf_tc_bw_bw_list,
12744 /* TC max bandwidth setting */
12746 cmd_vf_tc_max_bw_parsed(
12747 void *parsed_result,
12748 __rte_unused struct cmdline *cl,
12749 __rte_unused void *data)
12751 struct cmd_vf_tc_bw_result *res = parsed_result;
12752 int ret = -ENOTSUP;
12754 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12757 #ifdef RTE_NET_I40E
12758 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12759 res->tc_no, res->bw);
12766 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12767 res->vf_id, res->tc_no, res->bw);
12770 printf("invalid port_id %d\n", res->port_id);
12773 printf("function not implemented\n");
12776 printf("programming error: (%s)\n", strerror(-ret));
12780 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12781 .f = cmd_vf_tc_max_bw_parsed,
12783 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12786 (void *)&cmd_vf_tc_bw_set,
12787 (void *)&cmd_vf_tc_bw_vf,
12788 (void *)&cmd_vf_tc_bw_tc,
12789 (void *)&cmd_vf_tc_bw_tx,
12790 (void *)&cmd_vf_tc_bw_max_bw,
12791 (void *)&cmd_vf_tc_bw_port_id,
12792 (void *)&cmd_vf_tc_bw_vf_id,
12793 (void *)&cmd_vf_tc_bw_tc_no,
12794 (void *)&cmd_vf_tc_bw_bw,
12799 /** Set VXLAN encapsulation details */
12800 struct cmd_set_vxlan_result {
12801 cmdline_fixed_string_t set;
12802 cmdline_fixed_string_t vxlan;
12803 cmdline_fixed_string_t pos_token;
12804 cmdline_fixed_string_t ip_version;
12805 uint32_t vlan_present:1;
12809 cmdline_ipaddr_t ip_src;
12810 cmdline_ipaddr_t ip_dst;
12814 struct rte_ether_addr eth_src;
12815 struct rte_ether_addr eth_dst;
12818 cmdline_parse_token_string_t cmd_set_vxlan_set =
12819 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12820 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12821 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12822 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12823 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12825 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12826 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12827 "vxlan-with-vlan");
12828 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12829 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12831 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12832 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12834 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12835 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12837 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12838 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12839 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12840 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12842 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12843 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12844 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12845 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12847 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12848 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12849 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12850 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12852 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12853 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12854 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12855 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12857 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12858 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12859 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12860 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12862 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12863 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12864 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12865 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12867 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12868 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12869 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12870 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12872 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12873 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12874 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12875 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12877 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12878 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12879 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12880 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12882 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12883 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12885 static void cmd_set_vxlan_parsed(void *parsed_result,
12886 __rte_unused struct cmdline *cl,
12887 __rte_unused void *data)
12889 struct cmd_set_vxlan_result *res = parsed_result;
12894 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12897 vxlan_encap_conf.select_tos_ttl = 0;
12898 if (strcmp(res->vxlan, "vxlan") == 0)
12899 vxlan_encap_conf.select_vlan = 0;
12900 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12901 vxlan_encap_conf.select_vlan = 1;
12902 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12903 vxlan_encap_conf.select_vlan = 0;
12904 vxlan_encap_conf.select_tos_ttl = 1;
12906 if (strcmp(res->ip_version, "ipv4") == 0)
12907 vxlan_encap_conf.select_ipv4 = 1;
12908 else if (strcmp(res->ip_version, "ipv6") == 0)
12909 vxlan_encap_conf.select_ipv4 = 0;
12912 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12913 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12914 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12915 vxlan_encap_conf.ip_tos = res->tos;
12916 vxlan_encap_conf.ip_ttl = res->ttl;
12917 if (vxlan_encap_conf.select_ipv4) {
12918 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12919 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12921 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12922 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12924 if (vxlan_encap_conf.select_vlan)
12925 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12926 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12927 RTE_ETHER_ADDR_LEN);
12928 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12929 RTE_ETHER_ADDR_LEN);
12932 cmdline_parse_inst_t cmd_set_vxlan = {
12933 .f = cmd_set_vxlan_parsed,
12935 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12936 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12937 " eth-src <eth-src> eth-dst <eth-dst>",
12939 (void *)&cmd_set_vxlan_set,
12940 (void *)&cmd_set_vxlan_vxlan,
12941 (void *)&cmd_set_vxlan_ip_version,
12942 (void *)&cmd_set_vxlan_ip_version_value,
12943 (void *)&cmd_set_vxlan_vni,
12944 (void *)&cmd_set_vxlan_vni_value,
12945 (void *)&cmd_set_vxlan_udp_src,
12946 (void *)&cmd_set_vxlan_udp_src_value,
12947 (void *)&cmd_set_vxlan_udp_dst,
12948 (void *)&cmd_set_vxlan_udp_dst_value,
12949 (void *)&cmd_set_vxlan_ip_src,
12950 (void *)&cmd_set_vxlan_ip_src_value,
12951 (void *)&cmd_set_vxlan_ip_dst,
12952 (void *)&cmd_set_vxlan_ip_dst_value,
12953 (void *)&cmd_set_vxlan_eth_src,
12954 (void *)&cmd_set_vxlan_eth_src_value,
12955 (void *)&cmd_set_vxlan_eth_dst,
12956 (void *)&cmd_set_vxlan_eth_dst_value,
12961 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12962 .f = cmd_set_vxlan_parsed,
12964 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12965 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12966 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12967 " eth-dst <eth-dst>",
12969 (void *)&cmd_set_vxlan_set,
12970 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12971 (void *)&cmd_set_vxlan_ip_version,
12972 (void *)&cmd_set_vxlan_ip_version_value,
12973 (void *)&cmd_set_vxlan_vni,
12974 (void *)&cmd_set_vxlan_vni_value,
12975 (void *)&cmd_set_vxlan_udp_src,
12976 (void *)&cmd_set_vxlan_udp_src_value,
12977 (void *)&cmd_set_vxlan_udp_dst,
12978 (void *)&cmd_set_vxlan_udp_dst_value,
12979 (void *)&cmd_set_vxlan_ip_tos,
12980 (void *)&cmd_set_vxlan_ip_tos_value,
12981 (void *)&cmd_set_vxlan_ip_ttl,
12982 (void *)&cmd_set_vxlan_ip_ttl_value,
12983 (void *)&cmd_set_vxlan_ip_src,
12984 (void *)&cmd_set_vxlan_ip_src_value,
12985 (void *)&cmd_set_vxlan_ip_dst,
12986 (void *)&cmd_set_vxlan_ip_dst_value,
12987 (void *)&cmd_set_vxlan_eth_src,
12988 (void *)&cmd_set_vxlan_eth_src_value,
12989 (void *)&cmd_set_vxlan_eth_dst,
12990 (void *)&cmd_set_vxlan_eth_dst_value,
12995 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12996 .f = cmd_set_vxlan_parsed,
12998 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12999 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13000 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13003 (void *)&cmd_set_vxlan_set,
13004 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13005 (void *)&cmd_set_vxlan_ip_version,
13006 (void *)&cmd_set_vxlan_ip_version_value,
13007 (void *)&cmd_set_vxlan_vni,
13008 (void *)&cmd_set_vxlan_vni_value,
13009 (void *)&cmd_set_vxlan_udp_src,
13010 (void *)&cmd_set_vxlan_udp_src_value,
13011 (void *)&cmd_set_vxlan_udp_dst,
13012 (void *)&cmd_set_vxlan_udp_dst_value,
13013 (void *)&cmd_set_vxlan_ip_src,
13014 (void *)&cmd_set_vxlan_ip_src_value,
13015 (void *)&cmd_set_vxlan_ip_dst,
13016 (void *)&cmd_set_vxlan_ip_dst_value,
13017 (void *)&cmd_set_vxlan_vlan,
13018 (void *)&cmd_set_vxlan_vlan_value,
13019 (void *)&cmd_set_vxlan_eth_src,
13020 (void *)&cmd_set_vxlan_eth_src_value,
13021 (void *)&cmd_set_vxlan_eth_dst,
13022 (void *)&cmd_set_vxlan_eth_dst_value,
13027 /** Set NVGRE encapsulation details */
13028 struct cmd_set_nvgre_result {
13029 cmdline_fixed_string_t set;
13030 cmdline_fixed_string_t nvgre;
13031 cmdline_fixed_string_t pos_token;
13032 cmdline_fixed_string_t ip_version;
13034 cmdline_ipaddr_t ip_src;
13035 cmdline_ipaddr_t ip_dst;
13037 struct rte_ether_addr eth_src;
13038 struct rte_ether_addr eth_dst;
13041 cmdline_parse_token_string_t cmd_set_nvgre_set =
13042 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13043 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13044 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13045 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13046 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13047 "nvgre-with-vlan");
13048 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13049 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13051 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13052 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13054 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13055 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13057 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13058 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13059 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13060 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13062 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13063 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13064 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13065 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13067 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13068 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13069 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13070 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13072 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13073 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13074 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13075 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13077 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13078 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13079 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13080 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13082 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13083 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13085 static void cmd_set_nvgre_parsed(void *parsed_result,
13086 __rte_unused struct cmdline *cl,
13087 __rte_unused void *data)
13089 struct cmd_set_nvgre_result *res = parsed_result;
13091 uint32_t nvgre_tni;
13094 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13097 if (strcmp(res->nvgre, "nvgre") == 0)
13098 nvgre_encap_conf.select_vlan = 0;
13099 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13100 nvgre_encap_conf.select_vlan = 1;
13101 if (strcmp(res->ip_version, "ipv4") == 0)
13102 nvgre_encap_conf.select_ipv4 = 1;
13103 else if (strcmp(res->ip_version, "ipv6") == 0)
13104 nvgre_encap_conf.select_ipv4 = 0;
13107 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13108 if (nvgre_encap_conf.select_ipv4) {
13109 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13110 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13112 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13113 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13115 if (nvgre_encap_conf.select_vlan)
13116 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13117 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13118 RTE_ETHER_ADDR_LEN);
13119 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13120 RTE_ETHER_ADDR_LEN);
13123 cmdline_parse_inst_t cmd_set_nvgre = {
13124 .f = cmd_set_nvgre_parsed,
13126 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13127 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13128 " eth-dst <eth-dst>",
13130 (void *)&cmd_set_nvgre_set,
13131 (void *)&cmd_set_nvgre_nvgre,
13132 (void *)&cmd_set_nvgre_ip_version,
13133 (void *)&cmd_set_nvgre_ip_version_value,
13134 (void *)&cmd_set_nvgre_tni,
13135 (void *)&cmd_set_nvgre_tni_value,
13136 (void *)&cmd_set_nvgre_ip_src,
13137 (void *)&cmd_set_nvgre_ip_src_value,
13138 (void *)&cmd_set_nvgre_ip_dst,
13139 (void *)&cmd_set_nvgre_ip_dst_value,
13140 (void *)&cmd_set_nvgre_eth_src,
13141 (void *)&cmd_set_nvgre_eth_src_value,
13142 (void *)&cmd_set_nvgre_eth_dst,
13143 (void *)&cmd_set_nvgre_eth_dst_value,
13148 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13149 .f = cmd_set_nvgre_parsed,
13151 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13152 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13153 " eth-src <eth-src> eth-dst <eth-dst>",
13155 (void *)&cmd_set_nvgre_set,
13156 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13157 (void *)&cmd_set_nvgre_ip_version,
13158 (void *)&cmd_set_nvgre_ip_version_value,
13159 (void *)&cmd_set_nvgre_tni,
13160 (void *)&cmd_set_nvgre_tni_value,
13161 (void *)&cmd_set_nvgre_ip_src,
13162 (void *)&cmd_set_nvgre_ip_src_value,
13163 (void *)&cmd_set_nvgre_ip_dst,
13164 (void *)&cmd_set_nvgre_ip_dst_value,
13165 (void *)&cmd_set_nvgre_vlan,
13166 (void *)&cmd_set_nvgre_vlan_value,
13167 (void *)&cmd_set_nvgre_eth_src,
13168 (void *)&cmd_set_nvgre_eth_src_value,
13169 (void *)&cmd_set_nvgre_eth_dst,
13170 (void *)&cmd_set_nvgre_eth_dst_value,
13175 /** Set L2 encapsulation details */
13176 struct cmd_set_l2_encap_result {
13177 cmdline_fixed_string_t set;
13178 cmdline_fixed_string_t l2_encap;
13179 cmdline_fixed_string_t pos_token;
13180 cmdline_fixed_string_t ip_version;
13181 uint32_t vlan_present:1;
13183 struct rte_ether_addr eth_src;
13184 struct rte_ether_addr eth_dst;
13187 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13188 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13189 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13190 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13191 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13192 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13193 "l2_encap-with-vlan");
13194 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13195 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13197 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13198 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13200 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13201 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13203 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13204 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13205 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13206 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13208 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13209 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13210 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13211 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13213 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13214 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13216 static void cmd_set_l2_encap_parsed(void *parsed_result,
13217 __rte_unused struct cmdline *cl,
13218 __rte_unused void *data)
13220 struct cmd_set_l2_encap_result *res = parsed_result;
13222 if (strcmp(res->l2_encap, "l2_encap") == 0)
13223 l2_encap_conf.select_vlan = 0;
13224 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13225 l2_encap_conf.select_vlan = 1;
13226 if (strcmp(res->ip_version, "ipv4") == 0)
13227 l2_encap_conf.select_ipv4 = 1;
13228 else if (strcmp(res->ip_version, "ipv6") == 0)
13229 l2_encap_conf.select_ipv4 = 0;
13232 if (l2_encap_conf.select_vlan)
13233 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13234 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13235 RTE_ETHER_ADDR_LEN);
13236 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13237 RTE_ETHER_ADDR_LEN);
13240 cmdline_parse_inst_t cmd_set_l2_encap = {
13241 .f = cmd_set_l2_encap_parsed,
13243 .help_str = "set l2_encap ip-version ipv4|ipv6"
13244 " eth-src <eth-src> eth-dst <eth-dst>",
13246 (void *)&cmd_set_l2_encap_set,
13247 (void *)&cmd_set_l2_encap_l2_encap,
13248 (void *)&cmd_set_l2_encap_ip_version,
13249 (void *)&cmd_set_l2_encap_ip_version_value,
13250 (void *)&cmd_set_l2_encap_eth_src,
13251 (void *)&cmd_set_l2_encap_eth_src_value,
13252 (void *)&cmd_set_l2_encap_eth_dst,
13253 (void *)&cmd_set_l2_encap_eth_dst_value,
13258 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13259 .f = cmd_set_l2_encap_parsed,
13261 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13262 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13264 (void *)&cmd_set_l2_encap_set,
13265 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13266 (void *)&cmd_set_l2_encap_ip_version,
13267 (void *)&cmd_set_l2_encap_ip_version_value,
13268 (void *)&cmd_set_l2_encap_vlan,
13269 (void *)&cmd_set_l2_encap_vlan_value,
13270 (void *)&cmd_set_l2_encap_eth_src,
13271 (void *)&cmd_set_l2_encap_eth_src_value,
13272 (void *)&cmd_set_l2_encap_eth_dst,
13273 (void *)&cmd_set_l2_encap_eth_dst_value,
13278 /** Set L2 decapsulation details */
13279 struct cmd_set_l2_decap_result {
13280 cmdline_fixed_string_t set;
13281 cmdline_fixed_string_t l2_decap;
13282 cmdline_fixed_string_t pos_token;
13283 uint32_t vlan_present:1;
13286 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13287 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13288 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13289 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13291 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13292 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13293 "l2_decap-with-vlan");
13295 static void cmd_set_l2_decap_parsed(void *parsed_result,
13296 __rte_unused struct cmdline *cl,
13297 __rte_unused void *data)
13299 struct cmd_set_l2_decap_result *res = parsed_result;
13301 if (strcmp(res->l2_decap, "l2_decap") == 0)
13302 l2_decap_conf.select_vlan = 0;
13303 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13304 l2_decap_conf.select_vlan = 1;
13307 cmdline_parse_inst_t cmd_set_l2_decap = {
13308 .f = cmd_set_l2_decap_parsed,
13310 .help_str = "set l2_decap",
13312 (void *)&cmd_set_l2_decap_set,
13313 (void *)&cmd_set_l2_decap_l2_decap,
13318 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13319 .f = cmd_set_l2_decap_parsed,
13321 .help_str = "set l2_decap-with-vlan",
13323 (void *)&cmd_set_l2_decap_set,
13324 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13329 /** Set MPLSoGRE encapsulation details */
13330 struct cmd_set_mplsogre_encap_result {
13331 cmdline_fixed_string_t set;
13332 cmdline_fixed_string_t mplsogre;
13333 cmdline_fixed_string_t pos_token;
13334 cmdline_fixed_string_t ip_version;
13335 uint32_t vlan_present:1;
13337 cmdline_ipaddr_t ip_src;
13338 cmdline_ipaddr_t ip_dst;
13340 struct rte_ether_addr eth_src;
13341 struct rte_ether_addr eth_dst;
13344 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13345 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13347 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13348 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13350 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13351 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13352 mplsogre, "mplsogre_encap-with-vlan");
13353 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13354 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13355 pos_token, "ip-version");
13356 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13357 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13358 ip_version, "ipv4#ipv6");
13359 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13360 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13361 pos_token, "label");
13362 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13363 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13365 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13366 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13367 pos_token, "ip-src");
13368 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13369 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13370 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13371 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13372 pos_token, "ip-dst");
13373 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13374 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13375 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13376 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13377 pos_token, "vlan-tci");
13378 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13379 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13381 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13382 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13383 pos_token, "eth-src");
13384 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13385 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13387 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13388 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13389 pos_token, "eth-dst");
13390 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13391 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13394 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13395 __rte_unused struct cmdline *cl,
13396 __rte_unused void *data)
13398 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13400 uint32_t mplsogre_label;
13403 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13406 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13407 mplsogre_encap_conf.select_vlan = 0;
13408 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13409 mplsogre_encap_conf.select_vlan = 1;
13410 if (strcmp(res->ip_version, "ipv4") == 0)
13411 mplsogre_encap_conf.select_ipv4 = 1;
13412 else if (strcmp(res->ip_version, "ipv6") == 0)
13413 mplsogre_encap_conf.select_ipv4 = 0;
13416 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13417 if (mplsogre_encap_conf.select_ipv4) {
13418 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13419 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13421 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13422 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13424 if (mplsogre_encap_conf.select_vlan)
13425 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13426 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13427 RTE_ETHER_ADDR_LEN);
13428 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13429 RTE_ETHER_ADDR_LEN);
13432 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13433 .f = cmd_set_mplsogre_encap_parsed,
13435 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13436 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13437 " eth-dst <eth-dst>",
13439 (void *)&cmd_set_mplsogre_encap_set,
13440 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13441 (void *)&cmd_set_mplsogre_encap_ip_version,
13442 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13443 (void *)&cmd_set_mplsogre_encap_label,
13444 (void *)&cmd_set_mplsogre_encap_label_value,
13445 (void *)&cmd_set_mplsogre_encap_ip_src,
13446 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13447 (void *)&cmd_set_mplsogre_encap_ip_dst,
13448 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13449 (void *)&cmd_set_mplsogre_encap_eth_src,
13450 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13451 (void *)&cmd_set_mplsogre_encap_eth_dst,
13452 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13457 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13458 .f = cmd_set_mplsogre_encap_parsed,
13460 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13461 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13462 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13464 (void *)&cmd_set_mplsogre_encap_set,
13465 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13466 (void *)&cmd_set_mplsogre_encap_ip_version,
13467 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13468 (void *)&cmd_set_mplsogre_encap_label,
13469 (void *)&cmd_set_mplsogre_encap_label_value,
13470 (void *)&cmd_set_mplsogre_encap_ip_src,
13471 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13472 (void *)&cmd_set_mplsogre_encap_ip_dst,
13473 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13474 (void *)&cmd_set_mplsogre_encap_vlan,
13475 (void *)&cmd_set_mplsogre_encap_vlan_value,
13476 (void *)&cmd_set_mplsogre_encap_eth_src,
13477 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13478 (void *)&cmd_set_mplsogre_encap_eth_dst,
13479 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13484 /** Set MPLSoGRE decapsulation details */
13485 struct cmd_set_mplsogre_decap_result {
13486 cmdline_fixed_string_t set;
13487 cmdline_fixed_string_t mplsogre;
13488 cmdline_fixed_string_t pos_token;
13489 cmdline_fixed_string_t ip_version;
13490 uint32_t vlan_present:1;
13493 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13494 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13496 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13497 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13499 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13500 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13501 mplsogre, "mplsogre_decap-with-vlan");
13502 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13503 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13504 pos_token, "ip-version");
13505 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13506 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13507 ip_version, "ipv4#ipv6");
13509 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13510 __rte_unused struct cmdline *cl,
13511 __rte_unused void *data)
13513 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13515 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13516 mplsogre_decap_conf.select_vlan = 0;
13517 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13518 mplsogre_decap_conf.select_vlan = 1;
13519 if (strcmp(res->ip_version, "ipv4") == 0)
13520 mplsogre_decap_conf.select_ipv4 = 1;
13521 else if (strcmp(res->ip_version, "ipv6") == 0)
13522 mplsogre_decap_conf.select_ipv4 = 0;
13525 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13526 .f = cmd_set_mplsogre_decap_parsed,
13528 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13530 (void *)&cmd_set_mplsogre_decap_set,
13531 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13532 (void *)&cmd_set_mplsogre_decap_ip_version,
13533 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13538 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13539 .f = cmd_set_mplsogre_decap_parsed,
13541 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13543 (void *)&cmd_set_mplsogre_decap_set,
13544 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13545 (void *)&cmd_set_mplsogre_decap_ip_version,
13546 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13551 /** Set MPLSoUDP encapsulation details */
13552 struct cmd_set_mplsoudp_encap_result {
13553 cmdline_fixed_string_t set;
13554 cmdline_fixed_string_t mplsoudp;
13555 cmdline_fixed_string_t pos_token;
13556 cmdline_fixed_string_t ip_version;
13557 uint32_t vlan_present:1;
13561 cmdline_ipaddr_t ip_src;
13562 cmdline_ipaddr_t ip_dst;
13564 struct rte_ether_addr eth_src;
13565 struct rte_ether_addr eth_dst;
13568 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13569 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13571 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13572 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13574 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13575 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13576 mplsoudp, "mplsoudp_encap-with-vlan");
13577 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13578 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13579 pos_token, "ip-version");
13580 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13581 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13582 ip_version, "ipv4#ipv6");
13583 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13584 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13585 pos_token, "label");
13586 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13587 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13589 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13590 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13591 pos_token, "udp-src");
13592 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13593 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13595 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13596 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13597 pos_token, "udp-dst");
13598 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13599 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13601 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13602 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13603 pos_token, "ip-src");
13604 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13605 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13606 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13607 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13608 pos_token, "ip-dst");
13609 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13610 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13611 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13612 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13613 pos_token, "vlan-tci");
13614 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13615 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13617 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13618 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13619 pos_token, "eth-src");
13620 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13621 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13623 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13624 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13625 pos_token, "eth-dst");
13626 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13627 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13630 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13631 __rte_unused struct cmdline *cl,
13632 __rte_unused void *data)
13634 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13636 uint32_t mplsoudp_label;
13639 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13642 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13643 mplsoudp_encap_conf.select_vlan = 0;
13644 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13645 mplsoudp_encap_conf.select_vlan = 1;
13646 if (strcmp(res->ip_version, "ipv4") == 0)
13647 mplsoudp_encap_conf.select_ipv4 = 1;
13648 else if (strcmp(res->ip_version, "ipv6") == 0)
13649 mplsoudp_encap_conf.select_ipv4 = 0;
13652 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13653 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13654 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13655 if (mplsoudp_encap_conf.select_ipv4) {
13656 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13657 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13659 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13660 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13662 if (mplsoudp_encap_conf.select_vlan)
13663 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13664 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13665 RTE_ETHER_ADDR_LEN);
13666 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13667 RTE_ETHER_ADDR_LEN);
13670 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13671 .f = cmd_set_mplsoudp_encap_parsed,
13673 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13674 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13675 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13677 (void *)&cmd_set_mplsoudp_encap_set,
13678 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13679 (void *)&cmd_set_mplsoudp_encap_ip_version,
13680 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13681 (void *)&cmd_set_mplsoudp_encap_label,
13682 (void *)&cmd_set_mplsoudp_encap_label_value,
13683 (void *)&cmd_set_mplsoudp_encap_udp_src,
13684 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13685 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13686 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13687 (void *)&cmd_set_mplsoudp_encap_ip_src,
13688 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13689 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13690 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13691 (void *)&cmd_set_mplsoudp_encap_eth_src,
13692 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13693 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13694 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13699 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13700 .f = cmd_set_mplsoudp_encap_parsed,
13702 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13703 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13704 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13705 " eth-src <eth-src> eth-dst <eth-dst>",
13707 (void *)&cmd_set_mplsoudp_encap_set,
13708 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13709 (void *)&cmd_set_mplsoudp_encap_ip_version,
13710 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13711 (void *)&cmd_set_mplsoudp_encap_label,
13712 (void *)&cmd_set_mplsoudp_encap_label_value,
13713 (void *)&cmd_set_mplsoudp_encap_udp_src,
13714 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13715 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13716 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13717 (void *)&cmd_set_mplsoudp_encap_ip_src,
13718 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13719 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13720 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13721 (void *)&cmd_set_mplsoudp_encap_vlan,
13722 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13723 (void *)&cmd_set_mplsoudp_encap_eth_src,
13724 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13725 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13726 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13731 /** Set MPLSoUDP decapsulation details */
13732 struct cmd_set_mplsoudp_decap_result {
13733 cmdline_fixed_string_t set;
13734 cmdline_fixed_string_t mplsoudp;
13735 cmdline_fixed_string_t pos_token;
13736 cmdline_fixed_string_t ip_version;
13737 uint32_t vlan_present:1;
13740 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13741 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13743 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13744 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13746 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13747 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13748 mplsoudp, "mplsoudp_decap-with-vlan");
13749 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13750 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13751 pos_token, "ip-version");
13752 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13753 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13754 ip_version, "ipv4#ipv6");
13756 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13757 __rte_unused struct cmdline *cl,
13758 __rte_unused void *data)
13760 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13762 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13763 mplsoudp_decap_conf.select_vlan = 0;
13764 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13765 mplsoudp_decap_conf.select_vlan = 1;
13766 if (strcmp(res->ip_version, "ipv4") == 0)
13767 mplsoudp_decap_conf.select_ipv4 = 1;
13768 else if (strcmp(res->ip_version, "ipv6") == 0)
13769 mplsoudp_decap_conf.select_ipv4 = 0;
13772 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13773 .f = cmd_set_mplsoudp_decap_parsed,
13775 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13777 (void *)&cmd_set_mplsoudp_decap_set,
13778 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13779 (void *)&cmd_set_mplsoudp_decap_ip_version,
13780 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13785 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13786 .f = cmd_set_mplsoudp_decap_parsed,
13788 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13790 (void *)&cmd_set_mplsoudp_decap_set,
13791 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13792 (void *)&cmd_set_mplsoudp_decap_ip_version,
13793 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13798 /** Set connection tracking object common details */
13799 struct cmd_set_conntrack_common_result {
13800 cmdline_fixed_string_t set;
13801 cmdline_fixed_string_t conntrack;
13802 cmdline_fixed_string_t common;
13803 cmdline_fixed_string_t peer;
13804 cmdline_fixed_string_t is_orig;
13805 cmdline_fixed_string_t enable;
13806 cmdline_fixed_string_t live;
13807 cmdline_fixed_string_t sack;
13808 cmdline_fixed_string_t cack;
13809 cmdline_fixed_string_t last_dir;
13810 cmdline_fixed_string_t liberal;
13811 cmdline_fixed_string_t state;
13812 cmdline_fixed_string_t max_ack_win;
13813 cmdline_fixed_string_t retrans;
13814 cmdline_fixed_string_t last_win;
13815 cmdline_fixed_string_t last_seq;
13816 cmdline_fixed_string_t last_ack;
13817 cmdline_fixed_string_t last_end;
13818 cmdline_fixed_string_t last_index;
13821 uint16_t peer_port;
13822 uint32_t is_original;
13837 cmdline_parse_token_string_t cmd_set_conntrack_set =
13838 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13840 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13841 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13842 conntrack, "conntrack");
13843 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13844 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13846 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13847 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13849 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13850 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13851 peer_port, RTE_UINT16);
13852 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13853 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13854 is_orig, "is_orig");
13855 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13856 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13857 is_original, RTE_UINT32);
13858 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13859 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13861 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13862 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13864 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13865 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13867 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13868 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13869 is_live, RTE_UINT32);
13870 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13871 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13873 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13874 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13875 s_ack, RTE_UINT32);
13876 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13877 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13879 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13880 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13881 c_ack, RTE_UINT32);
13882 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13883 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13884 last_dir, "last_dir");
13885 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13886 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13888 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13889 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13890 liberal, "liberal");
13891 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13892 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13894 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13895 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13897 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13898 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13900 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13901 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13902 max_ack_win, "max_ack_win");
13903 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13904 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13905 factor, RTE_UINT8);
13906 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13907 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13909 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13910 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13911 re_num, RTE_UINT8);
13912 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13913 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13914 last_win, "last_win");
13915 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13916 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13918 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13919 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13920 last_seq, "last_seq");
13921 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13922 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13924 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13925 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13926 last_ack, "last_ack");
13927 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13928 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13930 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13931 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13932 last_end, "last_end");
13933 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13934 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13936 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13937 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13938 last_index, "last_index");
13939 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13940 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13943 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13944 __rte_unused struct cmdline *cl,
13945 __rte_unused void *data)
13947 struct cmd_set_conntrack_common_result *res = parsed_result;
13949 /* No need to swap to big endian. */
13950 conntrack_context.peer_port = res->peer_port;
13951 conntrack_context.is_original_dir = res->is_original;
13952 conntrack_context.enable = res->en;
13953 conntrack_context.live_connection = res->is_live;
13954 conntrack_context.selective_ack = res->s_ack;
13955 conntrack_context.challenge_ack_passed = res->c_ack;
13956 conntrack_context.last_direction = res->ld;
13957 conntrack_context.liberal_mode = res->lb;
13958 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13959 conntrack_context.max_ack_window = res->factor;
13960 conntrack_context.retransmission_limit = res->re_num;
13961 conntrack_context.last_window = res->lw;
13962 conntrack_context.last_index =
13963 (enum rte_flow_conntrack_tcp_last_index)res->li;
13964 conntrack_context.last_seq = res->ls;
13965 conntrack_context.last_ack = res->la;
13966 conntrack_context.last_end = res->le;
13969 cmdline_parse_inst_t cmd_set_conntrack_common = {
13970 .f = cmd_set_conntrack_common_parsed,
13972 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13973 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13974 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13975 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13976 " last_index <flag>",
13978 (void *)&cmd_set_conntrack_set,
13979 (void *)&cmd_set_conntrack_conntrack,
13980 (void *)&cmd_set_conntrack_common_com,
13981 (void *)&cmd_set_conntrack_common_peer,
13982 (void *)&cmd_set_conntrack_common_peer_value,
13983 (void *)&cmd_set_conntrack_common_is_orig,
13984 (void *)&cmd_set_conntrack_common_is_orig_value,
13985 (void *)&cmd_set_conntrack_common_enable,
13986 (void *)&cmd_set_conntrack_common_enable_value,
13987 (void *)&cmd_set_conntrack_common_live,
13988 (void *)&cmd_set_conntrack_common_live_value,
13989 (void *)&cmd_set_conntrack_common_sack,
13990 (void *)&cmd_set_conntrack_common_sack_value,
13991 (void *)&cmd_set_conntrack_common_cack,
13992 (void *)&cmd_set_conntrack_common_cack_value,
13993 (void *)&cmd_set_conntrack_common_last_dir,
13994 (void *)&cmd_set_conntrack_common_last_dir_value,
13995 (void *)&cmd_set_conntrack_common_liberal,
13996 (void *)&cmd_set_conntrack_common_liberal_value,
13997 (void *)&cmd_set_conntrack_common_state,
13998 (void *)&cmd_set_conntrack_common_state_value,
13999 (void *)&cmd_set_conntrack_common_max_ackwin,
14000 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14001 (void *)&cmd_set_conntrack_common_retrans,
14002 (void *)&cmd_set_conntrack_common_retrans_value,
14003 (void *)&cmd_set_conntrack_common_last_win,
14004 (void *)&cmd_set_conntrack_common_last_win_value,
14005 (void *)&cmd_set_conntrack_common_last_seq,
14006 (void *)&cmd_set_conntrack_common_last_seq_value,
14007 (void *)&cmd_set_conntrack_common_last_ack,
14008 (void *)&cmd_set_conntrack_common_last_ack_value,
14009 (void *)&cmd_set_conntrack_common_last_end,
14010 (void *)&cmd_set_conntrack_common_last_end_value,
14011 (void *)&cmd_set_conntrack_common_last_index,
14012 (void *)&cmd_set_conntrack_common_last_index_value,
14017 /** Set connection tracking object both directions' details */
14018 struct cmd_set_conntrack_dir_result {
14019 cmdline_fixed_string_t set;
14020 cmdline_fixed_string_t conntrack;
14021 cmdline_fixed_string_t dir;
14022 cmdline_fixed_string_t scale;
14023 cmdline_fixed_string_t fin;
14024 cmdline_fixed_string_t ack_seen;
14025 cmdline_fixed_string_t unack;
14026 cmdline_fixed_string_t sent_end;
14027 cmdline_fixed_string_t reply_end;
14028 cmdline_fixed_string_t max_win;
14029 cmdline_fixed_string_t max_ack;
14040 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14041 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14043 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14044 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14045 conntrack, "conntrack");
14046 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14047 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14049 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14050 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14052 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14053 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14054 factor, RTE_UINT32);
14055 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14056 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14058 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14059 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14061 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14062 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14063 ack_seen, "acked");
14064 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14065 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14067 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14068 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14069 unack, "unack_data");
14070 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14071 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14073 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14074 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14075 sent_end, "sent_end");
14076 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14077 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14079 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14080 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14081 reply_end, "reply_end");
14082 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14083 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14085 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14086 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14087 max_win, "max_win");
14088 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14089 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14091 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14092 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14093 max_ack, "max_ack");
14094 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14095 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14098 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14099 __rte_unused struct cmdline *cl,
14100 __rte_unused void *data)
14102 struct cmd_set_conntrack_dir_result *res = parsed_result;
14103 struct rte_flow_tcp_dir_param *dir = NULL;
14105 if (strcmp(res->dir, "orig") == 0)
14106 dir = &conntrack_context.original_dir;
14107 else if (strcmp(res->dir, "rply") == 0)
14108 dir = &conntrack_context.reply_dir;
14111 dir->scale = res->factor;
14112 dir->close_initiated = res->f;
14113 dir->last_ack_seen = res->as;
14114 dir->data_unacked = res->un;
14115 dir->sent_end = res->se;
14116 dir->reply_end = res->re;
14117 dir->max_ack = res->ma;
14118 dir->max_win = res->mw;
14121 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14122 .f = cmd_set_conntrack_dir_parsed,
14124 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14125 " acked <seen> unack_data <unack> sent_end <sent>"
14126 " reply_end <reply> max_win <win> max_ack <ack>",
14128 (void *)&cmd_set_conntrack_set,
14129 (void *)&cmd_set_conntrack_conntrack,
14130 (void *)&cmd_set_conntrack_dir_dir,
14131 (void *)&cmd_set_conntrack_dir_scale,
14132 (void *)&cmd_set_conntrack_dir_scale_value,
14133 (void *)&cmd_set_conntrack_dir_fin,
14134 (void *)&cmd_set_conntrack_dir_fin_value,
14135 (void *)&cmd_set_conntrack_dir_ack,
14136 (void *)&cmd_set_conntrack_dir_ack_value,
14137 (void *)&cmd_set_conntrack_dir_unack_data,
14138 (void *)&cmd_set_conntrack_dir_unack_data_value,
14139 (void *)&cmd_set_conntrack_dir_sent_end,
14140 (void *)&cmd_set_conntrack_dir_sent_end_value,
14141 (void *)&cmd_set_conntrack_dir_reply_end,
14142 (void *)&cmd_set_conntrack_dir_reply_end_value,
14143 (void *)&cmd_set_conntrack_dir_max_win,
14144 (void *)&cmd_set_conntrack_dir_max_win_value,
14145 (void *)&cmd_set_conntrack_dir_max_ack,
14146 (void *)&cmd_set_conntrack_dir_max_ack_value,
14151 /* Strict link priority scheduling mode setting */
14153 cmd_strict_link_prio_parsed(
14154 void *parsed_result,
14155 __rte_unused struct cmdline *cl,
14156 __rte_unused void *data)
14158 struct cmd_vf_tc_bw_result *res = parsed_result;
14159 int ret = -ENOTSUP;
14161 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14164 #ifdef RTE_NET_I40E
14165 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14172 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14175 printf("invalid port_id %d\n", res->port_id);
14178 printf("function not implemented\n");
14181 printf("programming error: (%s)\n", strerror(-ret));
14185 cmdline_parse_inst_t cmd_strict_link_prio = {
14186 .f = cmd_strict_link_prio_parsed,
14188 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14190 (void *)&cmd_vf_tc_bw_set,
14191 (void *)&cmd_vf_tc_bw_tx,
14192 (void *)&cmd_vf_tc_bw_strict_link_prio,
14193 (void *)&cmd_vf_tc_bw_port_id,
14194 (void *)&cmd_vf_tc_bw_tc_map,
14199 /* Load dynamic device personalization*/
14200 struct cmd_ddp_add_result {
14201 cmdline_fixed_string_t ddp;
14202 cmdline_fixed_string_t add;
14207 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14208 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14209 cmdline_parse_token_string_t cmd_ddp_add_add =
14210 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14211 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14212 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14214 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14215 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14218 cmd_ddp_add_parsed(
14219 void *parsed_result,
14220 __rte_unused struct cmdline *cl,
14221 __rte_unused void *data)
14223 struct cmd_ddp_add_result *res = parsed_result;
14229 int ret = -ENOTSUP;
14231 if (!all_ports_stopped()) {
14232 printf("Please stop all ports first\n");
14236 filepath = strdup(res->filepath);
14237 if (filepath == NULL) {
14238 printf("Failed to allocate memory\n");
14241 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14243 buff = open_file(file_fld[0], &size);
14245 free((void *)filepath);
14249 #ifdef RTE_NET_I40E
14250 if (ret == -ENOTSUP)
14251 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14253 RTE_PMD_I40E_PKG_OP_WR_ADD);
14256 if (ret == -EEXIST)
14257 printf("Profile has already existed.\n");
14259 printf("Failed to load profile.\n");
14260 else if (file_num == 2)
14261 save_file(file_fld[1], buff, size);
14264 free((void *)filepath);
14267 cmdline_parse_inst_t cmd_ddp_add = {
14268 .f = cmd_ddp_add_parsed,
14270 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14272 (void *)&cmd_ddp_add_ddp,
14273 (void *)&cmd_ddp_add_add,
14274 (void *)&cmd_ddp_add_port_id,
14275 (void *)&cmd_ddp_add_filepath,
14280 /* Delete dynamic device personalization*/
14281 struct cmd_ddp_del_result {
14282 cmdline_fixed_string_t ddp;
14283 cmdline_fixed_string_t del;
14288 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14289 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14290 cmdline_parse_token_string_t cmd_ddp_del_del =
14291 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14292 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14293 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14294 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14295 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14298 cmd_ddp_del_parsed(
14299 void *parsed_result,
14300 __rte_unused struct cmdline *cl,
14301 __rte_unused void *data)
14303 struct cmd_ddp_del_result *res = parsed_result;
14306 int ret = -ENOTSUP;
14308 if (!all_ports_stopped()) {
14309 printf("Please stop all ports first\n");
14313 buff = open_file(res->filepath, &size);
14317 #ifdef RTE_NET_I40E
14318 if (ret == -ENOTSUP)
14319 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14321 RTE_PMD_I40E_PKG_OP_WR_DEL);
14324 if (ret == -EACCES)
14325 printf("Profile does not exist.\n");
14327 printf("Failed to delete profile.\n");
14332 cmdline_parse_inst_t cmd_ddp_del = {
14333 .f = cmd_ddp_del_parsed,
14335 .help_str = "ddp del <port_id> <backup_profile_path>",
14337 (void *)&cmd_ddp_del_ddp,
14338 (void *)&cmd_ddp_del_del,
14339 (void *)&cmd_ddp_del_port_id,
14340 (void *)&cmd_ddp_del_filepath,
14345 /* Get dynamic device personalization profile info */
14346 struct cmd_ddp_info_result {
14347 cmdline_fixed_string_t ddp;
14348 cmdline_fixed_string_t get;
14349 cmdline_fixed_string_t info;
14353 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14354 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14355 cmdline_parse_token_string_t cmd_ddp_info_get =
14356 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14357 cmdline_parse_token_string_t cmd_ddp_info_info =
14358 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14359 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14360 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14363 cmd_ddp_info_parsed(
14364 void *parsed_result,
14365 __rte_unused struct cmdline *cl,
14366 __rte_unused void *data)
14368 struct cmd_ddp_info_result *res = parsed_result;
14371 int ret = -ENOTSUP;
14372 #ifdef RTE_NET_I40E
14375 uint32_t buff_size = 0;
14376 struct rte_pmd_i40e_profile_info info;
14377 uint32_t dev_num = 0;
14378 struct rte_pmd_i40e_ddp_device_id *devs;
14379 uint32_t proto_num = 0;
14380 struct rte_pmd_i40e_proto_info *proto = NULL;
14381 uint32_t pctype_num = 0;
14382 struct rte_pmd_i40e_ptype_info *pctype;
14383 uint32_t ptype_num = 0;
14384 struct rte_pmd_i40e_ptype_info *ptype;
14389 pkg = open_file(res->filepath, &pkg_size);
14393 #ifdef RTE_NET_I40E
14394 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14395 (uint8_t *)&info, sizeof(info),
14396 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14398 printf("Global Track id: 0x%x\n", info.track_id);
14399 printf("Global Version: %d.%d.%d.%d\n",
14400 info.version.major,
14401 info.version.minor,
14402 info.version.update,
14403 info.version.draft);
14404 printf("Global Package name: %s\n\n", info.name);
14407 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14408 (uint8_t *)&info, sizeof(info),
14409 RTE_PMD_I40E_PKG_INFO_HEADER);
14411 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14412 printf("i40e Profile Version: %d.%d.%d.%d\n",
14413 info.version.major,
14414 info.version.minor,
14415 info.version.update,
14416 info.version.draft);
14417 printf("i40e Profile name: %s\n\n", info.name);
14420 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14421 (uint8_t *)&buff_size, sizeof(buff_size),
14422 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14423 if (!ret && buff_size) {
14424 buff = (uint8_t *)malloc(buff_size);
14426 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14428 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14430 printf("Package Notes:\n%s\n\n", buff);
14435 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14436 (uint8_t *)&dev_num, sizeof(dev_num),
14437 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14438 if (!ret && dev_num) {
14439 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14440 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14442 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14443 (uint8_t *)devs, buff_size,
14444 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14446 printf("List of supported devices:\n");
14447 for (i = 0; i < dev_num; i++) {
14448 printf(" %04X:%04X %04X:%04X\n",
14449 devs[i].vendor_dev_id >> 16,
14450 devs[i].vendor_dev_id & 0xFFFF,
14451 devs[i].sub_vendor_dev_id >> 16,
14452 devs[i].sub_vendor_dev_id & 0xFFFF);
14460 /* get information about protocols and packet types */
14461 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14462 (uint8_t *)&proto_num, sizeof(proto_num),
14463 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14464 if (ret || !proto_num)
14465 goto no_print_return;
14467 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14468 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14470 goto no_print_return;
14472 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14474 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14476 printf("List of used protocols:\n");
14477 for (i = 0; i < proto_num; i++)
14478 printf(" %2u: %s\n", proto[i].proto_id,
14482 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14483 (uint8_t *)&pctype_num, sizeof(pctype_num),
14484 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14485 if (ret || !pctype_num)
14486 goto no_print_pctypes;
14488 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14489 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14491 goto no_print_pctypes;
14493 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14495 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14498 goto no_print_pctypes;
14501 printf("List of defined packet classification types:\n");
14502 for (i = 0; i < pctype_num; i++) {
14503 printf(" %2u:", pctype[i].ptype_id);
14504 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14505 proto_id = pctype[i].protocols[j];
14506 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14507 for (n = 0; n < proto_num; n++) {
14508 if (proto[n].proto_id == proto_id) {
14509 printf(" %s", proto[n].name);
14522 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14524 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14525 if (ret || !ptype_num)
14526 goto no_print_return;
14528 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14529 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14531 goto no_print_return;
14533 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14535 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14538 goto no_print_return;
14540 printf("List of defined packet types:\n");
14541 for (i = 0; i < ptype_num; i++) {
14542 printf(" %2u:", ptype[i].ptype_id);
14543 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14544 proto_id = ptype[i].protocols[j];
14545 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14546 for (n = 0; n < proto_num; n++) {
14547 if (proto[n].proto_id == proto_id) {
14548 printf(" %s", proto[n].name);
14564 if (ret == -ENOTSUP)
14565 printf("Function not supported in PMD driver\n");
14569 cmdline_parse_inst_t cmd_ddp_get_info = {
14570 .f = cmd_ddp_info_parsed,
14572 .help_str = "ddp get info <profile_path>",
14574 (void *)&cmd_ddp_info_ddp,
14575 (void *)&cmd_ddp_info_get,
14576 (void *)&cmd_ddp_info_info,
14577 (void *)&cmd_ddp_info_filepath,
14582 /* Get dynamic device personalization profile info list*/
14583 #define PROFILE_INFO_SIZE 48
14584 #define MAX_PROFILE_NUM 16
14586 struct cmd_ddp_get_list_result {
14587 cmdline_fixed_string_t ddp;
14588 cmdline_fixed_string_t get;
14589 cmdline_fixed_string_t list;
14593 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14594 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14595 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14596 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14597 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14598 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14599 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14600 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14604 cmd_ddp_get_list_parsed(
14605 __rte_unused void *parsed_result,
14606 __rte_unused struct cmdline *cl,
14607 __rte_unused void *data)
14609 #ifdef RTE_NET_I40E
14610 struct cmd_ddp_get_list_result *res = parsed_result;
14611 struct rte_pmd_i40e_profile_list *p_list;
14612 struct rte_pmd_i40e_profile_info *p_info;
14617 int ret = -ENOTSUP;
14619 #ifdef RTE_NET_I40E
14620 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14621 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14623 printf("%s: Failed to malloc buffer\n", __func__);
14627 if (ret == -ENOTSUP)
14628 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14629 (uint8_t *)p_list, size);
14632 p_num = p_list->p_count;
14633 printf("Profile number is: %d\n\n", p_num);
14635 for (i = 0; i < p_num; i++) {
14636 p_info = &p_list->p_info[i];
14637 printf("Profile %d:\n", i);
14638 printf("Track id: 0x%x\n", p_info->track_id);
14639 printf("Version: %d.%d.%d.%d\n",
14640 p_info->version.major,
14641 p_info->version.minor,
14642 p_info->version.update,
14643 p_info->version.draft);
14644 printf("Profile name: %s\n\n", p_info->name);
14652 printf("Failed to get ddp list\n");
14655 cmdline_parse_inst_t cmd_ddp_get_list = {
14656 .f = cmd_ddp_get_list_parsed,
14658 .help_str = "ddp get list <port_id>",
14660 (void *)&cmd_ddp_get_list_ddp,
14661 (void *)&cmd_ddp_get_list_get,
14662 (void *)&cmd_ddp_get_list_list,
14663 (void *)&cmd_ddp_get_list_port_id,
14668 /* Configure input set */
14669 struct cmd_cfg_input_set_result {
14670 cmdline_fixed_string_t port;
14671 cmdline_fixed_string_t cfg;
14673 cmdline_fixed_string_t pctype;
14675 cmdline_fixed_string_t inset_type;
14676 cmdline_fixed_string_t opt;
14677 cmdline_fixed_string_t field;
14682 cmd_cfg_input_set_parsed(
14683 __rte_unused void *parsed_result,
14684 __rte_unused struct cmdline *cl,
14685 __rte_unused void *data)
14687 #ifdef RTE_NET_I40E
14688 struct cmd_cfg_input_set_result *res = parsed_result;
14689 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14690 struct rte_pmd_i40e_inset inset;
14692 int ret = -ENOTSUP;
14694 if (!all_ports_stopped()) {
14695 printf("Please stop all ports first\n");
14699 #ifdef RTE_NET_I40E
14700 if (!strcmp(res->inset_type, "hash_inset"))
14701 inset_type = INSET_HASH;
14702 else if (!strcmp(res->inset_type, "fdir_inset"))
14703 inset_type = INSET_FDIR;
14704 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14705 inset_type = INSET_FDIR_FLX;
14706 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14707 &inset, inset_type);
14709 printf("Failed to get input set.\n");
14713 if (!strcmp(res->opt, "get")) {
14714 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14717 printf("Field index %d is enabled.\n", res->field_idx);
14719 printf("Field index %d is disabled.\n", res->field_idx);
14721 } else if (!strcmp(res->opt, "set"))
14722 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14724 else if (!strcmp(res->opt, "clear"))
14725 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14728 printf("Failed to configure input set field.\n");
14732 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14733 &inset, inset_type);
14735 printf("Failed to set input set.\n");
14740 if (ret == -ENOTSUP)
14741 printf("Function not supported\n");
14744 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14745 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14747 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14748 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14750 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14751 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14752 port_id, RTE_UINT16);
14753 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14754 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14756 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14757 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14758 pctype_id, RTE_UINT8);
14759 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14760 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14762 "hash_inset#fdir_inset#fdir_flx_inset");
14763 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14764 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14765 opt, "get#set#clear");
14766 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14767 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14769 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14770 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14771 field_idx, RTE_UINT8);
14773 cmdline_parse_inst_t cmd_cfg_input_set = {
14774 .f = cmd_cfg_input_set_parsed,
14776 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14777 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14779 (void *)&cmd_cfg_input_set_port,
14780 (void *)&cmd_cfg_input_set_cfg,
14781 (void *)&cmd_cfg_input_set_port_id,
14782 (void *)&cmd_cfg_input_set_pctype,
14783 (void *)&cmd_cfg_input_set_pctype_id,
14784 (void *)&cmd_cfg_input_set_inset_type,
14785 (void *)&cmd_cfg_input_set_opt,
14786 (void *)&cmd_cfg_input_set_field,
14787 (void *)&cmd_cfg_input_set_field_idx,
14792 /* Clear input set */
14793 struct cmd_clear_input_set_result {
14794 cmdline_fixed_string_t port;
14795 cmdline_fixed_string_t cfg;
14797 cmdline_fixed_string_t pctype;
14799 cmdline_fixed_string_t inset_type;
14800 cmdline_fixed_string_t clear;
14801 cmdline_fixed_string_t all;
14805 cmd_clear_input_set_parsed(
14806 __rte_unused void *parsed_result,
14807 __rte_unused struct cmdline *cl,
14808 __rte_unused void *data)
14810 #ifdef RTE_NET_I40E
14811 struct cmd_clear_input_set_result *res = parsed_result;
14812 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14813 struct rte_pmd_i40e_inset inset;
14815 int ret = -ENOTSUP;
14817 if (!all_ports_stopped()) {
14818 printf("Please stop all ports first\n");
14822 #ifdef RTE_NET_I40E
14823 if (!strcmp(res->inset_type, "hash_inset"))
14824 inset_type = INSET_HASH;
14825 else if (!strcmp(res->inset_type, "fdir_inset"))
14826 inset_type = INSET_FDIR;
14827 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14828 inset_type = INSET_FDIR_FLX;
14830 memset(&inset, 0, sizeof(inset));
14832 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14833 &inset, inset_type);
14835 printf("Failed to clear input set.\n");
14841 if (ret == -ENOTSUP)
14842 printf("Function not supported\n");
14845 cmdline_parse_token_string_t cmd_clear_input_set_port =
14846 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14848 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14849 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14851 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14852 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14853 port_id, RTE_UINT16);
14854 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14855 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14857 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14858 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14859 pctype_id, RTE_UINT8);
14860 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14861 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14863 "hash_inset#fdir_inset#fdir_flx_inset");
14864 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14865 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14867 cmdline_parse_token_string_t cmd_clear_input_set_all =
14868 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14871 cmdline_parse_inst_t cmd_clear_input_set = {
14872 .f = cmd_clear_input_set_parsed,
14874 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14875 "fdir_inset|fdir_flx_inset clear all",
14877 (void *)&cmd_clear_input_set_port,
14878 (void *)&cmd_clear_input_set_cfg,
14879 (void *)&cmd_clear_input_set_port_id,
14880 (void *)&cmd_clear_input_set_pctype,
14881 (void *)&cmd_clear_input_set_pctype_id,
14882 (void *)&cmd_clear_input_set_inset_type,
14883 (void *)&cmd_clear_input_set_clear,
14884 (void *)&cmd_clear_input_set_all,
14889 /* show vf stats */
14891 /* Common result structure for show vf stats */
14892 struct cmd_show_vf_stats_result {
14893 cmdline_fixed_string_t show;
14894 cmdline_fixed_string_t vf;
14895 cmdline_fixed_string_t stats;
14900 /* Common CLI fields show vf stats*/
14901 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14902 TOKEN_STRING_INITIALIZER
14903 (struct cmd_show_vf_stats_result,
14905 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14906 TOKEN_STRING_INITIALIZER
14907 (struct cmd_show_vf_stats_result,
14909 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14910 TOKEN_STRING_INITIALIZER
14911 (struct cmd_show_vf_stats_result,
14913 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14914 TOKEN_NUM_INITIALIZER
14915 (struct cmd_show_vf_stats_result,
14916 port_id, RTE_UINT16);
14917 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14918 TOKEN_NUM_INITIALIZER
14919 (struct cmd_show_vf_stats_result,
14920 vf_id, RTE_UINT16);
14923 cmd_show_vf_stats_parsed(
14924 void *parsed_result,
14925 __rte_unused struct cmdline *cl,
14926 __rte_unused void *data)
14928 struct cmd_show_vf_stats_result *res = parsed_result;
14929 struct rte_eth_stats stats;
14930 int ret = -ENOTSUP;
14931 static const char *nic_stats_border = "########################";
14933 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14936 memset(&stats, 0, sizeof(stats));
14938 #ifdef RTE_NET_I40E
14939 if (ret == -ENOTSUP)
14940 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14944 #ifdef RTE_NET_BNXT
14945 if (ret == -ENOTSUP)
14946 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14955 printf("invalid vf_id %d\n", res->vf_id);
14958 printf("invalid port_id %d\n", res->port_id);
14961 printf("function not implemented\n");
14964 printf("programming error: (%s)\n", strerror(-ret));
14967 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14968 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14970 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14972 stats.ipackets, stats.imissed, stats.ibytes);
14973 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14974 printf(" RX-nombuf: %-10"PRIu64"\n",
14976 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14978 stats.opackets, stats.oerrors, stats.obytes);
14980 printf(" %s############################%s\n",
14981 nic_stats_border, nic_stats_border);
14984 cmdline_parse_inst_t cmd_show_vf_stats = {
14985 .f = cmd_show_vf_stats_parsed,
14987 .help_str = "show vf stats <port_id> <vf_id>",
14989 (void *)&cmd_show_vf_stats_show,
14990 (void *)&cmd_show_vf_stats_vf,
14991 (void *)&cmd_show_vf_stats_stats,
14992 (void *)&cmd_show_vf_stats_port_id,
14993 (void *)&cmd_show_vf_stats_vf_id,
14998 /* clear vf stats */
15000 /* Common result structure for clear vf stats */
15001 struct cmd_clear_vf_stats_result {
15002 cmdline_fixed_string_t clear;
15003 cmdline_fixed_string_t vf;
15004 cmdline_fixed_string_t stats;
15009 /* Common CLI fields clear vf stats*/
15010 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15011 TOKEN_STRING_INITIALIZER
15012 (struct cmd_clear_vf_stats_result,
15014 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15015 TOKEN_STRING_INITIALIZER
15016 (struct cmd_clear_vf_stats_result,
15018 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15019 TOKEN_STRING_INITIALIZER
15020 (struct cmd_clear_vf_stats_result,
15022 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15023 TOKEN_NUM_INITIALIZER
15024 (struct cmd_clear_vf_stats_result,
15025 port_id, RTE_UINT16);
15026 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15027 TOKEN_NUM_INITIALIZER
15028 (struct cmd_clear_vf_stats_result,
15029 vf_id, RTE_UINT16);
15032 cmd_clear_vf_stats_parsed(
15033 void *parsed_result,
15034 __rte_unused struct cmdline *cl,
15035 __rte_unused void *data)
15037 struct cmd_clear_vf_stats_result *res = parsed_result;
15038 int ret = -ENOTSUP;
15040 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15043 #ifdef RTE_NET_I40E
15044 if (ret == -ENOTSUP)
15045 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15048 #ifdef RTE_NET_BNXT
15049 if (ret == -ENOTSUP)
15050 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15058 printf("invalid vf_id %d\n", res->vf_id);
15061 printf("invalid port_id %d\n", res->port_id);
15064 printf("function not implemented\n");
15067 printf("programming error: (%s)\n", strerror(-ret));
15071 cmdline_parse_inst_t cmd_clear_vf_stats = {
15072 .f = cmd_clear_vf_stats_parsed,
15074 .help_str = "clear vf stats <port_id> <vf_id>",
15076 (void *)&cmd_clear_vf_stats_clear,
15077 (void *)&cmd_clear_vf_stats_vf,
15078 (void *)&cmd_clear_vf_stats_stats,
15079 (void *)&cmd_clear_vf_stats_port_id,
15080 (void *)&cmd_clear_vf_stats_vf_id,
15085 /* port config pctype mapping reset */
15087 /* Common result structure for port config pctype mapping reset */
15088 struct cmd_pctype_mapping_reset_result {
15089 cmdline_fixed_string_t port;
15090 cmdline_fixed_string_t config;
15092 cmdline_fixed_string_t pctype;
15093 cmdline_fixed_string_t mapping;
15094 cmdline_fixed_string_t reset;
15097 /* Common CLI fields for port config pctype mapping reset*/
15098 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15099 TOKEN_STRING_INITIALIZER
15100 (struct cmd_pctype_mapping_reset_result,
15102 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15103 TOKEN_STRING_INITIALIZER
15104 (struct cmd_pctype_mapping_reset_result,
15106 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15107 TOKEN_NUM_INITIALIZER
15108 (struct cmd_pctype_mapping_reset_result,
15109 port_id, RTE_UINT16);
15110 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15111 TOKEN_STRING_INITIALIZER
15112 (struct cmd_pctype_mapping_reset_result,
15114 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15115 TOKEN_STRING_INITIALIZER
15116 (struct cmd_pctype_mapping_reset_result,
15117 mapping, "mapping");
15118 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15119 TOKEN_STRING_INITIALIZER
15120 (struct cmd_pctype_mapping_reset_result,
15124 cmd_pctype_mapping_reset_parsed(
15125 void *parsed_result,
15126 __rte_unused struct cmdline *cl,
15127 __rte_unused void *data)
15129 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15130 int ret = -ENOTSUP;
15132 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15135 #ifdef RTE_NET_I40E
15136 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15143 printf("invalid port_id %d\n", res->port_id);
15146 printf("function not implemented\n");
15149 printf("programming error: (%s)\n", strerror(-ret));
15153 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15154 .f = cmd_pctype_mapping_reset_parsed,
15156 .help_str = "port config <port_id> pctype mapping reset",
15158 (void *)&cmd_pctype_mapping_reset_port,
15159 (void *)&cmd_pctype_mapping_reset_config,
15160 (void *)&cmd_pctype_mapping_reset_port_id,
15161 (void *)&cmd_pctype_mapping_reset_pctype,
15162 (void *)&cmd_pctype_mapping_reset_mapping,
15163 (void *)&cmd_pctype_mapping_reset_reset,
15168 /* show port pctype mapping */
15170 /* Common result structure for show port pctype mapping */
15171 struct cmd_pctype_mapping_get_result {
15172 cmdline_fixed_string_t show;
15173 cmdline_fixed_string_t port;
15175 cmdline_fixed_string_t pctype;
15176 cmdline_fixed_string_t mapping;
15179 /* Common CLI fields for pctype mapping get */
15180 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15181 TOKEN_STRING_INITIALIZER
15182 (struct cmd_pctype_mapping_get_result,
15184 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15185 TOKEN_STRING_INITIALIZER
15186 (struct cmd_pctype_mapping_get_result,
15188 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15189 TOKEN_NUM_INITIALIZER
15190 (struct cmd_pctype_mapping_get_result,
15191 port_id, RTE_UINT16);
15192 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15193 TOKEN_STRING_INITIALIZER
15194 (struct cmd_pctype_mapping_get_result,
15196 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15197 TOKEN_STRING_INITIALIZER
15198 (struct cmd_pctype_mapping_get_result,
15199 mapping, "mapping");
15202 cmd_pctype_mapping_get_parsed(
15203 void *parsed_result,
15204 __rte_unused struct cmdline *cl,
15205 __rte_unused void *data)
15207 struct cmd_pctype_mapping_get_result *res = parsed_result;
15208 int ret = -ENOTSUP;
15209 #ifdef RTE_NET_I40E
15210 struct rte_pmd_i40e_flow_type_mapping
15211 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15212 int i, j, first_pctype;
15215 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15218 #ifdef RTE_NET_I40E
15219 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15226 printf("invalid port_id %d\n", res->port_id);
15229 printf("function not implemented\n");
15232 printf("programming error: (%s)\n", strerror(-ret));
15236 #ifdef RTE_NET_I40E
15237 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15238 if (mapping[i].pctype != 0ULL) {
15241 printf("pctype: ");
15242 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15243 if (mapping[i].pctype & (1ULL << j)) {
15244 printf(first_pctype ?
15245 "%02d" : ",%02d", j);
15249 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15255 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15256 .f = cmd_pctype_mapping_get_parsed,
15258 .help_str = "show port <port_id> pctype mapping",
15260 (void *)&cmd_pctype_mapping_get_show,
15261 (void *)&cmd_pctype_mapping_get_port,
15262 (void *)&cmd_pctype_mapping_get_port_id,
15263 (void *)&cmd_pctype_mapping_get_pctype,
15264 (void *)&cmd_pctype_mapping_get_mapping,
15269 /* port config pctype mapping update */
15271 /* Common result structure for port config pctype mapping update */
15272 struct cmd_pctype_mapping_update_result {
15273 cmdline_fixed_string_t port;
15274 cmdline_fixed_string_t config;
15276 cmdline_fixed_string_t pctype;
15277 cmdline_fixed_string_t mapping;
15278 cmdline_fixed_string_t update;
15279 cmdline_fixed_string_t pctype_list;
15280 uint16_t flow_type;
15283 /* Common CLI fields for pctype mapping update*/
15284 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15285 TOKEN_STRING_INITIALIZER
15286 (struct cmd_pctype_mapping_update_result,
15288 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15289 TOKEN_STRING_INITIALIZER
15290 (struct cmd_pctype_mapping_update_result,
15292 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15293 TOKEN_NUM_INITIALIZER
15294 (struct cmd_pctype_mapping_update_result,
15295 port_id, RTE_UINT16);
15296 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15297 TOKEN_STRING_INITIALIZER
15298 (struct cmd_pctype_mapping_update_result,
15300 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15301 TOKEN_STRING_INITIALIZER
15302 (struct cmd_pctype_mapping_update_result,
15303 mapping, "mapping");
15304 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15305 TOKEN_STRING_INITIALIZER
15306 (struct cmd_pctype_mapping_update_result,
15308 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15309 TOKEN_STRING_INITIALIZER
15310 (struct cmd_pctype_mapping_update_result,
15311 pctype_list, NULL);
15312 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15313 TOKEN_NUM_INITIALIZER
15314 (struct cmd_pctype_mapping_update_result,
15315 flow_type, RTE_UINT16);
15318 cmd_pctype_mapping_update_parsed(
15319 void *parsed_result,
15320 __rte_unused struct cmdline *cl,
15321 __rte_unused void *data)
15323 struct cmd_pctype_mapping_update_result *res = parsed_result;
15324 int ret = -ENOTSUP;
15325 #ifdef RTE_NET_I40E
15326 struct rte_pmd_i40e_flow_type_mapping mapping;
15328 unsigned int nb_item;
15329 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15332 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15335 #ifdef RTE_NET_I40E
15336 nb_item = parse_item_list(res->pctype_list, "pctypes",
15337 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15338 mapping.flow_type = res->flow_type;
15339 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15340 mapping.pctype |= (1ULL << pctype_list[i]);
15341 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15351 printf("invalid pctype or flow type\n");
15354 printf("invalid port_id %d\n", res->port_id);
15357 printf("function not implemented\n");
15360 printf("programming error: (%s)\n", strerror(-ret));
15364 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15365 .f = cmd_pctype_mapping_update_parsed,
15367 .help_str = "port config <port_id> pctype mapping update"
15368 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15370 (void *)&cmd_pctype_mapping_update_port,
15371 (void *)&cmd_pctype_mapping_update_config,
15372 (void *)&cmd_pctype_mapping_update_port_id,
15373 (void *)&cmd_pctype_mapping_update_pctype,
15374 (void *)&cmd_pctype_mapping_update_mapping,
15375 (void *)&cmd_pctype_mapping_update_update,
15376 (void *)&cmd_pctype_mapping_update_pc_type,
15377 (void *)&cmd_pctype_mapping_update_flow_type,
15382 /* ptype mapping get */
15384 /* Common result structure for ptype mapping get */
15385 struct cmd_ptype_mapping_get_result {
15386 cmdline_fixed_string_t ptype;
15387 cmdline_fixed_string_t mapping;
15388 cmdline_fixed_string_t get;
15390 uint8_t valid_only;
15393 /* Common CLI fields for ptype mapping get */
15394 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15395 TOKEN_STRING_INITIALIZER
15396 (struct cmd_ptype_mapping_get_result,
15398 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15399 TOKEN_STRING_INITIALIZER
15400 (struct cmd_ptype_mapping_get_result,
15401 mapping, "mapping");
15402 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15403 TOKEN_STRING_INITIALIZER
15404 (struct cmd_ptype_mapping_get_result,
15406 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15407 TOKEN_NUM_INITIALIZER
15408 (struct cmd_ptype_mapping_get_result,
15409 port_id, RTE_UINT16);
15410 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15411 TOKEN_NUM_INITIALIZER
15412 (struct cmd_ptype_mapping_get_result,
15413 valid_only, RTE_UINT8);
15416 cmd_ptype_mapping_get_parsed(
15417 void *parsed_result,
15418 __rte_unused struct cmdline *cl,
15419 __rte_unused void *data)
15421 struct cmd_ptype_mapping_get_result *res = parsed_result;
15422 int ret = -ENOTSUP;
15423 #ifdef RTE_NET_I40E
15424 int max_ptype_num = 256;
15425 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15430 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15433 #ifdef RTE_NET_I40E
15434 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15445 printf("invalid port_id %d\n", res->port_id);
15448 printf("function not implemented\n");
15451 printf("programming error: (%s)\n", strerror(-ret));
15454 #ifdef RTE_NET_I40E
15456 for (i = 0; i < count; i++)
15457 printf("%3d\t0x%08x\n",
15458 mapping[i].hw_ptype, mapping[i].sw_ptype);
15463 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15464 .f = cmd_ptype_mapping_get_parsed,
15466 .help_str = "ptype mapping get <port_id> <valid_only>",
15468 (void *)&cmd_ptype_mapping_get_ptype,
15469 (void *)&cmd_ptype_mapping_get_mapping,
15470 (void *)&cmd_ptype_mapping_get_get,
15471 (void *)&cmd_ptype_mapping_get_port_id,
15472 (void *)&cmd_ptype_mapping_get_valid_only,
15477 /* ptype mapping replace */
15479 /* Common result structure for ptype mapping replace */
15480 struct cmd_ptype_mapping_replace_result {
15481 cmdline_fixed_string_t ptype;
15482 cmdline_fixed_string_t mapping;
15483 cmdline_fixed_string_t replace;
15490 /* Common CLI fields for ptype mapping replace */
15491 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15492 TOKEN_STRING_INITIALIZER
15493 (struct cmd_ptype_mapping_replace_result,
15495 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15496 TOKEN_STRING_INITIALIZER
15497 (struct cmd_ptype_mapping_replace_result,
15498 mapping, "mapping");
15499 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15500 TOKEN_STRING_INITIALIZER
15501 (struct cmd_ptype_mapping_replace_result,
15502 replace, "replace");
15503 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15504 TOKEN_NUM_INITIALIZER
15505 (struct cmd_ptype_mapping_replace_result,
15506 port_id, RTE_UINT16);
15507 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15508 TOKEN_NUM_INITIALIZER
15509 (struct cmd_ptype_mapping_replace_result,
15510 target, RTE_UINT32);
15511 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15512 TOKEN_NUM_INITIALIZER
15513 (struct cmd_ptype_mapping_replace_result,
15515 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15516 TOKEN_NUM_INITIALIZER
15517 (struct cmd_ptype_mapping_replace_result,
15518 pkt_type, RTE_UINT32);
15521 cmd_ptype_mapping_replace_parsed(
15522 void *parsed_result,
15523 __rte_unused struct cmdline *cl,
15524 __rte_unused void *data)
15526 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15527 int ret = -ENOTSUP;
15529 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15532 #ifdef RTE_NET_I40E
15533 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15543 printf("invalid ptype 0x%8x or 0x%8x\n",
15544 res->target, res->pkt_type);
15547 printf("invalid port_id %d\n", res->port_id);
15550 printf("function not implemented\n");
15553 printf("programming error: (%s)\n", strerror(-ret));
15557 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15558 .f = cmd_ptype_mapping_replace_parsed,
15561 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15563 (void *)&cmd_ptype_mapping_replace_ptype,
15564 (void *)&cmd_ptype_mapping_replace_mapping,
15565 (void *)&cmd_ptype_mapping_replace_replace,
15566 (void *)&cmd_ptype_mapping_replace_port_id,
15567 (void *)&cmd_ptype_mapping_replace_target,
15568 (void *)&cmd_ptype_mapping_replace_mask,
15569 (void *)&cmd_ptype_mapping_replace_pkt_type,
15574 /* ptype mapping reset */
15576 /* Common result structure for ptype mapping reset */
15577 struct cmd_ptype_mapping_reset_result {
15578 cmdline_fixed_string_t ptype;
15579 cmdline_fixed_string_t mapping;
15580 cmdline_fixed_string_t reset;
15584 /* Common CLI fields for ptype mapping reset*/
15585 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15586 TOKEN_STRING_INITIALIZER
15587 (struct cmd_ptype_mapping_reset_result,
15589 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15590 TOKEN_STRING_INITIALIZER
15591 (struct cmd_ptype_mapping_reset_result,
15592 mapping, "mapping");
15593 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15594 TOKEN_STRING_INITIALIZER
15595 (struct cmd_ptype_mapping_reset_result,
15597 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15598 TOKEN_NUM_INITIALIZER
15599 (struct cmd_ptype_mapping_reset_result,
15600 port_id, RTE_UINT16);
15603 cmd_ptype_mapping_reset_parsed(
15604 void *parsed_result,
15605 __rte_unused struct cmdline *cl,
15606 __rte_unused void *data)
15608 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15609 int ret = -ENOTSUP;
15611 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15614 #ifdef RTE_NET_I40E
15615 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15622 printf("invalid port_id %d\n", res->port_id);
15625 printf("function not implemented\n");
15628 printf("programming error: (%s)\n", strerror(-ret));
15632 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15633 .f = cmd_ptype_mapping_reset_parsed,
15635 .help_str = "ptype mapping reset <port_id>",
15637 (void *)&cmd_ptype_mapping_reset_ptype,
15638 (void *)&cmd_ptype_mapping_reset_mapping,
15639 (void *)&cmd_ptype_mapping_reset_reset,
15640 (void *)&cmd_ptype_mapping_reset_port_id,
15645 /* ptype mapping update */
15647 /* Common result structure for ptype mapping update */
15648 struct cmd_ptype_mapping_update_result {
15649 cmdline_fixed_string_t ptype;
15650 cmdline_fixed_string_t mapping;
15651 cmdline_fixed_string_t reset;
15657 /* Common CLI fields for ptype mapping update*/
15658 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15659 TOKEN_STRING_INITIALIZER
15660 (struct cmd_ptype_mapping_update_result,
15662 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15663 TOKEN_STRING_INITIALIZER
15664 (struct cmd_ptype_mapping_update_result,
15665 mapping, "mapping");
15666 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15667 TOKEN_STRING_INITIALIZER
15668 (struct cmd_ptype_mapping_update_result,
15670 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15671 TOKEN_NUM_INITIALIZER
15672 (struct cmd_ptype_mapping_update_result,
15673 port_id, RTE_UINT16);
15674 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15675 TOKEN_NUM_INITIALIZER
15676 (struct cmd_ptype_mapping_update_result,
15677 hw_ptype, RTE_UINT8);
15678 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15679 TOKEN_NUM_INITIALIZER
15680 (struct cmd_ptype_mapping_update_result,
15681 sw_ptype, RTE_UINT32);
15684 cmd_ptype_mapping_update_parsed(
15685 void *parsed_result,
15686 __rte_unused struct cmdline *cl,
15687 __rte_unused void *data)
15689 struct cmd_ptype_mapping_update_result *res = parsed_result;
15690 int ret = -ENOTSUP;
15691 #ifdef RTE_NET_I40E
15692 struct rte_pmd_i40e_ptype_mapping mapping;
15694 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15697 #ifdef RTE_NET_I40E
15698 mapping.hw_ptype = res->hw_ptype;
15699 mapping.sw_ptype = res->sw_ptype;
15700 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15710 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15713 printf("invalid port_id %d\n", res->port_id);
15716 printf("function not implemented\n");
15719 printf("programming error: (%s)\n", strerror(-ret));
15723 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15724 .f = cmd_ptype_mapping_update_parsed,
15726 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15728 (void *)&cmd_ptype_mapping_update_ptype,
15729 (void *)&cmd_ptype_mapping_update_mapping,
15730 (void *)&cmd_ptype_mapping_update_update,
15731 (void *)&cmd_ptype_mapping_update_port_id,
15732 (void *)&cmd_ptype_mapping_update_hw_ptype,
15733 (void *)&cmd_ptype_mapping_update_sw_ptype,
15738 /* Common result structure for file commands */
15739 struct cmd_cmdfile_result {
15740 cmdline_fixed_string_t load;
15741 cmdline_fixed_string_t filename;
15744 /* Common CLI fields for file commands */
15745 cmdline_parse_token_string_t cmd_load_cmdfile =
15746 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15747 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15748 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15751 cmd_load_from_file_parsed(
15752 void *parsed_result,
15753 __rte_unused struct cmdline *cl,
15754 __rte_unused void *data)
15756 struct cmd_cmdfile_result *res = parsed_result;
15758 cmdline_read_from_file(res->filename);
15761 cmdline_parse_inst_t cmd_load_from_file = {
15762 .f = cmd_load_from_file_parsed,
15764 .help_str = "load <filename>",
15766 (void *)&cmd_load_cmdfile,
15767 (void *)&cmd_load_cmdfile_filename,
15772 /* Get Rx offloads capabilities */
15773 struct cmd_rx_offload_get_capa_result {
15774 cmdline_fixed_string_t show;
15775 cmdline_fixed_string_t port;
15777 cmdline_fixed_string_t rx_offload;
15778 cmdline_fixed_string_t capabilities;
15781 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15782 TOKEN_STRING_INITIALIZER
15783 (struct cmd_rx_offload_get_capa_result,
15785 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15786 TOKEN_STRING_INITIALIZER
15787 (struct cmd_rx_offload_get_capa_result,
15789 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15790 TOKEN_NUM_INITIALIZER
15791 (struct cmd_rx_offload_get_capa_result,
15792 port_id, RTE_UINT16);
15793 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15794 TOKEN_STRING_INITIALIZER
15795 (struct cmd_rx_offload_get_capa_result,
15796 rx_offload, "rx_offload");
15797 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15798 TOKEN_STRING_INITIALIZER
15799 (struct cmd_rx_offload_get_capa_result,
15800 capabilities, "capabilities");
15803 print_rx_offloads(uint64_t offloads)
15805 uint64_t single_offload;
15813 begin = __builtin_ctzll(offloads);
15814 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15816 single_offload = 1ULL << begin;
15817 for (bit = begin; bit < end; bit++) {
15818 if (offloads & single_offload)
15820 rte_eth_dev_rx_offload_name(single_offload));
15821 single_offload <<= 1;
15826 cmd_rx_offload_get_capa_parsed(
15827 void *parsed_result,
15828 __rte_unused struct cmdline *cl,
15829 __rte_unused void *data)
15831 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15832 struct rte_eth_dev_info dev_info;
15833 portid_t port_id = res->port_id;
15834 uint64_t queue_offloads;
15835 uint64_t port_offloads;
15838 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15842 queue_offloads = dev_info.rx_queue_offload_capa;
15843 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15845 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15846 printf(" Per Queue :");
15847 print_rx_offloads(queue_offloads);
15850 printf(" Per Port :");
15851 print_rx_offloads(port_offloads);
15855 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15856 .f = cmd_rx_offload_get_capa_parsed,
15858 .help_str = "show port <port_id> rx_offload capabilities",
15860 (void *)&cmd_rx_offload_get_capa_show,
15861 (void *)&cmd_rx_offload_get_capa_port,
15862 (void *)&cmd_rx_offload_get_capa_port_id,
15863 (void *)&cmd_rx_offload_get_capa_rx_offload,
15864 (void *)&cmd_rx_offload_get_capa_capabilities,
15869 /* Get Rx offloads configuration */
15870 struct cmd_rx_offload_get_configuration_result {
15871 cmdline_fixed_string_t show;
15872 cmdline_fixed_string_t port;
15874 cmdline_fixed_string_t rx_offload;
15875 cmdline_fixed_string_t configuration;
15878 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15879 TOKEN_STRING_INITIALIZER
15880 (struct cmd_rx_offload_get_configuration_result,
15882 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15883 TOKEN_STRING_INITIALIZER
15884 (struct cmd_rx_offload_get_configuration_result,
15886 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15887 TOKEN_NUM_INITIALIZER
15888 (struct cmd_rx_offload_get_configuration_result,
15889 port_id, RTE_UINT16);
15890 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15891 TOKEN_STRING_INITIALIZER
15892 (struct cmd_rx_offload_get_configuration_result,
15893 rx_offload, "rx_offload");
15894 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15895 TOKEN_STRING_INITIALIZER
15896 (struct cmd_rx_offload_get_configuration_result,
15897 configuration, "configuration");
15900 cmd_rx_offload_get_configuration_parsed(
15901 void *parsed_result,
15902 __rte_unused struct cmdline *cl,
15903 __rte_unused void *data)
15905 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15906 struct rte_eth_dev_info dev_info;
15907 portid_t port_id = res->port_id;
15908 struct rte_port *port = &ports[port_id];
15909 uint64_t port_offloads;
15910 uint64_t queue_offloads;
15911 uint16_t nb_rx_queues;
15915 printf("Rx Offloading Configuration of port %d :\n", port_id);
15917 port_offloads = port->dev_conf.rxmode.offloads;
15919 print_rx_offloads(port_offloads);
15922 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15926 nb_rx_queues = dev_info.nb_rx_queues;
15927 for (q = 0; q < nb_rx_queues; q++) {
15928 queue_offloads = port->rx_conf[q].offloads;
15929 printf(" Queue[%2d] :", q);
15930 print_rx_offloads(queue_offloads);
15936 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15937 .f = cmd_rx_offload_get_configuration_parsed,
15939 .help_str = "show port <port_id> rx_offload configuration",
15941 (void *)&cmd_rx_offload_get_configuration_show,
15942 (void *)&cmd_rx_offload_get_configuration_port,
15943 (void *)&cmd_rx_offload_get_configuration_port_id,
15944 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15945 (void *)&cmd_rx_offload_get_configuration_configuration,
15950 /* Enable/Disable a per port offloading */
15951 struct cmd_config_per_port_rx_offload_result {
15952 cmdline_fixed_string_t port;
15953 cmdline_fixed_string_t config;
15955 cmdline_fixed_string_t rx_offload;
15956 cmdline_fixed_string_t offload;
15957 cmdline_fixed_string_t on_off;
15960 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15961 TOKEN_STRING_INITIALIZER
15962 (struct cmd_config_per_port_rx_offload_result,
15964 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15965 TOKEN_STRING_INITIALIZER
15966 (struct cmd_config_per_port_rx_offload_result,
15968 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15969 TOKEN_NUM_INITIALIZER
15970 (struct cmd_config_per_port_rx_offload_result,
15971 port_id, RTE_UINT16);
15972 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15973 TOKEN_STRING_INITIALIZER
15974 (struct cmd_config_per_port_rx_offload_result,
15975 rx_offload, "rx_offload");
15976 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15977 TOKEN_STRING_INITIALIZER
15978 (struct cmd_config_per_port_rx_offload_result,
15979 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15980 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15981 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15982 "scatter#buffer_split#timestamp#security#"
15983 "keep_crc#rss_hash");
15984 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15985 TOKEN_STRING_INITIALIZER
15986 (struct cmd_config_per_port_rx_offload_result,
15990 search_rx_offload(const char *name)
15992 uint64_t single_offload;
15993 const char *single_name;
15997 single_offload = 1;
15998 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15999 single_name = rte_eth_dev_rx_offload_name(single_offload);
16000 if (!strcasecmp(single_name, name)) {
16004 single_offload <<= 1;
16008 return single_offload;
16014 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16015 __rte_unused struct cmdline *cl,
16016 __rte_unused void *data)
16018 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16019 portid_t port_id = res->port_id;
16020 struct rte_eth_dev_info dev_info;
16021 struct rte_port *port = &ports[port_id];
16022 uint64_t single_offload;
16023 uint16_t nb_rx_queues;
16027 if (port->port_status != RTE_PORT_STOPPED) {
16028 printf("Error: Can't config offload when Port %d "
16029 "is not stopped\n", port_id);
16033 single_offload = search_rx_offload(res->offload);
16034 if (single_offload == 0) {
16035 printf("Unknown offload name: %s\n", res->offload);
16039 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16043 nb_rx_queues = dev_info.nb_rx_queues;
16044 if (!strcmp(res->on_off, "on")) {
16045 port->dev_conf.rxmode.offloads |= single_offload;
16046 for (q = 0; q < nb_rx_queues; q++)
16047 port->rx_conf[q].offloads |= single_offload;
16049 port->dev_conf.rxmode.offloads &= ~single_offload;
16050 for (q = 0; q < nb_rx_queues; q++)
16051 port->rx_conf[q].offloads &= ~single_offload;
16054 cmd_reconfig_device_queue(port_id, 1, 1);
16057 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16058 .f = cmd_config_per_port_rx_offload_parsed,
16060 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16061 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16062 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16063 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16064 "keep_crc|rss_hash on|off",
16066 (void *)&cmd_config_per_port_rx_offload_result_port,
16067 (void *)&cmd_config_per_port_rx_offload_result_config,
16068 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16069 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16070 (void *)&cmd_config_per_port_rx_offload_result_offload,
16071 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16076 /* Enable/Disable a per queue offloading */
16077 struct cmd_config_per_queue_rx_offload_result {
16078 cmdline_fixed_string_t port;
16080 cmdline_fixed_string_t rxq;
16082 cmdline_fixed_string_t rx_offload;
16083 cmdline_fixed_string_t offload;
16084 cmdline_fixed_string_t on_off;
16087 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16088 TOKEN_STRING_INITIALIZER
16089 (struct cmd_config_per_queue_rx_offload_result,
16091 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16092 TOKEN_NUM_INITIALIZER
16093 (struct cmd_config_per_queue_rx_offload_result,
16094 port_id, RTE_UINT16);
16095 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16096 TOKEN_STRING_INITIALIZER
16097 (struct cmd_config_per_queue_rx_offload_result,
16099 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16100 TOKEN_NUM_INITIALIZER
16101 (struct cmd_config_per_queue_rx_offload_result,
16102 queue_id, RTE_UINT16);
16103 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16104 TOKEN_STRING_INITIALIZER
16105 (struct cmd_config_per_queue_rx_offload_result,
16106 rx_offload, "rx_offload");
16107 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16108 TOKEN_STRING_INITIALIZER
16109 (struct cmd_config_per_queue_rx_offload_result,
16110 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16111 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16112 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16113 "scatter#buffer_split#timestamp#security#keep_crc");
16114 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16115 TOKEN_STRING_INITIALIZER
16116 (struct cmd_config_per_queue_rx_offload_result,
16120 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16121 __rte_unused struct cmdline *cl,
16122 __rte_unused void *data)
16124 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16125 struct rte_eth_dev_info dev_info;
16126 portid_t port_id = res->port_id;
16127 uint16_t queue_id = res->queue_id;
16128 struct rte_port *port = &ports[port_id];
16129 uint64_t single_offload;
16132 if (port->port_status != RTE_PORT_STOPPED) {
16133 printf("Error: Can't config offload when Port %d "
16134 "is not stopped\n", port_id);
16138 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16142 if (queue_id >= dev_info.nb_rx_queues) {
16143 printf("Error: input queue_id should be 0 ... "
16144 "%d\n", dev_info.nb_rx_queues - 1);
16148 single_offload = search_rx_offload(res->offload);
16149 if (single_offload == 0) {
16150 printf("Unknown offload name: %s\n", res->offload);
16154 if (!strcmp(res->on_off, "on"))
16155 port->rx_conf[queue_id].offloads |= single_offload;
16157 port->rx_conf[queue_id].offloads &= ~single_offload;
16159 cmd_reconfig_device_queue(port_id, 1, 1);
16162 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16163 .f = cmd_config_per_queue_rx_offload_parsed,
16165 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16166 "vlan_strip|ipv4_cksum|"
16167 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16168 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16169 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16172 (void *)&cmd_config_per_queue_rx_offload_result_port,
16173 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16174 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16175 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16176 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16177 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16178 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16183 /* Get Tx offloads capabilities */
16184 struct cmd_tx_offload_get_capa_result {
16185 cmdline_fixed_string_t show;
16186 cmdline_fixed_string_t port;
16188 cmdline_fixed_string_t tx_offload;
16189 cmdline_fixed_string_t capabilities;
16192 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16193 TOKEN_STRING_INITIALIZER
16194 (struct cmd_tx_offload_get_capa_result,
16196 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16197 TOKEN_STRING_INITIALIZER
16198 (struct cmd_tx_offload_get_capa_result,
16200 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16201 TOKEN_NUM_INITIALIZER
16202 (struct cmd_tx_offload_get_capa_result,
16203 port_id, RTE_UINT16);
16204 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16205 TOKEN_STRING_INITIALIZER
16206 (struct cmd_tx_offload_get_capa_result,
16207 tx_offload, "tx_offload");
16208 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16209 TOKEN_STRING_INITIALIZER
16210 (struct cmd_tx_offload_get_capa_result,
16211 capabilities, "capabilities");
16214 print_tx_offloads(uint64_t offloads)
16216 uint64_t single_offload;
16224 begin = __builtin_ctzll(offloads);
16225 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16227 single_offload = 1ULL << begin;
16228 for (bit = begin; bit < end; bit++) {
16229 if (offloads & single_offload)
16231 rte_eth_dev_tx_offload_name(single_offload));
16232 single_offload <<= 1;
16237 cmd_tx_offload_get_capa_parsed(
16238 void *parsed_result,
16239 __rte_unused struct cmdline *cl,
16240 __rte_unused void *data)
16242 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16243 struct rte_eth_dev_info dev_info;
16244 portid_t port_id = res->port_id;
16245 uint64_t queue_offloads;
16246 uint64_t port_offloads;
16249 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16253 queue_offloads = dev_info.tx_queue_offload_capa;
16254 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16256 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16257 printf(" Per Queue :");
16258 print_tx_offloads(queue_offloads);
16261 printf(" Per Port :");
16262 print_tx_offloads(port_offloads);
16266 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16267 .f = cmd_tx_offload_get_capa_parsed,
16269 .help_str = "show port <port_id> tx_offload capabilities",
16271 (void *)&cmd_tx_offload_get_capa_show,
16272 (void *)&cmd_tx_offload_get_capa_port,
16273 (void *)&cmd_tx_offload_get_capa_port_id,
16274 (void *)&cmd_tx_offload_get_capa_tx_offload,
16275 (void *)&cmd_tx_offload_get_capa_capabilities,
16280 /* Get Tx offloads configuration */
16281 struct cmd_tx_offload_get_configuration_result {
16282 cmdline_fixed_string_t show;
16283 cmdline_fixed_string_t port;
16285 cmdline_fixed_string_t tx_offload;
16286 cmdline_fixed_string_t configuration;
16289 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16290 TOKEN_STRING_INITIALIZER
16291 (struct cmd_tx_offload_get_configuration_result,
16293 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16294 TOKEN_STRING_INITIALIZER
16295 (struct cmd_tx_offload_get_configuration_result,
16297 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16298 TOKEN_NUM_INITIALIZER
16299 (struct cmd_tx_offload_get_configuration_result,
16300 port_id, RTE_UINT16);
16301 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16302 TOKEN_STRING_INITIALIZER
16303 (struct cmd_tx_offload_get_configuration_result,
16304 tx_offload, "tx_offload");
16305 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16306 TOKEN_STRING_INITIALIZER
16307 (struct cmd_tx_offload_get_configuration_result,
16308 configuration, "configuration");
16311 cmd_tx_offload_get_configuration_parsed(
16312 void *parsed_result,
16313 __rte_unused struct cmdline *cl,
16314 __rte_unused void *data)
16316 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16317 struct rte_eth_dev_info dev_info;
16318 portid_t port_id = res->port_id;
16319 struct rte_port *port = &ports[port_id];
16320 uint64_t port_offloads;
16321 uint64_t queue_offloads;
16322 uint16_t nb_tx_queues;
16326 printf("Tx Offloading Configuration of port %d :\n", port_id);
16328 port_offloads = port->dev_conf.txmode.offloads;
16330 print_tx_offloads(port_offloads);
16333 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16337 nb_tx_queues = dev_info.nb_tx_queues;
16338 for (q = 0; q < nb_tx_queues; q++) {
16339 queue_offloads = port->tx_conf[q].offloads;
16340 printf(" Queue[%2d] :", q);
16341 print_tx_offloads(queue_offloads);
16347 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16348 .f = cmd_tx_offload_get_configuration_parsed,
16350 .help_str = "show port <port_id> tx_offload configuration",
16352 (void *)&cmd_tx_offload_get_configuration_show,
16353 (void *)&cmd_tx_offload_get_configuration_port,
16354 (void *)&cmd_tx_offload_get_configuration_port_id,
16355 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16356 (void *)&cmd_tx_offload_get_configuration_configuration,
16361 /* Enable/Disable a per port offloading */
16362 struct cmd_config_per_port_tx_offload_result {
16363 cmdline_fixed_string_t port;
16364 cmdline_fixed_string_t config;
16366 cmdline_fixed_string_t tx_offload;
16367 cmdline_fixed_string_t offload;
16368 cmdline_fixed_string_t on_off;
16371 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16372 TOKEN_STRING_INITIALIZER
16373 (struct cmd_config_per_port_tx_offload_result,
16375 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16376 TOKEN_STRING_INITIALIZER
16377 (struct cmd_config_per_port_tx_offload_result,
16379 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16380 TOKEN_NUM_INITIALIZER
16381 (struct cmd_config_per_port_tx_offload_result,
16382 port_id, RTE_UINT16);
16383 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16384 TOKEN_STRING_INITIALIZER
16385 (struct cmd_config_per_port_tx_offload_result,
16386 tx_offload, "tx_offload");
16387 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16388 TOKEN_STRING_INITIALIZER
16389 (struct cmd_config_per_port_tx_offload_result,
16390 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16391 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16392 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16393 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16394 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16395 "send_on_timestamp");
16396 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16397 TOKEN_STRING_INITIALIZER
16398 (struct cmd_config_per_port_tx_offload_result,
16402 search_tx_offload(const char *name)
16404 uint64_t single_offload;
16405 const char *single_name;
16409 single_offload = 1;
16410 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16411 single_name = rte_eth_dev_tx_offload_name(single_offload);
16412 if (single_name == NULL)
16414 if (!strcasecmp(single_name, name)) {
16417 } else if (!strcasecmp(single_name, "UNKNOWN"))
16419 single_offload <<= 1;
16423 return single_offload;
16429 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16430 __rte_unused struct cmdline *cl,
16431 __rte_unused void *data)
16433 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16434 portid_t port_id = res->port_id;
16435 struct rte_eth_dev_info dev_info;
16436 struct rte_port *port = &ports[port_id];
16437 uint64_t single_offload;
16438 uint16_t nb_tx_queues;
16442 if (port->port_status != RTE_PORT_STOPPED) {
16443 printf("Error: Can't config offload when Port %d "
16444 "is not stopped\n", port_id);
16448 single_offload = search_tx_offload(res->offload);
16449 if (single_offload == 0) {
16450 printf("Unknown offload name: %s\n", res->offload);
16454 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16458 nb_tx_queues = dev_info.nb_tx_queues;
16459 if (!strcmp(res->on_off, "on")) {
16460 port->dev_conf.txmode.offloads |= single_offload;
16461 for (q = 0; q < nb_tx_queues; q++)
16462 port->tx_conf[q].offloads |= single_offload;
16464 port->dev_conf.txmode.offloads &= ~single_offload;
16465 for (q = 0; q < nb_tx_queues; q++)
16466 port->tx_conf[q].offloads &= ~single_offload;
16469 cmd_reconfig_device_queue(port_id, 1, 1);
16472 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16473 .f = cmd_config_per_port_tx_offload_parsed,
16475 .help_str = "port config <port_id> tx_offload "
16476 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16477 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16478 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16479 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16480 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16481 "send_on_timestamp on|off",
16483 (void *)&cmd_config_per_port_tx_offload_result_port,
16484 (void *)&cmd_config_per_port_tx_offload_result_config,
16485 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16486 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16487 (void *)&cmd_config_per_port_tx_offload_result_offload,
16488 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16493 /* Enable/Disable a per queue offloading */
16494 struct cmd_config_per_queue_tx_offload_result {
16495 cmdline_fixed_string_t port;
16497 cmdline_fixed_string_t txq;
16499 cmdline_fixed_string_t tx_offload;
16500 cmdline_fixed_string_t offload;
16501 cmdline_fixed_string_t on_off;
16504 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16505 TOKEN_STRING_INITIALIZER
16506 (struct cmd_config_per_queue_tx_offload_result,
16508 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16509 TOKEN_NUM_INITIALIZER
16510 (struct cmd_config_per_queue_tx_offload_result,
16511 port_id, RTE_UINT16);
16512 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16513 TOKEN_STRING_INITIALIZER
16514 (struct cmd_config_per_queue_tx_offload_result,
16516 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16517 TOKEN_NUM_INITIALIZER
16518 (struct cmd_config_per_queue_tx_offload_result,
16519 queue_id, RTE_UINT16);
16520 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16521 TOKEN_STRING_INITIALIZER
16522 (struct cmd_config_per_queue_tx_offload_result,
16523 tx_offload, "tx_offload");
16524 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16525 TOKEN_STRING_INITIALIZER
16526 (struct cmd_config_per_queue_tx_offload_result,
16527 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16528 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16529 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16530 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16531 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16532 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16533 TOKEN_STRING_INITIALIZER
16534 (struct cmd_config_per_queue_tx_offload_result,
16538 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16539 __rte_unused struct cmdline *cl,
16540 __rte_unused void *data)
16542 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16543 struct rte_eth_dev_info dev_info;
16544 portid_t port_id = res->port_id;
16545 uint16_t queue_id = res->queue_id;
16546 struct rte_port *port = &ports[port_id];
16547 uint64_t single_offload;
16550 if (port->port_status != RTE_PORT_STOPPED) {
16551 printf("Error: Can't config offload when Port %d "
16552 "is not stopped\n", port_id);
16556 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16560 if (queue_id >= dev_info.nb_tx_queues) {
16561 printf("Error: input queue_id should be 0 ... "
16562 "%d\n", dev_info.nb_tx_queues - 1);
16566 single_offload = search_tx_offload(res->offload);
16567 if (single_offload == 0) {
16568 printf("Unknown offload name: %s\n", res->offload);
16572 if (!strcmp(res->on_off, "on"))
16573 port->tx_conf[queue_id].offloads |= single_offload;
16575 port->tx_conf[queue_id].offloads &= ~single_offload;
16577 cmd_reconfig_device_queue(port_id, 1, 1);
16580 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16581 .f = cmd_config_per_queue_tx_offload_parsed,
16583 .help_str = "port <port_id> txq <queue_id> tx_offload "
16584 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16585 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16586 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16587 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16588 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16591 (void *)&cmd_config_per_queue_tx_offload_result_port,
16592 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16593 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16594 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16595 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16596 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16597 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16602 /* *** configure tx_metadata for specific port *** */
16603 struct cmd_config_tx_metadata_specific_result {
16604 cmdline_fixed_string_t port;
16605 cmdline_fixed_string_t keyword;
16607 cmdline_fixed_string_t item;
16612 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16613 __rte_unused struct cmdline *cl,
16614 __rte_unused void *data)
16616 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16618 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16620 ports[res->port_id].tx_metadata = res->value;
16621 /* Add/remove callback to insert valid metadata in every Tx packet. */
16622 if (ports[res->port_id].tx_metadata)
16623 add_tx_md_callback(res->port_id);
16625 remove_tx_md_callback(res->port_id);
16626 rte_flow_dynf_metadata_register();
16629 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16630 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16632 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16633 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16634 keyword, "config");
16635 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16636 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16637 port_id, RTE_UINT16);
16638 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16639 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16640 item, "tx_metadata");
16641 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16642 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16643 value, RTE_UINT32);
16645 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16646 .f = cmd_config_tx_metadata_specific_parsed,
16648 .help_str = "port config <port_id> tx_metadata <value>",
16650 (void *)&cmd_config_tx_metadata_specific_port,
16651 (void *)&cmd_config_tx_metadata_specific_keyword,
16652 (void *)&cmd_config_tx_metadata_specific_id,
16653 (void *)&cmd_config_tx_metadata_specific_item,
16654 (void *)&cmd_config_tx_metadata_specific_value,
16659 /* *** set dynf *** */
16660 struct cmd_config_tx_dynf_specific_result {
16661 cmdline_fixed_string_t port;
16662 cmdline_fixed_string_t keyword;
16664 cmdline_fixed_string_t item;
16665 cmdline_fixed_string_t name;
16666 cmdline_fixed_string_t value;
16670 cmd_config_dynf_specific_parsed(void *parsed_result,
16671 __rte_unused struct cmdline *cl,
16672 __rte_unused void *data)
16674 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16675 struct rte_mbuf_dynflag desc_flag;
16677 uint64_t old_port_flags;
16679 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16681 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16683 if (strlcpy(desc_flag.name, res->name,
16684 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16685 printf("Flag name too long\n");
16688 desc_flag.flags = 0;
16689 flag = rte_mbuf_dynflag_register(&desc_flag);
16691 printf("Can't register flag\n");
16694 strcpy(dynf_names[flag], desc_flag.name);
16696 old_port_flags = ports[res->port_id].mbuf_dynf;
16697 if (!strcmp(res->value, "set")) {
16698 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16699 if (old_port_flags == 0)
16700 add_tx_dynf_callback(res->port_id);
16702 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16703 if (ports[res->port_id].mbuf_dynf == 0)
16704 remove_tx_dynf_callback(res->port_id);
16708 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16709 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16711 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16712 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16713 keyword, "config");
16714 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16715 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16716 port_id, RTE_UINT16);
16717 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16718 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16720 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16721 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16723 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16724 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16725 value, "set#clear");
16727 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16728 .f = cmd_config_dynf_specific_parsed,
16730 .help_str = "port config <port id> dynf <name> set|clear",
16732 (void *)&cmd_config_tx_dynf_specific_port,
16733 (void *)&cmd_config_tx_dynf_specific_keyword,
16734 (void *)&cmd_config_tx_dynf_specific_port_id,
16735 (void *)&cmd_config_tx_dynf_specific_item,
16736 (void *)&cmd_config_tx_dynf_specific_name,
16737 (void *)&cmd_config_tx_dynf_specific_value,
16742 /* *** display tx_metadata per port configuration *** */
16743 struct cmd_show_tx_metadata_result {
16744 cmdline_fixed_string_t cmd_show;
16745 cmdline_fixed_string_t cmd_port;
16746 cmdline_fixed_string_t cmd_keyword;
16751 cmd_show_tx_metadata_parsed(void *parsed_result,
16752 __rte_unused struct cmdline *cl,
16753 __rte_unused void *data)
16755 struct cmd_show_tx_metadata_result *res = parsed_result;
16757 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16758 printf("invalid port id %u\n", res->cmd_pid);
16761 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16762 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16763 ports[res->cmd_pid].tx_metadata);
16767 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16768 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16770 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16771 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16773 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16774 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16775 cmd_pid, RTE_UINT16);
16776 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16777 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16778 cmd_keyword, "tx_metadata");
16780 cmdline_parse_inst_t cmd_show_tx_metadata = {
16781 .f = cmd_show_tx_metadata_parsed,
16783 .help_str = "show port <port_id> tx_metadata",
16785 (void *)&cmd_show_tx_metadata_show,
16786 (void *)&cmd_show_tx_metadata_port,
16787 (void *)&cmd_show_tx_metadata_pid,
16788 (void *)&cmd_show_tx_metadata_keyword,
16793 /* *** show fec capability per port configuration *** */
16794 struct cmd_show_fec_capability_result {
16795 cmdline_fixed_string_t cmd_show;
16796 cmdline_fixed_string_t cmd_port;
16797 cmdline_fixed_string_t cmd_fec;
16798 cmdline_fixed_string_t cmd_keyword;
16803 cmd_show_fec_capability_parsed(void *parsed_result,
16804 __rte_unused struct cmdline *cl,
16805 __rte_unused void *data)
16807 struct cmd_show_fec_capability_result *res = parsed_result;
16808 struct rte_eth_fec_capa *speed_fec_capa;
16812 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16813 printf("Invalid port id %u\n", res->cmd_pid);
16817 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16818 if (ret == -ENOTSUP) {
16819 printf("Function not implemented\n");
16821 } else if (ret < 0) {
16822 printf("Get FEC capability failed: %d\n", ret);
16826 num = (unsigned int)ret;
16827 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16828 if (speed_fec_capa == NULL) {
16829 printf("Failed to alloc FEC capability buffer\n");
16833 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16835 printf("Error getting FEC capability: %d\n", ret);
16839 show_fec_capability(num, speed_fec_capa);
16841 free(speed_fec_capa);
16844 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16845 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16847 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16848 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16850 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16851 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16852 cmd_pid, RTE_UINT16);
16853 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16854 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16856 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16857 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16858 cmd_keyword, "capabilities");
16860 cmdline_parse_inst_t cmd_show_capability = {
16861 .f = cmd_show_fec_capability_parsed,
16863 .help_str = "show port <port_id> fec capabilities",
16865 (void *)&cmd_show_fec_capability_show,
16866 (void *)&cmd_show_fec_capability_port,
16867 (void *)&cmd_show_fec_capability_pid,
16868 (void *)&cmd_show_fec_capability_fec,
16869 (void *)&cmd_show_fec_capability_keyword,
16874 /* *** show fec mode per port configuration *** */
16875 struct cmd_show_fec_metadata_result {
16876 cmdline_fixed_string_t cmd_show;
16877 cmdline_fixed_string_t cmd_port;
16878 cmdline_fixed_string_t cmd_keyword;
16883 cmd_show_fec_mode_parsed(void *parsed_result,
16884 __rte_unused struct cmdline *cl,
16885 __rte_unused void *data)
16887 #define FEC_NAME_SIZE 16
16888 struct cmd_show_fec_metadata_result *res = parsed_result;
16890 char buf[FEC_NAME_SIZE];
16893 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16894 printf("Invalid port id %u\n", res->cmd_pid);
16897 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16898 if (ret == -ENOTSUP) {
16899 printf("Function not implemented\n");
16901 } else if (ret < 0) {
16902 printf("Get FEC mode failed\n");
16907 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16908 strlcpy(buf, "off", sizeof(buf));
16910 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16911 strlcpy(buf, "auto", sizeof(buf));
16913 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16914 strlcpy(buf, "baser", sizeof(buf));
16916 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16917 strlcpy(buf, "rs", sizeof(buf));
16923 printf("%s\n", buf);
16926 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16927 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16929 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16930 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16932 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16933 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16934 cmd_pid, RTE_UINT16);
16935 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16936 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16937 cmd_keyword, "fec_mode");
16939 cmdline_parse_inst_t cmd_show_fec_mode = {
16940 .f = cmd_show_fec_mode_parsed,
16942 .help_str = "show port <port_id> fec_mode",
16944 (void *)&cmd_show_fec_mode_show,
16945 (void *)&cmd_show_fec_mode_port,
16946 (void *)&cmd_show_fec_mode_pid,
16947 (void *)&cmd_show_fec_mode_keyword,
16952 /* *** set fec mode per port configuration *** */
16953 struct cmd_set_port_fec_mode {
16954 cmdline_fixed_string_t set;
16955 cmdline_fixed_string_t port;
16957 cmdline_fixed_string_t fec_mode;
16958 cmdline_fixed_string_t fec_value;
16961 /* Common CLI fields for set fec mode */
16962 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16963 TOKEN_STRING_INITIALIZER
16964 (struct cmd_set_port_fec_mode,
16966 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16967 TOKEN_STRING_INITIALIZER
16968 (struct cmd_set_port_fec_mode,
16970 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16971 TOKEN_NUM_INITIALIZER
16972 (struct cmd_set_port_fec_mode,
16973 port_id, RTE_UINT16);
16974 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16975 TOKEN_STRING_INITIALIZER
16976 (struct cmd_set_port_fec_mode,
16977 fec_mode, "fec_mode");
16978 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16979 TOKEN_STRING_INITIALIZER
16980 (struct cmd_set_port_fec_mode,
16984 cmd_set_port_fec_mode_parsed(
16985 void *parsed_result,
16986 __rte_unused struct cmdline *cl,
16987 __rte_unused void *data)
16989 struct cmd_set_port_fec_mode *res = parsed_result;
16990 uint16_t port_id = res->port_id;
16994 ret = parse_fec_mode(res->fec_value, &mode);
16996 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
17001 ret = rte_eth_fec_set(port_id, mode);
17002 if (ret == -ENOTSUP) {
17003 printf("Function not implemented\n");
17005 } else if (ret < 0) {
17006 printf("Set FEC mode failed\n");
17011 cmdline_parse_inst_t cmd_set_fec_mode = {
17012 .f = cmd_set_port_fec_mode_parsed,
17014 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17016 (void *)&cmd_set_port_fec_mode_set,
17017 (void *)&cmd_set_port_fec_mode_port,
17018 (void *)&cmd_set_port_fec_mode_port_id,
17019 (void *)&cmd_set_port_fec_mode_str,
17020 (void *)&cmd_set_port_fec_mode_value,
17025 /* show port supported ptypes */
17027 /* Common result structure for show port ptypes */
17028 struct cmd_show_port_supported_ptypes_result {
17029 cmdline_fixed_string_t show;
17030 cmdline_fixed_string_t port;
17032 cmdline_fixed_string_t ptypes;
17035 /* Common CLI fields for show port ptypes */
17036 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17037 TOKEN_STRING_INITIALIZER
17038 (struct cmd_show_port_supported_ptypes_result,
17040 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17041 TOKEN_STRING_INITIALIZER
17042 (struct cmd_show_port_supported_ptypes_result,
17044 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17045 TOKEN_NUM_INITIALIZER
17046 (struct cmd_show_port_supported_ptypes_result,
17047 port_id, RTE_UINT16);
17048 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17049 TOKEN_STRING_INITIALIZER
17050 (struct cmd_show_port_supported_ptypes_result,
17054 cmd_show_port_supported_ptypes_parsed(
17055 void *parsed_result,
17056 __rte_unused struct cmdline *cl,
17057 __rte_unused void *data)
17059 #define RSVD_PTYPE_MASK 0xf0000000
17060 #define MAX_PTYPES_PER_LAYER 16
17061 #define LTYPE_NAMESIZE 32
17062 #define PTYPE_NAMESIZE 256
17063 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17064 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17065 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17066 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17067 uint16_t port_id = res->port_id;
17070 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17074 while (ptype_mask != RSVD_PTYPE_MASK) {
17076 switch (ptype_mask) {
17077 case RTE_PTYPE_L2_MASK:
17078 strlcpy(ltype, "L2", sizeof(ltype));
17080 case RTE_PTYPE_L3_MASK:
17081 strlcpy(ltype, "L3", sizeof(ltype));
17083 case RTE_PTYPE_L4_MASK:
17084 strlcpy(ltype, "L4", sizeof(ltype));
17086 case RTE_PTYPE_TUNNEL_MASK:
17087 strlcpy(ltype, "Tunnel", sizeof(ltype));
17089 case RTE_PTYPE_INNER_L2_MASK:
17090 strlcpy(ltype, "Inner L2", sizeof(ltype));
17092 case RTE_PTYPE_INNER_L3_MASK:
17093 strlcpy(ltype, "Inner L3", sizeof(ltype));
17095 case RTE_PTYPE_INNER_L4_MASK:
17096 strlcpy(ltype, "Inner L4", sizeof(ltype));
17102 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17103 ptype_mask, ptypes,
17104 MAX_PTYPES_PER_LAYER);
17107 printf("Supported %s ptypes:\n", ltype);
17109 printf("%s ptypes unsupported\n", ltype);
17111 for (i = 0; i < ret; ++i) {
17112 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17113 printf("%s\n", buf);
17120 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17121 .f = cmd_show_port_supported_ptypes_parsed,
17123 .help_str = "show port <port_id> ptypes",
17125 (void *)&cmd_show_port_supported_ptypes_show,
17126 (void *)&cmd_show_port_supported_ptypes_port,
17127 (void *)&cmd_show_port_supported_ptypes_port_id,
17128 (void *)&cmd_show_port_supported_ptypes_ptypes,
17133 /* *** display rx/tx descriptor status *** */
17134 struct cmd_show_rx_tx_desc_status_result {
17135 cmdline_fixed_string_t cmd_show;
17136 cmdline_fixed_string_t cmd_port;
17137 cmdline_fixed_string_t cmd_keyword;
17138 cmdline_fixed_string_t cmd_desc;
17139 cmdline_fixed_string_t cmd_status;
17146 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17147 __rte_unused struct cmdline *cl,
17148 __rte_unused void *data)
17150 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17153 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17154 printf("invalid port id %u\n", res->cmd_pid);
17158 if (!strcmp(res->cmd_keyword, "rxq")) {
17159 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17162 printf("Invalid input: queue id = %d, desc id = %d\n",
17163 res->cmd_qid, res->cmd_did);
17166 if (rc == RTE_ETH_RX_DESC_AVAIL)
17167 printf("Desc status = AVAILABLE\n");
17168 else if (rc == RTE_ETH_RX_DESC_DONE)
17169 printf("Desc status = DONE\n");
17171 printf("Desc status = UNAVAILABLE\n");
17172 } else if (!strcmp(res->cmd_keyword, "txq")) {
17173 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17176 printf("Invalid input: queue id = %d, desc id = %d\n",
17177 res->cmd_qid, res->cmd_did);
17180 if (rc == RTE_ETH_TX_DESC_FULL)
17181 printf("Desc status = FULL\n");
17182 else if (rc == RTE_ETH_TX_DESC_DONE)
17183 printf("Desc status = DONE\n");
17185 printf("Desc status = UNAVAILABLE\n");
17189 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17190 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17192 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17193 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17195 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17196 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17197 cmd_pid, RTE_UINT16);
17198 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17199 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17200 cmd_keyword, "rxq#txq");
17201 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17202 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17203 cmd_qid, RTE_UINT16);
17204 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17205 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17207 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17208 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17209 cmd_did, RTE_UINT16);
17210 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17211 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17212 cmd_status, "status");
17213 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17214 .f = cmd_show_rx_tx_desc_status_parsed,
17216 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17219 (void *)&cmd_show_rx_tx_desc_status_show,
17220 (void *)&cmd_show_rx_tx_desc_status_port,
17221 (void *)&cmd_show_rx_tx_desc_status_pid,
17222 (void *)&cmd_show_rx_tx_desc_status_keyword,
17223 (void *)&cmd_show_rx_tx_desc_status_qid,
17224 (void *)&cmd_show_rx_tx_desc_status_desc,
17225 (void *)&cmd_show_rx_tx_desc_status_did,
17226 (void *)&cmd_show_rx_tx_desc_status_status,
17231 /* *** display rx queue desc used count *** */
17232 struct cmd_show_rx_queue_desc_used_count_result {
17233 cmdline_fixed_string_t cmd_show;
17234 cmdline_fixed_string_t cmd_port;
17235 cmdline_fixed_string_t cmd_rxq;
17236 cmdline_fixed_string_t cmd_desc;
17237 cmdline_fixed_string_t cmd_used;
17238 cmdline_fixed_string_t cmd_count;
17244 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17245 __rte_unused struct cmdline *cl,
17246 __rte_unused void *data)
17248 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17251 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17252 printf("invalid port id %u\n", res->cmd_pid);
17256 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17258 printf("Invalid queueid = %d\n", res->cmd_qid);
17261 printf("Used desc count = %d\n", rc);
17264 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17265 TOKEN_STRING_INITIALIZER
17266 (struct cmd_show_rx_queue_desc_used_count_result,
17268 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17269 TOKEN_STRING_INITIALIZER
17270 (struct cmd_show_rx_queue_desc_used_count_result,
17272 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17273 TOKEN_NUM_INITIALIZER
17274 (struct cmd_show_rx_queue_desc_used_count_result,
17275 cmd_pid, RTE_UINT16);
17276 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17277 TOKEN_STRING_INITIALIZER
17278 (struct cmd_show_rx_queue_desc_used_count_result,
17280 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17281 TOKEN_NUM_INITIALIZER
17282 (struct cmd_show_rx_queue_desc_used_count_result,
17283 cmd_qid, RTE_UINT16);
17284 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17285 TOKEN_STRING_INITIALIZER
17286 (struct cmd_show_rx_queue_desc_used_count_result,
17287 cmd_count, "desc");
17288 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17289 TOKEN_STRING_INITIALIZER
17290 (struct cmd_show_rx_queue_desc_used_count_result,
17291 cmd_count, "used");
17292 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17293 TOKEN_STRING_INITIALIZER
17294 (struct cmd_show_rx_queue_desc_used_count_result,
17295 cmd_count, "count");
17296 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17297 .f = cmd_show_rx_queue_desc_used_count_parsed,
17299 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17301 (void *)&cmd_show_rx_queue_desc_used_count_show,
17302 (void *)&cmd_show_rx_queue_desc_used_count_port,
17303 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17304 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17305 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17306 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17307 (void *)&cmd_show_rx_queue_desc_used_count_used,
17308 (void *)&cmd_show_rx_queue_desc_used_count_count,
17313 /* Common result structure for set port ptypes */
17314 struct cmd_set_port_ptypes_result {
17315 cmdline_fixed_string_t set;
17316 cmdline_fixed_string_t port;
17318 cmdline_fixed_string_t ptype_mask;
17322 /* Common CLI fields for set port ptypes */
17323 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17324 TOKEN_STRING_INITIALIZER
17325 (struct cmd_set_port_ptypes_result,
17327 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17328 TOKEN_STRING_INITIALIZER
17329 (struct cmd_set_port_ptypes_result,
17331 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17332 TOKEN_NUM_INITIALIZER
17333 (struct cmd_set_port_ptypes_result,
17334 port_id, RTE_UINT16);
17335 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17336 TOKEN_STRING_INITIALIZER
17337 (struct cmd_set_port_ptypes_result,
17338 ptype_mask, "ptype_mask");
17339 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17340 TOKEN_NUM_INITIALIZER
17341 (struct cmd_set_port_ptypes_result,
17345 cmd_set_port_ptypes_parsed(
17346 void *parsed_result,
17347 __rte_unused struct cmdline *cl,
17348 __rte_unused void *data)
17350 struct cmd_set_port_ptypes_result *res = parsed_result;
17351 #define PTYPE_NAMESIZE 256
17352 char ptype_name[PTYPE_NAMESIZE];
17353 uint16_t port_id = res->port_id;
17354 uint32_t ptype_mask = res->mask;
17357 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17360 printf("Port %d doesn't support any ptypes.\n", port_id);
17364 uint32_t ptypes[ret];
17366 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17368 printf("Unable to set requested ptypes for Port %d\n", port_id);
17372 printf("Successfully set following ptypes for Port %d\n", port_id);
17373 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17374 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17375 printf("%s\n", ptype_name);
17378 clear_ptypes = false;
17381 cmdline_parse_inst_t cmd_set_port_ptypes = {
17382 .f = cmd_set_port_ptypes_parsed,
17384 .help_str = "set port <port_id> ptype_mask <mask>",
17386 (void *)&cmd_set_port_ptypes_set,
17387 (void *)&cmd_set_port_ptypes_port,
17388 (void *)&cmd_set_port_ptypes_port_id,
17389 (void *)&cmd_set_port_ptypes_mask_str,
17390 (void *)&cmd_set_port_ptypes_mask_u32,
17395 /* *** display mac addresses added to a port *** */
17396 struct cmd_showport_macs_result {
17397 cmdline_fixed_string_t cmd_show;
17398 cmdline_fixed_string_t cmd_port;
17399 cmdline_fixed_string_t cmd_keyword;
17404 cmd_showport_macs_parsed(void *parsed_result,
17405 __rte_unused struct cmdline *cl,
17406 __rte_unused void *data)
17408 struct cmd_showport_macs_result *res = parsed_result;
17410 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17413 if (!strcmp(res->cmd_keyword, "macs"))
17414 show_macs(res->cmd_pid);
17415 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17416 show_mcast_macs(res->cmd_pid);
17419 cmdline_parse_token_string_t cmd_showport_macs_show =
17420 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17422 cmdline_parse_token_string_t cmd_showport_macs_port =
17423 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17425 cmdline_parse_token_num_t cmd_showport_macs_pid =
17426 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17427 cmd_pid, RTE_UINT16);
17428 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17429 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17430 cmd_keyword, "macs#mcast_macs");
17432 cmdline_parse_inst_t cmd_showport_macs = {
17433 .f = cmd_showport_macs_parsed,
17435 .help_str = "show port <port_id> macs|mcast_macs",
17437 (void *)&cmd_showport_macs_show,
17438 (void *)&cmd_showport_macs_port,
17439 (void *)&cmd_showport_macs_pid,
17440 (void *)&cmd_showport_macs_keyword,
17445 /* ******************************************************************************** */
17447 /* list of instructions */
17448 cmdline_parse_ctx_t main_ctx[] = {
17449 (cmdline_parse_inst_t *)&cmd_help_brief,
17450 (cmdline_parse_inst_t *)&cmd_help_long,
17451 (cmdline_parse_inst_t *)&cmd_quit,
17452 (cmdline_parse_inst_t *)&cmd_load_from_file,
17453 (cmdline_parse_inst_t *)&cmd_showport,
17454 (cmdline_parse_inst_t *)&cmd_showqueue,
17455 (cmdline_parse_inst_t *)&cmd_showeeprom,
17456 (cmdline_parse_inst_t *)&cmd_showportall,
17457 (cmdline_parse_inst_t *)&cmd_showdevice,
17458 (cmdline_parse_inst_t *)&cmd_showcfg,
17459 (cmdline_parse_inst_t *)&cmd_showfwdall,
17460 (cmdline_parse_inst_t *)&cmd_start,
17461 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17462 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17463 (cmdline_parse_inst_t *)&cmd_set_link_up,
17464 (cmdline_parse_inst_t *)&cmd_set_link_down,
17465 (cmdline_parse_inst_t *)&cmd_reset,
17466 (cmdline_parse_inst_t *)&cmd_set_numbers,
17467 (cmdline_parse_inst_t *)&cmd_set_log,
17468 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17469 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17470 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17471 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17472 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17473 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17474 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17475 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17476 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17477 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17478 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17479 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17480 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17481 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17482 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17483 (cmdline_parse_inst_t *)&cmd_set_link_check,
17484 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17485 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17486 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17487 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17488 #ifdef RTE_NET_BOND
17489 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17490 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17491 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17492 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17493 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17494 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17495 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17496 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17497 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17498 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17499 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17501 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17502 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17503 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17504 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17505 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17506 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17507 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17508 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17509 (cmdline_parse_inst_t *)&cmd_csum_set,
17510 (cmdline_parse_inst_t *)&cmd_csum_show,
17511 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17512 (cmdline_parse_inst_t *)&cmd_tso_set,
17513 (cmdline_parse_inst_t *)&cmd_tso_show,
17514 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17515 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17516 (cmdline_parse_inst_t *)&cmd_gro_enable,
17517 (cmdline_parse_inst_t *)&cmd_gro_flush,
17518 (cmdline_parse_inst_t *)&cmd_gro_show,
17519 (cmdline_parse_inst_t *)&cmd_gso_enable,
17520 (cmdline_parse_inst_t *)&cmd_gso_size,
17521 (cmdline_parse_inst_t *)&cmd_gso_show,
17522 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17523 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17524 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17525 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17526 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17527 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17528 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17529 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17530 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17531 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17532 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17533 (cmdline_parse_inst_t *)&cmd_config_dcb,
17534 (cmdline_parse_inst_t *)&cmd_read_reg,
17535 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17536 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17537 (cmdline_parse_inst_t *)&cmd_write_reg,
17538 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17539 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17540 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17541 (cmdline_parse_inst_t *)&cmd_stop,
17542 (cmdline_parse_inst_t *)&cmd_mac_addr,
17543 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17544 (cmdline_parse_inst_t *)&cmd_set_qmap,
17545 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17546 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17547 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17548 (cmdline_parse_inst_t *)&cmd_operate_port,
17549 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17550 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17551 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17552 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17553 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17554 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17555 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17556 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17557 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17558 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17559 (cmdline_parse_inst_t *)&cmd_config_mtu,
17560 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17561 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17562 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17563 (cmdline_parse_inst_t *)&cmd_config_rss,
17564 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17565 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17566 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17567 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17568 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17569 (cmdline_parse_inst_t *)&cmd_showport_reta,
17570 (cmdline_parse_inst_t *)&cmd_showport_macs,
17571 (cmdline_parse_inst_t *)&cmd_config_burst,
17572 (cmdline_parse_inst_t *)&cmd_config_thresh,
17573 (cmdline_parse_inst_t *)&cmd_config_threshold,
17574 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17575 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17576 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17577 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17578 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17579 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17580 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17581 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17582 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17583 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17584 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17585 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17586 (cmdline_parse_inst_t *)&cmd_dump,
17587 (cmdline_parse_inst_t *)&cmd_dump_one,
17588 #ifdef RTE_NET_I40E
17589 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17591 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17592 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17593 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17594 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17595 (cmdline_parse_inst_t *)&cmd_flow,
17596 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17597 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17598 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17599 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17600 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17601 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17602 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17603 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17604 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17605 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17606 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17607 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17608 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17609 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17610 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17611 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17612 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17613 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17614 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17615 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17616 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17617 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17618 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17619 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17620 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17621 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17622 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17623 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17624 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17625 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17626 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17627 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17628 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17629 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17630 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17631 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17632 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17633 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17634 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17635 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17636 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17637 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17638 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17639 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17640 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17641 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17642 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17643 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17644 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17645 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17646 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17647 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17648 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17649 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17650 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17651 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17652 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17653 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17654 (cmdline_parse_inst_t *)&cmd_ddp_add,
17655 (cmdline_parse_inst_t *)&cmd_ddp_del,
17656 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17657 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17658 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17659 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17660 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17661 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17662 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17663 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17664 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17665 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17666 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17667 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17669 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17670 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17671 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17672 (cmdline_parse_inst_t *)&cmd_queue_region,
17673 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17674 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17675 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17676 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17677 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17678 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17679 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17680 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17681 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17682 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17683 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17684 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17685 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17686 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17687 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17688 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17689 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17690 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17691 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17692 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17693 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17694 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17695 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17696 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17697 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17698 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17699 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17700 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17701 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17702 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17703 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17704 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17705 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17706 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17707 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17708 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17710 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17711 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17713 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17714 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17715 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17716 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17717 (cmdline_parse_inst_t *)&cmd_set_raw,
17718 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17719 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17720 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17721 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17722 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17723 (cmdline_parse_inst_t *)&cmd_show_capability,
17727 /* read cmdline commands from file */
17729 cmdline_read_from_file(const char *filename)
17731 struct cmdline *cl;
17733 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17735 printf("Failed to create file based cmdline context: %s\n",
17740 cmdline_interact(cl);
17745 printf("Read CLI commands from %s\n", filename);
17748 /* prompt function, called from main on MAIN lcore */
17753 /* initialize non-constant commands */
17754 cmd_set_fwd_mode_init();
17755 cmd_set_fwd_retry_mode_init();
17757 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17758 if (testpmd_cl == NULL)
17761 ret = atexit(prompt_exit);
17763 printf("Cannot set exit function for cmdline\n");
17765 cmdline_interact(testpmd_cl);
17767 cmdline_stdin_exit(testpmd_cl);
17773 if (testpmd_cl != NULL) {
17774 cmdline_quit(testpmd_cl);
17775 cmdline_stdin_exit(testpmd_cl);
17780 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17782 if (id == (portid_t)RTE_PORT_ALL) {
17785 RTE_ETH_FOREACH_DEV(pid) {
17786 /* check if need_reconfig has been set to 1 */
17787 if (ports[pid].need_reconfig == 0)
17788 ports[pid].need_reconfig = dev;
17789 /* check if need_reconfig_queues has been set to 1 */
17790 if (ports[pid].need_reconfig_queues == 0)
17791 ports[pid].need_reconfig_queues = queue;
17793 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17794 /* check if need_reconfig has been set to 1 */
17795 if (ports[id].need_reconfig == 0)
17796 ports[id].need_reconfig = dev;
17797 /* check if need_reconfig_queues has been set to 1 */
17798 if (ports[id].need_reconfig_queues == 0)
17799 ports[id].need_reconfig_queues = queue;