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 ret = rte_eth_tx_queue_setup(res->portid,
2915 port->nb_tx_desc[res->qid],
2917 &port->tx_conf[res->qid]);
2919 printf("Failed to setup TX queue\n");
2923 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2924 .f = cmd_setup_rxtx_queue_parsed,
2926 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2928 (void *)&cmd_setup_rxtx_queue_port,
2929 (void *)&cmd_setup_rxtx_queue_portid,
2930 (void *)&cmd_setup_rxtx_queue_rxtxq,
2931 (void *)&cmd_setup_rxtx_queue_qid,
2932 (void *)&cmd_setup_rxtx_queue_setup,
2938 /* *** Configure RSS RETA *** */
2939 struct cmd_config_rss_reta {
2940 cmdline_fixed_string_t port;
2941 cmdline_fixed_string_t keyword;
2943 cmdline_fixed_string_t name;
2944 cmdline_fixed_string_t list_name;
2945 cmdline_fixed_string_t list_of_items;
2949 parse_reta_config(const char *str,
2950 struct rte_eth_rss_reta_entry64 *reta_conf,
2951 uint16_t nb_entries)
2955 uint16_t hash_index, idx, shift;
2958 const char *p, *p0 = str;
2965 unsigned long int_fld[_NUM_FLD];
2966 char *str_fld[_NUM_FLD];
2968 while ((p = strchr(p0,'(')) != NULL) {
2970 if((p0 = strchr(p,')')) == NULL)
2974 if(size >= sizeof(s))
2977 snprintf(s, sizeof(s), "%.*s", size, p);
2978 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2980 for (i = 0; i < _NUM_FLD; i++) {
2982 int_fld[i] = strtoul(str_fld[i], &end, 0);
2983 if (errno != 0 || end == str_fld[i] ||
2988 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2989 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2991 if (hash_index >= nb_entries) {
2992 printf("Invalid RETA hash index=%d\n", hash_index);
2996 idx = hash_index / RTE_RETA_GROUP_SIZE;
2997 shift = hash_index % RTE_RETA_GROUP_SIZE;
2998 reta_conf[idx].mask |= (1ULL << shift);
2999 reta_conf[idx].reta[shift] = nb_queue;
3006 cmd_set_rss_reta_parsed(void *parsed_result,
3007 __rte_unused struct cmdline *cl,
3008 __rte_unused void *data)
3011 struct rte_eth_dev_info dev_info;
3012 struct rte_eth_rss_reta_entry64 reta_conf[8];
3013 struct cmd_config_rss_reta *res = parsed_result;
3015 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3019 if (dev_info.reta_size == 0) {
3020 printf("Redirection table size is 0 which is "
3021 "invalid for RSS\n");
3024 printf("The reta size of port %d is %u\n",
3025 res->port_id, dev_info.reta_size);
3026 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3027 printf("Currently do not support more than %u entries of "
3028 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3032 memset(reta_conf, 0, sizeof(reta_conf));
3033 if (!strcmp(res->list_name, "reta")) {
3034 if (parse_reta_config(res->list_of_items, reta_conf,
3035 dev_info.reta_size)) {
3036 printf("Invalid RSS Redirection Table "
3037 "config entered\n");
3040 ret = rte_eth_dev_rss_reta_update(res->port_id,
3041 reta_conf, dev_info.reta_size);
3043 printf("Bad redirection table parameter, "
3044 "return code = %d \n", ret);
3048 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3049 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3050 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3051 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3052 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3053 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3054 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3056 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3058 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3061 cmdline_parse_inst_t cmd_config_rss_reta = {
3062 .f = cmd_set_rss_reta_parsed,
3064 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3066 (void *)&cmd_config_rss_reta_port,
3067 (void *)&cmd_config_rss_reta_keyword,
3068 (void *)&cmd_config_rss_reta_port_id,
3069 (void *)&cmd_config_rss_reta_name,
3070 (void *)&cmd_config_rss_reta_list_name,
3071 (void *)&cmd_config_rss_reta_list_of_items,
3076 /* *** SHOW PORT RETA INFO *** */
3077 struct cmd_showport_reta {
3078 cmdline_fixed_string_t show;
3079 cmdline_fixed_string_t port;
3081 cmdline_fixed_string_t rss;
3082 cmdline_fixed_string_t reta;
3084 cmdline_fixed_string_t list_of_items;
3088 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3089 uint16_t nb_entries,
3093 const char *p, *p0 = str;
3098 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3099 RTE_RETA_GROUP_SIZE;
3102 p = strchr(p0, '(');
3106 p0 = strchr(p, ')');
3110 if (size >= sizeof(s)) {
3111 printf("The string size exceeds the internal buffer size\n");
3114 snprintf(s, sizeof(s), "%.*s", size, p);
3115 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3116 if (ret <= 0 || ret != num) {
3117 printf("The bits of masks do not match the number of "
3118 "reta entries: %u\n", num);
3121 for (i = 0; i < ret; i++)
3122 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3128 cmd_showport_reta_parsed(void *parsed_result,
3129 __rte_unused struct cmdline *cl,
3130 __rte_unused void *data)
3132 struct cmd_showport_reta *res = parsed_result;
3133 struct rte_eth_rss_reta_entry64 reta_conf[8];
3134 struct rte_eth_dev_info dev_info;
3135 uint16_t max_reta_size;
3138 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3142 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3143 if (res->size == 0 || res->size > max_reta_size) {
3144 printf("Invalid redirection table size: %u (1-%u)\n",
3145 res->size, max_reta_size);
3149 memset(reta_conf, 0, sizeof(reta_conf));
3150 if (showport_parse_reta_config(reta_conf, res->size,
3151 res->list_of_items) < 0) {
3152 printf("Invalid string: %s for reta masks\n",
3153 res->list_of_items);
3156 port_rss_reta_info(res->port_id, reta_conf, res->size);
3159 cmdline_parse_token_string_t cmd_showport_reta_show =
3160 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3161 cmdline_parse_token_string_t cmd_showport_reta_port =
3162 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3163 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3164 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3165 cmdline_parse_token_string_t cmd_showport_reta_rss =
3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3167 cmdline_parse_token_string_t cmd_showport_reta_reta =
3168 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3169 cmdline_parse_token_num_t cmd_showport_reta_size =
3170 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3171 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3173 list_of_items, NULL);
3175 cmdline_parse_inst_t cmd_showport_reta = {
3176 .f = cmd_showport_reta_parsed,
3178 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3180 (void *)&cmd_showport_reta_show,
3181 (void *)&cmd_showport_reta_port,
3182 (void *)&cmd_showport_reta_port_id,
3183 (void *)&cmd_showport_reta_rss,
3184 (void *)&cmd_showport_reta_reta,
3185 (void *)&cmd_showport_reta_size,
3186 (void *)&cmd_showport_reta_list_of_items,
3191 /* *** Show RSS hash configuration *** */
3192 struct cmd_showport_rss_hash {
3193 cmdline_fixed_string_t show;
3194 cmdline_fixed_string_t port;
3196 cmdline_fixed_string_t rss_hash;
3197 cmdline_fixed_string_t rss_type;
3198 cmdline_fixed_string_t key; /* optional argument */
3201 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3202 __rte_unused struct cmdline *cl,
3205 struct cmd_showport_rss_hash *res = parsed_result;
3207 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3210 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3211 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3212 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3213 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3214 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3215 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3217 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3218 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3220 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3221 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3223 cmdline_parse_inst_t cmd_showport_rss_hash = {
3224 .f = cmd_showport_rss_hash_parsed,
3226 .help_str = "show port <port_id> rss-hash",
3228 (void *)&cmd_showport_rss_hash_show,
3229 (void *)&cmd_showport_rss_hash_port,
3230 (void *)&cmd_showport_rss_hash_port_id,
3231 (void *)&cmd_showport_rss_hash_rss_hash,
3236 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3237 .f = cmd_showport_rss_hash_parsed,
3239 .help_str = "show port <port_id> rss-hash key",
3241 (void *)&cmd_showport_rss_hash_show,
3242 (void *)&cmd_showport_rss_hash_port,
3243 (void *)&cmd_showport_rss_hash_port_id,
3244 (void *)&cmd_showport_rss_hash_rss_hash,
3245 (void *)&cmd_showport_rss_hash_rss_key,
3250 /* *** Configure DCB *** */
3251 struct cmd_config_dcb {
3252 cmdline_fixed_string_t port;
3253 cmdline_fixed_string_t config;
3255 cmdline_fixed_string_t dcb;
3256 cmdline_fixed_string_t vt;
3257 cmdline_fixed_string_t vt_en;
3259 cmdline_fixed_string_t pfc;
3260 cmdline_fixed_string_t pfc_en;
3264 cmd_config_dcb_parsed(void *parsed_result,
3265 __rte_unused struct cmdline *cl,
3266 __rte_unused void *data)
3268 struct cmd_config_dcb *res = parsed_result;
3269 portid_t port_id = res->port_id;
3270 struct rte_port *port;
3274 port = &ports[port_id];
3275 /** Check if the port is not started **/
3276 if (port->port_status != RTE_PORT_STOPPED) {
3277 printf("Please stop port %d first\n", port_id);
3281 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3282 printf("The invalid number of traffic class,"
3283 " only 4 or 8 allowed.\n");
3287 if (nb_fwd_lcores < res->num_tcs) {
3288 printf("nb_cores shouldn't be less than number of TCs.\n");
3291 if (!strncmp(res->pfc_en, "on", 2))
3296 /* DCB in VT mode */
3297 if (!strncmp(res->vt_en, "on", 2))
3298 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3299 (enum rte_eth_nb_tcs)res->num_tcs,
3302 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3303 (enum rte_eth_nb_tcs)res->num_tcs,
3308 printf("Cannot initialize network ports.\n");
3312 cmd_reconfig_device_queue(port_id, 1, 1);
3315 cmdline_parse_token_string_t cmd_config_dcb_port =
3316 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3317 cmdline_parse_token_string_t cmd_config_dcb_config =
3318 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3319 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3320 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3321 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3322 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3323 cmdline_parse_token_string_t cmd_config_dcb_vt =
3324 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3325 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3326 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3327 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3328 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3329 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3330 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3331 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3332 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3334 cmdline_parse_inst_t cmd_config_dcb = {
3335 .f = cmd_config_dcb_parsed,
3337 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3339 (void *)&cmd_config_dcb_port,
3340 (void *)&cmd_config_dcb_config,
3341 (void *)&cmd_config_dcb_port_id,
3342 (void *)&cmd_config_dcb_dcb,
3343 (void *)&cmd_config_dcb_vt,
3344 (void *)&cmd_config_dcb_vt_en,
3345 (void *)&cmd_config_dcb_num_tcs,
3346 (void *)&cmd_config_dcb_pfc,
3347 (void *)&cmd_config_dcb_pfc_en,
3352 /* *** configure number of packets per burst *** */
3353 struct cmd_config_burst {
3354 cmdline_fixed_string_t port;
3355 cmdline_fixed_string_t keyword;
3356 cmdline_fixed_string_t all;
3357 cmdline_fixed_string_t name;
3362 cmd_config_burst_parsed(void *parsed_result,
3363 __rte_unused struct cmdline *cl,
3364 __rte_unused void *data)
3366 struct cmd_config_burst *res = parsed_result;
3367 struct rte_eth_dev_info dev_info;
3368 uint16_t rec_nb_pkts;
3371 if (!all_ports_stopped()) {
3372 printf("Please stop all ports first\n");
3376 if (!strcmp(res->name, "burst")) {
3377 if (res->value == 0) {
3378 /* If user gives a value of zero, query the PMD for
3379 * its recommended Rx burst size. Testpmd uses a single
3380 * size for all ports, so assume all ports are the same
3381 * NIC model and use the values from Port 0.
3383 ret = eth_dev_info_get_print_err(0, &dev_info);
3387 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3389 if (rec_nb_pkts == 0) {
3390 printf("PMD does not recommend a burst size.\n"
3391 "User provided value must be between"
3392 " 1 and %d\n", MAX_PKT_BURST);
3394 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3395 printf("PMD recommended burst size of %d"
3396 " exceeds maximum value of %d\n",
3397 rec_nb_pkts, MAX_PKT_BURST);
3400 printf("Using PMD-provided burst value of %d\n",
3402 nb_pkt_per_burst = rec_nb_pkts;
3403 } else if (res->value > MAX_PKT_BURST) {
3404 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3407 nb_pkt_per_burst = res->value;
3409 printf("Unknown parameter\n");
3415 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3418 cmdline_parse_token_string_t cmd_config_burst_port =
3419 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3420 cmdline_parse_token_string_t cmd_config_burst_keyword =
3421 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3422 cmdline_parse_token_string_t cmd_config_burst_all =
3423 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3424 cmdline_parse_token_string_t cmd_config_burst_name =
3425 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3426 cmdline_parse_token_num_t cmd_config_burst_value =
3427 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3429 cmdline_parse_inst_t cmd_config_burst = {
3430 .f = cmd_config_burst_parsed,
3432 .help_str = "port config all burst <value>",
3434 (void *)&cmd_config_burst_port,
3435 (void *)&cmd_config_burst_keyword,
3436 (void *)&cmd_config_burst_all,
3437 (void *)&cmd_config_burst_name,
3438 (void *)&cmd_config_burst_value,
3443 /* *** configure rx/tx queues *** */
3444 struct cmd_config_thresh {
3445 cmdline_fixed_string_t port;
3446 cmdline_fixed_string_t keyword;
3447 cmdline_fixed_string_t all;
3448 cmdline_fixed_string_t name;
3453 cmd_config_thresh_parsed(void *parsed_result,
3454 __rte_unused struct cmdline *cl,
3455 __rte_unused void *data)
3457 struct cmd_config_thresh *res = parsed_result;
3459 if (!all_ports_stopped()) {
3460 printf("Please stop all ports first\n");
3464 if (!strcmp(res->name, "txpt"))
3465 tx_pthresh = res->value;
3466 else if(!strcmp(res->name, "txht"))
3467 tx_hthresh = res->value;
3468 else if(!strcmp(res->name, "txwt"))
3469 tx_wthresh = res->value;
3470 else if(!strcmp(res->name, "rxpt"))
3471 rx_pthresh = res->value;
3472 else if(!strcmp(res->name, "rxht"))
3473 rx_hthresh = res->value;
3474 else if(!strcmp(res->name, "rxwt"))
3475 rx_wthresh = res->value;
3477 printf("Unknown parameter\n");
3483 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3486 cmdline_parse_token_string_t cmd_config_thresh_port =
3487 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3488 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3489 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3490 cmdline_parse_token_string_t cmd_config_thresh_all =
3491 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3492 cmdline_parse_token_string_t cmd_config_thresh_name =
3493 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3494 "txpt#txht#txwt#rxpt#rxht#rxwt");
3495 cmdline_parse_token_num_t cmd_config_thresh_value =
3496 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3498 cmdline_parse_inst_t cmd_config_thresh = {
3499 .f = cmd_config_thresh_parsed,
3501 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3503 (void *)&cmd_config_thresh_port,
3504 (void *)&cmd_config_thresh_keyword,
3505 (void *)&cmd_config_thresh_all,
3506 (void *)&cmd_config_thresh_name,
3507 (void *)&cmd_config_thresh_value,
3512 /* *** configure free/rs threshold *** */
3513 struct cmd_config_threshold {
3514 cmdline_fixed_string_t port;
3515 cmdline_fixed_string_t keyword;
3516 cmdline_fixed_string_t all;
3517 cmdline_fixed_string_t name;
3522 cmd_config_threshold_parsed(void *parsed_result,
3523 __rte_unused struct cmdline *cl,
3524 __rte_unused void *data)
3526 struct cmd_config_threshold *res = parsed_result;
3528 if (!all_ports_stopped()) {
3529 printf("Please stop all ports first\n");
3533 if (!strcmp(res->name, "txfreet"))
3534 tx_free_thresh = res->value;
3535 else if (!strcmp(res->name, "txrst"))
3536 tx_rs_thresh = res->value;
3537 else if (!strcmp(res->name, "rxfreet"))
3538 rx_free_thresh = res->value;
3540 printf("Unknown parameter\n");
3546 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3549 cmdline_parse_token_string_t cmd_config_threshold_port =
3550 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3551 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3552 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3554 cmdline_parse_token_string_t cmd_config_threshold_all =
3555 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3556 cmdline_parse_token_string_t cmd_config_threshold_name =
3557 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3558 "txfreet#txrst#rxfreet");
3559 cmdline_parse_token_num_t cmd_config_threshold_value =
3560 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3562 cmdline_parse_inst_t cmd_config_threshold = {
3563 .f = cmd_config_threshold_parsed,
3565 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3567 (void *)&cmd_config_threshold_port,
3568 (void *)&cmd_config_threshold_keyword,
3569 (void *)&cmd_config_threshold_all,
3570 (void *)&cmd_config_threshold_name,
3571 (void *)&cmd_config_threshold_value,
3577 struct cmd_stop_result {
3578 cmdline_fixed_string_t stop;
3581 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3582 __rte_unused struct cmdline *cl,
3583 __rte_unused void *data)
3585 stop_packet_forwarding();
3588 cmdline_parse_token_string_t cmd_stop_stop =
3589 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3591 cmdline_parse_inst_t cmd_stop = {
3592 .f = cmd_stop_parsed,
3594 .help_str = "stop: Stop packet forwarding",
3596 (void *)&cmd_stop_stop,
3601 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3604 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3605 unsigned int *parsed_items, int check_unique_values)
3607 unsigned int nb_item;
3615 * First parse all items in the list and store their value.
3620 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3622 if ((c >= '0') && (c <= '9')) {
3623 value = (unsigned int) (value * 10 + (c - '0'));
3628 printf("character %c is not a decimal digit\n", c);
3632 printf("No valid value before comma\n");
3635 if (nb_item < max_items) {
3636 parsed_items[nb_item] = value;
3642 if (nb_item >= max_items) {
3643 printf("Number of %s = %u > %u (maximum items)\n",
3644 item_name, nb_item + 1, max_items);
3647 parsed_items[nb_item++] = value;
3648 if (! check_unique_values)
3652 * Then, check that all values in the list are differents.
3653 * No optimization here...
3655 for (i = 0; i < nb_item; i++) {
3656 for (j = i + 1; j < nb_item; j++) {
3657 if (parsed_items[j] == parsed_items[i]) {
3658 printf("duplicated %s %u at index %u and %u\n",
3659 item_name, parsed_items[i], i, j);
3667 struct cmd_set_list_result {
3668 cmdline_fixed_string_t cmd_keyword;
3669 cmdline_fixed_string_t list_name;
3670 cmdline_fixed_string_t list_of_items;
3673 static void cmd_set_list_parsed(void *parsed_result,
3674 __rte_unused struct cmdline *cl,
3675 __rte_unused void *data)
3677 struct cmd_set_list_result *res;
3679 unsigned int lcorelist[RTE_MAX_LCORE];
3680 unsigned int portlist[RTE_MAX_ETHPORTS];
3682 unsigned int nb_item;
3684 if (test_done == 0) {
3685 printf("Please stop forwarding first\n");
3689 res = parsed_result;
3690 if (!strcmp(res->list_name, "corelist")) {
3691 nb_item = parse_item_list(res->list_of_items, "core",
3693 parsed_items.lcorelist, 1);
3695 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3700 if (!strcmp(res->list_name, "portlist")) {
3701 nb_item = parse_item_list(res->list_of_items, "port",
3703 parsed_items.portlist, 1);
3705 set_fwd_ports_list(parsed_items.portlist, nb_item);
3711 cmdline_parse_token_string_t cmd_set_list_keyword =
3712 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3714 cmdline_parse_token_string_t cmd_set_list_name =
3715 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3716 "corelist#portlist");
3717 cmdline_parse_token_string_t cmd_set_list_of_items =
3718 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3721 cmdline_parse_inst_t cmd_set_fwd_list = {
3722 .f = cmd_set_list_parsed,
3724 .help_str = "set corelist|portlist <list0[,list1]*>",
3726 (void *)&cmd_set_list_keyword,
3727 (void *)&cmd_set_list_name,
3728 (void *)&cmd_set_list_of_items,
3733 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3735 struct cmd_setmask_result {
3736 cmdline_fixed_string_t set;
3737 cmdline_fixed_string_t mask;
3741 static void cmd_set_mask_parsed(void *parsed_result,
3742 __rte_unused struct cmdline *cl,
3743 __rte_unused void *data)
3745 struct cmd_setmask_result *res = parsed_result;
3747 if (test_done == 0) {
3748 printf("Please stop forwarding first\n");
3751 if (!strcmp(res->mask, "coremask")) {
3752 set_fwd_lcores_mask(res->hexavalue);
3754 } else if (!strcmp(res->mask, "portmask")) {
3755 set_fwd_ports_mask(res->hexavalue);
3760 cmdline_parse_token_string_t cmd_setmask_set =
3761 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3762 cmdline_parse_token_string_t cmd_setmask_mask =
3763 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3764 "coremask#portmask");
3765 cmdline_parse_token_num_t cmd_setmask_value =
3766 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3768 cmdline_parse_inst_t cmd_set_fwd_mask = {
3769 .f = cmd_set_mask_parsed,
3771 .help_str = "set coremask|portmask <hexadecimal value>",
3773 (void *)&cmd_setmask_set,
3774 (void *)&cmd_setmask_mask,
3775 (void *)&cmd_setmask_value,
3781 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3783 struct cmd_set_result {
3784 cmdline_fixed_string_t set;
3785 cmdline_fixed_string_t what;
3789 static void cmd_set_parsed(void *parsed_result,
3790 __rte_unused struct cmdline *cl,
3791 __rte_unused void *data)
3793 struct cmd_set_result *res = parsed_result;
3794 if (!strcmp(res->what, "nbport")) {
3795 set_fwd_ports_number(res->value);
3797 } else if (!strcmp(res->what, "nbcore")) {
3798 set_fwd_lcores_number(res->value);
3800 } else if (!strcmp(res->what, "burst"))
3801 set_nb_pkt_per_burst(res->value);
3802 else if (!strcmp(res->what, "verbose"))
3803 set_verbose_level(res->value);
3806 cmdline_parse_token_string_t cmd_set_set =
3807 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3808 cmdline_parse_token_string_t cmd_set_what =
3809 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3810 "nbport#nbcore#burst#verbose");
3811 cmdline_parse_token_num_t cmd_set_value =
3812 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3814 cmdline_parse_inst_t cmd_set_numbers = {
3815 .f = cmd_set_parsed,
3817 .help_str = "set nbport|nbcore|burst|verbose <value>",
3819 (void *)&cmd_set_set,
3820 (void *)&cmd_set_what,
3821 (void *)&cmd_set_value,
3826 /* *** SET LOG LEVEL CONFIGURATION *** */
3828 struct cmd_set_log_result {
3829 cmdline_fixed_string_t set;
3830 cmdline_fixed_string_t log;
3831 cmdline_fixed_string_t type;
3836 cmd_set_log_parsed(void *parsed_result,
3837 __rte_unused struct cmdline *cl,
3838 __rte_unused void *data)
3840 struct cmd_set_log_result *res;
3843 res = parsed_result;
3844 if (!strcmp(res->type, "global"))
3845 rte_log_set_global_level(res->level);
3847 ret = rte_log_set_level_regexp(res->type, res->level);
3849 printf("Unable to set log level\n");
3853 cmdline_parse_token_string_t cmd_set_log_set =
3854 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3855 cmdline_parse_token_string_t cmd_set_log_log =
3856 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3857 cmdline_parse_token_string_t cmd_set_log_type =
3858 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3859 cmdline_parse_token_num_t cmd_set_log_level =
3860 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3862 cmdline_parse_inst_t cmd_set_log = {
3863 .f = cmd_set_log_parsed,
3865 .help_str = "set log global|<type> <level>",
3867 (void *)&cmd_set_log_set,
3868 (void *)&cmd_set_log_log,
3869 (void *)&cmd_set_log_type,
3870 (void *)&cmd_set_log_level,
3875 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3877 struct cmd_set_rxoffs_result {
3878 cmdline_fixed_string_t cmd_keyword;
3879 cmdline_fixed_string_t rxoffs;
3880 cmdline_fixed_string_t seg_offsets;
3884 cmd_set_rxoffs_parsed(void *parsed_result,
3885 __rte_unused struct cmdline *cl,
3886 __rte_unused void *data)
3888 struct cmd_set_rxoffs_result *res;
3889 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3890 unsigned int nb_segs;
3892 res = parsed_result;
3893 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3894 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3896 set_rx_pkt_offsets(seg_offsets, nb_segs);
3897 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3900 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3901 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3902 cmd_keyword, "set");
3903 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3904 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3906 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3907 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3910 cmdline_parse_inst_t cmd_set_rxoffs = {
3911 .f = cmd_set_rxoffs_parsed,
3913 .help_str = "set rxoffs <len0[,len1]*>",
3915 (void *)&cmd_set_rxoffs_keyword,
3916 (void *)&cmd_set_rxoffs_name,
3917 (void *)&cmd_set_rxoffs_offsets,
3922 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3924 struct cmd_set_rxpkts_result {
3925 cmdline_fixed_string_t cmd_keyword;
3926 cmdline_fixed_string_t rxpkts;
3927 cmdline_fixed_string_t seg_lengths;
3931 cmd_set_rxpkts_parsed(void *parsed_result,
3932 __rte_unused struct cmdline *cl,
3933 __rte_unused void *data)
3935 struct cmd_set_rxpkts_result *res;
3936 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3937 unsigned int nb_segs;
3939 res = parsed_result;
3940 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3941 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3943 set_rx_pkt_segments(seg_lengths, nb_segs);
3944 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3947 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3949 cmd_keyword, "set");
3950 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3953 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3954 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3957 cmdline_parse_inst_t cmd_set_rxpkts = {
3958 .f = cmd_set_rxpkts_parsed,
3960 .help_str = "set rxpkts <len0[,len1]*>",
3962 (void *)&cmd_set_rxpkts_keyword,
3963 (void *)&cmd_set_rxpkts_name,
3964 (void *)&cmd_set_rxpkts_lengths,
3969 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3971 struct cmd_set_txpkts_result {
3972 cmdline_fixed_string_t cmd_keyword;
3973 cmdline_fixed_string_t txpkts;
3974 cmdline_fixed_string_t seg_lengths;
3978 cmd_set_txpkts_parsed(void *parsed_result,
3979 __rte_unused struct cmdline *cl,
3980 __rte_unused void *data)
3982 struct cmd_set_txpkts_result *res;
3983 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3984 unsigned int nb_segs;
3986 res = parsed_result;
3987 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3988 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3990 set_tx_pkt_segments(seg_lengths, nb_segs);
3993 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3994 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3995 cmd_keyword, "set");
3996 cmdline_parse_token_string_t cmd_set_txpkts_name =
3997 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3999 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4000 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4003 cmdline_parse_inst_t cmd_set_txpkts = {
4004 .f = cmd_set_txpkts_parsed,
4006 .help_str = "set txpkts <len0[,len1]*>",
4008 (void *)&cmd_set_txpkts_keyword,
4009 (void *)&cmd_set_txpkts_name,
4010 (void *)&cmd_set_txpkts_lengths,
4015 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4017 struct cmd_set_txsplit_result {
4018 cmdline_fixed_string_t cmd_keyword;
4019 cmdline_fixed_string_t txsplit;
4020 cmdline_fixed_string_t mode;
4024 cmd_set_txsplit_parsed(void *parsed_result,
4025 __rte_unused struct cmdline *cl,
4026 __rte_unused void *data)
4028 struct cmd_set_txsplit_result *res;
4030 res = parsed_result;
4031 set_tx_pkt_split(res->mode);
4034 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4035 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4036 cmd_keyword, "set");
4037 cmdline_parse_token_string_t cmd_set_txsplit_name =
4038 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4039 txsplit, "txsplit");
4040 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4041 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4044 cmdline_parse_inst_t cmd_set_txsplit = {
4045 .f = cmd_set_txsplit_parsed,
4047 .help_str = "set txsplit on|off|rand",
4049 (void *)&cmd_set_txsplit_keyword,
4050 (void *)&cmd_set_txsplit_name,
4051 (void *)&cmd_set_txsplit_mode,
4056 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4058 struct cmd_set_txtimes_result {
4059 cmdline_fixed_string_t cmd_keyword;
4060 cmdline_fixed_string_t txtimes;
4061 cmdline_fixed_string_t tx_times;
4065 cmd_set_txtimes_parsed(void *parsed_result,
4066 __rte_unused struct cmdline *cl,
4067 __rte_unused void *data)
4069 struct cmd_set_txtimes_result *res;
4070 unsigned int tx_times[2] = {0, 0};
4071 unsigned int n_times;
4073 res = parsed_result;
4074 n_times = parse_item_list(res->tx_times, "tx times",
4077 set_tx_pkt_times(tx_times);
4080 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4081 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4082 cmd_keyword, "set");
4083 cmdline_parse_token_string_t cmd_set_txtimes_name =
4084 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4085 txtimes, "txtimes");
4086 cmdline_parse_token_string_t cmd_set_txtimes_value =
4087 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4090 cmdline_parse_inst_t cmd_set_txtimes = {
4091 .f = cmd_set_txtimes_parsed,
4093 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4095 (void *)&cmd_set_txtimes_keyword,
4096 (void *)&cmd_set_txtimes_name,
4097 (void *)&cmd_set_txtimes_value,
4102 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4103 struct cmd_rx_vlan_filter_all_result {
4104 cmdline_fixed_string_t rx_vlan;
4105 cmdline_fixed_string_t what;
4106 cmdline_fixed_string_t all;
4111 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4112 __rte_unused struct cmdline *cl,
4113 __rte_unused void *data)
4115 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4117 if (!strcmp(res->what, "add"))
4118 rx_vlan_all_filter_set(res->port_id, 1);
4120 rx_vlan_all_filter_set(res->port_id, 0);
4123 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4124 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4125 rx_vlan, "rx_vlan");
4126 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4127 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4129 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4130 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4132 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4133 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4134 port_id, RTE_UINT16);
4136 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4137 .f = cmd_rx_vlan_filter_all_parsed,
4139 .help_str = "rx_vlan add|rm all <port_id>: "
4140 "Add/Remove all identifiers to/from the set of VLAN "
4141 "identifiers filtered by a port",
4143 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4144 (void *)&cmd_rx_vlan_filter_all_what,
4145 (void *)&cmd_rx_vlan_filter_all_all,
4146 (void *)&cmd_rx_vlan_filter_all_portid,
4151 /* *** VLAN OFFLOAD SET ON A PORT *** */
4152 struct cmd_vlan_offload_result {
4153 cmdline_fixed_string_t vlan;
4154 cmdline_fixed_string_t set;
4155 cmdline_fixed_string_t vlan_type;
4156 cmdline_fixed_string_t what;
4157 cmdline_fixed_string_t on;
4158 cmdline_fixed_string_t port_id;
4162 cmd_vlan_offload_parsed(void *parsed_result,
4163 __rte_unused struct cmdline *cl,
4164 __rte_unused void *data)
4167 struct cmd_vlan_offload_result *res = parsed_result;
4170 portid_t port_id = 0;
4174 len = strnlen(str, STR_TOKEN_SIZE);
4176 /* Get port_id first */
4184 tmp = strtoul(str, NULL, 0);
4185 /* If port_id greater that what portid_t can represent, return */
4186 if(tmp >= RTE_MAX_ETHPORTS)
4188 port_id = (portid_t)tmp;
4190 if (!strcmp(res->on, "on"))
4195 if (!strcmp(res->what, "strip"))
4196 rx_vlan_strip_set(port_id, on);
4197 else if(!strcmp(res->what, "stripq")){
4198 uint16_t queue_id = 0;
4200 /* No queue_id, return */
4202 printf("must specify (port,queue_id)\n");
4205 tmp = strtoul(str + i + 1, NULL, 0);
4206 /* If queue_id greater that what 16-bits can represent, return */
4210 queue_id = (uint16_t)tmp;
4211 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4213 else if (!strcmp(res->what, "filter"))
4214 rx_vlan_filter_set(port_id, on);
4215 else if (!strcmp(res->what, "qinq_strip"))
4216 rx_vlan_qinq_strip_set(port_id, on);
4218 vlan_extend_set(port_id, on);
4223 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4224 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4226 cmdline_parse_token_string_t cmd_vlan_offload_set =
4227 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4229 cmdline_parse_token_string_t cmd_vlan_offload_what =
4230 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4231 what, "strip#filter#qinq_strip#extend#stripq");
4232 cmdline_parse_token_string_t cmd_vlan_offload_on =
4233 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4235 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4236 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4239 cmdline_parse_inst_t cmd_vlan_offload = {
4240 .f = cmd_vlan_offload_parsed,
4242 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4243 "<port_id[,queue_id]>: "
4244 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4246 (void *)&cmd_vlan_offload_vlan,
4247 (void *)&cmd_vlan_offload_set,
4248 (void *)&cmd_vlan_offload_what,
4249 (void *)&cmd_vlan_offload_on,
4250 (void *)&cmd_vlan_offload_portid,
4255 /* *** VLAN TPID SET ON A PORT *** */
4256 struct cmd_vlan_tpid_result {
4257 cmdline_fixed_string_t vlan;
4258 cmdline_fixed_string_t set;
4259 cmdline_fixed_string_t vlan_type;
4260 cmdline_fixed_string_t what;
4266 cmd_vlan_tpid_parsed(void *parsed_result,
4267 __rte_unused struct cmdline *cl,
4268 __rte_unused void *data)
4270 struct cmd_vlan_tpid_result *res = parsed_result;
4271 enum rte_vlan_type vlan_type;
4273 if (!strcmp(res->vlan_type, "inner"))
4274 vlan_type = ETH_VLAN_TYPE_INNER;
4275 else if (!strcmp(res->vlan_type, "outer"))
4276 vlan_type = ETH_VLAN_TYPE_OUTER;
4278 printf("Unknown vlan type\n");
4281 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4284 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4285 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4287 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4288 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4290 cmdline_parse_token_string_t cmd_vlan_type =
4291 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4292 vlan_type, "inner#outer");
4293 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4294 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4296 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4297 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4299 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4300 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4301 port_id, RTE_UINT16);
4303 cmdline_parse_inst_t cmd_vlan_tpid = {
4304 .f = cmd_vlan_tpid_parsed,
4306 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4307 "Set the VLAN Ether type",
4309 (void *)&cmd_vlan_tpid_vlan,
4310 (void *)&cmd_vlan_tpid_set,
4311 (void *)&cmd_vlan_type,
4312 (void *)&cmd_vlan_tpid_what,
4313 (void *)&cmd_vlan_tpid_tpid,
4314 (void *)&cmd_vlan_tpid_portid,
4319 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4320 struct cmd_rx_vlan_filter_result {
4321 cmdline_fixed_string_t rx_vlan;
4322 cmdline_fixed_string_t what;
4328 cmd_rx_vlan_filter_parsed(void *parsed_result,
4329 __rte_unused struct cmdline *cl,
4330 __rte_unused void *data)
4332 struct cmd_rx_vlan_filter_result *res = parsed_result;
4334 if (!strcmp(res->what, "add"))
4335 rx_vft_set(res->port_id, res->vlan_id, 1);
4337 rx_vft_set(res->port_id, res->vlan_id, 0);
4340 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4341 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4342 rx_vlan, "rx_vlan");
4343 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4344 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4346 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4347 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4348 vlan_id, RTE_UINT16);
4349 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4350 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4351 port_id, RTE_UINT16);
4353 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4354 .f = cmd_rx_vlan_filter_parsed,
4356 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4357 "Add/Remove a VLAN identifier to/from the set of VLAN "
4358 "identifiers filtered by a port",
4360 (void *)&cmd_rx_vlan_filter_rx_vlan,
4361 (void *)&cmd_rx_vlan_filter_what,
4362 (void *)&cmd_rx_vlan_filter_vlanid,
4363 (void *)&cmd_rx_vlan_filter_portid,
4368 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4369 struct cmd_tx_vlan_set_result {
4370 cmdline_fixed_string_t tx_vlan;
4371 cmdline_fixed_string_t set;
4377 cmd_tx_vlan_set_parsed(void *parsed_result,
4378 __rte_unused struct cmdline *cl,
4379 __rte_unused void *data)
4381 struct cmd_tx_vlan_set_result *res = parsed_result;
4383 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4386 if (!port_is_stopped(res->port_id)) {
4387 printf("Please stop port %d first\n", res->port_id);
4391 tx_vlan_set(res->port_id, res->vlan_id);
4393 cmd_reconfig_device_queue(res->port_id, 1, 1);
4396 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4397 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4398 tx_vlan, "tx_vlan");
4399 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4400 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4402 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4403 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4404 port_id, RTE_UINT16);
4405 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4406 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4407 vlan_id, RTE_UINT16);
4409 cmdline_parse_inst_t cmd_tx_vlan_set = {
4410 .f = cmd_tx_vlan_set_parsed,
4412 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4413 "Enable hardware insertion of a single VLAN header "
4414 "with a given TAG Identifier in packets sent on a port",
4416 (void *)&cmd_tx_vlan_set_tx_vlan,
4417 (void *)&cmd_tx_vlan_set_set,
4418 (void *)&cmd_tx_vlan_set_portid,
4419 (void *)&cmd_tx_vlan_set_vlanid,
4424 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4425 struct cmd_tx_vlan_set_qinq_result {
4426 cmdline_fixed_string_t tx_vlan;
4427 cmdline_fixed_string_t set;
4430 uint16_t vlan_id_outer;
4434 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4435 __rte_unused struct cmdline *cl,
4436 __rte_unused void *data)
4438 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4440 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4443 if (!port_is_stopped(res->port_id)) {
4444 printf("Please stop port %d first\n", res->port_id);
4448 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4450 cmd_reconfig_device_queue(res->port_id, 1, 1);
4453 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4454 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4455 tx_vlan, "tx_vlan");
4456 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4457 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4459 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4460 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4461 port_id, RTE_UINT16);
4462 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4463 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4464 vlan_id, RTE_UINT16);
4465 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4466 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4467 vlan_id_outer, RTE_UINT16);
4469 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4470 .f = cmd_tx_vlan_set_qinq_parsed,
4472 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4473 "Enable hardware insertion of double VLAN header "
4474 "with given TAG Identifiers in packets sent on a port",
4476 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4477 (void *)&cmd_tx_vlan_set_qinq_set,
4478 (void *)&cmd_tx_vlan_set_qinq_portid,
4479 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4480 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4485 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4486 struct cmd_tx_vlan_set_pvid_result {
4487 cmdline_fixed_string_t tx_vlan;
4488 cmdline_fixed_string_t set;
4489 cmdline_fixed_string_t pvid;
4492 cmdline_fixed_string_t mode;
4496 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4497 __rte_unused struct cmdline *cl,
4498 __rte_unused void *data)
4500 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4502 if (strcmp(res->mode, "on") == 0)
4503 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4505 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4508 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4509 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4510 tx_vlan, "tx_vlan");
4511 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4512 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4514 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4515 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4517 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4518 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4519 port_id, RTE_UINT16);
4520 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4521 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4522 vlan_id, RTE_UINT16);
4523 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4524 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4527 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4528 .f = cmd_tx_vlan_set_pvid_parsed,
4530 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4532 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4533 (void *)&cmd_tx_vlan_set_pvid_set,
4534 (void *)&cmd_tx_vlan_set_pvid_pvid,
4535 (void *)&cmd_tx_vlan_set_pvid_port_id,
4536 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4537 (void *)&cmd_tx_vlan_set_pvid_mode,
4542 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4543 struct cmd_tx_vlan_reset_result {
4544 cmdline_fixed_string_t tx_vlan;
4545 cmdline_fixed_string_t reset;
4550 cmd_tx_vlan_reset_parsed(void *parsed_result,
4551 __rte_unused struct cmdline *cl,
4552 __rte_unused void *data)
4554 struct cmd_tx_vlan_reset_result *res = parsed_result;
4556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4559 if (!port_is_stopped(res->port_id)) {
4560 printf("Please stop port %d first\n", res->port_id);
4564 tx_vlan_reset(res->port_id);
4566 cmd_reconfig_device_queue(res->port_id, 1, 1);
4569 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4570 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4571 tx_vlan, "tx_vlan");
4572 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4573 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4575 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4576 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4577 port_id, RTE_UINT16);
4579 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4580 .f = cmd_tx_vlan_reset_parsed,
4582 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4583 "VLAN header in packets sent on a port",
4585 (void *)&cmd_tx_vlan_reset_tx_vlan,
4586 (void *)&cmd_tx_vlan_reset_reset,
4587 (void *)&cmd_tx_vlan_reset_portid,
4593 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4594 struct cmd_csum_result {
4595 cmdline_fixed_string_t csum;
4596 cmdline_fixed_string_t mode;
4597 cmdline_fixed_string_t proto;
4598 cmdline_fixed_string_t hwsw;
4603 csum_show(int port_id)
4605 struct rte_eth_dev_info dev_info;
4606 uint64_t tx_offloads;
4609 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4610 printf("Parse tunnel is %s\n",
4611 (ports[port_id].parse_tunnel) ? "on" : "off");
4612 printf("IP checksum offload is %s\n",
4613 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4614 printf("UDP checksum offload is %s\n",
4615 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4616 printf("TCP checksum offload is %s\n",
4617 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4618 printf("SCTP checksum offload is %s\n",
4619 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4620 printf("Outer-Ip checksum offload is %s\n",
4621 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4622 printf("Outer-Udp checksum offload is %s\n",
4623 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4625 /* display warnings if configuration is not supported by the NIC */
4626 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4630 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4631 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4632 printf("Warning: hardware IP checksum enabled but not "
4633 "supported by port %d\n", port_id);
4635 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4636 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4637 printf("Warning: hardware UDP checksum enabled but not "
4638 "supported by port %d\n", port_id);
4640 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4641 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4642 printf("Warning: hardware TCP checksum enabled but not "
4643 "supported by port %d\n", port_id);
4645 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4646 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4647 printf("Warning: hardware SCTP checksum enabled but not "
4648 "supported by port %d\n", port_id);
4650 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4651 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4652 printf("Warning: hardware outer IP checksum enabled but not "
4653 "supported by port %d\n", port_id);
4655 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4656 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4658 printf("Warning: hardware outer UDP checksum enabled but not "
4659 "supported by port %d\n", port_id);
4664 cmd_config_queue_tx_offloads(struct rte_port *port)
4668 /* Apply queue tx offloads configuration */
4669 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4670 port->tx_conf[k].offloads =
4671 port->dev_conf.txmode.offloads;
4675 cmd_csum_parsed(void *parsed_result,
4676 __rte_unused struct cmdline *cl,
4677 __rte_unused void *data)
4679 struct cmd_csum_result *res = parsed_result;
4681 uint64_t csum_offloads = 0;
4682 struct rte_eth_dev_info dev_info;
4685 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4686 printf("invalid port %d\n", res->port_id);
4689 if (!port_is_stopped(res->port_id)) {
4690 printf("Please stop port %d first\n", res->port_id);
4694 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4698 if (!strcmp(res->mode, "set")) {
4700 if (!strcmp(res->hwsw, "hw"))
4703 if (!strcmp(res->proto, "ip")) {
4704 if (hw == 0 || (dev_info.tx_offload_capa &
4705 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4706 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4708 printf("IP checksum offload is not supported "
4709 "by port %u\n", res->port_id);
4711 } else if (!strcmp(res->proto, "udp")) {
4712 if (hw == 0 || (dev_info.tx_offload_capa &
4713 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4714 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4716 printf("UDP checksum offload is not supported "
4717 "by port %u\n", res->port_id);
4719 } else if (!strcmp(res->proto, "tcp")) {
4720 if (hw == 0 || (dev_info.tx_offload_capa &
4721 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4722 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4724 printf("TCP checksum offload is not supported "
4725 "by port %u\n", res->port_id);
4727 } else if (!strcmp(res->proto, "sctp")) {
4728 if (hw == 0 || (dev_info.tx_offload_capa &
4729 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4730 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4732 printf("SCTP checksum offload is not supported "
4733 "by port %u\n", res->port_id);
4735 } else if (!strcmp(res->proto, "outer-ip")) {
4736 if (hw == 0 || (dev_info.tx_offload_capa &
4737 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4739 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4741 printf("Outer IP checksum offload is not "
4742 "supported by port %u\n", res->port_id);
4744 } else if (!strcmp(res->proto, "outer-udp")) {
4745 if (hw == 0 || (dev_info.tx_offload_capa &
4746 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4748 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4750 printf("Outer UDP checksum offload is not "
4751 "supported by port %u\n", res->port_id);
4756 ports[res->port_id].dev_conf.txmode.offloads |=
4759 ports[res->port_id].dev_conf.txmode.offloads &=
4762 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4764 csum_show(res->port_id);
4766 cmd_reconfig_device_queue(res->port_id, 1, 1);
4769 cmdline_parse_token_string_t cmd_csum_csum =
4770 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4772 cmdline_parse_token_string_t cmd_csum_mode =
4773 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4775 cmdline_parse_token_string_t cmd_csum_proto =
4776 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4777 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4778 cmdline_parse_token_string_t cmd_csum_hwsw =
4779 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4781 cmdline_parse_token_num_t cmd_csum_portid =
4782 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4783 port_id, RTE_UINT16);
4785 cmdline_parse_inst_t cmd_csum_set = {
4786 .f = cmd_csum_parsed,
4788 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4789 "Enable/Disable hardware calculation of L3/L4 checksum when "
4790 "using csum forward engine",
4792 (void *)&cmd_csum_csum,
4793 (void *)&cmd_csum_mode,
4794 (void *)&cmd_csum_proto,
4795 (void *)&cmd_csum_hwsw,
4796 (void *)&cmd_csum_portid,
4801 cmdline_parse_token_string_t cmd_csum_mode_show =
4802 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4805 cmdline_parse_inst_t cmd_csum_show = {
4806 .f = cmd_csum_parsed,
4808 .help_str = "csum show <port_id>: Show checksum offload configuration",
4810 (void *)&cmd_csum_csum,
4811 (void *)&cmd_csum_mode_show,
4812 (void *)&cmd_csum_portid,
4817 /* Enable/disable tunnel parsing */
4818 struct cmd_csum_tunnel_result {
4819 cmdline_fixed_string_t csum;
4820 cmdline_fixed_string_t parse;
4821 cmdline_fixed_string_t onoff;
4826 cmd_csum_tunnel_parsed(void *parsed_result,
4827 __rte_unused struct cmdline *cl,
4828 __rte_unused void *data)
4830 struct cmd_csum_tunnel_result *res = parsed_result;
4832 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4835 if (!strcmp(res->onoff, "on"))
4836 ports[res->port_id].parse_tunnel = 1;
4838 ports[res->port_id].parse_tunnel = 0;
4840 csum_show(res->port_id);
4843 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4844 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4846 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4847 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4848 parse, "parse-tunnel");
4849 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4850 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4852 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4853 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4854 port_id, RTE_UINT16);
4856 cmdline_parse_inst_t cmd_csum_tunnel = {
4857 .f = cmd_csum_tunnel_parsed,
4859 .help_str = "csum parse-tunnel on|off <port_id>: "
4860 "Enable/Disable parsing of tunnels for csum engine",
4862 (void *)&cmd_csum_tunnel_csum,
4863 (void *)&cmd_csum_tunnel_parse,
4864 (void *)&cmd_csum_tunnel_onoff,
4865 (void *)&cmd_csum_tunnel_portid,
4870 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4871 struct cmd_tso_set_result {
4872 cmdline_fixed_string_t tso;
4873 cmdline_fixed_string_t mode;
4879 cmd_tso_set_parsed(void *parsed_result,
4880 __rte_unused struct cmdline *cl,
4881 __rte_unused void *data)
4883 struct cmd_tso_set_result *res = parsed_result;
4884 struct rte_eth_dev_info dev_info;
4887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4889 if (!port_is_stopped(res->port_id)) {
4890 printf("Please stop port %d first\n", res->port_id);
4894 if (!strcmp(res->mode, "set"))
4895 ports[res->port_id].tso_segsz = res->tso_segsz;
4897 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4901 if ((ports[res->port_id].tso_segsz != 0) &&
4902 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4903 printf("Error: TSO is not supported by port %d\n",
4908 if (ports[res->port_id].tso_segsz == 0) {
4909 ports[res->port_id].dev_conf.txmode.offloads &=
4910 ~DEV_TX_OFFLOAD_TCP_TSO;
4911 printf("TSO for non-tunneled packets is disabled\n");
4913 ports[res->port_id].dev_conf.txmode.offloads |=
4914 DEV_TX_OFFLOAD_TCP_TSO;
4915 printf("TSO segment size for non-tunneled packets is %d\n",
4916 ports[res->port_id].tso_segsz);
4918 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4920 /* display warnings if configuration is not supported by the NIC */
4921 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4925 if ((ports[res->port_id].tso_segsz != 0) &&
4926 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4927 printf("Warning: TSO enabled but not "
4928 "supported by port %d\n", res->port_id);
4931 cmd_reconfig_device_queue(res->port_id, 1, 1);
4934 cmdline_parse_token_string_t cmd_tso_set_tso =
4935 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4937 cmdline_parse_token_string_t cmd_tso_set_mode =
4938 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4940 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4941 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4942 tso_segsz, RTE_UINT16);
4943 cmdline_parse_token_num_t cmd_tso_set_portid =
4944 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4945 port_id, RTE_UINT16);
4947 cmdline_parse_inst_t cmd_tso_set = {
4948 .f = cmd_tso_set_parsed,
4950 .help_str = "tso set <tso_segsz> <port_id>: "
4951 "Set TSO segment size of non-tunneled packets for csum engine "
4954 (void *)&cmd_tso_set_tso,
4955 (void *)&cmd_tso_set_mode,
4956 (void *)&cmd_tso_set_tso_segsz,
4957 (void *)&cmd_tso_set_portid,
4962 cmdline_parse_token_string_t cmd_tso_show_mode =
4963 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4967 cmdline_parse_inst_t cmd_tso_show = {
4968 .f = cmd_tso_set_parsed,
4970 .help_str = "tso show <port_id>: "
4971 "Show TSO segment size of non-tunneled packets for csum engine",
4973 (void *)&cmd_tso_set_tso,
4974 (void *)&cmd_tso_show_mode,
4975 (void *)&cmd_tso_set_portid,
4980 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4981 struct cmd_tunnel_tso_set_result {
4982 cmdline_fixed_string_t tso;
4983 cmdline_fixed_string_t mode;
4988 static struct rte_eth_dev_info
4989 check_tunnel_tso_nic_support(portid_t port_id)
4991 struct rte_eth_dev_info dev_info;
4993 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4996 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4997 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4998 "not enabled for port %d\n", port_id);
4999 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5000 printf("Warning: GRE TUNNEL TSO not supported therefore "
5001 "not enabled for port %d\n", port_id);
5002 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5003 printf("Warning: IPIP TUNNEL TSO not supported therefore "
5004 "not enabled for port %d\n", port_id);
5005 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5006 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5007 "not enabled for port %d\n", port_id);
5008 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5009 printf("Warning: IP TUNNEL TSO not supported therefore "
5010 "not enabled for port %d\n", port_id);
5011 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5012 printf("Warning: UDP TUNNEL TSO not supported therefore "
5013 "not enabled for port %d\n", port_id);
5018 cmd_tunnel_tso_set_parsed(void *parsed_result,
5019 __rte_unused struct cmdline *cl,
5020 __rte_unused void *data)
5022 struct cmd_tunnel_tso_set_result *res = parsed_result;
5023 struct rte_eth_dev_info dev_info;
5025 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5027 if (!port_is_stopped(res->port_id)) {
5028 printf("Please stop port %d first\n", res->port_id);
5032 if (!strcmp(res->mode, "set"))
5033 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5035 dev_info = check_tunnel_tso_nic_support(res->port_id);
5036 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5037 ports[res->port_id].dev_conf.txmode.offloads &=
5038 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5039 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5040 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5041 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5042 DEV_TX_OFFLOAD_IP_TNL_TSO |
5043 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5044 printf("TSO for tunneled packets is disabled\n");
5046 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5047 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5048 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5049 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5050 DEV_TX_OFFLOAD_IP_TNL_TSO |
5051 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5053 ports[res->port_id].dev_conf.txmode.offloads |=
5054 (tso_offloads & dev_info.tx_offload_capa);
5055 printf("TSO segment size for tunneled packets is %d\n",
5056 ports[res->port_id].tunnel_tso_segsz);
5058 /* Below conditions are needed to make it work:
5059 * (1) tunnel TSO is supported by the NIC;
5060 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5062 * (3) for tunneled pkts with outer L3 of IPv4,
5063 * "csum set outer-ip" must be set to hw, because after tso,
5064 * total_len of outer IP header is changed, and the checksum
5065 * of outer IP header calculated by sw should be wrong; that
5066 * is not necessary for IPv6 tunneled pkts because there's no
5067 * checksum in IP header anymore.
5070 if (!ports[res->port_id].parse_tunnel)
5071 printf("Warning: csum parse_tunnel must be set "
5072 "so that tunneled packets are recognized\n");
5073 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5074 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5075 printf("Warning: csum set outer-ip must be set to hw "
5076 "if outer L3 is IPv4; not necessary for IPv6\n");
5079 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5080 cmd_reconfig_device_queue(res->port_id, 1, 1);
5083 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5084 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5086 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5087 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5089 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5090 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5091 tso_segsz, RTE_UINT16);
5092 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5093 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5094 port_id, RTE_UINT16);
5096 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5097 .f = cmd_tunnel_tso_set_parsed,
5099 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5100 "Set TSO segment size of tunneled packets for csum engine "
5103 (void *)&cmd_tunnel_tso_set_tso,
5104 (void *)&cmd_tunnel_tso_set_mode,
5105 (void *)&cmd_tunnel_tso_set_tso_segsz,
5106 (void *)&cmd_tunnel_tso_set_portid,
5111 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5112 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5116 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5117 .f = cmd_tunnel_tso_set_parsed,
5119 .help_str = "tunnel_tso show <port_id> "
5120 "Show TSO segment size of tunneled packets for csum engine",
5122 (void *)&cmd_tunnel_tso_set_tso,
5123 (void *)&cmd_tunnel_tso_show_mode,
5124 (void *)&cmd_tunnel_tso_set_portid,
5129 /* *** SET GRO FOR A PORT *** */
5130 struct cmd_gro_enable_result {
5131 cmdline_fixed_string_t cmd_set;
5132 cmdline_fixed_string_t cmd_port;
5133 cmdline_fixed_string_t cmd_keyword;
5134 cmdline_fixed_string_t cmd_onoff;
5139 cmd_gro_enable_parsed(void *parsed_result,
5140 __rte_unused struct cmdline *cl,
5141 __rte_unused void *data)
5143 struct cmd_gro_enable_result *res;
5145 res = parsed_result;
5146 if (!strcmp(res->cmd_keyword, "gro"))
5147 setup_gro(res->cmd_onoff, res->cmd_pid);
5150 cmdline_parse_token_string_t cmd_gro_enable_set =
5151 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5153 cmdline_parse_token_string_t cmd_gro_enable_port =
5154 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5155 cmd_keyword, "port");
5156 cmdline_parse_token_num_t cmd_gro_enable_pid =
5157 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5158 cmd_pid, RTE_UINT16);
5159 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5160 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5161 cmd_keyword, "gro");
5162 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5163 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5164 cmd_onoff, "on#off");
5166 cmdline_parse_inst_t cmd_gro_enable = {
5167 .f = cmd_gro_enable_parsed,
5169 .help_str = "set port <port_id> gro on|off",
5171 (void *)&cmd_gro_enable_set,
5172 (void *)&cmd_gro_enable_port,
5173 (void *)&cmd_gro_enable_pid,
5174 (void *)&cmd_gro_enable_keyword,
5175 (void *)&cmd_gro_enable_onoff,
5180 /* *** DISPLAY GRO CONFIGURATION *** */
5181 struct cmd_gro_show_result {
5182 cmdline_fixed_string_t cmd_show;
5183 cmdline_fixed_string_t cmd_port;
5184 cmdline_fixed_string_t cmd_keyword;
5189 cmd_gro_show_parsed(void *parsed_result,
5190 __rte_unused struct cmdline *cl,
5191 __rte_unused void *data)
5193 struct cmd_gro_show_result *res;
5195 res = parsed_result;
5196 if (!strcmp(res->cmd_keyword, "gro"))
5197 show_gro(res->cmd_pid);
5200 cmdline_parse_token_string_t cmd_gro_show_show =
5201 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5203 cmdline_parse_token_string_t cmd_gro_show_port =
5204 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5206 cmdline_parse_token_num_t cmd_gro_show_pid =
5207 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5208 cmd_pid, RTE_UINT16);
5209 cmdline_parse_token_string_t cmd_gro_show_keyword =
5210 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5211 cmd_keyword, "gro");
5213 cmdline_parse_inst_t cmd_gro_show = {
5214 .f = cmd_gro_show_parsed,
5216 .help_str = "show port <port_id> gro",
5218 (void *)&cmd_gro_show_show,
5219 (void *)&cmd_gro_show_port,
5220 (void *)&cmd_gro_show_pid,
5221 (void *)&cmd_gro_show_keyword,
5226 /* *** SET FLUSH CYCLES FOR GRO *** */
5227 struct cmd_gro_flush_result {
5228 cmdline_fixed_string_t cmd_set;
5229 cmdline_fixed_string_t cmd_keyword;
5230 cmdline_fixed_string_t cmd_flush;
5235 cmd_gro_flush_parsed(void *parsed_result,
5236 __rte_unused struct cmdline *cl,
5237 __rte_unused void *data)
5239 struct cmd_gro_flush_result *res;
5241 res = parsed_result;
5242 if ((!strcmp(res->cmd_keyword, "gro")) &&
5243 (!strcmp(res->cmd_flush, "flush")))
5244 setup_gro_flush_cycles(res->cmd_cycles);
5247 cmdline_parse_token_string_t cmd_gro_flush_set =
5248 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5250 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5251 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5252 cmd_keyword, "gro");
5253 cmdline_parse_token_string_t cmd_gro_flush_flush =
5254 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5255 cmd_flush, "flush");
5256 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5257 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5258 cmd_cycles, RTE_UINT8);
5260 cmdline_parse_inst_t cmd_gro_flush = {
5261 .f = cmd_gro_flush_parsed,
5263 .help_str = "set gro flush <cycles>",
5265 (void *)&cmd_gro_flush_set,
5266 (void *)&cmd_gro_flush_keyword,
5267 (void *)&cmd_gro_flush_flush,
5268 (void *)&cmd_gro_flush_cycles,
5273 /* *** ENABLE/DISABLE GSO *** */
5274 struct cmd_gso_enable_result {
5275 cmdline_fixed_string_t cmd_set;
5276 cmdline_fixed_string_t cmd_port;
5277 cmdline_fixed_string_t cmd_keyword;
5278 cmdline_fixed_string_t cmd_mode;
5283 cmd_gso_enable_parsed(void *parsed_result,
5284 __rte_unused struct cmdline *cl,
5285 __rte_unused void *data)
5287 struct cmd_gso_enable_result *res;
5289 res = parsed_result;
5290 if (!strcmp(res->cmd_keyword, "gso"))
5291 setup_gso(res->cmd_mode, res->cmd_pid);
5294 cmdline_parse_token_string_t cmd_gso_enable_set =
5295 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5297 cmdline_parse_token_string_t cmd_gso_enable_port =
5298 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5300 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5301 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5302 cmd_keyword, "gso");
5303 cmdline_parse_token_string_t cmd_gso_enable_mode =
5304 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5305 cmd_mode, "on#off");
5306 cmdline_parse_token_num_t cmd_gso_enable_pid =
5307 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5308 cmd_pid, RTE_UINT16);
5310 cmdline_parse_inst_t cmd_gso_enable = {
5311 .f = cmd_gso_enable_parsed,
5313 .help_str = "set port <port_id> gso on|off",
5315 (void *)&cmd_gso_enable_set,
5316 (void *)&cmd_gso_enable_port,
5317 (void *)&cmd_gso_enable_pid,
5318 (void *)&cmd_gso_enable_keyword,
5319 (void *)&cmd_gso_enable_mode,
5324 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5325 struct cmd_gso_size_result {
5326 cmdline_fixed_string_t cmd_set;
5327 cmdline_fixed_string_t cmd_keyword;
5328 cmdline_fixed_string_t cmd_segsz;
5333 cmd_gso_size_parsed(void *parsed_result,
5334 __rte_unused struct cmdline *cl,
5335 __rte_unused void *data)
5337 struct cmd_gso_size_result *res = parsed_result;
5339 if (test_done == 0) {
5340 printf("Before setting GSO segsz, please first"
5341 " stop forwarding\n");
5345 if (!strcmp(res->cmd_keyword, "gso") &&
5346 !strcmp(res->cmd_segsz, "segsz")) {
5347 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5348 printf("gso_size should be larger than %zu."
5349 " Please input a legal value\n",
5350 RTE_GSO_SEG_SIZE_MIN);
5352 gso_max_segment_size = res->cmd_size;
5356 cmdline_parse_token_string_t cmd_gso_size_set =
5357 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5359 cmdline_parse_token_string_t cmd_gso_size_keyword =
5360 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5361 cmd_keyword, "gso");
5362 cmdline_parse_token_string_t cmd_gso_size_segsz =
5363 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5364 cmd_segsz, "segsz");
5365 cmdline_parse_token_num_t cmd_gso_size_size =
5366 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5367 cmd_size, RTE_UINT16);
5369 cmdline_parse_inst_t cmd_gso_size = {
5370 .f = cmd_gso_size_parsed,
5372 .help_str = "set gso segsz <length>",
5374 (void *)&cmd_gso_size_set,
5375 (void *)&cmd_gso_size_keyword,
5376 (void *)&cmd_gso_size_segsz,
5377 (void *)&cmd_gso_size_size,
5382 /* *** SHOW GSO CONFIGURATION *** */
5383 struct cmd_gso_show_result {
5384 cmdline_fixed_string_t cmd_show;
5385 cmdline_fixed_string_t cmd_port;
5386 cmdline_fixed_string_t cmd_keyword;
5391 cmd_gso_show_parsed(void *parsed_result,
5392 __rte_unused struct cmdline *cl,
5393 __rte_unused void *data)
5395 struct cmd_gso_show_result *res = parsed_result;
5397 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5398 printf("invalid port id %u\n", res->cmd_pid);
5401 if (!strcmp(res->cmd_keyword, "gso")) {
5402 if (gso_ports[res->cmd_pid].enable) {
5403 printf("Max GSO'd packet size: %uB\n"
5404 "Supported GSO types: TCP/IPv4, "
5405 "UDP/IPv4, VxLAN with inner "
5406 "TCP/IPv4 packet, GRE with inner "
5407 "TCP/IPv4 packet\n",
5408 gso_max_segment_size);
5410 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5414 cmdline_parse_token_string_t cmd_gso_show_show =
5415 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5417 cmdline_parse_token_string_t cmd_gso_show_port =
5418 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5420 cmdline_parse_token_string_t cmd_gso_show_keyword =
5421 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5422 cmd_keyword, "gso");
5423 cmdline_parse_token_num_t cmd_gso_show_pid =
5424 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5425 cmd_pid, RTE_UINT16);
5427 cmdline_parse_inst_t cmd_gso_show = {
5428 .f = cmd_gso_show_parsed,
5430 .help_str = "show port <port_id> gso",
5432 (void *)&cmd_gso_show_show,
5433 (void *)&cmd_gso_show_port,
5434 (void *)&cmd_gso_show_pid,
5435 (void *)&cmd_gso_show_keyword,
5440 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5441 struct cmd_set_flush_rx {
5442 cmdline_fixed_string_t set;
5443 cmdline_fixed_string_t flush_rx;
5444 cmdline_fixed_string_t mode;
5448 cmd_set_flush_rx_parsed(void *parsed_result,
5449 __rte_unused struct cmdline *cl,
5450 __rte_unused void *data)
5452 struct cmd_set_flush_rx *res = parsed_result;
5453 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5456 cmdline_parse_token_string_t cmd_setflushrx_set =
5457 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5459 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5460 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5461 flush_rx, "flush_rx");
5462 cmdline_parse_token_string_t cmd_setflushrx_mode =
5463 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5467 cmdline_parse_inst_t cmd_set_flush_rx = {
5468 .f = cmd_set_flush_rx_parsed,
5469 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5472 (void *)&cmd_setflushrx_set,
5473 (void *)&cmd_setflushrx_flush_rx,
5474 (void *)&cmd_setflushrx_mode,
5479 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5480 struct cmd_set_link_check {
5481 cmdline_fixed_string_t set;
5482 cmdline_fixed_string_t link_check;
5483 cmdline_fixed_string_t mode;
5487 cmd_set_link_check_parsed(void *parsed_result,
5488 __rte_unused struct cmdline *cl,
5489 __rte_unused void *data)
5491 struct cmd_set_link_check *res = parsed_result;
5492 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5495 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5496 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5498 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5499 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5500 link_check, "link_check");
5501 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5502 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5506 cmdline_parse_inst_t cmd_set_link_check = {
5507 .f = cmd_set_link_check_parsed,
5508 .help_str = "set link_check on|off: Enable/Disable link status check "
5509 "when starting/stopping a port",
5512 (void *)&cmd_setlinkcheck_set,
5513 (void *)&cmd_setlinkcheck_link_check,
5514 (void *)&cmd_setlinkcheck_mode,
5519 /* *** SET NIC BYPASS MODE *** */
5520 struct cmd_set_bypass_mode_result {
5521 cmdline_fixed_string_t set;
5522 cmdline_fixed_string_t bypass;
5523 cmdline_fixed_string_t mode;
5524 cmdline_fixed_string_t value;
5529 cmd_set_bypass_mode_parsed(void *parsed_result,
5530 __rte_unused struct cmdline *cl,
5531 __rte_unused void *data)
5533 struct cmd_set_bypass_mode_result *res = parsed_result;
5534 portid_t port_id = res->port_id;
5535 int32_t rc = -EINVAL;
5537 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5538 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5540 if (!strcmp(res->value, "bypass"))
5541 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5542 else if (!strcmp(res->value, "isolate"))
5543 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5545 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5547 /* Set the bypass mode for the relevant port. */
5548 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5551 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5554 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5555 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5557 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5558 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5560 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5561 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5563 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5564 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5565 value, "normal#bypass#isolate");
5566 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5567 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5568 port_id, RTE_UINT16);
5570 cmdline_parse_inst_t cmd_set_bypass_mode = {
5571 .f = cmd_set_bypass_mode_parsed,
5572 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5573 "Set the NIC bypass mode for port_id",
5576 (void *)&cmd_setbypass_mode_set,
5577 (void *)&cmd_setbypass_mode_bypass,
5578 (void *)&cmd_setbypass_mode_mode,
5579 (void *)&cmd_setbypass_mode_value,
5580 (void *)&cmd_setbypass_mode_port,
5585 /* *** SET NIC BYPASS EVENT *** */
5586 struct cmd_set_bypass_event_result {
5587 cmdline_fixed_string_t set;
5588 cmdline_fixed_string_t bypass;
5589 cmdline_fixed_string_t event;
5590 cmdline_fixed_string_t event_value;
5591 cmdline_fixed_string_t mode;
5592 cmdline_fixed_string_t mode_value;
5597 cmd_set_bypass_event_parsed(void *parsed_result,
5598 __rte_unused struct cmdline *cl,
5599 __rte_unused void *data)
5601 int32_t rc = -EINVAL;
5602 struct cmd_set_bypass_event_result *res = parsed_result;
5603 portid_t port_id = res->port_id;
5605 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5606 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5607 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5609 if (!strcmp(res->event_value, "timeout"))
5610 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5611 else if (!strcmp(res->event_value, "os_on"))
5612 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5613 else if (!strcmp(res->event_value, "os_off"))
5614 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5615 else if (!strcmp(res->event_value, "power_on"))
5616 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5617 else if (!strcmp(res->event_value, "power_off"))
5618 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5620 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5622 if (!strcmp(res->mode_value, "bypass"))
5623 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5624 else if (!strcmp(res->mode_value, "isolate"))
5625 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5627 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5629 /* Set the watchdog timeout. */
5630 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5633 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5634 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5638 printf("Failed to set timeout value %u "
5639 "for port %d, errto code: %d.\n",
5640 bypass_timeout, port_id, rc);
5644 /* Set the bypass event to transition to bypass mode. */
5645 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5650 printf("\t Failed to set bypass event for port = %d.\n",
5654 cmdline_parse_token_string_t cmd_setbypass_event_set =
5655 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5657 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5658 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5660 cmdline_parse_token_string_t cmd_setbypass_event_event =
5661 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5663 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5664 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5665 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5666 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5667 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5669 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5670 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5671 mode_value, "normal#bypass#isolate");
5672 cmdline_parse_token_num_t cmd_setbypass_event_port =
5673 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5674 port_id, RTE_UINT16);
5676 cmdline_parse_inst_t cmd_set_bypass_event = {
5677 .f = cmd_set_bypass_event_parsed,
5678 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5679 "power_off mode normal|bypass|isolate <port_id>: "
5680 "Set the NIC bypass event mode for port_id",
5683 (void *)&cmd_setbypass_event_set,
5684 (void *)&cmd_setbypass_event_bypass,
5685 (void *)&cmd_setbypass_event_event,
5686 (void *)&cmd_setbypass_event_event_value,
5687 (void *)&cmd_setbypass_event_mode,
5688 (void *)&cmd_setbypass_event_mode_value,
5689 (void *)&cmd_setbypass_event_port,
5695 /* *** SET NIC BYPASS TIMEOUT *** */
5696 struct cmd_set_bypass_timeout_result {
5697 cmdline_fixed_string_t set;
5698 cmdline_fixed_string_t bypass;
5699 cmdline_fixed_string_t timeout;
5700 cmdline_fixed_string_t value;
5704 cmd_set_bypass_timeout_parsed(void *parsed_result,
5705 __rte_unused struct cmdline *cl,
5706 __rte_unused void *data)
5708 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5710 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5711 if (!strcmp(res->value, "1.5"))
5712 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5713 else if (!strcmp(res->value, "2"))
5714 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5715 else if (!strcmp(res->value, "3"))
5716 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5717 else if (!strcmp(res->value, "4"))
5718 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5719 else if (!strcmp(res->value, "8"))
5720 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5721 else if (!strcmp(res->value, "16"))
5722 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5723 else if (!strcmp(res->value, "32"))
5724 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5726 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5730 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5731 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5733 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5734 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5736 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5737 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5738 timeout, "timeout");
5739 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5740 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5741 value, "0#1.5#2#3#4#8#16#32");
5743 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5744 .f = cmd_set_bypass_timeout_parsed,
5745 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5746 "Set the NIC bypass watchdog timeout in seconds",
5749 (void *)&cmd_setbypass_timeout_set,
5750 (void *)&cmd_setbypass_timeout_bypass,
5751 (void *)&cmd_setbypass_timeout_timeout,
5752 (void *)&cmd_setbypass_timeout_value,
5757 /* *** SHOW NIC BYPASS MODE *** */
5758 struct cmd_show_bypass_config_result {
5759 cmdline_fixed_string_t show;
5760 cmdline_fixed_string_t bypass;
5761 cmdline_fixed_string_t config;
5766 cmd_show_bypass_config_parsed(void *parsed_result,
5767 __rte_unused struct cmdline *cl,
5768 __rte_unused void *data)
5770 struct cmd_show_bypass_config_result *res = parsed_result;
5771 portid_t port_id = res->port_id;
5773 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5774 uint32_t event_mode;
5775 uint32_t bypass_mode;
5776 uint32_t timeout = bypass_timeout;
5779 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5780 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5781 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5782 {"UNKNOWN", "normal", "bypass", "isolate"};
5783 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5791 /* Display the bypass mode.*/
5792 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5793 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5797 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5798 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5800 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5803 /* Display the bypass timeout.*/
5804 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5805 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5807 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5809 /* Display the bypass events and associated modes. */
5810 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5812 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5813 printf("\tFailed to get bypass mode for event = %s\n",
5816 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5817 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5819 printf("\tbypass event: %-16s = %s\n", events[i],
5825 printf("\tFailed to get bypass configuration for port = %d\n",
5829 cmdline_parse_token_string_t cmd_showbypass_config_show =
5830 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5832 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5833 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5835 cmdline_parse_token_string_t cmd_showbypass_config_config =
5836 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5838 cmdline_parse_token_num_t cmd_showbypass_config_port =
5839 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5840 port_id, RTE_UINT16);
5842 cmdline_parse_inst_t cmd_show_bypass_config = {
5843 .f = cmd_show_bypass_config_parsed,
5844 .help_str = "show bypass config <port_id>: "
5845 "Show the NIC bypass config for port_id",
5848 (void *)&cmd_showbypass_config_show,
5849 (void *)&cmd_showbypass_config_bypass,
5850 (void *)&cmd_showbypass_config_config,
5851 (void *)&cmd_showbypass_config_port,
5857 /* *** SET BONDING MODE *** */
5858 struct cmd_set_bonding_mode_result {
5859 cmdline_fixed_string_t set;
5860 cmdline_fixed_string_t bonding;
5861 cmdline_fixed_string_t mode;
5866 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5867 __rte_unused struct cmdline *cl,
5868 __rte_unused void *data)
5870 struct cmd_set_bonding_mode_result *res = parsed_result;
5871 portid_t port_id = res->port_id;
5873 /* Set the bonding mode for the relevant port. */
5874 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5875 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5878 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5879 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5881 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5882 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5883 bonding, "bonding");
5884 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5885 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5887 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5888 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5890 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5891 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5892 port_id, RTE_UINT16);
5894 cmdline_parse_inst_t cmd_set_bonding_mode = {
5895 .f = cmd_set_bonding_mode_parsed,
5896 .help_str = "set bonding mode <mode_value> <port_id>: "
5897 "Set the bonding mode for port_id",
5900 (void *) &cmd_setbonding_mode_set,
5901 (void *) &cmd_setbonding_mode_bonding,
5902 (void *) &cmd_setbonding_mode_mode,
5903 (void *) &cmd_setbonding_mode_value,
5904 (void *) &cmd_setbonding_mode_port,
5909 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5910 struct cmd_set_bonding_lacp_dedicated_queues_result {
5911 cmdline_fixed_string_t set;
5912 cmdline_fixed_string_t bonding;
5913 cmdline_fixed_string_t lacp;
5914 cmdline_fixed_string_t dedicated_queues;
5916 cmdline_fixed_string_t mode;
5919 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5920 __rte_unused struct cmdline *cl,
5921 __rte_unused void *data)
5923 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5924 portid_t port_id = res->port_id;
5925 struct rte_port *port;
5927 port = &ports[port_id];
5929 /** Check if the port is not started **/
5930 if (port->port_status != RTE_PORT_STOPPED) {
5931 printf("Please stop port %d first\n", port_id);
5935 if (!strcmp(res->mode, "enable")) {
5936 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5937 printf("Dedicate queues for LACP control packets"
5940 printf("Enabling dedicate queues for LACP control "
5941 "packets on port %d failed\n", port_id);
5942 } else if (!strcmp(res->mode, "disable")) {
5943 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5944 printf("Dedicated queues for LACP control packets "
5947 printf("Disabling dedicated queues for LACP control "
5948 "traffic on port %d failed\n", port_id);
5952 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5953 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5955 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5956 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5957 bonding, "bonding");
5958 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5959 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5961 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5962 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5963 dedicated_queues, "dedicated_queues");
5964 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5965 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5966 port_id, RTE_UINT16);
5967 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5968 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5969 mode, "enable#disable");
5971 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5972 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5973 .help_str = "set bonding lacp dedicated_queues <port_id> "
5975 "Enable/disable dedicated queues for LACP control traffic for port_id",
5978 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5979 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5980 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5981 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5982 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5983 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5988 /* *** SET BALANCE XMIT POLICY *** */
5989 struct cmd_set_bonding_balance_xmit_policy_result {
5990 cmdline_fixed_string_t set;
5991 cmdline_fixed_string_t bonding;
5992 cmdline_fixed_string_t balance_xmit_policy;
5994 cmdline_fixed_string_t policy;
5997 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5998 __rte_unused struct cmdline *cl,
5999 __rte_unused void *data)
6001 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6002 portid_t port_id = res->port_id;
6005 if (!strcmp(res->policy, "l2")) {
6006 policy = BALANCE_XMIT_POLICY_LAYER2;
6007 } else if (!strcmp(res->policy, "l23")) {
6008 policy = BALANCE_XMIT_POLICY_LAYER23;
6009 } else if (!strcmp(res->policy, "l34")) {
6010 policy = BALANCE_XMIT_POLICY_LAYER34;
6012 printf("\t Invalid xmit policy selection");
6016 /* Set the bonding mode for the relevant port. */
6017 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6018 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6023 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6024 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6026 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6027 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6028 bonding, "bonding");
6029 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6030 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6031 balance_xmit_policy, "balance_xmit_policy");
6032 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6033 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6034 port_id, RTE_UINT16);
6035 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6036 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6037 policy, "l2#l23#l34");
6039 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6040 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6041 .help_str = "set bonding balance_xmit_policy <port_id> "
6043 "Set the bonding balance_xmit_policy for port_id",
6046 (void *)&cmd_setbonding_balance_xmit_policy_set,
6047 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6048 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6049 (void *)&cmd_setbonding_balance_xmit_policy_port,
6050 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6055 /* *** SHOW NIC BONDING CONFIGURATION *** */
6056 struct cmd_show_bonding_config_result {
6057 cmdline_fixed_string_t show;
6058 cmdline_fixed_string_t bonding;
6059 cmdline_fixed_string_t config;
6063 static void cmd_show_bonding_config_parsed(void *parsed_result,
6064 __rte_unused struct cmdline *cl,
6065 __rte_unused void *data)
6067 struct cmd_show_bonding_config_result *res = parsed_result;
6068 int bonding_mode, agg_mode;
6069 portid_t slaves[RTE_MAX_ETHPORTS];
6070 int num_slaves, num_active_slaves;
6073 portid_t port_id = res->port_id;
6075 /* Display the bonding mode.*/
6076 bonding_mode = rte_eth_bond_mode_get(port_id);
6077 if (bonding_mode < 0) {
6078 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6081 printf("\tBonding mode: %d\n", bonding_mode);
6083 if (bonding_mode == BONDING_MODE_BALANCE) {
6084 int balance_xmit_policy;
6086 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6087 if (balance_xmit_policy < 0) {
6088 printf("\tFailed to get balance xmit policy for port = %d\n",
6092 printf("\tBalance Xmit Policy: ");
6094 switch (balance_xmit_policy) {
6095 case BALANCE_XMIT_POLICY_LAYER2:
6096 printf("BALANCE_XMIT_POLICY_LAYER2");
6098 case BALANCE_XMIT_POLICY_LAYER23:
6099 printf("BALANCE_XMIT_POLICY_LAYER23");
6101 case BALANCE_XMIT_POLICY_LAYER34:
6102 printf("BALANCE_XMIT_POLICY_LAYER34");
6109 if (bonding_mode == BONDING_MODE_8023AD) {
6110 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6111 printf("\tIEEE802.3AD Aggregator Mode: ");
6114 printf("bandwidth");
6126 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6128 if (num_slaves < 0) {
6129 printf("\tFailed to get slave list for port = %d\n", port_id);
6132 if (num_slaves > 0) {
6133 printf("\tSlaves (%d): [", num_slaves);
6134 for (i = 0; i < num_slaves - 1; i++)
6135 printf("%d ", slaves[i]);
6137 printf("%d]\n", slaves[num_slaves - 1]);
6139 printf("\tSlaves: []\n");
6143 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6146 if (num_active_slaves < 0) {
6147 printf("\tFailed to get active slave list for port = %d\n", port_id);
6150 if (num_active_slaves > 0) {
6151 printf("\tActive Slaves (%d): [", num_active_slaves);
6152 for (i = 0; i < num_active_slaves - 1; i++)
6153 printf("%d ", slaves[i]);
6155 printf("%d]\n", slaves[num_active_slaves - 1]);
6158 printf("\tActive Slaves: []\n");
6162 primary_id = rte_eth_bond_primary_get(port_id);
6163 if (primary_id < 0) {
6164 printf("\tFailed to get primary slave for port = %d\n", port_id);
6167 printf("\tPrimary: [%d]\n", primary_id);
6171 cmdline_parse_token_string_t cmd_showbonding_config_show =
6172 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6174 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6175 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6176 bonding, "bonding");
6177 cmdline_parse_token_string_t cmd_showbonding_config_config =
6178 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6180 cmdline_parse_token_num_t cmd_showbonding_config_port =
6181 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6182 port_id, RTE_UINT16);
6184 cmdline_parse_inst_t cmd_show_bonding_config = {
6185 .f = cmd_show_bonding_config_parsed,
6186 .help_str = "show bonding config <port_id>: "
6187 "Show the bonding config for port_id",
6190 (void *)&cmd_showbonding_config_show,
6191 (void *)&cmd_showbonding_config_bonding,
6192 (void *)&cmd_showbonding_config_config,
6193 (void *)&cmd_showbonding_config_port,
6198 /* *** SET BONDING PRIMARY *** */
6199 struct cmd_set_bonding_primary_result {
6200 cmdline_fixed_string_t set;
6201 cmdline_fixed_string_t bonding;
6202 cmdline_fixed_string_t primary;
6207 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6208 __rte_unused struct cmdline *cl,
6209 __rte_unused void *data)
6211 struct cmd_set_bonding_primary_result *res = parsed_result;
6212 portid_t master_port_id = res->port_id;
6213 portid_t slave_port_id = res->slave_id;
6215 /* Set the primary slave for a bonded device. */
6216 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6217 printf("\t Failed to set primary slave for port = %d.\n",
6224 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6225 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6227 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6228 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6229 bonding, "bonding");
6230 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6231 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6232 primary, "primary");
6233 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6234 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6235 slave_id, RTE_UINT16);
6236 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6237 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6238 port_id, RTE_UINT16);
6240 cmdline_parse_inst_t cmd_set_bonding_primary = {
6241 .f = cmd_set_bonding_primary_parsed,
6242 .help_str = "set bonding primary <slave_id> <port_id>: "
6243 "Set the primary slave for port_id",
6246 (void *)&cmd_setbonding_primary_set,
6247 (void *)&cmd_setbonding_primary_bonding,
6248 (void *)&cmd_setbonding_primary_primary,
6249 (void *)&cmd_setbonding_primary_slave,
6250 (void *)&cmd_setbonding_primary_port,
6255 /* *** ADD SLAVE *** */
6256 struct cmd_add_bonding_slave_result {
6257 cmdline_fixed_string_t add;
6258 cmdline_fixed_string_t bonding;
6259 cmdline_fixed_string_t slave;
6264 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6265 __rte_unused struct cmdline *cl,
6266 __rte_unused void *data)
6268 struct cmd_add_bonding_slave_result *res = parsed_result;
6269 portid_t master_port_id = res->port_id;
6270 portid_t slave_port_id = res->slave_id;
6272 /* add the slave for a bonded device. */
6273 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6274 printf("\t Failed to add slave %d to master port = %d.\n",
6275 slave_port_id, master_port_id);
6279 set_port_slave_flag(slave_port_id);
6282 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6283 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6285 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6286 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6287 bonding, "bonding");
6288 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6289 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6291 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6292 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6293 slave_id, RTE_UINT16);
6294 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6295 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6296 port_id, RTE_UINT16);
6298 cmdline_parse_inst_t cmd_add_bonding_slave = {
6299 .f = cmd_add_bonding_slave_parsed,
6300 .help_str = "add bonding slave <slave_id> <port_id>: "
6301 "Add a slave device to a bonded device",
6304 (void *)&cmd_addbonding_slave_add,
6305 (void *)&cmd_addbonding_slave_bonding,
6306 (void *)&cmd_addbonding_slave_slave,
6307 (void *)&cmd_addbonding_slave_slaveid,
6308 (void *)&cmd_addbonding_slave_port,
6313 /* *** REMOVE SLAVE *** */
6314 struct cmd_remove_bonding_slave_result {
6315 cmdline_fixed_string_t remove;
6316 cmdline_fixed_string_t bonding;
6317 cmdline_fixed_string_t slave;
6322 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6323 __rte_unused struct cmdline *cl,
6324 __rte_unused void *data)
6326 struct cmd_remove_bonding_slave_result *res = parsed_result;
6327 portid_t master_port_id = res->port_id;
6328 portid_t slave_port_id = res->slave_id;
6330 /* remove the slave from a bonded device. */
6331 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6332 printf("\t Failed to remove slave %d from master port = %d.\n",
6333 slave_port_id, master_port_id);
6337 clear_port_slave_flag(slave_port_id);
6340 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6341 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6343 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6344 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6345 bonding, "bonding");
6346 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6347 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6349 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6350 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6351 slave_id, RTE_UINT16);
6352 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6353 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6354 port_id, RTE_UINT16);
6356 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6357 .f = cmd_remove_bonding_slave_parsed,
6358 .help_str = "remove bonding slave <slave_id> <port_id>: "
6359 "Remove a slave device from a bonded device",
6362 (void *)&cmd_removebonding_slave_remove,
6363 (void *)&cmd_removebonding_slave_bonding,
6364 (void *)&cmd_removebonding_slave_slave,
6365 (void *)&cmd_removebonding_slave_slaveid,
6366 (void *)&cmd_removebonding_slave_port,
6371 /* *** CREATE BONDED DEVICE *** */
6372 struct cmd_create_bonded_device_result {
6373 cmdline_fixed_string_t create;
6374 cmdline_fixed_string_t bonded;
6375 cmdline_fixed_string_t device;
6380 static int bond_dev_num = 0;
6382 static void cmd_create_bonded_device_parsed(void *parsed_result,
6383 __rte_unused struct cmdline *cl,
6384 __rte_unused void *data)
6386 struct cmd_create_bonded_device_result *res = parsed_result;
6387 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6391 if (test_done == 0) {
6392 printf("Please stop forwarding first\n");
6396 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6399 /* Create a new bonded device. */
6400 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6402 printf("\t Failed to create bonded device.\n");
6405 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6408 /* Update number of ports */
6409 nb_ports = rte_eth_dev_count_avail();
6410 reconfig(port_id, res->socket);
6411 ret = rte_eth_promiscuous_enable(port_id);
6413 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6414 port_id, rte_strerror(-ret));
6416 ports[port_id].need_setup = 0;
6417 ports[port_id].port_status = RTE_PORT_STOPPED;
6422 cmdline_parse_token_string_t cmd_createbonded_device_create =
6423 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6425 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6426 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6428 cmdline_parse_token_string_t cmd_createbonded_device_device =
6429 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6431 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6432 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6434 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6435 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6438 cmdline_parse_inst_t cmd_create_bonded_device = {
6439 .f = cmd_create_bonded_device_parsed,
6440 .help_str = "create bonded device <mode> <socket>: "
6441 "Create a new bonded device with specific bonding mode and socket",
6444 (void *)&cmd_createbonded_device_create,
6445 (void *)&cmd_createbonded_device_bonded,
6446 (void *)&cmd_createbonded_device_device,
6447 (void *)&cmd_createbonded_device_mode,
6448 (void *)&cmd_createbonded_device_socket,
6453 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6454 struct cmd_set_bond_mac_addr_result {
6455 cmdline_fixed_string_t set;
6456 cmdline_fixed_string_t bonding;
6457 cmdline_fixed_string_t mac_addr;
6459 struct rte_ether_addr address;
6462 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6463 __rte_unused struct cmdline *cl,
6464 __rte_unused void *data)
6466 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6469 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6472 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6474 /* check the return value and print it if is < 0 */
6476 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6479 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6480 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6481 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6484 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6485 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6487 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6488 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6489 port_num, RTE_UINT16);
6490 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6491 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6493 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6494 .f = cmd_set_bond_mac_addr_parsed,
6496 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6498 (void *)&cmd_set_bond_mac_addr_set,
6499 (void *)&cmd_set_bond_mac_addr_bonding,
6500 (void *)&cmd_set_bond_mac_addr_mac,
6501 (void *)&cmd_set_bond_mac_addr_portnum,
6502 (void *)&cmd_set_bond_mac_addr_addr,
6508 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6509 struct cmd_set_bond_mon_period_result {
6510 cmdline_fixed_string_t set;
6511 cmdline_fixed_string_t bonding;
6512 cmdline_fixed_string_t mon_period;
6517 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6518 __rte_unused struct cmdline *cl,
6519 __rte_unused void *data)
6521 struct cmd_set_bond_mon_period_result *res = parsed_result;
6524 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6526 /* check the return value and print it if is < 0 */
6528 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6531 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6532 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6534 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6535 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6536 bonding, "bonding");
6537 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6538 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6539 mon_period, "mon_period");
6540 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6541 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6542 port_num, RTE_UINT16);
6543 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6544 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6545 period_ms, RTE_UINT32);
6547 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6548 .f = cmd_set_bond_mon_period_parsed,
6550 .help_str = "set bonding mon_period <port_id> <period_ms>",
6552 (void *)&cmd_set_bond_mon_period_set,
6553 (void *)&cmd_set_bond_mon_period_bonding,
6554 (void *)&cmd_set_bond_mon_period_mon_period,
6555 (void *)&cmd_set_bond_mon_period_portnum,
6556 (void *)&cmd_set_bond_mon_period_period_ms,
6563 struct cmd_set_bonding_agg_mode_policy_result {
6564 cmdline_fixed_string_t set;
6565 cmdline_fixed_string_t bonding;
6566 cmdline_fixed_string_t agg_mode;
6568 cmdline_fixed_string_t policy;
6573 cmd_set_bonding_agg_mode(void *parsed_result,
6574 __rte_unused struct cmdline *cl,
6575 __rte_unused void *data)
6577 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6578 uint8_t policy = AGG_BANDWIDTH;
6580 if (!strcmp(res->policy, "bandwidth"))
6581 policy = AGG_BANDWIDTH;
6582 else if (!strcmp(res->policy, "stable"))
6583 policy = AGG_STABLE;
6584 else if (!strcmp(res->policy, "count"))
6587 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6591 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6592 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6594 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6595 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6596 bonding, "bonding");
6598 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6599 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6600 agg_mode, "agg_mode");
6602 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6603 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6604 port_num, RTE_UINT16);
6606 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6607 TOKEN_STRING_INITIALIZER(
6608 struct cmd_set_bonding_balance_xmit_policy_result,
6609 policy, "stable#bandwidth#count");
6611 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6612 .f = cmd_set_bonding_agg_mode,
6614 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6616 (void *)&cmd_set_bonding_agg_mode_set,
6617 (void *)&cmd_set_bonding_agg_mode_bonding,
6618 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6619 (void *)&cmd_set_bonding_agg_mode_portnum,
6620 (void *)&cmd_set_bonding_agg_mode_policy_string,
6626 #endif /* RTE_NET_BOND */
6628 /* *** SET FORWARDING MODE *** */
6629 struct cmd_set_fwd_mode_result {
6630 cmdline_fixed_string_t set;
6631 cmdline_fixed_string_t fwd;
6632 cmdline_fixed_string_t mode;
6635 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6636 __rte_unused struct cmdline *cl,
6637 __rte_unused void *data)
6639 struct cmd_set_fwd_mode_result *res = parsed_result;
6642 set_pkt_forwarding_mode(res->mode);
6645 cmdline_parse_token_string_t cmd_setfwd_set =
6646 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6647 cmdline_parse_token_string_t cmd_setfwd_fwd =
6648 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6649 cmdline_parse_token_string_t cmd_setfwd_mode =
6650 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6651 "" /* defined at init */);
6653 cmdline_parse_inst_t cmd_set_fwd_mode = {
6654 .f = cmd_set_fwd_mode_parsed,
6656 .help_str = NULL, /* defined at init */
6658 (void *)&cmd_setfwd_set,
6659 (void *)&cmd_setfwd_fwd,
6660 (void *)&cmd_setfwd_mode,
6665 static void cmd_set_fwd_mode_init(void)
6668 static char token[128];
6669 static char help[256];
6670 cmdline_parse_token_string_t *token_struct;
6672 modes = list_pkt_forwarding_modes();
6673 snprintf(help, sizeof(help), "set fwd %s: "
6674 "Set packet forwarding mode", modes);
6675 cmd_set_fwd_mode.help_str = help;
6677 /* string token separator is # */
6678 for (c = token; *modes != '\0'; modes++)
6683 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6684 token_struct->string_data.str = token;
6687 /* *** SET RETRY FORWARDING MODE *** */
6688 struct cmd_set_fwd_retry_mode_result {
6689 cmdline_fixed_string_t set;
6690 cmdline_fixed_string_t fwd;
6691 cmdline_fixed_string_t mode;
6692 cmdline_fixed_string_t retry;
6695 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6696 __rte_unused struct cmdline *cl,
6697 __rte_unused void *data)
6699 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6702 set_pkt_forwarding_mode(res->mode);
6705 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6706 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6708 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6709 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6711 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6712 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6714 "" /* defined at init */);
6715 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6716 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6719 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6720 .f = cmd_set_fwd_retry_mode_parsed,
6722 .help_str = NULL, /* defined at init */
6724 (void *)&cmd_setfwd_retry_set,
6725 (void *)&cmd_setfwd_retry_fwd,
6726 (void *)&cmd_setfwd_retry_mode,
6727 (void *)&cmd_setfwd_retry_retry,
6732 static void cmd_set_fwd_retry_mode_init(void)
6735 static char token[128];
6736 static char help[256];
6737 cmdline_parse_token_string_t *token_struct;
6739 modes = list_pkt_forwarding_retry_modes();
6740 snprintf(help, sizeof(help), "set fwd %s retry: "
6741 "Set packet forwarding mode with retry", modes);
6742 cmd_set_fwd_retry_mode.help_str = help;
6744 /* string token separator is # */
6745 for (c = token; *modes != '\0'; modes++)
6750 token_struct = (cmdline_parse_token_string_t *)
6751 cmd_set_fwd_retry_mode.tokens[2];
6752 token_struct->string_data.str = token;
6755 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6756 struct cmd_set_burst_tx_retry_result {
6757 cmdline_fixed_string_t set;
6758 cmdline_fixed_string_t burst;
6759 cmdline_fixed_string_t tx;
6760 cmdline_fixed_string_t delay;
6762 cmdline_fixed_string_t retry;
6766 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6767 __rte_unused struct cmdline *cl,
6768 __rte_unused void *data)
6770 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6772 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6773 && !strcmp(res->tx, "tx")) {
6774 if (!strcmp(res->delay, "delay"))
6775 burst_tx_delay_time = res->time;
6776 if (!strcmp(res->retry, "retry"))
6777 burst_tx_retry_num = res->retry_num;
6782 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6783 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6784 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6785 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6787 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6788 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6789 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6790 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6791 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6792 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6794 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6795 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6796 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6797 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6800 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6801 .f = cmd_set_burst_tx_retry_parsed,
6802 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6804 (void *)&cmd_set_burst_tx_retry_set,
6805 (void *)&cmd_set_burst_tx_retry_burst,
6806 (void *)&cmd_set_burst_tx_retry_tx,
6807 (void *)&cmd_set_burst_tx_retry_delay,
6808 (void *)&cmd_set_burst_tx_retry_time,
6809 (void *)&cmd_set_burst_tx_retry_retry,
6810 (void *)&cmd_set_burst_tx_retry_retry_num,
6815 /* *** SET PROMISC MODE *** */
6816 struct cmd_set_promisc_mode_result {
6817 cmdline_fixed_string_t set;
6818 cmdline_fixed_string_t promisc;
6819 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6820 uint16_t port_num; /* valid if "allports" argument == 0 */
6821 cmdline_fixed_string_t mode;
6824 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6825 __rte_unused struct cmdline *cl,
6828 struct cmd_set_promisc_mode_result *res = parsed_result;
6832 if (!strcmp(res->mode, "on"))
6839 RTE_ETH_FOREACH_DEV(i)
6840 eth_set_promisc_mode(i, enable);
6842 eth_set_promisc_mode(res->port_num, enable);
6846 cmdline_parse_token_string_t cmd_setpromisc_set =
6847 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6848 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6849 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6851 cmdline_parse_token_string_t cmd_setpromisc_portall =
6852 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6854 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6855 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6857 cmdline_parse_token_string_t cmd_setpromisc_mode =
6858 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6861 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6862 .f = cmd_set_promisc_mode_parsed,
6864 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6866 (void *)&cmd_setpromisc_set,
6867 (void *)&cmd_setpromisc_promisc,
6868 (void *)&cmd_setpromisc_portall,
6869 (void *)&cmd_setpromisc_mode,
6874 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6875 .f = cmd_set_promisc_mode_parsed,
6877 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6879 (void *)&cmd_setpromisc_set,
6880 (void *)&cmd_setpromisc_promisc,
6881 (void *)&cmd_setpromisc_portnum,
6882 (void *)&cmd_setpromisc_mode,
6887 /* *** SET ALLMULTI MODE *** */
6888 struct cmd_set_allmulti_mode_result {
6889 cmdline_fixed_string_t set;
6890 cmdline_fixed_string_t allmulti;
6891 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6892 uint16_t port_num; /* valid if "allports" argument == 0 */
6893 cmdline_fixed_string_t mode;
6896 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6897 __rte_unused struct cmdline *cl,
6900 struct cmd_set_allmulti_mode_result *res = parsed_result;
6904 if (!strcmp(res->mode, "on"))
6911 RTE_ETH_FOREACH_DEV(i) {
6912 eth_set_allmulticast_mode(i, enable);
6916 eth_set_allmulticast_mode(res->port_num, enable);
6920 cmdline_parse_token_string_t cmd_setallmulti_set =
6921 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6922 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6923 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6925 cmdline_parse_token_string_t cmd_setallmulti_portall =
6926 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6928 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6929 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6931 cmdline_parse_token_string_t cmd_setallmulti_mode =
6932 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6935 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6936 .f = cmd_set_allmulti_mode_parsed,
6938 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6940 (void *)&cmd_setallmulti_set,
6941 (void *)&cmd_setallmulti_allmulti,
6942 (void *)&cmd_setallmulti_portall,
6943 (void *)&cmd_setallmulti_mode,
6948 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6949 .f = cmd_set_allmulti_mode_parsed,
6951 .help_str = "set allmulti <port_id> on|off: "
6952 "Set allmulti mode on port_id",
6954 (void *)&cmd_setallmulti_set,
6955 (void *)&cmd_setallmulti_allmulti,
6956 (void *)&cmd_setallmulti_portnum,
6957 (void *)&cmd_setallmulti_mode,
6962 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6963 struct cmd_link_flow_ctrl_show {
6964 cmdline_fixed_string_t show;
6965 cmdline_fixed_string_t port;
6967 cmdline_fixed_string_t flow_ctrl;
6970 cmdline_parse_token_string_t cmd_lfc_show_show =
6971 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6973 cmdline_parse_token_string_t cmd_lfc_show_port =
6974 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6976 cmdline_parse_token_num_t cmd_lfc_show_portid =
6977 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6978 port_id, RTE_UINT16);
6979 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6980 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6981 flow_ctrl, "flow_ctrl");
6984 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6985 __rte_unused struct cmdline *cl,
6986 __rte_unused void *data)
6988 struct cmd_link_flow_ctrl_show *res = parsed_result;
6989 static const char *info_border = "*********************";
6990 struct rte_eth_fc_conf fc_conf;
6991 bool rx_fc_en = false;
6992 bool tx_fc_en = false;
6995 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6997 printf("Failed to get current flow ctrl information: err = %d\n",
7002 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7004 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7007 printf("\n%s Flow control infos for port %-2d %s\n",
7008 info_border, res->port_id, info_border);
7009 printf("FC mode:\n");
7010 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7011 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7012 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7013 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7014 printf("High waterline: 0x%x\n", fc_conf.high_water);
7015 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7016 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7017 printf("Forward MAC control frames: %s\n",
7018 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7019 printf("\n%s************** End ***********%s\n",
7020 info_border, info_border);
7023 cmdline_parse_inst_t cmd_link_flow_control_show = {
7024 .f = cmd_link_flow_ctrl_show_parsed,
7026 .help_str = "show port <port_id> flow_ctrl",
7028 (void *)&cmd_lfc_show_show,
7029 (void *)&cmd_lfc_show_port,
7030 (void *)&cmd_lfc_show_portid,
7031 (void *)&cmd_lfc_show_flow_ctrl,
7036 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7037 struct cmd_link_flow_ctrl_set_result {
7038 cmdline_fixed_string_t set;
7039 cmdline_fixed_string_t flow_ctrl;
7040 cmdline_fixed_string_t rx;
7041 cmdline_fixed_string_t rx_lfc_mode;
7042 cmdline_fixed_string_t tx;
7043 cmdline_fixed_string_t tx_lfc_mode;
7044 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7045 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7046 cmdline_fixed_string_t autoneg_str;
7047 cmdline_fixed_string_t autoneg;
7048 cmdline_fixed_string_t hw_str;
7049 uint32_t high_water;
7050 cmdline_fixed_string_t lw_str;
7052 cmdline_fixed_string_t pt_str;
7053 uint16_t pause_time;
7054 cmdline_fixed_string_t xon_str;
7059 cmdline_parse_token_string_t cmd_lfc_set_set =
7060 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7062 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7063 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7064 flow_ctrl, "flow_ctrl");
7065 cmdline_parse_token_string_t cmd_lfc_set_rx =
7066 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7068 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7069 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7070 rx_lfc_mode, "on#off");
7071 cmdline_parse_token_string_t cmd_lfc_set_tx =
7072 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7074 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7075 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7076 tx_lfc_mode, "on#off");
7077 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7078 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7079 hw_str, "high_water");
7080 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7081 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7082 high_water, RTE_UINT32);
7083 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7084 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7085 lw_str, "low_water");
7086 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7087 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7088 low_water, RTE_UINT32);
7089 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7090 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7091 pt_str, "pause_time");
7092 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7093 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7094 pause_time, RTE_UINT16);
7095 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7096 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7097 xon_str, "send_xon");
7098 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7099 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7100 send_xon, RTE_UINT16);
7101 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7102 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7103 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7104 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7105 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7106 mac_ctrl_frame_fwd_mode, "on#off");
7107 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7108 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7109 autoneg_str, "autoneg");
7110 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7111 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7113 cmdline_parse_token_num_t cmd_lfc_set_portid =
7114 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7115 port_id, RTE_UINT16);
7117 /* forward declaration */
7119 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7122 cmdline_parse_inst_t cmd_link_flow_control_set = {
7123 .f = cmd_link_flow_ctrl_set_parsed,
7125 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7126 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7127 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7129 (void *)&cmd_lfc_set_set,
7130 (void *)&cmd_lfc_set_flow_ctrl,
7131 (void *)&cmd_lfc_set_rx,
7132 (void *)&cmd_lfc_set_rx_mode,
7133 (void *)&cmd_lfc_set_tx,
7134 (void *)&cmd_lfc_set_tx_mode,
7135 (void *)&cmd_lfc_set_high_water,
7136 (void *)&cmd_lfc_set_low_water,
7137 (void *)&cmd_lfc_set_pause_time,
7138 (void *)&cmd_lfc_set_send_xon,
7139 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7140 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7141 (void *)&cmd_lfc_set_autoneg_str,
7142 (void *)&cmd_lfc_set_autoneg,
7143 (void *)&cmd_lfc_set_portid,
7148 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7149 .f = cmd_link_flow_ctrl_set_parsed,
7150 .data = (void *)&cmd_link_flow_control_set_rx,
7151 .help_str = "set flow_ctrl rx on|off <port_id>: "
7152 "Change rx flow control parameter",
7154 (void *)&cmd_lfc_set_set,
7155 (void *)&cmd_lfc_set_flow_ctrl,
7156 (void *)&cmd_lfc_set_rx,
7157 (void *)&cmd_lfc_set_rx_mode,
7158 (void *)&cmd_lfc_set_portid,
7163 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7164 .f = cmd_link_flow_ctrl_set_parsed,
7165 .data = (void *)&cmd_link_flow_control_set_tx,
7166 .help_str = "set flow_ctrl tx on|off <port_id>: "
7167 "Change tx flow control parameter",
7169 (void *)&cmd_lfc_set_set,
7170 (void *)&cmd_lfc_set_flow_ctrl,
7171 (void *)&cmd_lfc_set_tx,
7172 (void *)&cmd_lfc_set_tx_mode,
7173 (void *)&cmd_lfc_set_portid,
7178 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7179 .f = cmd_link_flow_ctrl_set_parsed,
7180 .data = (void *)&cmd_link_flow_control_set_hw,
7181 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7182 "Change high water flow control parameter",
7184 (void *)&cmd_lfc_set_set,
7185 (void *)&cmd_lfc_set_flow_ctrl,
7186 (void *)&cmd_lfc_set_high_water_str,
7187 (void *)&cmd_lfc_set_high_water,
7188 (void *)&cmd_lfc_set_portid,
7193 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7194 .f = cmd_link_flow_ctrl_set_parsed,
7195 .data = (void *)&cmd_link_flow_control_set_lw,
7196 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7197 "Change low water flow control parameter",
7199 (void *)&cmd_lfc_set_set,
7200 (void *)&cmd_lfc_set_flow_ctrl,
7201 (void *)&cmd_lfc_set_low_water_str,
7202 (void *)&cmd_lfc_set_low_water,
7203 (void *)&cmd_lfc_set_portid,
7208 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7209 .f = cmd_link_flow_ctrl_set_parsed,
7210 .data = (void *)&cmd_link_flow_control_set_pt,
7211 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7212 "Change pause time flow control parameter",
7214 (void *)&cmd_lfc_set_set,
7215 (void *)&cmd_lfc_set_flow_ctrl,
7216 (void *)&cmd_lfc_set_pause_time_str,
7217 (void *)&cmd_lfc_set_pause_time,
7218 (void *)&cmd_lfc_set_portid,
7223 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7224 .f = cmd_link_flow_ctrl_set_parsed,
7225 .data = (void *)&cmd_link_flow_control_set_xon,
7226 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7227 "Change send_xon flow control parameter",
7229 (void *)&cmd_lfc_set_set,
7230 (void *)&cmd_lfc_set_flow_ctrl,
7231 (void *)&cmd_lfc_set_send_xon_str,
7232 (void *)&cmd_lfc_set_send_xon,
7233 (void *)&cmd_lfc_set_portid,
7238 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7239 .f = cmd_link_flow_ctrl_set_parsed,
7240 .data = (void *)&cmd_link_flow_control_set_macfwd,
7241 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7242 "Change mac ctrl fwd flow control parameter",
7244 (void *)&cmd_lfc_set_set,
7245 (void *)&cmd_lfc_set_flow_ctrl,
7246 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7247 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7248 (void *)&cmd_lfc_set_portid,
7253 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7254 .f = cmd_link_flow_ctrl_set_parsed,
7255 .data = (void *)&cmd_link_flow_control_set_autoneg,
7256 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7257 "Change autoneg flow control parameter",
7259 (void *)&cmd_lfc_set_set,
7260 (void *)&cmd_lfc_set_flow_ctrl,
7261 (void *)&cmd_lfc_set_autoneg_str,
7262 (void *)&cmd_lfc_set_autoneg,
7263 (void *)&cmd_lfc_set_portid,
7269 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7270 __rte_unused struct cmdline *cl,
7273 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7274 cmdline_parse_inst_t *cmd = data;
7275 struct rte_eth_fc_conf fc_conf;
7281 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7282 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7283 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7284 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7286 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7287 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7290 /* Partial command line, retrieve current configuration */
7292 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7294 printf("cannot get current flow ctrl parameters, return"
7295 "code = %d\n", ret);
7299 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7300 (fc_conf.mode == RTE_FC_FULL))
7302 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7303 (fc_conf.mode == RTE_FC_FULL))
7307 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7308 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7310 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7311 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7313 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7315 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7316 fc_conf.high_water = res->high_water;
7318 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7319 fc_conf.low_water = res->low_water;
7321 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7322 fc_conf.pause_time = res->pause_time;
7324 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7325 fc_conf.send_xon = res->send_xon;
7327 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7328 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7329 fc_conf.mac_ctrl_frame_fwd = 1;
7331 fc_conf.mac_ctrl_frame_fwd = 0;
7334 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7335 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7337 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7339 printf("bad flow contrl parameter, return code = %d \n", ret);
7342 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7343 struct cmd_priority_flow_ctrl_set_result {
7344 cmdline_fixed_string_t set;
7345 cmdline_fixed_string_t pfc_ctrl;
7346 cmdline_fixed_string_t rx;
7347 cmdline_fixed_string_t rx_pfc_mode;
7348 cmdline_fixed_string_t tx;
7349 cmdline_fixed_string_t tx_pfc_mode;
7350 uint32_t high_water;
7352 uint16_t pause_time;
7358 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7359 __rte_unused struct cmdline *cl,
7360 __rte_unused void *data)
7362 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7363 struct rte_eth_pfc_conf pfc_conf;
7364 int rx_fc_enable, tx_fc_enable;
7368 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7369 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7370 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7371 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7373 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7374 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7377 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7378 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7379 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7380 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7381 pfc_conf.fc.high_water = res->high_water;
7382 pfc_conf.fc.low_water = res->low_water;
7383 pfc_conf.fc.pause_time = res->pause_time;
7384 pfc_conf.priority = res->priority;
7386 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7388 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7391 cmdline_parse_token_string_t cmd_pfc_set_set =
7392 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7394 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7395 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7396 pfc_ctrl, "pfc_ctrl");
7397 cmdline_parse_token_string_t cmd_pfc_set_rx =
7398 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7400 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7401 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7402 rx_pfc_mode, "on#off");
7403 cmdline_parse_token_string_t cmd_pfc_set_tx =
7404 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7406 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7407 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7408 tx_pfc_mode, "on#off");
7409 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7410 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7411 high_water, RTE_UINT32);
7412 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7413 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7414 low_water, RTE_UINT32);
7415 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7416 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7417 pause_time, RTE_UINT16);
7418 cmdline_parse_token_num_t cmd_pfc_set_priority =
7419 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7420 priority, RTE_UINT8);
7421 cmdline_parse_token_num_t cmd_pfc_set_portid =
7422 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7423 port_id, RTE_UINT16);
7425 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7426 .f = cmd_priority_flow_ctrl_set_parsed,
7428 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7429 "<pause_time> <priority> <port_id>: "
7430 "Configure the Ethernet priority flow control",
7432 (void *)&cmd_pfc_set_set,
7433 (void *)&cmd_pfc_set_flow_ctrl,
7434 (void *)&cmd_pfc_set_rx,
7435 (void *)&cmd_pfc_set_rx_mode,
7436 (void *)&cmd_pfc_set_tx,
7437 (void *)&cmd_pfc_set_tx_mode,
7438 (void *)&cmd_pfc_set_high_water,
7439 (void *)&cmd_pfc_set_low_water,
7440 (void *)&cmd_pfc_set_pause_time,
7441 (void *)&cmd_pfc_set_priority,
7442 (void *)&cmd_pfc_set_portid,
7447 /* *** RESET CONFIGURATION *** */
7448 struct cmd_reset_result {
7449 cmdline_fixed_string_t reset;
7450 cmdline_fixed_string_t def;
7453 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7455 __rte_unused void *data)
7457 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7458 set_def_fwd_config();
7461 cmdline_parse_token_string_t cmd_reset_set =
7462 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7463 cmdline_parse_token_string_t cmd_reset_def =
7464 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7467 cmdline_parse_inst_t cmd_reset = {
7468 .f = cmd_reset_parsed,
7470 .help_str = "set default: Reset default forwarding configuration",
7472 (void *)&cmd_reset_set,
7473 (void *)&cmd_reset_def,
7478 /* *** START FORWARDING *** */
7479 struct cmd_start_result {
7480 cmdline_fixed_string_t start;
7483 cmdline_parse_token_string_t cmd_start_start =
7484 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7486 static void cmd_start_parsed(__rte_unused void *parsed_result,
7487 __rte_unused struct cmdline *cl,
7488 __rte_unused void *data)
7490 start_packet_forwarding(0);
7493 cmdline_parse_inst_t cmd_start = {
7494 .f = cmd_start_parsed,
7496 .help_str = "start: Start packet forwarding",
7498 (void *)&cmd_start_start,
7503 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7504 struct cmd_start_tx_first_result {
7505 cmdline_fixed_string_t start;
7506 cmdline_fixed_string_t tx_first;
7510 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7511 __rte_unused struct cmdline *cl,
7512 __rte_unused void *data)
7514 start_packet_forwarding(1);
7517 cmdline_parse_token_string_t cmd_start_tx_first_start =
7518 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7520 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7521 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7522 tx_first, "tx_first");
7524 cmdline_parse_inst_t cmd_start_tx_first = {
7525 .f = cmd_start_tx_first_parsed,
7527 .help_str = "start tx_first: Start packet forwarding, "
7528 "after sending 1 burst of packets",
7530 (void *)&cmd_start_tx_first_start,
7531 (void *)&cmd_start_tx_first_tx_first,
7536 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7537 struct cmd_start_tx_first_n_result {
7538 cmdline_fixed_string_t start;
7539 cmdline_fixed_string_t tx_first;
7544 cmd_start_tx_first_n_parsed(void *parsed_result,
7545 __rte_unused struct cmdline *cl,
7546 __rte_unused void *data)
7548 struct cmd_start_tx_first_n_result *res = parsed_result;
7550 start_packet_forwarding(res->tx_num);
7553 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7554 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7556 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7557 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7558 tx_first, "tx_first");
7559 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7560 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7561 tx_num, RTE_UINT32);
7563 cmdline_parse_inst_t cmd_start_tx_first_n = {
7564 .f = cmd_start_tx_first_n_parsed,
7566 .help_str = "start tx_first <num>: "
7567 "packet forwarding, after sending <num> bursts of packets",
7569 (void *)&cmd_start_tx_first_n_start,
7570 (void *)&cmd_start_tx_first_n_tx_first,
7571 (void *)&cmd_start_tx_first_n_tx_num,
7576 /* *** SET LINK UP *** */
7577 struct cmd_set_link_up_result {
7578 cmdline_fixed_string_t set;
7579 cmdline_fixed_string_t link_up;
7580 cmdline_fixed_string_t port;
7584 cmdline_parse_token_string_t cmd_set_link_up_set =
7585 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7586 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7587 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7589 cmdline_parse_token_string_t cmd_set_link_up_port =
7590 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7591 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7592 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7595 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7596 __rte_unused struct cmdline *cl,
7597 __rte_unused void *data)
7599 struct cmd_set_link_up_result *res = parsed_result;
7600 dev_set_link_up(res->port_id);
7603 cmdline_parse_inst_t cmd_set_link_up = {
7604 .f = cmd_set_link_up_parsed,
7606 .help_str = "set link-up port <port id>",
7608 (void *)&cmd_set_link_up_set,
7609 (void *)&cmd_set_link_up_link_up,
7610 (void *)&cmd_set_link_up_port,
7611 (void *)&cmd_set_link_up_port_id,
7616 /* *** SET LINK DOWN *** */
7617 struct cmd_set_link_down_result {
7618 cmdline_fixed_string_t set;
7619 cmdline_fixed_string_t link_down;
7620 cmdline_fixed_string_t port;
7624 cmdline_parse_token_string_t cmd_set_link_down_set =
7625 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7626 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7627 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7629 cmdline_parse_token_string_t cmd_set_link_down_port =
7630 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7631 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7632 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7635 static void cmd_set_link_down_parsed(
7636 __rte_unused void *parsed_result,
7637 __rte_unused struct cmdline *cl,
7638 __rte_unused void *data)
7640 struct cmd_set_link_down_result *res = parsed_result;
7641 dev_set_link_down(res->port_id);
7644 cmdline_parse_inst_t cmd_set_link_down = {
7645 .f = cmd_set_link_down_parsed,
7647 .help_str = "set link-down port <port id>",
7649 (void *)&cmd_set_link_down_set,
7650 (void *)&cmd_set_link_down_link_down,
7651 (void *)&cmd_set_link_down_port,
7652 (void *)&cmd_set_link_down_port_id,
7657 /* *** SHOW CFG *** */
7658 struct cmd_showcfg_result {
7659 cmdline_fixed_string_t show;
7660 cmdline_fixed_string_t cfg;
7661 cmdline_fixed_string_t what;
7664 static void cmd_showcfg_parsed(void *parsed_result,
7665 __rte_unused struct cmdline *cl,
7666 __rte_unused void *data)
7668 struct cmd_showcfg_result *res = parsed_result;
7669 if (!strcmp(res->what, "rxtx"))
7670 rxtx_config_display();
7671 else if (!strcmp(res->what, "cores"))
7672 fwd_lcores_config_display();
7673 else if (!strcmp(res->what, "fwd"))
7674 pkt_fwd_config_display(&cur_fwd_config);
7675 else if (!strcmp(res->what, "rxoffs"))
7676 show_rx_pkt_offsets();
7677 else if (!strcmp(res->what, "rxpkts"))
7678 show_rx_pkt_segments();
7679 else if (!strcmp(res->what, "txpkts"))
7680 show_tx_pkt_segments();
7681 else if (!strcmp(res->what, "txtimes"))
7682 show_tx_pkt_times();
7685 cmdline_parse_token_string_t cmd_showcfg_show =
7686 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7687 cmdline_parse_token_string_t cmd_showcfg_port =
7688 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7689 cmdline_parse_token_string_t cmd_showcfg_what =
7690 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7691 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7693 cmdline_parse_inst_t cmd_showcfg = {
7694 .f = cmd_showcfg_parsed,
7696 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7698 (void *)&cmd_showcfg_show,
7699 (void *)&cmd_showcfg_port,
7700 (void *)&cmd_showcfg_what,
7705 /* *** SHOW ALL PORT INFO *** */
7706 struct cmd_showportall_result {
7707 cmdline_fixed_string_t show;
7708 cmdline_fixed_string_t port;
7709 cmdline_fixed_string_t what;
7710 cmdline_fixed_string_t all;
7713 static void cmd_showportall_parsed(void *parsed_result,
7714 __rte_unused struct cmdline *cl,
7715 __rte_unused void *data)
7719 struct cmd_showportall_result *res = parsed_result;
7720 if (!strcmp(res->show, "clear")) {
7721 if (!strcmp(res->what, "stats"))
7722 RTE_ETH_FOREACH_DEV(i)
7724 else if (!strcmp(res->what, "xstats"))
7725 RTE_ETH_FOREACH_DEV(i)
7726 nic_xstats_clear(i);
7727 } else if (!strcmp(res->what, "info"))
7728 RTE_ETH_FOREACH_DEV(i)
7729 port_infos_display(i);
7730 else if (!strcmp(res->what, "summary")) {
7731 port_summary_header_display();
7732 RTE_ETH_FOREACH_DEV(i)
7733 port_summary_display(i);
7735 else if (!strcmp(res->what, "stats"))
7736 RTE_ETH_FOREACH_DEV(i)
7737 nic_stats_display(i);
7738 else if (!strcmp(res->what, "xstats"))
7739 RTE_ETH_FOREACH_DEV(i)
7740 nic_xstats_display(i);
7741 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7742 else if (!strcmp(res->what, "fdir"))
7743 RTE_ETH_FOREACH_DEV(i)
7746 else if (!strcmp(res->what, "dcb_tc"))
7747 RTE_ETH_FOREACH_DEV(i)
7748 port_dcb_info_display(i);
7751 cmdline_parse_token_string_t cmd_showportall_show =
7752 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7754 cmdline_parse_token_string_t cmd_showportall_port =
7755 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7756 cmdline_parse_token_string_t cmd_showportall_what =
7757 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7758 "info#summary#stats#xstats#fdir#dcb_tc");
7759 cmdline_parse_token_string_t cmd_showportall_all =
7760 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7761 cmdline_parse_inst_t cmd_showportall = {
7762 .f = cmd_showportall_parsed,
7764 .help_str = "show|clear port "
7765 "info|summary|stats|xstats|fdir|dcb_tc all",
7767 (void *)&cmd_showportall_show,
7768 (void *)&cmd_showportall_port,
7769 (void *)&cmd_showportall_what,
7770 (void *)&cmd_showportall_all,
7775 /* *** SHOW PORT INFO *** */
7776 struct cmd_showport_result {
7777 cmdline_fixed_string_t show;
7778 cmdline_fixed_string_t port;
7779 cmdline_fixed_string_t what;
7783 static void cmd_showport_parsed(void *parsed_result,
7784 __rte_unused struct cmdline *cl,
7785 __rte_unused void *data)
7787 struct cmd_showport_result *res = parsed_result;
7788 if (!strcmp(res->show, "clear")) {
7789 if (!strcmp(res->what, "stats"))
7790 nic_stats_clear(res->portnum);
7791 else if (!strcmp(res->what, "xstats"))
7792 nic_xstats_clear(res->portnum);
7793 } else if (!strcmp(res->what, "info"))
7794 port_infos_display(res->portnum);
7795 else if (!strcmp(res->what, "summary")) {
7796 port_summary_header_display();
7797 port_summary_display(res->portnum);
7799 else if (!strcmp(res->what, "stats"))
7800 nic_stats_display(res->portnum);
7801 else if (!strcmp(res->what, "xstats"))
7802 nic_xstats_display(res->portnum);
7803 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7804 else if (!strcmp(res->what, "fdir"))
7805 fdir_get_infos(res->portnum);
7807 else if (!strcmp(res->what, "dcb_tc"))
7808 port_dcb_info_display(res->portnum);
7811 cmdline_parse_token_string_t cmd_showport_show =
7812 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7814 cmdline_parse_token_string_t cmd_showport_port =
7815 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7816 cmdline_parse_token_string_t cmd_showport_what =
7817 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7818 "info#summary#stats#xstats#fdir#dcb_tc");
7819 cmdline_parse_token_num_t cmd_showport_portnum =
7820 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7822 cmdline_parse_inst_t cmd_showport = {
7823 .f = cmd_showport_parsed,
7825 .help_str = "show|clear port "
7826 "info|summary|stats|xstats|fdir|dcb_tc "
7829 (void *)&cmd_showport_show,
7830 (void *)&cmd_showport_port,
7831 (void *)&cmd_showport_what,
7832 (void *)&cmd_showport_portnum,
7837 /* *** SHOW DEVICE INFO *** */
7838 struct cmd_showdevice_result {
7839 cmdline_fixed_string_t show;
7840 cmdline_fixed_string_t device;
7841 cmdline_fixed_string_t what;
7842 cmdline_fixed_string_t identifier;
7845 static void cmd_showdevice_parsed(void *parsed_result,
7846 __rte_unused struct cmdline *cl,
7847 __rte_unused void *data)
7849 struct cmd_showdevice_result *res = parsed_result;
7850 if (!strcmp(res->what, "info")) {
7851 if (!strcmp(res->identifier, "all"))
7852 device_infos_display(NULL);
7854 device_infos_display(res->identifier);
7858 cmdline_parse_token_string_t cmd_showdevice_show =
7859 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7861 cmdline_parse_token_string_t cmd_showdevice_device =
7862 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7863 cmdline_parse_token_string_t cmd_showdevice_what =
7864 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7866 cmdline_parse_token_string_t cmd_showdevice_identifier =
7867 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7870 cmdline_parse_inst_t cmd_showdevice = {
7871 .f = cmd_showdevice_parsed,
7873 .help_str = "show device info <identifier>|all",
7875 (void *)&cmd_showdevice_show,
7876 (void *)&cmd_showdevice_device,
7877 (void *)&cmd_showdevice_what,
7878 (void *)&cmd_showdevice_identifier,
7883 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7884 struct cmd_showeeprom_result {
7885 cmdline_fixed_string_t show;
7886 cmdline_fixed_string_t port;
7888 cmdline_fixed_string_t type;
7891 static void cmd_showeeprom_parsed(void *parsed_result,
7892 __rte_unused struct cmdline *cl,
7893 __rte_unused void *data)
7895 struct cmd_showeeprom_result *res = parsed_result;
7897 if (!strcmp(res->type, "eeprom"))
7898 port_eeprom_display(res->portnum);
7899 else if (!strcmp(res->type, "module_eeprom"))
7900 port_module_eeprom_display(res->portnum);
7902 printf("Unknown argument\n");
7905 cmdline_parse_token_string_t cmd_showeeprom_show =
7906 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7907 cmdline_parse_token_string_t cmd_showeeprom_port =
7908 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7909 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7910 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7912 cmdline_parse_token_string_t cmd_showeeprom_type =
7913 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7915 cmdline_parse_inst_t cmd_showeeprom = {
7916 .f = cmd_showeeprom_parsed,
7918 .help_str = "show port <port_id> module_eeprom|eeprom",
7920 (void *)&cmd_showeeprom_show,
7921 (void *)&cmd_showeeprom_port,
7922 (void *)&cmd_showeeprom_portnum,
7923 (void *)&cmd_showeeprom_type,
7928 /* *** SHOW QUEUE INFO *** */
7929 struct cmd_showqueue_result {
7930 cmdline_fixed_string_t show;
7931 cmdline_fixed_string_t type;
7932 cmdline_fixed_string_t what;
7938 cmd_showqueue_parsed(void *parsed_result,
7939 __rte_unused struct cmdline *cl,
7940 __rte_unused void *data)
7942 struct cmd_showqueue_result *res = parsed_result;
7944 if (!strcmp(res->type, "rxq"))
7945 rx_queue_infos_display(res->portnum, res->queuenum);
7946 else if (!strcmp(res->type, "txq"))
7947 tx_queue_infos_display(res->portnum, res->queuenum);
7950 cmdline_parse_token_string_t cmd_showqueue_show =
7951 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7952 cmdline_parse_token_string_t cmd_showqueue_type =
7953 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7954 cmdline_parse_token_string_t cmd_showqueue_what =
7955 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7956 cmdline_parse_token_num_t cmd_showqueue_portnum =
7957 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7959 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7960 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7963 cmdline_parse_inst_t cmd_showqueue = {
7964 .f = cmd_showqueue_parsed,
7966 .help_str = "show rxq|txq info <port_id> <queue_id>",
7968 (void *)&cmd_showqueue_show,
7969 (void *)&cmd_showqueue_type,
7970 (void *)&cmd_showqueue_what,
7971 (void *)&cmd_showqueue_portnum,
7972 (void *)&cmd_showqueue_queuenum,
7977 /* show/clear fwd engine statistics */
7979 cmdline_fixed_string_t action;
7980 cmdline_fixed_string_t fwd;
7981 cmdline_fixed_string_t stats;
7982 cmdline_fixed_string_t all;
7985 cmdline_parse_token_string_t cmd_fwd_action =
7986 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7987 cmdline_parse_token_string_t cmd_fwd_fwd =
7988 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7989 cmdline_parse_token_string_t cmd_fwd_stats =
7990 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7991 cmdline_parse_token_string_t cmd_fwd_all =
7992 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7995 cmd_showfwdall_parsed(void *parsed_result,
7996 __rte_unused struct cmdline *cl,
7997 __rte_unused void *data)
7999 struct fwd_result *res = parsed_result;
8001 if (!strcmp(res->action, "show"))
8002 fwd_stats_display();
8007 static cmdline_parse_inst_t cmd_showfwdall = {
8008 .f = cmd_showfwdall_parsed,
8010 .help_str = "show|clear fwd stats all",
8012 (void *)&cmd_fwd_action,
8013 (void *)&cmd_fwd_fwd,
8014 (void *)&cmd_fwd_stats,
8015 (void *)&cmd_fwd_all,
8020 /* *** READ PORT REGISTER *** */
8021 struct cmd_read_reg_result {
8022 cmdline_fixed_string_t read;
8023 cmdline_fixed_string_t reg;
8029 cmd_read_reg_parsed(void *parsed_result,
8030 __rte_unused struct cmdline *cl,
8031 __rte_unused void *data)
8033 struct cmd_read_reg_result *res = parsed_result;
8034 port_reg_display(res->port_id, res->reg_off);
8037 cmdline_parse_token_string_t cmd_read_reg_read =
8038 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8039 cmdline_parse_token_string_t cmd_read_reg_reg =
8040 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8041 cmdline_parse_token_num_t cmd_read_reg_port_id =
8042 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8043 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8044 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8046 cmdline_parse_inst_t cmd_read_reg = {
8047 .f = cmd_read_reg_parsed,
8049 .help_str = "read reg <port_id> <reg_off>",
8051 (void *)&cmd_read_reg_read,
8052 (void *)&cmd_read_reg_reg,
8053 (void *)&cmd_read_reg_port_id,
8054 (void *)&cmd_read_reg_reg_off,
8059 /* *** READ PORT REGISTER BIT FIELD *** */
8060 struct cmd_read_reg_bit_field_result {
8061 cmdline_fixed_string_t read;
8062 cmdline_fixed_string_t regfield;
8070 cmd_read_reg_bit_field_parsed(void *parsed_result,
8071 __rte_unused struct cmdline *cl,
8072 __rte_unused void *data)
8074 struct cmd_read_reg_bit_field_result *res = parsed_result;
8075 port_reg_bit_field_display(res->port_id, res->reg_off,
8076 res->bit1_pos, res->bit2_pos);
8079 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8080 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8082 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8083 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8084 regfield, "regfield");
8085 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8086 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8088 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8089 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8091 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8092 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8094 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8095 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8098 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8099 .f = cmd_read_reg_bit_field_parsed,
8101 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8102 "Read register bit field between bit_x and bit_y included",
8104 (void *)&cmd_read_reg_bit_field_read,
8105 (void *)&cmd_read_reg_bit_field_regfield,
8106 (void *)&cmd_read_reg_bit_field_port_id,
8107 (void *)&cmd_read_reg_bit_field_reg_off,
8108 (void *)&cmd_read_reg_bit_field_bit1_pos,
8109 (void *)&cmd_read_reg_bit_field_bit2_pos,
8114 /* *** READ PORT REGISTER BIT *** */
8115 struct cmd_read_reg_bit_result {
8116 cmdline_fixed_string_t read;
8117 cmdline_fixed_string_t regbit;
8124 cmd_read_reg_bit_parsed(void *parsed_result,
8125 __rte_unused struct cmdline *cl,
8126 __rte_unused void *data)
8128 struct cmd_read_reg_bit_result *res = parsed_result;
8129 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8132 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8133 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8134 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8135 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8137 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8138 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8140 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8141 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8143 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8144 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8147 cmdline_parse_inst_t cmd_read_reg_bit = {
8148 .f = cmd_read_reg_bit_parsed,
8150 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8152 (void *)&cmd_read_reg_bit_read,
8153 (void *)&cmd_read_reg_bit_regbit,
8154 (void *)&cmd_read_reg_bit_port_id,
8155 (void *)&cmd_read_reg_bit_reg_off,
8156 (void *)&cmd_read_reg_bit_bit_pos,
8161 /* *** WRITE PORT REGISTER *** */
8162 struct cmd_write_reg_result {
8163 cmdline_fixed_string_t write;
8164 cmdline_fixed_string_t reg;
8171 cmd_write_reg_parsed(void *parsed_result,
8172 __rte_unused struct cmdline *cl,
8173 __rte_unused void *data)
8175 struct cmd_write_reg_result *res = parsed_result;
8176 port_reg_set(res->port_id, res->reg_off, res->value);
8179 cmdline_parse_token_string_t cmd_write_reg_write =
8180 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8181 cmdline_parse_token_string_t cmd_write_reg_reg =
8182 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8183 cmdline_parse_token_num_t cmd_write_reg_port_id =
8184 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8185 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8186 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8187 cmdline_parse_token_num_t cmd_write_reg_value =
8188 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8190 cmdline_parse_inst_t cmd_write_reg = {
8191 .f = cmd_write_reg_parsed,
8193 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8195 (void *)&cmd_write_reg_write,
8196 (void *)&cmd_write_reg_reg,
8197 (void *)&cmd_write_reg_port_id,
8198 (void *)&cmd_write_reg_reg_off,
8199 (void *)&cmd_write_reg_value,
8204 /* *** WRITE PORT REGISTER BIT FIELD *** */
8205 struct cmd_write_reg_bit_field_result {
8206 cmdline_fixed_string_t write;
8207 cmdline_fixed_string_t regfield;
8216 cmd_write_reg_bit_field_parsed(void *parsed_result,
8217 __rte_unused struct cmdline *cl,
8218 __rte_unused void *data)
8220 struct cmd_write_reg_bit_field_result *res = parsed_result;
8221 port_reg_bit_field_set(res->port_id, res->reg_off,
8222 res->bit1_pos, res->bit2_pos, res->value);
8225 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8226 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8228 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8229 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8230 regfield, "regfield");
8231 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8232 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8234 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8235 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8237 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8238 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8240 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8241 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8243 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8244 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8247 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8248 .f = cmd_write_reg_bit_field_parsed,
8250 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8252 "Set register bit field between bit_x and bit_y included",
8254 (void *)&cmd_write_reg_bit_field_write,
8255 (void *)&cmd_write_reg_bit_field_regfield,
8256 (void *)&cmd_write_reg_bit_field_port_id,
8257 (void *)&cmd_write_reg_bit_field_reg_off,
8258 (void *)&cmd_write_reg_bit_field_bit1_pos,
8259 (void *)&cmd_write_reg_bit_field_bit2_pos,
8260 (void *)&cmd_write_reg_bit_field_value,
8265 /* *** WRITE PORT REGISTER BIT *** */
8266 struct cmd_write_reg_bit_result {
8267 cmdline_fixed_string_t write;
8268 cmdline_fixed_string_t regbit;
8276 cmd_write_reg_bit_parsed(void *parsed_result,
8277 __rte_unused struct cmdline *cl,
8278 __rte_unused void *data)
8280 struct cmd_write_reg_bit_result *res = parsed_result;
8281 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8284 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8285 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8287 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8288 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8290 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8291 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8293 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8294 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8296 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8297 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8299 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8300 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8303 cmdline_parse_inst_t cmd_write_reg_bit = {
8304 .f = cmd_write_reg_bit_parsed,
8306 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8309 (void *)&cmd_write_reg_bit_write,
8310 (void *)&cmd_write_reg_bit_regbit,
8311 (void *)&cmd_write_reg_bit_port_id,
8312 (void *)&cmd_write_reg_bit_reg_off,
8313 (void *)&cmd_write_reg_bit_bit_pos,
8314 (void *)&cmd_write_reg_bit_value,
8319 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8320 struct cmd_read_rxd_txd_result {
8321 cmdline_fixed_string_t read;
8322 cmdline_fixed_string_t rxd_txd;
8329 cmd_read_rxd_txd_parsed(void *parsed_result,
8330 __rte_unused struct cmdline *cl,
8331 __rte_unused void *data)
8333 struct cmd_read_rxd_txd_result *res = parsed_result;
8335 if (!strcmp(res->rxd_txd, "rxd"))
8336 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8337 else if (!strcmp(res->rxd_txd, "txd"))
8338 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8341 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8342 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8343 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8344 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8346 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8347 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8349 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8350 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8352 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8353 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8356 cmdline_parse_inst_t cmd_read_rxd_txd = {
8357 .f = cmd_read_rxd_txd_parsed,
8359 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8361 (void *)&cmd_read_rxd_txd_read,
8362 (void *)&cmd_read_rxd_txd_rxd_txd,
8363 (void *)&cmd_read_rxd_txd_port_id,
8364 (void *)&cmd_read_rxd_txd_queue_id,
8365 (void *)&cmd_read_rxd_txd_desc_id,
8371 struct cmd_quit_result {
8372 cmdline_fixed_string_t quit;
8375 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8377 __rte_unused void *data)
8382 cmdline_parse_token_string_t cmd_quit_quit =
8383 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8385 cmdline_parse_inst_t cmd_quit = {
8386 .f = cmd_quit_parsed,
8388 .help_str = "quit: Exit application",
8390 (void *)&cmd_quit_quit,
8395 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8396 struct cmd_mac_addr_result {
8397 cmdline_fixed_string_t mac_addr_cmd;
8398 cmdline_fixed_string_t what;
8400 struct rte_ether_addr address;
8403 static void cmd_mac_addr_parsed(void *parsed_result,
8404 __rte_unused struct cmdline *cl,
8405 __rte_unused void *data)
8407 struct cmd_mac_addr_result *res = parsed_result;
8410 if (strcmp(res->what, "add") == 0)
8411 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8412 else if (strcmp(res->what, "set") == 0)
8413 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8416 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8418 /* check the return value and print it if is < 0 */
8420 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8424 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8425 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8427 cmdline_parse_token_string_t cmd_mac_addr_what =
8428 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8430 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8431 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8433 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8434 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8436 cmdline_parse_inst_t cmd_mac_addr = {
8437 .f = cmd_mac_addr_parsed,
8439 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8440 "Add/Remove/Set MAC address on port_id",
8442 (void *)&cmd_mac_addr_cmd,
8443 (void *)&cmd_mac_addr_what,
8444 (void *)&cmd_mac_addr_portnum,
8445 (void *)&cmd_mac_addr_addr,
8450 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8451 struct cmd_eth_peer_result {
8452 cmdline_fixed_string_t set;
8453 cmdline_fixed_string_t eth_peer;
8455 cmdline_fixed_string_t peer_addr;
8458 static void cmd_set_eth_peer_parsed(void *parsed_result,
8459 __rte_unused struct cmdline *cl,
8460 __rte_unused void *data)
8462 struct cmd_eth_peer_result *res = parsed_result;
8464 if (test_done == 0) {
8465 printf("Please stop forwarding first\n");
8468 if (!strcmp(res->eth_peer, "eth-peer")) {
8469 set_fwd_eth_peer(res->port_id, res->peer_addr);
8473 cmdline_parse_token_string_t cmd_eth_peer_set =
8474 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8475 cmdline_parse_token_string_t cmd_eth_peer =
8476 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8477 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8478 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8480 cmdline_parse_token_string_t cmd_eth_peer_addr =
8481 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8483 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8484 .f = cmd_set_eth_peer_parsed,
8486 .help_str = "set eth-peer <port_id> <peer_mac>",
8488 (void *)&cmd_eth_peer_set,
8489 (void *)&cmd_eth_peer,
8490 (void *)&cmd_eth_peer_port_id,
8491 (void *)&cmd_eth_peer_addr,
8496 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8497 struct cmd_set_qmap_result {
8498 cmdline_fixed_string_t set;
8499 cmdline_fixed_string_t qmap;
8500 cmdline_fixed_string_t what;
8507 cmd_set_qmap_parsed(void *parsed_result,
8508 __rte_unused struct cmdline *cl,
8509 __rte_unused void *data)
8511 struct cmd_set_qmap_result *res = parsed_result;
8512 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8514 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8517 cmdline_parse_token_string_t cmd_setqmap_set =
8518 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8520 cmdline_parse_token_string_t cmd_setqmap_qmap =
8521 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8523 cmdline_parse_token_string_t cmd_setqmap_what =
8524 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8526 cmdline_parse_token_num_t cmd_setqmap_portid =
8527 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8528 port_id, RTE_UINT16);
8529 cmdline_parse_token_num_t cmd_setqmap_queueid =
8530 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8531 queue_id, RTE_UINT16);
8532 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8533 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8534 map_value, RTE_UINT8);
8536 cmdline_parse_inst_t cmd_set_qmap = {
8537 .f = cmd_set_qmap_parsed,
8539 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8540 "Set statistics mapping value on tx|rx queue_id of port_id",
8542 (void *)&cmd_setqmap_set,
8543 (void *)&cmd_setqmap_qmap,
8544 (void *)&cmd_setqmap_what,
8545 (void *)&cmd_setqmap_portid,
8546 (void *)&cmd_setqmap_queueid,
8547 (void *)&cmd_setqmap_mapvalue,
8552 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8553 struct cmd_set_xstats_hide_zero_result {
8554 cmdline_fixed_string_t keyword;
8555 cmdline_fixed_string_t name;
8556 cmdline_fixed_string_t on_off;
8560 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8561 __rte_unused struct cmdline *cl,
8562 __rte_unused void *data)
8564 struct cmd_set_xstats_hide_zero_result *res;
8565 uint16_t on_off = 0;
8567 res = parsed_result;
8568 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8569 set_xstats_hide_zero(on_off);
8572 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8573 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8575 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8576 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8577 name, "xstats-hide-zero");
8578 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8579 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8582 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8583 .f = cmd_set_xstats_hide_zero_parsed,
8585 .help_str = "set xstats-hide-zero on|off",
8587 (void *)&cmd_set_xstats_hide_zero_keyword,
8588 (void *)&cmd_set_xstats_hide_zero_name,
8589 (void *)&cmd_set_xstats_hide_zero_on_off,
8594 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8595 struct cmd_set_record_core_cycles_result {
8596 cmdline_fixed_string_t keyword;
8597 cmdline_fixed_string_t name;
8598 cmdline_fixed_string_t on_off;
8602 cmd_set_record_core_cycles_parsed(void *parsed_result,
8603 __rte_unused struct cmdline *cl,
8604 __rte_unused void *data)
8606 struct cmd_set_record_core_cycles_result *res;
8607 uint16_t on_off = 0;
8609 res = parsed_result;
8610 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8611 set_record_core_cycles(on_off);
8614 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8615 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8617 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8618 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8619 name, "record-core-cycles");
8620 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8621 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8624 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8625 .f = cmd_set_record_core_cycles_parsed,
8627 .help_str = "set record-core-cycles on|off",
8629 (void *)&cmd_set_record_core_cycles_keyword,
8630 (void *)&cmd_set_record_core_cycles_name,
8631 (void *)&cmd_set_record_core_cycles_on_off,
8636 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8637 struct cmd_set_record_burst_stats_result {
8638 cmdline_fixed_string_t keyword;
8639 cmdline_fixed_string_t name;
8640 cmdline_fixed_string_t on_off;
8644 cmd_set_record_burst_stats_parsed(void *parsed_result,
8645 __rte_unused struct cmdline *cl,
8646 __rte_unused void *data)
8648 struct cmd_set_record_burst_stats_result *res;
8649 uint16_t on_off = 0;
8651 res = parsed_result;
8652 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8653 set_record_burst_stats(on_off);
8656 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8657 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8659 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8660 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8661 name, "record-burst-stats");
8662 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8663 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8666 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8667 .f = cmd_set_record_burst_stats_parsed,
8669 .help_str = "set record-burst-stats on|off",
8671 (void *)&cmd_set_record_burst_stats_keyword,
8672 (void *)&cmd_set_record_burst_stats_name,
8673 (void *)&cmd_set_record_burst_stats_on_off,
8678 /* *** CONFIGURE UNICAST HASH TABLE *** */
8679 struct cmd_set_uc_hash_table {
8680 cmdline_fixed_string_t set;
8681 cmdline_fixed_string_t port;
8683 cmdline_fixed_string_t what;
8684 struct rte_ether_addr address;
8685 cmdline_fixed_string_t mode;
8689 cmd_set_uc_hash_parsed(void *parsed_result,
8690 __rte_unused struct cmdline *cl,
8691 __rte_unused void *data)
8694 struct cmd_set_uc_hash_table *res = parsed_result;
8696 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8698 if (strcmp(res->what, "uta") == 0)
8699 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8700 &res->address,(uint8_t)is_on);
8702 printf("bad unicast hash table parameter, return code = %d \n", ret);
8706 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8707 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8709 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8710 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8712 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8713 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8714 port_id, RTE_UINT16);
8715 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8716 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8718 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8719 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8721 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8722 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8725 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8726 .f = cmd_set_uc_hash_parsed,
8728 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8730 (void *)&cmd_set_uc_hash_set,
8731 (void *)&cmd_set_uc_hash_port,
8732 (void *)&cmd_set_uc_hash_portid,
8733 (void *)&cmd_set_uc_hash_what,
8734 (void *)&cmd_set_uc_hash_mac,
8735 (void *)&cmd_set_uc_hash_mode,
8740 struct cmd_set_uc_all_hash_table {
8741 cmdline_fixed_string_t set;
8742 cmdline_fixed_string_t port;
8744 cmdline_fixed_string_t what;
8745 cmdline_fixed_string_t value;
8746 cmdline_fixed_string_t mode;
8750 cmd_set_uc_all_hash_parsed(void *parsed_result,
8751 __rte_unused struct cmdline *cl,
8752 __rte_unused void *data)
8755 struct cmd_set_uc_all_hash_table *res = parsed_result;
8757 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8759 if ((strcmp(res->what, "uta") == 0) &&
8760 (strcmp(res->value, "all") == 0))
8761 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8763 printf("bad unicast hash table parameter,"
8764 "return code = %d \n", ret);
8767 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8768 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8770 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8771 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8773 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8774 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8775 port_id, RTE_UINT16);
8776 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8777 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8779 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8780 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8782 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8783 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8786 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8787 .f = cmd_set_uc_all_hash_parsed,
8789 .help_str = "set port <port_id> uta all on|off",
8791 (void *)&cmd_set_uc_all_hash_set,
8792 (void *)&cmd_set_uc_all_hash_port,
8793 (void *)&cmd_set_uc_all_hash_portid,
8794 (void *)&cmd_set_uc_all_hash_what,
8795 (void *)&cmd_set_uc_all_hash_value,
8796 (void *)&cmd_set_uc_all_hash_mode,
8801 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8802 struct cmd_set_vf_traffic {
8803 cmdline_fixed_string_t set;
8804 cmdline_fixed_string_t port;
8806 cmdline_fixed_string_t vf;
8808 cmdline_fixed_string_t what;
8809 cmdline_fixed_string_t mode;
8813 cmd_set_vf_traffic_parsed(void *parsed_result,
8814 __rte_unused struct cmdline *cl,
8815 __rte_unused void *data)
8817 struct cmd_set_vf_traffic *res = parsed_result;
8818 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8819 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8821 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8824 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8825 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8827 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8828 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8830 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8831 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8832 port_id, RTE_UINT16);
8833 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8834 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8836 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8837 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8839 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8840 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8842 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8843 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8846 cmdline_parse_inst_t cmd_set_vf_traffic = {
8847 .f = cmd_set_vf_traffic_parsed,
8849 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8851 (void *)&cmd_setvf_traffic_set,
8852 (void *)&cmd_setvf_traffic_port,
8853 (void *)&cmd_setvf_traffic_portid,
8854 (void *)&cmd_setvf_traffic_vf,
8855 (void *)&cmd_setvf_traffic_vfid,
8856 (void *)&cmd_setvf_traffic_what,
8857 (void *)&cmd_setvf_traffic_mode,
8862 /* *** CONFIGURE VF RECEIVE MODE *** */
8863 struct cmd_set_vf_rxmode {
8864 cmdline_fixed_string_t set;
8865 cmdline_fixed_string_t port;
8867 cmdline_fixed_string_t vf;
8869 cmdline_fixed_string_t what;
8870 cmdline_fixed_string_t mode;
8871 cmdline_fixed_string_t on;
8875 cmd_set_vf_rxmode_parsed(void *parsed_result,
8876 __rte_unused struct cmdline *cl,
8877 __rte_unused void *data)
8880 uint16_t vf_rxmode = 0;
8881 struct cmd_set_vf_rxmode *res = parsed_result;
8883 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8884 if (!strcmp(res->what,"rxmode")) {
8885 if (!strcmp(res->mode, "AUPE"))
8886 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8887 else if (!strcmp(res->mode, "ROPE"))
8888 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8889 else if (!strcmp(res->mode, "BAM"))
8890 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8891 else if (!strncmp(res->mode, "MPE",3))
8892 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8895 RTE_SET_USED(is_on);
8897 #ifdef RTE_NET_IXGBE
8898 if (ret == -ENOTSUP)
8899 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8900 vf_rxmode, (uint8_t)is_on);
8903 if (ret == -ENOTSUP)
8904 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8905 vf_rxmode, (uint8_t)is_on);
8908 printf("bad VF receive mode parameter, return code = %d \n",
8912 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8913 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8915 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8916 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8918 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8919 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8920 port_id, RTE_UINT16);
8921 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8922 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8924 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8925 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8927 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8928 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8930 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8931 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8932 mode, "AUPE#ROPE#BAM#MPE");
8933 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8934 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8937 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8938 .f = cmd_set_vf_rxmode_parsed,
8940 .help_str = "set port <port_id> vf <vf_id> rxmode "
8941 "AUPE|ROPE|BAM|MPE on|off",
8943 (void *)&cmd_set_vf_rxmode_set,
8944 (void *)&cmd_set_vf_rxmode_port,
8945 (void *)&cmd_set_vf_rxmode_portid,
8946 (void *)&cmd_set_vf_rxmode_vf,
8947 (void *)&cmd_set_vf_rxmode_vfid,
8948 (void *)&cmd_set_vf_rxmode_what,
8949 (void *)&cmd_set_vf_rxmode_mode,
8950 (void *)&cmd_set_vf_rxmode_on,
8955 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8956 struct cmd_vf_mac_addr_result {
8957 cmdline_fixed_string_t mac_addr_cmd;
8958 cmdline_fixed_string_t what;
8959 cmdline_fixed_string_t port;
8961 cmdline_fixed_string_t vf;
8963 struct rte_ether_addr address;
8966 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8967 __rte_unused struct cmdline *cl,
8968 __rte_unused void *data)
8970 struct cmd_vf_mac_addr_result *res = parsed_result;
8973 if (strcmp(res->what, "add") != 0)
8977 if (ret == -ENOTSUP)
8978 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8982 if (ret == -ENOTSUP)
8983 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8988 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8992 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8993 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8994 mac_addr_cmd,"mac_addr");
8995 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8996 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8998 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8999 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9001 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9002 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9003 port_num, RTE_UINT16);
9004 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9005 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9007 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9008 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9010 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9011 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9014 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9015 .f = cmd_vf_mac_addr_parsed,
9017 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9018 "Add MAC address filtering for a VF on port_id",
9020 (void *)&cmd_vf_mac_addr_cmd,
9021 (void *)&cmd_vf_mac_addr_what,
9022 (void *)&cmd_vf_mac_addr_port,
9023 (void *)&cmd_vf_mac_addr_portnum,
9024 (void *)&cmd_vf_mac_addr_vf,
9025 (void *)&cmd_vf_mac_addr_vfnum,
9026 (void *)&cmd_vf_mac_addr_addr,
9031 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9032 struct cmd_vf_rx_vlan_filter {
9033 cmdline_fixed_string_t rx_vlan;
9034 cmdline_fixed_string_t what;
9036 cmdline_fixed_string_t port;
9038 cmdline_fixed_string_t vf;
9043 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9044 __rte_unused struct cmdline *cl,
9045 __rte_unused void *data)
9047 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9050 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9052 #ifdef RTE_NET_IXGBE
9053 if (ret == -ENOTSUP)
9054 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9055 res->vlan_id, res->vf_mask, is_add);
9058 if (ret == -ENOTSUP)
9059 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9060 res->vlan_id, res->vf_mask, is_add);
9063 if (ret == -ENOTSUP)
9064 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9065 res->vlan_id, res->vf_mask, is_add);
9072 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9073 res->vlan_id, res->vf_mask);
9076 printf("invalid port_id %d\n", res->port_id);
9079 printf("function not implemented or supported\n");
9082 printf("programming error: (%s)\n", strerror(-ret));
9086 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9087 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9088 rx_vlan, "rx_vlan");
9089 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9090 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9092 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9093 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9094 vlan_id, RTE_UINT16);
9095 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9096 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9098 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9099 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9100 port_id, RTE_UINT16);
9101 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9102 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9104 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9105 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9106 vf_mask, RTE_UINT64);
9108 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9109 .f = cmd_vf_rx_vlan_filter_parsed,
9111 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9112 "(vf_mask = hexadecimal VF mask)",
9114 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9115 (void *)&cmd_vf_rx_vlan_filter_what,
9116 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9117 (void *)&cmd_vf_rx_vlan_filter_port,
9118 (void *)&cmd_vf_rx_vlan_filter_portid,
9119 (void *)&cmd_vf_rx_vlan_filter_vf,
9120 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9125 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9126 struct cmd_queue_rate_limit_result {
9127 cmdline_fixed_string_t set;
9128 cmdline_fixed_string_t port;
9130 cmdline_fixed_string_t queue;
9132 cmdline_fixed_string_t rate;
9136 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9137 __rte_unused struct cmdline *cl,
9138 __rte_unused void *data)
9140 struct cmd_queue_rate_limit_result *res = parsed_result;
9143 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9144 && (strcmp(res->queue, "queue") == 0)
9145 && (strcmp(res->rate, "rate") == 0))
9146 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9149 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9153 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9154 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9156 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9157 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9159 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9160 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9161 port_num, RTE_UINT16);
9162 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9163 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9165 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9166 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9167 queue_num, RTE_UINT8);
9168 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9169 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9171 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9172 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9173 rate_num, RTE_UINT16);
9175 cmdline_parse_inst_t cmd_queue_rate_limit = {
9176 .f = cmd_queue_rate_limit_parsed,
9178 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9179 "Set rate limit for a queue on port_id",
9181 (void *)&cmd_queue_rate_limit_set,
9182 (void *)&cmd_queue_rate_limit_port,
9183 (void *)&cmd_queue_rate_limit_portnum,
9184 (void *)&cmd_queue_rate_limit_queue,
9185 (void *)&cmd_queue_rate_limit_queuenum,
9186 (void *)&cmd_queue_rate_limit_rate,
9187 (void *)&cmd_queue_rate_limit_ratenum,
9192 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9193 struct cmd_vf_rate_limit_result {
9194 cmdline_fixed_string_t set;
9195 cmdline_fixed_string_t port;
9197 cmdline_fixed_string_t vf;
9199 cmdline_fixed_string_t rate;
9201 cmdline_fixed_string_t q_msk;
9205 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9206 __rte_unused struct cmdline *cl,
9207 __rte_unused void *data)
9209 struct cmd_vf_rate_limit_result *res = parsed_result;
9212 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9213 && (strcmp(res->vf, "vf") == 0)
9214 && (strcmp(res->rate, "rate") == 0)
9215 && (strcmp(res->q_msk, "queue_mask") == 0))
9216 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9217 res->rate_num, res->q_msk_val);
9219 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9223 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9224 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9226 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9227 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9229 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9230 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9231 port_num, RTE_UINT16);
9232 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9233 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9235 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9236 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9238 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9239 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9241 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9242 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9243 rate_num, RTE_UINT16);
9244 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9245 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9246 q_msk, "queue_mask");
9247 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9248 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9249 q_msk_val, RTE_UINT64);
9251 cmdline_parse_inst_t cmd_vf_rate_limit = {
9252 .f = cmd_vf_rate_limit_parsed,
9254 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9255 "queue_mask <queue_mask_value>: "
9256 "Set rate limit for queues of VF on port_id",
9258 (void *)&cmd_vf_rate_limit_set,
9259 (void *)&cmd_vf_rate_limit_port,
9260 (void *)&cmd_vf_rate_limit_portnum,
9261 (void *)&cmd_vf_rate_limit_vf,
9262 (void *)&cmd_vf_rate_limit_vfnum,
9263 (void *)&cmd_vf_rate_limit_rate,
9264 (void *)&cmd_vf_rate_limit_ratenum,
9265 (void *)&cmd_vf_rate_limit_q_msk,
9266 (void *)&cmd_vf_rate_limit_q_msk_val,
9271 /* *** CONFIGURE TUNNEL UDP PORT *** */
9272 struct cmd_tunnel_udp_config {
9273 cmdline_fixed_string_t rx_vxlan_port;
9274 cmdline_fixed_string_t what;
9280 cmd_tunnel_udp_config_parsed(void *parsed_result,
9281 __rte_unused struct cmdline *cl,
9282 __rte_unused void *data)
9284 struct cmd_tunnel_udp_config *res = parsed_result;
9285 struct rte_eth_udp_tunnel tunnel_udp;
9288 tunnel_udp.udp_port = res->udp_port;
9289 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9291 if (!strcmp(res->what, "add"))
9292 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9295 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9299 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9302 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9303 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9304 rx_vxlan_port, "rx_vxlan_port");
9305 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9306 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9308 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9309 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9310 udp_port, RTE_UINT16);
9311 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9312 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9313 port_id, RTE_UINT16);
9315 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9316 .f = cmd_tunnel_udp_config_parsed,
9318 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9319 "Add/Remove a tunneling UDP port filter",
9321 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9322 (void *)&cmd_tunnel_udp_config_what,
9323 (void *)&cmd_tunnel_udp_config_udp_port,
9324 (void *)&cmd_tunnel_udp_config_port_id,
9329 struct cmd_config_tunnel_udp_port {
9330 cmdline_fixed_string_t port;
9331 cmdline_fixed_string_t config;
9333 cmdline_fixed_string_t udp_tunnel_port;
9334 cmdline_fixed_string_t action;
9335 cmdline_fixed_string_t tunnel_type;
9340 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9341 __rte_unused struct cmdline *cl,
9342 __rte_unused void *data)
9344 struct cmd_config_tunnel_udp_port *res = parsed_result;
9345 struct rte_eth_udp_tunnel tunnel_udp;
9348 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9351 tunnel_udp.udp_port = res->udp_port;
9353 if (!strcmp(res->tunnel_type, "vxlan")) {
9354 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9355 } else if (!strcmp(res->tunnel_type, "geneve")) {
9356 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9357 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9358 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9359 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9360 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9362 printf("Invalid tunnel type\n");
9366 if (!strcmp(res->action, "add"))
9367 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9370 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9374 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9377 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9378 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9380 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9381 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9383 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9384 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9386 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9387 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9390 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9391 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9393 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9394 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9395 "vxlan#geneve#vxlan-gpe#ecpri");
9396 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9397 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9400 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9401 .f = cmd_cfg_tunnel_udp_port_parsed,
9403 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9404 "geneve|vxlan-gpe|ecpri <udp_port>",
9406 (void *)&cmd_config_tunnel_udp_port_port,
9407 (void *)&cmd_config_tunnel_udp_port_config,
9408 (void *)&cmd_config_tunnel_udp_port_port_id,
9409 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9410 (void *)&cmd_config_tunnel_udp_port_action,
9411 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9412 (void *)&cmd_config_tunnel_udp_port_value,
9417 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9418 struct cmd_set_mirror_mask_result {
9419 cmdline_fixed_string_t set;
9420 cmdline_fixed_string_t port;
9422 cmdline_fixed_string_t mirror;
9424 cmdline_fixed_string_t what;
9425 cmdline_fixed_string_t value;
9426 cmdline_fixed_string_t dstpool;
9428 cmdline_fixed_string_t on;
9431 cmdline_parse_token_string_t cmd_mirror_mask_set =
9432 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9434 cmdline_parse_token_string_t cmd_mirror_mask_port =
9435 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9437 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9438 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9439 port_id, RTE_UINT16);
9440 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9441 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9442 mirror, "mirror-rule");
9443 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9444 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9445 rule_id, RTE_UINT8);
9446 cmdline_parse_token_string_t cmd_mirror_mask_what =
9447 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9448 what, "pool-mirror-up#pool-mirror-down"
9450 cmdline_parse_token_string_t cmd_mirror_mask_value =
9451 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9453 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9454 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9455 dstpool, "dst-pool");
9456 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9457 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9458 dstpool_id, RTE_UINT8);
9459 cmdline_parse_token_string_t cmd_mirror_mask_on =
9460 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9464 cmd_set_mirror_mask_parsed(void *parsed_result,
9465 __rte_unused struct cmdline *cl,
9466 __rte_unused void *data)
9469 struct cmd_set_mirror_mask_result *res = parsed_result;
9470 struct rte_eth_mirror_conf mr_conf;
9472 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9474 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9476 mr_conf.dst_pool = res->dstpool_id;
9478 if (!strcmp(res->what, "pool-mirror-up")) {
9479 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9480 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9481 } else if (!strcmp(res->what, "pool-mirror-down")) {
9482 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9483 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9484 } else if (!strcmp(res->what, "vlan-mirror")) {
9485 mr_conf.rule_type = ETH_MIRROR_VLAN;
9486 nb_item = parse_item_list(res->value, "vlan",
9487 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9491 for (i = 0; i < nb_item; i++) {
9492 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9493 printf("Invalid vlan_id: must be < 4096\n");
9497 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9498 mr_conf.vlan.vlan_mask |= 1ULL << i;
9502 if (!strcmp(res->on, "on"))
9503 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9506 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9509 printf("mirror rule add error: (%s)\n", strerror(-ret));
9512 cmdline_parse_inst_t cmd_set_mirror_mask = {
9513 .f = cmd_set_mirror_mask_parsed,
9515 .help_str = "set port <port_id> mirror-rule <rule_id> "
9516 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9517 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9519 (void *)&cmd_mirror_mask_set,
9520 (void *)&cmd_mirror_mask_port,
9521 (void *)&cmd_mirror_mask_portid,
9522 (void *)&cmd_mirror_mask_mirror,
9523 (void *)&cmd_mirror_mask_ruleid,
9524 (void *)&cmd_mirror_mask_what,
9525 (void *)&cmd_mirror_mask_value,
9526 (void *)&cmd_mirror_mask_dstpool,
9527 (void *)&cmd_mirror_mask_poolid,
9528 (void *)&cmd_mirror_mask_on,
9533 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9534 struct cmd_set_mirror_link_result {
9535 cmdline_fixed_string_t set;
9536 cmdline_fixed_string_t port;
9538 cmdline_fixed_string_t mirror;
9540 cmdline_fixed_string_t what;
9541 cmdline_fixed_string_t dstpool;
9543 cmdline_fixed_string_t on;
9546 cmdline_parse_token_string_t cmd_mirror_link_set =
9547 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9549 cmdline_parse_token_string_t cmd_mirror_link_port =
9550 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9552 cmdline_parse_token_num_t cmd_mirror_link_portid =
9553 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9554 port_id, RTE_UINT16);
9555 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9556 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9557 mirror, "mirror-rule");
9558 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9559 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9560 rule_id, RTE_UINT8);
9561 cmdline_parse_token_string_t cmd_mirror_link_what =
9562 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9563 what, "uplink-mirror#downlink-mirror");
9564 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9565 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9566 dstpool, "dst-pool");
9567 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9568 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9569 dstpool_id, RTE_UINT8);
9570 cmdline_parse_token_string_t cmd_mirror_link_on =
9571 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9575 cmd_set_mirror_link_parsed(void *parsed_result,
9576 __rte_unused struct cmdline *cl,
9577 __rte_unused void *data)
9580 struct cmd_set_mirror_link_result *res = parsed_result;
9581 struct rte_eth_mirror_conf mr_conf;
9583 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9584 if (!strcmp(res->what, "uplink-mirror"))
9585 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9587 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9589 mr_conf.dst_pool = res->dstpool_id;
9591 if (!strcmp(res->on, "on"))
9592 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9595 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9598 /* check the return value and print it if is < 0 */
9600 printf("mirror rule add error: (%s)\n", strerror(-ret));
9604 cmdline_parse_inst_t cmd_set_mirror_link = {
9605 .f = cmd_set_mirror_link_parsed,
9607 .help_str = "set port <port_id> mirror-rule <rule_id> "
9608 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9610 (void *)&cmd_mirror_link_set,
9611 (void *)&cmd_mirror_link_port,
9612 (void *)&cmd_mirror_link_portid,
9613 (void *)&cmd_mirror_link_mirror,
9614 (void *)&cmd_mirror_link_ruleid,
9615 (void *)&cmd_mirror_link_what,
9616 (void *)&cmd_mirror_link_dstpool,
9617 (void *)&cmd_mirror_link_poolid,
9618 (void *)&cmd_mirror_link_on,
9623 /* *** RESET VM MIRROR RULE *** */
9624 struct cmd_rm_mirror_rule_result {
9625 cmdline_fixed_string_t reset;
9626 cmdline_fixed_string_t port;
9628 cmdline_fixed_string_t mirror;
9632 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9633 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9635 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9636 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9638 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9639 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9640 port_id, RTE_UINT16);
9641 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9642 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9643 mirror, "mirror-rule");
9644 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9645 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9646 rule_id, RTE_UINT8);
9649 cmd_reset_mirror_rule_parsed(void *parsed_result,
9650 __rte_unused struct cmdline *cl,
9651 __rte_unused void *data)
9654 struct cmd_set_mirror_link_result *res = parsed_result;
9656 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9658 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9661 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9662 .f = cmd_reset_mirror_rule_parsed,
9664 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9666 (void *)&cmd_rm_mirror_rule_reset,
9667 (void *)&cmd_rm_mirror_rule_port,
9668 (void *)&cmd_rm_mirror_rule_portid,
9669 (void *)&cmd_rm_mirror_rule_mirror,
9670 (void *)&cmd_rm_mirror_rule_ruleid,
9675 /* ******************************************************************************** */
9677 struct cmd_dump_result {
9678 cmdline_fixed_string_t dump;
9682 dump_struct_sizes(void)
9684 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9685 DUMP_SIZE(struct rte_mbuf);
9686 DUMP_SIZE(struct rte_mempool);
9687 DUMP_SIZE(struct rte_ring);
9692 /* Dump the socket memory statistics on console */
9694 dump_socket_mem(FILE *f)
9696 struct rte_malloc_socket_stats socket_stats;
9701 unsigned int n_alloc = 0;
9702 unsigned int n_free = 0;
9703 static size_t last_allocs;
9704 static size_t last_total;
9707 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9708 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9709 !socket_stats.heap_totalsz_bytes)
9711 total += socket_stats.heap_totalsz_bytes;
9712 alloc += socket_stats.heap_allocsz_bytes;
9713 free += socket_stats.heap_freesz_bytes;
9714 n_alloc += socket_stats.alloc_count;
9715 n_free += socket_stats.free_count;
9717 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9719 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9720 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9721 (double)socket_stats.heap_allocsz_bytes * 100 /
9722 (double)socket_stats.heap_totalsz_bytes,
9723 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9724 socket_stats.alloc_count,
9725 socket_stats.free_count);
9728 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9729 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9730 (double)alloc * 100 / (double)total,
9731 (double)free / (1024 * 1024),
9734 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9735 ((double)total - (double)last_total) / (1024 * 1024),
9736 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9737 last_allocs = alloc;
9741 static void cmd_dump_parsed(void *parsed_result,
9742 __rte_unused struct cmdline *cl,
9743 __rte_unused void *data)
9745 struct cmd_dump_result *res = parsed_result;
9747 if (!strcmp(res->dump, "dump_physmem"))
9748 rte_dump_physmem_layout(stdout);
9749 else if (!strcmp(res->dump, "dump_socket_mem"))
9750 dump_socket_mem(stdout);
9751 else if (!strcmp(res->dump, "dump_memzone"))
9752 rte_memzone_dump(stdout);
9753 else if (!strcmp(res->dump, "dump_struct_sizes"))
9754 dump_struct_sizes();
9755 else if (!strcmp(res->dump, "dump_ring"))
9756 rte_ring_list_dump(stdout);
9757 else if (!strcmp(res->dump, "dump_mempool"))
9758 rte_mempool_list_dump(stdout);
9759 else if (!strcmp(res->dump, "dump_devargs"))
9760 rte_devargs_dump(stdout);
9761 else if (!strcmp(res->dump, "dump_log_types"))
9762 rte_log_dump(stdout);
9765 cmdline_parse_token_string_t cmd_dump_dump =
9766 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9770 "dump_struct_sizes#"
9776 cmdline_parse_inst_t cmd_dump = {
9777 .f = cmd_dump_parsed, /* function to call */
9778 .data = NULL, /* 2nd arg of func */
9779 .help_str = "Dump status",
9780 .tokens = { /* token list, NULL terminated */
9781 (void *)&cmd_dump_dump,
9786 /* ******************************************************************************** */
9788 struct cmd_dump_one_result {
9789 cmdline_fixed_string_t dump;
9790 cmdline_fixed_string_t name;
9793 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9794 __rte_unused void *data)
9796 struct cmd_dump_one_result *res = parsed_result;
9798 if (!strcmp(res->dump, "dump_ring")) {
9800 r = rte_ring_lookup(res->name);
9802 cmdline_printf(cl, "Cannot find ring\n");
9805 rte_ring_dump(stdout, r);
9806 } else if (!strcmp(res->dump, "dump_mempool")) {
9807 struct rte_mempool *mp;
9808 mp = rte_mempool_lookup(res->name);
9810 cmdline_printf(cl, "Cannot find mempool\n");
9813 rte_mempool_dump(stdout, mp);
9817 cmdline_parse_token_string_t cmd_dump_one_dump =
9818 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9819 "dump_ring#dump_mempool");
9821 cmdline_parse_token_string_t cmd_dump_one_name =
9822 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9824 cmdline_parse_inst_t cmd_dump_one = {
9825 .f = cmd_dump_one_parsed, /* function to call */
9826 .data = NULL, /* 2nd arg of func */
9827 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9828 .tokens = { /* token list, NULL terminated */
9829 (void *)&cmd_dump_one_dump,
9830 (void *)&cmd_dump_one_name,
9835 /* *** queue region set *** */
9836 struct cmd_queue_region_result {
9837 cmdline_fixed_string_t set;
9838 cmdline_fixed_string_t port;
9840 cmdline_fixed_string_t cmd;
9841 cmdline_fixed_string_t region;
9843 cmdline_fixed_string_t queue_start_index;
9845 cmdline_fixed_string_t queue_num;
9846 uint8_t queue_num_value;
9850 cmd_queue_region_parsed(void *parsed_result,
9851 __rte_unused struct cmdline *cl,
9852 __rte_unused void *data)
9854 struct cmd_queue_region_result *res = parsed_result;
9857 struct rte_pmd_i40e_queue_region_conf region_conf;
9858 enum rte_pmd_i40e_queue_region_op op_type;
9861 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9865 memset(®ion_conf, 0, sizeof(region_conf));
9866 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9867 region_conf.region_id = res->region_id;
9868 region_conf.queue_num = res->queue_num_value;
9869 region_conf.queue_start_index = res->queue_id;
9871 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9872 op_type, ®ion_conf);
9879 printf("function not implemented or supported\n");
9882 printf("queue region config error: (%s)\n", strerror(-ret));
9886 cmdline_parse_token_string_t cmd_queue_region_set =
9887 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9889 cmdline_parse_token_string_t cmd_queue_region_port =
9890 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9891 cmdline_parse_token_num_t cmd_queue_region_port_id =
9892 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9893 port_id, RTE_UINT16);
9894 cmdline_parse_token_string_t cmd_queue_region_cmd =
9895 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9896 cmd, "queue-region");
9897 cmdline_parse_token_string_t cmd_queue_region_id =
9898 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9899 region, "region_id");
9900 cmdline_parse_token_num_t cmd_queue_region_index =
9901 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9902 region_id, RTE_UINT8);
9903 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9904 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9905 queue_start_index, "queue_start_index");
9906 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9907 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9908 queue_id, RTE_UINT8);
9909 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9910 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9911 queue_num, "queue_num");
9912 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9913 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9914 queue_num_value, RTE_UINT8);
9916 cmdline_parse_inst_t cmd_queue_region = {
9917 .f = cmd_queue_region_parsed,
9919 .help_str = "set port <port_id> queue-region region_id <value> "
9920 "queue_start_index <value> queue_num <value>: Set a queue region",
9922 (void *)&cmd_queue_region_set,
9923 (void *)&cmd_queue_region_port,
9924 (void *)&cmd_queue_region_port_id,
9925 (void *)&cmd_queue_region_cmd,
9926 (void *)&cmd_queue_region_id,
9927 (void *)&cmd_queue_region_index,
9928 (void *)&cmd_queue_region_queue_start_index,
9929 (void *)&cmd_queue_region_queue_id,
9930 (void *)&cmd_queue_region_queue_num,
9931 (void *)&cmd_queue_region_queue_num_value,
9936 /* *** queue region and flowtype set *** */
9937 struct cmd_region_flowtype_result {
9938 cmdline_fixed_string_t set;
9939 cmdline_fixed_string_t port;
9941 cmdline_fixed_string_t cmd;
9942 cmdline_fixed_string_t region;
9944 cmdline_fixed_string_t flowtype;
9945 uint8_t flowtype_id;
9949 cmd_region_flowtype_parsed(void *parsed_result,
9950 __rte_unused struct cmdline *cl,
9951 __rte_unused void *data)
9953 struct cmd_region_flowtype_result *res = parsed_result;
9956 struct rte_pmd_i40e_queue_region_conf region_conf;
9957 enum rte_pmd_i40e_queue_region_op op_type;
9960 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9964 memset(®ion_conf, 0, sizeof(region_conf));
9966 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9967 region_conf.region_id = res->region_id;
9968 region_conf.hw_flowtype = res->flowtype_id;
9970 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9971 op_type, ®ion_conf);
9978 printf("function not implemented or supported\n");
9981 printf("region flowtype config error: (%s)\n", strerror(-ret));
9985 cmdline_parse_token_string_t cmd_region_flowtype_set =
9986 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9988 cmdline_parse_token_string_t cmd_region_flowtype_port =
9989 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9991 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9992 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9993 port_id, RTE_UINT16);
9994 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9995 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9996 cmd, "queue-region");
9997 cmdline_parse_token_string_t cmd_region_flowtype_index =
9998 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9999 region, "region_id");
10000 cmdline_parse_token_num_t cmd_region_flowtype_id =
10001 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10002 region_id, RTE_UINT8);
10003 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10004 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10005 flowtype, "flowtype");
10006 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10007 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10008 flowtype_id, RTE_UINT8);
10009 cmdline_parse_inst_t cmd_region_flowtype = {
10010 .f = cmd_region_flowtype_parsed,
10012 .help_str = "set port <port_id> queue-region region_id <value> "
10013 "flowtype <value>: Set a flowtype region index",
10015 (void *)&cmd_region_flowtype_set,
10016 (void *)&cmd_region_flowtype_port,
10017 (void *)&cmd_region_flowtype_port_index,
10018 (void *)&cmd_region_flowtype_cmd,
10019 (void *)&cmd_region_flowtype_index,
10020 (void *)&cmd_region_flowtype_id,
10021 (void *)&cmd_region_flowtype_flow_index,
10022 (void *)&cmd_region_flowtype_flow_id,
10027 /* *** User Priority (UP) to queue region (region_id) set *** */
10028 struct cmd_user_priority_region_result {
10029 cmdline_fixed_string_t set;
10030 cmdline_fixed_string_t port;
10032 cmdline_fixed_string_t cmd;
10033 cmdline_fixed_string_t user_priority;
10034 uint8_t user_priority_id;
10035 cmdline_fixed_string_t region;
10040 cmd_user_priority_region_parsed(void *parsed_result,
10041 __rte_unused struct cmdline *cl,
10042 __rte_unused void *data)
10044 struct cmd_user_priority_region_result *res = parsed_result;
10045 int ret = -ENOTSUP;
10046 #ifdef RTE_NET_I40E
10047 struct rte_pmd_i40e_queue_region_conf region_conf;
10048 enum rte_pmd_i40e_queue_region_op op_type;
10051 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10054 #ifdef RTE_NET_I40E
10055 memset(®ion_conf, 0, sizeof(region_conf));
10056 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10057 region_conf.user_priority = res->user_priority_id;
10058 region_conf.region_id = res->region_id;
10060 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10061 op_type, ®ion_conf);
10068 printf("function not implemented or supported\n");
10071 printf("user_priority region config error: (%s)\n",
10076 cmdline_parse_token_string_t cmd_user_priority_region_set =
10077 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10079 cmdline_parse_token_string_t cmd_user_priority_region_port =
10080 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10082 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10083 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10084 port_id, RTE_UINT16);
10085 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10086 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10087 cmd, "queue-region");
10088 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10089 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10090 user_priority, "UP");
10091 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10092 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10093 user_priority_id, RTE_UINT8);
10094 cmdline_parse_token_string_t cmd_user_priority_region_region =
10095 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10096 region, "region_id");
10097 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10098 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10099 region_id, RTE_UINT8);
10101 cmdline_parse_inst_t cmd_user_priority_region = {
10102 .f = cmd_user_priority_region_parsed,
10104 .help_str = "set port <port_id> queue-region UP <value> "
10105 "region_id <value>: Set the mapping of User Priority (UP) "
10106 "to queue region (region_id) ",
10108 (void *)&cmd_user_priority_region_set,
10109 (void *)&cmd_user_priority_region_port,
10110 (void *)&cmd_user_priority_region_port_index,
10111 (void *)&cmd_user_priority_region_cmd,
10112 (void *)&cmd_user_priority_region_UP,
10113 (void *)&cmd_user_priority_region_UP_id,
10114 (void *)&cmd_user_priority_region_region,
10115 (void *)&cmd_user_priority_region_region_id,
10120 /* *** flush all queue region related configuration *** */
10121 struct cmd_flush_queue_region_result {
10122 cmdline_fixed_string_t set;
10123 cmdline_fixed_string_t port;
10125 cmdline_fixed_string_t cmd;
10126 cmdline_fixed_string_t flush;
10127 cmdline_fixed_string_t what;
10131 cmd_flush_queue_region_parsed(void *parsed_result,
10132 __rte_unused struct cmdline *cl,
10133 __rte_unused void *data)
10135 struct cmd_flush_queue_region_result *res = parsed_result;
10136 int ret = -ENOTSUP;
10137 #ifdef RTE_NET_I40E
10138 struct rte_pmd_i40e_queue_region_conf region_conf;
10139 enum rte_pmd_i40e_queue_region_op op_type;
10142 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10145 #ifdef RTE_NET_I40E
10146 memset(®ion_conf, 0, sizeof(region_conf));
10148 if (strcmp(res->what, "on") == 0)
10149 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10151 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10153 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10154 op_type, ®ion_conf);
10161 printf("function not implemented or supported\n");
10164 printf("queue region config flush error: (%s)\n",
10169 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10170 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10172 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10173 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10175 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10176 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10177 port_id, RTE_UINT16);
10178 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10179 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10180 cmd, "queue-region");
10181 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10182 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10184 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10185 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10188 cmdline_parse_inst_t cmd_flush_queue_region = {
10189 .f = cmd_flush_queue_region_parsed,
10191 .help_str = "set port <port_id> queue-region flush on|off"
10192 ": flush all queue region related configuration",
10194 (void *)&cmd_flush_queue_region_set,
10195 (void *)&cmd_flush_queue_region_port,
10196 (void *)&cmd_flush_queue_region_port_index,
10197 (void *)&cmd_flush_queue_region_cmd,
10198 (void *)&cmd_flush_queue_region_flush,
10199 (void *)&cmd_flush_queue_region_what,
10204 /* *** get all queue region related configuration info *** */
10205 struct cmd_show_queue_region_info {
10206 cmdline_fixed_string_t show;
10207 cmdline_fixed_string_t port;
10209 cmdline_fixed_string_t cmd;
10213 cmd_show_queue_region_info_parsed(void *parsed_result,
10214 __rte_unused struct cmdline *cl,
10215 __rte_unused void *data)
10217 struct cmd_show_queue_region_info *res = parsed_result;
10218 int ret = -ENOTSUP;
10219 #ifdef RTE_NET_I40E
10220 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10221 enum rte_pmd_i40e_queue_region_op op_type;
10224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10227 #ifdef RTE_NET_I40E
10228 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10230 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10232 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10233 op_type, &rte_pmd_regions);
10235 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10242 printf("function not implemented or supported\n");
10245 printf("queue region config info show error: (%s)\n",
10250 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10251 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10253 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10254 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10256 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10257 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10258 port_id, RTE_UINT16);
10259 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10260 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10261 cmd, "queue-region");
10263 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10264 .f = cmd_show_queue_region_info_parsed,
10266 .help_str = "show port <port_id> queue-region"
10267 ": show all queue region related configuration info",
10269 (void *)&cmd_show_queue_region_info_get,
10270 (void *)&cmd_show_queue_region_info_port,
10271 (void *)&cmd_show_queue_region_info_port_index,
10272 (void *)&cmd_show_queue_region_info_cmd,
10277 /* *** Filters Control *** */
10279 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10281 if ((ip_addr).family == AF_INET) \
10282 (ip) = (ip_addr).addr.ipv4.s_addr; \
10284 printf("invalid parameter.\n"); \
10289 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10291 if ((ip_addr).family == AF_INET6) \
10292 rte_memcpy(&(ip), \
10293 &((ip_addr).addr.ipv6), \
10294 sizeof(struct in6_addr)); \
10296 printf("invalid parameter.\n"); \
10301 #ifdef RTE_NET_I40E
10304 str2flowtype(char *string)
10307 static const struct {
10310 } flowtype_str[] = {
10311 {"raw", RTE_ETH_FLOW_RAW},
10312 {"ipv4", RTE_ETH_FLOW_IPV4},
10313 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10314 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10315 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10316 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10317 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10318 {"ipv6", RTE_ETH_FLOW_IPV6},
10319 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10320 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10321 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10322 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10323 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10324 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10327 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10328 if (!strcmp(flowtype_str[i].str, string))
10329 return flowtype_str[i].type;
10332 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10333 return (uint16_t)atoi(string);
10335 return RTE_ETH_FLOW_UNKNOWN;
10338 /* *** deal with flow director filter *** */
10339 struct cmd_flow_director_result {
10340 cmdline_fixed_string_t flow_director_filter;
10342 cmdline_fixed_string_t mode;
10343 cmdline_fixed_string_t mode_value;
10344 cmdline_fixed_string_t ops;
10345 cmdline_fixed_string_t flow;
10346 cmdline_fixed_string_t flow_type;
10347 cmdline_fixed_string_t drop;
10348 cmdline_fixed_string_t queue;
10350 cmdline_fixed_string_t fd_id;
10351 uint32_t fd_id_value;
10352 cmdline_fixed_string_t packet;
10357 cmd_flow_director_filter_parsed(void *parsed_result,
10358 __rte_unused struct cmdline *cl,
10359 __rte_unused void *data)
10361 struct cmd_flow_director_result *res = parsed_result;
10363 struct rte_pmd_i40e_flow_type_mapping
10364 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10365 struct rte_pmd_i40e_pkt_template_conf conf;
10366 uint16_t flow_type = str2flowtype(res->flow_type);
10367 uint16_t i, port = res->port_id;
10370 memset(&conf, 0, sizeof(conf));
10372 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10373 printf("Invalid flow type specified.\n");
10376 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10380 if (mapping[flow_type].pctype == 0ULL) {
10381 printf("Invalid flow type specified.\n");
10384 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10385 if (mapping[flow_type].pctype & (1ULL << i)) {
10386 conf.input.pctype = i;
10391 conf.input.packet = open_file(res->filepath,
10392 &conf.input.length);
10393 if (!conf.input.packet)
10395 if (!strcmp(res->drop, "drop"))
10396 conf.action.behavior =
10397 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10399 conf.action.behavior =
10400 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10401 conf.action.report_status =
10402 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10403 conf.action.rx_queue = res->queue_id;
10404 conf.soft_id = res->fd_id_value;
10405 add = strcmp(res->ops, "del") ? 1 : 0;
10406 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10410 printf("flow director config error: (%s)\n",
10412 close_file(conf.input.packet);
10415 cmdline_parse_token_string_t cmd_flow_director_filter =
10416 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10417 flow_director_filter, "flow_director_filter");
10418 cmdline_parse_token_num_t cmd_flow_director_port_id =
10419 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10420 port_id, RTE_UINT16);
10421 cmdline_parse_token_string_t cmd_flow_director_ops =
10422 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10423 ops, "add#del#update");
10424 cmdline_parse_token_string_t cmd_flow_director_flow =
10425 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10427 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10428 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10430 cmdline_parse_token_string_t cmd_flow_director_drop =
10431 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10433 cmdline_parse_token_string_t cmd_flow_director_queue =
10434 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10436 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10437 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10438 queue_id, RTE_UINT16);
10439 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10442 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10443 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10444 fd_id_value, RTE_UINT32);
10446 cmdline_parse_token_string_t cmd_flow_director_mode =
10447 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10449 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10450 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10451 mode_value, "raw");
10452 cmdline_parse_token_string_t cmd_flow_director_packet =
10453 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10455 cmdline_parse_token_string_t cmd_flow_director_filepath =
10456 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10459 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10460 .f = cmd_flow_director_filter_parsed,
10462 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10463 "director entry on NIC",
10465 (void *)&cmd_flow_director_filter,
10466 (void *)&cmd_flow_director_port_id,
10467 (void *)&cmd_flow_director_mode,
10468 (void *)&cmd_flow_director_mode_raw,
10469 (void *)&cmd_flow_director_ops,
10470 (void *)&cmd_flow_director_flow,
10471 (void *)&cmd_flow_director_flow_type,
10472 (void *)&cmd_flow_director_drop,
10473 (void *)&cmd_flow_director_queue,
10474 (void *)&cmd_flow_director_queue_id,
10475 (void *)&cmd_flow_director_fd_id,
10476 (void *)&cmd_flow_director_fd_id_value,
10477 (void *)&cmd_flow_director_packet,
10478 (void *)&cmd_flow_director_filepath,
10483 #endif /* RTE_NET_I40E */
10485 /* *** deal with flow director mask *** */
10486 struct cmd_flow_director_mask_result {
10487 cmdline_fixed_string_t flow_director_mask;
10489 cmdline_fixed_string_t mode;
10490 cmdline_fixed_string_t mode_value;
10491 cmdline_fixed_string_t vlan;
10492 uint16_t vlan_mask;
10493 cmdline_fixed_string_t src_mask;
10494 cmdline_ipaddr_t ipv4_src;
10495 cmdline_ipaddr_t ipv6_src;
10497 cmdline_fixed_string_t dst_mask;
10498 cmdline_ipaddr_t ipv4_dst;
10499 cmdline_ipaddr_t ipv6_dst;
10501 cmdline_fixed_string_t mac;
10502 uint8_t mac_addr_byte_mask;
10503 cmdline_fixed_string_t tunnel_id;
10504 uint32_t tunnel_id_mask;
10505 cmdline_fixed_string_t tunnel_type;
10506 uint8_t tunnel_type_mask;
10510 cmd_flow_director_mask_parsed(void *parsed_result,
10511 __rte_unused struct cmdline *cl,
10512 __rte_unused void *data)
10514 struct cmd_flow_director_mask_result *res = parsed_result;
10515 struct rte_eth_fdir_masks *mask;
10516 struct rte_port *port;
10518 port = &ports[res->port_id];
10519 /** Check if the port is not started **/
10520 if (port->port_status != RTE_PORT_STOPPED) {
10521 printf("Please stop port %d first\n", res->port_id);
10525 mask = &port->dev_conf.fdir_conf.mask;
10527 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10528 if (strcmp(res->mode_value, "MAC-VLAN")) {
10529 printf("Please set mode to MAC-VLAN.\n");
10533 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10534 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10535 if (strcmp(res->mode_value, "Tunnel")) {
10536 printf("Please set mode to Tunnel.\n");
10540 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10541 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10542 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10543 mask->tunnel_type_mask = res->tunnel_type_mask;
10545 if (strcmp(res->mode_value, "IP")) {
10546 printf("Please set mode to IP.\n");
10550 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10551 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10552 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10553 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10554 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10555 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10556 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10559 cmd_reconfig_device_queue(res->port_id, 1, 1);
10562 cmdline_parse_token_string_t cmd_flow_director_mask =
10563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10564 flow_director_mask, "flow_director_mask");
10565 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10566 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10567 port_id, RTE_UINT16);
10568 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10569 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10571 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10572 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10573 vlan_mask, RTE_UINT16);
10574 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10575 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10576 src_mask, "src_mask");
10577 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10578 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10580 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10581 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10583 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10584 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10585 port_src, RTE_UINT16);
10586 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10587 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10588 dst_mask, "dst_mask");
10589 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10590 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10592 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10593 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10595 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10596 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10597 port_dst, RTE_UINT16);
10599 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10600 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10602 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10603 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10605 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10606 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10607 mode_value, "MAC-VLAN");
10608 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10609 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10610 mode_value, "Tunnel");
10611 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10612 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10614 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10615 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10616 mac_addr_byte_mask, RTE_UINT8);
10617 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10618 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10619 tunnel_type, "tunnel-type");
10620 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10621 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10622 tunnel_type_mask, RTE_UINT8);
10623 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10624 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10625 tunnel_id, "tunnel-id");
10626 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10627 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10628 tunnel_id_mask, RTE_UINT32);
10630 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10631 .f = cmd_flow_director_mask_parsed,
10633 .help_str = "flow_director_mask ... : "
10634 "Set IP mode flow director's mask on NIC",
10636 (void *)&cmd_flow_director_mask,
10637 (void *)&cmd_flow_director_mask_port_id,
10638 (void *)&cmd_flow_director_mask_mode,
10639 (void *)&cmd_flow_director_mask_mode_ip,
10640 (void *)&cmd_flow_director_mask_vlan,
10641 (void *)&cmd_flow_director_mask_vlan_value,
10642 (void *)&cmd_flow_director_mask_src,
10643 (void *)&cmd_flow_director_mask_ipv4_src,
10644 (void *)&cmd_flow_director_mask_ipv6_src,
10645 (void *)&cmd_flow_director_mask_port_src,
10646 (void *)&cmd_flow_director_mask_dst,
10647 (void *)&cmd_flow_director_mask_ipv4_dst,
10648 (void *)&cmd_flow_director_mask_ipv6_dst,
10649 (void *)&cmd_flow_director_mask_port_dst,
10654 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10655 .f = cmd_flow_director_mask_parsed,
10657 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10658 "flow director's mask on NIC",
10660 (void *)&cmd_flow_director_mask,
10661 (void *)&cmd_flow_director_mask_port_id,
10662 (void *)&cmd_flow_director_mask_mode,
10663 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10664 (void *)&cmd_flow_director_mask_vlan,
10665 (void *)&cmd_flow_director_mask_vlan_value,
10670 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10671 .f = cmd_flow_director_mask_parsed,
10673 .help_str = "flow_director_mask ... : Set tunnel mode "
10674 "flow director's mask on NIC",
10676 (void *)&cmd_flow_director_mask,
10677 (void *)&cmd_flow_director_mask_port_id,
10678 (void *)&cmd_flow_director_mask_mode,
10679 (void *)&cmd_flow_director_mask_mode_tunnel,
10680 (void *)&cmd_flow_director_mask_vlan,
10681 (void *)&cmd_flow_director_mask_vlan_value,
10682 (void *)&cmd_flow_director_mask_mac,
10683 (void *)&cmd_flow_director_mask_mac_value,
10684 (void *)&cmd_flow_director_mask_tunnel_type,
10685 (void *)&cmd_flow_director_mask_tunnel_type_value,
10686 (void *)&cmd_flow_director_mask_tunnel_id,
10687 (void *)&cmd_flow_director_mask_tunnel_id_value,
10692 /* *** deal with flow director flexible payload configuration *** */
10693 struct cmd_flow_director_flexpayload_result {
10694 cmdline_fixed_string_t flow_director_flexpayload;
10696 cmdline_fixed_string_t payload_layer;
10697 cmdline_fixed_string_t payload_cfg;
10701 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10704 const char *p, *p0 = q_arg;
10706 unsigned long int_fld;
10707 char *str_fld[max_num];
10712 p = strchr(p0, '(');
10716 p0 = strchr(p, ')');
10721 if (size >= sizeof(s))
10724 snprintf(s, sizeof(s), "%.*s", size, p);
10725 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10726 if (ret < 0 || ret > max_num)
10728 for (i = 0; i < ret; i++) {
10730 int_fld = strtoul(str_fld[i], &end, 0);
10731 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10733 offsets[i] = (uint16_t)int_fld;
10739 cmd_flow_director_flxpld_parsed(void *parsed_result,
10740 __rte_unused struct cmdline *cl,
10741 __rte_unused void *data)
10743 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10744 struct rte_eth_flex_payload_cfg flex_cfg;
10745 struct rte_port *port;
10748 port = &ports[res->port_id];
10749 /** Check if the port is not started **/
10750 if (port->port_status != RTE_PORT_STOPPED) {
10751 printf("Please stop port %d first\n", res->port_id);
10755 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10757 if (!strcmp(res->payload_layer, "raw"))
10758 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10759 else if (!strcmp(res->payload_layer, "l2"))
10760 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10761 else if (!strcmp(res->payload_layer, "l3"))
10762 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10763 else if (!strcmp(res->payload_layer, "l4"))
10764 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10766 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10767 RTE_ETH_FDIR_MAX_FLEXLEN);
10769 printf("error: Cannot parse flex payload input.\n");
10773 fdir_set_flex_payload(res->port_id, &flex_cfg);
10774 cmd_reconfig_device_queue(res->port_id, 1, 1);
10777 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10779 flow_director_flexpayload,
10780 "flow_director_flex_payload");
10781 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10782 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10783 port_id, RTE_UINT16);
10784 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10786 payload_layer, "raw#l2#l3#l4");
10787 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10788 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10789 payload_cfg, NULL);
10791 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10792 .f = cmd_flow_director_flxpld_parsed,
10794 .help_str = "flow_director_flexpayload ... : "
10795 "Set flow director's flex payload on NIC",
10797 (void *)&cmd_flow_director_flexpayload,
10798 (void *)&cmd_flow_director_flexpayload_port_id,
10799 (void *)&cmd_flow_director_flexpayload_payload_layer,
10800 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10805 /* Generic flow interface command. */
10806 extern cmdline_parse_inst_t cmd_flow;
10808 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10809 struct cmd_mcast_addr_result {
10810 cmdline_fixed_string_t mcast_addr_cmd;
10811 cmdline_fixed_string_t what;
10813 struct rte_ether_addr mc_addr;
10816 static void cmd_mcast_addr_parsed(void *parsed_result,
10817 __rte_unused struct cmdline *cl,
10818 __rte_unused void *data)
10820 struct cmd_mcast_addr_result *res = parsed_result;
10822 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10823 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10824 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10825 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10826 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10829 if (strcmp(res->what, "add") == 0)
10830 mcast_addr_add(res->port_num, &res->mc_addr);
10832 mcast_addr_remove(res->port_num, &res->mc_addr);
10835 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10836 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10837 mcast_addr_cmd, "mcast_addr");
10838 cmdline_parse_token_string_t cmd_mcast_addr_what =
10839 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10841 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10842 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10844 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10845 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10847 cmdline_parse_inst_t cmd_mcast_addr = {
10848 .f = cmd_mcast_addr_parsed,
10850 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10851 "Add/Remove multicast MAC address on port_id",
10853 (void *)&cmd_mcast_addr_cmd,
10854 (void *)&cmd_mcast_addr_what,
10855 (void *)&cmd_mcast_addr_portnum,
10856 (void *)&cmd_mcast_addr_addr,
10861 /* vf vlan anti spoof configuration */
10863 /* Common result structure for vf vlan anti spoof */
10864 struct cmd_vf_vlan_anti_spoof_result {
10865 cmdline_fixed_string_t set;
10866 cmdline_fixed_string_t vf;
10867 cmdline_fixed_string_t vlan;
10868 cmdline_fixed_string_t antispoof;
10871 cmdline_fixed_string_t on_off;
10874 /* Common CLI fields for vf vlan anti spoof enable disable */
10875 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10876 TOKEN_STRING_INITIALIZER
10877 (struct cmd_vf_vlan_anti_spoof_result,
10879 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10880 TOKEN_STRING_INITIALIZER
10881 (struct cmd_vf_vlan_anti_spoof_result,
10883 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10884 TOKEN_STRING_INITIALIZER
10885 (struct cmd_vf_vlan_anti_spoof_result,
10887 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10888 TOKEN_STRING_INITIALIZER
10889 (struct cmd_vf_vlan_anti_spoof_result,
10890 antispoof, "antispoof");
10891 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10892 TOKEN_NUM_INITIALIZER
10893 (struct cmd_vf_vlan_anti_spoof_result,
10894 port_id, RTE_UINT16);
10895 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10896 TOKEN_NUM_INITIALIZER
10897 (struct cmd_vf_vlan_anti_spoof_result,
10898 vf_id, RTE_UINT32);
10899 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10900 TOKEN_STRING_INITIALIZER
10901 (struct cmd_vf_vlan_anti_spoof_result,
10905 cmd_set_vf_vlan_anti_spoof_parsed(
10906 void *parsed_result,
10907 __rte_unused struct cmdline *cl,
10908 __rte_unused void *data)
10910 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10911 int ret = -ENOTSUP;
10913 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10915 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10918 #ifdef RTE_NET_IXGBE
10919 if (ret == -ENOTSUP)
10920 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10921 res->vf_id, is_on);
10923 #ifdef RTE_NET_I40E
10924 if (ret == -ENOTSUP)
10925 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10926 res->vf_id, is_on);
10928 #ifdef RTE_NET_BNXT
10929 if (ret == -ENOTSUP)
10930 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10931 res->vf_id, is_on);
10938 printf("invalid vf_id %d\n", res->vf_id);
10941 printf("invalid port_id %d\n", res->port_id);
10944 printf("function not implemented\n");
10947 printf("programming error: (%s)\n", strerror(-ret));
10951 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10952 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10954 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10956 (void *)&cmd_vf_vlan_anti_spoof_set,
10957 (void *)&cmd_vf_vlan_anti_spoof_vf,
10958 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10959 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10960 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10961 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10962 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10967 /* vf mac anti spoof configuration */
10969 /* Common result structure for vf mac anti spoof */
10970 struct cmd_vf_mac_anti_spoof_result {
10971 cmdline_fixed_string_t set;
10972 cmdline_fixed_string_t vf;
10973 cmdline_fixed_string_t mac;
10974 cmdline_fixed_string_t antispoof;
10977 cmdline_fixed_string_t on_off;
10980 /* Common CLI fields for vf mac anti spoof enable disable */
10981 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10982 TOKEN_STRING_INITIALIZER
10983 (struct cmd_vf_mac_anti_spoof_result,
10985 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10986 TOKEN_STRING_INITIALIZER
10987 (struct cmd_vf_mac_anti_spoof_result,
10989 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10990 TOKEN_STRING_INITIALIZER
10991 (struct cmd_vf_mac_anti_spoof_result,
10993 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10994 TOKEN_STRING_INITIALIZER
10995 (struct cmd_vf_mac_anti_spoof_result,
10996 antispoof, "antispoof");
10997 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10998 TOKEN_NUM_INITIALIZER
10999 (struct cmd_vf_mac_anti_spoof_result,
11000 port_id, RTE_UINT16);
11001 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11002 TOKEN_NUM_INITIALIZER
11003 (struct cmd_vf_mac_anti_spoof_result,
11004 vf_id, RTE_UINT32);
11005 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11006 TOKEN_STRING_INITIALIZER
11007 (struct cmd_vf_mac_anti_spoof_result,
11011 cmd_set_vf_mac_anti_spoof_parsed(
11012 void *parsed_result,
11013 __rte_unused struct cmdline *cl,
11014 __rte_unused void *data)
11016 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11017 int ret = -ENOTSUP;
11019 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11021 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11024 #ifdef RTE_NET_IXGBE
11025 if (ret == -ENOTSUP)
11026 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11027 res->vf_id, is_on);
11029 #ifdef RTE_NET_I40E
11030 if (ret == -ENOTSUP)
11031 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11032 res->vf_id, is_on);
11034 #ifdef RTE_NET_BNXT
11035 if (ret == -ENOTSUP)
11036 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11037 res->vf_id, is_on);
11044 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11047 printf("invalid port_id %d\n", res->port_id);
11050 printf("function not implemented\n");
11053 printf("programming error: (%s)\n", strerror(-ret));
11057 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11058 .f = cmd_set_vf_mac_anti_spoof_parsed,
11060 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11062 (void *)&cmd_vf_mac_anti_spoof_set,
11063 (void *)&cmd_vf_mac_anti_spoof_vf,
11064 (void *)&cmd_vf_mac_anti_spoof_mac,
11065 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11066 (void *)&cmd_vf_mac_anti_spoof_port_id,
11067 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11068 (void *)&cmd_vf_mac_anti_spoof_on_off,
11073 /* vf vlan strip queue configuration */
11075 /* Common result structure for vf mac anti spoof */
11076 struct cmd_vf_vlan_stripq_result {
11077 cmdline_fixed_string_t set;
11078 cmdline_fixed_string_t vf;
11079 cmdline_fixed_string_t vlan;
11080 cmdline_fixed_string_t stripq;
11083 cmdline_fixed_string_t on_off;
11086 /* Common CLI fields for vf vlan strip enable disable */
11087 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11088 TOKEN_STRING_INITIALIZER
11089 (struct cmd_vf_vlan_stripq_result,
11091 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11092 TOKEN_STRING_INITIALIZER
11093 (struct cmd_vf_vlan_stripq_result,
11095 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11096 TOKEN_STRING_INITIALIZER
11097 (struct cmd_vf_vlan_stripq_result,
11099 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11100 TOKEN_STRING_INITIALIZER
11101 (struct cmd_vf_vlan_stripq_result,
11103 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11104 TOKEN_NUM_INITIALIZER
11105 (struct cmd_vf_vlan_stripq_result,
11106 port_id, RTE_UINT16);
11107 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11108 TOKEN_NUM_INITIALIZER
11109 (struct cmd_vf_vlan_stripq_result,
11110 vf_id, RTE_UINT16);
11111 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11112 TOKEN_STRING_INITIALIZER
11113 (struct cmd_vf_vlan_stripq_result,
11117 cmd_set_vf_vlan_stripq_parsed(
11118 void *parsed_result,
11119 __rte_unused struct cmdline *cl,
11120 __rte_unused void *data)
11122 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11123 int ret = -ENOTSUP;
11125 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11127 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11130 #ifdef RTE_NET_IXGBE
11131 if (ret == -ENOTSUP)
11132 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11133 res->vf_id, is_on);
11135 #ifdef RTE_NET_I40E
11136 if (ret == -ENOTSUP)
11137 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11138 res->vf_id, is_on);
11140 #ifdef RTE_NET_BNXT
11141 if (ret == -ENOTSUP)
11142 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11143 res->vf_id, is_on);
11150 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11153 printf("invalid port_id %d\n", res->port_id);
11156 printf("function not implemented\n");
11159 printf("programming error: (%s)\n", strerror(-ret));
11163 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11164 .f = cmd_set_vf_vlan_stripq_parsed,
11166 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11168 (void *)&cmd_vf_vlan_stripq_set,
11169 (void *)&cmd_vf_vlan_stripq_vf,
11170 (void *)&cmd_vf_vlan_stripq_vlan,
11171 (void *)&cmd_vf_vlan_stripq_stripq,
11172 (void *)&cmd_vf_vlan_stripq_port_id,
11173 (void *)&cmd_vf_vlan_stripq_vf_id,
11174 (void *)&cmd_vf_vlan_stripq_on_off,
11179 /* vf vlan insert configuration */
11181 /* Common result structure for vf vlan insert */
11182 struct cmd_vf_vlan_insert_result {
11183 cmdline_fixed_string_t set;
11184 cmdline_fixed_string_t vf;
11185 cmdline_fixed_string_t vlan;
11186 cmdline_fixed_string_t insert;
11192 /* Common CLI fields for vf vlan insert enable disable */
11193 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11194 TOKEN_STRING_INITIALIZER
11195 (struct cmd_vf_vlan_insert_result,
11197 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11198 TOKEN_STRING_INITIALIZER
11199 (struct cmd_vf_vlan_insert_result,
11201 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11202 TOKEN_STRING_INITIALIZER
11203 (struct cmd_vf_vlan_insert_result,
11205 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11206 TOKEN_STRING_INITIALIZER
11207 (struct cmd_vf_vlan_insert_result,
11209 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11210 TOKEN_NUM_INITIALIZER
11211 (struct cmd_vf_vlan_insert_result,
11212 port_id, RTE_UINT16);
11213 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11214 TOKEN_NUM_INITIALIZER
11215 (struct cmd_vf_vlan_insert_result,
11216 vf_id, RTE_UINT16);
11217 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11218 TOKEN_NUM_INITIALIZER
11219 (struct cmd_vf_vlan_insert_result,
11220 vlan_id, RTE_UINT16);
11223 cmd_set_vf_vlan_insert_parsed(
11224 void *parsed_result,
11225 __rte_unused struct cmdline *cl,
11226 __rte_unused void *data)
11228 struct cmd_vf_vlan_insert_result *res = parsed_result;
11229 int ret = -ENOTSUP;
11231 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11234 #ifdef RTE_NET_IXGBE
11235 if (ret == -ENOTSUP)
11236 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11239 #ifdef RTE_NET_I40E
11240 if (ret == -ENOTSUP)
11241 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11244 #ifdef RTE_NET_BNXT
11245 if (ret == -ENOTSUP)
11246 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11254 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11257 printf("invalid port_id %d\n", res->port_id);
11260 printf("function not implemented\n");
11263 printf("programming error: (%s)\n", strerror(-ret));
11267 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11268 .f = cmd_set_vf_vlan_insert_parsed,
11270 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11272 (void *)&cmd_vf_vlan_insert_set,
11273 (void *)&cmd_vf_vlan_insert_vf,
11274 (void *)&cmd_vf_vlan_insert_vlan,
11275 (void *)&cmd_vf_vlan_insert_insert,
11276 (void *)&cmd_vf_vlan_insert_port_id,
11277 (void *)&cmd_vf_vlan_insert_vf_id,
11278 (void *)&cmd_vf_vlan_insert_vlan_id,
11283 /* tx loopback configuration */
11285 /* Common result structure for tx loopback */
11286 struct cmd_tx_loopback_result {
11287 cmdline_fixed_string_t set;
11288 cmdline_fixed_string_t tx;
11289 cmdline_fixed_string_t loopback;
11291 cmdline_fixed_string_t on_off;
11294 /* Common CLI fields for tx loopback enable disable */
11295 cmdline_parse_token_string_t cmd_tx_loopback_set =
11296 TOKEN_STRING_INITIALIZER
11297 (struct cmd_tx_loopback_result,
11299 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11300 TOKEN_STRING_INITIALIZER
11301 (struct cmd_tx_loopback_result,
11303 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11304 TOKEN_STRING_INITIALIZER
11305 (struct cmd_tx_loopback_result,
11306 loopback, "loopback");
11307 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11308 TOKEN_NUM_INITIALIZER
11309 (struct cmd_tx_loopback_result,
11310 port_id, RTE_UINT16);
11311 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11312 TOKEN_STRING_INITIALIZER
11313 (struct cmd_tx_loopback_result,
11317 cmd_set_tx_loopback_parsed(
11318 void *parsed_result,
11319 __rte_unused struct cmdline *cl,
11320 __rte_unused void *data)
11322 struct cmd_tx_loopback_result *res = parsed_result;
11323 int ret = -ENOTSUP;
11325 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11327 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11330 #ifdef RTE_NET_IXGBE
11331 if (ret == -ENOTSUP)
11332 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11334 #ifdef RTE_NET_I40E
11335 if (ret == -ENOTSUP)
11336 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11338 #ifdef RTE_NET_BNXT
11339 if (ret == -ENOTSUP)
11340 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11342 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11343 if (ret == -ENOTSUP)
11344 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11351 printf("invalid is_on %d\n", is_on);
11354 printf("invalid port_id %d\n", res->port_id);
11357 printf("function not implemented\n");
11360 printf("programming error: (%s)\n", strerror(-ret));
11364 cmdline_parse_inst_t cmd_set_tx_loopback = {
11365 .f = cmd_set_tx_loopback_parsed,
11367 .help_str = "set tx loopback <port_id> on|off",
11369 (void *)&cmd_tx_loopback_set,
11370 (void *)&cmd_tx_loopback_tx,
11371 (void *)&cmd_tx_loopback_loopback,
11372 (void *)&cmd_tx_loopback_port_id,
11373 (void *)&cmd_tx_loopback_on_off,
11378 /* all queues drop enable configuration */
11380 /* Common result structure for all queues drop enable */
11381 struct cmd_all_queues_drop_en_result {
11382 cmdline_fixed_string_t set;
11383 cmdline_fixed_string_t all;
11384 cmdline_fixed_string_t queues;
11385 cmdline_fixed_string_t drop;
11387 cmdline_fixed_string_t on_off;
11390 /* Common CLI fields for tx loopback enable disable */
11391 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11392 TOKEN_STRING_INITIALIZER
11393 (struct cmd_all_queues_drop_en_result,
11395 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11396 TOKEN_STRING_INITIALIZER
11397 (struct cmd_all_queues_drop_en_result,
11399 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11400 TOKEN_STRING_INITIALIZER
11401 (struct cmd_all_queues_drop_en_result,
11403 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11404 TOKEN_STRING_INITIALIZER
11405 (struct cmd_all_queues_drop_en_result,
11407 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11408 TOKEN_NUM_INITIALIZER
11409 (struct cmd_all_queues_drop_en_result,
11410 port_id, RTE_UINT16);
11411 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11412 TOKEN_STRING_INITIALIZER
11413 (struct cmd_all_queues_drop_en_result,
11417 cmd_set_all_queues_drop_en_parsed(
11418 void *parsed_result,
11419 __rte_unused struct cmdline *cl,
11420 __rte_unused void *data)
11422 struct cmd_all_queues_drop_en_result *res = parsed_result;
11423 int ret = -ENOTSUP;
11424 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11426 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11429 #ifdef RTE_NET_IXGBE
11430 if (ret == -ENOTSUP)
11431 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11433 #ifdef RTE_NET_BNXT
11434 if (ret == -ENOTSUP)
11435 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11441 printf("invalid is_on %d\n", is_on);
11444 printf("invalid port_id %d\n", res->port_id);
11447 printf("function not implemented\n");
11450 printf("programming error: (%s)\n", strerror(-ret));
11454 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11455 .f = cmd_set_all_queues_drop_en_parsed,
11457 .help_str = "set all queues drop <port_id> on|off",
11459 (void *)&cmd_all_queues_drop_en_set,
11460 (void *)&cmd_all_queues_drop_en_all,
11461 (void *)&cmd_all_queues_drop_en_queues,
11462 (void *)&cmd_all_queues_drop_en_drop,
11463 (void *)&cmd_all_queues_drop_en_port_id,
11464 (void *)&cmd_all_queues_drop_en_on_off,
11469 /* vf split drop enable configuration */
11471 /* Common result structure for vf split drop enable */
11472 struct cmd_vf_split_drop_en_result {
11473 cmdline_fixed_string_t set;
11474 cmdline_fixed_string_t vf;
11475 cmdline_fixed_string_t split;
11476 cmdline_fixed_string_t drop;
11479 cmdline_fixed_string_t on_off;
11482 /* Common CLI fields for vf split drop enable disable */
11483 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11484 TOKEN_STRING_INITIALIZER
11485 (struct cmd_vf_split_drop_en_result,
11487 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11488 TOKEN_STRING_INITIALIZER
11489 (struct cmd_vf_split_drop_en_result,
11491 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11492 TOKEN_STRING_INITIALIZER
11493 (struct cmd_vf_split_drop_en_result,
11495 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11496 TOKEN_STRING_INITIALIZER
11497 (struct cmd_vf_split_drop_en_result,
11499 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11500 TOKEN_NUM_INITIALIZER
11501 (struct cmd_vf_split_drop_en_result,
11502 port_id, RTE_UINT16);
11503 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11504 TOKEN_NUM_INITIALIZER
11505 (struct cmd_vf_split_drop_en_result,
11506 vf_id, RTE_UINT16);
11507 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11508 TOKEN_STRING_INITIALIZER
11509 (struct cmd_vf_split_drop_en_result,
11513 cmd_set_vf_split_drop_en_parsed(
11514 void *parsed_result,
11515 __rte_unused struct cmdline *cl,
11516 __rte_unused void *data)
11518 struct cmd_vf_split_drop_en_result *res = parsed_result;
11519 int ret = -ENOTSUP;
11520 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11522 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11525 #ifdef RTE_NET_IXGBE
11526 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11533 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11536 printf("invalid port_id %d\n", res->port_id);
11539 printf("not supported on port %d\n", res->port_id);
11542 printf("programming error: (%s)\n", strerror(-ret));
11546 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11547 .f = cmd_set_vf_split_drop_en_parsed,
11549 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11551 (void *)&cmd_vf_split_drop_en_set,
11552 (void *)&cmd_vf_split_drop_en_vf,
11553 (void *)&cmd_vf_split_drop_en_split,
11554 (void *)&cmd_vf_split_drop_en_drop,
11555 (void *)&cmd_vf_split_drop_en_port_id,
11556 (void *)&cmd_vf_split_drop_en_vf_id,
11557 (void *)&cmd_vf_split_drop_en_on_off,
11562 /* vf mac address configuration */
11564 /* Common result structure for vf mac address */
11565 struct cmd_set_vf_mac_addr_result {
11566 cmdline_fixed_string_t set;
11567 cmdline_fixed_string_t vf;
11568 cmdline_fixed_string_t mac;
11569 cmdline_fixed_string_t addr;
11572 struct rte_ether_addr mac_addr;
11576 /* Common CLI fields for vf split drop enable disable */
11577 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11578 TOKEN_STRING_INITIALIZER
11579 (struct cmd_set_vf_mac_addr_result,
11581 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11582 TOKEN_STRING_INITIALIZER
11583 (struct cmd_set_vf_mac_addr_result,
11585 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11586 TOKEN_STRING_INITIALIZER
11587 (struct cmd_set_vf_mac_addr_result,
11589 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11590 TOKEN_STRING_INITIALIZER
11591 (struct cmd_set_vf_mac_addr_result,
11593 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11594 TOKEN_NUM_INITIALIZER
11595 (struct cmd_set_vf_mac_addr_result,
11596 port_id, RTE_UINT16);
11597 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11598 TOKEN_NUM_INITIALIZER
11599 (struct cmd_set_vf_mac_addr_result,
11600 vf_id, RTE_UINT16);
11601 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11602 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11606 cmd_set_vf_mac_addr_parsed(
11607 void *parsed_result,
11608 __rte_unused struct cmdline *cl,
11609 __rte_unused void *data)
11611 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11612 int ret = -ENOTSUP;
11614 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11617 #ifdef RTE_NET_IXGBE
11618 if (ret == -ENOTSUP)
11619 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11622 #ifdef RTE_NET_I40E
11623 if (ret == -ENOTSUP)
11624 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11627 #ifdef RTE_NET_BNXT
11628 if (ret == -ENOTSUP)
11629 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11637 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11640 printf("invalid port_id %d\n", res->port_id);
11643 printf("function not implemented\n");
11646 printf("programming error: (%s)\n", strerror(-ret));
11650 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11651 .f = cmd_set_vf_mac_addr_parsed,
11653 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11655 (void *)&cmd_set_vf_mac_addr_set,
11656 (void *)&cmd_set_vf_mac_addr_vf,
11657 (void *)&cmd_set_vf_mac_addr_mac,
11658 (void *)&cmd_set_vf_mac_addr_addr,
11659 (void *)&cmd_set_vf_mac_addr_port_id,
11660 (void *)&cmd_set_vf_mac_addr_vf_id,
11661 (void *)&cmd_set_vf_mac_addr_mac_addr,
11666 /* MACsec configuration */
11668 /* Common result structure for MACsec offload enable */
11669 struct cmd_macsec_offload_on_result {
11670 cmdline_fixed_string_t set;
11671 cmdline_fixed_string_t macsec;
11672 cmdline_fixed_string_t offload;
11674 cmdline_fixed_string_t on;
11675 cmdline_fixed_string_t encrypt;
11676 cmdline_fixed_string_t en_on_off;
11677 cmdline_fixed_string_t replay_protect;
11678 cmdline_fixed_string_t rp_on_off;
11681 /* Common CLI fields for MACsec offload disable */
11682 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11683 TOKEN_STRING_INITIALIZER
11684 (struct cmd_macsec_offload_on_result,
11686 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11687 TOKEN_STRING_INITIALIZER
11688 (struct cmd_macsec_offload_on_result,
11690 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11691 TOKEN_STRING_INITIALIZER
11692 (struct cmd_macsec_offload_on_result,
11693 offload, "offload");
11694 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11695 TOKEN_NUM_INITIALIZER
11696 (struct cmd_macsec_offload_on_result,
11697 port_id, RTE_UINT16);
11698 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11699 TOKEN_STRING_INITIALIZER
11700 (struct cmd_macsec_offload_on_result,
11702 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11703 TOKEN_STRING_INITIALIZER
11704 (struct cmd_macsec_offload_on_result,
11705 encrypt, "encrypt");
11706 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11707 TOKEN_STRING_INITIALIZER
11708 (struct cmd_macsec_offload_on_result,
11709 en_on_off, "on#off");
11710 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11711 TOKEN_STRING_INITIALIZER
11712 (struct cmd_macsec_offload_on_result,
11713 replay_protect, "replay-protect");
11714 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11715 TOKEN_STRING_INITIALIZER
11716 (struct cmd_macsec_offload_on_result,
11717 rp_on_off, "on#off");
11720 cmd_set_macsec_offload_on_parsed(
11721 void *parsed_result,
11722 __rte_unused struct cmdline *cl,
11723 __rte_unused void *data)
11725 struct cmd_macsec_offload_on_result *res = parsed_result;
11726 int ret = -ENOTSUP;
11727 portid_t port_id = res->port_id;
11728 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11729 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11730 struct rte_eth_dev_info dev_info;
11732 if (port_id_is_invalid(port_id, ENABLED_WARN))
11734 if (!port_is_stopped(port_id)) {
11735 printf("Please stop port %d first\n", port_id);
11739 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11743 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11744 #ifdef RTE_NET_IXGBE
11745 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11753 ports[port_id].dev_conf.txmode.offloads |=
11754 DEV_TX_OFFLOAD_MACSEC_INSERT;
11755 cmd_reconfig_device_queue(port_id, 1, 1);
11758 printf("invalid port_id %d\n", port_id);
11761 printf("not supported on port %d\n", port_id);
11764 printf("programming error: (%s)\n", strerror(-ret));
11768 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11769 .f = cmd_set_macsec_offload_on_parsed,
11771 .help_str = "set macsec offload <port_id> on "
11772 "encrypt on|off replay-protect on|off",
11774 (void *)&cmd_macsec_offload_on_set,
11775 (void *)&cmd_macsec_offload_on_macsec,
11776 (void *)&cmd_macsec_offload_on_offload,
11777 (void *)&cmd_macsec_offload_on_port_id,
11778 (void *)&cmd_macsec_offload_on_on,
11779 (void *)&cmd_macsec_offload_on_encrypt,
11780 (void *)&cmd_macsec_offload_on_en_on_off,
11781 (void *)&cmd_macsec_offload_on_replay_protect,
11782 (void *)&cmd_macsec_offload_on_rp_on_off,
11787 /* Common result structure for MACsec offload disable */
11788 struct cmd_macsec_offload_off_result {
11789 cmdline_fixed_string_t set;
11790 cmdline_fixed_string_t macsec;
11791 cmdline_fixed_string_t offload;
11793 cmdline_fixed_string_t off;
11796 /* Common CLI fields for MACsec offload disable */
11797 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11798 TOKEN_STRING_INITIALIZER
11799 (struct cmd_macsec_offload_off_result,
11801 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11802 TOKEN_STRING_INITIALIZER
11803 (struct cmd_macsec_offload_off_result,
11805 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11806 TOKEN_STRING_INITIALIZER
11807 (struct cmd_macsec_offload_off_result,
11808 offload, "offload");
11809 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11810 TOKEN_NUM_INITIALIZER
11811 (struct cmd_macsec_offload_off_result,
11812 port_id, RTE_UINT16);
11813 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_macsec_offload_off_result,
11819 cmd_set_macsec_offload_off_parsed(
11820 void *parsed_result,
11821 __rte_unused struct cmdline *cl,
11822 __rte_unused void *data)
11824 struct cmd_macsec_offload_off_result *res = parsed_result;
11825 int ret = -ENOTSUP;
11826 struct rte_eth_dev_info dev_info;
11827 portid_t port_id = res->port_id;
11829 if (port_id_is_invalid(port_id, ENABLED_WARN))
11831 if (!port_is_stopped(port_id)) {
11832 printf("Please stop port %d first\n", port_id);
11836 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11840 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11841 #ifdef RTE_NET_IXGBE
11842 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11847 ports[port_id].dev_conf.txmode.offloads &=
11848 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11849 cmd_reconfig_device_queue(port_id, 1, 1);
11852 printf("invalid port_id %d\n", port_id);
11855 printf("not supported on port %d\n", port_id);
11858 printf("programming error: (%s)\n", strerror(-ret));
11862 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11863 .f = cmd_set_macsec_offload_off_parsed,
11865 .help_str = "set macsec offload <port_id> off",
11867 (void *)&cmd_macsec_offload_off_set,
11868 (void *)&cmd_macsec_offload_off_macsec,
11869 (void *)&cmd_macsec_offload_off_offload,
11870 (void *)&cmd_macsec_offload_off_port_id,
11871 (void *)&cmd_macsec_offload_off_off,
11876 /* Common result structure for MACsec secure connection configure */
11877 struct cmd_macsec_sc_result {
11878 cmdline_fixed_string_t set;
11879 cmdline_fixed_string_t macsec;
11880 cmdline_fixed_string_t sc;
11881 cmdline_fixed_string_t tx_rx;
11883 struct rte_ether_addr mac;
11887 /* Common CLI fields for MACsec secure connection configure */
11888 cmdline_parse_token_string_t cmd_macsec_sc_set =
11889 TOKEN_STRING_INITIALIZER
11890 (struct cmd_macsec_sc_result,
11892 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11893 TOKEN_STRING_INITIALIZER
11894 (struct cmd_macsec_sc_result,
11896 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11897 TOKEN_STRING_INITIALIZER
11898 (struct cmd_macsec_sc_result,
11900 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11901 TOKEN_STRING_INITIALIZER
11902 (struct cmd_macsec_sc_result,
11904 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11905 TOKEN_NUM_INITIALIZER
11906 (struct cmd_macsec_sc_result,
11907 port_id, RTE_UINT16);
11908 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11909 TOKEN_ETHERADDR_INITIALIZER
11910 (struct cmd_macsec_sc_result,
11912 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11913 TOKEN_NUM_INITIALIZER
11914 (struct cmd_macsec_sc_result,
11918 cmd_set_macsec_sc_parsed(
11919 void *parsed_result,
11920 __rte_unused struct cmdline *cl,
11921 __rte_unused void *data)
11923 struct cmd_macsec_sc_result *res = parsed_result;
11924 int ret = -ENOTSUP;
11925 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11927 #ifdef RTE_NET_IXGBE
11929 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11930 res->mac.addr_bytes) :
11931 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11932 res->mac.addr_bytes, res->pi);
11934 RTE_SET_USED(is_tx);
11940 printf("invalid port_id %d\n", res->port_id);
11943 printf("not supported on port %d\n", res->port_id);
11946 printf("programming error: (%s)\n", strerror(-ret));
11950 cmdline_parse_inst_t cmd_set_macsec_sc = {
11951 .f = cmd_set_macsec_sc_parsed,
11953 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11955 (void *)&cmd_macsec_sc_set,
11956 (void *)&cmd_macsec_sc_macsec,
11957 (void *)&cmd_macsec_sc_sc,
11958 (void *)&cmd_macsec_sc_tx_rx,
11959 (void *)&cmd_macsec_sc_port_id,
11960 (void *)&cmd_macsec_sc_mac,
11961 (void *)&cmd_macsec_sc_pi,
11966 /* Common result structure for MACsec secure connection configure */
11967 struct cmd_macsec_sa_result {
11968 cmdline_fixed_string_t set;
11969 cmdline_fixed_string_t macsec;
11970 cmdline_fixed_string_t sa;
11971 cmdline_fixed_string_t tx_rx;
11976 cmdline_fixed_string_t key;
11979 /* Common CLI fields for MACsec secure connection configure */
11980 cmdline_parse_token_string_t cmd_macsec_sa_set =
11981 TOKEN_STRING_INITIALIZER
11982 (struct cmd_macsec_sa_result,
11984 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11985 TOKEN_STRING_INITIALIZER
11986 (struct cmd_macsec_sa_result,
11988 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11989 TOKEN_STRING_INITIALIZER
11990 (struct cmd_macsec_sa_result,
11992 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11993 TOKEN_STRING_INITIALIZER
11994 (struct cmd_macsec_sa_result,
11996 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11997 TOKEN_NUM_INITIALIZER
11998 (struct cmd_macsec_sa_result,
11999 port_id, RTE_UINT16);
12000 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12001 TOKEN_NUM_INITIALIZER
12002 (struct cmd_macsec_sa_result,
12004 cmdline_parse_token_num_t cmd_macsec_sa_an =
12005 TOKEN_NUM_INITIALIZER
12006 (struct cmd_macsec_sa_result,
12008 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12009 TOKEN_NUM_INITIALIZER
12010 (struct cmd_macsec_sa_result,
12012 cmdline_parse_token_string_t cmd_macsec_sa_key =
12013 TOKEN_STRING_INITIALIZER
12014 (struct cmd_macsec_sa_result,
12018 cmd_set_macsec_sa_parsed(
12019 void *parsed_result,
12020 __rte_unused struct cmdline *cl,
12021 __rte_unused void *data)
12023 struct cmd_macsec_sa_result *res = parsed_result;
12024 int ret = -ENOTSUP;
12025 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12026 uint8_t key[16] = { 0 };
12032 key_len = strlen(res->key) / 2;
12036 for (i = 0; i < key_len; i++) {
12037 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12040 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12043 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12046 #ifdef RTE_NET_IXGBE
12048 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12049 res->idx, res->an, res->pn, key) :
12050 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12051 res->idx, res->an, res->pn, key);
12053 RTE_SET_USED(is_tx);
12060 printf("invalid idx %d or an %d\n", res->idx, res->an);
12063 printf("invalid port_id %d\n", res->port_id);
12066 printf("not supported on port %d\n", res->port_id);
12069 printf("programming error: (%s)\n", strerror(-ret));
12073 cmdline_parse_inst_t cmd_set_macsec_sa = {
12074 .f = cmd_set_macsec_sa_parsed,
12076 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12078 (void *)&cmd_macsec_sa_set,
12079 (void *)&cmd_macsec_sa_macsec,
12080 (void *)&cmd_macsec_sa_sa,
12081 (void *)&cmd_macsec_sa_tx_rx,
12082 (void *)&cmd_macsec_sa_port_id,
12083 (void *)&cmd_macsec_sa_idx,
12084 (void *)&cmd_macsec_sa_an,
12085 (void *)&cmd_macsec_sa_pn,
12086 (void *)&cmd_macsec_sa_key,
12091 /* VF unicast promiscuous mode configuration */
12093 /* Common result structure for VF unicast promiscuous mode */
12094 struct cmd_vf_promisc_result {
12095 cmdline_fixed_string_t set;
12096 cmdline_fixed_string_t vf;
12097 cmdline_fixed_string_t promisc;
12100 cmdline_fixed_string_t on_off;
12103 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12104 cmdline_parse_token_string_t cmd_vf_promisc_set =
12105 TOKEN_STRING_INITIALIZER
12106 (struct cmd_vf_promisc_result,
12108 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12109 TOKEN_STRING_INITIALIZER
12110 (struct cmd_vf_promisc_result,
12112 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12113 TOKEN_STRING_INITIALIZER
12114 (struct cmd_vf_promisc_result,
12115 promisc, "promisc");
12116 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12117 TOKEN_NUM_INITIALIZER
12118 (struct cmd_vf_promisc_result,
12119 port_id, RTE_UINT16);
12120 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12121 TOKEN_NUM_INITIALIZER
12122 (struct cmd_vf_promisc_result,
12123 vf_id, RTE_UINT32);
12124 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12125 TOKEN_STRING_INITIALIZER
12126 (struct cmd_vf_promisc_result,
12130 cmd_set_vf_promisc_parsed(
12131 void *parsed_result,
12132 __rte_unused struct cmdline *cl,
12133 __rte_unused void *data)
12135 struct cmd_vf_promisc_result *res = parsed_result;
12136 int ret = -ENOTSUP;
12138 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12140 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12143 #ifdef RTE_NET_I40E
12144 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12145 res->vf_id, is_on);
12152 printf("invalid vf_id %d\n", res->vf_id);
12155 printf("invalid port_id %d\n", res->port_id);
12158 printf("function not implemented\n");
12161 printf("programming error: (%s)\n", strerror(-ret));
12165 cmdline_parse_inst_t cmd_set_vf_promisc = {
12166 .f = cmd_set_vf_promisc_parsed,
12168 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12169 "Set unicast promiscuous mode for a VF from the PF",
12171 (void *)&cmd_vf_promisc_set,
12172 (void *)&cmd_vf_promisc_vf,
12173 (void *)&cmd_vf_promisc_promisc,
12174 (void *)&cmd_vf_promisc_port_id,
12175 (void *)&cmd_vf_promisc_vf_id,
12176 (void *)&cmd_vf_promisc_on_off,
12181 /* VF multicast promiscuous mode configuration */
12183 /* Common result structure for VF multicast promiscuous mode */
12184 struct cmd_vf_allmulti_result {
12185 cmdline_fixed_string_t set;
12186 cmdline_fixed_string_t vf;
12187 cmdline_fixed_string_t allmulti;
12190 cmdline_fixed_string_t on_off;
12193 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12194 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12195 TOKEN_STRING_INITIALIZER
12196 (struct cmd_vf_allmulti_result,
12198 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12199 TOKEN_STRING_INITIALIZER
12200 (struct cmd_vf_allmulti_result,
12202 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12203 TOKEN_STRING_INITIALIZER
12204 (struct cmd_vf_allmulti_result,
12205 allmulti, "allmulti");
12206 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12207 TOKEN_NUM_INITIALIZER
12208 (struct cmd_vf_allmulti_result,
12209 port_id, RTE_UINT16);
12210 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12211 TOKEN_NUM_INITIALIZER
12212 (struct cmd_vf_allmulti_result,
12213 vf_id, RTE_UINT32);
12214 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12215 TOKEN_STRING_INITIALIZER
12216 (struct cmd_vf_allmulti_result,
12220 cmd_set_vf_allmulti_parsed(
12221 void *parsed_result,
12222 __rte_unused struct cmdline *cl,
12223 __rte_unused void *data)
12225 struct cmd_vf_allmulti_result *res = parsed_result;
12226 int ret = -ENOTSUP;
12228 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12230 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12233 #ifdef RTE_NET_I40E
12234 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12235 res->vf_id, is_on);
12242 printf("invalid vf_id %d\n", res->vf_id);
12245 printf("invalid port_id %d\n", res->port_id);
12248 printf("function not implemented\n");
12251 printf("programming error: (%s)\n", strerror(-ret));
12255 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12256 .f = cmd_set_vf_allmulti_parsed,
12258 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12259 "Set multicast promiscuous mode for a VF from the PF",
12261 (void *)&cmd_vf_allmulti_set,
12262 (void *)&cmd_vf_allmulti_vf,
12263 (void *)&cmd_vf_allmulti_allmulti,
12264 (void *)&cmd_vf_allmulti_port_id,
12265 (void *)&cmd_vf_allmulti_vf_id,
12266 (void *)&cmd_vf_allmulti_on_off,
12271 /* vf broadcast mode configuration */
12273 /* Common result structure for vf broadcast */
12274 struct cmd_set_vf_broadcast_result {
12275 cmdline_fixed_string_t set;
12276 cmdline_fixed_string_t vf;
12277 cmdline_fixed_string_t broadcast;
12280 cmdline_fixed_string_t on_off;
12283 /* Common CLI fields for vf broadcast enable disable */
12284 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12285 TOKEN_STRING_INITIALIZER
12286 (struct cmd_set_vf_broadcast_result,
12288 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12289 TOKEN_STRING_INITIALIZER
12290 (struct cmd_set_vf_broadcast_result,
12292 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12293 TOKEN_STRING_INITIALIZER
12294 (struct cmd_set_vf_broadcast_result,
12295 broadcast, "broadcast");
12296 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12297 TOKEN_NUM_INITIALIZER
12298 (struct cmd_set_vf_broadcast_result,
12299 port_id, RTE_UINT16);
12300 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12301 TOKEN_NUM_INITIALIZER
12302 (struct cmd_set_vf_broadcast_result,
12303 vf_id, RTE_UINT16);
12304 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12305 TOKEN_STRING_INITIALIZER
12306 (struct cmd_set_vf_broadcast_result,
12310 cmd_set_vf_broadcast_parsed(
12311 void *parsed_result,
12312 __rte_unused struct cmdline *cl,
12313 __rte_unused void *data)
12315 struct cmd_set_vf_broadcast_result *res = parsed_result;
12316 int ret = -ENOTSUP;
12318 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12320 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12323 #ifdef RTE_NET_I40E
12324 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12325 res->vf_id, is_on);
12332 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12335 printf("invalid port_id %d\n", res->port_id);
12338 printf("function not implemented\n");
12341 printf("programming error: (%s)\n", strerror(-ret));
12345 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12346 .f = cmd_set_vf_broadcast_parsed,
12348 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12350 (void *)&cmd_set_vf_broadcast_set,
12351 (void *)&cmd_set_vf_broadcast_vf,
12352 (void *)&cmd_set_vf_broadcast_broadcast,
12353 (void *)&cmd_set_vf_broadcast_port_id,
12354 (void *)&cmd_set_vf_broadcast_vf_id,
12355 (void *)&cmd_set_vf_broadcast_on_off,
12360 /* vf vlan tag configuration */
12362 /* Common result structure for vf vlan tag */
12363 struct cmd_set_vf_vlan_tag_result {
12364 cmdline_fixed_string_t set;
12365 cmdline_fixed_string_t vf;
12366 cmdline_fixed_string_t vlan;
12367 cmdline_fixed_string_t tag;
12370 cmdline_fixed_string_t on_off;
12373 /* Common CLI fields for vf vlan tag enable disable */
12374 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12375 TOKEN_STRING_INITIALIZER
12376 (struct cmd_set_vf_vlan_tag_result,
12378 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12379 TOKEN_STRING_INITIALIZER
12380 (struct cmd_set_vf_vlan_tag_result,
12382 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12383 TOKEN_STRING_INITIALIZER
12384 (struct cmd_set_vf_vlan_tag_result,
12386 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12387 TOKEN_STRING_INITIALIZER
12388 (struct cmd_set_vf_vlan_tag_result,
12390 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12391 TOKEN_NUM_INITIALIZER
12392 (struct cmd_set_vf_vlan_tag_result,
12393 port_id, RTE_UINT16);
12394 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12395 TOKEN_NUM_INITIALIZER
12396 (struct cmd_set_vf_vlan_tag_result,
12397 vf_id, RTE_UINT16);
12398 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12399 TOKEN_STRING_INITIALIZER
12400 (struct cmd_set_vf_vlan_tag_result,
12404 cmd_set_vf_vlan_tag_parsed(
12405 void *parsed_result,
12406 __rte_unused struct cmdline *cl,
12407 __rte_unused void *data)
12409 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12410 int ret = -ENOTSUP;
12412 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12414 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12417 #ifdef RTE_NET_I40E
12418 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12419 res->vf_id, is_on);
12426 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12429 printf("invalid port_id %d\n", res->port_id);
12432 printf("function not implemented\n");
12435 printf("programming error: (%s)\n", strerror(-ret));
12439 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12440 .f = cmd_set_vf_vlan_tag_parsed,
12442 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12444 (void *)&cmd_set_vf_vlan_tag_set,
12445 (void *)&cmd_set_vf_vlan_tag_vf,
12446 (void *)&cmd_set_vf_vlan_tag_vlan,
12447 (void *)&cmd_set_vf_vlan_tag_tag,
12448 (void *)&cmd_set_vf_vlan_tag_port_id,
12449 (void *)&cmd_set_vf_vlan_tag_vf_id,
12450 (void *)&cmd_set_vf_vlan_tag_on_off,
12455 /* Common definition of VF and TC TX bandwidth configuration */
12456 struct cmd_vf_tc_bw_result {
12457 cmdline_fixed_string_t set;
12458 cmdline_fixed_string_t vf;
12459 cmdline_fixed_string_t tc;
12460 cmdline_fixed_string_t tx;
12461 cmdline_fixed_string_t min_bw;
12462 cmdline_fixed_string_t max_bw;
12463 cmdline_fixed_string_t strict_link_prio;
12468 cmdline_fixed_string_t bw_list;
12472 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12473 TOKEN_STRING_INITIALIZER
12474 (struct cmd_vf_tc_bw_result,
12476 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_vf_tc_bw_result,
12480 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12481 TOKEN_STRING_INITIALIZER
12482 (struct cmd_vf_tc_bw_result,
12484 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12485 TOKEN_STRING_INITIALIZER
12486 (struct cmd_vf_tc_bw_result,
12488 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_vf_tc_bw_result,
12491 strict_link_prio, "strict-link-priority");
12492 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12493 TOKEN_STRING_INITIALIZER
12494 (struct cmd_vf_tc_bw_result,
12495 min_bw, "min-bandwidth");
12496 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12497 TOKEN_STRING_INITIALIZER
12498 (struct cmd_vf_tc_bw_result,
12499 max_bw, "max-bandwidth");
12500 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12501 TOKEN_NUM_INITIALIZER
12502 (struct cmd_vf_tc_bw_result,
12503 port_id, RTE_UINT16);
12504 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12505 TOKEN_NUM_INITIALIZER
12506 (struct cmd_vf_tc_bw_result,
12507 vf_id, RTE_UINT16);
12508 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12509 TOKEN_NUM_INITIALIZER
12510 (struct cmd_vf_tc_bw_result,
12512 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12513 TOKEN_NUM_INITIALIZER
12514 (struct cmd_vf_tc_bw_result,
12516 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12517 TOKEN_STRING_INITIALIZER
12518 (struct cmd_vf_tc_bw_result,
12520 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12521 TOKEN_NUM_INITIALIZER
12522 (struct cmd_vf_tc_bw_result,
12523 tc_map, RTE_UINT8);
12525 /* VF max bandwidth setting */
12527 cmd_vf_max_bw_parsed(
12528 void *parsed_result,
12529 __rte_unused struct cmdline *cl,
12530 __rte_unused void *data)
12532 struct cmd_vf_tc_bw_result *res = parsed_result;
12533 int ret = -ENOTSUP;
12535 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12538 #ifdef RTE_NET_I40E
12539 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12540 res->vf_id, res->bw);
12547 printf("invalid vf_id %d or bandwidth %d\n",
12548 res->vf_id, res->bw);
12551 printf("invalid port_id %d\n", res->port_id);
12554 printf("function not implemented\n");
12557 printf("programming error: (%s)\n", strerror(-ret));
12561 cmdline_parse_inst_t cmd_vf_max_bw = {
12562 .f = cmd_vf_max_bw_parsed,
12564 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12566 (void *)&cmd_vf_tc_bw_set,
12567 (void *)&cmd_vf_tc_bw_vf,
12568 (void *)&cmd_vf_tc_bw_tx,
12569 (void *)&cmd_vf_tc_bw_max_bw,
12570 (void *)&cmd_vf_tc_bw_port_id,
12571 (void *)&cmd_vf_tc_bw_vf_id,
12572 (void *)&cmd_vf_tc_bw_bw,
12578 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12583 const char *p, *p0 = str;
12590 p = strchr(p0, '(');
12592 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12596 p0 = strchr(p, ')');
12598 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12602 if (size >= sizeof(s)) {
12603 printf("The string size exceeds the internal buffer size\n");
12606 snprintf(s, sizeof(s), "%.*s", size, p);
12607 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12609 printf("Failed to get the bandwidth list. ");
12613 for (i = 0; i < ret; i++)
12614 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12619 /* TC min bandwidth setting */
12621 cmd_vf_tc_min_bw_parsed(
12622 void *parsed_result,
12623 __rte_unused struct cmdline *cl,
12624 __rte_unused void *data)
12626 struct cmd_vf_tc_bw_result *res = parsed_result;
12629 int ret = -ENOTSUP;
12631 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12634 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12638 #ifdef RTE_NET_I40E
12639 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12647 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12650 printf("invalid port_id %d\n", res->port_id);
12653 printf("function not implemented\n");
12656 printf("programming error: (%s)\n", strerror(-ret));
12660 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12661 .f = cmd_vf_tc_min_bw_parsed,
12663 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12664 " <bw1, bw2, ...>",
12666 (void *)&cmd_vf_tc_bw_set,
12667 (void *)&cmd_vf_tc_bw_vf,
12668 (void *)&cmd_vf_tc_bw_tc,
12669 (void *)&cmd_vf_tc_bw_tx,
12670 (void *)&cmd_vf_tc_bw_min_bw,
12671 (void *)&cmd_vf_tc_bw_port_id,
12672 (void *)&cmd_vf_tc_bw_vf_id,
12673 (void *)&cmd_vf_tc_bw_bw_list,
12679 cmd_tc_min_bw_parsed(
12680 void *parsed_result,
12681 __rte_unused struct cmdline *cl,
12682 __rte_unused void *data)
12684 struct cmd_vf_tc_bw_result *res = parsed_result;
12685 struct rte_port *port;
12688 int ret = -ENOTSUP;
12690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12693 port = &ports[res->port_id];
12694 /** Check if the port is not started **/
12695 if (port->port_status != RTE_PORT_STOPPED) {
12696 printf("Please stop port %d first\n", res->port_id);
12700 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12704 #ifdef RTE_NET_IXGBE
12705 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12712 printf("invalid bandwidth\n");
12715 printf("invalid port_id %d\n", res->port_id);
12718 printf("function not implemented\n");
12721 printf("programming error: (%s)\n", strerror(-ret));
12725 cmdline_parse_inst_t cmd_tc_min_bw = {
12726 .f = cmd_tc_min_bw_parsed,
12728 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12730 (void *)&cmd_vf_tc_bw_set,
12731 (void *)&cmd_vf_tc_bw_tc,
12732 (void *)&cmd_vf_tc_bw_tx,
12733 (void *)&cmd_vf_tc_bw_min_bw,
12734 (void *)&cmd_vf_tc_bw_port_id,
12735 (void *)&cmd_vf_tc_bw_bw_list,
12740 /* TC max bandwidth setting */
12742 cmd_vf_tc_max_bw_parsed(
12743 void *parsed_result,
12744 __rte_unused struct cmdline *cl,
12745 __rte_unused void *data)
12747 struct cmd_vf_tc_bw_result *res = parsed_result;
12748 int ret = -ENOTSUP;
12750 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12753 #ifdef RTE_NET_I40E
12754 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12755 res->tc_no, res->bw);
12762 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12763 res->vf_id, res->tc_no, res->bw);
12766 printf("invalid port_id %d\n", res->port_id);
12769 printf("function not implemented\n");
12772 printf("programming error: (%s)\n", strerror(-ret));
12776 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12777 .f = cmd_vf_tc_max_bw_parsed,
12779 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12782 (void *)&cmd_vf_tc_bw_set,
12783 (void *)&cmd_vf_tc_bw_vf,
12784 (void *)&cmd_vf_tc_bw_tc,
12785 (void *)&cmd_vf_tc_bw_tx,
12786 (void *)&cmd_vf_tc_bw_max_bw,
12787 (void *)&cmd_vf_tc_bw_port_id,
12788 (void *)&cmd_vf_tc_bw_vf_id,
12789 (void *)&cmd_vf_tc_bw_tc_no,
12790 (void *)&cmd_vf_tc_bw_bw,
12795 /** Set VXLAN encapsulation details */
12796 struct cmd_set_vxlan_result {
12797 cmdline_fixed_string_t set;
12798 cmdline_fixed_string_t vxlan;
12799 cmdline_fixed_string_t pos_token;
12800 cmdline_fixed_string_t ip_version;
12801 uint32_t vlan_present:1;
12805 cmdline_ipaddr_t ip_src;
12806 cmdline_ipaddr_t ip_dst;
12810 struct rte_ether_addr eth_src;
12811 struct rte_ether_addr eth_dst;
12814 cmdline_parse_token_string_t cmd_set_vxlan_set =
12815 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12816 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12817 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12818 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12819 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12821 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12822 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12823 "vxlan-with-vlan");
12824 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12825 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12827 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12828 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12830 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12831 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12833 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12834 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12835 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12836 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12838 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12839 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12840 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12841 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12843 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12844 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12845 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12846 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12848 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12849 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12850 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12851 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12853 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12854 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12855 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12856 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12858 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12859 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12860 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12861 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12863 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12864 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12865 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12866 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12868 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12869 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12870 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12871 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12873 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12874 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12875 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12876 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12878 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12879 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12881 static void cmd_set_vxlan_parsed(void *parsed_result,
12882 __rte_unused struct cmdline *cl,
12883 __rte_unused void *data)
12885 struct cmd_set_vxlan_result *res = parsed_result;
12890 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12893 vxlan_encap_conf.select_tos_ttl = 0;
12894 if (strcmp(res->vxlan, "vxlan") == 0)
12895 vxlan_encap_conf.select_vlan = 0;
12896 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12897 vxlan_encap_conf.select_vlan = 1;
12898 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12899 vxlan_encap_conf.select_vlan = 0;
12900 vxlan_encap_conf.select_tos_ttl = 1;
12902 if (strcmp(res->ip_version, "ipv4") == 0)
12903 vxlan_encap_conf.select_ipv4 = 1;
12904 else if (strcmp(res->ip_version, "ipv6") == 0)
12905 vxlan_encap_conf.select_ipv4 = 0;
12908 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12909 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12910 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12911 vxlan_encap_conf.ip_tos = res->tos;
12912 vxlan_encap_conf.ip_ttl = res->ttl;
12913 if (vxlan_encap_conf.select_ipv4) {
12914 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12915 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12917 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12918 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12920 if (vxlan_encap_conf.select_vlan)
12921 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12922 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12923 RTE_ETHER_ADDR_LEN);
12924 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12925 RTE_ETHER_ADDR_LEN);
12928 cmdline_parse_inst_t cmd_set_vxlan = {
12929 .f = cmd_set_vxlan_parsed,
12931 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12932 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12933 " eth-src <eth-src> eth-dst <eth-dst>",
12935 (void *)&cmd_set_vxlan_set,
12936 (void *)&cmd_set_vxlan_vxlan,
12937 (void *)&cmd_set_vxlan_ip_version,
12938 (void *)&cmd_set_vxlan_ip_version_value,
12939 (void *)&cmd_set_vxlan_vni,
12940 (void *)&cmd_set_vxlan_vni_value,
12941 (void *)&cmd_set_vxlan_udp_src,
12942 (void *)&cmd_set_vxlan_udp_src_value,
12943 (void *)&cmd_set_vxlan_udp_dst,
12944 (void *)&cmd_set_vxlan_udp_dst_value,
12945 (void *)&cmd_set_vxlan_ip_src,
12946 (void *)&cmd_set_vxlan_ip_src_value,
12947 (void *)&cmd_set_vxlan_ip_dst,
12948 (void *)&cmd_set_vxlan_ip_dst_value,
12949 (void *)&cmd_set_vxlan_eth_src,
12950 (void *)&cmd_set_vxlan_eth_src_value,
12951 (void *)&cmd_set_vxlan_eth_dst,
12952 (void *)&cmd_set_vxlan_eth_dst_value,
12957 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12958 .f = cmd_set_vxlan_parsed,
12960 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12961 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12962 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12963 " eth-dst <eth-dst>",
12965 (void *)&cmd_set_vxlan_set,
12966 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12967 (void *)&cmd_set_vxlan_ip_version,
12968 (void *)&cmd_set_vxlan_ip_version_value,
12969 (void *)&cmd_set_vxlan_vni,
12970 (void *)&cmd_set_vxlan_vni_value,
12971 (void *)&cmd_set_vxlan_udp_src,
12972 (void *)&cmd_set_vxlan_udp_src_value,
12973 (void *)&cmd_set_vxlan_udp_dst,
12974 (void *)&cmd_set_vxlan_udp_dst_value,
12975 (void *)&cmd_set_vxlan_ip_tos,
12976 (void *)&cmd_set_vxlan_ip_tos_value,
12977 (void *)&cmd_set_vxlan_ip_ttl,
12978 (void *)&cmd_set_vxlan_ip_ttl_value,
12979 (void *)&cmd_set_vxlan_ip_src,
12980 (void *)&cmd_set_vxlan_ip_src_value,
12981 (void *)&cmd_set_vxlan_ip_dst,
12982 (void *)&cmd_set_vxlan_ip_dst_value,
12983 (void *)&cmd_set_vxlan_eth_src,
12984 (void *)&cmd_set_vxlan_eth_src_value,
12985 (void *)&cmd_set_vxlan_eth_dst,
12986 (void *)&cmd_set_vxlan_eth_dst_value,
12991 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12992 .f = cmd_set_vxlan_parsed,
12994 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12995 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12996 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12999 (void *)&cmd_set_vxlan_set,
13000 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13001 (void *)&cmd_set_vxlan_ip_version,
13002 (void *)&cmd_set_vxlan_ip_version_value,
13003 (void *)&cmd_set_vxlan_vni,
13004 (void *)&cmd_set_vxlan_vni_value,
13005 (void *)&cmd_set_vxlan_udp_src,
13006 (void *)&cmd_set_vxlan_udp_src_value,
13007 (void *)&cmd_set_vxlan_udp_dst,
13008 (void *)&cmd_set_vxlan_udp_dst_value,
13009 (void *)&cmd_set_vxlan_ip_src,
13010 (void *)&cmd_set_vxlan_ip_src_value,
13011 (void *)&cmd_set_vxlan_ip_dst,
13012 (void *)&cmd_set_vxlan_ip_dst_value,
13013 (void *)&cmd_set_vxlan_vlan,
13014 (void *)&cmd_set_vxlan_vlan_value,
13015 (void *)&cmd_set_vxlan_eth_src,
13016 (void *)&cmd_set_vxlan_eth_src_value,
13017 (void *)&cmd_set_vxlan_eth_dst,
13018 (void *)&cmd_set_vxlan_eth_dst_value,
13023 /** Set NVGRE encapsulation details */
13024 struct cmd_set_nvgre_result {
13025 cmdline_fixed_string_t set;
13026 cmdline_fixed_string_t nvgre;
13027 cmdline_fixed_string_t pos_token;
13028 cmdline_fixed_string_t ip_version;
13030 cmdline_ipaddr_t ip_src;
13031 cmdline_ipaddr_t ip_dst;
13033 struct rte_ether_addr eth_src;
13034 struct rte_ether_addr eth_dst;
13037 cmdline_parse_token_string_t cmd_set_nvgre_set =
13038 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13039 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13040 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13041 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13042 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13043 "nvgre-with-vlan");
13044 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13045 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13047 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13048 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13050 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13051 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13053 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13054 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13055 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13056 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13058 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13059 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13060 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13061 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13063 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13064 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13065 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13066 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13068 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13069 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13070 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13071 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13073 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13074 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13075 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13076 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13078 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13079 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13081 static void cmd_set_nvgre_parsed(void *parsed_result,
13082 __rte_unused struct cmdline *cl,
13083 __rte_unused void *data)
13085 struct cmd_set_nvgre_result *res = parsed_result;
13087 uint32_t nvgre_tni;
13090 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13093 if (strcmp(res->nvgre, "nvgre") == 0)
13094 nvgre_encap_conf.select_vlan = 0;
13095 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13096 nvgre_encap_conf.select_vlan = 1;
13097 if (strcmp(res->ip_version, "ipv4") == 0)
13098 nvgre_encap_conf.select_ipv4 = 1;
13099 else if (strcmp(res->ip_version, "ipv6") == 0)
13100 nvgre_encap_conf.select_ipv4 = 0;
13103 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13104 if (nvgre_encap_conf.select_ipv4) {
13105 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13106 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13108 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13109 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13111 if (nvgre_encap_conf.select_vlan)
13112 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13113 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13114 RTE_ETHER_ADDR_LEN);
13115 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13116 RTE_ETHER_ADDR_LEN);
13119 cmdline_parse_inst_t cmd_set_nvgre = {
13120 .f = cmd_set_nvgre_parsed,
13122 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13123 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13124 " eth-dst <eth-dst>",
13126 (void *)&cmd_set_nvgre_set,
13127 (void *)&cmd_set_nvgre_nvgre,
13128 (void *)&cmd_set_nvgre_ip_version,
13129 (void *)&cmd_set_nvgre_ip_version_value,
13130 (void *)&cmd_set_nvgre_tni,
13131 (void *)&cmd_set_nvgre_tni_value,
13132 (void *)&cmd_set_nvgre_ip_src,
13133 (void *)&cmd_set_nvgre_ip_src_value,
13134 (void *)&cmd_set_nvgre_ip_dst,
13135 (void *)&cmd_set_nvgre_ip_dst_value,
13136 (void *)&cmd_set_nvgre_eth_src,
13137 (void *)&cmd_set_nvgre_eth_src_value,
13138 (void *)&cmd_set_nvgre_eth_dst,
13139 (void *)&cmd_set_nvgre_eth_dst_value,
13144 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13145 .f = cmd_set_nvgre_parsed,
13147 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13148 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13149 " eth-src <eth-src> eth-dst <eth-dst>",
13151 (void *)&cmd_set_nvgre_set,
13152 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13153 (void *)&cmd_set_nvgre_ip_version,
13154 (void *)&cmd_set_nvgre_ip_version_value,
13155 (void *)&cmd_set_nvgre_tni,
13156 (void *)&cmd_set_nvgre_tni_value,
13157 (void *)&cmd_set_nvgre_ip_src,
13158 (void *)&cmd_set_nvgre_ip_src_value,
13159 (void *)&cmd_set_nvgre_ip_dst,
13160 (void *)&cmd_set_nvgre_ip_dst_value,
13161 (void *)&cmd_set_nvgre_vlan,
13162 (void *)&cmd_set_nvgre_vlan_value,
13163 (void *)&cmd_set_nvgre_eth_src,
13164 (void *)&cmd_set_nvgre_eth_src_value,
13165 (void *)&cmd_set_nvgre_eth_dst,
13166 (void *)&cmd_set_nvgre_eth_dst_value,
13171 /** Set L2 encapsulation details */
13172 struct cmd_set_l2_encap_result {
13173 cmdline_fixed_string_t set;
13174 cmdline_fixed_string_t l2_encap;
13175 cmdline_fixed_string_t pos_token;
13176 cmdline_fixed_string_t ip_version;
13177 uint32_t vlan_present:1;
13179 struct rte_ether_addr eth_src;
13180 struct rte_ether_addr eth_dst;
13183 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13184 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13185 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13186 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13187 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13188 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13189 "l2_encap-with-vlan");
13190 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13191 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13193 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13194 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13196 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13197 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13199 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13200 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13201 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13202 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13204 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13205 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13206 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13207 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13209 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13210 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13212 static void cmd_set_l2_encap_parsed(void *parsed_result,
13213 __rte_unused struct cmdline *cl,
13214 __rte_unused void *data)
13216 struct cmd_set_l2_encap_result *res = parsed_result;
13218 if (strcmp(res->l2_encap, "l2_encap") == 0)
13219 l2_encap_conf.select_vlan = 0;
13220 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13221 l2_encap_conf.select_vlan = 1;
13222 if (strcmp(res->ip_version, "ipv4") == 0)
13223 l2_encap_conf.select_ipv4 = 1;
13224 else if (strcmp(res->ip_version, "ipv6") == 0)
13225 l2_encap_conf.select_ipv4 = 0;
13228 if (l2_encap_conf.select_vlan)
13229 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13230 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13231 RTE_ETHER_ADDR_LEN);
13232 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13233 RTE_ETHER_ADDR_LEN);
13236 cmdline_parse_inst_t cmd_set_l2_encap = {
13237 .f = cmd_set_l2_encap_parsed,
13239 .help_str = "set l2_encap ip-version ipv4|ipv6"
13240 " eth-src <eth-src> eth-dst <eth-dst>",
13242 (void *)&cmd_set_l2_encap_set,
13243 (void *)&cmd_set_l2_encap_l2_encap,
13244 (void *)&cmd_set_l2_encap_ip_version,
13245 (void *)&cmd_set_l2_encap_ip_version_value,
13246 (void *)&cmd_set_l2_encap_eth_src,
13247 (void *)&cmd_set_l2_encap_eth_src_value,
13248 (void *)&cmd_set_l2_encap_eth_dst,
13249 (void *)&cmd_set_l2_encap_eth_dst_value,
13254 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13255 .f = cmd_set_l2_encap_parsed,
13257 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13258 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13260 (void *)&cmd_set_l2_encap_set,
13261 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13262 (void *)&cmd_set_l2_encap_ip_version,
13263 (void *)&cmd_set_l2_encap_ip_version_value,
13264 (void *)&cmd_set_l2_encap_vlan,
13265 (void *)&cmd_set_l2_encap_vlan_value,
13266 (void *)&cmd_set_l2_encap_eth_src,
13267 (void *)&cmd_set_l2_encap_eth_src_value,
13268 (void *)&cmd_set_l2_encap_eth_dst,
13269 (void *)&cmd_set_l2_encap_eth_dst_value,
13274 /** Set L2 decapsulation details */
13275 struct cmd_set_l2_decap_result {
13276 cmdline_fixed_string_t set;
13277 cmdline_fixed_string_t l2_decap;
13278 cmdline_fixed_string_t pos_token;
13279 uint32_t vlan_present:1;
13282 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13283 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13284 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13285 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13287 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13288 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13289 "l2_decap-with-vlan");
13291 static void cmd_set_l2_decap_parsed(void *parsed_result,
13292 __rte_unused struct cmdline *cl,
13293 __rte_unused void *data)
13295 struct cmd_set_l2_decap_result *res = parsed_result;
13297 if (strcmp(res->l2_decap, "l2_decap") == 0)
13298 l2_decap_conf.select_vlan = 0;
13299 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13300 l2_decap_conf.select_vlan = 1;
13303 cmdline_parse_inst_t cmd_set_l2_decap = {
13304 .f = cmd_set_l2_decap_parsed,
13306 .help_str = "set l2_decap",
13308 (void *)&cmd_set_l2_decap_set,
13309 (void *)&cmd_set_l2_decap_l2_decap,
13314 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13315 .f = cmd_set_l2_decap_parsed,
13317 .help_str = "set l2_decap-with-vlan",
13319 (void *)&cmd_set_l2_decap_set,
13320 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13325 /** Set MPLSoGRE encapsulation details */
13326 struct cmd_set_mplsogre_encap_result {
13327 cmdline_fixed_string_t set;
13328 cmdline_fixed_string_t mplsogre;
13329 cmdline_fixed_string_t pos_token;
13330 cmdline_fixed_string_t ip_version;
13331 uint32_t vlan_present:1;
13333 cmdline_ipaddr_t ip_src;
13334 cmdline_ipaddr_t ip_dst;
13336 struct rte_ether_addr eth_src;
13337 struct rte_ether_addr eth_dst;
13340 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13341 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13343 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13344 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13346 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13347 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13348 mplsogre, "mplsogre_encap-with-vlan");
13349 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13350 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13351 pos_token, "ip-version");
13352 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13353 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13354 ip_version, "ipv4#ipv6");
13355 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13356 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13357 pos_token, "label");
13358 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13359 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13361 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13362 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13363 pos_token, "ip-src");
13364 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13365 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13366 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13367 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13368 pos_token, "ip-dst");
13369 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13370 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13371 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13372 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13373 pos_token, "vlan-tci");
13374 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13375 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13377 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13378 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13379 pos_token, "eth-src");
13380 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13381 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13383 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13384 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13385 pos_token, "eth-dst");
13386 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13387 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13390 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13391 __rte_unused struct cmdline *cl,
13392 __rte_unused void *data)
13394 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13396 uint32_t mplsogre_label;
13399 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13402 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13403 mplsogre_encap_conf.select_vlan = 0;
13404 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13405 mplsogre_encap_conf.select_vlan = 1;
13406 if (strcmp(res->ip_version, "ipv4") == 0)
13407 mplsogre_encap_conf.select_ipv4 = 1;
13408 else if (strcmp(res->ip_version, "ipv6") == 0)
13409 mplsogre_encap_conf.select_ipv4 = 0;
13412 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13413 if (mplsogre_encap_conf.select_ipv4) {
13414 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13415 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13417 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13418 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13420 if (mplsogre_encap_conf.select_vlan)
13421 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13422 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13423 RTE_ETHER_ADDR_LEN);
13424 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13425 RTE_ETHER_ADDR_LEN);
13428 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13429 .f = cmd_set_mplsogre_encap_parsed,
13431 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13432 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13433 " eth-dst <eth-dst>",
13435 (void *)&cmd_set_mplsogre_encap_set,
13436 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13437 (void *)&cmd_set_mplsogre_encap_ip_version,
13438 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13439 (void *)&cmd_set_mplsogre_encap_label,
13440 (void *)&cmd_set_mplsogre_encap_label_value,
13441 (void *)&cmd_set_mplsogre_encap_ip_src,
13442 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13443 (void *)&cmd_set_mplsogre_encap_ip_dst,
13444 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13445 (void *)&cmd_set_mplsogre_encap_eth_src,
13446 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13447 (void *)&cmd_set_mplsogre_encap_eth_dst,
13448 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13453 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13454 .f = cmd_set_mplsogre_encap_parsed,
13456 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13457 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13458 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13460 (void *)&cmd_set_mplsogre_encap_set,
13461 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13462 (void *)&cmd_set_mplsogre_encap_ip_version,
13463 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13464 (void *)&cmd_set_mplsogre_encap_label,
13465 (void *)&cmd_set_mplsogre_encap_label_value,
13466 (void *)&cmd_set_mplsogre_encap_ip_src,
13467 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13468 (void *)&cmd_set_mplsogre_encap_ip_dst,
13469 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13470 (void *)&cmd_set_mplsogre_encap_vlan,
13471 (void *)&cmd_set_mplsogre_encap_vlan_value,
13472 (void *)&cmd_set_mplsogre_encap_eth_src,
13473 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13474 (void *)&cmd_set_mplsogre_encap_eth_dst,
13475 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13480 /** Set MPLSoGRE decapsulation details */
13481 struct cmd_set_mplsogre_decap_result {
13482 cmdline_fixed_string_t set;
13483 cmdline_fixed_string_t mplsogre;
13484 cmdline_fixed_string_t pos_token;
13485 cmdline_fixed_string_t ip_version;
13486 uint32_t vlan_present:1;
13489 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13490 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13492 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13493 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13495 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13496 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13497 mplsogre, "mplsogre_decap-with-vlan");
13498 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13499 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13500 pos_token, "ip-version");
13501 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13502 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13503 ip_version, "ipv4#ipv6");
13505 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13506 __rte_unused struct cmdline *cl,
13507 __rte_unused void *data)
13509 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13511 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13512 mplsogre_decap_conf.select_vlan = 0;
13513 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13514 mplsogre_decap_conf.select_vlan = 1;
13515 if (strcmp(res->ip_version, "ipv4") == 0)
13516 mplsogre_decap_conf.select_ipv4 = 1;
13517 else if (strcmp(res->ip_version, "ipv6") == 0)
13518 mplsogre_decap_conf.select_ipv4 = 0;
13521 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13522 .f = cmd_set_mplsogre_decap_parsed,
13524 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13526 (void *)&cmd_set_mplsogre_decap_set,
13527 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13528 (void *)&cmd_set_mplsogre_decap_ip_version,
13529 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13534 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13535 .f = cmd_set_mplsogre_decap_parsed,
13537 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13539 (void *)&cmd_set_mplsogre_decap_set,
13540 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13541 (void *)&cmd_set_mplsogre_decap_ip_version,
13542 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13547 /** Set MPLSoUDP encapsulation details */
13548 struct cmd_set_mplsoudp_encap_result {
13549 cmdline_fixed_string_t set;
13550 cmdline_fixed_string_t mplsoudp;
13551 cmdline_fixed_string_t pos_token;
13552 cmdline_fixed_string_t ip_version;
13553 uint32_t vlan_present:1;
13557 cmdline_ipaddr_t ip_src;
13558 cmdline_ipaddr_t ip_dst;
13560 struct rte_ether_addr eth_src;
13561 struct rte_ether_addr eth_dst;
13564 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13565 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13567 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13568 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13570 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13571 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13572 mplsoudp, "mplsoudp_encap-with-vlan");
13573 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13574 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13575 pos_token, "ip-version");
13576 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13577 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13578 ip_version, "ipv4#ipv6");
13579 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13580 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13581 pos_token, "label");
13582 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13583 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13585 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13586 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13587 pos_token, "udp-src");
13588 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13589 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13591 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13592 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13593 pos_token, "udp-dst");
13594 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13595 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13597 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13598 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13599 pos_token, "ip-src");
13600 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13601 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13602 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13603 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13604 pos_token, "ip-dst");
13605 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13606 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13607 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13608 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13609 pos_token, "vlan-tci");
13610 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13611 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13613 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13614 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13615 pos_token, "eth-src");
13616 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13617 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13619 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13620 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13621 pos_token, "eth-dst");
13622 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13623 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13626 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13627 __rte_unused struct cmdline *cl,
13628 __rte_unused void *data)
13630 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13632 uint32_t mplsoudp_label;
13635 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13638 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13639 mplsoudp_encap_conf.select_vlan = 0;
13640 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13641 mplsoudp_encap_conf.select_vlan = 1;
13642 if (strcmp(res->ip_version, "ipv4") == 0)
13643 mplsoudp_encap_conf.select_ipv4 = 1;
13644 else if (strcmp(res->ip_version, "ipv6") == 0)
13645 mplsoudp_encap_conf.select_ipv4 = 0;
13648 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13649 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13650 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13651 if (mplsoudp_encap_conf.select_ipv4) {
13652 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13653 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13655 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13656 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13658 if (mplsoudp_encap_conf.select_vlan)
13659 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13660 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13661 RTE_ETHER_ADDR_LEN);
13662 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13663 RTE_ETHER_ADDR_LEN);
13666 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13667 .f = cmd_set_mplsoudp_encap_parsed,
13669 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13670 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13671 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13673 (void *)&cmd_set_mplsoudp_encap_set,
13674 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13675 (void *)&cmd_set_mplsoudp_encap_ip_version,
13676 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13677 (void *)&cmd_set_mplsoudp_encap_label,
13678 (void *)&cmd_set_mplsoudp_encap_label_value,
13679 (void *)&cmd_set_mplsoudp_encap_udp_src,
13680 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13681 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13682 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13683 (void *)&cmd_set_mplsoudp_encap_ip_src,
13684 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13685 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13686 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13687 (void *)&cmd_set_mplsoudp_encap_eth_src,
13688 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13689 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13690 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13695 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13696 .f = cmd_set_mplsoudp_encap_parsed,
13698 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13699 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13700 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13701 " eth-src <eth-src> eth-dst <eth-dst>",
13703 (void *)&cmd_set_mplsoudp_encap_set,
13704 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13705 (void *)&cmd_set_mplsoudp_encap_ip_version,
13706 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13707 (void *)&cmd_set_mplsoudp_encap_label,
13708 (void *)&cmd_set_mplsoudp_encap_label_value,
13709 (void *)&cmd_set_mplsoudp_encap_udp_src,
13710 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13711 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13712 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13713 (void *)&cmd_set_mplsoudp_encap_ip_src,
13714 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13715 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13716 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13717 (void *)&cmd_set_mplsoudp_encap_vlan,
13718 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13719 (void *)&cmd_set_mplsoudp_encap_eth_src,
13720 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13721 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13722 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13727 /** Set MPLSoUDP decapsulation details */
13728 struct cmd_set_mplsoudp_decap_result {
13729 cmdline_fixed_string_t set;
13730 cmdline_fixed_string_t mplsoudp;
13731 cmdline_fixed_string_t pos_token;
13732 cmdline_fixed_string_t ip_version;
13733 uint32_t vlan_present:1;
13736 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13737 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13739 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13740 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13742 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13743 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13744 mplsoudp, "mplsoudp_decap-with-vlan");
13745 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13746 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13747 pos_token, "ip-version");
13748 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13749 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13750 ip_version, "ipv4#ipv6");
13752 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13753 __rte_unused struct cmdline *cl,
13754 __rte_unused void *data)
13756 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13758 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13759 mplsoudp_decap_conf.select_vlan = 0;
13760 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13761 mplsoudp_decap_conf.select_vlan = 1;
13762 if (strcmp(res->ip_version, "ipv4") == 0)
13763 mplsoudp_decap_conf.select_ipv4 = 1;
13764 else if (strcmp(res->ip_version, "ipv6") == 0)
13765 mplsoudp_decap_conf.select_ipv4 = 0;
13768 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13769 .f = cmd_set_mplsoudp_decap_parsed,
13771 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13773 (void *)&cmd_set_mplsoudp_decap_set,
13774 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13775 (void *)&cmd_set_mplsoudp_decap_ip_version,
13776 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13781 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13782 .f = cmd_set_mplsoudp_decap_parsed,
13784 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13786 (void *)&cmd_set_mplsoudp_decap_set,
13787 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13788 (void *)&cmd_set_mplsoudp_decap_ip_version,
13789 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13794 /** Set connection tracking object common details */
13795 struct cmd_set_conntrack_common_result {
13796 cmdline_fixed_string_t set;
13797 cmdline_fixed_string_t conntrack;
13798 cmdline_fixed_string_t common;
13799 cmdline_fixed_string_t peer;
13800 cmdline_fixed_string_t is_orig;
13801 cmdline_fixed_string_t enable;
13802 cmdline_fixed_string_t live;
13803 cmdline_fixed_string_t sack;
13804 cmdline_fixed_string_t cack;
13805 cmdline_fixed_string_t last_dir;
13806 cmdline_fixed_string_t liberal;
13807 cmdline_fixed_string_t state;
13808 cmdline_fixed_string_t max_ack_win;
13809 cmdline_fixed_string_t retrans;
13810 cmdline_fixed_string_t last_win;
13811 cmdline_fixed_string_t last_seq;
13812 cmdline_fixed_string_t last_ack;
13813 cmdline_fixed_string_t last_end;
13814 cmdline_fixed_string_t last_index;
13817 uint16_t peer_port;
13818 uint32_t is_original;
13833 cmdline_parse_token_string_t cmd_set_conntrack_set =
13834 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13836 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13837 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13838 conntrack, "conntrack");
13839 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13840 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13842 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13843 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13845 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13846 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13847 peer_port, RTE_UINT16);
13848 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13849 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13850 is_orig, "is_orig");
13851 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13852 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13853 is_original, RTE_UINT32);
13854 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13855 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13857 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13858 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13860 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13861 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13863 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13864 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13865 is_live, RTE_UINT32);
13866 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13867 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13869 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13870 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13871 s_ack, RTE_UINT32);
13872 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13873 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13875 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13876 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13877 c_ack, RTE_UINT32);
13878 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13879 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13880 last_dir, "last_dir");
13881 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13882 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13884 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13885 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13886 liberal, "liberal");
13887 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13888 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13890 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13891 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13893 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13894 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13896 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13897 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13898 max_ack_win, "max_ack_win");
13899 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13900 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13901 factor, RTE_UINT8);
13902 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13903 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13905 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13906 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13907 re_num, RTE_UINT8);
13908 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13909 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13910 last_win, "last_win");
13911 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13912 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13914 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13915 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13916 last_seq, "last_seq");
13917 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13918 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13920 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13921 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13922 last_ack, "last_ack");
13923 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13924 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13926 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13927 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13928 last_end, "last_end");
13929 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13930 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13932 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13933 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13934 last_index, "last_index");
13935 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13936 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13939 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13940 __rte_unused struct cmdline *cl,
13941 __rte_unused void *data)
13943 struct cmd_set_conntrack_common_result *res = parsed_result;
13945 /* No need to swap to big endian. */
13946 conntrack_context.peer_port = res->peer_port;
13947 conntrack_context.is_original_dir = res->is_original;
13948 conntrack_context.enable = res->en;
13949 conntrack_context.live_connection = res->is_live;
13950 conntrack_context.selective_ack = res->s_ack;
13951 conntrack_context.challenge_ack_passed = res->c_ack;
13952 conntrack_context.last_direction = res->ld;
13953 conntrack_context.liberal_mode = res->lb;
13954 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13955 conntrack_context.max_ack_window = res->factor;
13956 conntrack_context.retransmission_limit = res->re_num;
13957 conntrack_context.last_window = res->lw;
13958 conntrack_context.last_index =
13959 (enum rte_flow_conntrack_tcp_last_index)res->li;
13960 conntrack_context.last_seq = res->ls;
13961 conntrack_context.last_ack = res->la;
13962 conntrack_context.last_end = res->le;
13965 cmdline_parse_inst_t cmd_set_conntrack_common = {
13966 .f = cmd_set_conntrack_common_parsed,
13968 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13969 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13970 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13971 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13972 " last_index <flag>",
13974 (void *)&cmd_set_conntrack_set,
13975 (void *)&cmd_set_conntrack_conntrack,
13976 (void *)&cmd_set_conntrack_common_com,
13977 (void *)&cmd_set_conntrack_common_peer,
13978 (void *)&cmd_set_conntrack_common_peer_value,
13979 (void *)&cmd_set_conntrack_common_is_orig,
13980 (void *)&cmd_set_conntrack_common_is_orig_value,
13981 (void *)&cmd_set_conntrack_common_enable,
13982 (void *)&cmd_set_conntrack_common_enable_value,
13983 (void *)&cmd_set_conntrack_common_live,
13984 (void *)&cmd_set_conntrack_common_live_value,
13985 (void *)&cmd_set_conntrack_common_sack,
13986 (void *)&cmd_set_conntrack_common_sack_value,
13987 (void *)&cmd_set_conntrack_common_cack,
13988 (void *)&cmd_set_conntrack_common_cack_value,
13989 (void *)&cmd_set_conntrack_common_last_dir,
13990 (void *)&cmd_set_conntrack_common_last_dir_value,
13991 (void *)&cmd_set_conntrack_common_liberal,
13992 (void *)&cmd_set_conntrack_common_liberal_value,
13993 (void *)&cmd_set_conntrack_common_state,
13994 (void *)&cmd_set_conntrack_common_state_value,
13995 (void *)&cmd_set_conntrack_common_max_ackwin,
13996 (void *)&cmd_set_conntrack_common_max_ackwin_value,
13997 (void *)&cmd_set_conntrack_common_retrans,
13998 (void *)&cmd_set_conntrack_common_retrans_value,
13999 (void *)&cmd_set_conntrack_common_last_win,
14000 (void *)&cmd_set_conntrack_common_last_win_value,
14001 (void *)&cmd_set_conntrack_common_last_seq,
14002 (void *)&cmd_set_conntrack_common_last_seq_value,
14003 (void *)&cmd_set_conntrack_common_last_ack,
14004 (void *)&cmd_set_conntrack_common_last_ack_value,
14005 (void *)&cmd_set_conntrack_common_last_end,
14006 (void *)&cmd_set_conntrack_common_last_end_value,
14007 (void *)&cmd_set_conntrack_common_last_index,
14008 (void *)&cmd_set_conntrack_common_last_index_value,
14013 /** Set connection tracking object both directions' details */
14014 struct cmd_set_conntrack_dir_result {
14015 cmdline_fixed_string_t set;
14016 cmdline_fixed_string_t conntrack;
14017 cmdline_fixed_string_t dir;
14018 cmdline_fixed_string_t scale;
14019 cmdline_fixed_string_t fin;
14020 cmdline_fixed_string_t ack_seen;
14021 cmdline_fixed_string_t unack;
14022 cmdline_fixed_string_t sent_end;
14023 cmdline_fixed_string_t reply_end;
14024 cmdline_fixed_string_t max_win;
14025 cmdline_fixed_string_t max_ack;
14036 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14037 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14039 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14040 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14041 conntrack, "conntrack");
14042 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14043 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14045 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14046 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14048 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14049 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14050 factor, RTE_UINT32);
14051 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14052 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14054 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14055 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14057 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14058 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14059 ack_seen, "acked");
14060 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14061 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14063 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14064 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14065 unack, "unack_data");
14066 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14067 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14069 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14070 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14071 sent_end, "sent_end");
14072 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14073 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14075 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14076 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14077 reply_end, "reply_end");
14078 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14079 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14081 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14082 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14083 max_win, "max_win");
14084 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14085 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14087 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14088 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14089 max_ack, "max_ack");
14090 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14091 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14094 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14095 __rte_unused struct cmdline *cl,
14096 __rte_unused void *data)
14098 struct cmd_set_conntrack_dir_result *res = parsed_result;
14099 struct rte_flow_tcp_dir_param *dir = NULL;
14101 if (strcmp(res->dir, "orig") == 0)
14102 dir = &conntrack_context.original_dir;
14103 else if (strcmp(res->dir, "rply") == 0)
14104 dir = &conntrack_context.reply_dir;
14107 dir->scale = res->factor;
14108 dir->close_initiated = res->f;
14109 dir->last_ack_seen = res->as;
14110 dir->data_unacked = res->un;
14111 dir->sent_end = res->se;
14112 dir->reply_end = res->re;
14113 dir->max_ack = res->ma;
14114 dir->max_win = res->mw;
14117 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14118 .f = cmd_set_conntrack_dir_parsed,
14120 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14121 " acked <seen> unack_data <unack> sent_end <sent>"
14122 " reply_end <reply> max_win <win> max_ack <ack>",
14124 (void *)&cmd_set_conntrack_set,
14125 (void *)&cmd_set_conntrack_conntrack,
14126 (void *)&cmd_set_conntrack_dir_dir,
14127 (void *)&cmd_set_conntrack_dir_scale,
14128 (void *)&cmd_set_conntrack_dir_scale_value,
14129 (void *)&cmd_set_conntrack_dir_fin,
14130 (void *)&cmd_set_conntrack_dir_fin_value,
14131 (void *)&cmd_set_conntrack_dir_ack,
14132 (void *)&cmd_set_conntrack_dir_ack_value,
14133 (void *)&cmd_set_conntrack_dir_unack_data,
14134 (void *)&cmd_set_conntrack_dir_unack_data_value,
14135 (void *)&cmd_set_conntrack_dir_sent_end,
14136 (void *)&cmd_set_conntrack_dir_sent_end_value,
14137 (void *)&cmd_set_conntrack_dir_reply_end,
14138 (void *)&cmd_set_conntrack_dir_reply_end_value,
14139 (void *)&cmd_set_conntrack_dir_max_win,
14140 (void *)&cmd_set_conntrack_dir_max_win_value,
14141 (void *)&cmd_set_conntrack_dir_max_ack,
14142 (void *)&cmd_set_conntrack_dir_max_ack_value,
14147 /* Strict link priority scheduling mode setting */
14149 cmd_strict_link_prio_parsed(
14150 void *parsed_result,
14151 __rte_unused struct cmdline *cl,
14152 __rte_unused void *data)
14154 struct cmd_vf_tc_bw_result *res = parsed_result;
14155 int ret = -ENOTSUP;
14157 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14160 #ifdef RTE_NET_I40E
14161 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14168 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14171 printf("invalid port_id %d\n", res->port_id);
14174 printf("function not implemented\n");
14177 printf("programming error: (%s)\n", strerror(-ret));
14181 cmdline_parse_inst_t cmd_strict_link_prio = {
14182 .f = cmd_strict_link_prio_parsed,
14184 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14186 (void *)&cmd_vf_tc_bw_set,
14187 (void *)&cmd_vf_tc_bw_tx,
14188 (void *)&cmd_vf_tc_bw_strict_link_prio,
14189 (void *)&cmd_vf_tc_bw_port_id,
14190 (void *)&cmd_vf_tc_bw_tc_map,
14195 /* Load dynamic device personalization*/
14196 struct cmd_ddp_add_result {
14197 cmdline_fixed_string_t ddp;
14198 cmdline_fixed_string_t add;
14203 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14204 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14205 cmdline_parse_token_string_t cmd_ddp_add_add =
14206 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14207 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14208 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14210 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14211 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14214 cmd_ddp_add_parsed(
14215 void *parsed_result,
14216 __rte_unused struct cmdline *cl,
14217 __rte_unused void *data)
14219 struct cmd_ddp_add_result *res = parsed_result;
14225 int ret = -ENOTSUP;
14227 if (!all_ports_stopped()) {
14228 printf("Please stop all ports first\n");
14232 filepath = strdup(res->filepath);
14233 if (filepath == NULL) {
14234 printf("Failed to allocate memory\n");
14237 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14239 buff = open_file(file_fld[0], &size);
14241 free((void *)filepath);
14245 #ifdef RTE_NET_I40E
14246 if (ret == -ENOTSUP)
14247 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14249 RTE_PMD_I40E_PKG_OP_WR_ADD);
14252 if (ret == -EEXIST)
14253 printf("Profile has already existed.\n");
14255 printf("Failed to load profile.\n");
14256 else if (file_num == 2)
14257 save_file(file_fld[1], buff, size);
14260 free((void *)filepath);
14263 cmdline_parse_inst_t cmd_ddp_add = {
14264 .f = cmd_ddp_add_parsed,
14266 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14268 (void *)&cmd_ddp_add_ddp,
14269 (void *)&cmd_ddp_add_add,
14270 (void *)&cmd_ddp_add_port_id,
14271 (void *)&cmd_ddp_add_filepath,
14276 /* Delete dynamic device personalization*/
14277 struct cmd_ddp_del_result {
14278 cmdline_fixed_string_t ddp;
14279 cmdline_fixed_string_t del;
14284 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14285 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14286 cmdline_parse_token_string_t cmd_ddp_del_del =
14287 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14288 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14289 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14290 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14291 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14294 cmd_ddp_del_parsed(
14295 void *parsed_result,
14296 __rte_unused struct cmdline *cl,
14297 __rte_unused void *data)
14299 struct cmd_ddp_del_result *res = parsed_result;
14302 int ret = -ENOTSUP;
14304 if (!all_ports_stopped()) {
14305 printf("Please stop all ports first\n");
14309 buff = open_file(res->filepath, &size);
14313 #ifdef RTE_NET_I40E
14314 if (ret == -ENOTSUP)
14315 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14317 RTE_PMD_I40E_PKG_OP_WR_DEL);
14320 if (ret == -EACCES)
14321 printf("Profile does not exist.\n");
14323 printf("Failed to delete profile.\n");
14328 cmdline_parse_inst_t cmd_ddp_del = {
14329 .f = cmd_ddp_del_parsed,
14331 .help_str = "ddp del <port_id> <backup_profile_path>",
14333 (void *)&cmd_ddp_del_ddp,
14334 (void *)&cmd_ddp_del_del,
14335 (void *)&cmd_ddp_del_port_id,
14336 (void *)&cmd_ddp_del_filepath,
14341 /* Get dynamic device personalization profile info */
14342 struct cmd_ddp_info_result {
14343 cmdline_fixed_string_t ddp;
14344 cmdline_fixed_string_t get;
14345 cmdline_fixed_string_t info;
14349 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14350 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14351 cmdline_parse_token_string_t cmd_ddp_info_get =
14352 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14353 cmdline_parse_token_string_t cmd_ddp_info_info =
14354 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14355 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14356 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14359 cmd_ddp_info_parsed(
14360 void *parsed_result,
14361 __rte_unused struct cmdline *cl,
14362 __rte_unused void *data)
14364 struct cmd_ddp_info_result *res = parsed_result;
14367 int ret = -ENOTSUP;
14368 #ifdef RTE_NET_I40E
14371 uint32_t buff_size = 0;
14372 struct rte_pmd_i40e_profile_info info;
14373 uint32_t dev_num = 0;
14374 struct rte_pmd_i40e_ddp_device_id *devs;
14375 uint32_t proto_num = 0;
14376 struct rte_pmd_i40e_proto_info *proto = NULL;
14377 uint32_t pctype_num = 0;
14378 struct rte_pmd_i40e_ptype_info *pctype;
14379 uint32_t ptype_num = 0;
14380 struct rte_pmd_i40e_ptype_info *ptype;
14385 pkg = open_file(res->filepath, &pkg_size);
14389 #ifdef RTE_NET_I40E
14390 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14391 (uint8_t *)&info, sizeof(info),
14392 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14394 printf("Global Track id: 0x%x\n", info.track_id);
14395 printf("Global Version: %d.%d.%d.%d\n",
14396 info.version.major,
14397 info.version.minor,
14398 info.version.update,
14399 info.version.draft);
14400 printf("Global Package name: %s\n\n", info.name);
14403 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14404 (uint8_t *)&info, sizeof(info),
14405 RTE_PMD_I40E_PKG_INFO_HEADER);
14407 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14408 printf("i40e Profile Version: %d.%d.%d.%d\n",
14409 info.version.major,
14410 info.version.minor,
14411 info.version.update,
14412 info.version.draft);
14413 printf("i40e Profile name: %s\n\n", info.name);
14416 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14417 (uint8_t *)&buff_size, sizeof(buff_size),
14418 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14419 if (!ret && buff_size) {
14420 buff = (uint8_t *)malloc(buff_size);
14422 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14424 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14426 printf("Package Notes:\n%s\n\n", buff);
14431 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14432 (uint8_t *)&dev_num, sizeof(dev_num),
14433 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14434 if (!ret && dev_num) {
14435 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14436 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14438 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14439 (uint8_t *)devs, buff_size,
14440 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14442 printf("List of supported devices:\n");
14443 for (i = 0; i < dev_num; i++) {
14444 printf(" %04X:%04X %04X:%04X\n",
14445 devs[i].vendor_dev_id >> 16,
14446 devs[i].vendor_dev_id & 0xFFFF,
14447 devs[i].sub_vendor_dev_id >> 16,
14448 devs[i].sub_vendor_dev_id & 0xFFFF);
14456 /* get information about protocols and packet types */
14457 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14458 (uint8_t *)&proto_num, sizeof(proto_num),
14459 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14460 if (ret || !proto_num)
14461 goto no_print_return;
14463 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14464 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14466 goto no_print_return;
14468 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14470 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14472 printf("List of used protocols:\n");
14473 for (i = 0; i < proto_num; i++)
14474 printf(" %2u: %s\n", proto[i].proto_id,
14478 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14479 (uint8_t *)&pctype_num, sizeof(pctype_num),
14480 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14481 if (ret || !pctype_num)
14482 goto no_print_pctypes;
14484 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14485 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14487 goto no_print_pctypes;
14489 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14491 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14494 goto no_print_pctypes;
14497 printf("List of defined packet classification types:\n");
14498 for (i = 0; i < pctype_num; i++) {
14499 printf(" %2u:", pctype[i].ptype_id);
14500 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14501 proto_id = pctype[i].protocols[j];
14502 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14503 for (n = 0; n < proto_num; n++) {
14504 if (proto[n].proto_id == proto_id) {
14505 printf(" %s", proto[n].name);
14518 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14520 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14521 if (ret || !ptype_num)
14522 goto no_print_return;
14524 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14525 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14527 goto no_print_return;
14529 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14531 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14534 goto no_print_return;
14536 printf("List of defined packet types:\n");
14537 for (i = 0; i < ptype_num; i++) {
14538 printf(" %2u:", ptype[i].ptype_id);
14539 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14540 proto_id = ptype[i].protocols[j];
14541 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14542 for (n = 0; n < proto_num; n++) {
14543 if (proto[n].proto_id == proto_id) {
14544 printf(" %s", proto[n].name);
14560 if (ret == -ENOTSUP)
14561 printf("Function not supported in PMD driver\n");
14565 cmdline_parse_inst_t cmd_ddp_get_info = {
14566 .f = cmd_ddp_info_parsed,
14568 .help_str = "ddp get info <profile_path>",
14570 (void *)&cmd_ddp_info_ddp,
14571 (void *)&cmd_ddp_info_get,
14572 (void *)&cmd_ddp_info_info,
14573 (void *)&cmd_ddp_info_filepath,
14578 /* Get dynamic device personalization profile info list*/
14579 #define PROFILE_INFO_SIZE 48
14580 #define MAX_PROFILE_NUM 16
14582 struct cmd_ddp_get_list_result {
14583 cmdline_fixed_string_t ddp;
14584 cmdline_fixed_string_t get;
14585 cmdline_fixed_string_t list;
14589 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14590 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14591 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14592 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14593 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14594 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14595 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14596 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14600 cmd_ddp_get_list_parsed(
14601 __rte_unused void *parsed_result,
14602 __rte_unused struct cmdline *cl,
14603 __rte_unused void *data)
14605 #ifdef RTE_NET_I40E
14606 struct cmd_ddp_get_list_result *res = parsed_result;
14607 struct rte_pmd_i40e_profile_list *p_list;
14608 struct rte_pmd_i40e_profile_info *p_info;
14613 int ret = -ENOTSUP;
14615 #ifdef RTE_NET_I40E
14616 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14617 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14619 printf("%s: Failed to malloc buffer\n", __func__);
14623 if (ret == -ENOTSUP)
14624 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14625 (uint8_t *)p_list, size);
14628 p_num = p_list->p_count;
14629 printf("Profile number is: %d\n\n", p_num);
14631 for (i = 0; i < p_num; i++) {
14632 p_info = &p_list->p_info[i];
14633 printf("Profile %d:\n", i);
14634 printf("Track id: 0x%x\n", p_info->track_id);
14635 printf("Version: %d.%d.%d.%d\n",
14636 p_info->version.major,
14637 p_info->version.minor,
14638 p_info->version.update,
14639 p_info->version.draft);
14640 printf("Profile name: %s\n\n", p_info->name);
14648 printf("Failed to get ddp list\n");
14651 cmdline_parse_inst_t cmd_ddp_get_list = {
14652 .f = cmd_ddp_get_list_parsed,
14654 .help_str = "ddp get list <port_id>",
14656 (void *)&cmd_ddp_get_list_ddp,
14657 (void *)&cmd_ddp_get_list_get,
14658 (void *)&cmd_ddp_get_list_list,
14659 (void *)&cmd_ddp_get_list_port_id,
14664 /* Configure input set */
14665 struct cmd_cfg_input_set_result {
14666 cmdline_fixed_string_t port;
14667 cmdline_fixed_string_t cfg;
14669 cmdline_fixed_string_t pctype;
14671 cmdline_fixed_string_t inset_type;
14672 cmdline_fixed_string_t opt;
14673 cmdline_fixed_string_t field;
14678 cmd_cfg_input_set_parsed(
14679 __rte_unused void *parsed_result,
14680 __rte_unused struct cmdline *cl,
14681 __rte_unused void *data)
14683 #ifdef RTE_NET_I40E
14684 struct cmd_cfg_input_set_result *res = parsed_result;
14685 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14686 struct rte_pmd_i40e_inset inset;
14688 int ret = -ENOTSUP;
14690 if (!all_ports_stopped()) {
14691 printf("Please stop all ports first\n");
14695 #ifdef RTE_NET_I40E
14696 if (!strcmp(res->inset_type, "hash_inset"))
14697 inset_type = INSET_HASH;
14698 else if (!strcmp(res->inset_type, "fdir_inset"))
14699 inset_type = INSET_FDIR;
14700 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14701 inset_type = INSET_FDIR_FLX;
14702 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14703 &inset, inset_type);
14705 printf("Failed to get input set.\n");
14709 if (!strcmp(res->opt, "get")) {
14710 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14713 printf("Field index %d is enabled.\n", res->field_idx);
14715 printf("Field index %d is disabled.\n", res->field_idx);
14717 } else if (!strcmp(res->opt, "set"))
14718 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14720 else if (!strcmp(res->opt, "clear"))
14721 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14724 printf("Failed to configure input set field.\n");
14728 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14729 &inset, inset_type);
14731 printf("Failed to set input set.\n");
14736 if (ret == -ENOTSUP)
14737 printf("Function not supported\n");
14740 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14741 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14743 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14744 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14746 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14747 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14748 port_id, RTE_UINT16);
14749 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14750 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14752 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14753 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14754 pctype_id, RTE_UINT8);
14755 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14756 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14758 "hash_inset#fdir_inset#fdir_flx_inset");
14759 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14760 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14761 opt, "get#set#clear");
14762 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14763 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14765 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14766 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14767 field_idx, RTE_UINT8);
14769 cmdline_parse_inst_t cmd_cfg_input_set = {
14770 .f = cmd_cfg_input_set_parsed,
14772 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14773 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14775 (void *)&cmd_cfg_input_set_port,
14776 (void *)&cmd_cfg_input_set_cfg,
14777 (void *)&cmd_cfg_input_set_port_id,
14778 (void *)&cmd_cfg_input_set_pctype,
14779 (void *)&cmd_cfg_input_set_pctype_id,
14780 (void *)&cmd_cfg_input_set_inset_type,
14781 (void *)&cmd_cfg_input_set_opt,
14782 (void *)&cmd_cfg_input_set_field,
14783 (void *)&cmd_cfg_input_set_field_idx,
14788 /* Clear input set */
14789 struct cmd_clear_input_set_result {
14790 cmdline_fixed_string_t port;
14791 cmdline_fixed_string_t cfg;
14793 cmdline_fixed_string_t pctype;
14795 cmdline_fixed_string_t inset_type;
14796 cmdline_fixed_string_t clear;
14797 cmdline_fixed_string_t all;
14801 cmd_clear_input_set_parsed(
14802 __rte_unused void *parsed_result,
14803 __rte_unused struct cmdline *cl,
14804 __rte_unused void *data)
14806 #ifdef RTE_NET_I40E
14807 struct cmd_clear_input_set_result *res = parsed_result;
14808 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14809 struct rte_pmd_i40e_inset inset;
14811 int ret = -ENOTSUP;
14813 if (!all_ports_stopped()) {
14814 printf("Please stop all ports first\n");
14818 #ifdef RTE_NET_I40E
14819 if (!strcmp(res->inset_type, "hash_inset"))
14820 inset_type = INSET_HASH;
14821 else if (!strcmp(res->inset_type, "fdir_inset"))
14822 inset_type = INSET_FDIR;
14823 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14824 inset_type = INSET_FDIR_FLX;
14826 memset(&inset, 0, sizeof(inset));
14828 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14829 &inset, inset_type);
14831 printf("Failed to clear input set.\n");
14837 if (ret == -ENOTSUP)
14838 printf("Function not supported\n");
14841 cmdline_parse_token_string_t cmd_clear_input_set_port =
14842 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14844 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14845 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14847 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14848 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14849 port_id, RTE_UINT16);
14850 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14851 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14853 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14854 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14855 pctype_id, RTE_UINT8);
14856 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14857 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14859 "hash_inset#fdir_inset#fdir_flx_inset");
14860 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14861 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14863 cmdline_parse_token_string_t cmd_clear_input_set_all =
14864 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14867 cmdline_parse_inst_t cmd_clear_input_set = {
14868 .f = cmd_clear_input_set_parsed,
14870 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14871 "fdir_inset|fdir_flx_inset clear all",
14873 (void *)&cmd_clear_input_set_port,
14874 (void *)&cmd_clear_input_set_cfg,
14875 (void *)&cmd_clear_input_set_port_id,
14876 (void *)&cmd_clear_input_set_pctype,
14877 (void *)&cmd_clear_input_set_pctype_id,
14878 (void *)&cmd_clear_input_set_inset_type,
14879 (void *)&cmd_clear_input_set_clear,
14880 (void *)&cmd_clear_input_set_all,
14885 /* show vf stats */
14887 /* Common result structure for show vf stats */
14888 struct cmd_show_vf_stats_result {
14889 cmdline_fixed_string_t show;
14890 cmdline_fixed_string_t vf;
14891 cmdline_fixed_string_t stats;
14896 /* Common CLI fields show vf stats*/
14897 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14898 TOKEN_STRING_INITIALIZER
14899 (struct cmd_show_vf_stats_result,
14901 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14902 TOKEN_STRING_INITIALIZER
14903 (struct cmd_show_vf_stats_result,
14905 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14906 TOKEN_STRING_INITIALIZER
14907 (struct cmd_show_vf_stats_result,
14909 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14910 TOKEN_NUM_INITIALIZER
14911 (struct cmd_show_vf_stats_result,
14912 port_id, RTE_UINT16);
14913 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14914 TOKEN_NUM_INITIALIZER
14915 (struct cmd_show_vf_stats_result,
14916 vf_id, RTE_UINT16);
14919 cmd_show_vf_stats_parsed(
14920 void *parsed_result,
14921 __rte_unused struct cmdline *cl,
14922 __rte_unused void *data)
14924 struct cmd_show_vf_stats_result *res = parsed_result;
14925 struct rte_eth_stats stats;
14926 int ret = -ENOTSUP;
14927 static const char *nic_stats_border = "########################";
14929 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14932 memset(&stats, 0, sizeof(stats));
14934 #ifdef RTE_NET_I40E
14935 if (ret == -ENOTSUP)
14936 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14940 #ifdef RTE_NET_BNXT
14941 if (ret == -ENOTSUP)
14942 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14951 printf("invalid vf_id %d\n", res->vf_id);
14954 printf("invalid port_id %d\n", res->port_id);
14957 printf("function not implemented\n");
14960 printf("programming error: (%s)\n", strerror(-ret));
14963 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14964 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14966 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14968 stats.ipackets, stats.imissed, stats.ibytes);
14969 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14970 printf(" RX-nombuf: %-10"PRIu64"\n",
14972 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14974 stats.opackets, stats.oerrors, stats.obytes);
14976 printf(" %s############################%s\n",
14977 nic_stats_border, nic_stats_border);
14980 cmdline_parse_inst_t cmd_show_vf_stats = {
14981 .f = cmd_show_vf_stats_parsed,
14983 .help_str = "show vf stats <port_id> <vf_id>",
14985 (void *)&cmd_show_vf_stats_show,
14986 (void *)&cmd_show_vf_stats_vf,
14987 (void *)&cmd_show_vf_stats_stats,
14988 (void *)&cmd_show_vf_stats_port_id,
14989 (void *)&cmd_show_vf_stats_vf_id,
14994 /* clear vf stats */
14996 /* Common result structure for clear vf stats */
14997 struct cmd_clear_vf_stats_result {
14998 cmdline_fixed_string_t clear;
14999 cmdline_fixed_string_t vf;
15000 cmdline_fixed_string_t stats;
15005 /* Common CLI fields clear vf stats*/
15006 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15007 TOKEN_STRING_INITIALIZER
15008 (struct cmd_clear_vf_stats_result,
15010 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15011 TOKEN_STRING_INITIALIZER
15012 (struct cmd_clear_vf_stats_result,
15014 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15015 TOKEN_STRING_INITIALIZER
15016 (struct cmd_clear_vf_stats_result,
15018 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15019 TOKEN_NUM_INITIALIZER
15020 (struct cmd_clear_vf_stats_result,
15021 port_id, RTE_UINT16);
15022 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15023 TOKEN_NUM_INITIALIZER
15024 (struct cmd_clear_vf_stats_result,
15025 vf_id, RTE_UINT16);
15028 cmd_clear_vf_stats_parsed(
15029 void *parsed_result,
15030 __rte_unused struct cmdline *cl,
15031 __rte_unused void *data)
15033 struct cmd_clear_vf_stats_result *res = parsed_result;
15034 int ret = -ENOTSUP;
15036 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15039 #ifdef RTE_NET_I40E
15040 if (ret == -ENOTSUP)
15041 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15044 #ifdef RTE_NET_BNXT
15045 if (ret == -ENOTSUP)
15046 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15054 printf("invalid vf_id %d\n", res->vf_id);
15057 printf("invalid port_id %d\n", res->port_id);
15060 printf("function not implemented\n");
15063 printf("programming error: (%s)\n", strerror(-ret));
15067 cmdline_parse_inst_t cmd_clear_vf_stats = {
15068 .f = cmd_clear_vf_stats_parsed,
15070 .help_str = "clear vf stats <port_id> <vf_id>",
15072 (void *)&cmd_clear_vf_stats_clear,
15073 (void *)&cmd_clear_vf_stats_vf,
15074 (void *)&cmd_clear_vf_stats_stats,
15075 (void *)&cmd_clear_vf_stats_port_id,
15076 (void *)&cmd_clear_vf_stats_vf_id,
15081 /* port config pctype mapping reset */
15083 /* Common result structure for port config pctype mapping reset */
15084 struct cmd_pctype_mapping_reset_result {
15085 cmdline_fixed_string_t port;
15086 cmdline_fixed_string_t config;
15088 cmdline_fixed_string_t pctype;
15089 cmdline_fixed_string_t mapping;
15090 cmdline_fixed_string_t reset;
15093 /* Common CLI fields for port config pctype mapping reset*/
15094 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15095 TOKEN_STRING_INITIALIZER
15096 (struct cmd_pctype_mapping_reset_result,
15098 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15099 TOKEN_STRING_INITIALIZER
15100 (struct cmd_pctype_mapping_reset_result,
15102 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15103 TOKEN_NUM_INITIALIZER
15104 (struct cmd_pctype_mapping_reset_result,
15105 port_id, RTE_UINT16);
15106 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15107 TOKEN_STRING_INITIALIZER
15108 (struct cmd_pctype_mapping_reset_result,
15110 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15111 TOKEN_STRING_INITIALIZER
15112 (struct cmd_pctype_mapping_reset_result,
15113 mapping, "mapping");
15114 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15115 TOKEN_STRING_INITIALIZER
15116 (struct cmd_pctype_mapping_reset_result,
15120 cmd_pctype_mapping_reset_parsed(
15121 void *parsed_result,
15122 __rte_unused struct cmdline *cl,
15123 __rte_unused void *data)
15125 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15126 int ret = -ENOTSUP;
15128 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15131 #ifdef RTE_NET_I40E
15132 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15139 printf("invalid port_id %d\n", res->port_id);
15142 printf("function not implemented\n");
15145 printf("programming error: (%s)\n", strerror(-ret));
15149 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15150 .f = cmd_pctype_mapping_reset_parsed,
15152 .help_str = "port config <port_id> pctype mapping reset",
15154 (void *)&cmd_pctype_mapping_reset_port,
15155 (void *)&cmd_pctype_mapping_reset_config,
15156 (void *)&cmd_pctype_mapping_reset_port_id,
15157 (void *)&cmd_pctype_mapping_reset_pctype,
15158 (void *)&cmd_pctype_mapping_reset_mapping,
15159 (void *)&cmd_pctype_mapping_reset_reset,
15164 /* show port pctype mapping */
15166 /* Common result structure for show port pctype mapping */
15167 struct cmd_pctype_mapping_get_result {
15168 cmdline_fixed_string_t show;
15169 cmdline_fixed_string_t port;
15171 cmdline_fixed_string_t pctype;
15172 cmdline_fixed_string_t mapping;
15175 /* Common CLI fields for pctype mapping get */
15176 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15177 TOKEN_STRING_INITIALIZER
15178 (struct cmd_pctype_mapping_get_result,
15180 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15181 TOKEN_STRING_INITIALIZER
15182 (struct cmd_pctype_mapping_get_result,
15184 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15185 TOKEN_NUM_INITIALIZER
15186 (struct cmd_pctype_mapping_get_result,
15187 port_id, RTE_UINT16);
15188 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15189 TOKEN_STRING_INITIALIZER
15190 (struct cmd_pctype_mapping_get_result,
15192 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15193 TOKEN_STRING_INITIALIZER
15194 (struct cmd_pctype_mapping_get_result,
15195 mapping, "mapping");
15198 cmd_pctype_mapping_get_parsed(
15199 void *parsed_result,
15200 __rte_unused struct cmdline *cl,
15201 __rte_unused void *data)
15203 struct cmd_pctype_mapping_get_result *res = parsed_result;
15204 int ret = -ENOTSUP;
15205 #ifdef RTE_NET_I40E
15206 struct rte_pmd_i40e_flow_type_mapping
15207 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15208 int i, j, first_pctype;
15211 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15214 #ifdef RTE_NET_I40E
15215 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15222 printf("invalid port_id %d\n", res->port_id);
15225 printf("function not implemented\n");
15228 printf("programming error: (%s)\n", strerror(-ret));
15232 #ifdef RTE_NET_I40E
15233 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15234 if (mapping[i].pctype != 0ULL) {
15237 printf("pctype: ");
15238 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15239 if (mapping[i].pctype & (1ULL << j)) {
15240 printf(first_pctype ?
15241 "%02d" : ",%02d", j);
15245 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15251 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15252 .f = cmd_pctype_mapping_get_parsed,
15254 .help_str = "show port <port_id> pctype mapping",
15256 (void *)&cmd_pctype_mapping_get_show,
15257 (void *)&cmd_pctype_mapping_get_port,
15258 (void *)&cmd_pctype_mapping_get_port_id,
15259 (void *)&cmd_pctype_mapping_get_pctype,
15260 (void *)&cmd_pctype_mapping_get_mapping,
15265 /* port config pctype mapping update */
15267 /* Common result structure for port config pctype mapping update */
15268 struct cmd_pctype_mapping_update_result {
15269 cmdline_fixed_string_t port;
15270 cmdline_fixed_string_t config;
15272 cmdline_fixed_string_t pctype;
15273 cmdline_fixed_string_t mapping;
15274 cmdline_fixed_string_t update;
15275 cmdline_fixed_string_t pctype_list;
15276 uint16_t flow_type;
15279 /* Common CLI fields for pctype mapping update*/
15280 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15281 TOKEN_STRING_INITIALIZER
15282 (struct cmd_pctype_mapping_update_result,
15284 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15285 TOKEN_STRING_INITIALIZER
15286 (struct cmd_pctype_mapping_update_result,
15288 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15289 TOKEN_NUM_INITIALIZER
15290 (struct cmd_pctype_mapping_update_result,
15291 port_id, RTE_UINT16);
15292 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15293 TOKEN_STRING_INITIALIZER
15294 (struct cmd_pctype_mapping_update_result,
15296 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15297 TOKEN_STRING_INITIALIZER
15298 (struct cmd_pctype_mapping_update_result,
15299 mapping, "mapping");
15300 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15301 TOKEN_STRING_INITIALIZER
15302 (struct cmd_pctype_mapping_update_result,
15304 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15305 TOKEN_STRING_INITIALIZER
15306 (struct cmd_pctype_mapping_update_result,
15307 pctype_list, NULL);
15308 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15309 TOKEN_NUM_INITIALIZER
15310 (struct cmd_pctype_mapping_update_result,
15311 flow_type, RTE_UINT16);
15314 cmd_pctype_mapping_update_parsed(
15315 void *parsed_result,
15316 __rte_unused struct cmdline *cl,
15317 __rte_unused void *data)
15319 struct cmd_pctype_mapping_update_result *res = parsed_result;
15320 int ret = -ENOTSUP;
15321 #ifdef RTE_NET_I40E
15322 struct rte_pmd_i40e_flow_type_mapping mapping;
15324 unsigned int nb_item;
15325 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15328 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15331 #ifdef RTE_NET_I40E
15332 nb_item = parse_item_list(res->pctype_list, "pctypes",
15333 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15334 mapping.flow_type = res->flow_type;
15335 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15336 mapping.pctype |= (1ULL << pctype_list[i]);
15337 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15347 printf("invalid pctype or flow type\n");
15350 printf("invalid port_id %d\n", res->port_id);
15353 printf("function not implemented\n");
15356 printf("programming error: (%s)\n", strerror(-ret));
15360 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15361 .f = cmd_pctype_mapping_update_parsed,
15363 .help_str = "port config <port_id> pctype mapping update"
15364 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15366 (void *)&cmd_pctype_mapping_update_port,
15367 (void *)&cmd_pctype_mapping_update_config,
15368 (void *)&cmd_pctype_mapping_update_port_id,
15369 (void *)&cmd_pctype_mapping_update_pctype,
15370 (void *)&cmd_pctype_mapping_update_mapping,
15371 (void *)&cmd_pctype_mapping_update_update,
15372 (void *)&cmd_pctype_mapping_update_pc_type,
15373 (void *)&cmd_pctype_mapping_update_flow_type,
15378 /* ptype mapping get */
15380 /* Common result structure for ptype mapping get */
15381 struct cmd_ptype_mapping_get_result {
15382 cmdline_fixed_string_t ptype;
15383 cmdline_fixed_string_t mapping;
15384 cmdline_fixed_string_t get;
15386 uint8_t valid_only;
15389 /* Common CLI fields for ptype mapping get */
15390 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15391 TOKEN_STRING_INITIALIZER
15392 (struct cmd_ptype_mapping_get_result,
15394 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15395 TOKEN_STRING_INITIALIZER
15396 (struct cmd_ptype_mapping_get_result,
15397 mapping, "mapping");
15398 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15399 TOKEN_STRING_INITIALIZER
15400 (struct cmd_ptype_mapping_get_result,
15402 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15403 TOKEN_NUM_INITIALIZER
15404 (struct cmd_ptype_mapping_get_result,
15405 port_id, RTE_UINT16);
15406 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15407 TOKEN_NUM_INITIALIZER
15408 (struct cmd_ptype_mapping_get_result,
15409 valid_only, RTE_UINT8);
15412 cmd_ptype_mapping_get_parsed(
15413 void *parsed_result,
15414 __rte_unused struct cmdline *cl,
15415 __rte_unused void *data)
15417 struct cmd_ptype_mapping_get_result *res = parsed_result;
15418 int ret = -ENOTSUP;
15419 #ifdef RTE_NET_I40E
15420 int max_ptype_num = 256;
15421 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15426 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15429 #ifdef RTE_NET_I40E
15430 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15441 printf("invalid port_id %d\n", res->port_id);
15444 printf("function not implemented\n");
15447 printf("programming error: (%s)\n", strerror(-ret));
15450 #ifdef RTE_NET_I40E
15452 for (i = 0; i < count; i++)
15453 printf("%3d\t0x%08x\n",
15454 mapping[i].hw_ptype, mapping[i].sw_ptype);
15459 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15460 .f = cmd_ptype_mapping_get_parsed,
15462 .help_str = "ptype mapping get <port_id> <valid_only>",
15464 (void *)&cmd_ptype_mapping_get_ptype,
15465 (void *)&cmd_ptype_mapping_get_mapping,
15466 (void *)&cmd_ptype_mapping_get_get,
15467 (void *)&cmd_ptype_mapping_get_port_id,
15468 (void *)&cmd_ptype_mapping_get_valid_only,
15473 /* ptype mapping replace */
15475 /* Common result structure for ptype mapping replace */
15476 struct cmd_ptype_mapping_replace_result {
15477 cmdline_fixed_string_t ptype;
15478 cmdline_fixed_string_t mapping;
15479 cmdline_fixed_string_t replace;
15486 /* Common CLI fields for ptype mapping replace */
15487 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15488 TOKEN_STRING_INITIALIZER
15489 (struct cmd_ptype_mapping_replace_result,
15491 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15492 TOKEN_STRING_INITIALIZER
15493 (struct cmd_ptype_mapping_replace_result,
15494 mapping, "mapping");
15495 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15496 TOKEN_STRING_INITIALIZER
15497 (struct cmd_ptype_mapping_replace_result,
15498 replace, "replace");
15499 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15500 TOKEN_NUM_INITIALIZER
15501 (struct cmd_ptype_mapping_replace_result,
15502 port_id, RTE_UINT16);
15503 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15504 TOKEN_NUM_INITIALIZER
15505 (struct cmd_ptype_mapping_replace_result,
15506 target, RTE_UINT32);
15507 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15508 TOKEN_NUM_INITIALIZER
15509 (struct cmd_ptype_mapping_replace_result,
15511 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15512 TOKEN_NUM_INITIALIZER
15513 (struct cmd_ptype_mapping_replace_result,
15514 pkt_type, RTE_UINT32);
15517 cmd_ptype_mapping_replace_parsed(
15518 void *parsed_result,
15519 __rte_unused struct cmdline *cl,
15520 __rte_unused void *data)
15522 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15523 int ret = -ENOTSUP;
15525 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15528 #ifdef RTE_NET_I40E
15529 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15539 printf("invalid ptype 0x%8x or 0x%8x\n",
15540 res->target, res->pkt_type);
15543 printf("invalid port_id %d\n", res->port_id);
15546 printf("function not implemented\n");
15549 printf("programming error: (%s)\n", strerror(-ret));
15553 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15554 .f = cmd_ptype_mapping_replace_parsed,
15557 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15559 (void *)&cmd_ptype_mapping_replace_ptype,
15560 (void *)&cmd_ptype_mapping_replace_mapping,
15561 (void *)&cmd_ptype_mapping_replace_replace,
15562 (void *)&cmd_ptype_mapping_replace_port_id,
15563 (void *)&cmd_ptype_mapping_replace_target,
15564 (void *)&cmd_ptype_mapping_replace_mask,
15565 (void *)&cmd_ptype_mapping_replace_pkt_type,
15570 /* ptype mapping reset */
15572 /* Common result structure for ptype mapping reset */
15573 struct cmd_ptype_mapping_reset_result {
15574 cmdline_fixed_string_t ptype;
15575 cmdline_fixed_string_t mapping;
15576 cmdline_fixed_string_t reset;
15580 /* Common CLI fields for ptype mapping reset*/
15581 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15582 TOKEN_STRING_INITIALIZER
15583 (struct cmd_ptype_mapping_reset_result,
15585 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15586 TOKEN_STRING_INITIALIZER
15587 (struct cmd_ptype_mapping_reset_result,
15588 mapping, "mapping");
15589 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15590 TOKEN_STRING_INITIALIZER
15591 (struct cmd_ptype_mapping_reset_result,
15593 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15594 TOKEN_NUM_INITIALIZER
15595 (struct cmd_ptype_mapping_reset_result,
15596 port_id, RTE_UINT16);
15599 cmd_ptype_mapping_reset_parsed(
15600 void *parsed_result,
15601 __rte_unused struct cmdline *cl,
15602 __rte_unused void *data)
15604 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15605 int ret = -ENOTSUP;
15607 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15610 #ifdef RTE_NET_I40E
15611 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15618 printf("invalid port_id %d\n", res->port_id);
15621 printf("function not implemented\n");
15624 printf("programming error: (%s)\n", strerror(-ret));
15628 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15629 .f = cmd_ptype_mapping_reset_parsed,
15631 .help_str = "ptype mapping reset <port_id>",
15633 (void *)&cmd_ptype_mapping_reset_ptype,
15634 (void *)&cmd_ptype_mapping_reset_mapping,
15635 (void *)&cmd_ptype_mapping_reset_reset,
15636 (void *)&cmd_ptype_mapping_reset_port_id,
15641 /* ptype mapping update */
15643 /* Common result structure for ptype mapping update */
15644 struct cmd_ptype_mapping_update_result {
15645 cmdline_fixed_string_t ptype;
15646 cmdline_fixed_string_t mapping;
15647 cmdline_fixed_string_t reset;
15653 /* Common CLI fields for ptype mapping update*/
15654 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15655 TOKEN_STRING_INITIALIZER
15656 (struct cmd_ptype_mapping_update_result,
15658 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15659 TOKEN_STRING_INITIALIZER
15660 (struct cmd_ptype_mapping_update_result,
15661 mapping, "mapping");
15662 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15663 TOKEN_STRING_INITIALIZER
15664 (struct cmd_ptype_mapping_update_result,
15666 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15667 TOKEN_NUM_INITIALIZER
15668 (struct cmd_ptype_mapping_update_result,
15669 port_id, RTE_UINT16);
15670 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15671 TOKEN_NUM_INITIALIZER
15672 (struct cmd_ptype_mapping_update_result,
15673 hw_ptype, RTE_UINT8);
15674 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15675 TOKEN_NUM_INITIALIZER
15676 (struct cmd_ptype_mapping_update_result,
15677 sw_ptype, RTE_UINT32);
15680 cmd_ptype_mapping_update_parsed(
15681 void *parsed_result,
15682 __rte_unused struct cmdline *cl,
15683 __rte_unused void *data)
15685 struct cmd_ptype_mapping_update_result *res = parsed_result;
15686 int ret = -ENOTSUP;
15687 #ifdef RTE_NET_I40E
15688 struct rte_pmd_i40e_ptype_mapping mapping;
15690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15693 #ifdef RTE_NET_I40E
15694 mapping.hw_ptype = res->hw_ptype;
15695 mapping.sw_ptype = res->sw_ptype;
15696 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15706 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15709 printf("invalid port_id %d\n", res->port_id);
15712 printf("function not implemented\n");
15715 printf("programming error: (%s)\n", strerror(-ret));
15719 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15720 .f = cmd_ptype_mapping_update_parsed,
15722 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15724 (void *)&cmd_ptype_mapping_update_ptype,
15725 (void *)&cmd_ptype_mapping_update_mapping,
15726 (void *)&cmd_ptype_mapping_update_update,
15727 (void *)&cmd_ptype_mapping_update_port_id,
15728 (void *)&cmd_ptype_mapping_update_hw_ptype,
15729 (void *)&cmd_ptype_mapping_update_sw_ptype,
15734 /* Common result structure for file commands */
15735 struct cmd_cmdfile_result {
15736 cmdline_fixed_string_t load;
15737 cmdline_fixed_string_t filename;
15740 /* Common CLI fields for file commands */
15741 cmdline_parse_token_string_t cmd_load_cmdfile =
15742 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15743 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15744 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15747 cmd_load_from_file_parsed(
15748 void *parsed_result,
15749 __rte_unused struct cmdline *cl,
15750 __rte_unused void *data)
15752 struct cmd_cmdfile_result *res = parsed_result;
15754 cmdline_read_from_file(res->filename);
15757 cmdline_parse_inst_t cmd_load_from_file = {
15758 .f = cmd_load_from_file_parsed,
15760 .help_str = "load <filename>",
15762 (void *)&cmd_load_cmdfile,
15763 (void *)&cmd_load_cmdfile_filename,
15768 /* Get Rx offloads capabilities */
15769 struct cmd_rx_offload_get_capa_result {
15770 cmdline_fixed_string_t show;
15771 cmdline_fixed_string_t port;
15773 cmdline_fixed_string_t rx_offload;
15774 cmdline_fixed_string_t capabilities;
15777 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15778 TOKEN_STRING_INITIALIZER
15779 (struct cmd_rx_offload_get_capa_result,
15781 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15782 TOKEN_STRING_INITIALIZER
15783 (struct cmd_rx_offload_get_capa_result,
15785 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15786 TOKEN_NUM_INITIALIZER
15787 (struct cmd_rx_offload_get_capa_result,
15788 port_id, RTE_UINT16);
15789 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15790 TOKEN_STRING_INITIALIZER
15791 (struct cmd_rx_offload_get_capa_result,
15792 rx_offload, "rx_offload");
15793 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15794 TOKEN_STRING_INITIALIZER
15795 (struct cmd_rx_offload_get_capa_result,
15796 capabilities, "capabilities");
15799 print_rx_offloads(uint64_t offloads)
15801 uint64_t single_offload;
15809 begin = __builtin_ctzll(offloads);
15810 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15812 single_offload = 1ULL << begin;
15813 for (bit = begin; bit < end; bit++) {
15814 if (offloads & single_offload)
15816 rte_eth_dev_rx_offload_name(single_offload));
15817 single_offload <<= 1;
15822 cmd_rx_offload_get_capa_parsed(
15823 void *parsed_result,
15824 __rte_unused struct cmdline *cl,
15825 __rte_unused void *data)
15827 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15828 struct rte_eth_dev_info dev_info;
15829 portid_t port_id = res->port_id;
15830 uint64_t queue_offloads;
15831 uint64_t port_offloads;
15834 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15838 queue_offloads = dev_info.rx_queue_offload_capa;
15839 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15841 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15842 printf(" Per Queue :");
15843 print_rx_offloads(queue_offloads);
15846 printf(" Per Port :");
15847 print_rx_offloads(port_offloads);
15851 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15852 .f = cmd_rx_offload_get_capa_parsed,
15854 .help_str = "show port <port_id> rx_offload capabilities",
15856 (void *)&cmd_rx_offload_get_capa_show,
15857 (void *)&cmd_rx_offload_get_capa_port,
15858 (void *)&cmd_rx_offload_get_capa_port_id,
15859 (void *)&cmd_rx_offload_get_capa_rx_offload,
15860 (void *)&cmd_rx_offload_get_capa_capabilities,
15865 /* Get Rx offloads configuration */
15866 struct cmd_rx_offload_get_configuration_result {
15867 cmdline_fixed_string_t show;
15868 cmdline_fixed_string_t port;
15870 cmdline_fixed_string_t rx_offload;
15871 cmdline_fixed_string_t configuration;
15874 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15875 TOKEN_STRING_INITIALIZER
15876 (struct cmd_rx_offload_get_configuration_result,
15878 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15879 TOKEN_STRING_INITIALIZER
15880 (struct cmd_rx_offload_get_configuration_result,
15882 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15883 TOKEN_NUM_INITIALIZER
15884 (struct cmd_rx_offload_get_configuration_result,
15885 port_id, RTE_UINT16);
15886 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15887 TOKEN_STRING_INITIALIZER
15888 (struct cmd_rx_offload_get_configuration_result,
15889 rx_offload, "rx_offload");
15890 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15891 TOKEN_STRING_INITIALIZER
15892 (struct cmd_rx_offload_get_configuration_result,
15893 configuration, "configuration");
15896 cmd_rx_offload_get_configuration_parsed(
15897 void *parsed_result,
15898 __rte_unused struct cmdline *cl,
15899 __rte_unused void *data)
15901 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15902 struct rte_eth_dev_info dev_info;
15903 portid_t port_id = res->port_id;
15904 struct rte_port *port = &ports[port_id];
15905 uint64_t port_offloads;
15906 uint64_t queue_offloads;
15907 uint16_t nb_rx_queues;
15911 printf("Rx Offloading Configuration of port %d :\n", port_id);
15913 port_offloads = port->dev_conf.rxmode.offloads;
15915 print_rx_offloads(port_offloads);
15918 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15922 nb_rx_queues = dev_info.nb_rx_queues;
15923 for (q = 0; q < nb_rx_queues; q++) {
15924 queue_offloads = port->rx_conf[q].offloads;
15925 printf(" Queue[%2d] :", q);
15926 print_rx_offloads(queue_offloads);
15932 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15933 .f = cmd_rx_offload_get_configuration_parsed,
15935 .help_str = "show port <port_id> rx_offload configuration",
15937 (void *)&cmd_rx_offload_get_configuration_show,
15938 (void *)&cmd_rx_offload_get_configuration_port,
15939 (void *)&cmd_rx_offload_get_configuration_port_id,
15940 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15941 (void *)&cmd_rx_offload_get_configuration_configuration,
15946 /* Enable/Disable a per port offloading */
15947 struct cmd_config_per_port_rx_offload_result {
15948 cmdline_fixed_string_t port;
15949 cmdline_fixed_string_t config;
15951 cmdline_fixed_string_t rx_offload;
15952 cmdline_fixed_string_t offload;
15953 cmdline_fixed_string_t on_off;
15956 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15957 TOKEN_STRING_INITIALIZER
15958 (struct cmd_config_per_port_rx_offload_result,
15960 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15961 TOKEN_STRING_INITIALIZER
15962 (struct cmd_config_per_port_rx_offload_result,
15964 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15965 TOKEN_NUM_INITIALIZER
15966 (struct cmd_config_per_port_rx_offload_result,
15967 port_id, RTE_UINT16);
15968 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15969 TOKEN_STRING_INITIALIZER
15970 (struct cmd_config_per_port_rx_offload_result,
15971 rx_offload, "rx_offload");
15972 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15973 TOKEN_STRING_INITIALIZER
15974 (struct cmd_config_per_port_rx_offload_result,
15975 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15976 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15977 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15978 "scatter#buffer_split#timestamp#security#"
15979 "keep_crc#rss_hash");
15980 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15981 TOKEN_STRING_INITIALIZER
15982 (struct cmd_config_per_port_rx_offload_result,
15986 search_rx_offload(const char *name)
15988 uint64_t single_offload;
15989 const char *single_name;
15993 single_offload = 1;
15994 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15995 single_name = rte_eth_dev_rx_offload_name(single_offload);
15996 if (!strcasecmp(single_name, name)) {
16000 single_offload <<= 1;
16004 return single_offload;
16010 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16011 __rte_unused struct cmdline *cl,
16012 __rte_unused void *data)
16014 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16015 portid_t port_id = res->port_id;
16016 struct rte_eth_dev_info dev_info;
16017 struct rte_port *port = &ports[port_id];
16018 uint64_t single_offload;
16019 uint16_t nb_rx_queues;
16023 if (port->port_status != RTE_PORT_STOPPED) {
16024 printf("Error: Can't config offload when Port %d "
16025 "is not stopped\n", port_id);
16029 single_offload = search_rx_offload(res->offload);
16030 if (single_offload == 0) {
16031 printf("Unknown offload name: %s\n", res->offload);
16035 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16039 nb_rx_queues = dev_info.nb_rx_queues;
16040 if (!strcmp(res->on_off, "on")) {
16041 port->dev_conf.rxmode.offloads |= single_offload;
16042 for (q = 0; q < nb_rx_queues; q++)
16043 port->rx_conf[q].offloads |= single_offload;
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;
16050 cmd_reconfig_device_queue(port_id, 1, 1);
16053 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16054 .f = cmd_config_per_port_rx_offload_parsed,
16056 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16057 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16058 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16059 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16060 "keep_crc|rss_hash on|off",
16062 (void *)&cmd_config_per_port_rx_offload_result_port,
16063 (void *)&cmd_config_per_port_rx_offload_result_config,
16064 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16065 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16066 (void *)&cmd_config_per_port_rx_offload_result_offload,
16067 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16072 /* Enable/Disable a per queue offloading */
16073 struct cmd_config_per_queue_rx_offload_result {
16074 cmdline_fixed_string_t port;
16076 cmdline_fixed_string_t rxq;
16078 cmdline_fixed_string_t rx_offload;
16079 cmdline_fixed_string_t offload;
16080 cmdline_fixed_string_t on_off;
16083 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16084 TOKEN_STRING_INITIALIZER
16085 (struct cmd_config_per_queue_rx_offload_result,
16087 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16088 TOKEN_NUM_INITIALIZER
16089 (struct cmd_config_per_queue_rx_offload_result,
16090 port_id, RTE_UINT16);
16091 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16092 TOKEN_STRING_INITIALIZER
16093 (struct cmd_config_per_queue_rx_offload_result,
16095 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16096 TOKEN_NUM_INITIALIZER
16097 (struct cmd_config_per_queue_rx_offload_result,
16098 queue_id, RTE_UINT16);
16099 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16100 TOKEN_STRING_INITIALIZER
16101 (struct cmd_config_per_queue_rx_offload_result,
16102 rx_offload, "rx_offload");
16103 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16104 TOKEN_STRING_INITIALIZER
16105 (struct cmd_config_per_queue_rx_offload_result,
16106 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16107 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16108 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16109 "scatter#buffer_split#timestamp#security#keep_crc");
16110 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16111 TOKEN_STRING_INITIALIZER
16112 (struct cmd_config_per_queue_rx_offload_result,
16116 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16117 __rte_unused struct cmdline *cl,
16118 __rte_unused void *data)
16120 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16121 struct rte_eth_dev_info dev_info;
16122 portid_t port_id = res->port_id;
16123 uint16_t queue_id = res->queue_id;
16124 struct rte_port *port = &ports[port_id];
16125 uint64_t single_offload;
16128 if (port->port_status != RTE_PORT_STOPPED) {
16129 printf("Error: Can't config offload when Port %d "
16130 "is not stopped\n", port_id);
16134 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16138 if (queue_id >= dev_info.nb_rx_queues) {
16139 printf("Error: input queue_id should be 0 ... "
16140 "%d\n", dev_info.nb_rx_queues - 1);
16144 single_offload = search_rx_offload(res->offload);
16145 if (single_offload == 0) {
16146 printf("Unknown offload name: %s\n", res->offload);
16150 if (!strcmp(res->on_off, "on"))
16151 port->rx_conf[queue_id].offloads |= single_offload;
16153 port->rx_conf[queue_id].offloads &= ~single_offload;
16155 cmd_reconfig_device_queue(port_id, 1, 1);
16158 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16159 .f = cmd_config_per_queue_rx_offload_parsed,
16161 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16162 "vlan_strip|ipv4_cksum|"
16163 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16164 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16165 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16168 (void *)&cmd_config_per_queue_rx_offload_result_port,
16169 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16170 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16171 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16172 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16173 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16174 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16179 /* Get Tx offloads capabilities */
16180 struct cmd_tx_offload_get_capa_result {
16181 cmdline_fixed_string_t show;
16182 cmdline_fixed_string_t port;
16184 cmdline_fixed_string_t tx_offload;
16185 cmdline_fixed_string_t capabilities;
16188 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16189 TOKEN_STRING_INITIALIZER
16190 (struct cmd_tx_offload_get_capa_result,
16192 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16193 TOKEN_STRING_INITIALIZER
16194 (struct cmd_tx_offload_get_capa_result,
16196 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16197 TOKEN_NUM_INITIALIZER
16198 (struct cmd_tx_offload_get_capa_result,
16199 port_id, RTE_UINT16);
16200 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16201 TOKEN_STRING_INITIALIZER
16202 (struct cmd_tx_offload_get_capa_result,
16203 tx_offload, "tx_offload");
16204 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16205 TOKEN_STRING_INITIALIZER
16206 (struct cmd_tx_offload_get_capa_result,
16207 capabilities, "capabilities");
16210 print_tx_offloads(uint64_t offloads)
16212 uint64_t single_offload;
16220 begin = __builtin_ctzll(offloads);
16221 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16223 single_offload = 1ULL << begin;
16224 for (bit = begin; bit < end; bit++) {
16225 if (offloads & single_offload)
16227 rte_eth_dev_tx_offload_name(single_offload));
16228 single_offload <<= 1;
16233 cmd_tx_offload_get_capa_parsed(
16234 void *parsed_result,
16235 __rte_unused struct cmdline *cl,
16236 __rte_unused void *data)
16238 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16239 struct rte_eth_dev_info dev_info;
16240 portid_t port_id = res->port_id;
16241 uint64_t queue_offloads;
16242 uint64_t port_offloads;
16245 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16249 queue_offloads = dev_info.tx_queue_offload_capa;
16250 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16252 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16253 printf(" Per Queue :");
16254 print_tx_offloads(queue_offloads);
16257 printf(" Per Port :");
16258 print_tx_offloads(port_offloads);
16262 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16263 .f = cmd_tx_offload_get_capa_parsed,
16265 .help_str = "show port <port_id> tx_offload capabilities",
16267 (void *)&cmd_tx_offload_get_capa_show,
16268 (void *)&cmd_tx_offload_get_capa_port,
16269 (void *)&cmd_tx_offload_get_capa_port_id,
16270 (void *)&cmd_tx_offload_get_capa_tx_offload,
16271 (void *)&cmd_tx_offload_get_capa_capabilities,
16276 /* Get Tx offloads configuration */
16277 struct cmd_tx_offload_get_configuration_result {
16278 cmdline_fixed_string_t show;
16279 cmdline_fixed_string_t port;
16281 cmdline_fixed_string_t tx_offload;
16282 cmdline_fixed_string_t configuration;
16285 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16286 TOKEN_STRING_INITIALIZER
16287 (struct cmd_tx_offload_get_configuration_result,
16289 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16290 TOKEN_STRING_INITIALIZER
16291 (struct cmd_tx_offload_get_configuration_result,
16293 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16294 TOKEN_NUM_INITIALIZER
16295 (struct cmd_tx_offload_get_configuration_result,
16296 port_id, RTE_UINT16);
16297 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16298 TOKEN_STRING_INITIALIZER
16299 (struct cmd_tx_offload_get_configuration_result,
16300 tx_offload, "tx_offload");
16301 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16302 TOKEN_STRING_INITIALIZER
16303 (struct cmd_tx_offload_get_configuration_result,
16304 configuration, "configuration");
16307 cmd_tx_offload_get_configuration_parsed(
16308 void *parsed_result,
16309 __rte_unused struct cmdline *cl,
16310 __rte_unused void *data)
16312 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16313 struct rte_eth_dev_info dev_info;
16314 portid_t port_id = res->port_id;
16315 struct rte_port *port = &ports[port_id];
16316 uint64_t port_offloads;
16317 uint64_t queue_offloads;
16318 uint16_t nb_tx_queues;
16322 printf("Tx Offloading Configuration of port %d :\n", port_id);
16324 port_offloads = port->dev_conf.txmode.offloads;
16326 print_tx_offloads(port_offloads);
16329 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16333 nb_tx_queues = dev_info.nb_tx_queues;
16334 for (q = 0; q < nb_tx_queues; q++) {
16335 queue_offloads = port->tx_conf[q].offloads;
16336 printf(" Queue[%2d] :", q);
16337 print_tx_offloads(queue_offloads);
16343 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16344 .f = cmd_tx_offload_get_configuration_parsed,
16346 .help_str = "show port <port_id> tx_offload configuration",
16348 (void *)&cmd_tx_offload_get_configuration_show,
16349 (void *)&cmd_tx_offload_get_configuration_port,
16350 (void *)&cmd_tx_offload_get_configuration_port_id,
16351 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16352 (void *)&cmd_tx_offload_get_configuration_configuration,
16357 /* Enable/Disable a per port offloading */
16358 struct cmd_config_per_port_tx_offload_result {
16359 cmdline_fixed_string_t port;
16360 cmdline_fixed_string_t config;
16362 cmdline_fixed_string_t tx_offload;
16363 cmdline_fixed_string_t offload;
16364 cmdline_fixed_string_t on_off;
16367 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16368 TOKEN_STRING_INITIALIZER
16369 (struct cmd_config_per_port_tx_offload_result,
16371 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16372 TOKEN_STRING_INITIALIZER
16373 (struct cmd_config_per_port_tx_offload_result,
16375 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16376 TOKEN_NUM_INITIALIZER
16377 (struct cmd_config_per_port_tx_offload_result,
16378 port_id, RTE_UINT16);
16379 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16380 TOKEN_STRING_INITIALIZER
16381 (struct cmd_config_per_port_tx_offload_result,
16382 tx_offload, "tx_offload");
16383 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16384 TOKEN_STRING_INITIALIZER
16385 (struct cmd_config_per_port_tx_offload_result,
16386 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16387 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16388 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16389 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16390 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16391 "send_on_timestamp");
16392 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16393 TOKEN_STRING_INITIALIZER
16394 (struct cmd_config_per_port_tx_offload_result,
16398 search_tx_offload(const char *name)
16400 uint64_t single_offload;
16401 const char *single_name;
16405 single_offload = 1;
16406 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16407 single_name = rte_eth_dev_tx_offload_name(single_offload);
16408 if (single_name == NULL)
16410 if (!strcasecmp(single_name, name)) {
16413 } else if (!strcasecmp(single_name, "UNKNOWN"))
16415 single_offload <<= 1;
16419 return single_offload;
16425 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16426 __rte_unused struct cmdline *cl,
16427 __rte_unused void *data)
16429 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16430 portid_t port_id = res->port_id;
16431 struct rte_eth_dev_info dev_info;
16432 struct rte_port *port = &ports[port_id];
16433 uint64_t single_offload;
16434 uint16_t nb_tx_queues;
16438 if (port->port_status != RTE_PORT_STOPPED) {
16439 printf("Error: Can't config offload when Port %d "
16440 "is not stopped\n", port_id);
16444 single_offload = search_tx_offload(res->offload);
16445 if (single_offload == 0) {
16446 printf("Unknown offload name: %s\n", res->offload);
16450 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16454 nb_tx_queues = dev_info.nb_tx_queues;
16455 if (!strcmp(res->on_off, "on")) {
16456 port->dev_conf.txmode.offloads |= single_offload;
16457 for (q = 0; q < nb_tx_queues; q++)
16458 port->tx_conf[q].offloads |= single_offload;
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;
16465 cmd_reconfig_device_queue(port_id, 1, 1);
16468 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16469 .f = cmd_config_per_port_tx_offload_parsed,
16471 .help_str = "port config <port_id> tx_offload "
16472 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16473 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16474 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16475 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16476 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16477 "send_on_timestamp on|off",
16479 (void *)&cmd_config_per_port_tx_offload_result_port,
16480 (void *)&cmd_config_per_port_tx_offload_result_config,
16481 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16482 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16483 (void *)&cmd_config_per_port_tx_offload_result_offload,
16484 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16489 /* Enable/Disable a per queue offloading */
16490 struct cmd_config_per_queue_tx_offload_result {
16491 cmdline_fixed_string_t port;
16493 cmdline_fixed_string_t txq;
16495 cmdline_fixed_string_t tx_offload;
16496 cmdline_fixed_string_t offload;
16497 cmdline_fixed_string_t on_off;
16500 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16501 TOKEN_STRING_INITIALIZER
16502 (struct cmd_config_per_queue_tx_offload_result,
16504 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16505 TOKEN_NUM_INITIALIZER
16506 (struct cmd_config_per_queue_tx_offload_result,
16507 port_id, RTE_UINT16);
16508 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16509 TOKEN_STRING_INITIALIZER
16510 (struct cmd_config_per_queue_tx_offload_result,
16512 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16513 TOKEN_NUM_INITIALIZER
16514 (struct cmd_config_per_queue_tx_offload_result,
16515 queue_id, RTE_UINT16);
16516 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16517 TOKEN_STRING_INITIALIZER
16518 (struct cmd_config_per_queue_tx_offload_result,
16519 tx_offload, "tx_offload");
16520 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16521 TOKEN_STRING_INITIALIZER
16522 (struct cmd_config_per_queue_tx_offload_result,
16523 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16524 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16525 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16526 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16527 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16528 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16529 TOKEN_STRING_INITIALIZER
16530 (struct cmd_config_per_queue_tx_offload_result,
16534 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16535 __rte_unused struct cmdline *cl,
16536 __rte_unused void *data)
16538 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16539 struct rte_eth_dev_info dev_info;
16540 portid_t port_id = res->port_id;
16541 uint16_t queue_id = res->queue_id;
16542 struct rte_port *port = &ports[port_id];
16543 uint64_t single_offload;
16546 if (port->port_status != RTE_PORT_STOPPED) {
16547 printf("Error: Can't config offload when Port %d "
16548 "is not stopped\n", port_id);
16552 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16556 if (queue_id >= dev_info.nb_tx_queues) {
16557 printf("Error: input queue_id should be 0 ... "
16558 "%d\n", dev_info.nb_tx_queues - 1);
16562 single_offload = search_tx_offload(res->offload);
16563 if (single_offload == 0) {
16564 printf("Unknown offload name: %s\n", res->offload);
16568 if (!strcmp(res->on_off, "on"))
16569 port->tx_conf[queue_id].offloads |= single_offload;
16571 port->tx_conf[queue_id].offloads &= ~single_offload;
16573 cmd_reconfig_device_queue(port_id, 1, 1);
16576 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16577 .f = cmd_config_per_queue_tx_offload_parsed,
16579 .help_str = "port <port_id> txq <queue_id> tx_offload "
16580 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16581 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16582 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16583 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16584 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16587 (void *)&cmd_config_per_queue_tx_offload_result_port,
16588 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16589 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16590 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16591 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16592 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16593 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16598 /* *** configure tx_metadata for specific port *** */
16599 struct cmd_config_tx_metadata_specific_result {
16600 cmdline_fixed_string_t port;
16601 cmdline_fixed_string_t keyword;
16603 cmdline_fixed_string_t item;
16608 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16609 __rte_unused struct cmdline *cl,
16610 __rte_unused void *data)
16612 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16614 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16616 ports[res->port_id].tx_metadata = res->value;
16617 /* Add/remove callback to insert valid metadata in every Tx packet. */
16618 if (ports[res->port_id].tx_metadata)
16619 add_tx_md_callback(res->port_id);
16621 remove_tx_md_callback(res->port_id);
16622 rte_flow_dynf_metadata_register();
16625 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16626 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16628 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16629 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16630 keyword, "config");
16631 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16632 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16633 port_id, RTE_UINT16);
16634 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16635 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16636 item, "tx_metadata");
16637 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16638 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16639 value, RTE_UINT32);
16641 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16642 .f = cmd_config_tx_metadata_specific_parsed,
16644 .help_str = "port config <port_id> tx_metadata <value>",
16646 (void *)&cmd_config_tx_metadata_specific_port,
16647 (void *)&cmd_config_tx_metadata_specific_keyword,
16648 (void *)&cmd_config_tx_metadata_specific_id,
16649 (void *)&cmd_config_tx_metadata_specific_item,
16650 (void *)&cmd_config_tx_metadata_specific_value,
16655 /* *** set dynf *** */
16656 struct cmd_config_tx_dynf_specific_result {
16657 cmdline_fixed_string_t port;
16658 cmdline_fixed_string_t keyword;
16660 cmdline_fixed_string_t item;
16661 cmdline_fixed_string_t name;
16662 cmdline_fixed_string_t value;
16666 cmd_config_dynf_specific_parsed(void *parsed_result,
16667 __rte_unused struct cmdline *cl,
16668 __rte_unused void *data)
16670 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16671 struct rte_mbuf_dynflag desc_flag;
16673 uint64_t old_port_flags;
16675 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16677 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16679 if (strlcpy(desc_flag.name, res->name,
16680 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16681 printf("Flag name too long\n");
16684 desc_flag.flags = 0;
16685 flag = rte_mbuf_dynflag_register(&desc_flag);
16687 printf("Can't register flag\n");
16690 strcpy(dynf_names[flag], desc_flag.name);
16692 old_port_flags = ports[res->port_id].mbuf_dynf;
16693 if (!strcmp(res->value, "set")) {
16694 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16695 if (old_port_flags == 0)
16696 add_tx_dynf_callback(res->port_id);
16698 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16699 if (ports[res->port_id].mbuf_dynf == 0)
16700 remove_tx_dynf_callback(res->port_id);
16704 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16705 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16707 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16708 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16709 keyword, "config");
16710 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16711 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16712 port_id, RTE_UINT16);
16713 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16714 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16716 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16717 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16719 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16720 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16721 value, "set#clear");
16723 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16724 .f = cmd_config_dynf_specific_parsed,
16726 .help_str = "port config <port id> dynf <name> set|clear",
16728 (void *)&cmd_config_tx_dynf_specific_port,
16729 (void *)&cmd_config_tx_dynf_specific_keyword,
16730 (void *)&cmd_config_tx_dynf_specific_port_id,
16731 (void *)&cmd_config_tx_dynf_specific_item,
16732 (void *)&cmd_config_tx_dynf_specific_name,
16733 (void *)&cmd_config_tx_dynf_specific_value,
16738 /* *** display tx_metadata per port configuration *** */
16739 struct cmd_show_tx_metadata_result {
16740 cmdline_fixed_string_t cmd_show;
16741 cmdline_fixed_string_t cmd_port;
16742 cmdline_fixed_string_t cmd_keyword;
16747 cmd_show_tx_metadata_parsed(void *parsed_result,
16748 __rte_unused struct cmdline *cl,
16749 __rte_unused void *data)
16751 struct cmd_show_tx_metadata_result *res = parsed_result;
16753 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16754 printf("invalid port id %u\n", res->cmd_pid);
16757 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16758 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16759 ports[res->cmd_pid].tx_metadata);
16763 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16764 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16766 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16767 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16769 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16770 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16771 cmd_pid, RTE_UINT16);
16772 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16773 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16774 cmd_keyword, "tx_metadata");
16776 cmdline_parse_inst_t cmd_show_tx_metadata = {
16777 .f = cmd_show_tx_metadata_parsed,
16779 .help_str = "show port <port_id> tx_metadata",
16781 (void *)&cmd_show_tx_metadata_show,
16782 (void *)&cmd_show_tx_metadata_port,
16783 (void *)&cmd_show_tx_metadata_pid,
16784 (void *)&cmd_show_tx_metadata_keyword,
16789 /* *** show fec capability per port configuration *** */
16790 struct cmd_show_fec_capability_result {
16791 cmdline_fixed_string_t cmd_show;
16792 cmdline_fixed_string_t cmd_port;
16793 cmdline_fixed_string_t cmd_fec;
16794 cmdline_fixed_string_t cmd_keyword;
16799 cmd_show_fec_capability_parsed(void *parsed_result,
16800 __rte_unused struct cmdline *cl,
16801 __rte_unused void *data)
16803 struct cmd_show_fec_capability_result *res = parsed_result;
16804 struct rte_eth_fec_capa *speed_fec_capa;
16808 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16809 printf("Invalid port id %u\n", res->cmd_pid);
16813 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16814 if (ret == -ENOTSUP) {
16815 printf("Function not implemented\n");
16817 } else if (ret < 0) {
16818 printf("Get FEC capability failed: %d\n", ret);
16822 num = (unsigned int)ret;
16823 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16824 if (speed_fec_capa == NULL) {
16825 printf("Failed to alloc FEC capability buffer\n");
16829 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16831 printf("Error getting FEC capability: %d\n", ret);
16835 show_fec_capability(num, speed_fec_capa);
16837 free(speed_fec_capa);
16840 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16841 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16843 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16844 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16846 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16847 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16848 cmd_pid, RTE_UINT16);
16849 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16850 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16852 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16853 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16854 cmd_keyword, "capabilities");
16856 cmdline_parse_inst_t cmd_show_capability = {
16857 .f = cmd_show_fec_capability_parsed,
16859 .help_str = "show port <port_id> fec capabilities",
16861 (void *)&cmd_show_fec_capability_show,
16862 (void *)&cmd_show_fec_capability_port,
16863 (void *)&cmd_show_fec_capability_pid,
16864 (void *)&cmd_show_fec_capability_fec,
16865 (void *)&cmd_show_fec_capability_keyword,
16870 /* *** show fec mode per port configuration *** */
16871 struct cmd_show_fec_metadata_result {
16872 cmdline_fixed_string_t cmd_show;
16873 cmdline_fixed_string_t cmd_port;
16874 cmdline_fixed_string_t cmd_keyword;
16879 cmd_show_fec_mode_parsed(void *parsed_result,
16880 __rte_unused struct cmdline *cl,
16881 __rte_unused void *data)
16883 #define FEC_NAME_SIZE 16
16884 struct cmd_show_fec_metadata_result *res = parsed_result;
16886 char buf[FEC_NAME_SIZE];
16889 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16890 printf("Invalid port id %u\n", res->cmd_pid);
16893 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16894 if (ret == -ENOTSUP) {
16895 printf("Function not implemented\n");
16897 } else if (ret < 0) {
16898 printf("Get FEC mode failed\n");
16903 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16904 strlcpy(buf, "off", sizeof(buf));
16906 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16907 strlcpy(buf, "auto", sizeof(buf));
16909 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16910 strlcpy(buf, "baser", sizeof(buf));
16912 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16913 strlcpy(buf, "rs", sizeof(buf));
16919 printf("%s\n", buf);
16922 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16923 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16925 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16926 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16928 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16929 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16930 cmd_pid, RTE_UINT16);
16931 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16932 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16933 cmd_keyword, "fec_mode");
16935 cmdline_parse_inst_t cmd_show_fec_mode = {
16936 .f = cmd_show_fec_mode_parsed,
16938 .help_str = "show port <port_id> fec_mode",
16940 (void *)&cmd_show_fec_mode_show,
16941 (void *)&cmd_show_fec_mode_port,
16942 (void *)&cmd_show_fec_mode_pid,
16943 (void *)&cmd_show_fec_mode_keyword,
16948 /* *** set fec mode per port configuration *** */
16949 struct cmd_set_port_fec_mode {
16950 cmdline_fixed_string_t set;
16951 cmdline_fixed_string_t port;
16953 cmdline_fixed_string_t fec_mode;
16954 cmdline_fixed_string_t fec_value;
16957 /* Common CLI fields for set fec mode */
16958 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16959 TOKEN_STRING_INITIALIZER
16960 (struct cmd_set_port_fec_mode,
16962 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16963 TOKEN_STRING_INITIALIZER
16964 (struct cmd_set_port_fec_mode,
16966 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16967 TOKEN_NUM_INITIALIZER
16968 (struct cmd_set_port_fec_mode,
16969 port_id, RTE_UINT16);
16970 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16971 TOKEN_STRING_INITIALIZER
16972 (struct cmd_set_port_fec_mode,
16973 fec_mode, "fec_mode");
16974 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16975 TOKEN_STRING_INITIALIZER
16976 (struct cmd_set_port_fec_mode,
16980 cmd_set_port_fec_mode_parsed(
16981 void *parsed_result,
16982 __rte_unused struct cmdline *cl,
16983 __rte_unused void *data)
16985 struct cmd_set_port_fec_mode *res = parsed_result;
16986 uint16_t port_id = res->port_id;
16990 ret = parse_fec_mode(res->fec_value, &mode);
16992 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16997 ret = rte_eth_fec_set(port_id, mode);
16998 if (ret == -ENOTSUP) {
16999 printf("Function not implemented\n");
17001 } else if (ret < 0) {
17002 printf("Set FEC mode failed\n");
17007 cmdline_parse_inst_t cmd_set_fec_mode = {
17008 .f = cmd_set_port_fec_mode_parsed,
17010 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17012 (void *)&cmd_set_port_fec_mode_set,
17013 (void *)&cmd_set_port_fec_mode_port,
17014 (void *)&cmd_set_port_fec_mode_port_id,
17015 (void *)&cmd_set_port_fec_mode_str,
17016 (void *)&cmd_set_port_fec_mode_value,
17021 /* show port supported ptypes */
17023 /* Common result structure for show port ptypes */
17024 struct cmd_show_port_supported_ptypes_result {
17025 cmdline_fixed_string_t show;
17026 cmdline_fixed_string_t port;
17028 cmdline_fixed_string_t ptypes;
17031 /* Common CLI fields for show port ptypes */
17032 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17033 TOKEN_STRING_INITIALIZER
17034 (struct cmd_show_port_supported_ptypes_result,
17036 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17037 TOKEN_STRING_INITIALIZER
17038 (struct cmd_show_port_supported_ptypes_result,
17040 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17041 TOKEN_NUM_INITIALIZER
17042 (struct cmd_show_port_supported_ptypes_result,
17043 port_id, RTE_UINT16);
17044 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17045 TOKEN_STRING_INITIALIZER
17046 (struct cmd_show_port_supported_ptypes_result,
17050 cmd_show_port_supported_ptypes_parsed(
17051 void *parsed_result,
17052 __rte_unused struct cmdline *cl,
17053 __rte_unused void *data)
17055 #define RSVD_PTYPE_MASK 0xf0000000
17056 #define MAX_PTYPES_PER_LAYER 16
17057 #define LTYPE_NAMESIZE 32
17058 #define PTYPE_NAMESIZE 256
17059 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17060 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17061 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17062 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17063 uint16_t port_id = res->port_id;
17066 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17070 while (ptype_mask != RSVD_PTYPE_MASK) {
17072 switch (ptype_mask) {
17073 case RTE_PTYPE_L2_MASK:
17074 strlcpy(ltype, "L2", sizeof(ltype));
17076 case RTE_PTYPE_L3_MASK:
17077 strlcpy(ltype, "L3", sizeof(ltype));
17079 case RTE_PTYPE_L4_MASK:
17080 strlcpy(ltype, "L4", sizeof(ltype));
17082 case RTE_PTYPE_TUNNEL_MASK:
17083 strlcpy(ltype, "Tunnel", sizeof(ltype));
17085 case RTE_PTYPE_INNER_L2_MASK:
17086 strlcpy(ltype, "Inner L2", sizeof(ltype));
17088 case RTE_PTYPE_INNER_L3_MASK:
17089 strlcpy(ltype, "Inner L3", sizeof(ltype));
17091 case RTE_PTYPE_INNER_L4_MASK:
17092 strlcpy(ltype, "Inner L4", sizeof(ltype));
17098 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17099 ptype_mask, ptypes,
17100 MAX_PTYPES_PER_LAYER);
17103 printf("Supported %s ptypes:\n", ltype);
17105 printf("%s ptypes unsupported\n", ltype);
17107 for (i = 0; i < ret; ++i) {
17108 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17109 printf("%s\n", buf);
17116 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17117 .f = cmd_show_port_supported_ptypes_parsed,
17119 .help_str = "show port <port_id> ptypes",
17121 (void *)&cmd_show_port_supported_ptypes_show,
17122 (void *)&cmd_show_port_supported_ptypes_port,
17123 (void *)&cmd_show_port_supported_ptypes_port_id,
17124 (void *)&cmd_show_port_supported_ptypes_ptypes,
17129 /* *** display rx/tx descriptor status *** */
17130 struct cmd_show_rx_tx_desc_status_result {
17131 cmdline_fixed_string_t cmd_show;
17132 cmdline_fixed_string_t cmd_port;
17133 cmdline_fixed_string_t cmd_keyword;
17134 cmdline_fixed_string_t cmd_desc;
17135 cmdline_fixed_string_t cmd_status;
17142 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17143 __rte_unused struct cmdline *cl,
17144 __rte_unused void *data)
17146 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17149 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17150 printf("invalid port id %u\n", res->cmd_pid);
17154 if (!strcmp(res->cmd_keyword, "rxq")) {
17155 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17158 printf("Invalid input: queue id = %d, desc id = %d\n",
17159 res->cmd_qid, res->cmd_did);
17162 if (rc == RTE_ETH_RX_DESC_AVAIL)
17163 printf("Desc status = AVAILABLE\n");
17164 else if (rc == RTE_ETH_RX_DESC_DONE)
17165 printf("Desc status = DONE\n");
17167 printf("Desc status = UNAVAILABLE\n");
17168 } else if (!strcmp(res->cmd_keyword, "txq")) {
17169 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17172 printf("Invalid input: queue id = %d, desc id = %d\n",
17173 res->cmd_qid, res->cmd_did);
17176 if (rc == RTE_ETH_TX_DESC_FULL)
17177 printf("Desc status = FULL\n");
17178 else if (rc == RTE_ETH_TX_DESC_DONE)
17179 printf("Desc status = DONE\n");
17181 printf("Desc status = UNAVAILABLE\n");
17185 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17186 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17188 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17189 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17191 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17192 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17193 cmd_pid, RTE_UINT16);
17194 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17195 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17196 cmd_keyword, "rxq#txq");
17197 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17198 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17199 cmd_qid, RTE_UINT16);
17200 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17201 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17203 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17204 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17205 cmd_did, RTE_UINT16);
17206 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17207 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17208 cmd_status, "status");
17209 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17210 .f = cmd_show_rx_tx_desc_status_parsed,
17212 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17215 (void *)&cmd_show_rx_tx_desc_status_show,
17216 (void *)&cmd_show_rx_tx_desc_status_port,
17217 (void *)&cmd_show_rx_tx_desc_status_pid,
17218 (void *)&cmd_show_rx_tx_desc_status_keyword,
17219 (void *)&cmd_show_rx_tx_desc_status_qid,
17220 (void *)&cmd_show_rx_tx_desc_status_desc,
17221 (void *)&cmd_show_rx_tx_desc_status_did,
17222 (void *)&cmd_show_rx_tx_desc_status_status,
17227 /* *** display rx queue desc used count *** */
17228 struct cmd_show_rx_queue_desc_used_count_result {
17229 cmdline_fixed_string_t cmd_show;
17230 cmdline_fixed_string_t cmd_port;
17231 cmdline_fixed_string_t cmd_rxq;
17232 cmdline_fixed_string_t cmd_desc;
17233 cmdline_fixed_string_t cmd_used;
17234 cmdline_fixed_string_t cmd_count;
17240 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17241 __rte_unused struct cmdline *cl,
17242 __rte_unused void *data)
17244 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17247 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17248 printf("invalid port id %u\n", res->cmd_pid);
17252 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17254 printf("Invalid queueid = %d\n", res->cmd_qid);
17257 printf("Used desc count = %d\n", rc);
17260 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17261 TOKEN_STRING_INITIALIZER
17262 (struct cmd_show_rx_queue_desc_used_count_result,
17264 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17265 TOKEN_STRING_INITIALIZER
17266 (struct cmd_show_rx_queue_desc_used_count_result,
17268 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17269 TOKEN_NUM_INITIALIZER
17270 (struct cmd_show_rx_queue_desc_used_count_result,
17271 cmd_pid, RTE_UINT16);
17272 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17273 TOKEN_STRING_INITIALIZER
17274 (struct cmd_show_rx_queue_desc_used_count_result,
17276 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17277 TOKEN_NUM_INITIALIZER
17278 (struct cmd_show_rx_queue_desc_used_count_result,
17279 cmd_qid, RTE_UINT16);
17280 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17281 TOKEN_STRING_INITIALIZER
17282 (struct cmd_show_rx_queue_desc_used_count_result,
17283 cmd_count, "desc");
17284 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17285 TOKEN_STRING_INITIALIZER
17286 (struct cmd_show_rx_queue_desc_used_count_result,
17287 cmd_count, "used");
17288 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17289 TOKEN_STRING_INITIALIZER
17290 (struct cmd_show_rx_queue_desc_used_count_result,
17291 cmd_count, "count");
17292 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17293 .f = cmd_show_rx_queue_desc_used_count_parsed,
17295 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17297 (void *)&cmd_show_rx_queue_desc_used_count_show,
17298 (void *)&cmd_show_rx_queue_desc_used_count_port,
17299 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17300 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17301 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17302 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17303 (void *)&cmd_show_rx_queue_desc_used_count_used,
17304 (void *)&cmd_show_rx_queue_desc_used_count_count,
17309 /* Common result structure for set port ptypes */
17310 struct cmd_set_port_ptypes_result {
17311 cmdline_fixed_string_t set;
17312 cmdline_fixed_string_t port;
17314 cmdline_fixed_string_t ptype_mask;
17318 /* Common CLI fields for set port ptypes */
17319 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17320 TOKEN_STRING_INITIALIZER
17321 (struct cmd_set_port_ptypes_result,
17323 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17324 TOKEN_STRING_INITIALIZER
17325 (struct cmd_set_port_ptypes_result,
17327 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17328 TOKEN_NUM_INITIALIZER
17329 (struct cmd_set_port_ptypes_result,
17330 port_id, RTE_UINT16);
17331 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17332 TOKEN_STRING_INITIALIZER
17333 (struct cmd_set_port_ptypes_result,
17334 ptype_mask, "ptype_mask");
17335 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17336 TOKEN_NUM_INITIALIZER
17337 (struct cmd_set_port_ptypes_result,
17341 cmd_set_port_ptypes_parsed(
17342 void *parsed_result,
17343 __rte_unused struct cmdline *cl,
17344 __rte_unused void *data)
17346 struct cmd_set_port_ptypes_result *res = parsed_result;
17347 #define PTYPE_NAMESIZE 256
17348 char ptype_name[PTYPE_NAMESIZE];
17349 uint16_t port_id = res->port_id;
17350 uint32_t ptype_mask = res->mask;
17353 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17356 printf("Port %d doesn't support any ptypes.\n", port_id);
17360 uint32_t ptypes[ret];
17362 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17364 printf("Unable to set requested ptypes for Port %d\n", port_id);
17368 printf("Successfully set following ptypes for Port %d\n", port_id);
17369 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17370 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17371 printf("%s\n", ptype_name);
17374 clear_ptypes = false;
17377 cmdline_parse_inst_t cmd_set_port_ptypes = {
17378 .f = cmd_set_port_ptypes_parsed,
17380 .help_str = "set port <port_id> ptype_mask <mask>",
17382 (void *)&cmd_set_port_ptypes_set,
17383 (void *)&cmd_set_port_ptypes_port,
17384 (void *)&cmd_set_port_ptypes_port_id,
17385 (void *)&cmd_set_port_ptypes_mask_str,
17386 (void *)&cmd_set_port_ptypes_mask_u32,
17391 /* *** display mac addresses added to a port *** */
17392 struct cmd_showport_macs_result {
17393 cmdline_fixed_string_t cmd_show;
17394 cmdline_fixed_string_t cmd_port;
17395 cmdline_fixed_string_t cmd_keyword;
17400 cmd_showport_macs_parsed(void *parsed_result,
17401 __rte_unused struct cmdline *cl,
17402 __rte_unused void *data)
17404 struct cmd_showport_macs_result *res = parsed_result;
17406 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17409 if (!strcmp(res->cmd_keyword, "macs"))
17410 show_macs(res->cmd_pid);
17411 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17412 show_mcast_macs(res->cmd_pid);
17415 cmdline_parse_token_string_t cmd_showport_macs_show =
17416 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17418 cmdline_parse_token_string_t cmd_showport_macs_port =
17419 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17421 cmdline_parse_token_num_t cmd_showport_macs_pid =
17422 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17423 cmd_pid, RTE_UINT16);
17424 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17425 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17426 cmd_keyword, "macs#mcast_macs");
17428 cmdline_parse_inst_t cmd_showport_macs = {
17429 .f = cmd_showport_macs_parsed,
17431 .help_str = "show port <port_id> macs|mcast_macs",
17433 (void *)&cmd_showport_macs_show,
17434 (void *)&cmd_showport_macs_port,
17435 (void *)&cmd_showport_macs_pid,
17436 (void *)&cmd_showport_macs_keyword,
17441 /* ******************************************************************************** */
17443 /* list of instructions */
17444 cmdline_parse_ctx_t main_ctx[] = {
17445 (cmdline_parse_inst_t *)&cmd_help_brief,
17446 (cmdline_parse_inst_t *)&cmd_help_long,
17447 (cmdline_parse_inst_t *)&cmd_quit,
17448 (cmdline_parse_inst_t *)&cmd_load_from_file,
17449 (cmdline_parse_inst_t *)&cmd_showport,
17450 (cmdline_parse_inst_t *)&cmd_showqueue,
17451 (cmdline_parse_inst_t *)&cmd_showeeprom,
17452 (cmdline_parse_inst_t *)&cmd_showportall,
17453 (cmdline_parse_inst_t *)&cmd_showdevice,
17454 (cmdline_parse_inst_t *)&cmd_showcfg,
17455 (cmdline_parse_inst_t *)&cmd_showfwdall,
17456 (cmdline_parse_inst_t *)&cmd_start,
17457 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17458 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17459 (cmdline_parse_inst_t *)&cmd_set_link_up,
17460 (cmdline_parse_inst_t *)&cmd_set_link_down,
17461 (cmdline_parse_inst_t *)&cmd_reset,
17462 (cmdline_parse_inst_t *)&cmd_set_numbers,
17463 (cmdline_parse_inst_t *)&cmd_set_log,
17464 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17465 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17466 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17467 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17468 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17469 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17470 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17471 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17472 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17473 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17474 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17475 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17476 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17477 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17478 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17479 (cmdline_parse_inst_t *)&cmd_set_link_check,
17480 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17481 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17482 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17483 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17484 #ifdef RTE_NET_BOND
17485 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17486 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17487 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17488 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17489 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17490 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17491 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17492 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17493 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17494 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17495 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17497 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17498 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17499 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17500 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17501 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17502 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17503 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17504 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17505 (cmdline_parse_inst_t *)&cmd_csum_set,
17506 (cmdline_parse_inst_t *)&cmd_csum_show,
17507 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17508 (cmdline_parse_inst_t *)&cmd_tso_set,
17509 (cmdline_parse_inst_t *)&cmd_tso_show,
17510 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17511 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17512 (cmdline_parse_inst_t *)&cmd_gro_enable,
17513 (cmdline_parse_inst_t *)&cmd_gro_flush,
17514 (cmdline_parse_inst_t *)&cmd_gro_show,
17515 (cmdline_parse_inst_t *)&cmd_gso_enable,
17516 (cmdline_parse_inst_t *)&cmd_gso_size,
17517 (cmdline_parse_inst_t *)&cmd_gso_show,
17518 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17519 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17520 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17521 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17522 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17523 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17524 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17525 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17526 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17527 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17528 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17529 (cmdline_parse_inst_t *)&cmd_config_dcb,
17530 (cmdline_parse_inst_t *)&cmd_read_reg,
17531 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17532 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17533 (cmdline_parse_inst_t *)&cmd_write_reg,
17534 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17535 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17536 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17537 (cmdline_parse_inst_t *)&cmd_stop,
17538 (cmdline_parse_inst_t *)&cmd_mac_addr,
17539 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17540 (cmdline_parse_inst_t *)&cmd_set_qmap,
17541 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17542 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17543 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17544 (cmdline_parse_inst_t *)&cmd_operate_port,
17545 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17546 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17547 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17548 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17549 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17550 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17551 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17552 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17553 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17554 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17555 (cmdline_parse_inst_t *)&cmd_config_mtu,
17556 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17557 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17558 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17559 (cmdline_parse_inst_t *)&cmd_config_rss,
17560 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17561 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17562 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17563 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17564 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17565 (cmdline_parse_inst_t *)&cmd_showport_reta,
17566 (cmdline_parse_inst_t *)&cmd_showport_macs,
17567 (cmdline_parse_inst_t *)&cmd_config_burst,
17568 (cmdline_parse_inst_t *)&cmd_config_thresh,
17569 (cmdline_parse_inst_t *)&cmd_config_threshold,
17570 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17571 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17572 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17573 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17574 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17575 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17576 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17577 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17578 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17579 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17580 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17581 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17582 (cmdline_parse_inst_t *)&cmd_dump,
17583 (cmdline_parse_inst_t *)&cmd_dump_one,
17584 #ifdef RTE_NET_I40E
17585 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17587 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17588 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17589 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17590 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17591 (cmdline_parse_inst_t *)&cmd_flow,
17592 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17593 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17594 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17595 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17596 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17597 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17598 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17599 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17600 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17601 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17602 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17603 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17604 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17605 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17606 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17607 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17608 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17609 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17610 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17611 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17612 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17613 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17614 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17615 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17616 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17617 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17618 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17619 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17620 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17621 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17622 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17623 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17624 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17625 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17626 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17627 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17628 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17629 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17630 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17631 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17632 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17633 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17634 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17635 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17636 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17637 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17638 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17639 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17640 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17641 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17642 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17643 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17644 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17645 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17646 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17647 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17648 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17649 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17650 (cmdline_parse_inst_t *)&cmd_ddp_add,
17651 (cmdline_parse_inst_t *)&cmd_ddp_del,
17652 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17653 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17654 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17655 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17656 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17657 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17658 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17659 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17660 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17661 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17662 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17663 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17665 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17666 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17667 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17668 (cmdline_parse_inst_t *)&cmd_queue_region,
17669 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17670 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17671 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17672 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17673 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17674 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17675 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17676 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17677 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17678 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17679 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17680 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17681 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17682 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17683 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17684 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17685 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17686 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17687 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17688 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17689 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17690 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17691 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17692 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17693 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17694 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17695 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17696 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17697 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17698 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17699 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17700 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17701 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17702 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17703 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17704 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17706 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17707 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17709 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17710 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17711 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17712 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17713 (cmdline_parse_inst_t *)&cmd_set_raw,
17714 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17715 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17716 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17717 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17718 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17719 (cmdline_parse_inst_t *)&cmd_show_capability,
17723 /* read cmdline commands from file */
17725 cmdline_read_from_file(const char *filename)
17727 struct cmdline *cl;
17729 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17731 printf("Failed to create file based cmdline context: %s\n",
17736 cmdline_interact(cl);
17741 printf("Read CLI commands from %s\n", filename);
17744 /* prompt function, called from main on MAIN lcore */
17749 /* initialize non-constant commands */
17750 cmd_set_fwd_mode_init();
17751 cmd_set_fwd_retry_mode_init();
17753 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17754 if (testpmd_cl == NULL)
17757 ret = atexit(prompt_exit);
17759 printf("Cannot set exit function for cmdline\n");
17761 cmdline_interact(testpmd_cl);
17763 cmdline_stdin_exit(testpmd_cl);
17769 if (testpmd_cl != NULL) {
17770 cmdline_quit(testpmd_cl);
17771 cmdline_stdin_exit(testpmd_cl);
17776 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17778 if (id == (portid_t)RTE_PORT_ALL) {
17781 RTE_ETH_FOREACH_DEV(pid) {
17782 /* check if need_reconfig has been set to 1 */
17783 if (ports[pid].need_reconfig == 0)
17784 ports[pid].need_reconfig = dev;
17785 /* check if need_reconfig_queues has been set to 1 */
17786 if (ports[pid].need_reconfig_queues == 0)
17787 ports[pid].need_reconfig_queues = queue;
17789 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17790 /* check if need_reconfig has been set to 1 */
17791 if (ports[id].need_reconfig == 0)
17792 ports[id].need_reconfig = dev;
17793 /* check if need_reconfig_queues has been set to 1 */
17794 if (ports[id].need_reconfig_queues == 0)
17795 ports[id].need_reconfig_queues = queue;