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>
53 #ifdef RTE_LIBRTE_PMD_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
58 #include <rte_pmd_dpaa.h>
60 #ifdef RTE_LIBRTE_IXGBE_PMD
61 #include <rte_pmd_ixgbe.h>
63 #ifdef RTE_LIBRTE_I40E_PMD
64 #include <rte_pmd_i40e.h>
66 #ifdef RTE_LIBRTE_BNXT_PMD
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 commmands.\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|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port X rss reta (size) (mask0,mask1,...)\n"
170 " Display the rss redirection table entry indicated"
171 " by masks on port X. size is used to indicate the"
172 " hardware supported reta size\n\n"
174 "show port (port_id) rss-hash [key]\n"
175 " Display the RSS hash functions and RSS hash key of port\n\n"
177 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
178 " Clear information for port_id, or all.\n\n"
180 "show (rxq|txq) info (port_id) (queue_id)\n"
181 " Display information for configured RX/TX queue.\n\n"
183 "show config (rxtx|cores|fwd|txpkts)\n"
184 " Display the given configuration.\n\n"
186 "read rxd (port_id) (queue_id) (rxd_id)\n"
187 " Display an RX descriptor of a port RX queue.\n\n"
189 "read txd (port_id) (queue_id) (txd_id)\n"
190 " Display a TX descriptor of a port TX queue.\n\n"
192 "ddp get list (port_id)\n"
193 " Get ddp profile info list\n\n"
195 "ddp get info (profile_path)\n"
196 " Get ddp profile information.\n\n"
198 "show vf stats (port_id) (vf_id)\n"
199 " Display a VF's statistics.\n\n"
201 "clear vf stats (port_id) (vf_id)\n"
202 " Reset a VF's statistics.\n\n"
204 "show port (port_id) pctype mapping\n"
205 " Get flow ptype to pctype mapping on a port\n\n"
207 "show port meter stats (port_id) (meter_id) (clear)\n"
208 " Get meter stats on a port\n\n"
210 "show fwd stats all\n"
211 " Display statistics for all fwd engines.\n\n"
213 "clear fwd stats all\n"
214 " Clear statistics for all fwd engines.\n\n"
216 "show port (port_id) rx_offload capabilities\n"
217 " List all per queue and per port Rx offloading"
218 " capabilities of a port\n\n"
220 "show port (port_id) rx_offload configuration\n"
221 " List port level and all queue level"
222 " Rx offloading configuration\n\n"
224 "show port (port_id) tx_offload capabilities\n"
225 " List all per queue and per port"
226 " Tx offloading capabilities of a port\n\n"
228 "show port (port_id) tx_offload configuration\n"
229 " List port level and all queue level"
230 " Tx offloading configuration\n\n"
232 "show port (port_id) tx_metadata\n"
233 " Show Tx metadata value set"
234 " for a specific port\n\n"
236 "show port (port_id) ptypes\n"
237 " Show port supported ptypes"
238 " for a specific port\n\n"
240 "show device info (<identifier>|all)"
241 " Show general information about devices probed.\n\n"
243 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
244 " Show status of rx|tx descriptor.\n\n"
246 "show port (port_id) macs|mcast_macs"
247 " Display list of mac addresses added to port.\n\n"
251 if (show_all || !strcmp(res->section, "config")) {
257 "Configuration changes only become active when"
258 " forwarding is started/restarted.\n\n"
261 " Reset forwarding to the default configuration.\n\n"
263 "set verbose (level)\n"
264 " Set the debug verbosity level X.\n\n"
266 "set log global|(type) (level)\n"
267 " Set the log level.\n\n"
270 " Set number of ports.\n\n"
273 " Set number of cores.\n\n"
275 "set coremask (mask)\n"
276 " Set the forwarding cores hexadecimal mask.\n\n"
278 "set portmask (mask)\n"
279 " Set the forwarding ports hexadecimal mask.\n\n"
282 " Set number of packets per burst.\n\n"
284 "set burst tx delay (microseconds) retry (num)\n"
285 " Set the transmit delay time and number of retries,"
286 " effective when retry is enabled.\n\n"
288 "set txpkts (x[,y]*)\n"
289 " Set the length of each segment of TXONLY"
290 " and optionally CSUM packets.\n\n"
292 "set txsplit (off|on|rand)\n"
293 " Set the split policy for the TX packets."
294 " Right now only applicable for CSUM and TXONLY"
297 "set corelist (x[,y]*)\n"
298 " Set the list of forwarding cores.\n\n"
300 "set portlist (x[,y]*)\n"
301 " Set the list of forwarding ports.\n\n"
303 "set port setup on (iterator|event)\n"
304 " Select how attached port is retrieved for setup.\n\n"
306 "set tx loopback (port_id) (on|off)\n"
307 " Enable or disable tx loopback.\n\n"
309 "set all queues drop (port_id) (on|off)\n"
310 " Set drop enable bit for all queues.\n\n"
312 "set vf split drop (port_id) (vf_id) (on|off)\n"
313 " Set split drop enable bit for a VF from the PF.\n\n"
315 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
316 " Set MAC antispoof for a VF from the PF.\n\n"
318 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
319 " Enable MACsec offload.\n\n"
321 "set macsec offload (port_id) off\n"
322 " Disable MACsec offload.\n\n"
324 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
325 " Configure MACsec secure connection (SC).\n\n"
327 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
328 " Configure MACsec secure association (SA).\n\n"
330 "set vf broadcast (port_id) (vf_id) (on|off)\n"
331 " Set VF broadcast for a VF from the PF.\n\n"
333 "vlan set stripq (on|off) (port_id,queue_id)\n"
334 " Set the VLAN strip for a queue on a port.\n\n"
336 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
337 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
339 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
340 " Set VLAN insert for a VF from the PF.\n\n"
342 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
343 " Set VLAN antispoof for a VF from the PF.\n\n"
345 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
346 " Set VLAN tag for a VF from the PF.\n\n"
348 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
349 " Set a VF's max bandwidth(Mbps).\n\n"
351 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
352 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
354 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
355 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
357 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
358 " Set some TCs' strict link priority mode on a physical port.\n\n"
360 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
361 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
363 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
364 " Set the VLAN strip or filter or qinq strip or extend\n\n"
366 "vlan set (inner|outer) tpid (value) (port_id)\n"
367 " Set the VLAN TPID for Packet Filtering on"
370 "rx_vlan add (vlan_id|all) (port_id)\n"
371 " Add a vlan_id, or all identifiers, to the set"
372 " of VLAN identifiers filtered by port_id.\n\n"
374 "rx_vlan rm (vlan_id|all) (port_id)\n"
375 " Remove a vlan_id, or all identifiers, from the set"
376 " of VLAN identifiers filtered by port_id.\n\n"
378 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
379 " Add a vlan_id, to the set of VLAN identifiers"
380 "filtered for VF(s) from port_id.\n\n"
382 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
383 " Remove a vlan_id, to the set of VLAN identifiers"
384 "filtered for VF(s) from port_id.\n\n"
386 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
387 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
388 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
389 " add a tunnel filter of a port.\n\n"
391 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
392 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
393 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
394 " remove a tunnel filter of a port.\n\n"
396 "rx_vxlan_port add (udp_port) (port_id)\n"
397 " Add an UDP port for VXLAN packet filter on a port\n\n"
399 "rx_vxlan_port rm (udp_port) (port_id)\n"
400 " Remove an UDP port for VXLAN packet filter on a port\n\n"
402 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
403 " Set hardware insertion of VLAN IDs (single or double VLAN "
404 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
406 "tx_vlan set pvid port_id vlan_id (on|off)\n"
407 " Set port based TX VLAN insertion.\n\n"
409 "tx_vlan reset (port_id)\n"
410 " Disable hardware insertion of a VLAN header in"
411 " packets sent on a port.\n\n"
413 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
414 " Select hardware or software calculation of the"
415 " checksum when transmitting a packet using the"
416 " csum forward engine.\n"
417 " ip|udp|tcp|sctp always concern the inner layer.\n"
418 " outer-ip concerns the outer IP layer in"
419 " outer-udp concerns the outer UDP layer in"
420 " case the packet is recognized as a tunnel packet by"
421 " the forward engine (vxlan, gre and ipip are supported)\n"
422 " Please check the NIC datasheet for HW limits.\n\n"
424 "csum parse-tunnel (on|off) (tx_port_id)\n"
425 " If disabled, treat tunnel packets as non-tunneled"
426 " packets (treat inner headers as payload). The port\n"
427 " argument is the port used for TX in csum forward"
430 "csum show (port_id)\n"
431 " Display tx checksum offload configuration\n\n"
433 "tso set (segsize) (portid)\n"
434 " Enable TCP Segmentation Offload in csum forward"
436 " Please check the NIC datasheet for HW limits.\n\n"
439 " Display the status of TCP Segmentation Offload.\n\n"
441 "set port (port_id) gro on|off\n"
442 " Enable or disable Generic Receive Offload in"
443 " csum forwarding engine.\n\n"
445 "show port (port_id) gro\n"
446 " Display GRO configuration.\n\n"
448 "set gro flush (cycles)\n"
449 " Set the cycle to flush GROed packets from"
450 " reassembly tables.\n\n"
452 "set port (port_id) gso (on|off)"
453 " Enable or disable Generic Segmentation Offload in"
454 " csum forwarding engine.\n\n"
456 "set gso segsz (length)\n"
457 " Set max packet length for output GSO segments,"
458 " including packet header and payload.\n\n"
460 "show port (port_id) gso\n"
461 " Show GSO configuration.\n\n"
464 " Set packet forwarding mode.\n\n"
466 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
467 " Add a MAC address on port_id.\n\n"
469 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
470 " Remove a MAC address from port_id.\n\n"
472 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
473 " Set the default MAC address for port_id.\n\n"
475 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
476 " Add a MAC address for a VF on the port.\n\n"
478 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
479 " Set the MAC address for a VF from the PF.\n\n"
481 "set eth-peer (port_id) (peer_addr)\n"
482 " set the peer address for certain port.\n\n"
484 "set port (port_id) uta (mac_address|all) (on|off)\n"
485 " Add/Remove a or all unicast hash filter(s)"
488 "set promisc (port_id|all) (on|off)\n"
489 " Set the promiscuous mode on port_id, or all.\n\n"
491 "set allmulti (port_id|all) (on|off)\n"
492 " Set the allmulti mode on port_id, or all.\n\n"
494 "set vf promisc (port_id) (vf_id) (on|off)\n"
495 " Set unicast promiscuous mode for a VF from the PF.\n\n"
497 "set vf allmulti (port_id) (vf_id) (on|off)\n"
498 " Set multicast promiscuous mode for a VF from the PF.\n\n"
500 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
501 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
502 " (on|off) autoneg (on|off) (port_id)\n"
503 "set flow_ctrl rx (on|off) (portid)\n"
504 "set flow_ctrl tx (on|off) (portid)\n"
505 "set flow_ctrl high_water (high_water) (portid)\n"
506 "set flow_ctrl low_water (low_water) (portid)\n"
507 "set flow_ctrl pause_time (pause_time) (portid)\n"
508 "set flow_ctrl send_xon (send_xon) (portid)\n"
509 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
510 "set flow_ctrl autoneg (on|off) (port_id)\n"
511 " Set the link flow control parameter on a port.\n\n"
513 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
514 " (low_water) (pause_time) (priority) (port_id)\n"
515 " Set the priority flow control parameter on a"
518 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
519 " Set statistics mapping (qmapping 0..15) for RX/TX"
521 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
522 " on port 0 to mapping 5.\n\n"
524 "set xstats-hide-zero on|off\n"
525 " Set the option to hide the zero values"
526 " for xstats display.\n"
528 "set port (port_id) vf (vf_id) rx|tx on|off\n"
529 " Enable/Disable a VF receive/tranmit from a port\n\n"
531 "set port (port_id) vf (vf_id) (mac_addr)"
532 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
533 " Add/Remove unicast or multicast MAC addr filter"
536 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
538 " AUPE:accepts untagged VLAN;"
539 "ROPE:accept unicast hash\n\n"
540 " BAM:accepts broadcast packets;"
541 "MPE:accepts all multicast packets\n\n"
542 " Enable/Disable a VF receive mode of a port\n\n"
544 "set port (port_id) queue (queue_id) rate (rate_num)\n"
545 " Set rate limit for a queue of a port\n\n"
547 "set port (port_id) vf (vf_id) rate (rate_num) "
548 "queue_mask (queue_mask_value)\n"
549 " Set rate limit for queues in VF of a port\n\n"
551 "set port (port_id) mirror-rule (rule_id)"
552 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
553 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
554 " Set pool or vlan type mirror rule on a port.\n"
555 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
556 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
559 "set port (port_id) mirror-rule (rule_id)"
560 " (uplink-mirror|downlink-mirror) dst-pool"
561 " (pool_id) (on|off)\n"
562 " Set uplink or downlink type mirror rule on a port.\n"
563 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
564 " 0 on' enable mirror income traffic to pool 0.\n\n"
566 "reset port (port_id) mirror-rule (rule_id)\n"
567 " Reset a mirror rule.\n\n"
569 "set flush_rx (on|off)\n"
570 " Flush (default) or don't flush RX streams before"
571 " forwarding. Mainly used with PCAP drivers.\n\n"
573 "set bypass mode (normal|bypass|isolate) (port_id)\n"
574 " Set the bypass mode for the lowest port on bypass enabled"
577 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
578 "mode (normal|bypass|isolate) (port_id)\n"
579 " Set the event required to initiate specified bypass mode for"
580 " the lowest port on a bypass enabled NIC where:\n"
581 " timeout = enable bypass after watchdog timeout.\n"
582 " os_on = enable bypass when OS/board is powered on.\n"
583 " os_off = enable bypass when OS/board is powered off.\n"
584 " power_on = enable bypass when power supply is turned on.\n"
585 " power_off = enable bypass when power supply is turned off."
588 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
589 " Set the bypass watchdog timeout to 'n' seconds"
590 " where 0 = instant.\n\n"
592 "show bypass config (port_id)\n"
593 " Show the bypass configuration for a bypass enabled NIC"
594 " using the lowest port on the NIC.\n\n"
596 #ifdef RTE_LIBRTE_PMD_BOND
597 "create bonded device (mode) (socket)\n"
598 " Create a new bonded device with specific bonding mode and socket.\n\n"
600 "add bonding slave (slave_id) (port_id)\n"
601 " Add a slave device to a bonded device.\n\n"
603 "remove bonding slave (slave_id) (port_id)\n"
604 " Remove a slave device from a bonded device.\n\n"
606 "set bonding mode (value) (port_id)\n"
607 " Set the bonding mode on a bonded device.\n\n"
609 "set bonding primary (slave_id) (port_id)\n"
610 " Set the primary slave for a bonded device.\n\n"
612 "show bonding config (port_id)\n"
613 " Show the bonding config for port_id.\n\n"
615 "set bonding mac_addr (port_id) (address)\n"
616 " Set the MAC address of a bonded device.\n\n"
618 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
619 " Set Aggregation mode for IEEE802.3AD (mode 4)"
621 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
622 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
624 "set bonding mon_period (port_id) (value)\n"
625 " Set the bonding link status monitoring polling period in ms.\n\n"
627 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
628 " Enable/disable dedicated queues for LACP control traffic.\n\n"
631 "set link-up port (port_id)\n"
632 " Set link up for a port.\n\n"
634 "set link-down port (port_id)\n"
635 " Set link down for a port.\n\n"
637 "E-tag set insertion on port-tag-id (value)"
638 " port (port_id) vf (vf_id)\n"
639 " Enable E-tag insertion for a VF on a port\n\n"
641 "E-tag set insertion off port (port_id) vf (vf_id)\n"
642 " Disable E-tag insertion for a VF on a port\n\n"
644 "E-tag set stripping (on|off) port (port_id)\n"
645 " Enable/disable E-tag stripping on a port\n\n"
647 "E-tag set forwarding (on|off) port (port_id)\n"
648 " Enable/disable E-tag based forwarding"
651 "E-tag set filter add e-tag-id (value) dst-pool"
652 " (pool_id) port (port_id)\n"
653 " Add an E-tag forwarding filter on a port\n\n"
655 "E-tag set filter del e-tag-id (value) port (port_id)\n"
656 " Delete an E-tag forwarding filter on a port\n\n"
658 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
659 " Load a profile package on a port\n\n"
661 "ddp del (port_id) (backup_profile_path)\n"
662 " Delete a profile package from a port\n\n"
664 "ptype mapping get (port_id) (valid_only)\n"
665 " Get ptype mapping on a port\n\n"
667 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
668 " Replace target with the pkt_type in ptype mapping\n\n"
670 "ptype mapping reset (port_id)\n"
671 " Reset ptype mapping on a port\n\n"
673 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
674 " Update a ptype mapping item on a port\n\n"
676 "set port (port_id) ptype_mask (ptype_mask)\n"
677 " set packet types classification for a specific port\n\n"
679 "set port (port_id) queue-region region_id (value) "
680 "queue_start_index (value) queue_num (value)\n"
681 " Set a queue region on a port\n\n"
683 "set port (port_id) queue-region region_id (value) "
685 " Set a flowtype region index on a port\n\n"
687 "set port (port_id) queue-region UP (value) region_id (value)\n"
688 " Set the mapping of User Priority to "
689 "queue region on a port\n\n"
691 "set port (port_id) queue-region flush (on|off)\n"
692 " flush all queue region related configuration\n\n"
694 "show port meter cap (port_id)\n"
695 " Show port meter capability information\n\n"
697 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
698 " meter profile add - srtcm rfc 2697\n\n"
700 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
701 " meter profile add - trtcm rfc 2698\n\n"
703 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
704 " meter profile add - trtcm rfc 4115\n\n"
706 "del port meter profile (port_id) (profile_id)\n"
707 " meter profile delete\n\n"
709 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
710 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
711 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
712 "(dscp_tbl_entry63)]\n"
715 "enable port meter (port_id) (mtr_id)\n"
718 "disable port meter (port_id) (mtr_id)\n"
721 "del port meter (port_id) (mtr_id)\n"
724 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
725 " meter update meter profile\n\n"
727 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
728 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
729 " update meter dscp table entries\n\n"
731 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
732 "(action0) [(action1) (action2)]\n"
733 " meter update policer action\n\n"
735 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
736 " meter update stats\n\n"
738 "show port (port_id) queue-region\n"
739 " show all queue region related configuration info\n\n"
741 , list_pkt_forwarding_modes()
745 if (show_all || !strcmp(res->section, "ports")) {
751 "----------------\n\n"
753 "port start (port_id|all)\n"
754 " Start all ports or port_id.\n\n"
756 "port stop (port_id|all)\n"
757 " Stop all ports or port_id.\n\n"
759 "port close (port_id|all)\n"
760 " Close all ports or port_id.\n\n"
762 "port reset (port_id|all)\n"
763 " Reset all ports or port_id.\n\n"
765 "port attach (ident)\n"
766 " Attach physical or virtual dev by pci address or virtual device name\n\n"
768 "port detach (port_id)\n"
769 " Detach physical or virtual dev by port_id\n\n"
771 "port config (port_id|all)"
772 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
773 " duplex (half|full|auto)\n"
774 " Set speed and duplex for all ports or port_id\n\n"
776 "port config (port_id|all) loopback (mode)\n"
777 " Set loopback mode for all ports or port_id\n\n"
779 "port config all (rxq|txq|rxd|txd) (value)\n"
780 " Set number for rxq/txq/rxd/txd.\n\n"
782 "port config all max-pkt-len (value)\n"
783 " Set the max packet length.\n\n"
785 "port config all max-lro-pkt-size (value)\n"
786 " Set the max LRO aggregated packet size.\n\n"
788 "port config all drop-en (on|off)\n"
789 " Enable or disable packet drop on all RX queues of all ports when no "
790 "receive buffers available.\n\n"
792 "port config all rss (all|default|ip|tcp|udp|sctp|"
793 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
794 " Set the RSS mode.\n\n"
796 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
797 " Set the RSS redirection table.\n\n"
799 "port config (port_id) dcb vt (on|off) (traffic_class)"
801 " Set the DCB mode.\n\n"
803 "port config all burst (value)\n"
804 " Set the number of packets per burst.\n\n"
806 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
808 " Set the ring prefetch/host/writeback threshold"
809 " for tx/rx queue.\n\n"
811 "port config all (txfreet|txrst|rxfreet) (value)\n"
812 " Set free threshold for rx/tx, or set"
813 " tx rs bit threshold.\n\n"
814 "port config mtu X value\n"
815 " Set the MTU of port X to a given value\n\n"
817 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
818 " Set a rx/tx queue's ring size configuration, the new"
819 " value will take effect after command that (re-)start the port"
820 " or command that setup the specific queue\n\n"
822 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
823 " Start/stop a rx/tx queue of port X. Only take effect"
824 " when port X is started\n\n"
826 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
827 " Switch on/off a deferred start of port X rx/tx queue. Only"
828 " take effect when port X is stopped.\n\n"
830 "port (port_id) (rxq|txq) (queue_id) setup\n"
831 " Setup a rx/tx queue of port X.\n\n"
833 "port config (port_id|all) l2-tunnel E-tag ether-type"
835 " Set the value of E-tag ether-type.\n\n"
837 "port config (port_id|all) l2-tunnel E-tag"
838 " (enable|disable)\n"
839 " Enable/disable the E-tag support.\n\n"
841 "port config (port_id) pctype mapping reset\n"
842 " Reset flow type to pctype mapping on a port\n\n"
844 "port config (port_id) pctype mapping update"
845 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 " Update a flow type to pctype mapping item on a port\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset get|set|clear field\n"
851 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
853 "port config (port_id) pctype (pctype_id) hash_inset|"
854 "fdir_inset|fdir_flx_inset clear all"
855 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
857 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
858 " Add/remove UDP tunnel port for tunneling offload\n\n"
860 "port config <port_id> rx_offload vlan_strip|"
861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 "outer_ipv4_cksum|macsec_strip|header_split|"
863 "vlan_filter|vlan_extend|jumbo_frame|"
864 "scatter|timestamp|security|keep_crc on|off\n"
865 " Enable or disable a per port Rx offloading"
866 " on all Rx queues of a port\n\n"
868 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 "outer_ipv4_cksum|macsec_strip|header_split|"
871 "vlan_filter|vlan_extend|jumbo_frame|"
872 "scatter|timestamp|security|keep_crc on|off\n"
873 " Enable or disable a per queue Rx offloading"
874 " only on a specific Rx queue\n\n"
876 "port config (port_id) tx_offload vlan_insert|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
880 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
882 " Enable or disable a per port Tx offloading"
883 " on all Tx queues of a port\n\n"
885 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
891 " Enable or disable a per queue Tx offloading"
892 " only on a specific Tx queue\n\n"
894 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 " Load an eBPF program as a callback"
896 " for particular RX/TX queue\n\n"
898 "bpf-unload rx|tx (port) (queue)\n"
899 " Unload previously loaded eBPF program"
900 " for particular RX/TX queue\n\n"
902 "port config (port_id) tx_metadata (value)\n"
903 " Set Tx metadata value per port. Testpmd will add this value"
904 " to any Tx packet sent from this port\n\n"
906 "port config (port_id) dynf (name) set|clear\n"
907 " Register a dynf and Set/clear this flag on Tx. "
908 "Testpmd will set this value to any Tx packet "
909 "sent from this port\n\n"
913 if (show_all || !strcmp(res->section, "registers")) {
921 "read reg (port_id) (address)\n"
922 " Display value of a port register.\n\n"
924 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
925 " Display a port register bit field.\n\n"
927 "read regbit (port_id) (address) (bit_x)\n"
928 " Display a single port register bit.\n\n"
930 "write reg (port_id) (address) (value)\n"
931 " Set value of a port register.\n\n"
933 "write regfield (port_id) (address) (bit_x) (bit_y)"
935 " Set bit field of a port register.\n\n"
937 "write regbit (port_id) (address) (bit_x) (value)\n"
938 " Set single bit value of a port register.\n\n"
941 if (show_all || !strcmp(res->section, "filters")) {
949 "ethertype_filter (port_id) (add|del)"
950 " (mac_addr|mac_ignr) (mac_address) ethertype"
951 " (ether_type) (drop|fwd) queue (queue_id)\n"
952 " Add/Del an ethertype filter.\n\n"
954 "2tuple_filter (port_id) (add|del)"
955 " dst_port (dst_port_value) protocol (protocol_value)"
956 " mask (mask_value) tcp_flags (tcp_flags_value)"
957 " priority (prio_value) queue (queue_id)\n"
958 " Add/Del a 2tuple filter.\n\n"
960 "5tuple_filter (port_id) (add|del)"
961 " dst_ip (dst_address) src_ip (src_address)"
962 " dst_port (dst_port_value) src_port (src_port_value)"
963 " protocol (protocol_value)"
964 " mask (mask_value) tcp_flags (tcp_flags_value)"
965 " priority (prio_value) queue (queue_id)\n"
966 " Add/Del a 5tuple filter.\n\n"
968 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
969 " Add/Del syn filter.\n\n"
971 "flex_filter (port_id) (add|del) len (len_value)"
972 " bytes (bytes_value) mask (mask_value)"
973 " priority (prio_value) queue (queue_id)\n"
974 " Add/Del a flex filter.\n\n"
976 "flow_director_filter (port_id) mode IP (add|del|update)"
977 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
978 " src (src_ip_address) dst (dst_ip_address)"
979 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
980 " vlan (vlan_value) flexbytes (flexbytes_value)"
981 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
982 " fd_id (fd_id_value)\n"
983 " Add/Del an IP type flow director filter.\n\n"
985 "flow_director_filter (port_id) mode IP (add|del|update)"
986 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
987 " src (src_ip_address) (src_port)"
988 " dst (dst_ip_address) (dst_port)"
989 " tos (tos_value) ttl (ttl_value)"
990 " vlan (vlan_value) flexbytes (flexbytes_value)"
991 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
992 " fd_id (fd_id_value)\n"
993 " Add/Del an UDP/TCP type flow director filter.\n\n"
995 "flow_director_filter (port_id) mode IP (add|del|update)"
996 " flow (ipv4-sctp|ipv6-sctp)"
997 " src (src_ip_address) (src_port)"
998 " dst (dst_ip_address) (dst_port)"
999 " tag (verification_tag) "
1000 " tos (tos_value) ttl (ttl_value)"
1001 " vlan (vlan_value)"
1002 " flexbytes (flexbytes_value) (drop|fwd)"
1003 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1004 " Add/Del a SCTP type flow director filter.\n\n"
1006 "flow_director_filter (port_id) mode IP (add|del|update)"
1007 " flow l2_payload ether (ethertype)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a l2 payload type flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1013 " mac (mac_address) vlan (vlan_value)"
1014 " flexbytes (flexbytes_value) (drop|fwd)"
1015 " queue (queue_id) fd_id (fd_id_value)\n"
1016 " Add/Del a MAC-VLAN flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1019 " mac (mac_address) vlan (vlan_value)"
1020 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1021 " flexbytes (flexbytes_value) (drop|fwd)"
1022 " queue (queue_id) fd_id (fd_id_value)\n"
1023 " Add/Del a Tunnel flow director filter.\n\n"
1025 "flow_director_filter (port_id) mode raw (add|del|update)"
1026 " flow (flow_id) (drop|fwd) queue (queue_id)"
1027 " fd_id (fd_id_value) packet (packet file name)\n"
1028 " Add/Del a raw type flow director filter.\n\n"
1030 "flush_flow_director (port_id)\n"
1031 " Flush all flow director entries of a device.\n\n"
1033 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1034 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1035 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1036 " Set flow director IP mask.\n\n"
1038 "flow_director_mask (port_id) mode MAC-VLAN"
1039 " vlan (vlan_value)\n"
1040 " Set flow director MAC-VLAN mask.\n\n"
1042 "flow_director_mask (port_id) mode Tunnel"
1043 " vlan (vlan_value) mac (mac_value)"
1044 " tunnel-type (tunnel_type_value)"
1045 " tunnel-id (tunnel_id_value)\n"
1046 " Set flow director Tunnel mask.\n\n"
1048 "flow_director_flex_mask (port_id)"
1049 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1050 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1052 " Configure mask of flex payload.\n\n"
1054 "flow_director_flex_payload (port_id)"
1055 " (raw|l2|l3|l4) (config)\n"
1056 " Configure flex payload selection.\n\n"
1058 "get_sym_hash_ena_per_port (port_id)\n"
1059 " get symmetric hash enable configuration per port.\n\n"
1061 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1062 " set symmetric hash enable configuration per port"
1063 " to enable or disable.\n\n"
1065 "get_hash_global_config (port_id)\n"
1066 " Get the global configurations of hash filters.\n\n"
1068 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1069 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1070 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1071 " (enable|disable)\n"
1072 " Set the global configurations of hash filters.\n\n"
1074 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1075 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1076 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1077 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1078 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1079 "ipv6-next-header|udp-src-port|udp-dst-port|"
1080 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1081 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1082 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1083 "fld-8th|none) (select|add)\n"
1084 " Set the input set for hash.\n\n"
1086 "set_fdir_input_set (port_id) "
1087 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1088 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1089 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1090 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1091 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1092 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1093 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1095 " Set the input set for FDir.\n\n"
1097 "flow validate {port_id}"
1098 " [group {group_id}] [priority {level}]"
1099 " [ingress] [egress]"
1100 " pattern {item} [/ {item} [...]] / end"
1101 " actions {action} [/ {action} [...]] / end\n"
1102 " Check whether a flow rule can be created.\n\n"
1104 "flow create {port_id}"
1105 " [group {group_id}] [priority {level}]"
1106 " [ingress] [egress]"
1107 " pattern {item} [/ {item} [...]] / end"
1108 " actions {action} [/ {action} [...]] / end\n"
1109 " Create a flow rule.\n\n"
1111 "flow destroy {port_id} rule {rule_id} [...]\n"
1112 " Destroy specific flow rules.\n\n"
1114 "flow flush {port_id}\n"
1115 " Destroy all flow rules.\n\n"
1117 "flow query {port_id} {rule_id} {action}\n"
1118 " Query an existing flow rule.\n\n"
1120 "flow list {port_id} [group {group_id}] [...]\n"
1121 " List existing flow rules sorted by priority,"
1122 " filtered by group identifiers.\n\n"
1124 "flow isolate {port_id} {boolean}\n"
1125 " Restrict ingress traffic to the defined"
1128 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1129 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1130 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1131 " Configure the VXLAN encapsulation for flows.\n\n"
1133 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1134 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1135 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1136 " eth-dst (eth-dst)\n"
1137 " Configure the VXLAN encapsulation for flows.\n\n"
1139 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1140 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1141 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1142 " eth-dst (eth-dst)\n"
1143 " Configure the VXLAN encapsulation for flows.\n\n"
1145 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1146 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1148 " Configure the NVGRE encapsulation for flows.\n\n"
1150 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1151 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1152 " eth-src (eth-src) eth-dst (eth-dst)\n"
1153 " Configure the NVGRE encapsulation for flows.\n\n"
1155 "set raw_encap {flow items}\n"
1156 " Configure the encapsulation with raw data.\n\n"
1158 "set raw_decap {flow items}\n"
1159 " Configure the decapsulation with raw data.\n\n"
1164 if (show_all || !strcmp(res->section, "traffic_management")) {
1168 "Traffic Management:\n"
1170 "show port tm cap (port_id)\n"
1171 " Display the port TM capability.\n\n"
1173 "show port tm level cap (port_id) (level_id)\n"
1174 " Display the port TM hierarchical level capability.\n\n"
1176 "show port tm node cap (port_id) (node_id)\n"
1177 " Display the port TM node capability.\n\n"
1179 "show port tm node type (port_id) (node_id)\n"
1180 " Display the port TM node type.\n\n"
1182 "show port tm node stats (port_id) (node_id) (clear)\n"
1183 " Display the port TM node stats.\n\n"
1185 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1186 "set port tm hierarchy default (port_id)\n"
1187 " Set default traffic Management hierarchy on a port\n\n"
1190 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1191 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1192 " (packet_length_adjust)\n"
1193 " Add port tm node private shaper profile.\n\n"
1195 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1196 " Delete port tm node private shaper profile.\n\n"
1198 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1199 " (shaper_profile_id)\n"
1200 " Add/update port tm node shared shaper.\n\n"
1202 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1203 " Delete port tm node shared shaper.\n\n"
1205 "set port tm node shaper profile (port_id) (node_id)"
1206 " (shaper_profile_id)\n"
1207 " Set port tm node shaper profile.\n\n"
1209 "add port tm node wred profile (port_id) (wred_profile_id)"
1210 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1211 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1212 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1213 " Add port tm node wred profile.\n\n"
1215 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1216 " Delete port tm node wred profile.\n\n"
1218 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1219 " (priority) (weight) (level_id) (shaper_profile_id)"
1220 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1221 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1222 " Add port tm nonleaf node.\n\n"
1224 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1225 " (priority) (weight) (level_id) (shaper_profile_id)"
1226 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1227 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1228 " Add port tm leaf node.\n\n"
1230 "del port tm node (port_id) (node_id)\n"
1231 " Delete port tm node.\n\n"
1233 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1234 " (priority) (weight)\n"
1235 " Set port tm node parent.\n\n"
1237 "suspend port tm node (port_id) (node_id)"
1238 " Suspend tm node.\n\n"
1240 "resume port tm node (port_id) (node_id)"
1241 " Resume tm node.\n\n"
1243 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1244 " Commit tm hierarchy.\n\n"
1246 "set port tm mark ip_ecn (port) (green) (yellow)"
1248 " Enables/Disables the traffic management marking"
1249 " for IP ECN (Explicit Congestion Notification)"
1250 " packets on a given port\n\n"
1252 "set port tm mark ip_dscp (port) (green) (yellow)"
1254 " Enables/Disables the traffic management marking"
1255 " on the port for IP dscp packets\n\n"
1257 "set port tm mark vlan_dei (port) (green) (yellow)"
1259 " Enables/Disables the traffic management marking"
1260 " on the port for VLAN packets with DEI enabled\n\n"
1264 if (show_all || !strcmp(res->section, "devices")) {
1268 "Device Operations:\n"
1270 "device detach (identifier)\n"
1271 " Detach device by identifier.\n\n"
1277 cmdline_parse_token_string_t cmd_help_long_help =
1278 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1280 cmdline_parse_token_string_t cmd_help_long_section =
1281 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1282 "all#control#display#config#"
1283 "ports#registers#filters#traffic_management#devices");
1285 cmdline_parse_inst_t cmd_help_long = {
1286 .f = cmd_help_long_parsed,
1288 .help_str = "help all|control|display|config|ports|register|"
1289 "filters|traffic_management|devices: "
1292 (void *)&cmd_help_long_help,
1293 (void *)&cmd_help_long_section,
1299 /* *** start/stop/close all ports *** */
1300 struct cmd_operate_port_result {
1301 cmdline_fixed_string_t keyword;
1302 cmdline_fixed_string_t name;
1303 cmdline_fixed_string_t value;
1306 static void cmd_operate_port_parsed(void *parsed_result,
1307 __rte_unused struct cmdline *cl,
1308 __rte_unused void *data)
1310 struct cmd_operate_port_result *res = parsed_result;
1312 if (!strcmp(res->name, "start"))
1313 start_port(RTE_PORT_ALL);
1314 else if (!strcmp(res->name, "stop"))
1315 stop_port(RTE_PORT_ALL);
1316 else if (!strcmp(res->name, "close"))
1317 close_port(RTE_PORT_ALL);
1318 else if (!strcmp(res->name, "reset"))
1319 reset_port(RTE_PORT_ALL);
1321 printf("Unknown parameter\n");
1324 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1325 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1327 cmdline_parse_token_string_t cmd_operate_port_all_port =
1328 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1329 "start#stop#close#reset");
1330 cmdline_parse_token_string_t cmd_operate_port_all_all =
1331 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1333 cmdline_parse_inst_t cmd_operate_port = {
1334 .f = cmd_operate_port_parsed,
1336 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1338 (void *)&cmd_operate_port_all_cmd,
1339 (void *)&cmd_operate_port_all_port,
1340 (void *)&cmd_operate_port_all_all,
1345 /* *** start/stop/close specific port *** */
1346 struct cmd_operate_specific_port_result {
1347 cmdline_fixed_string_t keyword;
1348 cmdline_fixed_string_t name;
1352 static void cmd_operate_specific_port_parsed(void *parsed_result,
1353 __rte_unused struct cmdline *cl,
1354 __rte_unused void *data)
1356 struct cmd_operate_specific_port_result *res = parsed_result;
1358 if (!strcmp(res->name, "start"))
1359 start_port(res->value);
1360 else if (!strcmp(res->name, "stop"))
1361 stop_port(res->value);
1362 else if (!strcmp(res->name, "close"))
1363 close_port(res->value);
1364 else if (!strcmp(res->name, "reset"))
1365 reset_port(res->value);
1367 printf("Unknown parameter\n");
1370 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1371 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1373 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1374 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1375 name, "start#stop#close#reset");
1376 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1377 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1380 cmdline_parse_inst_t cmd_operate_specific_port = {
1381 .f = cmd_operate_specific_port_parsed,
1383 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1385 (void *)&cmd_operate_specific_port_cmd,
1386 (void *)&cmd_operate_specific_port_port,
1387 (void *)&cmd_operate_specific_port_id,
1392 /* *** enable port setup (after attach) via iterator or event *** */
1393 struct cmd_set_port_setup_on_result {
1394 cmdline_fixed_string_t set;
1395 cmdline_fixed_string_t port;
1396 cmdline_fixed_string_t setup;
1397 cmdline_fixed_string_t on;
1398 cmdline_fixed_string_t mode;
1401 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1402 __rte_unused struct cmdline *cl,
1403 __rte_unused void *data)
1405 struct cmd_set_port_setup_on_result *res = parsed_result;
1407 if (strcmp(res->mode, "event") == 0)
1408 setup_on_probe_event = true;
1409 else if (strcmp(res->mode, "iterator") == 0)
1410 setup_on_probe_event = false;
1412 printf("Unknown mode\n");
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1416 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1418 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1419 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1421 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1422 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1424 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1425 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1427 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1428 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1429 mode, "iterator#event");
1431 cmdline_parse_inst_t cmd_set_port_setup_on = {
1432 .f = cmd_set_port_setup_on_parsed,
1434 .help_str = "set port setup on iterator|event",
1436 (void *)&cmd_set_port_setup_on_set,
1437 (void *)&cmd_set_port_setup_on_port,
1438 (void *)&cmd_set_port_setup_on_setup,
1439 (void *)&cmd_set_port_setup_on_on,
1440 (void *)&cmd_set_port_setup_on_mode,
1445 /* *** attach a specified port *** */
1446 struct cmd_operate_attach_port_result {
1447 cmdline_fixed_string_t port;
1448 cmdline_fixed_string_t keyword;
1449 cmdline_multi_string_t identifier;
1452 static void cmd_operate_attach_port_parsed(void *parsed_result,
1453 __rte_unused struct cmdline *cl,
1454 __rte_unused void *data)
1456 struct cmd_operate_attach_port_result *res = parsed_result;
1458 if (!strcmp(res->keyword, "attach"))
1459 attach_port(res->identifier);
1461 printf("Unknown parameter\n");
1464 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1465 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1467 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1468 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1470 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1471 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1472 identifier, TOKEN_STRING_MULTI);
1474 cmdline_parse_inst_t cmd_operate_attach_port = {
1475 .f = cmd_operate_attach_port_parsed,
1477 .help_str = "port attach <identifier>: "
1478 "(identifier: pci address or virtual dev name)",
1480 (void *)&cmd_operate_attach_port_port,
1481 (void *)&cmd_operate_attach_port_keyword,
1482 (void *)&cmd_operate_attach_port_identifier,
1487 /* *** detach a specified port *** */
1488 struct cmd_operate_detach_port_result {
1489 cmdline_fixed_string_t port;
1490 cmdline_fixed_string_t keyword;
1494 static void cmd_operate_detach_port_parsed(void *parsed_result,
1495 __rte_unused struct cmdline *cl,
1496 __rte_unused void *data)
1498 struct cmd_operate_detach_port_result *res = parsed_result;
1500 if (!strcmp(res->keyword, "detach")) {
1501 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1502 detach_port_device(res->port_id);
1504 printf("Unknown parameter\n");
1508 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1509 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1511 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1512 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1514 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1515 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1518 cmdline_parse_inst_t cmd_operate_detach_port = {
1519 .f = cmd_operate_detach_port_parsed,
1521 .help_str = "port detach <port_id>",
1523 (void *)&cmd_operate_detach_port_port,
1524 (void *)&cmd_operate_detach_port_keyword,
1525 (void *)&cmd_operate_detach_port_port_id,
1530 /* *** detach device by identifier *** */
1531 struct cmd_operate_detach_device_result {
1532 cmdline_fixed_string_t device;
1533 cmdline_fixed_string_t keyword;
1534 cmdline_fixed_string_t identifier;
1537 static void cmd_operate_detach_device_parsed(void *parsed_result,
1538 __rte_unused struct cmdline *cl,
1539 __rte_unused void *data)
1541 struct cmd_operate_detach_device_result *res = parsed_result;
1543 if (!strcmp(res->keyword, "detach"))
1544 detach_devargs(res->identifier);
1546 printf("Unknown parameter\n");
1549 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1550 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1552 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1553 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1555 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1556 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1559 cmdline_parse_inst_t cmd_operate_detach_device = {
1560 .f = cmd_operate_detach_device_parsed,
1562 .help_str = "device detach <identifier>:"
1563 "(identifier: pci address or virtual dev name)",
1565 (void *)&cmd_operate_detach_device_device,
1566 (void *)&cmd_operate_detach_device_keyword,
1567 (void *)&cmd_operate_detach_device_identifier,
1571 /* *** configure speed for all ports *** */
1572 struct cmd_config_speed_all {
1573 cmdline_fixed_string_t port;
1574 cmdline_fixed_string_t keyword;
1575 cmdline_fixed_string_t all;
1576 cmdline_fixed_string_t item1;
1577 cmdline_fixed_string_t item2;
1578 cmdline_fixed_string_t value1;
1579 cmdline_fixed_string_t value2;
1583 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1588 if (!strcmp(duplexstr, "half")) {
1589 duplex = ETH_LINK_HALF_DUPLEX;
1590 } else if (!strcmp(duplexstr, "full")) {
1591 duplex = ETH_LINK_FULL_DUPLEX;
1592 } else if (!strcmp(duplexstr, "auto")) {
1593 duplex = ETH_LINK_FULL_DUPLEX;
1595 printf("Unknown duplex parameter\n");
1599 if (!strcmp(speedstr, "10")) {
1600 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1601 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1602 } else if (!strcmp(speedstr, "100")) {
1603 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1604 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1606 if (duplex != ETH_LINK_FULL_DUPLEX) {
1607 printf("Invalid speed/duplex parameters\n");
1610 if (!strcmp(speedstr, "1000")) {
1611 *speed = ETH_LINK_SPEED_1G;
1612 } else if (!strcmp(speedstr, "10000")) {
1613 *speed = ETH_LINK_SPEED_10G;
1614 } else if (!strcmp(speedstr, "25000")) {
1615 *speed = ETH_LINK_SPEED_25G;
1616 } else if (!strcmp(speedstr, "40000")) {
1617 *speed = ETH_LINK_SPEED_40G;
1618 } else if (!strcmp(speedstr, "50000")) {
1619 *speed = ETH_LINK_SPEED_50G;
1620 } else if (!strcmp(speedstr, "100000")) {
1621 *speed = ETH_LINK_SPEED_100G;
1622 } else if (!strcmp(speedstr, "auto")) {
1623 *speed = ETH_LINK_SPEED_AUTONEG;
1625 printf("Unknown speed parameter\n");
1634 cmd_config_speed_all_parsed(void *parsed_result,
1635 __rte_unused struct cmdline *cl,
1636 __rte_unused void *data)
1638 struct cmd_config_speed_all *res = parsed_result;
1639 uint32_t link_speed;
1642 if (!all_ports_stopped()) {
1643 printf("Please stop all ports first\n");
1647 if (parse_and_check_speed_duplex(res->value1, res->value2,
1651 RTE_ETH_FOREACH_DEV(pid) {
1652 ports[pid].dev_conf.link_speeds = link_speed;
1655 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1658 cmdline_parse_token_string_t cmd_config_speed_all_port =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1660 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1663 cmdline_parse_token_string_t cmd_config_speed_all_all =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1665 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1667 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1669 "10#100#1000#10000#25000#40000#50000#100000#auto");
1670 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1672 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1673 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1676 cmdline_parse_inst_t cmd_config_speed_all = {
1677 .f = cmd_config_speed_all_parsed,
1679 .help_str = "port config all speed "
1680 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1683 (void *)&cmd_config_speed_all_port,
1684 (void *)&cmd_config_speed_all_keyword,
1685 (void *)&cmd_config_speed_all_all,
1686 (void *)&cmd_config_speed_all_item1,
1687 (void *)&cmd_config_speed_all_value1,
1688 (void *)&cmd_config_speed_all_item2,
1689 (void *)&cmd_config_speed_all_value2,
1694 /* *** configure speed for specific port *** */
1695 struct cmd_config_speed_specific {
1696 cmdline_fixed_string_t port;
1697 cmdline_fixed_string_t keyword;
1699 cmdline_fixed_string_t item1;
1700 cmdline_fixed_string_t item2;
1701 cmdline_fixed_string_t value1;
1702 cmdline_fixed_string_t value2;
1706 cmd_config_speed_specific_parsed(void *parsed_result,
1707 __rte_unused struct cmdline *cl,
1708 __rte_unused void *data)
1710 struct cmd_config_speed_specific *res = parsed_result;
1711 uint32_t link_speed;
1713 if (!all_ports_stopped()) {
1714 printf("Please stop all ports first\n");
1718 if (port_id_is_invalid(res->id, ENABLED_WARN))
1721 if (parse_and_check_speed_duplex(res->value1, res->value2,
1725 ports[res->id].dev_conf.link_speeds = link_speed;
1727 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1731 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1734 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1735 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1737 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1738 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1739 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1740 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1742 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1743 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1744 "10#100#1000#10000#25000#40000#50000#100000#auto");
1745 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1746 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1748 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1749 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1752 cmdline_parse_inst_t cmd_config_speed_specific = {
1753 .f = cmd_config_speed_specific_parsed,
1755 .help_str = "port config <port_id> speed "
1756 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1759 (void *)&cmd_config_speed_specific_port,
1760 (void *)&cmd_config_speed_specific_keyword,
1761 (void *)&cmd_config_speed_specific_id,
1762 (void *)&cmd_config_speed_specific_item1,
1763 (void *)&cmd_config_speed_specific_value1,
1764 (void *)&cmd_config_speed_specific_item2,
1765 (void *)&cmd_config_speed_specific_value2,
1770 /* *** configure loopback for all ports *** */
1771 struct cmd_config_loopback_all {
1772 cmdline_fixed_string_t port;
1773 cmdline_fixed_string_t keyword;
1774 cmdline_fixed_string_t all;
1775 cmdline_fixed_string_t item;
1780 cmd_config_loopback_all_parsed(void *parsed_result,
1781 __rte_unused struct cmdline *cl,
1782 __rte_unused void *data)
1784 struct cmd_config_loopback_all *res = parsed_result;
1787 if (!all_ports_stopped()) {
1788 printf("Please stop all ports first\n");
1792 RTE_ETH_FOREACH_DEV(pid) {
1793 ports[pid].dev_conf.lpbk_mode = res->mode;
1796 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1799 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1801 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1802 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1804 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1805 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1806 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1807 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1809 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1810 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1812 cmdline_parse_inst_t cmd_config_loopback_all = {
1813 .f = cmd_config_loopback_all_parsed,
1815 .help_str = "port config all loopback <mode>",
1817 (void *)&cmd_config_loopback_all_port,
1818 (void *)&cmd_config_loopback_all_keyword,
1819 (void *)&cmd_config_loopback_all_all,
1820 (void *)&cmd_config_loopback_all_item,
1821 (void *)&cmd_config_loopback_all_mode,
1826 /* *** configure loopback for specific port *** */
1827 struct cmd_config_loopback_specific {
1828 cmdline_fixed_string_t port;
1829 cmdline_fixed_string_t keyword;
1831 cmdline_fixed_string_t item;
1836 cmd_config_loopback_specific_parsed(void *parsed_result,
1837 __rte_unused struct cmdline *cl,
1838 __rte_unused void *data)
1840 struct cmd_config_loopback_specific *res = parsed_result;
1842 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1845 if (!port_is_stopped(res->port_id)) {
1846 printf("Please stop port %u first\n", res->port_id);
1850 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1852 cmd_reconfig_device_queue(res->port_id, 1, 1);
1856 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1859 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1862 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1863 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1865 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1868 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1869 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1872 cmdline_parse_inst_t cmd_config_loopback_specific = {
1873 .f = cmd_config_loopback_specific_parsed,
1875 .help_str = "port config <port_id> loopback <mode>",
1877 (void *)&cmd_config_loopback_specific_port,
1878 (void *)&cmd_config_loopback_specific_keyword,
1879 (void *)&cmd_config_loopback_specific_id,
1880 (void *)&cmd_config_loopback_specific_item,
1881 (void *)&cmd_config_loopback_specific_mode,
1886 /* *** configure txq/rxq, txd/rxd *** */
1887 struct cmd_config_rx_tx {
1888 cmdline_fixed_string_t port;
1889 cmdline_fixed_string_t keyword;
1890 cmdline_fixed_string_t all;
1891 cmdline_fixed_string_t name;
1896 cmd_config_rx_tx_parsed(void *parsed_result,
1897 __rte_unused struct cmdline *cl,
1898 __rte_unused void *data)
1900 struct cmd_config_rx_tx *res = parsed_result;
1902 if (!all_ports_stopped()) {
1903 printf("Please stop all ports first\n");
1906 if (!strcmp(res->name, "rxq")) {
1907 if (!res->value && !nb_txq) {
1908 printf("Warning: Either rx or tx queues should be non zero\n");
1911 if (check_nb_rxq(res->value) != 0)
1913 nb_rxq = res->value;
1915 else if (!strcmp(res->name, "txq")) {
1916 if (!res->value && !nb_rxq) {
1917 printf("Warning: Either rx or tx queues should be non zero\n");
1920 if (check_nb_txq(res->value) != 0)
1922 nb_txq = res->value;
1924 else if (!strcmp(res->name, "rxd")) {
1925 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1926 printf("rxd %d invalid - must be > 0 && <= %d\n",
1927 res->value, RTE_TEST_RX_DESC_MAX);
1930 nb_rxd = res->value;
1931 } else if (!strcmp(res->name, "txd")) {
1932 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1933 printf("txd %d invalid - must be > 0 && <= %d\n",
1934 res->value, RTE_TEST_TX_DESC_MAX);
1937 nb_txd = res->value;
1939 printf("Unknown parameter\n");
1947 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1950 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1952 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1954 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1956 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1957 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1959 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1960 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1962 cmdline_parse_inst_t cmd_config_rx_tx = {
1963 .f = cmd_config_rx_tx_parsed,
1965 .help_str = "port config all rxq|txq|rxd|txd <value>",
1967 (void *)&cmd_config_rx_tx_port,
1968 (void *)&cmd_config_rx_tx_keyword,
1969 (void *)&cmd_config_rx_tx_all,
1970 (void *)&cmd_config_rx_tx_name,
1971 (void *)&cmd_config_rx_tx_value,
1976 /* *** config max packet length *** */
1977 struct cmd_config_max_pkt_len_result {
1978 cmdline_fixed_string_t port;
1979 cmdline_fixed_string_t keyword;
1980 cmdline_fixed_string_t all;
1981 cmdline_fixed_string_t name;
1986 cmd_config_max_pkt_len_parsed(void *parsed_result,
1987 __rte_unused struct cmdline *cl,
1988 __rte_unused void *data)
1990 struct cmd_config_max_pkt_len_result *res = parsed_result;
1993 if (!all_ports_stopped()) {
1994 printf("Please stop all ports first\n");
1998 RTE_ETH_FOREACH_DEV(pid) {
1999 struct rte_port *port = &ports[pid];
2000 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2002 if (!strcmp(res->name, "max-pkt-len")) {
2003 if (res->value < RTE_ETHER_MIN_LEN) {
2004 printf("max-pkt-len can not be less than %d\n",
2008 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2011 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2012 if (res->value > RTE_ETHER_MAX_LEN)
2013 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2015 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2016 port->dev_conf.rxmode.offloads = rx_offloads;
2018 printf("Unknown parameter\n");
2025 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2028 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2029 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2031 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2032 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2034 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2037 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2038 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2040 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2041 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2044 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2045 .f = cmd_config_max_pkt_len_parsed,
2047 .help_str = "port config all max-pkt-len <value>",
2049 (void *)&cmd_config_max_pkt_len_port,
2050 (void *)&cmd_config_max_pkt_len_keyword,
2051 (void *)&cmd_config_max_pkt_len_all,
2052 (void *)&cmd_config_max_pkt_len_name,
2053 (void *)&cmd_config_max_pkt_len_value,
2058 /* *** config max LRO aggregated packet size *** */
2059 struct cmd_config_max_lro_pkt_size_result {
2060 cmdline_fixed_string_t port;
2061 cmdline_fixed_string_t keyword;
2062 cmdline_fixed_string_t all;
2063 cmdline_fixed_string_t name;
2068 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2069 __rte_unused struct cmdline *cl,
2070 __rte_unused void *data)
2072 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2075 if (!all_ports_stopped()) {
2076 printf("Please stop all ports first\n");
2080 RTE_ETH_FOREACH_DEV(pid) {
2081 struct rte_port *port = &ports[pid];
2083 if (!strcmp(res->name, "max-lro-pkt-size")) {
2085 port->dev_conf.rxmode.max_lro_pkt_size)
2088 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2090 printf("Unknown parameter\n");
2097 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2100 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2101 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2103 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2104 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2106 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2107 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2109 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2111 name, "max-lro-pkt-size");
2112 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2113 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2116 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2117 .f = cmd_config_max_lro_pkt_size_parsed,
2119 .help_str = "port config all max-lro-pkt-size <value>",
2121 (void *)&cmd_config_max_lro_pkt_size_port,
2122 (void *)&cmd_config_max_lro_pkt_size_keyword,
2123 (void *)&cmd_config_max_lro_pkt_size_all,
2124 (void *)&cmd_config_max_lro_pkt_size_name,
2125 (void *)&cmd_config_max_lro_pkt_size_value,
2130 /* *** configure port MTU *** */
2131 struct cmd_config_mtu_result {
2132 cmdline_fixed_string_t port;
2133 cmdline_fixed_string_t keyword;
2134 cmdline_fixed_string_t mtu;
2140 cmd_config_mtu_parsed(void *parsed_result,
2141 __rte_unused struct cmdline *cl,
2142 __rte_unused void *data)
2144 struct cmd_config_mtu_result *res = parsed_result;
2146 if (res->value < RTE_ETHER_MIN_LEN) {
2147 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2150 port_mtu_set(res->port_id, res->value);
2153 cmdline_parse_token_string_t cmd_config_mtu_port =
2154 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2156 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2157 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2159 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2160 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2162 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2163 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2164 cmdline_parse_token_num_t cmd_config_mtu_value =
2165 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2167 cmdline_parse_inst_t cmd_config_mtu = {
2168 .f = cmd_config_mtu_parsed,
2170 .help_str = "port config mtu <port_id> <value>",
2172 (void *)&cmd_config_mtu_port,
2173 (void *)&cmd_config_mtu_keyword,
2174 (void *)&cmd_config_mtu_mtu,
2175 (void *)&cmd_config_mtu_port_id,
2176 (void *)&cmd_config_mtu_value,
2181 /* *** configure rx mode *** */
2182 struct cmd_config_rx_mode_flag {
2183 cmdline_fixed_string_t port;
2184 cmdline_fixed_string_t keyword;
2185 cmdline_fixed_string_t all;
2186 cmdline_fixed_string_t name;
2187 cmdline_fixed_string_t value;
2191 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2192 __rte_unused struct cmdline *cl,
2193 __rte_unused void *data)
2195 struct cmd_config_rx_mode_flag *res = parsed_result;
2197 if (!all_ports_stopped()) {
2198 printf("Please stop all ports first\n");
2202 if (!strcmp(res->name, "drop-en")) {
2203 if (!strcmp(res->value, "on"))
2205 else if (!strcmp(res->value, "off"))
2208 printf("Unknown parameter\n");
2212 printf("Unknown parameter\n");
2218 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2221 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2222 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2223 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2224 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2226 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2227 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2228 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2229 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2231 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2232 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2235 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2236 .f = cmd_config_rx_mode_flag_parsed,
2238 .help_str = "port config all drop-en on|off",
2240 (void *)&cmd_config_rx_mode_flag_port,
2241 (void *)&cmd_config_rx_mode_flag_keyword,
2242 (void *)&cmd_config_rx_mode_flag_all,
2243 (void *)&cmd_config_rx_mode_flag_name,
2244 (void *)&cmd_config_rx_mode_flag_value,
2249 /* *** configure rss *** */
2250 struct cmd_config_rss {
2251 cmdline_fixed_string_t port;
2252 cmdline_fixed_string_t keyword;
2253 cmdline_fixed_string_t all;
2254 cmdline_fixed_string_t name;
2255 cmdline_fixed_string_t value;
2259 cmd_config_rss_parsed(void *parsed_result,
2260 __rte_unused struct cmdline *cl,
2261 __rte_unused void *data)
2263 struct cmd_config_rss *res = parsed_result;
2264 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2265 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2266 int use_default = 0;
2267 int all_updated = 1;
2272 if (!strcmp(res->value, "all"))
2273 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2274 ETH_RSS_UDP | ETH_RSS_SCTP |
2276 else if (!strcmp(res->value, "ip"))
2277 rss_conf.rss_hf = ETH_RSS_IP;
2278 else if (!strcmp(res->value, "udp"))
2279 rss_conf.rss_hf = ETH_RSS_UDP;
2280 else if (!strcmp(res->value, "tcp"))
2281 rss_conf.rss_hf = ETH_RSS_TCP;
2282 else if (!strcmp(res->value, "sctp"))
2283 rss_conf.rss_hf = ETH_RSS_SCTP;
2284 else if (!strcmp(res->value, "ether"))
2285 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2286 else if (!strcmp(res->value, "port"))
2287 rss_conf.rss_hf = ETH_RSS_PORT;
2288 else if (!strcmp(res->value, "vxlan"))
2289 rss_conf.rss_hf = ETH_RSS_VXLAN;
2290 else if (!strcmp(res->value, "geneve"))
2291 rss_conf.rss_hf = ETH_RSS_GENEVE;
2292 else if (!strcmp(res->value, "nvgre"))
2293 rss_conf.rss_hf = ETH_RSS_NVGRE;
2294 else if (!strcmp(res->value, "l3-src-only"))
2295 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2296 else if (!strcmp(res->value, "l3-dst-only"))
2297 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2298 else if (!strcmp(res->value, "l4-src-only"))
2299 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2300 else if (!strcmp(res->value, "l4-dst-only"))
2301 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2302 else if (!strcmp(res->value, "none"))
2303 rss_conf.rss_hf = 0;
2304 else if (!strcmp(res->value, "default"))
2306 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2307 atoi(res->value) < 64)
2308 rss_conf.rss_hf = 1ULL << atoi(res->value);
2310 printf("Unknown parameter\n");
2313 rss_conf.rss_key = NULL;
2314 /* Update global configuration for RSS types. */
2315 RTE_ETH_FOREACH_DEV(i) {
2316 struct rte_eth_rss_conf local_rss_conf;
2318 ret = eth_dev_info_get_print_err(i, &dev_info);
2323 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2325 local_rss_conf = rss_conf;
2326 local_rss_conf.rss_hf = rss_conf.rss_hf &
2327 dev_info.flow_type_rss_offloads;
2328 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2329 printf("Port %u modified RSS hash function based on hardware support,"
2330 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2331 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2333 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2336 printf("Configuration of RSS hash at ethernet port %d "
2337 "failed with error (%d): %s.\n",
2338 i, -diag, strerror(-diag));
2341 if (all_updated && !use_default) {
2342 rss_hf = rss_conf.rss_hf;
2343 printf("rss_hf %#"PRIx64"\n", rss_hf);
2347 cmdline_parse_token_string_t cmd_config_rss_port =
2348 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2349 cmdline_parse_token_string_t cmd_config_rss_keyword =
2350 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2351 cmdline_parse_token_string_t cmd_config_rss_all =
2352 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2353 cmdline_parse_token_string_t cmd_config_rss_name =
2354 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2355 cmdline_parse_token_string_t cmd_config_rss_value =
2356 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2358 cmdline_parse_inst_t cmd_config_rss = {
2359 .f = cmd_config_rss_parsed,
2361 .help_str = "port config all rss "
2362 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2364 (void *)&cmd_config_rss_port,
2365 (void *)&cmd_config_rss_keyword,
2366 (void *)&cmd_config_rss_all,
2367 (void *)&cmd_config_rss_name,
2368 (void *)&cmd_config_rss_value,
2373 /* *** configure rss hash key *** */
2374 struct cmd_config_rss_hash_key {
2375 cmdline_fixed_string_t port;
2376 cmdline_fixed_string_t config;
2378 cmdline_fixed_string_t rss_hash_key;
2379 cmdline_fixed_string_t rss_type;
2380 cmdline_fixed_string_t key;
2384 hexa_digit_to_value(char hexa_digit)
2386 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2387 return (uint8_t) (hexa_digit - '0');
2388 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2389 return (uint8_t) ((hexa_digit - 'a') + 10);
2390 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2391 return (uint8_t) ((hexa_digit - 'A') + 10);
2392 /* Invalid hexa digit */
2397 parse_and_check_key_hexa_digit(char *key, int idx)
2401 hexa_v = hexa_digit_to_value(key[idx]);
2403 printf("invalid key: character %c at position %d is not a "
2404 "valid hexa digit\n", key[idx], idx);
2409 cmd_config_rss_hash_key_parsed(void *parsed_result,
2410 __rte_unused struct cmdline *cl,
2411 __rte_unused void *data)
2413 struct cmd_config_rss_hash_key *res = parsed_result;
2414 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2418 struct rte_eth_dev_info dev_info;
2419 uint8_t hash_key_size;
2423 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2427 if (dev_info.hash_key_size > 0 &&
2428 dev_info.hash_key_size <= sizeof(hash_key))
2429 hash_key_size = dev_info.hash_key_size;
2431 printf("dev_info did not provide a valid hash key size\n");
2434 /* Check the length of the RSS hash key */
2435 key_len = strlen(res->key);
2436 if (key_len != (hash_key_size * 2)) {
2437 printf("key length: %d invalid - key must be a string of %d"
2438 " hexa-decimal numbers\n",
2439 (int) key_len, hash_key_size * 2);
2442 /* Translate RSS hash key into binary representation */
2443 for (i = 0; i < hash_key_size; i++) {
2444 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2447 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2450 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2452 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2456 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2457 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2458 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2459 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2461 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2462 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2463 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2464 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2465 rss_hash_key, "rss-hash-key");
2466 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2467 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2468 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2469 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2470 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2471 "ipv6-tcp-ex#ipv6-udp-ex#"
2472 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2473 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2474 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2476 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2477 .f = cmd_config_rss_hash_key_parsed,
2479 .help_str = "port config <port_id> rss-hash-key "
2480 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2481 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2482 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2483 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2484 "<string of hex digits (variable length, NIC dependent)>",
2486 (void *)&cmd_config_rss_hash_key_port,
2487 (void *)&cmd_config_rss_hash_key_config,
2488 (void *)&cmd_config_rss_hash_key_port_id,
2489 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2490 (void *)&cmd_config_rss_hash_key_rss_type,
2491 (void *)&cmd_config_rss_hash_key_value,
2496 /* *** configure port rxq/txq ring size *** */
2497 struct cmd_config_rxtx_ring_size {
2498 cmdline_fixed_string_t port;
2499 cmdline_fixed_string_t config;
2501 cmdline_fixed_string_t rxtxq;
2503 cmdline_fixed_string_t rsize;
2508 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2509 __rte_unused struct cmdline *cl,
2510 __rte_unused void *data)
2512 struct cmd_config_rxtx_ring_size *res = parsed_result;
2513 struct rte_port *port;
2516 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2519 if (res->portid == (portid_t)RTE_PORT_ALL) {
2520 printf("Invalid port id\n");
2524 port = &ports[res->portid];
2526 if (!strcmp(res->rxtxq, "rxq"))
2528 else if (!strcmp(res->rxtxq, "txq"))
2531 printf("Unknown parameter\n");
2535 if (isrx && rx_queue_id_is_invalid(res->qid))
2537 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2540 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2541 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2547 port->nb_rx_desc[res->qid] = res->size;
2549 port->nb_tx_desc[res->qid] = res->size;
2551 cmd_reconfig_device_queue(res->portid, 0, 1);
2554 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2555 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2557 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2558 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2560 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2561 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2563 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2564 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2566 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2567 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2569 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2570 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2571 rsize, "ring_size");
2572 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2573 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2576 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2577 .f = cmd_config_rxtx_ring_size_parsed,
2579 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2581 (void *)&cmd_config_rxtx_ring_size_port,
2582 (void *)&cmd_config_rxtx_ring_size_config,
2583 (void *)&cmd_config_rxtx_ring_size_portid,
2584 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2585 (void *)&cmd_config_rxtx_ring_size_qid,
2586 (void *)&cmd_config_rxtx_ring_size_rsize,
2587 (void *)&cmd_config_rxtx_ring_size_size,
2592 /* *** configure port rxq/txq start/stop *** */
2593 struct cmd_config_rxtx_queue {
2594 cmdline_fixed_string_t port;
2596 cmdline_fixed_string_t rxtxq;
2598 cmdline_fixed_string_t opname;
2602 cmd_config_rxtx_queue_parsed(void *parsed_result,
2603 __rte_unused struct cmdline *cl,
2604 __rte_unused void *data)
2606 struct cmd_config_rxtx_queue *res = parsed_result;
2611 if (test_done == 0) {
2612 printf("Please stop forwarding first\n");
2616 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2619 if (port_is_started(res->portid) != 1) {
2620 printf("Please start port %u first\n", res->portid);
2624 if (!strcmp(res->rxtxq, "rxq"))
2626 else if (!strcmp(res->rxtxq, "txq"))
2629 printf("Unknown parameter\n");
2633 if (isrx && rx_queue_id_is_invalid(res->qid))
2635 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2638 if (!strcmp(res->opname, "start"))
2640 else if (!strcmp(res->opname, "stop"))
2643 printf("Unknown parameter\n");
2647 if (isstart && isrx)
2648 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2649 else if (!isstart && isrx)
2650 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2651 else if (isstart && !isrx)
2652 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2654 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2656 if (ret == -ENOTSUP)
2657 printf("Function not supported in PMD driver\n");
2660 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2661 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2662 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2663 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2664 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2665 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2666 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2667 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2668 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2669 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2672 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2673 .f = cmd_config_rxtx_queue_parsed,
2675 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2677 (void *)&cmd_config_rxtx_queue_port,
2678 (void *)&cmd_config_rxtx_queue_portid,
2679 (void *)&cmd_config_rxtx_queue_rxtxq,
2680 (void *)&cmd_config_rxtx_queue_qid,
2681 (void *)&cmd_config_rxtx_queue_opname,
2686 /* *** configure port rxq/txq deferred start on/off *** */
2687 struct cmd_config_deferred_start_rxtx_queue {
2688 cmdline_fixed_string_t port;
2690 cmdline_fixed_string_t rxtxq;
2692 cmdline_fixed_string_t opname;
2693 cmdline_fixed_string_t state;
2697 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2698 __rte_unused struct cmdline *cl,
2699 __rte_unused void *data)
2701 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2702 struct rte_port *port;
2705 uint8_t needreconfig = 0;
2707 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2710 if (port_is_started(res->port_id) != 0) {
2711 printf("Please stop port %u first\n", res->port_id);
2715 port = &ports[res->port_id];
2717 isrx = !strcmp(res->rxtxq, "rxq");
2719 if (isrx && rx_queue_id_is_invalid(res->qid))
2721 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2724 ison = !strcmp(res->state, "on");
2726 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2727 port->rx_conf[res->qid].rx_deferred_start = ison;
2729 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2730 port->tx_conf[res->qid].tx_deferred_start = ison;
2735 cmd_reconfig_device_queue(res->port_id, 0, 1);
2738 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2739 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2741 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2742 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2744 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2745 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2747 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2748 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2750 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2751 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2752 opname, "deferred_start");
2753 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2754 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2757 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2758 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2760 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2762 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2763 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2764 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2765 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2766 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2767 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2772 /* *** configure port rxq/txq setup *** */
2773 struct cmd_setup_rxtx_queue {
2774 cmdline_fixed_string_t port;
2776 cmdline_fixed_string_t rxtxq;
2778 cmdline_fixed_string_t setup;
2781 /* Common CLI fields for queue setup */
2782 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2783 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2784 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2785 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2786 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2787 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2788 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2789 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2790 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2791 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2794 cmd_setup_rxtx_queue_parsed(
2795 void *parsed_result,
2796 __rte_unused struct cmdline *cl,
2797 __rte_unused void *data)
2799 struct cmd_setup_rxtx_queue *res = parsed_result;
2800 struct rte_port *port;
2801 struct rte_mempool *mp;
2802 unsigned int socket_id;
2806 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2809 if (res->portid == (portid_t)RTE_PORT_ALL) {
2810 printf("Invalid port id\n");
2814 if (!strcmp(res->rxtxq, "rxq"))
2816 else if (!strcmp(res->rxtxq, "txq"))
2819 printf("Unknown parameter\n");
2823 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2824 printf("Invalid rx queue\n");
2826 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2827 printf("Invalid tx queue\n");
2831 port = &ports[res->portid];
2833 socket_id = rxring_numa[res->portid];
2834 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2835 socket_id = port->socket_id;
2837 mp = mbuf_pool_find(socket_id);
2839 printf("Failed to setup RX queue: "
2840 "No mempool allocation"
2841 " on the socket %d\n",
2842 rxring_numa[res->portid]);
2845 ret = rte_eth_rx_queue_setup(res->portid,
2847 port->nb_rx_desc[res->qid],
2849 &port->rx_conf[res->qid],
2852 printf("Failed to setup RX queue\n");
2854 socket_id = txring_numa[res->portid];
2855 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2856 socket_id = port->socket_id;
2858 ret = rte_eth_tx_queue_setup(res->portid,
2860 port->nb_tx_desc[res->qid],
2862 &port->tx_conf[res->qid]);
2864 printf("Failed to setup TX queue\n");
2868 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2869 .f = cmd_setup_rxtx_queue_parsed,
2871 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2873 (void *)&cmd_setup_rxtx_queue_port,
2874 (void *)&cmd_setup_rxtx_queue_portid,
2875 (void *)&cmd_setup_rxtx_queue_rxtxq,
2876 (void *)&cmd_setup_rxtx_queue_qid,
2877 (void *)&cmd_setup_rxtx_queue_setup,
2883 /* *** Configure RSS RETA *** */
2884 struct cmd_config_rss_reta {
2885 cmdline_fixed_string_t port;
2886 cmdline_fixed_string_t keyword;
2888 cmdline_fixed_string_t name;
2889 cmdline_fixed_string_t list_name;
2890 cmdline_fixed_string_t list_of_items;
2894 parse_reta_config(const char *str,
2895 struct rte_eth_rss_reta_entry64 *reta_conf,
2896 uint16_t nb_entries)
2900 uint16_t hash_index, idx, shift;
2903 const char *p, *p0 = str;
2910 unsigned long int_fld[_NUM_FLD];
2911 char *str_fld[_NUM_FLD];
2913 while ((p = strchr(p0,'(')) != NULL) {
2915 if((p0 = strchr(p,')')) == NULL)
2919 if(size >= sizeof(s))
2922 snprintf(s, sizeof(s), "%.*s", size, p);
2923 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2925 for (i = 0; i < _NUM_FLD; i++) {
2927 int_fld[i] = strtoul(str_fld[i], &end, 0);
2928 if (errno != 0 || end == str_fld[i] ||
2933 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2934 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2936 if (hash_index >= nb_entries) {
2937 printf("Invalid RETA hash index=%d\n", hash_index);
2941 idx = hash_index / RTE_RETA_GROUP_SIZE;
2942 shift = hash_index % RTE_RETA_GROUP_SIZE;
2943 reta_conf[idx].mask |= (1ULL << shift);
2944 reta_conf[idx].reta[shift] = nb_queue;
2951 cmd_set_rss_reta_parsed(void *parsed_result,
2952 __rte_unused struct cmdline *cl,
2953 __rte_unused void *data)
2956 struct rte_eth_dev_info dev_info;
2957 struct rte_eth_rss_reta_entry64 reta_conf[8];
2958 struct cmd_config_rss_reta *res = parsed_result;
2960 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2964 if (dev_info.reta_size == 0) {
2965 printf("Redirection table size is 0 which is "
2966 "invalid for RSS\n");
2969 printf("The reta size of port %d is %u\n",
2970 res->port_id, dev_info.reta_size);
2971 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2972 printf("Currently do not support more than %u entries of "
2973 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2977 memset(reta_conf, 0, sizeof(reta_conf));
2978 if (!strcmp(res->list_name, "reta")) {
2979 if (parse_reta_config(res->list_of_items, reta_conf,
2980 dev_info.reta_size)) {
2981 printf("Invalid RSS Redirection Table "
2982 "config entered\n");
2985 ret = rte_eth_dev_rss_reta_update(res->port_id,
2986 reta_conf, dev_info.reta_size);
2988 printf("Bad redirection table parameter, "
2989 "return code = %d \n", ret);
2993 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2994 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2995 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2996 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2997 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2998 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2999 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3000 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3001 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3002 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3003 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3004 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3006 cmdline_parse_inst_t cmd_config_rss_reta = {
3007 .f = cmd_set_rss_reta_parsed,
3009 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3011 (void *)&cmd_config_rss_reta_port,
3012 (void *)&cmd_config_rss_reta_keyword,
3013 (void *)&cmd_config_rss_reta_port_id,
3014 (void *)&cmd_config_rss_reta_name,
3015 (void *)&cmd_config_rss_reta_list_name,
3016 (void *)&cmd_config_rss_reta_list_of_items,
3021 /* *** SHOW PORT RETA INFO *** */
3022 struct cmd_showport_reta {
3023 cmdline_fixed_string_t show;
3024 cmdline_fixed_string_t port;
3026 cmdline_fixed_string_t rss;
3027 cmdline_fixed_string_t reta;
3029 cmdline_fixed_string_t list_of_items;
3033 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3034 uint16_t nb_entries,
3038 const char *p, *p0 = str;
3043 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3044 RTE_RETA_GROUP_SIZE;
3047 p = strchr(p0, '(');
3051 p0 = strchr(p, ')');
3055 if (size >= sizeof(s)) {
3056 printf("The string size exceeds the internal buffer size\n");
3059 snprintf(s, sizeof(s), "%.*s", size, p);
3060 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3061 if (ret <= 0 || ret != num) {
3062 printf("The bits of masks do not match the number of "
3063 "reta entries: %u\n", num);
3066 for (i = 0; i < ret; i++)
3067 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3073 cmd_showport_reta_parsed(void *parsed_result,
3074 __rte_unused struct cmdline *cl,
3075 __rte_unused void *data)
3077 struct cmd_showport_reta *res = parsed_result;
3078 struct rte_eth_rss_reta_entry64 reta_conf[8];
3079 struct rte_eth_dev_info dev_info;
3080 uint16_t max_reta_size;
3083 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3087 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3088 if (res->size == 0 || res->size > max_reta_size) {
3089 printf("Invalid redirection table size: %u (1-%u)\n",
3090 res->size, max_reta_size);
3094 memset(reta_conf, 0, sizeof(reta_conf));
3095 if (showport_parse_reta_config(reta_conf, res->size,
3096 res->list_of_items) < 0) {
3097 printf("Invalid string: %s for reta masks\n",
3098 res->list_of_items);
3101 port_rss_reta_info(res->port_id, reta_conf, res->size);
3104 cmdline_parse_token_string_t cmd_showport_reta_show =
3105 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3106 cmdline_parse_token_string_t cmd_showport_reta_port =
3107 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3108 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3109 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3110 cmdline_parse_token_string_t cmd_showport_reta_rss =
3111 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3112 cmdline_parse_token_string_t cmd_showport_reta_reta =
3113 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3114 cmdline_parse_token_num_t cmd_showport_reta_size =
3115 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3116 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3117 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3118 list_of_items, NULL);
3120 cmdline_parse_inst_t cmd_showport_reta = {
3121 .f = cmd_showport_reta_parsed,
3123 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3125 (void *)&cmd_showport_reta_show,
3126 (void *)&cmd_showport_reta_port,
3127 (void *)&cmd_showport_reta_port_id,
3128 (void *)&cmd_showport_reta_rss,
3129 (void *)&cmd_showport_reta_reta,
3130 (void *)&cmd_showport_reta_size,
3131 (void *)&cmd_showport_reta_list_of_items,
3136 /* *** Show RSS hash configuration *** */
3137 struct cmd_showport_rss_hash {
3138 cmdline_fixed_string_t show;
3139 cmdline_fixed_string_t port;
3141 cmdline_fixed_string_t rss_hash;
3142 cmdline_fixed_string_t rss_type;
3143 cmdline_fixed_string_t key; /* optional argument */
3146 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3147 __rte_unused struct cmdline *cl,
3150 struct cmd_showport_rss_hash *res = parsed_result;
3152 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3155 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3156 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3157 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3158 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3159 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3160 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3161 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3162 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3164 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3165 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3167 cmdline_parse_inst_t cmd_showport_rss_hash = {
3168 .f = cmd_showport_rss_hash_parsed,
3170 .help_str = "show port <port_id> rss-hash",
3172 (void *)&cmd_showport_rss_hash_show,
3173 (void *)&cmd_showport_rss_hash_port,
3174 (void *)&cmd_showport_rss_hash_port_id,
3175 (void *)&cmd_showport_rss_hash_rss_hash,
3180 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3181 .f = cmd_showport_rss_hash_parsed,
3183 .help_str = "show port <port_id> rss-hash key",
3185 (void *)&cmd_showport_rss_hash_show,
3186 (void *)&cmd_showport_rss_hash_port,
3187 (void *)&cmd_showport_rss_hash_port_id,
3188 (void *)&cmd_showport_rss_hash_rss_hash,
3189 (void *)&cmd_showport_rss_hash_rss_key,
3194 /* *** Configure DCB *** */
3195 struct cmd_config_dcb {
3196 cmdline_fixed_string_t port;
3197 cmdline_fixed_string_t config;
3199 cmdline_fixed_string_t dcb;
3200 cmdline_fixed_string_t vt;
3201 cmdline_fixed_string_t vt_en;
3203 cmdline_fixed_string_t pfc;
3204 cmdline_fixed_string_t pfc_en;
3208 cmd_config_dcb_parsed(void *parsed_result,
3209 __rte_unused struct cmdline *cl,
3210 __rte_unused void *data)
3212 struct cmd_config_dcb *res = parsed_result;
3213 portid_t port_id = res->port_id;
3214 struct rte_port *port;
3218 port = &ports[port_id];
3219 /** Check if the port is not started **/
3220 if (port->port_status != RTE_PORT_STOPPED) {
3221 printf("Please stop port %d first\n", port_id);
3225 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3226 printf("The invalid number of traffic class,"
3227 " only 4 or 8 allowed.\n");
3231 if (nb_fwd_lcores < res->num_tcs) {
3232 printf("nb_cores shouldn't be less than number of TCs.\n");
3235 if (!strncmp(res->pfc_en, "on", 2))
3240 /* DCB in VT mode */
3241 if (!strncmp(res->vt_en, "on", 2))
3242 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3243 (enum rte_eth_nb_tcs)res->num_tcs,
3246 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3247 (enum rte_eth_nb_tcs)res->num_tcs,
3252 printf("Cannot initialize network ports.\n");
3256 cmd_reconfig_device_queue(port_id, 1, 1);
3259 cmdline_parse_token_string_t cmd_config_dcb_port =
3260 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3261 cmdline_parse_token_string_t cmd_config_dcb_config =
3262 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3263 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3264 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3265 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3266 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3267 cmdline_parse_token_string_t cmd_config_dcb_vt =
3268 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3269 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3270 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3271 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3272 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3273 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3274 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3275 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3276 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3278 cmdline_parse_inst_t cmd_config_dcb = {
3279 .f = cmd_config_dcb_parsed,
3281 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3283 (void *)&cmd_config_dcb_port,
3284 (void *)&cmd_config_dcb_config,
3285 (void *)&cmd_config_dcb_port_id,
3286 (void *)&cmd_config_dcb_dcb,
3287 (void *)&cmd_config_dcb_vt,
3288 (void *)&cmd_config_dcb_vt_en,
3289 (void *)&cmd_config_dcb_num_tcs,
3290 (void *)&cmd_config_dcb_pfc,
3291 (void *)&cmd_config_dcb_pfc_en,
3296 /* *** configure number of packets per burst *** */
3297 struct cmd_config_burst {
3298 cmdline_fixed_string_t port;
3299 cmdline_fixed_string_t keyword;
3300 cmdline_fixed_string_t all;
3301 cmdline_fixed_string_t name;
3306 cmd_config_burst_parsed(void *parsed_result,
3307 __rte_unused struct cmdline *cl,
3308 __rte_unused void *data)
3310 struct cmd_config_burst *res = parsed_result;
3311 struct rte_eth_dev_info dev_info;
3312 uint16_t rec_nb_pkts;
3315 if (!all_ports_stopped()) {
3316 printf("Please stop all ports first\n");
3320 if (!strcmp(res->name, "burst")) {
3321 if (res->value == 0) {
3322 /* If user gives a value of zero, query the PMD for
3323 * its recommended Rx burst size. Testpmd uses a single
3324 * size for all ports, so assume all ports are the same
3325 * NIC model and use the values from Port 0.
3327 ret = eth_dev_info_get_print_err(0, &dev_info);
3331 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3333 if (rec_nb_pkts == 0) {
3334 printf("PMD does not recommend a burst size.\n"
3335 "User provided value must be between"
3336 " 1 and %d\n", MAX_PKT_BURST);
3338 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3339 printf("PMD recommended burst size of %d"
3340 " exceeds maximum value of %d\n",
3341 rec_nb_pkts, MAX_PKT_BURST);
3344 printf("Using PMD-provided burst value of %d\n",
3346 nb_pkt_per_burst = rec_nb_pkts;
3347 } else if (res->value > MAX_PKT_BURST) {
3348 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3351 nb_pkt_per_burst = res->value;
3353 printf("Unknown parameter\n");
3359 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3362 cmdline_parse_token_string_t cmd_config_burst_port =
3363 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3364 cmdline_parse_token_string_t cmd_config_burst_keyword =
3365 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3366 cmdline_parse_token_string_t cmd_config_burst_all =
3367 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3368 cmdline_parse_token_string_t cmd_config_burst_name =
3369 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3370 cmdline_parse_token_num_t cmd_config_burst_value =
3371 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3373 cmdline_parse_inst_t cmd_config_burst = {
3374 .f = cmd_config_burst_parsed,
3376 .help_str = "port config all burst <value>",
3378 (void *)&cmd_config_burst_port,
3379 (void *)&cmd_config_burst_keyword,
3380 (void *)&cmd_config_burst_all,
3381 (void *)&cmd_config_burst_name,
3382 (void *)&cmd_config_burst_value,
3387 /* *** configure rx/tx queues *** */
3388 struct cmd_config_thresh {
3389 cmdline_fixed_string_t port;
3390 cmdline_fixed_string_t keyword;
3391 cmdline_fixed_string_t all;
3392 cmdline_fixed_string_t name;
3397 cmd_config_thresh_parsed(void *parsed_result,
3398 __rte_unused struct cmdline *cl,
3399 __rte_unused void *data)
3401 struct cmd_config_thresh *res = parsed_result;
3403 if (!all_ports_stopped()) {
3404 printf("Please stop all ports first\n");
3408 if (!strcmp(res->name, "txpt"))
3409 tx_pthresh = res->value;
3410 else if(!strcmp(res->name, "txht"))
3411 tx_hthresh = res->value;
3412 else if(!strcmp(res->name, "txwt"))
3413 tx_wthresh = res->value;
3414 else if(!strcmp(res->name, "rxpt"))
3415 rx_pthresh = res->value;
3416 else if(!strcmp(res->name, "rxht"))
3417 rx_hthresh = res->value;
3418 else if(!strcmp(res->name, "rxwt"))
3419 rx_wthresh = res->value;
3421 printf("Unknown parameter\n");
3427 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3430 cmdline_parse_token_string_t cmd_config_thresh_port =
3431 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3432 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3433 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3434 cmdline_parse_token_string_t cmd_config_thresh_all =
3435 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3436 cmdline_parse_token_string_t cmd_config_thresh_name =
3437 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3438 "txpt#txht#txwt#rxpt#rxht#rxwt");
3439 cmdline_parse_token_num_t cmd_config_thresh_value =
3440 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3442 cmdline_parse_inst_t cmd_config_thresh = {
3443 .f = cmd_config_thresh_parsed,
3445 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3447 (void *)&cmd_config_thresh_port,
3448 (void *)&cmd_config_thresh_keyword,
3449 (void *)&cmd_config_thresh_all,
3450 (void *)&cmd_config_thresh_name,
3451 (void *)&cmd_config_thresh_value,
3456 /* *** configure free/rs threshold *** */
3457 struct cmd_config_threshold {
3458 cmdline_fixed_string_t port;
3459 cmdline_fixed_string_t keyword;
3460 cmdline_fixed_string_t all;
3461 cmdline_fixed_string_t name;
3466 cmd_config_threshold_parsed(void *parsed_result,
3467 __rte_unused struct cmdline *cl,
3468 __rte_unused void *data)
3470 struct cmd_config_threshold *res = parsed_result;
3472 if (!all_ports_stopped()) {
3473 printf("Please stop all ports first\n");
3477 if (!strcmp(res->name, "txfreet"))
3478 tx_free_thresh = res->value;
3479 else if (!strcmp(res->name, "txrst"))
3480 tx_rs_thresh = res->value;
3481 else if (!strcmp(res->name, "rxfreet"))
3482 rx_free_thresh = res->value;
3484 printf("Unknown parameter\n");
3490 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3493 cmdline_parse_token_string_t cmd_config_threshold_port =
3494 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3495 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3496 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3498 cmdline_parse_token_string_t cmd_config_threshold_all =
3499 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3500 cmdline_parse_token_string_t cmd_config_threshold_name =
3501 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3502 "txfreet#txrst#rxfreet");
3503 cmdline_parse_token_num_t cmd_config_threshold_value =
3504 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3506 cmdline_parse_inst_t cmd_config_threshold = {
3507 .f = cmd_config_threshold_parsed,
3509 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3511 (void *)&cmd_config_threshold_port,
3512 (void *)&cmd_config_threshold_keyword,
3513 (void *)&cmd_config_threshold_all,
3514 (void *)&cmd_config_threshold_name,
3515 (void *)&cmd_config_threshold_value,
3521 struct cmd_stop_result {
3522 cmdline_fixed_string_t stop;
3525 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3526 __rte_unused struct cmdline *cl,
3527 __rte_unused void *data)
3529 stop_packet_forwarding();
3532 cmdline_parse_token_string_t cmd_stop_stop =
3533 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3535 cmdline_parse_inst_t cmd_stop = {
3536 .f = cmd_stop_parsed,
3538 .help_str = "stop: Stop packet forwarding",
3540 (void *)&cmd_stop_stop,
3545 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3548 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3549 unsigned int *parsed_items, int check_unique_values)
3551 unsigned int nb_item;
3559 * First parse all items in the list and store their value.
3564 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3566 if ((c >= '0') && (c <= '9')) {
3567 value = (unsigned int) (value * 10 + (c - '0'));
3572 printf("character %c is not a decimal digit\n", c);
3576 printf("No valid value before comma\n");
3579 if (nb_item < max_items) {
3580 parsed_items[nb_item] = value;
3586 if (nb_item >= max_items) {
3587 printf("Number of %s = %u > %u (maximum items)\n",
3588 item_name, nb_item + 1, max_items);
3591 parsed_items[nb_item++] = value;
3592 if (! check_unique_values)
3596 * Then, check that all values in the list are differents.
3597 * No optimization here...
3599 for (i = 0; i < nb_item; i++) {
3600 for (j = i + 1; j < nb_item; j++) {
3601 if (parsed_items[j] == parsed_items[i]) {
3602 printf("duplicated %s %u at index %u and %u\n",
3603 item_name, parsed_items[i], i, j);
3611 struct cmd_set_list_result {
3612 cmdline_fixed_string_t cmd_keyword;
3613 cmdline_fixed_string_t list_name;
3614 cmdline_fixed_string_t list_of_items;
3617 static void cmd_set_list_parsed(void *parsed_result,
3618 __rte_unused struct cmdline *cl,
3619 __rte_unused void *data)
3621 struct cmd_set_list_result *res;
3623 unsigned int lcorelist[RTE_MAX_LCORE];
3624 unsigned int portlist[RTE_MAX_ETHPORTS];
3626 unsigned int nb_item;
3628 if (test_done == 0) {
3629 printf("Please stop forwarding first\n");
3633 res = parsed_result;
3634 if (!strcmp(res->list_name, "corelist")) {
3635 nb_item = parse_item_list(res->list_of_items, "core",
3637 parsed_items.lcorelist, 1);
3639 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3644 if (!strcmp(res->list_name, "portlist")) {
3645 nb_item = parse_item_list(res->list_of_items, "port",
3647 parsed_items.portlist, 1);
3649 set_fwd_ports_list(parsed_items.portlist, nb_item);
3655 cmdline_parse_token_string_t cmd_set_list_keyword =
3656 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3658 cmdline_parse_token_string_t cmd_set_list_name =
3659 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3660 "corelist#portlist");
3661 cmdline_parse_token_string_t cmd_set_list_of_items =
3662 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3665 cmdline_parse_inst_t cmd_set_fwd_list = {
3666 .f = cmd_set_list_parsed,
3668 .help_str = "set corelist|portlist <list0[,list1]*>",
3670 (void *)&cmd_set_list_keyword,
3671 (void *)&cmd_set_list_name,
3672 (void *)&cmd_set_list_of_items,
3677 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3679 struct cmd_setmask_result {
3680 cmdline_fixed_string_t set;
3681 cmdline_fixed_string_t mask;
3685 static void cmd_set_mask_parsed(void *parsed_result,
3686 __rte_unused struct cmdline *cl,
3687 __rte_unused void *data)
3689 struct cmd_setmask_result *res = parsed_result;
3691 if (test_done == 0) {
3692 printf("Please stop forwarding first\n");
3695 if (!strcmp(res->mask, "coremask")) {
3696 set_fwd_lcores_mask(res->hexavalue);
3698 } else if (!strcmp(res->mask, "portmask")) {
3699 set_fwd_ports_mask(res->hexavalue);
3704 cmdline_parse_token_string_t cmd_setmask_set =
3705 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3706 cmdline_parse_token_string_t cmd_setmask_mask =
3707 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3708 "coremask#portmask");
3709 cmdline_parse_token_num_t cmd_setmask_value =
3710 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3712 cmdline_parse_inst_t cmd_set_fwd_mask = {
3713 .f = cmd_set_mask_parsed,
3715 .help_str = "set coremask|portmask <hexadecimal value>",
3717 (void *)&cmd_setmask_set,
3718 (void *)&cmd_setmask_mask,
3719 (void *)&cmd_setmask_value,
3725 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3727 struct cmd_set_result {
3728 cmdline_fixed_string_t set;
3729 cmdline_fixed_string_t what;
3733 static void cmd_set_parsed(void *parsed_result,
3734 __rte_unused struct cmdline *cl,
3735 __rte_unused void *data)
3737 struct cmd_set_result *res = parsed_result;
3738 if (!strcmp(res->what, "nbport")) {
3739 set_fwd_ports_number(res->value);
3741 } else if (!strcmp(res->what, "nbcore")) {
3742 set_fwd_lcores_number(res->value);
3744 } else if (!strcmp(res->what, "burst"))
3745 set_nb_pkt_per_burst(res->value);
3746 else if (!strcmp(res->what, "verbose"))
3747 set_verbose_level(res->value);
3750 cmdline_parse_token_string_t cmd_set_set =
3751 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3752 cmdline_parse_token_string_t cmd_set_what =
3753 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3754 "nbport#nbcore#burst#verbose");
3755 cmdline_parse_token_num_t cmd_set_value =
3756 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3758 cmdline_parse_inst_t cmd_set_numbers = {
3759 .f = cmd_set_parsed,
3761 .help_str = "set nbport|nbcore|burst|verbose <value>",
3763 (void *)&cmd_set_set,
3764 (void *)&cmd_set_what,
3765 (void *)&cmd_set_value,
3770 /* *** SET LOG LEVEL CONFIGURATION *** */
3772 struct cmd_set_log_result {
3773 cmdline_fixed_string_t set;
3774 cmdline_fixed_string_t log;
3775 cmdline_fixed_string_t type;
3780 cmd_set_log_parsed(void *parsed_result,
3781 __rte_unused struct cmdline *cl,
3782 __rte_unused void *data)
3784 struct cmd_set_log_result *res;
3787 res = parsed_result;
3788 if (!strcmp(res->type, "global"))
3789 rte_log_set_global_level(res->level);
3791 ret = rte_log_set_level_regexp(res->type, res->level);
3793 printf("Unable to set log level\n");
3797 cmdline_parse_token_string_t cmd_set_log_set =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3799 cmdline_parse_token_string_t cmd_set_log_log =
3800 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3801 cmdline_parse_token_string_t cmd_set_log_type =
3802 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3803 cmdline_parse_token_num_t cmd_set_log_level =
3804 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3806 cmdline_parse_inst_t cmd_set_log = {
3807 .f = cmd_set_log_parsed,
3809 .help_str = "set log global|<type> <level>",
3811 (void *)&cmd_set_log_set,
3812 (void *)&cmd_set_log_log,
3813 (void *)&cmd_set_log_type,
3814 (void *)&cmd_set_log_level,
3819 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3821 struct cmd_set_txpkts_result {
3822 cmdline_fixed_string_t cmd_keyword;
3823 cmdline_fixed_string_t txpkts;
3824 cmdline_fixed_string_t seg_lengths;
3828 cmd_set_txpkts_parsed(void *parsed_result,
3829 __rte_unused struct cmdline *cl,
3830 __rte_unused void *data)
3832 struct cmd_set_txpkts_result *res;
3833 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3834 unsigned int nb_segs;
3836 res = parsed_result;
3837 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3838 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3840 set_tx_pkt_segments(seg_lengths, nb_segs);
3843 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3844 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3845 cmd_keyword, "set");
3846 cmdline_parse_token_string_t cmd_set_txpkts_name =
3847 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3849 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3850 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3853 cmdline_parse_inst_t cmd_set_txpkts = {
3854 .f = cmd_set_txpkts_parsed,
3856 .help_str = "set txpkts <len0[,len1]*>",
3858 (void *)&cmd_set_txpkts_keyword,
3859 (void *)&cmd_set_txpkts_name,
3860 (void *)&cmd_set_txpkts_lengths,
3865 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3867 struct cmd_set_txsplit_result {
3868 cmdline_fixed_string_t cmd_keyword;
3869 cmdline_fixed_string_t txsplit;
3870 cmdline_fixed_string_t mode;
3874 cmd_set_txsplit_parsed(void *parsed_result,
3875 __rte_unused struct cmdline *cl,
3876 __rte_unused void *data)
3878 struct cmd_set_txsplit_result *res;
3880 res = parsed_result;
3881 set_tx_pkt_split(res->mode);
3884 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3885 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3886 cmd_keyword, "set");
3887 cmdline_parse_token_string_t cmd_set_txsplit_name =
3888 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3889 txsplit, "txsplit");
3890 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3891 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3894 cmdline_parse_inst_t cmd_set_txsplit = {
3895 .f = cmd_set_txsplit_parsed,
3897 .help_str = "set txsplit on|off|rand",
3899 (void *)&cmd_set_txsplit_keyword,
3900 (void *)&cmd_set_txsplit_name,
3901 (void *)&cmd_set_txsplit_mode,
3906 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3907 struct cmd_rx_vlan_filter_all_result {
3908 cmdline_fixed_string_t rx_vlan;
3909 cmdline_fixed_string_t what;
3910 cmdline_fixed_string_t all;
3915 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3916 __rte_unused struct cmdline *cl,
3917 __rte_unused void *data)
3919 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3921 if (!strcmp(res->what, "add"))
3922 rx_vlan_all_filter_set(res->port_id, 1);
3924 rx_vlan_all_filter_set(res->port_id, 0);
3927 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3928 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3929 rx_vlan, "rx_vlan");
3930 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3931 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3933 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3934 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3936 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3937 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3940 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3941 .f = cmd_rx_vlan_filter_all_parsed,
3943 .help_str = "rx_vlan add|rm all <port_id>: "
3944 "Add/Remove all identifiers to/from the set of VLAN "
3945 "identifiers filtered by a port",
3947 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3948 (void *)&cmd_rx_vlan_filter_all_what,
3949 (void *)&cmd_rx_vlan_filter_all_all,
3950 (void *)&cmd_rx_vlan_filter_all_portid,
3955 /* *** VLAN OFFLOAD SET ON A PORT *** */
3956 struct cmd_vlan_offload_result {
3957 cmdline_fixed_string_t vlan;
3958 cmdline_fixed_string_t set;
3959 cmdline_fixed_string_t vlan_type;
3960 cmdline_fixed_string_t what;
3961 cmdline_fixed_string_t on;
3962 cmdline_fixed_string_t port_id;
3966 cmd_vlan_offload_parsed(void *parsed_result,
3967 __rte_unused struct cmdline *cl,
3968 __rte_unused void *data)
3971 struct cmd_vlan_offload_result *res = parsed_result;
3974 portid_t port_id = 0;
3978 len = strnlen(str, STR_TOKEN_SIZE);
3980 /* Get port_id first */
3988 tmp = strtoul(str, NULL, 0);
3989 /* If port_id greater that what portid_t can represent, return */
3990 if(tmp >= RTE_MAX_ETHPORTS)
3992 port_id = (portid_t)tmp;
3994 if (!strcmp(res->on, "on"))
3999 if (!strcmp(res->what, "strip"))
4000 rx_vlan_strip_set(port_id, on);
4001 else if(!strcmp(res->what, "stripq")){
4002 uint16_t queue_id = 0;
4004 /* No queue_id, return */
4006 printf("must specify (port,queue_id)\n");
4009 tmp = strtoul(str + i + 1, NULL, 0);
4010 /* If queue_id greater that what 16-bits can represent, return */
4014 queue_id = (uint16_t)tmp;
4015 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4017 else if (!strcmp(res->what, "filter"))
4018 rx_vlan_filter_set(port_id, on);
4019 else if (!strcmp(res->what, "qinq_strip"))
4020 rx_vlan_qinq_strip_set(port_id, on);
4022 vlan_extend_set(port_id, on);
4027 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4028 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4030 cmdline_parse_token_string_t cmd_vlan_offload_set =
4031 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4033 cmdline_parse_token_string_t cmd_vlan_offload_what =
4034 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4035 what, "strip#filter#qinq_strip#extend#stripq");
4036 cmdline_parse_token_string_t cmd_vlan_offload_on =
4037 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4039 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4040 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4043 cmdline_parse_inst_t cmd_vlan_offload = {
4044 .f = cmd_vlan_offload_parsed,
4046 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4047 "<port_id[,queue_id]>: "
4048 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4050 (void *)&cmd_vlan_offload_vlan,
4051 (void *)&cmd_vlan_offload_set,
4052 (void *)&cmd_vlan_offload_what,
4053 (void *)&cmd_vlan_offload_on,
4054 (void *)&cmd_vlan_offload_portid,
4059 /* *** VLAN TPID SET ON A PORT *** */
4060 struct cmd_vlan_tpid_result {
4061 cmdline_fixed_string_t vlan;
4062 cmdline_fixed_string_t set;
4063 cmdline_fixed_string_t vlan_type;
4064 cmdline_fixed_string_t what;
4070 cmd_vlan_tpid_parsed(void *parsed_result,
4071 __rte_unused struct cmdline *cl,
4072 __rte_unused void *data)
4074 struct cmd_vlan_tpid_result *res = parsed_result;
4075 enum rte_vlan_type vlan_type;
4077 if (!strcmp(res->vlan_type, "inner"))
4078 vlan_type = ETH_VLAN_TYPE_INNER;
4079 else if (!strcmp(res->vlan_type, "outer"))
4080 vlan_type = ETH_VLAN_TYPE_OUTER;
4082 printf("Unknown vlan type\n");
4085 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4088 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4089 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4091 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4092 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4094 cmdline_parse_token_string_t cmd_vlan_type =
4095 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4096 vlan_type, "inner#outer");
4097 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4098 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4100 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4101 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4103 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4104 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4107 cmdline_parse_inst_t cmd_vlan_tpid = {
4108 .f = cmd_vlan_tpid_parsed,
4110 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4111 "Set the VLAN Ether type",
4113 (void *)&cmd_vlan_tpid_vlan,
4114 (void *)&cmd_vlan_tpid_set,
4115 (void *)&cmd_vlan_type,
4116 (void *)&cmd_vlan_tpid_what,
4117 (void *)&cmd_vlan_tpid_tpid,
4118 (void *)&cmd_vlan_tpid_portid,
4123 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4124 struct cmd_rx_vlan_filter_result {
4125 cmdline_fixed_string_t rx_vlan;
4126 cmdline_fixed_string_t what;
4132 cmd_rx_vlan_filter_parsed(void *parsed_result,
4133 __rte_unused struct cmdline *cl,
4134 __rte_unused void *data)
4136 struct cmd_rx_vlan_filter_result *res = parsed_result;
4138 if (!strcmp(res->what, "add"))
4139 rx_vft_set(res->port_id, res->vlan_id, 1);
4141 rx_vft_set(res->port_id, res->vlan_id, 0);
4144 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4145 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4146 rx_vlan, "rx_vlan");
4147 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4148 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4150 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4151 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4153 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4154 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4157 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4158 .f = cmd_rx_vlan_filter_parsed,
4160 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4161 "Add/Remove a VLAN identifier to/from the set of VLAN "
4162 "identifiers filtered by a port",
4164 (void *)&cmd_rx_vlan_filter_rx_vlan,
4165 (void *)&cmd_rx_vlan_filter_what,
4166 (void *)&cmd_rx_vlan_filter_vlanid,
4167 (void *)&cmd_rx_vlan_filter_portid,
4172 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4173 struct cmd_tx_vlan_set_result {
4174 cmdline_fixed_string_t tx_vlan;
4175 cmdline_fixed_string_t set;
4181 cmd_tx_vlan_set_parsed(void *parsed_result,
4182 __rte_unused struct cmdline *cl,
4183 __rte_unused void *data)
4185 struct cmd_tx_vlan_set_result *res = parsed_result;
4187 if (!port_is_stopped(res->port_id)) {
4188 printf("Please stop port %d first\n", res->port_id);
4192 tx_vlan_set(res->port_id, res->vlan_id);
4194 cmd_reconfig_device_queue(res->port_id, 1, 1);
4197 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4198 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4199 tx_vlan, "tx_vlan");
4200 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4201 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4203 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4204 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4206 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4207 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4210 cmdline_parse_inst_t cmd_tx_vlan_set = {
4211 .f = cmd_tx_vlan_set_parsed,
4213 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4214 "Enable hardware insertion of a single VLAN header "
4215 "with a given TAG Identifier in packets sent on a port",
4217 (void *)&cmd_tx_vlan_set_tx_vlan,
4218 (void *)&cmd_tx_vlan_set_set,
4219 (void *)&cmd_tx_vlan_set_portid,
4220 (void *)&cmd_tx_vlan_set_vlanid,
4225 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4226 struct cmd_tx_vlan_set_qinq_result {
4227 cmdline_fixed_string_t tx_vlan;
4228 cmdline_fixed_string_t set;
4231 uint16_t vlan_id_outer;
4235 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4236 __rte_unused struct cmdline *cl,
4237 __rte_unused void *data)
4239 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4241 if (!port_is_stopped(res->port_id)) {
4242 printf("Please stop port %d first\n", res->port_id);
4246 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4248 cmd_reconfig_device_queue(res->port_id, 1, 1);
4251 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4252 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4253 tx_vlan, "tx_vlan");
4254 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4255 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4257 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4258 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4260 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4261 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4263 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4264 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4265 vlan_id_outer, UINT16);
4267 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4268 .f = cmd_tx_vlan_set_qinq_parsed,
4270 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4271 "Enable hardware insertion of double VLAN header "
4272 "with given TAG Identifiers in packets sent on a port",
4274 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4275 (void *)&cmd_tx_vlan_set_qinq_set,
4276 (void *)&cmd_tx_vlan_set_qinq_portid,
4277 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4278 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4283 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4284 struct cmd_tx_vlan_set_pvid_result {
4285 cmdline_fixed_string_t tx_vlan;
4286 cmdline_fixed_string_t set;
4287 cmdline_fixed_string_t pvid;
4290 cmdline_fixed_string_t mode;
4294 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4295 __rte_unused struct cmdline *cl,
4296 __rte_unused void *data)
4298 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4300 if (strcmp(res->mode, "on") == 0)
4301 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4303 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4306 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4307 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4308 tx_vlan, "tx_vlan");
4309 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4310 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4312 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4313 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4315 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4316 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4318 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4319 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4321 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4322 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4325 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4326 .f = cmd_tx_vlan_set_pvid_parsed,
4328 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4330 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4331 (void *)&cmd_tx_vlan_set_pvid_set,
4332 (void *)&cmd_tx_vlan_set_pvid_pvid,
4333 (void *)&cmd_tx_vlan_set_pvid_port_id,
4334 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4335 (void *)&cmd_tx_vlan_set_pvid_mode,
4340 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4341 struct cmd_tx_vlan_reset_result {
4342 cmdline_fixed_string_t tx_vlan;
4343 cmdline_fixed_string_t reset;
4348 cmd_tx_vlan_reset_parsed(void *parsed_result,
4349 __rte_unused struct cmdline *cl,
4350 __rte_unused void *data)
4352 struct cmd_tx_vlan_reset_result *res = parsed_result;
4354 if (!port_is_stopped(res->port_id)) {
4355 printf("Please stop port %d first\n", res->port_id);
4359 tx_vlan_reset(res->port_id);
4361 cmd_reconfig_device_queue(res->port_id, 1, 1);
4364 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4365 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4366 tx_vlan, "tx_vlan");
4367 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4368 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4370 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4371 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4374 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4375 .f = cmd_tx_vlan_reset_parsed,
4377 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4378 "VLAN header in packets sent on a port",
4380 (void *)&cmd_tx_vlan_reset_tx_vlan,
4381 (void *)&cmd_tx_vlan_reset_reset,
4382 (void *)&cmd_tx_vlan_reset_portid,
4388 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4389 struct cmd_csum_result {
4390 cmdline_fixed_string_t csum;
4391 cmdline_fixed_string_t mode;
4392 cmdline_fixed_string_t proto;
4393 cmdline_fixed_string_t hwsw;
4398 csum_show(int port_id)
4400 struct rte_eth_dev_info dev_info;
4401 uint64_t tx_offloads;
4404 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4405 printf("Parse tunnel is %s\n",
4406 (ports[port_id].parse_tunnel) ? "on" : "off");
4407 printf("IP checksum offload is %s\n",
4408 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4409 printf("UDP checksum offload is %s\n",
4410 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4411 printf("TCP checksum offload is %s\n",
4412 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4413 printf("SCTP checksum offload is %s\n",
4414 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4415 printf("Outer-Ip checksum offload is %s\n",
4416 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4417 printf("Outer-Udp checksum offload is %s\n",
4418 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4420 /* display warnings if configuration is not supported by the NIC */
4421 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4425 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4426 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4427 printf("Warning: hardware IP checksum enabled but not "
4428 "supported by port %d\n", port_id);
4430 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4431 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4432 printf("Warning: hardware UDP checksum enabled but not "
4433 "supported by port %d\n", port_id);
4435 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4436 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4437 printf("Warning: hardware TCP checksum enabled but not "
4438 "supported by port %d\n", port_id);
4440 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4441 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4442 printf("Warning: hardware SCTP checksum enabled but not "
4443 "supported by port %d\n", port_id);
4445 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4446 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4447 printf("Warning: hardware outer IP checksum enabled but not "
4448 "supported by port %d\n", port_id);
4450 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4451 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4453 printf("Warning: hardware outer UDP checksum enabled but not "
4454 "supported by port %d\n", port_id);
4459 cmd_config_queue_tx_offloads(struct rte_port *port)
4463 /* Apply queue tx offloads configuration */
4464 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4465 port->tx_conf[k].offloads =
4466 port->dev_conf.txmode.offloads;
4470 cmd_csum_parsed(void *parsed_result,
4471 __rte_unused struct cmdline *cl,
4472 __rte_unused void *data)
4474 struct cmd_csum_result *res = parsed_result;
4476 uint64_t csum_offloads = 0;
4477 struct rte_eth_dev_info dev_info;
4480 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4481 printf("invalid port %d\n", res->port_id);
4484 if (!port_is_stopped(res->port_id)) {
4485 printf("Please stop port %d first\n", res->port_id);
4489 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4493 if (!strcmp(res->mode, "set")) {
4495 if (!strcmp(res->hwsw, "hw"))
4498 if (!strcmp(res->proto, "ip")) {
4499 if (hw == 0 || (dev_info.tx_offload_capa &
4500 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4501 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4503 printf("IP checksum offload is not supported "
4504 "by port %u\n", res->port_id);
4506 } else if (!strcmp(res->proto, "udp")) {
4507 if (hw == 0 || (dev_info.tx_offload_capa &
4508 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4509 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4511 printf("UDP checksum offload is not supported "
4512 "by port %u\n", res->port_id);
4514 } else if (!strcmp(res->proto, "tcp")) {
4515 if (hw == 0 || (dev_info.tx_offload_capa &
4516 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4517 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4519 printf("TCP checksum offload is not supported "
4520 "by port %u\n", res->port_id);
4522 } else if (!strcmp(res->proto, "sctp")) {
4523 if (hw == 0 || (dev_info.tx_offload_capa &
4524 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4525 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4527 printf("SCTP checksum offload is not supported "
4528 "by port %u\n", res->port_id);
4530 } else if (!strcmp(res->proto, "outer-ip")) {
4531 if (hw == 0 || (dev_info.tx_offload_capa &
4532 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4534 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4536 printf("Outer IP checksum offload is not "
4537 "supported by port %u\n", res->port_id);
4539 } else if (!strcmp(res->proto, "outer-udp")) {
4540 if (hw == 0 || (dev_info.tx_offload_capa &
4541 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4543 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4545 printf("Outer UDP checksum offload is not "
4546 "supported by port %u\n", res->port_id);
4551 ports[res->port_id].dev_conf.txmode.offloads |=
4554 ports[res->port_id].dev_conf.txmode.offloads &=
4557 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4559 csum_show(res->port_id);
4561 cmd_reconfig_device_queue(res->port_id, 1, 1);
4564 cmdline_parse_token_string_t cmd_csum_csum =
4565 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4567 cmdline_parse_token_string_t cmd_csum_mode =
4568 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4570 cmdline_parse_token_string_t cmd_csum_proto =
4571 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4572 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4573 cmdline_parse_token_string_t cmd_csum_hwsw =
4574 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4576 cmdline_parse_token_num_t cmd_csum_portid =
4577 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4580 cmdline_parse_inst_t cmd_csum_set = {
4581 .f = cmd_csum_parsed,
4583 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4584 "Enable/Disable hardware calculation of L3/L4 checksum when "
4585 "using csum forward engine",
4587 (void *)&cmd_csum_csum,
4588 (void *)&cmd_csum_mode,
4589 (void *)&cmd_csum_proto,
4590 (void *)&cmd_csum_hwsw,
4591 (void *)&cmd_csum_portid,
4596 cmdline_parse_token_string_t cmd_csum_mode_show =
4597 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4600 cmdline_parse_inst_t cmd_csum_show = {
4601 .f = cmd_csum_parsed,
4603 .help_str = "csum show <port_id>: Show checksum offload configuration",
4605 (void *)&cmd_csum_csum,
4606 (void *)&cmd_csum_mode_show,
4607 (void *)&cmd_csum_portid,
4612 /* Enable/disable tunnel parsing */
4613 struct cmd_csum_tunnel_result {
4614 cmdline_fixed_string_t csum;
4615 cmdline_fixed_string_t parse;
4616 cmdline_fixed_string_t onoff;
4621 cmd_csum_tunnel_parsed(void *parsed_result,
4622 __rte_unused struct cmdline *cl,
4623 __rte_unused void *data)
4625 struct cmd_csum_tunnel_result *res = parsed_result;
4627 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4630 if (!strcmp(res->onoff, "on"))
4631 ports[res->port_id].parse_tunnel = 1;
4633 ports[res->port_id].parse_tunnel = 0;
4635 csum_show(res->port_id);
4638 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4639 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4641 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4642 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4643 parse, "parse-tunnel");
4644 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4645 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4647 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4648 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4651 cmdline_parse_inst_t cmd_csum_tunnel = {
4652 .f = cmd_csum_tunnel_parsed,
4654 .help_str = "csum parse-tunnel on|off <port_id>: "
4655 "Enable/Disable parsing of tunnels for csum engine",
4657 (void *)&cmd_csum_tunnel_csum,
4658 (void *)&cmd_csum_tunnel_parse,
4659 (void *)&cmd_csum_tunnel_onoff,
4660 (void *)&cmd_csum_tunnel_portid,
4665 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4666 struct cmd_tso_set_result {
4667 cmdline_fixed_string_t tso;
4668 cmdline_fixed_string_t mode;
4674 cmd_tso_set_parsed(void *parsed_result,
4675 __rte_unused struct cmdline *cl,
4676 __rte_unused void *data)
4678 struct cmd_tso_set_result *res = parsed_result;
4679 struct rte_eth_dev_info dev_info;
4682 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4684 if (!port_is_stopped(res->port_id)) {
4685 printf("Please stop port %d first\n", res->port_id);
4689 if (!strcmp(res->mode, "set"))
4690 ports[res->port_id].tso_segsz = res->tso_segsz;
4692 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4696 if ((ports[res->port_id].tso_segsz != 0) &&
4697 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4698 printf("Error: TSO is not supported by port %d\n",
4703 if (ports[res->port_id].tso_segsz == 0) {
4704 ports[res->port_id].dev_conf.txmode.offloads &=
4705 ~DEV_TX_OFFLOAD_TCP_TSO;
4706 printf("TSO for non-tunneled packets is disabled\n");
4708 ports[res->port_id].dev_conf.txmode.offloads |=
4709 DEV_TX_OFFLOAD_TCP_TSO;
4710 printf("TSO segment size for non-tunneled packets is %d\n",
4711 ports[res->port_id].tso_segsz);
4713 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4715 /* display warnings if configuration is not supported by the NIC */
4716 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4720 if ((ports[res->port_id].tso_segsz != 0) &&
4721 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4722 printf("Warning: TSO enabled but not "
4723 "supported by port %d\n", res->port_id);
4726 cmd_reconfig_device_queue(res->port_id, 1, 1);
4729 cmdline_parse_token_string_t cmd_tso_set_tso =
4730 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4732 cmdline_parse_token_string_t cmd_tso_set_mode =
4733 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4735 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4736 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4738 cmdline_parse_token_num_t cmd_tso_set_portid =
4739 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4742 cmdline_parse_inst_t cmd_tso_set = {
4743 .f = cmd_tso_set_parsed,
4745 .help_str = "tso set <tso_segsz> <port_id>: "
4746 "Set TSO segment size of non-tunneled packets for csum engine "
4749 (void *)&cmd_tso_set_tso,
4750 (void *)&cmd_tso_set_mode,
4751 (void *)&cmd_tso_set_tso_segsz,
4752 (void *)&cmd_tso_set_portid,
4757 cmdline_parse_token_string_t cmd_tso_show_mode =
4758 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4762 cmdline_parse_inst_t cmd_tso_show = {
4763 .f = cmd_tso_set_parsed,
4765 .help_str = "tso show <port_id>: "
4766 "Show TSO segment size of non-tunneled packets for csum engine",
4768 (void *)&cmd_tso_set_tso,
4769 (void *)&cmd_tso_show_mode,
4770 (void *)&cmd_tso_set_portid,
4775 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4776 struct cmd_tunnel_tso_set_result {
4777 cmdline_fixed_string_t tso;
4778 cmdline_fixed_string_t mode;
4783 static struct rte_eth_dev_info
4784 check_tunnel_tso_nic_support(portid_t port_id)
4786 struct rte_eth_dev_info dev_info;
4788 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4791 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4792 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4793 "not enabled for port %d\n", port_id);
4794 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4795 printf("Warning: GRE TUNNEL TSO not supported therefore "
4796 "not enabled for port %d\n", port_id);
4797 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4798 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4799 "not enabled for port %d\n", port_id);
4800 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4801 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4802 "not enabled for port %d\n", port_id);
4803 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4804 printf("Warning: IP TUNNEL TSO not supported therefore "
4805 "not enabled for port %d\n", port_id);
4806 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4807 printf("Warning: UDP TUNNEL TSO not supported therefore "
4808 "not enabled for port %d\n", port_id);
4813 cmd_tunnel_tso_set_parsed(void *parsed_result,
4814 __rte_unused struct cmdline *cl,
4815 __rte_unused void *data)
4817 struct cmd_tunnel_tso_set_result *res = parsed_result;
4818 struct rte_eth_dev_info dev_info;
4820 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4822 if (!port_is_stopped(res->port_id)) {
4823 printf("Please stop port %d first\n", res->port_id);
4827 if (!strcmp(res->mode, "set"))
4828 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4830 dev_info = check_tunnel_tso_nic_support(res->port_id);
4831 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4832 ports[res->port_id].dev_conf.txmode.offloads &=
4833 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4834 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4835 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4836 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4837 DEV_TX_OFFLOAD_IP_TNL_TSO |
4838 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4839 printf("TSO for tunneled packets is disabled\n");
4841 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4842 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4843 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4844 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4845 DEV_TX_OFFLOAD_IP_TNL_TSO |
4846 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4848 ports[res->port_id].dev_conf.txmode.offloads |=
4849 (tso_offloads & dev_info.tx_offload_capa);
4850 printf("TSO segment size for tunneled packets is %d\n",
4851 ports[res->port_id].tunnel_tso_segsz);
4853 /* Below conditions are needed to make it work:
4854 * (1) tunnel TSO is supported by the NIC;
4855 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4857 * (3) for tunneled pkts with outer L3 of IPv4,
4858 * "csum set outer-ip" must be set to hw, because after tso,
4859 * total_len of outer IP header is changed, and the checksum
4860 * of outer IP header calculated by sw should be wrong; that
4861 * is not necessary for IPv6 tunneled pkts because there's no
4862 * checksum in IP header anymore.
4865 if (!ports[res->port_id].parse_tunnel)
4866 printf("Warning: csum parse_tunnel must be set "
4867 "so that tunneled packets are recognized\n");
4868 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4869 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4870 printf("Warning: csum set outer-ip must be set to hw "
4871 "if outer L3 is IPv4; not necessary for IPv6\n");
4874 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4875 cmd_reconfig_device_queue(res->port_id, 1, 1);
4878 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4879 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4881 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4882 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4884 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4885 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4887 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4888 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4891 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4892 .f = cmd_tunnel_tso_set_parsed,
4894 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4895 "Set TSO segment size of tunneled packets for csum engine "
4898 (void *)&cmd_tunnel_tso_set_tso,
4899 (void *)&cmd_tunnel_tso_set_mode,
4900 (void *)&cmd_tunnel_tso_set_tso_segsz,
4901 (void *)&cmd_tunnel_tso_set_portid,
4906 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4907 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4911 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4912 .f = cmd_tunnel_tso_set_parsed,
4914 .help_str = "tunnel_tso show <port_id> "
4915 "Show TSO segment size of tunneled packets for csum engine",
4917 (void *)&cmd_tunnel_tso_set_tso,
4918 (void *)&cmd_tunnel_tso_show_mode,
4919 (void *)&cmd_tunnel_tso_set_portid,
4924 /* *** SET GRO FOR A PORT *** */
4925 struct cmd_gro_enable_result {
4926 cmdline_fixed_string_t cmd_set;
4927 cmdline_fixed_string_t cmd_port;
4928 cmdline_fixed_string_t cmd_keyword;
4929 cmdline_fixed_string_t cmd_onoff;
4934 cmd_gro_enable_parsed(void *parsed_result,
4935 __rte_unused struct cmdline *cl,
4936 __rte_unused void *data)
4938 struct cmd_gro_enable_result *res;
4940 res = parsed_result;
4941 if (!strcmp(res->cmd_keyword, "gro"))
4942 setup_gro(res->cmd_onoff, res->cmd_pid);
4945 cmdline_parse_token_string_t cmd_gro_enable_set =
4946 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4948 cmdline_parse_token_string_t cmd_gro_enable_port =
4949 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4950 cmd_keyword, "port");
4951 cmdline_parse_token_num_t cmd_gro_enable_pid =
4952 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4954 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4955 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4956 cmd_keyword, "gro");
4957 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4958 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4959 cmd_onoff, "on#off");
4961 cmdline_parse_inst_t cmd_gro_enable = {
4962 .f = cmd_gro_enable_parsed,
4964 .help_str = "set port <port_id> gro on|off",
4966 (void *)&cmd_gro_enable_set,
4967 (void *)&cmd_gro_enable_port,
4968 (void *)&cmd_gro_enable_pid,
4969 (void *)&cmd_gro_enable_keyword,
4970 (void *)&cmd_gro_enable_onoff,
4975 /* *** DISPLAY GRO CONFIGURATION *** */
4976 struct cmd_gro_show_result {
4977 cmdline_fixed_string_t cmd_show;
4978 cmdline_fixed_string_t cmd_port;
4979 cmdline_fixed_string_t cmd_keyword;
4984 cmd_gro_show_parsed(void *parsed_result,
4985 __rte_unused struct cmdline *cl,
4986 __rte_unused void *data)
4988 struct cmd_gro_show_result *res;
4990 res = parsed_result;
4991 if (!strcmp(res->cmd_keyword, "gro"))
4992 show_gro(res->cmd_pid);
4995 cmdline_parse_token_string_t cmd_gro_show_show =
4996 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4998 cmdline_parse_token_string_t cmd_gro_show_port =
4999 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5001 cmdline_parse_token_num_t cmd_gro_show_pid =
5002 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5004 cmdline_parse_token_string_t cmd_gro_show_keyword =
5005 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5006 cmd_keyword, "gro");
5008 cmdline_parse_inst_t cmd_gro_show = {
5009 .f = cmd_gro_show_parsed,
5011 .help_str = "show port <port_id> gro",
5013 (void *)&cmd_gro_show_show,
5014 (void *)&cmd_gro_show_port,
5015 (void *)&cmd_gro_show_pid,
5016 (void *)&cmd_gro_show_keyword,
5021 /* *** SET FLUSH CYCLES FOR GRO *** */
5022 struct cmd_gro_flush_result {
5023 cmdline_fixed_string_t cmd_set;
5024 cmdline_fixed_string_t cmd_keyword;
5025 cmdline_fixed_string_t cmd_flush;
5030 cmd_gro_flush_parsed(void *parsed_result,
5031 __rte_unused struct cmdline *cl,
5032 __rte_unused void *data)
5034 struct cmd_gro_flush_result *res;
5036 res = parsed_result;
5037 if ((!strcmp(res->cmd_keyword, "gro")) &&
5038 (!strcmp(res->cmd_flush, "flush")))
5039 setup_gro_flush_cycles(res->cmd_cycles);
5042 cmdline_parse_token_string_t cmd_gro_flush_set =
5043 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5045 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5046 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5047 cmd_keyword, "gro");
5048 cmdline_parse_token_string_t cmd_gro_flush_flush =
5049 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5050 cmd_flush, "flush");
5051 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5052 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5055 cmdline_parse_inst_t cmd_gro_flush = {
5056 .f = cmd_gro_flush_parsed,
5058 .help_str = "set gro flush <cycles>",
5060 (void *)&cmd_gro_flush_set,
5061 (void *)&cmd_gro_flush_keyword,
5062 (void *)&cmd_gro_flush_flush,
5063 (void *)&cmd_gro_flush_cycles,
5068 /* *** ENABLE/DISABLE GSO *** */
5069 struct cmd_gso_enable_result {
5070 cmdline_fixed_string_t cmd_set;
5071 cmdline_fixed_string_t cmd_port;
5072 cmdline_fixed_string_t cmd_keyword;
5073 cmdline_fixed_string_t cmd_mode;
5078 cmd_gso_enable_parsed(void *parsed_result,
5079 __rte_unused struct cmdline *cl,
5080 __rte_unused void *data)
5082 struct cmd_gso_enable_result *res;
5084 res = parsed_result;
5085 if (!strcmp(res->cmd_keyword, "gso"))
5086 setup_gso(res->cmd_mode, res->cmd_pid);
5089 cmdline_parse_token_string_t cmd_gso_enable_set =
5090 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5092 cmdline_parse_token_string_t cmd_gso_enable_port =
5093 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5095 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5096 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5097 cmd_keyword, "gso");
5098 cmdline_parse_token_string_t cmd_gso_enable_mode =
5099 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5100 cmd_mode, "on#off");
5101 cmdline_parse_token_num_t cmd_gso_enable_pid =
5102 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5105 cmdline_parse_inst_t cmd_gso_enable = {
5106 .f = cmd_gso_enable_parsed,
5108 .help_str = "set port <port_id> gso on|off",
5110 (void *)&cmd_gso_enable_set,
5111 (void *)&cmd_gso_enable_port,
5112 (void *)&cmd_gso_enable_pid,
5113 (void *)&cmd_gso_enable_keyword,
5114 (void *)&cmd_gso_enable_mode,
5119 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5120 struct cmd_gso_size_result {
5121 cmdline_fixed_string_t cmd_set;
5122 cmdline_fixed_string_t cmd_keyword;
5123 cmdline_fixed_string_t cmd_segsz;
5128 cmd_gso_size_parsed(void *parsed_result,
5129 __rte_unused struct cmdline *cl,
5130 __rte_unused void *data)
5132 struct cmd_gso_size_result *res = parsed_result;
5134 if (test_done == 0) {
5135 printf("Before setting GSO segsz, please first"
5136 " stop fowarding\n");
5140 if (!strcmp(res->cmd_keyword, "gso") &&
5141 !strcmp(res->cmd_segsz, "segsz")) {
5142 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5143 printf("gso_size should be larger than %zu."
5144 " Please input a legal value\n",
5145 RTE_GSO_SEG_SIZE_MIN);
5147 gso_max_segment_size = res->cmd_size;
5151 cmdline_parse_token_string_t cmd_gso_size_set =
5152 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5154 cmdline_parse_token_string_t cmd_gso_size_keyword =
5155 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5156 cmd_keyword, "gso");
5157 cmdline_parse_token_string_t cmd_gso_size_segsz =
5158 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5159 cmd_segsz, "segsz");
5160 cmdline_parse_token_num_t cmd_gso_size_size =
5161 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5164 cmdline_parse_inst_t cmd_gso_size = {
5165 .f = cmd_gso_size_parsed,
5167 .help_str = "set gso segsz <length>",
5169 (void *)&cmd_gso_size_set,
5170 (void *)&cmd_gso_size_keyword,
5171 (void *)&cmd_gso_size_segsz,
5172 (void *)&cmd_gso_size_size,
5177 /* *** SHOW GSO CONFIGURATION *** */
5178 struct cmd_gso_show_result {
5179 cmdline_fixed_string_t cmd_show;
5180 cmdline_fixed_string_t cmd_port;
5181 cmdline_fixed_string_t cmd_keyword;
5186 cmd_gso_show_parsed(void *parsed_result,
5187 __rte_unused struct cmdline *cl,
5188 __rte_unused void *data)
5190 struct cmd_gso_show_result *res = parsed_result;
5192 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5193 printf("invalid port id %u\n", res->cmd_pid);
5196 if (!strcmp(res->cmd_keyword, "gso")) {
5197 if (gso_ports[res->cmd_pid].enable) {
5198 printf("Max GSO'd packet size: %uB\n"
5199 "Supported GSO types: TCP/IPv4, "
5200 "UDP/IPv4, VxLAN with inner "
5201 "TCP/IPv4 packet, GRE with inner "
5202 "TCP/IPv4 packet\n",
5203 gso_max_segment_size);
5205 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5209 cmdline_parse_token_string_t cmd_gso_show_show =
5210 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5212 cmdline_parse_token_string_t cmd_gso_show_port =
5213 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5215 cmdline_parse_token_string_t cmd_gso_show_keyword =
5216 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5217 cmd_keyword, "gso");
5218 cmdline_parse_token_num_t cmd_gso_show_pid =
5219 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5222 cmdline_parse_inst_t cmd_gso_show = {
5223 .f = cmd_gso_show_parsed,
5225 .help_str = "show port <port_id> gso",
5227 (void *)&cmd_gso_show_show,
5228 (void *)&cmd_gso_show_port,
5229 (void *)&cmd_gso_show_pid,
5230 (void *)&cmd_gso_show_keyword,
5235 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5236 struct cmd_set_flush_rx {
5237 cmdline_fixed_string_t set;
5238 cmdline_fixed_string_t flush_rx;
5239 cmdline_fixed_string_t mode;
5243 cmd_set_flush_rx_parsed(void *parsed_result,
5244 __rte_unused struct cmdline *cl,
5245 __rte_unused void *data)
5247 struct cmd_set_flush_rx *res = parsed_result;
5248 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5251 cmdline_parse_token_string_t cmd_setflushrx_set =
5252 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5254 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5255 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5256 flush_rx, "flush_rx");
5257 cmdline_parse_token_string_t cmd_setflushrx_mode =
5258 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5262 cmdline_parse_inst_t cmd_set_flush_rx = {
5263 .f = cmd_set_flush_rx_parsed,
5264 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5267 (void *)&cmd_setflushrx_set,
5268 (void *)&cmd_setflushrx_flush_rx,
5269 (void *)&cmd_setflushrx_mode,
5274 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5275 struct cmd_set_link_check {
5276 cmdline_fixed_string_t set;
5277 cmdline_fixed_string_t link_check;
5278 cmdline_fixed_string_t mode;
5282 cmd_set_link_check_parsed(void *parsed_result,
5283 __rte_unused struct cmdline *cl,
5284 __rte_unused void *data)
5286 struct cmd_set_link_check *res = parsed_result;
5287 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5290 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5291 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5293 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5294 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5295 link_check, "link_check");
5296 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5297 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5301 cmdline_parse_inst_t cmd_set_link_check = {
5302 .f = cmd_set_link_check_parsed,
5303 .help_str = "set link_check on|off: Enable/Disable link status check "
5304 "when starting/stopping a port",
5307 (void *)&cmd_setlinkcheck_set,
5308 (void *)&cmd_setlinkcheck_link_check,
5309 (void *)&cmd_setlinkcheck_mode,
5314 /* *** SET NIC BYPASS MODE *** */
5315 struct cmd_set_bypass_mode_result {
5316 cmdline_fixed_string_t set;
5317 cmdline_fixed_string_t bypass;
5318 cmdline_fixed_string_t mode;
5319 cmdline_fixed_string_t value;
5324 cmd_set_bypass_mode_parsed(void *parsed_result,
5325 __rte_unused struct cmdline *cl,
5326 __rte_unused void *data)
5328 struct cmd_set_bypass_mode_result *res = parsed_result;
5329 portid_t port_id = res->port_id;
5330 int32_t rc = -EINVAL;
5332 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5333 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5335 if (!strcmp(res->value, "bypass"))
5336 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5337 else if (!strcmp(res->value, "isolate"))
5338 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5340 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5342 /* Set the bypass mode for the relevant port. */
5343 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5346 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5349 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5350 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5352 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5353 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5355 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5356 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5358 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5359 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5360 value, "normal#bypass#isolate");
5361 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5362 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5365 cmdline_parse_inst_t cmd_set_bypass_mode = {
5366 .f = cmd_set_bypass_mode_parsed,
5367 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5368 "Set the NIC bypass mode for port_id",
5371 (void *)&cmd_setbypass_mode_set,
5372 (void *)&cmd_setbypass_mode_bypass,
5373 (void *)&cmd_setbypass_mode_mode,
5374 (void *)&cmd_setbypass_mode_value,
5375 (void *)&cmd_setbypass_mode_port,
5380 /* *** SET NIC BYPASS EVENT *** */
5381 struct cmd_set_bypass_event_result {
5382 cmdline_fixed_string_t set;
5383 cmdline_fixed_string_t bypass;
5384 cmdline_fixed_string_t event;
5385 cmdline_fixed_string_t event_value;
5386 cmdline_fixed_string_t mode;
5387 cmdline_fixed_string_t mode_value;
5392 cmd_set_bypass_event_parsed(void *parsed_result,
5393 __rte_unused struct cmdline *cl,
5394 __rte_unused void *data)
5396 int32_t rc = -EINVAL;
5397 struct cmd_set_bypass_event_result *res = parsed_result;
5398 portid_t port_id = res->port_id;
5400 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5401 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5402 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5404 if (!strcmp(res->event_value, "timeout"))
5405 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5406 else if (!strcmp(res->event_value, "os_on"))
5407 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5408 else if (!strcmp(res->event_value, "os_off"))
5409 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5410 else if (!strcmp(res->event_value, "power_on"))
5411 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5412 else if (!strcmp(res->event_value, "power_off"))
5413 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5415 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5417 if (!strcmp(res->mode_value, "bypass"))
5418 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5419 else if (!strcmp(res->mode_value, "isolate"))
5420 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5422 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5424 /* Set the watchdog timeout. */
5425 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5428 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5429 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5433 printf("Failed to set timeout value %u "
5434 "for port %d, errto code: %d.\n",
5435 bypass_timeout, port_id, rc);
5439 /* Set the bypass event to transition to bypass mode. */
5440 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5445 printf("\t Failed to set bypass event for port = %d.\n",
5449 cmdline_parse_token_string_t cmd_setbypass_event_set =
5450 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5452 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5453 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5455 cmdline_parse_token_string_t cmd_setbypass_event_event =
5456 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5458 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5459 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5460 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5461 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5462 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5464 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5465 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5466 mode_value, "normal#bypass#isolate");
5467 cmdline_parse_token_num_t cmd_setbypass_event_port =
5468 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5471 cmdline_parse_inst_t cmd_set_bypass_event = {
5472 .f = cmd_set_bypass_event_parsed,
5473 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5474 "power_off mode normal|bypass|isolate <port_id>: "
5475 "Set the NIC bypass event mode for port_id",
5478 (void *)&cmd_setbypass_event_set,
5479 (void *)&cmd_setbypass_event_bypass,
5480 (void *)&cmd_setbypass_event_event,
5481 (void *)&cmd_setbypass_event_event_value,
5482 (void *)&cmd_setbypass_event_mode,
5483 (void *)&cmd_setbypass_event_mode_value,
5484 (void *)&cmd_setbypass_event_port,
5490 /* *** SET NIC BYPASS TIMEOUT *** */
5491 struct cmd_set_bypass_timeout_result {
5492 cmdline_fixed_string_t set;
5493 cmdline_fixed_string_t bypass;
5494 cmdline_fixed_string_t timeout;
5495 cmdline_fixed_string_t value;
5499 cmd_set_bypass_timeout_parsed(void *parsed_result,
5500 __rte_unused struct cmdline *cl,
5501 __rte_unused void *data)
5503 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5505 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5506 if (!strcmp(res->value, "1.5"))
5507 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5508 else if (!strcmp(res->value, "2"))
5509 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5510 else if (!strcmp(res->value, "3"))
5511 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5512 else if (!strcmp(res->value, "4"))
5513 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5514 else if (!strcmp(res->value, "8"))
5515 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5516 else if (!strcmp(res->value, "16"))
5517 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5518 else if (!strcmp(res->value, "32"))
5519 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5521 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5525 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5526 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5528 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5529 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5531 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5532 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5533 timeout, "timeout");
5534 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5535 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5536 value, "0#1.5#2#3#4#8#16#32");
5538 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5539 .f = cmd_set_bypass_timeout_parsed,
5540 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5541 "Set the NIC bypass watchdog timeout in seconds",
5544 (void *)&cmd_setbypass_timeout_set,
5545 (void *)&cmd_setbypass_timeout_bypass,
5546 (void *)&cmd_setbypass_timeout_timeout,
5547 (void *)&cmd_setbypass_timeout_value,
5552 /* *** SHOW NIC BYPASS MODE *** */
5553 struct cmd_show_bypass_config_result {
5554 cmdline_fixed_string_t show;
5555 cmdline_fixed_string_t bypass;
5556 cmdline_fixed_string_t config;
5561 cmd_show_bypass_config_parsed(void *parsed_result,
5562 __rte_unused struct cmdline *cl,
5563 __rte_unused void *data)
5565 struct cmd_show_bypass_config_result *res = parsed_result;
5566 portid_t port_id = res->port_id;
5568 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5569 uint32_t event_mode;
5570 uint32_t bypass_mode;
5571 uint32_t timeout = bypass_timeout;
5574 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5575 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5576 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5577 {"UNKNOWN", "normal", "bypass", "isolate"};
5578 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5586 /* Display the bypass mode.*/
5587 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5588 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5592 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5593 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5595 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5598 /* Display the bypass timeout.*/
5599 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5600 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5602 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5604 /* Display the bypass events and associated modes. */
5605 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5607 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5608 printf("\tFailed to get bypass mode for event = %s\n",
5611 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5612 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5614 printf("\tbypass event: %-16s = %s\n", events[i],
5620 printf("\tFailed to get bypass configuration for port = %d\n",
5624 cmdline_parse_token_string_t cmd_showbypass_config_show =
5625 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5627 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5628 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5630 cmdline_parse_token_string_t cmd_showbypass_config_config =
5631 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5633 cmdline_parse_token_num_t cmd_showbypass_config_port =
5634 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5637 cmdline_parse_inst_t cmd_show_bypass_config = {
5638 .f = cmd_show_bypass_config_parsed,
5639 .help_str = "show bypass config <port_id>: "
5640 "Show the NIC bypass config for port_id",
5643 (void *)&cmd_showbypass_config_show,
5644 (void *)&cmd_showbypass_config_bypass,
5645 (void *)&cmd_showbypass_config_config,
5646 (void *)&cmd_showbypass_config_port,
5651 #ifdef RTE_LIBRTE_PMD_BOND
5652 /* *** SET BONDING MODE *** */
5653 struct cmd_set_bonding_mode_result {
5654 cmdline_fixed_string_t set;
5655 cmdline_fixed_string_t bonding;
5656 cmdline_fixed_string_t mode;
5661 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5662 __rte_unused struct cmdline *cl,
5663 __rte_unused void *data)
5665 struct cmd_set_bonding_mode_result *res = parsed_result;
5666 portid_t port_id = res->port_id;
5668 /* Set the bonding mode for the relevant port. */
5669 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5670 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5673 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5676 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5677 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5678 bonding, "bonding");
5679 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5680 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5682 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5683 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5685 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5686 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5689 cmdline_parse_inst_t cmd_set_bonding_mode = {
5690 .f = cmd_set_bonding_mode_parsed,
5691 .help_str = "set bonding mode <mode_value> <port_id>: "
5692 "Set the bonding mode for port_id",
5695 (void *) &cmd_setbonding_mode_set,
5696 (void *) &cmd_setbonding_mode_bonding,
5697 (void *) &cmd_setbonding_mode_mode,
5698 (void *) &cmd_setbonding_mode_value,
5699 (void *) &cmd_setbonding_mode_port,
5704 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5705 struct cmd_set_bonding_lacp_dedicated_queues_result {
5706 cmdline_fixed_string_t set;
5707 cmdline_fixed_string_t bonding;
5708 cmdline_fixed_string_t lacp;
5709 cmdline_fixed_string_t dedicated_queues;
5711 cmdline_fixed_string_t mode;
5714 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5715 __rte_unused struct cmdline *cl,
5716 __rte_unused void *data)
5718 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5719 portid_t port_id = res->port_id;
5720 struct rte_port *port;
5722 port = &ports[port_id];
5724 /** Check if the port is not started **/
5725 if (port->port_status != RTE_PORT_STOPPED) {
5726 printf("Please stop port %d first\n", port_id);
5730 if (!strcmp(res->mode, "enable")) {
5731 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5732 printf("Dedicate queues for LACP control packets"
5735 printf("Enabling dedicate queues for LACP control "
5736 "packets on port %d failed\n", port_id);
5737 } else if (!strcmp(res->mode, "disable")) {
5738 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5739 printf("Dedicated queues for LACP control packets "
5742 printf("Disabling dedicated queues for LACP control "
5743 "traffic on port %d failed\n", port_id);
5747 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5748 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5750 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5751 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5752 bonding, "bonding");
5753 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5754 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5756 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5757 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5758 dedicated_queues, "dedicated_queues");
5759 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5760 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5762 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5763 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5764 mode, "enable#disable");
5766 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5767 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5768 .help_str = "set bonding lacp dedicated_queues <port_id> "
5770 "Enable/disable dedicated queues for LACP control traffic for port_id",
5773 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5774 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5775 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5776 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5777 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5778 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5783 /* *** SET BALANCE XMIT POLICY *** */
5784 struct cmd_set_bonding_balance_xmit_policy_result {
5785 cmdline_fixed_string_t set;
5786 cmdline_fixed_string_t bonding;
5787 cmdline_fixed_string_t balance_xmit_policy;
5789 cmdline_fixed_string_t policy;
5792 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5793 __rte_unused struct cmdline *cl,
5794 __rte_unused void *data)
5796 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5797 portid_t port_id = res->port_id;
5800 if (!strcmp(res->policy, "l2")) {
5801 policy = BALANCE_XMIT_POLICY_LAYER2;
5802 } else if (!strcmp(res->policy, "l23")) {
5803 policy = BALANCE_XMIT_POLICY_LAYER23;
5804 } else if (!strcmp(res->policy, "l34")) {
5805 policy = BALANCE_XMIT_POLICY_LAYER34;
5807 printf("\t Invalid xmit policy selection");
5811 /* Set the bonding mode for the relevant port. */
5812 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5813 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5818 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5819 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5821 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5822 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5823 bonding, "bonding");
5824 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5825 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5826 balance_xmit_policy, "balance_xmit_policy");
5827 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5828 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5830 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5831 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5832 policy, "l2#l23#l34");
5834 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5835 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5836 .help_str = "set bonding balance_xmit_policy <port_id> "
5838 "Set the bonding balance_xmit_policy for port_id",
5841 (void *)&cmd_setbonding_balance_xmit_policy_set,
5842 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5843 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5844 (void *)&cmd_setbonding_balance_xmit_policy_port,
5845 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5850 /* *** SHOW NIC BONDING CONFIGURATION *** */
5851 struct cmd_show_bonding_config_result {
5852 cmdline_fixed_string_t show;
5853 cmdline_fixed_string_t bonding;
5854 cmdline_fixed_string_t config;
5858 static void cmd_show_bonding_config_parsed(void *parsed_result,
5859 __rte_unused struct cmdline *cl,
5860 __rte_unused void *data)
5862 struct cmd_show_bonding_config_result *res = parsed_result;
5863 int bonding_mode, agg_mode;
5864 portid_t slaves[RTE_MAX_ETHPORTS];
5865 int num_slaves, num_active_slaves;
5868 portid_t port_id = res->port_id;
5870 /* Display the bonding mode.*/
5871 bonding_mode = rte_eth_bond_mode_get(port_id);
5872 if (bonding_mode < 0) {
5873 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5876 printf("\tBonding mode: %d\n", bonding_mode);
5878 if (bonding_mode == BONDING_MODE_BALANCE) {
5879 int balance_xmit_policy;
5881 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5882 if (balance_xmit_policy < 0) {
5883 printf("\tFailed to get balance xmit policy for port = %d\n",
5887 printf("\tBalance Xmit Policy: ");
5889 switch (balance_xmit_policy) {
5890 case BALANCE_XMIT_POLICY_LAYER2:
5891 printf("BALANCE_XMIT_POLICY_LAYER2");
5893 case BALANCE_XMIT_POLICY_LAYER23:
5894 printf("BALANCE_XMIT_POLICY_LAYER23");
5896 case BALANCE_XMIT_POLICY_LAYER34:
5897 printf("BALANCE_XMIT_POLICY_LAYER34");
5904 if (bonding_mode == BONDING_MODE_8023AD) {
5905 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5906 printf("\tIEEE802.3AD Aggregator Mode: ");
5909 printf("bandwidth");
5921 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5923 if (num_slaves < 0) {
5924 printf("\tFailed to get slave list for port = %d\n", port_id);
5927 if (num_slaves > 0) {
5928 printf("\tSlaves (%d): [", num_slaves);
5929 for (i = 0; i < num_slaves - 1; i++)
5930 printf("%d ", slaves[i]);
5932 printf("%d]\n", slaves[num_slaves - 1]);
5934 printf("\tSlaves: []\n");
5938 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5941 if (num_active_slaves < 0) {
5942 printf("\tFailed to get active slave list for port = %d\n", port_id);
5945 if (num_active_slaves > 0) {
5946 printf("\tActive Slaves (%d): [", num_active_slaves);
5947 for (i = 0; i < num_active_slaves - 1; i++)
5948 printf("%d ", slaves[i]);
5950 printf("%d]\n", slaves[num_active_slaves - 1]);
5953 printf("\tActive Slaves: []\n");
5957 primary_id = rte_eth_bond_primary_get(port_id);
5958 if (primary_id < 0) {
5959 printf("\tFailed to get primary slave for port = %d\n", port_id);
5962 printf("\tPrimary: [%d]\n", primary_id);
5966 cmdline_parse_token_string_t cmd_showbonding_config_show =
5967 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5969 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5970 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5971 bonding, "bonding");
5972 cmdline_parse_token_string_t cmd_showbonding_config_config =
5973 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5975 cmdline_parse_token_num_t cmd_showbonding_config_port =
5976 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5979 cmdline_parse_inst_t cmd_show_bonding_config = {
5980 .f = cmd_show_bonding_config_parsed,
5981 .help_str = "show bonding config <port_id>: "
5982 "Show the bonding config for port_id",
5985 (void *)&cmd_showbonding_config_show,
5986 (void *)&cmd_showbonding_config_bonding,
5987 (void *)&cmd_showbonding_config_config,
5988 (void *)&cmd_showbonding_config_port,
5993 /* *** SET BONDING PRIMARY *** */
5994 struct cmd_set_bonding_primary_result {
5995 cmdline_fixed_string_t set;
5996 cmdline_fixed_string_t bonding;
5997 cmdline_fixed_string_t primary;
6002 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6003 __rte_unused struct cmdline *cl,
6004 __rte_unused void *data)
6006 struct cmd_set_bonding_primary_result *res = parsed_result;
6007 portid_t master_port_id = res->port_id;
6008 portid_t slave_port_id = res->slave_id;
6010 /* Set the primary slave for a bonded device. */
6011 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6012 printf("\t Failed to set primary slave for port = %d.\n",
6019 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6020 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6022 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6023 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6024 bonding, "bonding");
6025 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6026 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6027 primary, "primary");
6028 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6029 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6031 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6032 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6035 cmdline_parse_inst_t cmd_set_bonding_primary = {
6036 .f = cmd_set_bonding_primary_parsed,
6037 .help_str = "set bonding primary <slave_id> <port_id>: "
6038 "Set the primary slave for port_id",
6041 (void *)&cmd_setbonding_primary_set,
6042 (void *)&cmd_setbonding_primary_bonding,
6043 (void *)&cmd_setbonding_primary_primary,
6044 (void *)&cmd_setbonding_primary_slave,
6045 (void *)&cmd_setbonding_primary_port,
6050 /* *** ADD SLAVE *** */
6051 struct cmd_add_bonding_slave_result {
6052 cmdline_fixed_string_t add;
6053 cmdline_fixed_string_t bonding;
6054 cmdline_fixed_string_t slave;
6059 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6060 __rte_unused struct cmdline *cl,
6061 __rte_unused void *data)
6063 struct cmd_add_bonding_slave_result *res = parsed_result;
6064 portid_t master_port_id = res->port_id;
6065 portid_t slave_port_id = res->slave_id;
6067 /* add the slave for a bonded device. */
6068 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6069 printf("\t Failed to add slave %d to master port = %d.\n",
6070 slave_port_id, master_port_id);
6074 set_port_slave_flag(slave_port_id);
6077 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6078 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6080 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6081 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6082 bonding, "bonding");
6083 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6084 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6086 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6087 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6089 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6090 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6093 cmdline_parse_inst_t cmd_add_bonding_slave = {
6094 .f = cmd_add_bonding_slave_parsed,
6095 .help_str = "add bonding slave <slave_id> <port_id>: "
6096 "Add a slave device to a bonded device",
6099 (void *)&cmd_addbonding_slave_add,
6100 (void *)&cmd_addbonding_slave_bonding,
6101 (void *)&cmd_addbonding_slave_slave,
6102 (void *)&cmd_addbonding_slave_slaveid,
6103 (void *)&cmd_addbonding_slave_port,
6108 /* *** REMOVE SLAVE *** */
6109 struct cmd_remove_bonding_slave_result {
6110 cmdline_fixed_string_t remove;
6111 cmdline_fixed_string_t bonding;
6112 cmdline_fixed_string_t slave;
6117 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6118 __rte_unused struct cmdline *cl,
6119 __rte_unused void *data)
6121 struct cmd_remove_bonding_slave_result *res = parsed_result;
6122 portid_t master_port_id = res->port_id;
6123 portid_t slave_port_id = res->slave_id;
6125 /* remove the slave from a bonded device. */
6126 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6127 printf("\t Failed to remove slave %d from master port = %d.\n",
6128 slave_port_id, master_port_id);
6132 clear_port_slave_flag(slave_port_id);
6135 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6136 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6138 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6139 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6140 bonding, "bonding");
6141 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6142 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6144 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6145 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6147 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6148 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6151 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6152 .f = cmd_remove_bonding_slave_parsed,
6153 .help_str = "remove bonding slave <slave_id> <port_id>: "
6154 "Remove a slave device from a bonded device",
6157 (void *)&cmd_removebonding_slave_remove,
6158 (void *)&cmd_removebonding_slave_bonding,
6159 (void *)&cmd_removebonding_slave_slave,
6160 (void *)&cmd_removebonding_slave_slaveid,
6161 (void *)&cmd_removebonding_slave_port,
6166 /* *** CREATE BONDED DEVICE *** */
6167 struct cmd_create_bonded_device_result {
6168 cmdline_fixed_string_t create;
6169 cmdline_fixed_string_t bonded;
6170 cmdline_fixed_string_t device;
6175 static int bond_dev_num = 0;
6177 static void cmd_create_bonded_device_parsed(void *parsed_result,
6178 __rte_unused struct cmdline *cl,
6179 __rte_unused void *data)
6181 struct cmd_create_bonded_device_result *res = parsed_result;
6182 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6186 if (test_done == 0) {
6187 printf("Please stop forwarding first\n");
6191 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6194 /* Create a new bonded device. */
6195 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6197 printf("\t Failed to create bonded device.\n");
6200 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6203 /* Update number of ports */
6204 nb_ports = rte_eth_dev_count_avail();
6205 reconfig(port_id, res->socket);
6206 ret = rte_eth_promiscuous_enable(port_id);
6208 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6209 port_id, rte_strerror(-ret));
6211 ports[port_id].need_setup = 0;
6212 ports[port_id].port_status = RTE_PORT_STOPPED;
6217 cmdline_parse_token_string_t cmd_createbonded_device_create =
6218 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6220 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6221 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6223 cmdline_parse_token_string_t cmd_createbonded_device_device =
6224 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6226 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6227 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6229 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6230 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6233 cmdline_parse_inst_t cmd_create_bonded_device = {
6234 .f = cmd_create_bonded_device_parsed,
6235 .help_str = "create bonded device <mode> <socket>: "
6236 "Create a new bonded device with specific bonding mode and socket",
6239 (void *)&cmd_createbonded_device_create,
6240 (void *)&cmd_createbonded_device_bonded,
6241 (void *)&cmd_createbonded_device_device,
6242 (void *)&cmd_createbonded_device_mode,
6243 (void *)&cmd_createbonded_device_socket,
6248 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6249 struct cmd_set_bond_mac_addr_result {
6250 cmdline_fixed_string_t set;
6251 cmdline_fixed_string_t bonding;
6252 cmdline_fixed_string_t mac_addr;
6254 struct rte_ether_addr address;
6257 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6258 __rte_unused struct cmdline *cl,
6259 __rte_unused void *data)
6261 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6264 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6267 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6269 /* check the return value and print it if is < 0 */
6271 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6274 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6275 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6276 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6277 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6279 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6280 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6282 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6283 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6285 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6286 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6288 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6289 .f = cmd_set_bond_mac_addr_parsed,
6291 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6293 (void *)&cmd_set_bond_mac_addr_set,
6294 (void *)&cmd_set_bond_mac_addr_bonding,
6295 (void *)&cmd_set_bond_mac_addr_mac,
6296 (void *)&cmd_set_bond_mac_addr_portnum,
6297 (void *)&cmd_set_bond_mac_addr_addr,
6303 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6304 struct cmd_set_bond_mon_period_result {
6305 cmdline_fixed_string_t set;
6306 cmdline_fixed_string_t bonding;
6307 cmdline_fixed_string_t mon_period;
6312 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6313 __rte_unused struct cmdline *cl,
6314 __rte_unused void *data)
6316 struct cmd_set_bond_mon_period_result *res = parsed_result;
6319 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6321 /* check the return value and print it if is < 0 */
6323 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6326 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6327 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6329 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6330 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6331 bonding, "bonding");
6332 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6333 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6334 mon_period, "mon_period");
6335 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6336 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6338 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6339 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6342 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6343 .f = cmd_set_bond_mon_period_parsed,
6345 .help_str = "set bonding mon_period <port_id> <period_ms>",
6347 (void *)&cmd_set_bond_mon_period_set,
6348 (void *)&cmd_set_bond_mon_period_bonding,
6349 (void *)&cmd_set_bond_mon_period_mon_period,
6350 (void *)&cmd_set_bond_mon_period_portnum,
6351 (void *)&cmd_set_bond_mon_period_period_ms,
6358 struct cmd_set_bonding_agg_mode_policy_result {
6359 cmdline_fixed_string_t set;
6360 cmdline_fixed_string_t bonding;
6361 cmdline_fixed_string_t agg_mode;
6363 cmdline_fixed_string_t policy;
6368 cmd_set_bonding_agg_mode(void *parsed_result,
6369 __rte_unused struct cmdline *cl,
6370 __rte_unused void *data)
6372 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6373 uint8_t policy = AGG_BANDWIDTH;
6375 if (!strcmp(res->policy, "bandwidth"))
6376 policy = AGG_BANDWIDTH;
6377 else if (!strcmp(res->policy, "stable"))
6378 policy = AGG_STABLE;
6379 else if (!strcmp(res->policy, "count"))
6382 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6386 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6387 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6389 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6390 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6391 bonding, "bonding");
6393 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6394 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6395 agg_mode, "agg_mode");
6397 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6398 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6401 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6402 TOKEN_STRING_INITIALIZER(
6403 struct cmd_set_bonding_balance_xmit_policy_result,
6404 policy, "stable#bandwidth#count");
6406 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6407 .f = cmd_set_bonding_agg_mode,
6409 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6411 (void *)&cmd_set_bonding_agg_mode_set,
6412 (void *)&cmd_set_bonding_agg_mode_bonding,
6413 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6414 (void *)&cmd_set_bonding_agg_mode_portnum,
6415 (void *)&cmd_set_bonding_agg_mode_policy_string,
6421 #endif /* RTE_LIBRTE_PMD_BOND */
6423 /* *** SET FORWARDING MODE *** */
6424 struct cmd_set_fwd_mode_result {
6425 cmdline_fixed_string_t set;
6426 cmdline_fixed_string_t fwd;
6427 cmdline_fixed_string_t mode;
6430 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6431 __rte_unused struct cmdline *cl,
6432 __rte_unused void *data)
6434 struct cmd_set_fwd_mode_result *res = parsed_result;
6437 set_pkt_forwarding_mode(res->mode);
6440 cmdline_parse_token_string_t cmd_setfwd_set =
6441 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6442 cmdline_parse_token_string_t cmd_setfwd_fwd =
6443 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6444 cmdline_parse_token_string_t cmd_setfwd_mode =
6445 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6446 "" /* defined at init */);
6448 cmdline_parse_inst_t cmd_set_fwd_mode = {
6449 .f = cmd_set_fwd_mode_parsed,
6451 .help_str = NULL, /* defined at init */
6453 (void *)&cmd_setfwd_set,
6454 (void *)&cmd_setfwd_fwd,
6455 (void *)&cmd_setfwd_mode,
6460 static void cmd_set_fwd_mode_init(void)
6463 static char token[128];
6464 static char help[256];
6465 cmdline_parse_token_string_t *token_struct;
6467 modes = list_pkt_forwarding_modes();
6468 snprintf(help, sizeof(help), "set fwd %s: "
6469 "Set packet forwarding mode", modes);
6470 cmd_set_fwd_mode.help_str = help;
6472 /* string token separator is # */
6473 for (c = token; *modes != '\0'; modes++)
6478 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6479 token_struct->string_data.str = token;
6482 /* *** SET RETRY FORWARDING MODE *** */
6483 struct cmd_set_fwd_retry_mode_result {
6484 cmdline_fixed_string_t set;
6485 cmdline_fixed_string_t fwd;
6486 cmdline_fixed_string_t mode;
6487 cmdline_fixed_string_t retry;
6490 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6491 __rte_unused struct cmdline *cl,
6492 __rte_unused void *data)
6494 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6497 set_pkt_forwarding_mode(res->mode);
6500 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6501 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6503 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6504 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6506 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6507 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6509 "" /* defined at init */);
6510 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6511 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6514 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6515 .f = cmd_set_fwd_retry_mode_parsed,
6517 .help_str = NULL, /* defined at init */
6519 (void *)&cmd_setfwd_retry_set,
6520 (void *)&cmd_setfwd_retry_fwd,
6521 (void *)&cmd_setfwd_retry_mode,
6522 (void *)&cmd_setfwd_retry_retry,
6527 static void cmd_set_fwd_retry_mode_init(void)
6530 static char token[128];
6531 static char help[256];
6532 cmdline_parse_token_string_t *token_struct;
6534 modes = list_pkt_forwarding_retry_modes();
6535 snprintf(help, sizeof(help), "set fwd %s retry: "
6536 "Set packet forwarding mode with retry", modes);
6537 cmd_set_fwd_retry_mode.help_str = help;
6539 /* string token separator is # */
6540 for (c = token; *modes != '\0'; modes++)
6545 token_struct = (cmdline_parse_token_string_t *)
6546 cmd_set_fwd_retry_mode.tokens[2];
6547 token_struct->string_data.str = token;
6550 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6551 struct cmd_set_burst_tx_retry_result {
6552 cmdline_fixed_string_t set;
6553 cmdline_fixed_string_t burst;
6554 cmdline_fixed_string_t tx;
6555 cmdline_fixed_string_t delay;
6557 cmdline_fixed_string_t retry;
6561 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6562 __rte_unused struct cmdline *cl,
6563 __rte_unused void *data)
6565 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6567 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6568 && !strcmp(res->tx, "tx")) {
6569 if (!strcmp(res->delay, "delay"))
6570 burst_tx_delay_time = res->time;
6571 if (!strcmp(res->retry, "retry"))
6572 burst_tx_retry_num = res->retry_num;
6577 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6578 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6579 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6580 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6582 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6583 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6584 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6585 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6586 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6587 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6588 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6589 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6590 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6591 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6593 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6594 .f = cmd_set_burst_tx_retry_parsed,
6595 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6597 (void *)&cmd_set_burst_tx_retry_set,
6598 (void *)&cmd_set_burst_tx_retry_burst,
6599 (void *)&cmd_set_burst_tx_retry_tx,
6600 (void *)&cmd_set_burst_tx_retry_delay,
6601 (void *)&cmd_set_burst_tx_retry_time,
6602 (void *)&cmd_set_burst_tx_retry_retry,
6603 (void *)&cmd_set_burst_tx_retry_retry_num,
6608 /* *** SET PROMISC MODE *** */
6609 struct cmd_set_promisc_mode_result {
6610 cmdline_fixed_string_t set;
6611 cmdline_fixed_string_t promisc;
6612 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6613 uint16_t port_num; /* valid if "allports" argument == 0 */
6614 cmdline_fixed_string_t mode;
6617 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6618 __rte_unused struct cmdline *cl,
6621 struct cmd_set_promisc_mode_result *res = parsed_result;
6625 if (!strcmp(res->mode, "on"))
6632 RTE_ETH_FOREACH_DEV(i)
6633 eth_set_promisc_mode(i, enable);
6635 eth_set_promisc_mode(res->port_num, enable);
6639 cmdline_parse_token_string_t cmd_setpromisc_set =
6640 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6641 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6642 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6644 cmdline_parse_token_string_t cmd_setpromisc_portall =
6645 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6647 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6648 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6650 cmdline_parse_token_string_t cmd_setpromisc_mode =
6651 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6654 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6655 .f = cmd_set_promisc_mode_parsed,
6657 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6659 (void *)&cmd_setpromisc_set,
6660 (void *)&cmd_setpromisc_promisc,
6661 (void *)&cmd_setpromisc_portall,
6662 (void *)&cmd_setpromisc_mode,
6667 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6668 .f = cmd_set_promisc_mode_parsed,
6670 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6672 (void *)&cmd_setpromisc_set,
6673 (void *)&cmd_setpromisc_promisc,
6674 (void *)&cmd_setpromisc_portnum,
6675 (void *)&cmd_setpromisc_mode,
6680 /* *** SET ALLMULTI MODE *** */
6681 struct cmd_set_allmulti_mode_result {
6682 cmdline_fixed_string_t set;
6683 cmdline_fixed_string_t allmulti;
6684 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6685 uint16_t port_num; /* valid if "allports" argument == 0 */
6686 cmdline_fixed_string_t mode;
6689 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6690 __rte_unused struct cmdline *cl,
6693 struct cmd_set_allmulti_mode_result *res = parsed_result;
6697 if (!strcmp(res->mode, "on"))
6704 RTE_ETH_FOREACH_DEV(i) {
6705 eth_set_allmulticast_mode(i, enable);
6709 eth_set_allmulticast_mode(res->port_num, enable);
6713 cmdline_parse_token_string_t cmd_setallmulti_set =
6714 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6715 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6716 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6718 cmdline_parse_token_string_t cmd_setallmulti_portall =
6719 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6721 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6722 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6724 cmdline_parse_token_string_t cmd_setallmulti_mode =
6725 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6728 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6729 .f = cmd_set_allmulti_mode_parsed,
6731 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6733 (void *)&cmd_setallmulti_set,
6734 (void *)&cmd_setallmulti_allmulti,
6735 (void *)&cmd_setallmulti_portall,
6736 (void *)&cmd_setallmulti_mode,
6741 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6742 .f = cmd_set_allmulti_mode_parsed,
6744 .help_str = "set allmulti <port_id> on|off: "
6745 "Set allmulti mode on port_id",
6747 (void *)&cmd_setallmulti_set,
6748 (void *)&cmd_setallmulti_allmulti,
6749 (void *)&cmd_setallmulti_portnum,
6750 (void *)&cmd_setallmulti_mode,
6755 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6756 struct cmd_link_flow_ctrl_set_result {
6757 cmdline_fixed_string_t set;
6758 cmdline_fixed_string_t flow_ctrl;
6759 cmdline_fixed_string_t rx;
6760 cmdline_fixed_string_t rx_lfc_mode;
6761 cmdline_fixed_string_t tx;
6762 cmdline_fixed_string_t tx_lfc_mode;
6763 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6764 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6765 cmdline_fixed_string_t autoneg_str;
6766 cmdline_fixed_string_t autoneg;
6767 cmdline_fixed_string_t hw_str;
6768 uint32_t high_water;
6769 cmdline_fixed_string_t lw_str;
6771 cmdline_fixed_string_t pt_str;
6772 uint16_t pause_time;
6773 cmdline_fixed_string_t xon_str;
6778 cmdline_parse_token_string_t cmd_lfc_set_set =
6779 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6781 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6782 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6783 flow_ctrl, "flow_ctrl");
6784 cmdline_parse_token_string_t cmd_lfc_set_rx =
6785 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6787 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6788 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6789 rx_lfc_mode, "on#off");
6790 cmdline_parse_token_string_t cmd_lfc_set_tx =
6791 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6793 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6794 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6795 tx_lfc_mode, "on#off");
6796 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6797 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6798 hw_str, "high_water");
6799 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6800 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6801 high_water, UINT32);
6802 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6803 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6804 lw_str, "low_water");
6805 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6806 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6808 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6809 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6810 pt_str, "pause_time");
6811 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6812 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6813 pause_time, UINT16);
6814 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6815 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6816 xon_str, "send_xon");
6817 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6818 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6820 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6821 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6822 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6823 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6824 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6825 mac_ctrl_frame_fwd_mode, "on#off");
6826 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6827 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6828 autoneg_str, "autoneg");
6829 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6830 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6832 cmdline_parse_token_num_t cmd_lfc_set_portid =
6833 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6836 /* forward declaration */
6838 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6841 cmdline_parse_inst_t cmd_link_flow_control_set = {
6842 .f = cmd_link_flow_ctrl_set_parsed,
6844 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6845 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6846 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6848 (void *)&cmd_lfc_set_set,
6849 (void *)&cmd_lfc_set_flow_ctrl,
6850 (void *)&cmd_lfc_set_rx,
6851 (void *)&cmd_lfc_set_rx_mode,
6852 (void *)&cmd_lfc_set_tx,
6853 (void *)&cmd_lfc_set_tx_mode,
6854 (void *)&cmd_lfc_set_high_water,
6855 (void *)&cmd_lfc_set_low_water,
6856 (void *)&cmd_lfc_set_pause_time,
6857 (void *)&cmd_lfc_set_send_xon,
6858 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6859 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6860 (void *)&cmd_lfc_set_autoneg_str,
6861 (void *)&cmd_lfc_set_autoneg,
6862 (void *)&cmd_lfc_set_portid,
6867 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6868 .f = cmd_link_flow_ctrl_set_parsed,
6869 .data = (void *)&cmd_link_flow_control_set_rx,
6870 .help_str = "set flow_ctrl rx on|off <port_id>: "
6871 "Change rx flow control parameter",
6873 (void *)&cmd_lfc_set_set,
6874 (void *)&cmd_lfc_set_flow_ctrl,
6875 (void *)&cmd_lfc_set_rx,
6876 (void *)&cmd_lfc_set_rx_mode,
6877 (void *)&cmd_lfc_set_portid,
6882 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6883 .f = cmd_link_flow_ctrl_set_parsed,
6884 .data = (void *)&cmd_link_flow_control_set_tx,
6885 .help_str = "set flow_ctrl tx on|off <port_id>: "
6886 "Change tx flow control parameter",
6888 (void *)&cmd_lfc_set_set,
6889 (void *)&cmd_lfc_set_flow_ctrl,
6890 (void *)&cmd_lfc_set_tx,
6891 (void *)&cmd_lfc_set_tx_mode,
6892 (void *)&cmd_lfc_set_portid,
6897 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6898 .f = cmd_link_flow_ctrl_set_parsed,
6899 .data = (void *)&cmd_link_flow_control_set_hw,
6900 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6901 "Change high water flow control parameter",
6903 (void *)&cmd_lfc_set_set,
6904 (void *)&cmd_lfc_set_flow_ctrl,
6905 (void *)&cmd_lfc_set_high_water_str,
6906 (void *)&cmd_lfc_set_high_water,
6907 (void *)&cmd_lfc_set_portid,
6912 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6913 .f = cmd_link_flow_ctrl_set_parsed,
6914 .data = (void *)&cmd_link_flow_control_set_lw,
6915 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6916 "Change low water flow control parameter",
6918 (void *)&cmd_lfc_set_set,
6919 (void *)&cmd_lfc_set_flow_ctrl,
6920 (void *)&cmd_lfc_set_low_water_str,
6921 (void *)&cmd_lfc_set_low_water,
6922 (void *)&cmd_lfc_set_portid,
6927 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6928 .f = cmd_link_flow_ctrl_set_parsed,
6929 .data = (void *)&cmd_link_flow_control_set_pt,
6930 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6931 "Change pause time flow control parameter",
6933 (void *)&cmd_lfc_set_set,
6934 (void *)&cmd_lfc_set_flow_ctrl,
6935 (void *)&cmd_lfc_set_pause_time_str,
6936 (void *)&cmd_lfc_set_pause_time,
6937 (void *)&cmd_lfc_set_portid,
6942 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6943 .f = cmd_link_flow_ctrl_set_parsed,
6944 .data = (void *)&cmd_link_flow_control_set_xon,
6945 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6946 "Change send_xon flow control parameter",
6948 (void *)&cmd_lfc_set_set,
6949 (void *)&cmd_lfc_set_flow_ctrl,
6950 (void *)&cmd_lfc_set_send_xon_str,
6951 (void *)&cmd_lfc_set_send_xon,
6952 (void *)&cmd_lfc_set_portid,
6957 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6958 .f = cmd_link_flow_ctrl_set_parsed,
6959 .data = (void *)&cmd_link_flow_control_set_macfwd,
6960 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6961 "Change mac ctrl fwd flow control parameter",
6963 (void *)&cmd_lfc_set_set,
6964 (void *)&cmd_lfc_set_flow_ctrl,
6965 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6966 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6967 (void *)&cmd_lfc_set_portid,
6972 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6973 .f = cmd_link_flow_ctrl_set_parsed,
6974 .data = (void *)&cmd_link_flow_control_set_autoneg,
6975 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6976 "Change autoneg flow control parameter",
6978 (void *)&cmd_lfc_set_set,
6979 (void *)&cmd_lfc_set_flow_ctrl,
6980 (void *)&cmd_lfc_set_autoneg_str,
6981 (void *)&cmd_lfc_set_autoneg,
6982 (void *)&cmd_lfc_set_portid,
6988 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6989 __rte_unused struct cmdline *cl,
6992 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6993 cmdline_parse_inst_t *cmd = data;
6994 struct rte_eth_fc_conf fc_conf;
7000 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7001 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7002 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7003 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7005 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7006 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7009 /* Partial command line, retrieve current configuration */
7011 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7013 printf("cannot get current flow ctrl parameters, return"
7014 "code = %d\n", ret);
7018 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7019 (fc_conf.mode == RTE_FC_FULL))
7021 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7022 (fc_conf.mode == RTE_FC_FULL))
7026 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7027 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7029 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7030 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7032 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7034 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7035 fc_conf.high_water = res->high_water;
7037 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7038 fc_conf.low_water = res->low_water;
7040 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7041 fc_conf.pause_time = res->pause_time;
7043 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7044 fc_conf.send_xon = res->send_xon;
7046 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7047 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7048 fc_conf.mac_ctrl_frame_fwd = 1;
7050 fc_conf.mac_ctrl_frame_fwd = 0;
7053 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7054 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7056 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7058 printf("bad flow contrl parameter, return code = %d \n", ret);
7061 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7062 struct cmd_priority_flow_ctrl_set_result {
7063 cmdline_fixed_string_t set;
7064 cmdline_fixed_string_t pfc_ctrl;
7065 cmdline_fixed_string_t rx;
7066 cmdline_fixed_string_t rx_pfc_mode;
7067 cmdline_fixed_string_t tx;
7068 cmdline_fixed_string_t tx_pfc_mode;
7069 uint32_t high_water;
7071 uint16_t pause_time;
7077 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7078 __rte_unused struct cmdline *cl,
7079 __rte_unused void *data)
7081 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7082 struct rte_eth_pfc_conf pfc_conf;
7083 int rx_fc_enable, tx_fc_enable;
7087 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7088 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7089 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7090 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7092 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7093 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7096 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7097 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7098 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7099 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7100 pfc_conf.fc.high_water = res->high_water;
7101 pfc_conf.fc.low_water = res->low_water;
7102 pfc_conf.fc.pause_time = res->pause_time;
7103 pfc_conf.priority = res->priority;
7105 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7107 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7110 cmdline_parse_token_string_t cmd_pfc_set_set =
7111 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7113 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7114 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7115 pfc_ctrl, "pfc_ctrl");
7116 cmdline_parse_token_string_t cmd_pfc_set_rx =
7117 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7119 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7120 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7121 rx_pfc_mode, "on#off");
7122 cmdline_parse_token_string_t cmd_pfc_set_tx =
7123 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7125 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7126 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7127 tx_pfc_mode, "on#off");
7128 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7129 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7130 high_water, UINT32);
7131 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7132 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7134 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7135 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7136 pause_time, UINT16);
7137 cmdline_parse_token_num_t cmd_pfc_set_priority =
7138 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7140 cmdline_parse_token_num_t cmd_pfc_set_portid =
7141 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7144 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7145 .f = cmd_priority_flow_ctrl_set_parsed,
7147 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7148 "<pause_time> <priority> <port_id>: "
7149 "Configure the Ethernet priority flow control",
7151 (void *)&cmd_pfc_set_set,
7152 (void *)&cmd_pfc_set_flow_ctrl,
7153 (void *)&cmd_pfc_set_rx,
7154 (void *)&cmd_pfc_set_rx_mode,
7155 (void *)&cmd_pfc_set_tx,
7156 (void *)&cmd_pfc_set_tx_mode,
7157 (void *)&cmd_pfc_set_high_water,
7158 (void *)&cmd_pfc_set_low_water,
7159 (void *)&cmd_pfc_set_pause_time,
7160 (void *)&cmd_pfc_set_priority,
7161 (void *)&cmd_pfc_set_portid,
7166 /* *** RESET CONFIGURATION *** */
7167 struct cmd_reset_result {
7168 cmdline_fixed_string_t reset;
7169 cmdline_fixed_string_t def;
7172 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7174 __rte_unused void *data)
7176 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7177 set_def_fwd_config();
7180 cmdline_parse_token_string_t cmd_reset_set =
7181 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7182 cmdline_parse_token_string_t cmd_reset_def =
7183 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7186 cmdline_parse_inst_t cmd_reset = {
7187 .f = cmd_reset_parsed,
7189 .help_str = "set default: Reset default forwarding configuration",
7191 (void *)&cmd_reset_set,
7192 (void *)&cmd_reset_def,
7197 /* *** START FORWARDING *** */
7198 struct cmd_start_result {
7199 cmdline_fixed_string_t start;
7202 cmdline_parse_token_string_t cmd_start_start =
7203 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7205 static void cmd_start_parsed(__rte_unused void *parsed_result,
7206 __rte_unused struct cmdline *cl,
7207 __rte_unused void *data)
7209 start_packet_forwarding(0);
7212 cmdline_parse_inst_t cmd_start = {
7213 .f = cmd_start_parsed,
7215 .help_str = "start: Start packet forwarding",
7217 (void *)&cmd_start_start,
7222 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7223 struct cmd_start_tx_first_result {
7224 cmdline_fixed_string_t start;
7225 cmdline_fixed_string_t tx_first;
7229 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7230 __rte_unused struct cmdline *cl,
7231 __rte_unused void *data)
7233 start_packet_forwarding(1);
7236 cmdline_parse_token_string_t cmd_start_tx_first_start =
7237 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7239 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7240 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7241 tx_first, "tx_first");
7243 cmdline_parse_inst_t cmd_start_tx_first = {
7244 .f = cmd_start_tx_first_parsed,
7246 .help_str = "start tx_first: Start packet forwarding, "
7247 "after sending 1 burst of packets",
7249 (void *)&cmd_start_tx_first_start,
7250 (void *)&cmd_start_tx_first_tx_first,
7255 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7256 struct cmd_start_tx_first_n_result {
7257 cmdline_fixed_string_t start;
7258 cmdline_fixed_string_t tx_first;
7263 cmd_start_tx_first_n_parsed(void *parsed_result,
7264 __rte_unused struct cmdline *cl,
7265 __rte_unused void *data)
7267 struct cmd_start_tx_first_n_result *res = parsed_result;
7269 start_packet_forwarding(res->tx_num);
7272 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7273 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7275 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7276 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7277 tx_first, "tx_first");
7278 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7279 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7282 cmdline_parse_inst_t cmd_start_tx_first_n = {
7283 .f = cmd_start_tx_first_n_parsed,
7285 .help_str = "start tx_first <num>: "
7286 "packet forwarding, after sending <num> bursts of packets",
7288 (void *)&cmd_start_tx_first_n_start,
7289 (void *)&cmd_start_tx_first_n_tx_first,
7290 (void *)&cmd_start_tx_first_n_tx_num,
7295 /* *** SET LINK UP *** */
7296 struct cmd_set_link_up_result {
7297 cmdline_fixed_string_t set;
7298 cmdline_fixed_string_t link_up;
7299 cmdline_fixed_string_t port;
7303 cmdline_parse_token_string_t cmd_set_link_up_set =
7304 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7305 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7306 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7308 cmdline_parse_token_string_t cmd_set_link_up_port =
7309 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7310 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7311 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7313 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7314 __rte_unused struct cmdline *cl,
7315 __rte_unused void *data)
7317 struct cmd_set_link_up_result *res = parsed_result;
7318 dev_set_link_up(res->port_id);
7321 cmdline_parse_inst_t cmd_set_link_up = {
7322 .f = cmd_set_link_up_parsed,
7324 .help_str = "set link-up port <port id>",
7326 (void *)&cmd_set_link_up_set,
7327 (void *)&cmd_set_link_up_link_up,
7328 (void *)&cmd_set_link_up_port,
7329 (void *)&cmd_set_link_up_port_id,
7334 /* *** SET LINK DOWN *** */
7335 struct cmd_set_link_down_result {
7336 cmdline_fixed_string_t set;
7337 cmdline_fixed_string_t link_down;
7338 cmdline_fixed_string_t port;
7342 cmdline_parse_token_string_t cmd_set_link_down_set =
7343 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7344 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7345 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7347 cmdline_parse_token_string_t cmd_set_link_down_port =
7348 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7349 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7350 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7352 static void cmd_set_link_down_parsed(
7353 __rte_unused void *parsed_result,
7354 __rte_unused struct cmdline *cl,
7355 __rte_unused void *data)
7357 struct cmd_set_link_down_result *res = parsed_result;
7358 dev_set_link_down(res->port_id);
7361 cmdline_parse_inst_t cmd_set_link_down = {
7362 .f = cmd_set_link_down_parsed,
7364 .help_str = "set link-down port <port id>",
7366 (void *)&cmd_set_link_down_set,
7367 (void *)&cmd_set_link_down_link_down,
7368 (void *)&cmd_set_link_down_port,
7369 (void *)&cmd_set_link_down_port_id,
7374 /* *** SHOW CFG *** */
7375 struct cmd_showcfg_result {
7376 cmdline_fixed_string_t show;
7377 cmdline_fixed_string_t cfg;
7378 cmdline_fixed_string_t what;
7381 static void cmd_showcfg_parsed(void *parsed_result,
7382 __rte_unused struct cmdline *cl,
7383 __rte_unused void *data)
7385 struct cmd_showcfg_result *res = parsed_result;
7386 if (!strcmp(res->what, "rxtx"))
7387 rxtx_config_display();
7388 else if (!strcmp(res->what, "cores"))
7389 fwd_lcores_config_display();
7390 else if (!strcmp(res->what, "fwd"))
7391 pkt_fwd_config_display(&cur_fwd_config);
7392 else if (!strcmp(res->what, "txpkts"))
7393 show_tx_pkt_segments();
7396 cmdline_parse_token_string_t cmd_showcfg_show =
7397 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7398 cmdline_parse_token_string_t cmd_showcfg_port =
7399 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7400 cmdline_parse_token_string_t cmd_showcfg_what =
7401 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7402 "rxtx#cores#fwd#txpkts");
7404 cmdline_parse_inst_t cmd_showcfg = {
7405 .f = cmd_showcfg_parsed,
7407 .help_str = "show config rxtx|cores|fwd|txpkts",
7409 (void *)&cmd_showcfg_show,
7410 (void *)&cmd_showcfg_port,
7411 (void *)&cmd_showcfg_what,
7416 /* *** SHOW ALL PORT INFO *** */
7417 struct cmd_showportall_result {
7418 cmdline_fixed_string_t show;
7419 cmdline_fixed_string_t port;
7420 cmdline_fixed_string_t what;
7421 cmdline_fixed_string_t all;
7424 static void cmd_showportall_parsed(void *parsed_result,
7425 __rte_unused struct cmdline *cl,
7426 __rte_unused void *data)
7430 struct cmd_showportall_result *res = parsed_result;
7431 if (!strcmp(res->show, "clear")) {
7432 if (!strcmp(res->what, "stats"))
7433 RTE_ETH_FOREACH_DEV(i)
7435 else if (!strcmp(res->what, "xstats"))
7436 RTE_ETH_FOREACH_DEV(i)
7437 nic_xstats_clear(i);
7438 } else if (!strcmp(res->what, "info"))
7439 RTE_ETH_FOREACH_DEV(i)
7440 port_infos_display(i);
7441 else if (!strcmp(res->what, "summary")) {
7442 port_summary_header_display();
7443 RTE_ETH_FOREACH_DEV(i)
7444 port_summary_display(i);
7446 else if (!strcmp(res->what, "stats"))
7447 RTE_ETH_FOREACH_DEV(i)
7448 nic_stats_display(i);
7449 else if (!strcmp(res->what, "xstats"))
7450 RTE_ETH_FOREACH_DEV(i)
7451 nic_xstats_display(i);
7452 else if (!strcmp(res->what, "fdir"))
7453 RTE_ETH_FOREACH_DEV(i)
7455 else if (!strcmp(res->what, "stat_qmap"))
7456 RTE_ETH_FOREACH_DEV(i)
7457 nic_stats_mapping_display(i);
7458 else if (!strcmp(res->what, "dcb_tc"))
7459 RTE_ETH_FOREACH_DEV(i)
7460 port_dcb_info_display(i);
7461 else if (!strcmp(res->what, "cap"))
7462 RTE_ETH_FOREACH_DEV(i)
7463 port_offload_cap_display(i);
7466 cmdline_parse_token_string_t cmd_showportall_show =
7467 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7469 cmdline_parse_token_string_t cmd_showportall_port =
7470 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7471 cmdline_parse_token_string_t cmd_showportall_what =
7472 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7473 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7474 cmdline_parse_token_string_t cmd_showportall_all =
7475 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7476 cmdline_parse_inst_t cmd_showportall = {
7477 .f = cmd_showportall_parsed,
7479 .help_str = "show|clear port "
7480 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7482 (void *)&cmd_showportall_show,
7483 (void *)&cmd_showportall_port,
7484 (void *)&cmd_showportall_what,
7485 (void *)&cmd_showportall_all,
7490 /* *** SHOW PORT INFO *** */
7491 struct cmd_showport_result {
7492 cmdline_fixed_string_t show;
7493 cmdline_fixed_string_t port;
7494 cmdline_fixed_string_t what;
7498 static void cmd_showport_parsed(void *parsed_result,
7499 __rte_unused struct cmdline *cl,
7500 __rte_unused void *data)
7502 struct cmd_showport_result *res = parsed_result;
7503 if (!strcmp(res->show, "clear")) {
7504 if (!strcmp(res->what, "stats"))
7505 nic_stats_clear(res->portnum);
7506 else if (!strcmp(res->what, "xstats"))
7507 nic_xstats_clear(res->portnum);
7508 } else if (!strcmp(res->what, "info"))
7509 port_infos_display(res->portnum);
7510 else if (!strcmp(res->what, "summary")) {
7511 port_summary_header_display();
7512 port_summary_display(res->portnum);
7514 else if (!strcmp(res->what, "stats"))
7515 nic_stats_display(res->portnum);
7516 else if (!strcmp(res->what, "xstats"))
7517 nic_xstats_display(res->portnum);
7518 else if (!strcmp(res->what, "fdir"))
7519 fdir_get_infos(res->portnum);
7520 else if (!strcmp(res->what, "stat_qmap"))
7521 nic_stats_mapping_display(res->portnum);
7522 else if (!strcmp(res->what, "dcb_tc"))
7523 port_dcb_info_display(res->portnum);
7524 else if (!strcmp(res->what, "cap"))
7525 port_offload_cap_display(res->portnum);
7528 cmdline_parse_token_string_t cmd_showport_show =
7529 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7531 cmdline_parse_token_string_t cmd_showport_port =
7532 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7533 cmdline_parse_token_string_t cmd_showport_what =
7534 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7535 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7536 cmdline_parse_token_num_t cmd_showport_portnum =
7537 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7539 cmdline_parse_inst_t cmd_showport = {
7540 .f = cmd_showport_parsed,
7542 .help_str = "show|clear port "
7543 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7546 (void *)&cmd_showport_show,
7547 (void *)&cmd_showport_port,
7548 (void *)&cmd_showport_what,
7549 (void *)&cmd_showport_portnum,
7554 /* *** SHOW DEVICE INFO *** */
7555 struct cmd_showdevice_result {
7556 cmdline_fixed_string_t show;
7557 cmdline_fixed_string_t device;
7558 cmdline_fixed_string_t what;
7559 cmdline_fixed_string_t identifier;
7562 static void cmd_showdevice_parsed(void *parsed_result,
7563 __rte_unused struct cmdline *cl,
7564 __rte_unused void *data)
7566 struct cmd_showdevice_result *res = parsed_result;
7567 if (!strcmp(res->what, "info")) {
7568 if (!strcmp(res->identifier, "all"))
7569 device_infos_display(NULL);
7571 device_infos_display(res->identifier);
7575 cmdline_parse_token_string_t cmd_showdevice_show =
7576 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7578 cmdline_parse_token_string_t cmd_showdevice_device =
7579 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7580 cmdline_parse_token_string_t cmd_showdevice_what =
7581 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7583 cmdline_parse_token_string_t cmd_showdevice_identifier =
7584 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7587 cmdline_parse_inst_t cmd_showdevice = {
7588 .f = cmd_showdevice_parsed,
7590 .help_str = "show device info <identifier>|all",
7592 (void *)&cmd_showdevice_show,
7593 (void *)&cmd_showdevice_device,
7594 (void *)&cmd_showdevice_what,
7595 (void *)&cmd_showdevice_identifier,
7599 /* *** SHOW QUEUE INFO *** */
7600 struct cmd_showqueue_result {
7601 cmdline_fixed_string_t show;
7602 cmdline_fixed_string_t type;
7603 cmdline_fixed_string_t what;
7609 cmd_showqueue_parsed(void *parsed_result,
7610 __rte_unused struct cmdline *cl,
7611 __rte_unused void *data)
7613 struct cmd_showqueue_result *res = parsed_result;
7615 if (!strcmp(res->type, "rxq"))
7616 rx_queue_infos_display(res->portnum, res->queuenum);
7617 else if (!strcmp(res->type, "txq"))
7618 tx_queue_infos_display(res->portnum, res->queuenum);
7621 cmdline_parse_token_string_t cmd_showqueue_show =
7622 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7623 cmdline_parse_token_string_t cmd_showqueue_type =
7624 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7625 cmdline_parse_token_string_t cmd_showqueue_what =
7626 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7627 cmdline_parse_token_num_t cmd_showqueue_portnum =
7628 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7629 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7630 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7632 cmdline_parse_inst_t cmd_showqueue = {
7633 .f = cmd_showqueue_parsed,
7635 .help_str = "show rxq|txq info <port_id> <queue_id>",
7637 (void *)&cmd_showqueue_show,
7638 (void *)&cmd_showqueue_type,
7639 (void *)&cmd_showqueue_what,
7640 (void *)&cmd_showqueue_portnum,
7641 (void *)&cmd_showqueue_queuenum,
7646 /* show/clear fwd engine statistics */
7648 cmdline_fixed_string_t action;
7649 cmdline_fixed_string_t fwd;
7650 cmdline_fixed_string_t stats;
7651 cmdline_fixed_string_t all;
7654 cmdline_parse_token_string_t cmd_fwd_action =
7655 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7656 cmdline_parse_token_string_t cmd_fwd_fwd =
7657 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7658 cmdline_parse_token_string_t cmd_fwd_stats =
7659 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7660 cmdline_parse_token_string_t cmd_fwd_all =
7661 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7664 cmd_showfwdall_parsed(void *parsed_result,
7665 __rte_unused struct cmdline *cl,
7666 __rte_unused void *data)
7668 struct fwd_result *res = parsed_result;
7670 if (!strcmp(res->action, "show"))
7671 fwd_stats_display();
7676 static cmdline_parse_inst_t cmd_showfwdall = {
7677 .f = cmd_showfwdall_parsed,
7679 .help_str = "show|clear fwd stats all",
7681 (void *)&cmd_fwd_action,
7682 (void *)&cmd_fwd_fwd,
7683 (void *)&cmd_fwd_stats,
7684 (void *)&cmd_fwd_all,
7689 /* *** READ PORT REGISTER *** */
7690 struct cmd_read_reg_result {
7691 cmdline_fixed_string_t read;
7692 cmdline_fixed_string_t reg;
7698 cmd_read_reg_parsed(void *parsed_result,
7699 __rte_unused struct cmdline *cl,
7700 __rte_unused void *data)
7702 struct cmd_read_reg_result *res = parsed_result;
7703 port_reg_display(res->port_id, res->reg_off);
7706 cmdline_parse_token_string_t cmd_read_reg_read =
7707 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7708 cmdline_parse_token_string_t cmd_read_reg_reg =
7709 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7710 cmdline_parse_token_num_t cmd_read_reg_port_id =
7711 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7712 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7713 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7715 cmdline_parse_inst_t cmd_read_reg = {
7716 .f = cmd_read_reg_parsed,
7718 .help_str = "read reg <port_id> <reg_off>",
7720 (void *)&cmd_read_reg_read,
7721 (void *)&cmd_read_reg_reg,
7722 (void *)&cmd_read_reg_port_id,
7723 (void *)&cmd_read_reg_reg_off,
7728 /* *** READ PORT REGISTER BIT FIELD *** */
7729 struct cmd_read_reg_bit_field_result {
7730 cmdline_fixed_string_t read;
7731 cmdline_fixed_string_t regfield;
7739 cmd_read_reg_bit_field_parsed(void *parsed_result,
7740 __rte_unused struct cmdline *cl,
7741 __rte_unused void *data)
7743 struct cmd_read_reg_bit_field_result *res = parsed_result;
7744 port_reg_bit_field_display(res->port_id, res->reg_off,
7745 res->bit1_pos, res->bit2_pos);
7748 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7749 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7751 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7752 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7753 regfield, "regfield");
7754 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7755 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7757 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7758 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7760 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7761 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7763 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7764 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7767 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7768 .f = cmd_read_reg_bit_field_parsed,
7770 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7771 "Read register bit field between bit_x and bit_y included",
7773 (void *)&cmd_read_reg_bit_field_read,
7774 (void *)&cmd_read_reg_bit_field_regfield,
7775 (void *)&cmd_read_reg_bit_field_port_id,
7776 (void *)&cmd_read_reg_bit_field_reg_off,
7777 (void *)&cmd_read_reg_bit_field_bit1_pos,
7778 (void *)&cmd_read_reg_bit_field_bit2_pos,
7783 /* *** READ PORT REGISTER BIT *** */
7784 struct cmd_read_reg_bit_result {
7785 cmdline_fixed_string_t read;
7786 cmdline_fixed_string_t regbit;
7793 cmd_read_reg_bit_parsed(void *parsed_result,
7794 __rte_unused struct cmdline *cl,
7795 __rte_unused void *data)
7797 struct cmd_read_reg_bit_result *res = parsed_result;
7798 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7801 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7802 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7803 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7804 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7806 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7807 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7808 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7809 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7810 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7811 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7813 cmdline_parse_inst_t cmd_read_reg_bit = {
7814 .f = cmd_read_reg_bit_parsed,
7816 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7818 (void *)&cmd_read_reg_bit_read,
7819 (void *)&cmd_read_reg_bit_regbit,
7820 (void *)&cmd_read_reg_bit_port_id,
7821 (void *)&cmd_read_reg_bit_reg_off,
7822 (void *)&cmd_read_reg_bit_bit_pos,
7827 /* *** WRITE PORT REGISTER *** */
7828 struct cmd_write_reg_result {
7829 cmdline_fixed_string_t write;
7830 cmdline_fixed_string_t reg;
7837 cmd_write_reg_parsed(void *parsed_result,
7838 __rte_unused struct cmdline *cl,
7839 __rte_unused void *data)
7841 struct cmd_write_reg_result *res = parsed_result;
7842 port_reg_set(res->port_id, res->reg_off, res->value);
7845 cmdline_parse_token_string_t cmd_write_reg_write =
7846 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7847 cmdline_parse_token_string_t cmd_write_reg_reg =
7848 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7849 cmdline_parse_token_num_t cmd_write_reg_port_id =
7850 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7851 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7852 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7853 cmdline_parse_token_num_t cmd_write_reg_value =
7854 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7856 cmdline_parse_inst_t cmd_write_reg = {
7857 .f = cmd_write_reg_parsed,
7859 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7861 (void *)&cmd_write_reg_write,
7862 (void *)&cmd_write_reg_reg,
7863 (void *)&cmd_write_reg_port_id,
7864 (void *)&cmd_write_reg_reg_off,
7865 (void *)&cmd_write_reg_value,
7870 /* *** WRITE PORT REGISTER BIT FIELD *** */
7871 struct cmd_write_reg_bit_field_result {
7872 cmdline_fixed_string_t write;
7873 cmdline_fixed_string_t regfield;
7882 cmd_write_reg_bit_field_parsed(void *parsed_result,
7883 __rte_unused struct cmdline *cl,
7884 __rte_unused void *data)
7886 struct cmd_write_reg_bit_field_result *res = parsed_result;
7887 port_reg_bit_field_set(res->port_id, res->reg_off,
7888 res->bit1_pos, res->bit2_pos, res->value);
7891 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7892 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7894 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7895 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7896 regfield, "regfield");
7897 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7898 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7900 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7901 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7903 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7904 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7906 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7907 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7909 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7910 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7913 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7914 .f = cmd_write_reg_bit_field_parsed,
7916 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7918 "Set register bit field between bit_x and bit_y included",
7920 (void *)&cmd_write_reg_bit_field_write,
7921 (void *)&cmd_write_reg_bit_field_regfield,
7922 (void *)&cmd_write_reg_bit_field_port_id,
7923 (void *)&cmd_write_reg_bit_field_reg_off,
7924 (void *)&cmd_write_reg_bit_field_bit1_pos,
7925 (void *)&cmd_write_reg_bit_field_bit2_pos,
7926 (void *)&cmd_write_reg_bit_field_value,
7931 /* *** WRITE PORT REGISTER BIT *** */
7932 struct cmd_write_reg_bit_result {
7933 cmdline_fixed_string_t write;
7934 cmdline_fixed_string_t regbit;
7942 cmd_write_reg_bit_parsed(void *parsed_result,
7943 __rte_unused struct cmdline *cl,
7944 __rte_unused void *data)
7946 struct cmd_write_reg_bit_result *res = parsed_result;
7947 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7950 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7951 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7953 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7954 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7956 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7957 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7958 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7959 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7960 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7961 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7962 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7963 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7965 cmdline_parse_inst_t cmd_write_reg_bit = {
7966 .f = cmd_write_reg_bit_parsed,
7968 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7971 (void *)&cmd_write_reg_bit_write,
7972 (void *)&cmd_write_reg_bit_regbit,
7973 (void *)&cmd_write_reg_bit_port_id,
7974 (void *)&cmd_write_reg_bit_reg_off,
7975 (void *)&cmd_write_reg_bit_bit_pos,
7976 (void *)&cmd_write_reg_bit_value,
7981 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7982 struct cmd_read_rxd_txd_result {
7983 cmdline_fixed_string_t read;
7984 cmdline_fixed_string_t rxd_txd;
7991 cmd_read_rxd_txd_parsed(void *parsed_result,
7992 __rte_unused struct cmdline *cl,
7993 __rte_unused void *data)
7995 struct cmd_read_rxd_txd_result *res = parsed_result;
7997 if (!strcmp(res->rxd_txd, "rxd"))
7998 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7999 else if (!strcmp(res->rxd_txd, "txd"))
8000 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8003 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8004 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8005 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8006 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8008 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8009 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8010 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8011 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8012 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8013 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8015 cmdline_parse_inst_t cmd_read_rxd_txd = {
8016 .f = cmd_read_rxd_txd_parsed,
8018 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8020 (void *)&cmd_read_rxd_txd_read,
8021 (void *)&cmd_read_rxd_txd_rxd_txd,
8022 (void *)&cmd_read_rxd_txd_port_id,
8023 (void *)&cmd_read_rxd_txd_queue_id,
8024 (void *)&cmd_read_rxd_txd_desc_id,
8030 struct cmd_quit_result {
8031 cmdline_fixed_string_t quit;
8034 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8036 __rte_unused void *data)
8041 cmdline_parse_token_string_t cmd_quit_quit =
8042 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8044 cmdline_parse_inst_t cmd_quit = {
8045 .f = cmd_quit_parsed,
8047 .help_str = "quit: Exit application",
8049 (void *)&cmd_quit_quit,
8054 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8055 struct cmd_mac_addr_result {
8056 cmdline_fixed_string_t mac_addr_cmd;
8057 cmdline_fixed_string_t what;
8059 struct rte_ether_addr address;
8062 static void cmd_mac_addr_parsed(void *parsed_result,
8063 __rte_unused struct cmdline *cl,
8064 __rte_unused void *data)
8066 struct cmd_mac_addr_result *res = parsed_result;
8069 if (strcmp(res->what, "add") == 0)
8070 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8071 else if (strcmp(res->what, "set") == 0)
8072 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8075 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8077 /* check the return value and print it if is < 0 */
8079 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8083 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8084 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8086 cmdline_parse_token_string_t cmd_mac_addr_what =
8087 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8089 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8090 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8092 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8093 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8095 cmdline_parse_inst_t cmd_mac_addr = {
8096 .f = cmd_mac_addr_parsed,
8098 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8099 "Add/Remove/Set MAC address on port_id",
8101 (void *)&cmd_mac_addr_cmd,
8102 (void *)&cmd_mac_addr_what,
8103 (void *)&cmd_mac_addr_portnum,
8104 (void *)&cmd_mac_addr_addr,
8109 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8110 struct cmd_eth_peer_result {
8111 cmdline_fixed_string_t set;
8112 cmdline_fixed_string_t eth_peer;
8114 cmdline_fixed_string_t peer_addr;
8117 static void cmd_set_eth_peer_parsed(void *parsed_result,
8118 __rte_unused struct cmdline *cl,
8119 __rte_unused void *data)
8121 struct cmd_eth_peer_result *res = parsed_result;
8123 if (test_done == 0) {
8124 printf("Please stop forwarding first\n");
8127 if (!strcmp(res->eth_peer, "eth-peer")) {
8128 set_fwd_eth_peer(res->port_id, res->peer_addr);
8132 cmdline_parse_token_string_t cmd_eth_peer_set =
8133 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8134 cmdline_parse_token_string_t cmd_eth_peer =
8135 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8136 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8137 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8138 cmdline_parse_token_string_t cmd_eth_peer_addr =
8139 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8141 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8142 .f = cmd_set_eth_peer_parsed,
8144 .help_str = "set eth-peer <port_id> <peer_mac>",
8146 (void *)&cmd_eth_peer_set,
8147 (void *)&cmd_eth_peer,
8148 (void *)&cmd_eth_peer_port_id,
8149 (void *)&cmd_eth_peer_addr,
8154 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8155 struct cmd_set_qmap_result {
8156 cmdline_fixed_string_t set;
8157 cmdline_fixed_string_t qmap;
8158 cmdline_fixed_string_t what;
8165 cmd_set_qmap_parsed(void *parsed_result,
8166 __rte_unused struct cmdline *cl,
8167 __rte_unused void *data)
8169 struct cmd_set_qmap_result *res = parsed_result;
8170 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8172 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8175 cmdline_parse_token_string_t cmd_setqmap_set =
8176 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8178 cmdline_parse_token_string_t cmd_setqmap_qmap =
8179 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8181 cmdline_parse_token_string_t cmd_setqmap_what =
8182 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8184 cmdline_parse_token_num_t cmd_setqmap_portid =
8185 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8187 cmdline_parse_token_num_t cmd_setqmap_queueid =
8188 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8190 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8191 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8194 cmdline_parse_inst_t cmd_set_qmap = {
8195 .f = cmd_set_qmap_parsed,
8197 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8198 "Set statistics mapping value on tx|rx queue_id of port_id",
8200 (void *)&cmd_setqmap_set,
8201 (void *)&cmd_setqmap_qmap,
8202 (void *)&cmd_setqmap_what,
8203 (void *)&cmd_setqmap_portid,
8204 (void *)&cmd_setqmap_queueid,
8205 (void *)&cmd_setqmap_mapvalue,
8210 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8211 struct cmd_set_xstats_hide_zero_result {
8212 cmdline_fixed_string_t keyword;
8213 cmdline_fixed_string_t name;
8214 cmdline_fixed_string_t on_off;
8218 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8219 __rte_unused struct cmdline *cl,
8220 __rte_unused void *data)
8222 struct cmd_set_xstats_hide_zero_result *res;
8223 uint16_t on_off = 0;
8225 res = parsed_result;
8226 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8227 set_xstats_hide_zero(on_off);
8230 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8231 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8233 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8234 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8235 name, "xstats-hide-zero");
8236 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8237 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8240 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8241 .f = cmd_set_xstats_hide_zero_parsed,
8243 .help_str = "set xstats-hide-zero on|off",
8245 (void *)&cmd_set_xstats_hide_zero_keyword,
8246 (void *)&cmd_set_xstats_hide_zero_name,
8247 (void *)&cmd_set_xstats_hide_zero_on_off,
8252 /* *** CONFIGURE UNICAST HASH TABLE *** */
8253 struct cmd_set_uc_hash_table {
8254 cmdline_fixed_string_t set;
8255 cmdline_fixed_string_t port;
8257 cmdline_fixed_string_t what;
8258 struct rte_ether_addr address;
8259 cmdline_fixed_string_t mode;
8263 cmd_set_uc_hash_parsed(void *parsed_result,
8264 __rte_unused struct cmdline *cl,
8265 __rte_unused void *data)
8268 struct cmd_set_uc_hash_table *res = parsed_result;
8270 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8272 if (strcmp(res->what, "uta") == 0)
8273 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8274 &res->address,(uint8_t)is_on);
8276 printf("bad unicast hash table parameter, return code = %d \n", ret);
8280 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8281 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8283 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8284 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8286 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8287 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8289 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8290 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8292 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8293 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8295 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8296 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8299 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8300 .f = cmd_set_uc_hash_parsed,
8302 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8304 (void *)&cmd_set_uc_hash_set,
8305 (void *)&cmd_set_uc_hash_port,
8306 (void *)&cmd_set_uc_hash_portid,
8307 (void *)&cmd_set_uc_hash_what,
8308 (void *)&cmd_set_uc_hash_mac,
8309 (void *)&cmd_set_uc_hash_mode,
8314 struct cmd_set_uc_all_hash_table {
8315 cmdline_fixed_string_t set;
8316 cmdline_fixed_string_t port;
8318 cmdline_fixed_string_t what;
8319 cmdline_fixed_string_t value;
8320 cmdline_fixed_string_t mode;
8324 cmd_set_uc_all_hash_parsed(void *parsed_result,
8325 __rte_unused struct cmdline *cl,
8326 __rte_unused void *data)
8329 struct cmd_set_uc_all_hash_table *res = parsed_result;
8331 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8333 if ((strcmp(res->what, "uta") == 0) &&
8334 (strcmp(res->value, "all") == 0))
8335 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8337 printf("bad unicast hash table parameter,"
8338 "return code = %d \n", ret);
8341 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8342 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8344 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8345 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8347 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8348 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8350 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8351 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8353 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8354 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8356 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8357 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8360 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8361 .f = cmd_set_uc_all_hash_parsed,
8363 .help_str = "set port <port_id> uta all on|off",
8365 (void *)&cmd_set_uc_all_hash_set,
8366 (void *)&cmd_set_uc_all_hash_port,
8367 (void *)&cmd_set_uc_all_hash_portid,
8368 (void *)&cmd_set_uc_all_hash_what,
8369 (void *)&cmd_set_uc_all_hash_value,
8370 (void *)&cmd_set_uc_all_hash_mode,
8375 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8376 struct cmd_set_vf_macvlan_filter {
8377 cmdline_fixed_string_t set;
8378 cmdline_fixed_string_t port;
8380 cmdline_fixed_string_t vf;
8382 struct rte_ether_addr address;
8383 cmdline_fixed_string_t filter_type;
8384 cmdline_fixed_string_t mode;
8388 cmd_set_vf_macvlan_parsed(void *parsed_result,
8389 __rte_unused struct cmdline *cl,
8390 __rte_unused void *data)
8393 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8394 struct rte_eth_mac_filter filter;
8396 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8398 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8400 /* set VF MAC filter */
8404 filter.dst_id = res->vf_id;
8406 if (!strcmp(res->filter_type, "exact-mac"))
8407 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8408 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8409 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8410 else if (!strcmp(res->filter_type, "hashmac"))
8411 filter.filter_type = RTE_MAC_HASH_MATCH;
8412 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8413 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8415 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8418 ret = rte_eth_dev_filter_ctrl(res->port_id,
8419 RTE_ETH_FILTER_MACVLAN,
8423 ret = rte_eth_dev_filter_ctrl(res->port_id,
8424 RTE_ETH_FILTER_MACVLAN,
8425 RTE_ETH_FILTER_DELETE,
8429 printf("bad set MAC hash parameter, return code = %d\n", ret);
8433 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8434 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8436 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8437 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8439 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8440 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8442 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8443 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8445 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8446 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8448 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8449 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8451 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8452 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8453 filter_type, "exact-mac#exact-mac-vlan"
8454 "#hashmac#hashmac-vlan");
8455 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8456 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8459 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8460 .f = cmd_set_vf_macvlan_parsed,
8462 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8463 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8464 "Exact match rule: exact match of MAC or MAC and VLAN; "
8465 "hash match rule: hash match of MAC and exact match of VLAN",
8467 (void *)&cmd_set_vf_macvlan_set,
8468 (void *)&cmd_set_vf_macvlan_port,
8469 (void *)&cmd_set_vf_macvlan_portid,
8470 (void *)&cmd_set_vf_macvlan_vf,
8471 (void *)&cmd_set_vf_macvlan_vf_id,
8472 (void *)&cmd_set_vf_macvlan_mac,
8473 (void *)&cmd_set_vf_macvlan_filter_type,
8474 (void *)&cmd_set_vf_macvlan_mode,
8479 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8480 struct cmd_set_vf_traffic {
8481 cmdline_fixed_string_t set;
8482 cmdline_fixed_string_t port;
8484 cmdline_fixed_string_t vf;
8486 cmdline_fixed_string_t what;
8487 cmdline_fixed_string_t mode;
8491 cmd_set_vf_traffic_parsed(void *parsed_result,
8492 __rte_unused struct cmdline *cl,
8493 __rte_unused void *data)
8495 struct cmd_set_vf_traffic *res = parsed_result;
8496 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8497 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8499 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8502 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8503 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8505 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8506 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8508 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8509 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8511 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8512 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8514 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8515 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8517 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8518 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8520 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8521 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8524 cmdline_parse_inst_t cmd_set_vf_traffic = {
8525 .f = cmd_set_vf_traffic_parsed,
8527 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8529 (void *)&cmd_setvf_traffic_set,
8530 (void *)&cmd_setvf_traffic_port,
8531 (void *)&cmd_setvf_traffic_portid,
8532 (void *)&cmd_setvf_traffic_vf,
8533 (void *)&cmd_setvf_traffic_vfid,
8534 (void *)&cmd_setvf_traffic_what,
8535 (void *)&cmd_setvf_traffic_mode,
8540 /* *** CONFIGURE VF RECEIVE MODE *** */
8541 struct cmd_set_vf_rxmode {
8542 cmdline_fixed_string_t set;
8543 cmdline_fixed_string_t port;
8545 cmdline_fixed_string_t vf;
8547 cmdline_fixed_string_t what;
8548 cmdline_fixed_string_t mode;
8549 cmdline_fixed_string_t on;
8553 cmd_set_vf_rxmode_parsed(void *parsed_result,
8554 __rte_unused struct cmdline *cl,
8555 __rte_unused void *data)
8558 uint16_t vf_rxmode = 0;
8559 struct cmd_set_vf_rxmode *res = parsed_result;
8561 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8562 if (!strcmp(res->what,"rxmode")) {
8563 if (!strcmp(res->mode, "AUPE"))
8564 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8565 else if (!strcmp(res->mode, "ROPE"))
8566 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8567 else if (!strcmp(res->mode, "BAM"))
8568 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8569 else if (!strncmp(res->mode, "MPE",3))
8570 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8573 RTE_SET_USED(is_on);
8575 #ifdef RTE_LIBRTE_IXGBE_PMD
8576 if (ret == -ENOTSUP)
8577 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8578 vf_rxmode, (uint8_t)is_on);
8580 #ifdef RTE_LIBRTE_BNXT_PMD
8581 if (ret == -ENOTSUP)
8582 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8583 vf_rxmode, (uint8_t)is_on);
8586 printf("bad VF receive mode parameter, return code = %d \n",
8590 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8591 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8593 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8594 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8596 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8597 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8599 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8600 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8602 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8603 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8605 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8606 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8608 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8609 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8610 mode, "AUPE#ROPE#BAM#MPE");
8611 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8612 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8615 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8616 .f = cmd_set_vf_rxmode_parsed,
8618 .help_str = "set port <port_id> vf <vf_id> rxmode "
8619 "AUPE|ROPE|BAM|MPE on|off",
8621 (void *)&cmd_set_vf_rxmode_set,
8622 (void *)&cmd_set_vf_rxmode_port,
8623 (void *)&cmd_set_vf_rxmode_portid,
8624 (void *)&cmd_set_vf_rxmode_vf,
8625 (void *)&cmd_set_vf_rxmode_vfid,
8626 (void *)&cmd_set_vf_rxmode_what,
8627 (void *)&cmd_set_vf_rxmode_mode,
8628 (void *)&cmd_set_vf_rxmode_on,
8633 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8634 struct cmd_vf_mac_addr_result {
8635 cmdline_fixed_string_t mac_addr_cmd;
8636 cmdline_fixed_string_t what;
8637 cmdline_fixed_string_t port;
8639 cmdline_fixed_string_t vf;
8641 struct rte_ether_addr address;
8644 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8645 __rte_unused struct cmdline *cl,
8646 __rte_unused void *data)
8648 struct cmd_vf_mac_addr_result *res = parsed_result;
8651 if (strcmp(res->what, "add") != 0)
8654 #ifdef RTE_LIBRTE_I40E_PMD
8655 if (ret == -ENOTSUP)
8656 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8659 #ifdef RTE_LIBRTE_BNXT_PMD
8660 if (ret == -ENOTSUP)
8661 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8666 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8670 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8671 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8672 mac_addr_cmd,"mac_addr");
8673 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8674 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8676 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8677 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8679 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8680 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8682 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8683 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8685 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8686 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8688 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8689 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8692 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8693 .f = cmd_vf_mac_addr_parsed,
8695 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8696 "Add MAC address filtering for a VF on port_id",
8698 (void *)&cmd_vf_mac_addr_cmd,
8699 (void *)&cmd_vf_mac_addr_what,
8700 (void *)&cmd_vf_mac_addr_port,
8701 (void *)&cmd_vf_mac_addr_portnum,
8702 (void *)&cmd_vf_mac_addr_vf,
8703 (void *)&cmd_vf_mac_addr_vfnum,
8704 (void *)&cmd_vf_mac_addr_addr,
8709 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8710 struct cmd_vf_rx_vlan_filter {
8711 cmdline_fixed_string_t rx_vlan;
8712 cmdline_fixed_string_t what;
8714 cmdline_fixed_string_t port;
8716 cmdline_fixed_string_t vf;
8721 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8722 __rte_unused struct cmdline *cl,
8723 __rte_unused void *data)
8725 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8728 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8730 #ifdef RTE_LIBRTE_IXGBE_PMD
8731 if (ret == -ENOTSUP)
8732 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8733 res->vlan_id, res->vf_mask, is_add);
8735 #ifdef RTE_LIBRTE_I40E_PMD
8736 if (ret == -ENOTSUP)
8737 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8738 res->vlan_id, res->vf_mask, is_add);
8740 #ifdef RTE_LIBRTE_BNXT_PMD
8741 if (ret == -ENOTSUP)
8742 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8743 res->vlan_id, res->vf_mask, is_add);
8750 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8751 res->vlan_id, res->vf_mask);
8754 printf("invalid port_id %d\n", res->port_id);
8757 printf("function not implemented or supported\n");
8760 printf("programming error: (%s)\n", strerror(-ret));
8764 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8765 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8766 rx_vlan, "rx_vlan");
8767 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8768 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8770 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8771 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8773 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8774 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8776 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8777 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8779 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8780 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8782 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8783 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8786 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8787 .f = cmd_vf_rx_vlan_filter_parsed,
8789 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8790 "(vf_mask = hexadecimal VF mask)",
8792 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8793 (void *)&cmd_vf_rx_vlan_filter_what,
8794 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8795 (void *)&cmd_vf_rx_vlan_filter_port,
8796 (void *)&cmd_vf_rx_vlan_filter_portid,
8797 (void *)&cmd_vf_rx_vlan_filter_vf,
8798 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8803 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8804 struct cmd_queue_rate_limit_result {
8805 cmdline_fixed_string_t set;
8806 cmdline_fixed_string_t port;
8808 cmdline_fixed_string_t queue;
8810 cmdline_fixed_string_t rate;
8814 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8815 __rte_unused struct cmdline *cl,
8816 __rte_unused void *data)
8818 struct cmd_queue_rate_limit_result *res = parsed_result;
8821 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8822 && (strcmp(res->queue, "queue") == 0)
8823 && (strcmp(res->rate, "rate") == 0))
8824 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8827 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8831 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8832 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8834 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8835 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8837 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8838 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8840 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8841 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8843 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8844 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8846 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8847 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8849 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8850 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8853 cmdline_parse_inst_t cmd_queue_rate_limit = {
8854 .f = cmd_queue_rate_limit_parsed,
8856 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8857 "Set rate limit for a queue on port_id",
8859 (void *)&cmd_queue_rate_limit_set,
8860 (void *)&cmd_queue_rate_limit_port,
8861 (void *)&cmd_queue_rate_limit_portnum,
8862 (void *)&cmd_queue_rate_limit_queue,
8863 (void *)&cmd_queue_rate_limit_queuenum,
8864 (void *)&cmd_queue_rate_limit_rate,
8865 (void *)&cmd_queue_rate_limit_ratenum,
8870 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8871 struct cmd_vf_rate_limit_result {
8872 cmdline_fixed_string_t set;
8873 cmdline_fixed_string_t port;
8875 cmdline_fixed_string_t vf;
8877 cmdline_fixed_string_t rate;
8879 cmdline_fixed_string_t q_msk;
8883 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8884 __rte_unused struct cmdline *cl,
8885 __rte_unused void *data)
8887 struct cmd_vf_rate_limit_result *res = parsed_result;
8890 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8891 && (strcmp(res->vf, "vf") == 0)
8892 && (strcmp(res->rate, "rate") == 0)
8893 && (strcmp(res->q_msk, "queue_mask") == 0))
8894 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8895 res->rate_num, res->q_msk_val);
8897 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8901 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8902 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8904 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8905 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8907 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8908 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8910 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8911 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8913 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8914 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8916 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8917 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8919 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8920 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8922 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8923 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8924 q_msk, "queue_mask");
8925 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8926 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8929 cmdline_parse_inst_t cmd_vf_rate_limit = {
8930 .f = cmd_vf_rate_limit_parsed,
8932 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8933 "queue_mask <queue_mask_value>: "
8934 "Set rate limit for queues of VF on port_id",
8936 (void *)&cmd_vf_rate_limit_set,
8937 (void *)&cmd_vf_rate_limit_port,
8938 (void *)&cmd_vf_rate_limit_portnum,
8939 (void *)&cmd_vf_rate_limit_vf,
8940 (void *)&cmd_vf_rate_limit_vfnum,
8941 (void *)&cmd_vf_rate_limit_rate,
8942 (void *)&cmd_vf_rate_limit_ratenum,
8943 (void *)&cmd_vf_rate_limit_q_msk,
8944 (void *)&cmd_vf_rate_limit_q_msk_val,
8949 /* *** ADD TUNNEL FILTER OF A PORT *** */
8950 struct cmd_tunnel_filter_result {
8951 cmdline_fixed_string_t cmd;
8952 cmdline_fixed_string_t what;
8954 struct rte_ether_addr outer_mac;
8955 struct rte_ether_addr inner_mac;
8956 cmdline_ipaddr_t ip_value;
8957 uint16_t inner_vlan;
8958 cmdline_fixed_string_t tunnel_type;
8959 cmdline_fixed_string_t filter_type;
8965 cmd_tunnel_filter_parsed(void *parsed_result,
8966 __rte_unused struct cmdline *cl,
8967 __rte_unused void *data)
8969 struct cmd_tunnel_filter_result *res = parsed_result;
8970 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8973 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8975 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8976 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8977 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8979 if (res->ip_value.family == AF_INET) {
8980 tunnel_filter_conf.ip_addr.ipv4_addr =
8981 res->ip_value.addr.ipv4.s_addr;
8982 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8984 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8985 &(res->ip_value.addr.ipv6),
8986 sizeof(struct in6_addr));
8987 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8990 if (!strcmp(res->filter_type, "imac-ivlan"))
8991 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8992 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8993 tunnel_filter_conf.filter_type =
8994 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8995 else if (!strcmp(res->filter_type, "imac-tenid"))
8996 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8997 else if (!strcmp(res->filter_type, "imac"))
8998 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8999 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9000 tunnel_filter_conf.filter_type =
9001 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9002 else if (!strcmp(res->filter_type, "oip"))
9003 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9004 else if (!strcmp(res->filter_type, "iip"))
9005 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9007 printf("The filter type is not supported");
9011 if (!strcmp(res->tunnel_type, "vxlan"))
9012 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9013 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9014 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9015 else if (!strcmp(res->tunnel_type, "nvgre"))
9016 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9017 else if (!strcmp(res->tunnel_type, "ipingre"))
9018 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9020 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9024 tunnel_filter_conf.tenant_id = res->tenant_id;
9025 tunnel_filter_conf.queue_id = res->queue_num;
9026 if (!strcmp(res->what, "add"))
9027 ret = rte_eth_dev_filter_ctrl(res->port_id,
9028 RTE_ETH_FILTER_TUNNEL,
9030 &tunnel_filter_conf);
9032 ret = rte_eth_dev_filter_ctrl(res->port_id,
9033 RTE_ETH_FILTER_TUNNEL,
9034 RTE_ETH_FILTER_DELETE,
9035 &tunnel_filter_conf);
9037 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9041 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9042 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9043 cmd, "tunnel_filter");
9044 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9045 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9047 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9048 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9050 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9051 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9053 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9054 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9056 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9057 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9058 inner_vlan, UINT16);
9059 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9060 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9062 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9063 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9064 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9066 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9067 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9068 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9069 "imac#omac-imac-tenid");
9070 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9071 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9073 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9074 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9077 cmdline_parse_inst_t cmd_tunnel_filter = {
9078 .f = cmd_tunnel_filter_parsed,
9080 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9081 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9082 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9083 "<queue_id>: Add/Rm tunnel filter of a port",
9085 (void *)&cmd_tunnel_filter_cmd,
9086 (void *)&cmd_tunnel_filter_what,
9087 (void *)&cmd_tunnel_filter_port_id,
9088 (void *)&cmd_tunnel_filter_outer_mac,
9089 (void *)&cmd_tunnel_filter_inner_mac,
9090 (void *)&cmd_tunnel_filter_ip_value,
9091 (void *)&cmd_tunnel_filter_innner_vlan,
9092 (void *)&cmd_tunnel_filter_tunnel_type,
9093 (void *)&cmd_tunnel_filter_filter_type,
9094 (void *)&cmd_tunnel_filter_tenant_id,
9095 (void *)&cmd_tunnel_filter_queue_num,
9100 /* *** CONFIGURE TUNNEL UDP PORT *** */
9101 struct cmd_tunnel_udp_config {
9102 cmdline_fixed_string_t cmd;
9103 cmdline_fixed_string_t what;
9109 cmd_tunnel_udp_config_parsed(void *parsed_result,
9110 __rte_unused struct cmdline *cl,
9111 __rte_unused void *data)
9113 struct cmd_tunnel_udp_config *res = parsed_result;
9114 struct rte_eth_udp_tunnel tunnel_udp;
9117 tunnel_udp.udp_port = res->udp_port;
9119 if (!strcmp(res->cmd, "rx_vxlan_port"))
9120 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9122 if (!strcmp(res->what, "add"))
9123 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9126 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9130 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9133 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9134 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9135 cmd, "rx_vxlan_port");
9136 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9137 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9139 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9140 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9142 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9143 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9146 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9147 .f = cmd_tunnel_udp_config_parsed,
9149 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9150 "Add/Remove a tunneling UDP port filter",
9152 (void *)&cmd_tunnel_udp_config_cmd,
9153 (void *)&cmd_tunnel_udp_config_what,
9154 (void *)&cmd_tunnel_udp_config_udp_port,
9155 (void *)&cmd_tunnel_udp_config_port_id,
9160 struct cmd_config_tunnel_udp_port {
9161 cmdline_fixed_string_t port;
9162 cmdline_fixed_string_t config;
9164 cmdline_fixed_string_t udp_tunnel_port;
9165 cmdline_fixed_string_t action;
9166 cmdline_fixed_string_t tunnel_type;
9171 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9172 __rte_unused struct cmdline *cl,
9173 __rte_unused void *data)
9175 struct cmd_config_tunnel_udp_port *res = parsed_result;
9176 struct rte_eth_udp_tunnel tunnel_udp;
9179 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9182 tunnel_udp.udp_port = res->udp_port;
9184 if (!strcmp(res->tunnel_type, "vxlan")) {
9185 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9186 } else if (!strcmp(res->tunnel_type, "geneve")) {
9187 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9188 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9189 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9191 printf("Invalid tunnel type\n");
9195 if (!strcmp(res->action, "add"))
9196 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9199 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9203 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9206 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9207 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9209 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9210 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9212 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9213 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9215 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9216 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9219 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9220 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9222 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9223 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9224 "vxlan#geneve#vxlan-gpe");
9225 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9226 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9229 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9230 .f = cmd_cfg_tunnel_udp_port_parsed,
9232 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9234 (void *)&cmd_config_tunnel_udp_port_port,
9235 (void *)&cmd_config_tunnel_udp_port_config,
9236 (void *)&cmd_config_tunnel_udp_port_port_id,
9237 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9238 (void *)&cmd_config_tunnel_udp_port_action,
9239 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9240 (void *)&cmd_config_tunnel_udp_port_value,
9245 /* *** GLOBAL CONFIG *** */
9246 struct cmd_global_config_result {
9247 cmdline_fixed_string_t cmd;
9249 cmdline_fixed_string_t cfg_type;
9254 cmd_global_config_parsed(void *parsed_result,
9255 __rte_unused struct cmdline *cl,
9256 __rte_unused void *data)
9258 struct cmd_global_config_result *res = parsed_result;
9259 struct rte_eth_global_cfg conf;
9262 memset(&conf, 0, sizeof(conf));
9263 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9264 conf.cfg.gre_key_len = res->len;
9265 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9266 RTE_ETH_FILTER_SET, &conf);
9268 printf("Global config error\n");
9271 cmdline_parse_token_string_t cmd_global_config_cmd =
9272 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9274 cmdline_parse_token_num_t cmd_global_config_port_id =
9275 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9277 cmdline_parse_token_string_t cmd_global_config_type =
9278 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9279 cfg_type, "gre-key-len");
9280 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9281 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9284 cmdline_parse_inst_t cmd_global_config = {
9285 .f = cmd_global_config_parsed,
9286 .data = (void *)NULL,
9287 .help_str = "global_config <port_id> gre-key-len <key_len>",
9289 (void *)&cmd_global_config_cmd,
9290 (void *)&cmd_global_config_port_id,
9291 (void *)&cmd_global_config_type,
9292 (void *)&cmd_global_config_gre_key_len,
9297 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9298 struct cmd_set_mirror_mask_result {
9299 cmdline_fixed_string_t set;
9300 cmdline_fixed_string_t port;
9302 cmdline_fixed_string_t mirror;
9304 cmdline_fixed_string_t what;
9305 cmdline_fixed_string_t value;
9306 cmdline_fixed_string_t dstpool;
9308 cmdline_fixed_string_t on;
9311 cmdline_parse_token_string_t cmd_mirror_mask_set =
9312 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9314 cmdline_parse_token_string_t cmd_mirror_mask_port =
9315 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9317 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9318 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9320 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9321 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9322 mirror, "mirror-rule");
9323 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9324 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9326 cmdline_parse_token_string_t cmd_mirror_mask_what =
9327 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9328 what, "pool-mirror-up#pool-mirror-down"
9330 cmdline_parse_token_string_t cmd_mirror_mask_value =
9331 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9333 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9334 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9335 dstpool, "dst-pool");
9336 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9337 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9339 cmdline_parse_token_string_t cmd_mirror_mask_on =
9340 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9344 cmd_set_mirror_mask_parsed(void *parsed_result,
9345 __rte_unused struct cmdline *cl,
9346 __rte_unused void *data)
9349 struct cmd_set_mirror_mask_result *res = parsed_result;
9350 struct rte_eth_mirror_conf mr_conf;
9352 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9354 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9356 mr_conf.dst_pool = res->dstpool_id;
9358 if (!strcmp(res->what, "pool-mirror-up")) {
9359 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9360 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9361 } else if (!strcmp(res->what, "pool-mirror-down")) {
9362 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9363 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9364 } else if (!strcmp(res->what, "vlan-mirror")) {
9365 mr_conf.rule_type = ETH_MIRROR_VLAN;
9366 nb_item = parse_item_list(res->value, "vlan",
9367 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9371 for (i = 0; i < nb_item; i++) {
9372 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9373 printf("Invalid vlan_id: must be < 4096\n");
9377 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9378 mr_conf.vlan.vlan_mask |= 1ULL << i;
9382 if (!strcmp(res->on, "on"))
9383 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9386 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9389 printf("mirror rule add error: (%s)\n", strerror(-ret));
9392 cmdline_parse_inst_t cmd_set_mirror_mask = {
9393 .f = cmd_set_mirror_mask_parsed,
9395 .help_str = "set port <port_id> mirror-rule <rule_id> "
9396 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9397 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9399 (void *)&cmd_mirror_mask_set,
9400 (void *)&cmd_mirror_mask_port,
9401 (void *)&cmd_mirror_mask_portid,
9402 (void *)&cmd_mirror_mask_mirror,
9403 (void *)&cmd_mirror_mask_ruleid,
9404 (void *)&cmd_mirror_mask_what,
9405 (void *)&cmd_mirror_mask_value,
9406 (void *)&cmd_mirror_mask_dstpool,
9407 (void *)&cmd_mirror_mask_poolid,
9408 (void *)&cmd_mirror_mask_on,
9413 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9414 struct cmd_set_mirror_link_result {
9415 cmdline_fixed_string_t set;
9416 cmdline_fixed_string_t port;
9418 cmdline_fixed_string_t mirror;
9420 cmdline_fixed_string_t what;
9421 cmdline_fixed_string_t dstpool;
9423 cmdline_fixed_string_t on;
9426 cmdline_parse_token_string_t cmd_mirror_link_set =
9427 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9429 cmdline_parse_token_string_t cmd_mirror_link_port =
9430 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9432 cmdline_parse_token_num_t cmd_mirror_link_portid =
9433 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9435 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9436 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9437 mirror, "mirror-rule");
9438 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9439 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9441 cmdline_parse_token_string_t cmd_mirror_link_what =
9442 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9443 what, "uplink-mirror#downlink-mirror");
9444 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9445 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9446 dstpool, "dst-pool");
9447 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9448 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9450 cmdline_parse_token_string_t cmd_mirror_link_on =
9451 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9455 cmd_set_mirror_link_parsed(void *parsed_result,
9456 __rte_unused struct cmdline *cl,
9457 __rte_unused void *data)
9460 struct cmd_set_mirror_link_result *res = parsed_result;
9461 struct rte_eth_mirror_conf mr_conf;
9463 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9464 if (!strcmp(res->what, "uplink-mirror"))
9465 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9467 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9469 mr_conf.dst_pool = res->dstpool_id;
9471 if (!strcmp(res->on, "on"))
9472 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9475 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9478 /* check the return value and print it if is < 0 */
9480 printf("mirror rule add error: (%s)\n", strerror(-ret));
9484 cmdline_parse_inst_t cmd_set_mirror_link = {
9485 .f = cmd_set_mirror_link_parsed,
9487 .help_str = "set port <port_id> mirror-rule <rule_id> "
9488 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9490 (void *)&cmd_mirror_link_set,
9491 (void *)&cmd_mirror_link_port,
9492 (void *)&cmd_mirror_link_portid,
9493 (void *)&cmd_mirror_link_mirror,
9494 (void *)&cmd_mirror_link_ruleid,
9495 (void *)&cmd_mirror_link_what,
9496 (void *)&cmd_mirror_link_dstpool,
9497 (void *)&cmd_mirror_link_poolid,
9498 (void *)&cmd_mirror_link_on,
9503 /* *** RESET VM MIRROR RULE *** */
9504 struct cmd_rm_mirror_rule_result {
9505 cmdline_fixed_string_t reset;
9506 cmdline_fixed_string_t port;
9508 cmdline_fixed_string_t mirror;
9512 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9513 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9515 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9516 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9518 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9519 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9521 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9522 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9523 mirror, "mirror-rule");
9524 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9525 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9529 cmd_reset_mirror_rule_parsed(void *parsed_result,
9530 __rte_unused struct cmdline *cl,
9531 __rte_unused void *data)
9534 struct cmd_set_mirror_link_result *res = parsed_result;
9536 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9538 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9541 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9542 .f = cmd_reset_mirror_rule_parsed,
9544 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9546 (void *)&cmd_rm_mirror_rule_reset,
9547 (void *)&cmd_rm_mirror_rule_port,
9548 (void *)&cmd_rm_mirror_rule_portid,
9549 (void *)&cmd_rm_mirror_rule_mirror,
9550 (void *)&cmd_rm_mirror_rule_ruleid,
9555 /* ******************************************************************************** */
9557 struct cmd_dump_result {
9558 cmdline_fixed_string_t dump;
9562 dump_struct_sizes(void)
9564 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9565 DUMP_SIZE(struct rte_mbuf);
9566 DUMP_SIZE(struct rte_mempool);
9567 DUMP_SIZE(struct rte_ring);
9572 /* Dump the socket memory statistics on console */
9574 dump_socket_mem(FILE *f)
9576 struct rte_malloc_socket_stats socket_stats;
9581 unsigned int n_alloc = 0;
9582 unsigned int n_free = 0;
9583 static size_t last_allocs;
9584 static size_t last_total;
9587 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9588 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9589 !socket_stats.heap_totalsz_bytes)
9591 total += socket_stats.heap_totalsz_bytes;
9592 alloc += socket_stats.heap_allocsz_bytes;
9593 free += socket_stats.heap_freesz_bytes;
9594 n_alloc += socket_stats.alloc_count;
9595 n_free += socket_stats.free_count;
9597 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9599 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9600 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9601 (double)socket_stats.heap_allocsz_bytes * 100 /
9602 (double)socket_stats.heap_totalsz_bytes,
9603 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9604 socket_stats.alloc_count,
9605 socket_stats.free_count);
9608 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9609 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9610 (double)alloc * 100 / (double)total,
9611 (double)free / (1024 * 1024),
9614 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9615 ((double)total - (double)last_total) / (1024 * 1024),
9616 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9617 last_allocs = alloc;
9621 static void cmd_dump_parsed(void *parsed_result,
9622 __rte_unused struct cmdline *cl,
9623 __rte_unused void *data)
9625 struct cmd_dump_result *res = parsed_result;
9627 if (!strcmp(res->dump, "dump_physmem"))
9628 rte_dump_physmem_layout(stdout);
9629 else if (!strcmp(res->dump, "dump_socket_mem"))
9630 dump_socket_mem(stdout);
9631 else if (!strcmp(res->dump, "dump_memzone"))
9632 rte_memzone_dump(stdout);
9633 else if (!strcmp(res->dump, "dump_struct_sizes"))
9634 dump_struct_sizes();
9635 else if (!strcmp(res->dump, "dump_ring"))
9636 rte_ring_list_dump(stdout);
9637 else if (!strcmp(res->dump, "dump_mempool"))
9638 rte_mempool_list_dump(stdout);
9639 else if (!strcmp(res->dump, "dump_devargs"))
9640 rte_devargs_dump(stdout);
9641 else if (!strcmp(res->dump, "dump_log_types"))
9642 rte_log_dump(stdout);
9645 cmdline_parse_token_string_t cmd_dump_dump =
9646 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9650 "dump_struct_sizes#"
9656 cmdline_parse_inst_t cmd_dump = {
9657 .f = cmd_dump_parsed, /* function to call */
9658 .data = NULL, /* 2nd arg of func */
9659 .help_str = "Dump status",
9660 .tokens = { /* token list, NULL terminated */
9661 (void *)&cmd_dump_dump,
9666 /* ******************************************************************************** */
9668 struct cmd_dump_one_result {
9669 cmdline_fixed_string_t dump;
9670 cmdline_fixed_string_t name;
9673 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9674 __rte_unused void *data)
9676 struct cmd_dump_one_result *res = parsed_result;
9678 if (!strcmp(res->dump, "dump_ring")) {
9680 r = rte_ring_lookup(res->name);
9682 cmdline_printf(cl, "Cannot find ring\n");
9685 rte_ring_dump(stdout, r);
9686 } else if (!strcmp(res->dump, "dump_mempool")) {
9687 struct rte_mempool *mp;
9688 mp = rte_mempool_lookup(res->name);
9690 cmdline_printf(cl, "Cannot find mempool\n");
9693 rte_mempool_dump(stdout, mp);
9697 cmdline_parse_token_string_t cmd_dump_one_dump =
9698 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9699 "dump_ring#dump_mempool");
9701 cmdline_parse_token_string_t cmd_dump_one_name =
9702 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9704 cmdline_parse_inst_t cmd_dump_one = {
9705 .f = cmd_dump_one_parsed, /* function to call */
9706 .data = NULL, /* 2nd arg of func */
9707 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9708 .tokens = { /* token list, NULL terminated */
9709 (void *)&cmd_dump_one_dump,
9710 (void *)&cmd_dump_one_name,
9715 /* *** Add/Del syn filter *** */
9716 struct cmd_syn_filter_result {
9717 cmdline_fixed_string_t filter;
9719 cmdline_fixed_string_t ops;
9720 cmdline_fixed_string_t priority;
9721 cmdline_fixed_string_t high;
9722 cmdline_fixed_string_t queue;
9727 cmd_syn_filter_parsed(void *parsed_result,
9728 __rte_unused struct cmdline *cl,
9729 __rte_unused void *data)
9731 struct cmd_syn_filter_result *res = parsed_result;
9732 struct rte_eth_syn_filter syn_filter;
9735 ret = rte_eth_dev_filter_supported(res->port_id,
9736 RTE_ETH_FILTER_SYN);
9738 printf("syn filter is not supported on port %u.\n",
9743 memset(&syn_filter, 0, sizeof(syn_filter));
9745 if (!strcmp(res->ops, "add")) {
9746 if (!strcmp(res->high, "high"))
9747 syn_filter.hig_pri = 1;
9749 syn_filter.hig_pri = 0;
9751 syn_filter.queue = res->queue_id;
9752 ret = rte_eth_dev_filter_ctrl(res->port_id,
9757 ret = rte_eth_dev_filter_ctrl(res->port_id,
9759 RTE_ETH_FILTER_DELETE,
9763 printf("syn filter programming error: (%s)\n",
9767 cmdline_parse_token_string_t cmd_syn_filter_filter =
9768 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9769 filter, "syn_filter");
9770 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9771 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9773 cmdline_parse_token_string_t cmd_syn_filter_ops =
9774 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9776 cmdline_parse_token_string_t cmd_syn_filter_priority =
9777 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9778 priority, "priority");
9779 cmdline_parse_token_string_t cmd_syn_filter_high =
9780 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9782 cmdline_parse_token_string_t cmd_syn_filter_queue =
9783 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9785 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9786 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9789 cmdline_parse_inst_t cmd_syn_filter = {
9790 .f = cmd_syn_filter_parsed,
9792 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9793 "<queue_id>: Add/Delete syn filter",
9795 (void *)&cmd_syn_filter_filter,
9796 (void *)&cmd_syn_filter_port_id,
9797 (void *)&cmd_syn_filter_ops,
9798 (void *)&cmd_syn_filter_priority,
9799 (void *)&cmd_syn_filter_high,
9800 (void *)&cmd_syn_filter_queue,
9801 (void *)&cmd_syn_filter_queue_id,
9806 /* *** queue region set *** */
9807 struct cmd_queue_region_result {
9808 cmdline_fixed_string_t set;
9809 cmdline_fixed_string_t port;
9811 cmdline_fixed_string_t cmd;
9812 cmdline_fixed_string_t region;
9814 cmdline_fixed_string_t queue_start_index;
9816 cmdline_fixed_string_t queue_num;
9817 uint8_t queue_num_value;
9821 cmd_queue_region_parsed(void *parsed_result,
9822 __rte_unused struct cmdline *cl,
9823 __rte_unused void *data)
9825 struct cmd_queue_region_result *res = parsed_result;
9827 #ifdef RTE_LIBRTE_I40E_PMD
9828 struct rte_pmd_i40e_queue_region_conf region_conf;
9829 enum rte_pmd_i40e_queue_region_op op_type;
9832 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9835 #ifdef RTE_LIBRTE_I40E_PMD
9836 memset(®ion_conf, 0, sizeof(region_conf));
9837 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9838 region_conf.region_id = res->region_id;
9839 region_conf.queue_num = res->queue_num_value;
9840 region_conf.queue_start_index = res->queue_id;
9842 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9843 op_type, ®ion_conf);
9850 printf("function not implemented or supported\n");
9853 printf("queue region config error: (%s)\n", strerror(-ret));
9857 cmdline_parse_token_string_t cmd_queue_region_set =
9858 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9860 cmdline_parse_token_string_t cmd_queue_region_port =
9861 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9862 cmdline_parse_token_num_t cmd_queue_region_port_id =
9863 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9865 cmdline_parse_token_string_t cmd_queue_region_cmd =
9866 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9867 cmd, "queue-region");
9868 cmdline_parse_token_string_t cmd_queue_region_id =
9869 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9870 region, "region_id");
9871 cmdline_parse_token_num_t cmd_queue_region_index =
9872 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9874 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9875 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9876 queue_start_index, "queue_start_index");
9877 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9878 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9880 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9881 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9882 queue_num, "queue_num");
9883 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9884 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9885 queue_num_value, UINT8);
9887 cmdline_parse_inst_t cmd_queue_region = {
9888 .f = cmd_queue_region_parsed,
9890 .help_str = "set port <port_id> queue-region region_id <value> "
9891 "queue_start_index <value> queue_num <value>: Set a queue region",
9893 (void *)&cmd_queue_region_set,
9894 (void *)&cmd_queue_region_port,
9895 (void *)&cmd_queue_region_port_id,
9896 (void *)&cmd_queue_region_cmd,
9897 (void *)&cmd_queue_region_id,
9898 (void *)&cmd_queue_region_index,
9899 (void *)&cmd_queue_region_queue_start_index,
9900 (void *)&cmd_queue_region_queue_id,
9901 (void *)&cmd_queue_region_queue_num,
9902 (void *)&cmd_queue_region_queue_num_value,
9907 /* *** queue region and flowtype set *** */
9908 struct cmd_region_flowtype_result {
9909 cmdline_fixed_string_t set;
9910 cmdline_fixed_string_t port;
9912 cmdline_fixed_string_t cmd;
9913 cmdline_fixed_string_t region;
9915 cmdline_fixed_string_t flowtype;
9916 uint8_t flowtype_id;
9920 cmd_region_flowtype_parsed(void *parsed_result,
9921 __rte_unused struct cmdline *cl,
9922 __rte_unused void *data)
9924 struct cmd_region_flowtype_result *res = parsed_result;
9926 #ifdef RTE_LIBRTE_I40E_PMD
9927 struct rte_pmd_i40e_queue_region_conf region_conf;
9928 enum rte_pmd_i40e_queue_region_op op_type;
9931 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9934 #ifdef RTE_LIBRTE_I40E_PMD
9935 memset(®ion_conf, 0, sizeof(region_conf));
9937 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9938 region_conf.region_id = res->region_id;
9939 region_conf.hw_flowtype = res->flowtype_id;
9941 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9942 op_type, ®ion_conf);
9949 printf("function not implemented or supported\n");
9952 printf("region flowtype config error: (%s)\n", strerror(-ret));
9956 cmdline_parse_token_string_t cmd_region_flowtype_set =
9957 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9959 cmdline_parse_token_string_t cmd_region_flowtype_port =
9960 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9962 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9963 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9965 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9966 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9967 cmd, "queue-region");
9968 cmdline_parse_token_string_t cmd_region_flowtype_index =
9969 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9970 region, "region_id");
9971 cmdline_parse_token_num_t cmd_region_flowtype_id =
9972 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9974 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9975 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9976 flowtype, "flowtype");
9977 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9978 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9979 flowtype_id, UINT8);
9980 cmdline_parse_inst_t cmd_region_flowtype = {
9981 .f = cmd_region_flowtype_parsed,
9983 .help_str = "set port <port_id> queue-region region_id <value> "
9984 "flowtype <value>: Set a flowtype region index",
9986 (void *)&cmd_region_flowtype_set,
9987 (void *)&cmd_region_flowtype_port,
9988 (void *)&cmd_region_flowtype_port_index,
9989 (void *)&cmd_region_flowtype_cmd,
9990 (void *)&cmd_region_flowtype_index,
9991 (void *)&cmd_region_flowtype_id,
9992 (void *)&cmd_region_flowtype_flow_index,
9993 (void *)&cmd_region_flowtype_flow_id,
9998 /* *** User Priority (UP) to queue region (region_id) set *** */
9999 struct cmd_user_priority_region_result {
10000 cmdline_fixed_string_t set;
10001 cmdline_fixed_string_t port;
10003 cmdline_fixed_string_t cmd;
10004 cmdline_fixed_string_t user_priority;
10005 uint8_t user_priority_id;
10006 cmdline_fixed_string_t region;
10011 cmd_user_priority_region_parsed(void *parsed_result,
10012 __rte_unused struct cmdline *cl,
10013 __rte_unused void *data)
10015 struct cmd_user_priority_region_result *res = parsed_result;
10016 int ret = -ENOTSUP;
10017 #ifdef RTE_LIBRTE_I40E_PMD
10018 struct rte_pmd_i40e_queue_region_conf region_conf;
10019 enum rte_pmd_i40e_queue_region_op op_type;
10022 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10025 #ifdef RTE_LIBRTE_I40E_PMD
10026 memset(®ion_conf, 0, sizeof(region_conf));
10027 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10028 region_conf.user_priority = res->user_priority_id;
10029 region_conf.region_id = res->region_id;
10031 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10032 op_type, ®ion_conf);
10039 printf("function not implemented or supported\n");
10042 printf("user_priority region config error: (%s)\n",
10047 cmdline_parse_token_string_t cmd_user_priority_region_set =
10048 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10050 cmdline_parse_token_string_t cmd_user_priority_region_port =
10051 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10053 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10054 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10056 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10057 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10058 cmd, "queue-region");
10059 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10060 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10061 user_priority, "UP");
10062 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10063 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10064 user_priority_id, UINT8);
10065 cmdline_parse_token_string_t cmd_user_priority_region_region =
10066 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10067 region, "region_id");
10068 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10069 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10072 cmdline_parse_inst_t cmd_user_priority_region = {
10073 .f = cmd_user_priority_region_parsed,
10075 .help_str = "set port <port_id> queue-region UP <value> "
10076 "region_id <value>: Set the mapping of User Priority (UP) "
10077 "to queue region (region_id) ",
10079 (void *)&cmd_user_priority_region_set,
10080 (void *)&cmd_user_priority_region_port,
10081 (void *)&cmd_user_priority_region_port_index,
10082 (void *)&cmd_user_priority_region_cmd,
10083 (void *)&cmd_user_priority_region_UP,
10084 (void *)&cmd_user_priority_region_UP_id,
10085 (void *)&cmd_user_priority_region_region,
10086 (void *)&cmd_user_priority_region_region_id,
10091 /* *** flush all queue region related configuration *** */
10092 struct cmd_flush_queue_region_result {
10093 cmdline_fixed_string_t set;
10094 cmdline_fixed_string_t port;
10096 cmdline_fixed_string_t cmd;
10097 cmdline_fixed_string_t flush;
10098 cmdline_fixed_string_t what;
10102 cmd_flush_queue_region_parsed(void *parsed_result,
10103 __rte_unused struct cmdline *cl,
10104 __rte_unused void *data)
10106 struct cmd_flush_queue_region_result *res = parsed_result;
10107 int ret = -ENOTSUP;
10108 #ifdef RTE_LIBRTE_I40E_PMD
10109 struct rte_pmd_i40e_queue_region_conf region_conf;
10110 enum rte_pmd_i40e_queue_region_op op_type;
10113 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10116 #ifdef RTE_LIBRTE_I40E_PMD
10117 memset(®ion_conf, 0, sizeof(region_conf));
10119 if (strcmp(res->what, "on") == 0)
10120 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10122 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10124 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10125 op_type, ®ion_conf);
10132 printf("function not implemented or supported\n");
10135 printf("queue region config flush error: (%s)\n",
10140 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10141 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10143 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10144 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10146 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10147 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10149 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10150 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10151 cmd, "queue-region");
10152 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10153 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10155 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10156 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10159 cmdline_parse_inst_t cmd_flush_queue_region = {
10160 .f = cmd_flush_queue_region_parsed,
10162 .help_str = "set port <port_id> queue-region flush on|off"
10163 ": flush all queue region related configuration",
10165 (void *)&cmd_flush_queue_region_set,
10166 (void *)&cmd_flush_queue_region_port,
10167 (void *)&cmd_flush_queue_region_port_index,
10168 (void *)&cmd_flush_queue_region_cmd,
10169 (void *)&cmd_flush_queue_region_flush,
10170 (void *)&cmd_flush_queue_region_what,
10175 /* *** get all queue region related configuration info *** */
10176 struct cmd_show_queue_region_info {
10177 cmdline_fixed_string_t show;
10178 cmdline_fixed_string_t port;
10180 cmdline_fixed_string_t cmd;
10184 cmd_show_queue_region_info_parsed(void *parsed_result,
10185 __rte_unused struct cmdline *cl,
10186 __rte_unused void *data)
10188 struct cmd_show_queue_region_info *res = parsed_result;
10189 int ret = -ENOTSUP;
10190 #ifdef RTE_LIBRTE_I40E_PMD
10191 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10192 enum rte_pmd_i40e_queue_region_op op_type;
10195 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10198 #ifdef RTE_LIBRTE_I40E_PMD
10199 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10201 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10203 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10204 op_type, &rte_pmd_regions);
10206 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10213 printf("function not implemented or supported\n");
10216 printf("queue region config info show error: (%s)\n",
10221 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10222 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10224 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10225 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10227 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10228 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10230 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10231 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10232 cmd, "queue-region");
10234 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10235 .f = cmd_show_queue_region_info_parsed,
10237 .help_str = "show port <port_id> queue-region"
10238 ": show all queue region related configuration info",
10240 (void *)&cmd_show_queue_region_info_get,
10241 (void *)&cmd_show_queue_region_info_port,
10242 (void *)&cmd_show_queue_region_info_port_index,
10243 (void *)&cmd_show_queue_region_info_cmd,
10248 /* *** ADD/REMOVE A 2tuple FILTER *** */
10249 struct cmd_2tuple_filter_result {
10250 cmdline_fixed_string_t filter;
10252 cmdline_fixed_string_t ops;
10253 cmdline_fixed_string_t dst_port;
10254 uint16_t dst_port_value;
10255 cmdline_fixed_string_t protocol;
10256 uint8_t protocol_value;
10257 cmdline_fixed_string_t mask;
10258 uint8_t mask_value;
10259 cmdline_fixed_string_t tcp_flags;
10260 uint8_t tcp_flags_value;
10261 cmdline_fixed_string_t priority;
10262 uint8_t priority_value;
10263 cmdline_fixed_string_t queue;
10268 cmd_2tuple_filter_parsed(void *parsed_result,
10269 __rte_unused struct cmdline *cl,
10270 __rte_unused void *data)
10272 struct rte_eth_ntuple_filter filter;
10273 struct cmd_2tuple_filter_result *res = parsed_result;
10276 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10278 printf("ntuple filter is not supported on port %u.\n",
10283 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10285 filter.flags = RTE_2TUPLE_FLAGS;
10286 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10287 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10288 filter.proto = res->protocol_value;
10289 filter.priority = res->priority_value;
10290 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10291 printf("nonzero tcp_flags is only meaningful"
10292 " when protocol is TCP.\n");
10295 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10296 printf("invalid TCP flags.\n");
10300 if (res->tcp_flags_value != 0) {
10301 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10302 filter.tcp_flags = res->tcp_flags_value;
10305 /* need convert to big endian. */
10306 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10307 filter.queue = res->queue_id;
10309 if (!strcmp(res->ops, "add"))
10310 ret = rte_eth_dev_filter_ctrl(res->port_id,
10311 RTE_ETH_FILTER_NTUPLE,
10312 RTE_ETH_FILTER_ADD,
10315 ret = rte_eth_dev_filter_ctrl(res->port_id,
10316 RTE_ETH_FILTER_NTUPLE,
10317 RTE_ETH_FILTER_DELETE,
10320 printf("2tuple filter programming error: (%s)\n",
10325 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10326 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10327 filter, "2tuple_filter");
10328 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10329 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10331 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10332 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10334 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10335 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10336 dst_port, "dst_port");
10337 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10338 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10339 dst_port_value, UINT16);
10340 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10341 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10342 protocol, "protocol");
10343 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10344 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10345 protocol_value, UINT8);
10346 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10347 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10349 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10350 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10352 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10353 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10354 tcp_flags, "tcp_flags");
10355 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10356 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10357 tcp_flags_value, UINT8);
10358 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10359 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10360 priority, "priority");
10361 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10362 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10363 priority_value, UINT8);
10364 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10365 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10367 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10368 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10371 cmdline_parse_inst_t cmd_2tuple_filter = {
10372 .f = cmd_2tuple_filter_parsed,
10374 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10375 "<value> mask <value> tcp_flags <value> priority <value> queue "
10376 "<queue_id>: Add a 2tuple filter",
10378 (void *)&cmd_2tuple_filter_filter,
10379 (void *)&cmd_2tuple_filter_port_id,
10380 (void *)&cmd_2tuple_filter_ops,
10381 (void *)&cmd_2tuple_filter_dst_port,
10382 (void *)&cmd_2tuple_filter_dst_port_value,
10383 (void *)&cmd_2tuple_filter_protocol,
10384 (void *)&cmd_2tuple_filter_protocol_value,
10385 (void *)&cmd_2tuple_filter_mask,
10386 (void *)&cmd_2tuple_filter_mask_value,
10387 (void *)&cmd_2tuple_filter_tcp_flags,
10388 (void *)&cmd_2tuple_filter_tcp_flags_value,
10389 (void *)&cmd_2tuple_filter_priority,
10390 (void *)&cmd_2tuple_filter_priority_value,
10391 (void *)&cmd_2tuple_filter_queue,
10392 (void *)&cmd_2tuple_filter_queue_id,
10397 /* *** ADD/REMOVE A 5tuple FILTER *** */
10398 struct cmd_5tuple_filter_result {
10399 cmdline_fixed_string_t filter;
10401 cmdline_fixed_string_t ops;
10402 cmdline_fixed_string_t dst_ip;
10403 cmdline_ipaddr_t dst_ip_value;
10404 cmdline_fixed_string_t src_ip;
10405 cmdline_ipaddr_t src_ip_value;
10406 cmdline_fixed_string_t dst_port;
10407 uint16_t dst_port_value;
10408 cmdline_fixed_string_t src_port;
10409 uint16_t src_port_value;
10410 cmdline_fixed_string_t protocol;
10411 uint8_t protocol_value;
10412 cmdline_fixed_string_t mask;
10413 uint8_t mask_value;
10414 cmdline_fixed_string_t tcp_flags;
10415 uint8_t tcp_flags_value;
10416 cmdline_fixed_string_t priority;
10417 uint8_t priority_value;
10418 cmdline_fixed_string_t queue;
10423 cmd_5tuple_filter_parsed(void *parsed_result,
10424 __rte_unused struct cmdline *cl,
10425 __rte_unused void *data)
10427 struct rte_eth_ntuple_filter filter;
10428 struct cmd_5tuple_filter_result *res = parsed_result;
10431 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10433 printf("ntuple filter is not supported on port %u.\n",
10438 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10440 filter.flags = RTE_5TUPLE_FLAGS;
10441 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10442 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10443 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10444 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10445 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10446 filter.proto = res->protocol_value;
10447 filter.priority = res->priority_value;
10448 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10449 printf("nonzero tcp_flags is only meaningful"
10450 " when protocol is TCP.\n");
10453 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10454 printf("invalid TCP flags.\n");
10458 if (res->tcp_flags_value != 0) {
10459 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10460 filter.tcp_flags = res->tcp_flags_value;
10463 if (res->dst_ip_value.family == AF_INET)
10464 /* no need to convert, already big endian. */
10465 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10467 if (filter.dst_ip_mask == 0) {
10468 printf("can not support ipv6 involved compare.\n");
10474 if (res->src_ip_value.family == AF_INET)
10475 /* no need to convert, already big endian. */
10476 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10478 if (filter.src_ip_mask == 0) {
10479 printf("can not support ipv6 involved compare.\n");
10484 /* need convert to big endian. */
10485 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10486 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10487 filter.queue = res->queue_id;
10489 if (!strcmp(res->ops, "add"))
10490 ret = rte_eth_dev_filter_ctrl(res->port_id,
10491 RTE_ETH_FILTER_NTUPLE,
10492 RTE_ETH_FILTER_ADD,
10495 ret = rte_eth_dev_filter_ctrl(res->port_id,
10496 RTE_ETH_FILTER_NTUPLE,
10497 RTE_ETH_FILTER_DELETE,
10500 printf("5tuple filter programming error: (%s)\n",
10504 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10505 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10506 filter, "5tuple_filter");
10507 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10508 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10510 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10511 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10513 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10514 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10516 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10517 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10519 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10520 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10522 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10523 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10525 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10526 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10527 dst_port, "dst_port");
10528 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10529 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10530 dst_port_value, UINT16);
10531 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10532 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10533 src_port, "src_port");
10534 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10535 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10536 src_port_value, UINT16);
10537 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10538 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10539 protocol, "protocol");
10540 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10541 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10542 protocol_value, UINT8);
10543 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10544 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10546 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10547 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10549 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10550 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10551 tcp_flags, "tcp_flags");
10552 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10553 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10554 tcp_flags_value, UINT8);
10555 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10556 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10557 priority, "priority");
10558 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10559 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10560 priority_value, UINT8);
10561 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10562 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10564 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10565 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10568 cmdline_parse_inst_t cmd_5tuple_filter = {
10569 .f = cmd_5tuple_filter_parsed,
10571 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10572 "src_ip <value> dst_port <value> src_port <value> "
10573 "protocol <value> mask <value> tcp_flags <value> "
10574 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10576 (void *)&cmd_5tuple_filter_filter,
10577 (void *)&cmd_5tuple_filter_port_id,
10578 (void *)&cmd_5tuple_filter_ops,
10579 (void *)&cmd_5tuple_filter_dst_ip,
10580 (void *)&cmd_5tuple_filter_dst_ip_value,
10581 (void *)&cmd_5tuple_filter_src_ip,
10582 (void *)&cmd_5tuple_filter_src_ip_value,
10583 (void *)&cmd_5tuple_filter_dst_port,
10584 (void *)&cmd_5tuple_filter_dst_port_value,
10585 (void *)&cmd_5tuple_filter_src_port,
10586 (void *)&cmd_5tuple_filter_src_port_value,
10587 (void *)&cmd_5tuple_filter_protocol,
10588 (void *)&cmd_5tuple_filter_protocol_value,
10589 (void *)&cmd_5tuple_filter_mask,
10590 (void *)&cmd_5tuple_filter_mask_value,
10591 (void *)&cmd_5tuple_filter_tcp_flags,
10592 (void *)&cmd_5tuple_filter_tcp_flags_value,
10593 (void *)&cmd_5tuple_filter_priority,
10594 (void *)&cmd_5tuple_filter_priority_value,
10595 (void *)&cmd_5tuple_filter_queue,
10596 (void *)&cmd_5tuple_filter_queue_id,
10601 /* *** ADD/REMOVE A flex FILTER *** */
10602 struct cmd_flex_filter_result {
10603 cmdline_fixed_string_t filter;
10604 cmdline_fixed_string_t ops;
10606 cmdline_fixed_string_t len;
10608 cmdline_fixed_string_t bytes;
10609 cmdline_fixed_string_t bytes_value;
10610 cmdline_fixed_string_t mask;
10611 cmdline_fixed_string_t mask_value;
10612 cmdline_fixed_string_t priority;
10613 uint8_t priority_value;
10614 cmdline_fixed_string_t queue;
10618 static int xdigit2val(unsigned char c)
10623 else if (isupper(c))
10624 val = c - 'A' + 10;
10626 val = c - 'a' + 10;
10631 cmd_flex_filter_parsed(void *parsed_result,
10632 __rte_unused struct cmdline *cl,
10633 __rte_unused void *data)
10636 struct rte_eth_flex_filter filter;
10637 struct cmd_flex_filter_result *res = parsed_result;
10638 char *bytes_ptr, *mask_ptr;
10639 uint16_t len, i, j = 0;
10644 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10645 printf("the len exceed the max length 128\n");
10648 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10649 filter.len = res->len_value;
10650 filter.priority = res->priority_value;
10651 filter.queue = res->queue_id;
10652 bytes_ptr = res->bytes_value;
10653 mask_ptr = res->mask_value;
10655 /* translate bytes string to array. */
10656 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10657 (bytes_ptr[1] == 'X')))
10659 len = strnlen(bytes_ptr, res->len_value * 2);
10660 if (len == 0 || (len % 8 != 0)) {
10661 printf("please check len and bytes input\n");
10664 for (i = 0; i < len; i++) {
10666 if (isxdigit(c) == 0) {
10667 /* invalid characters. */
10668 printf("invalid input\n");
10671 val = xdigit2val(c);
10674 filter.bytes[j] = byte;
10675 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10682 /* translate mask string to uint8_t array. */
10683 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10684 (mask_ptr[1] == 'X')))
10686 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10688 printf("invalid input\n");
10693 for (i = 0; i < len; i++) {
10695 if (isxdigit(c) == 0) {
10696 /* invalid characters. */
10697 printf("invalid input\n");
10700 val = xdigit2val(c);
10703 filter.mask[j] = byte;
10704 printf("mask[%d]:%02x ", j, filter.mask[j]);
10712 if (!strcmp(res->ops, "add"))
10713 ret = rte_eth_dev_filter_ctrl(res->port_id,
10714 RTE_ETH_FILTER_FLEXIBLE,
10715 RTE_ETH_FILTER_ADD,
10718 ret = rte_eth_dev_filter_ctrl(res->port_id,
10719 RTE_ETH_FILTER_FLEXIBLE,
10720 RTE_ETH_FILTER_DELETE,
10724 printf("flex filter setting error: (%s)\n", strerror(-ret));
10727 cmdline_parse_token_string_t cmd_flex_filter_filter =
10728 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10729 filter, "flex_filter");
10730 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10731 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10733 cmdline_parse_token_string_t cmd_flex_filter_ops =
10734 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10736 cmdline_parse_token_string_t cmd_flex_filter_len =
10737 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10739 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10740 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10742 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10743 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10745 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10746 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10747 bytes_value, NULL);
10748 cmdline_parse_token_string_t cmd_flex_filter_mask =
10749 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10751 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10752 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10754 cmdline_parse_token_string_t cmd_flex_filter_priority =
10755 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10756 priority, "priority");
10757 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10758 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10759 priority_value, UINT8);
10760 cmdline_parse_token_string_t cmd_flex_filter_queue =
10761 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10763 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10764 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10766 cmdline_parse_inst_t cmd_flex_filter = {
10767 .f = cmd_flex_filter_parsed,
10769 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10770 "<value> mask <value> priority <value> queue <queue_id>: "
10771 "Add/Del a flex filter",
10773 (void *)&cmd_flex_filter_filter,
10774 (void *)&cmd_flex_filter_port_id,
10775 (void *)&cmd_flex_filter_ops,
10776 (void *)&cmd_flex_filter_len,
10777 (void *)&cmd_flex_filter_len_value,
10778 (void *)&cmd_flex_filter_bytes,
10779 (void *)&cmd_flex_filter_bytes_value,
10780 (void *)&cmd_flex_filter_mask,
10781 (void *)&cmd_flex_filter_mask_value,
10782 (void *)&cmd_flex_filter_priority,
10783 (void *)&cmd_flex_filter_priority_value,
10784 (void *)&cmd_flex_filter_queue,
10785 (void *)&cmd_flex_filter_queue_id,
10790 /* *** Filters Control *** */
10792 /* *** deal with ethertype filter *** */
10793 struct cmd_ethertype_filter_result {
10794 cmdline_fixed_string_t filter;
10796 cmdline_fixed_string_t ops;
10797 cmdline_fixed_string_t mac;
10798 struct rte_ether_addr mac_addr;
10799 cmdline_fixed_string_t ethertype;
10800 uint16_t ethertype_value;
10801 cmdline_fixed_string_t drop;
10802 cmdline_fixed_string_t queue;
10806 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10807 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10808 filter, "ethertype_filter");
10809 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10810 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10812 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10813 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10815 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10816 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10817 mac, "mac_addr#mac_ignr");
10818 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10819 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10821 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10822 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10823 ethertype, "ethertype");
10824 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10825 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10826 ethertype_value, UINT16);
10827 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10828 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10830 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10831 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10833 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10834 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10838 cmd_ethertype_filter_parsed(void *parsed_result,
10839 __rte_unused struct cmdline *cl,
10840 __rte_unused void *data)
10842 struct cmd_ethertype_filter_result *res = parsed_result;
10843 struct rte_eth_ethertype_filter filter;
10846 ret = rte_eth_dev_filter_supported(res->port_id,
10847 RTE_ETH_FILTER_ETHERTYPE);
10849 printf("ethertype filter is not supported on port %u.\n",
10854 memset(&filter, 0, sizeof(filter));
10855 if (!strcmp(res->mac, "mac_addr")) {
10856 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10857 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10858 sizeof(struct rte_ether_addr));
10860 if (!strcmp(res->drop, "drop"))
10861 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10862 filter.ether_type = res->ethertype_value;
10863 filter.queue = res->queue_id;
10865 if (!strcmp(res->ops, "add"))
10866 ret = rte_eth_dev_filter_ctrl(res->port_id,
10867 RTE_ETH_FILTER_ETHERTYPE,
10868 RTE_ETH_FILTER_ADD,
10871 ret = rte_eth_dev_filter_ctrl(res->port_id,
10872 RTE_ETH_FILTER_ETHERTYPE,
10873 RTE_ETH_FILTER_DELETE,
10876 printf("ethertype filter programming error: (%s)\n",
10880 cmdline_parse_inst_t cmd_ethertype_filter = {
10881 .f = cmd_ethertype_filter_parsed,
10883 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10884 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10885 "Add or delete an ethertype filter entry",
10887 (void *)&cmd_ethertype_filter_filter,
10888 (void *)&cmd_ethertype_filter_port_id,
10889 (void *)&cmd_ethertype_filter_ops,
10890 (void *)&cmd_ethertype_filter_mac,
10891 (void *)&cmd_ethertype_filter_mac_addr,
10892 (void *)&cmd_ethertype_filter_ethertype,
10893 (void *)&cmd_ethertype_filter_ethertype_value,
10894 (void *)&cmd_ethertype_filter_drop,
10895 (void *)&cmd_ethertype_filter_queue,
10896 (void *)&cmd_ethertype_filter_queue_id,
10901 /* *** deal with flow director filter *** */
10902 struct cmd_flow_director_result {
10903 cmdline_fixed_string_t flow_director_filter;
10905 cmdline_fixed_string_t mode;
10906 cmdline_fixed_string_t mode_value;
10907 cmdline_fixed_string_t ops;
10908 cmdline_fixed_string_t flow;
10909 cmdline_fixed_string_t flow_type;
10910 cmdline_fixed_string_t ether;
10911 uint16_t ether_type;
10912 cmdline_fixed_string_t src;
10913 cmdline_ipaddr_t ip_src;
10915 cmdline_fixed_string_t dst;
10916 cmdline_ipaddr_t ip_dst;
10918 cmdline_fixed_string_t verify_tag;
10919 uint32_t verify_tag_value;
10920 cmdline_fixed_string_t tos;
10922 cmdline_fixed_string_t proto;
10923 uint8_t proto_value;
10924 cmdline_fixed_string_t ttl;
10926 cmdline_fixed_string_t vlan;
10927 uint16_t vlan_value;
10928 cmdline_fixed_string_t flexbytes;
10929 cmdline_fixed_string_t flexbytes_value;
10930 cmdline_fixed_string_t pf_vf;
10931 cmdline_fixed_string_t drop;
10932 cmdline_fixed_string_t queue;
10934 cmdline_fixed_string_t fd_id;
10935 uint32_t fd_id_value;
10936 cmdline_fixed_string_t mac;
10937 struct rte_ether_addr mac_addr;
10938 cmdline_fixed_string_t tunnel;
10939 cmdline_fixed_string_t tunnel_type;
10940 cmdline_fixed_string_t tunnel_id;
10941 uint32_t tunnel_id_value;
10942 cmdline_fixed_string_t packet;
10947 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10950 const char *p, *p0 = q_arg;
10952 unsigned long int_fld;
10953 char *str_fld[max_num];
10958 p = strchr(p0, '(');
10962 p0 = strchr(p, ')');
10967 if (size >= sizeof(s))
10970 snprintf(s, sizeof(s), "%.*s", size, p);
10971 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10972 if (ret < 0 || ret > max_num)
10974 for (i = 0; i < ret; i++) {
10976 int_fld = strtoul(str_fld[i], &end, 0);
10977 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10979 flexbytes[i] = (uint8_t)int_fld;
10985 str2flowtype(char *string)
10988 static const struct {
10991 } flowtype_str[] = {
10992 {"raw", RTE_ETH_FLOW_RAW},
10993 {"ipv4", RTE_ETH_FLOW_IPV4},
10994 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10995 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10996 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10997 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10998 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10999 {"ipv6", RTE_ETH_FLOW_IPV6},
11000 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11001 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11002 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11003 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11004 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11005 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11008 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11009 if (!strcmp(flowtype_str[i].str, string))
11010 return flowtype_str[i].type;
11013 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11014 return (uint16_t)atoi(string);
11016 return RTE_ETH_FLOW_UNKNOWN;
11019 static enum rte_eth_fdir_tunnel_type
11020 str2fdir_tunneltype(char *string)
11024 static const struct {
11026 enum rte_eth_fdir_tunnel_type type;
11027 } tunneltype_str[] = {
11028 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11029 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11032 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11033 if (!strcmp(tunneltype_str[i].str, string))
11034 return tunneltype_str[i].type;
11036 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11039 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11041 if ((ip_addr).family == AF_INET) \
11042 (ip) = (ip_addr).addr.ipv4.s_addr; \
11044 printf("invalid parameter.\n"); \
11049 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11051 if ((ip_addr).family == AF_INET6) \
11052 rte_memcpy(&(ip), \
11053 &((ip_addr).addr.ipv6), \
11054 sizeof(struct in6_addr)); \
11056 printf("invalid parameter.\n"); \
11062 cmd_flow_director_filter_parsed(void *parsed_result,
11063 __rte_unused struct cmdline *cl,
11064 __rte_unused void *data)
11066 struct cmd_flow_director_result *res = parsed_result;
11067 struct rte_eth_fdir_filter entry;
11068 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11070 unsigned long vf_id;
11073 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11075 printf("flow director is not supported on port %u.\n",
11079 memset(flexbytes, 0, sizeof(flexbytes));
11080 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11082 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11083 if (strcmp(res->mode_value, "MAC-VLAN")) {
11084 printf("Please set mode to MAC-VLAN.\n");
11087 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11088 if (strcmp(res->mode_value, "Tunnel")) {
11089 printf("Please set mode to Tunnel.\n");
11093 if (!strcmp(res->mode_value, "raw")) {
11094 #ifdef RTE_LIBRTE_I40E_PMD
11095 struct rte_pmd_i40e_flow_type_mapping
11096 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11097 struct rte_pmd_i40e_pkt_template_conf conf;
11098 uint16_t flow_type = str2flowtype(res->flow_type);
11099 uint16_t i, port = res->port_id;
11102 memset(&conf, 0, sizeof(conf));
11104 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11105 printf("Invalid flow type specified.\n");
11108 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11112 if (mapping[flow_type].pctype == 0ULL) {
11113 printf("Invalid flow type specified.\n");
11116 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11117 if (mapping[flow_type].pctype & (1ULL << i)) {
11118 conf.input.pctype = i;
11123 conf.input.packet = open_file(res->filepath,
11124 &conf.input.length);
11125 if (!conf.input.packet)
11127 if (!strcmp(res->drop, "drop"))
11128 conf.action.behavior =
11129 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11131 conf.action.behavior =
11132 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11133 conf.action.report_status =
11134 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11135 conf.action.rx_queue = res->queue_id;
11136 conf.soft_id = res->fd_id_value;
11137 add = strcmp(res->ops, "del") ? 1 : 0;
11138 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11142 printf("flow director config error: (%s)\n",
11144 close_file(conf.input.packet);
11147 } else if (strcmp(res->mode_value, "IP")) {
11148 printf("Please set mode to IP or raw.\n");
11151 entry.input.flow_type = str2flowtype(res->flow_type);
11154 ret = parse_flexbytes(res->flexbytes_value,
11156 RTE_ETH_FDIR_MAX_FLEXLEN);
11158 printf("error: Cannot parse flexbytes input.\n");
11162 switch (entry.input.flow_type) {
11163 case RTE_ETH_FLOW_FRAG_IPV4:
11164 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11165 entry.input.flow.ip4_flow.proto = res->proto_value;
11167 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11168 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11169 IPV4_ADDR_TO_UINT(res->ip_dst,
11170 entry.input.flow.ip4_flow.dst_ip);
11171 IPV4_ADDR_TO_UINT(res->ip_src,
11172 entry.input.flow.ip4_flow.src_ip);
11173 entry.input.flow.ip4_flow.tos = res->tos_value;
11174 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11175 /* need convert to big endian. */
11176 entry.input.flow.udp4_flow.dst_port =
11177 rte_cpu_to_be_16(res->port_dst);
11178 entry.input.flow.udp4_flow.src_port =
11179 rte_cpu_to_be_16(res->port_src);
11181 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11182 IPV4_ADDR_TO_UINT(res->ip_dst,
11183 entry.input.flow.sctp4_flow.ip.dst_ip);
11184 IPV4_ADDR_TO_UINT(res->ip_src,
11185 entry.input.flow.sctp4_flow.ip.src_ip);
11186 entry.input.flow.ip4_flow.tos = res->tos_value;
11187 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11188 /* need convert to big endian. */
11189 entry.input.flow.sctp4_flow.dst_port =
11190 rte_cpu_to_be_16(res->port_dst);
11191 entry.input.flow.sctp4_flow.src_port =
11192 rte_cpu_to_be_16(res->port_src);
11193 entry.input.flow.sctp4_flow.verify_tag =
11194 rte_cpu_to_be_32(res->verify_tag_value);
11196 case RTE_ETH_FLOW_FRAG_IPV6:
11197 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11198 entry.input.flow.ipv6_flow.proto = res->proto_value;
11200 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11201 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11202 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11203 entry.input.flow.ipv6_flow.dst_ip);
11204 IPV6_ADDR_TO_ARRAY(res->ip_src,
11205 entry.input.flow.ipv6_flow.src_ip);
11206 entry.input.flow.ipv6_flow.tc = res->tos_value;
11207 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11208 /* need convert to big endian. */
11209 entry.input.flow.udp6_flow.dst_port =
11210 rte_cpu_to_be_16(res->port_dst);
11211 entry.input.flow.udp6_flow.src_port =
11212 rte_cpu_to_be_16(res->port_src);
11214 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11215 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11216 entry.input.flow.sctp6_flow.ip.dst_ip);
11217 IPV6_ADDR_TO_ARRAY(res->ip_src,
11218 entry.input.flow.sctp6_flow.ip.src_ip);
11219 entry.input.flow.ipv6_flow.tc = res->tos_value;
11220 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11221 /* need convert to big endian. */
11222 entry.input.flow.sctp6_flow.dst_port =
11223 rte_cpu_to_be_16(res->port_dst);
11224 entry.input.flow.sctp6_flow.src_port =
11225 rte_cpu_to_be_16(res->port_src);
11226 entry.input.flow.sctp6_flow.verify_tag =
11227 rte_cpu_to_be_32(res->verify_tag_value);
11229 case RTE_ETH_FLOW_L2_PAYLOAD:
11230 entry.input.flow.l2_flow.ether_type =
11231 rte_cpu_to_be_16(res->ether_type);
11237 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11238 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11240 sizeof(struct rte_ether_addr));
11242 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11243 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11245 sizeof(struct rte_ether_addr));
11246 entry.input.flow.tunnel_flow.tunnel_type =
11247 str2fdir_tunneltype(res->tunnel_type);
11248 entry.input.flow.tunnel_flow.tunnel_id =
11249 rte_cpu_to_be_32(res->tunnel_id_value);
11252 rte_memcpy(entry.input.flow_ext.flexbytes,
11254 RTE_ETH_FDIR_MAX_FLEXLEN);
11256 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11258 entry.action.flex_off = 0; /*use 0 by default */
11259 if (!strcmp(res->drop, "drop"))
11260 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11262 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11264 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11265 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11266 if (!strcmp(res->pf_vf, "pf"))
11267 entry.input.flow_ext.is_vf = 0;
11268 else if (!strncmp(res->pf_vf, "vf", 2)) {
11269 struct rte_eth_dev_info dev_info;
11271 ret = eth_dev_info_get_print_err(res->port_id,
11277 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11278 if (errno != 0 || *end != '\0' ||
11279 vf_id >= dev_info.max_vfs) {
11280 printf("invalid parameter %s.\n", res->pf_vf);
11283 entry.input.flow_ext.is_vf = 1;
11284 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11286 printf("invalid parameter %s.\n", res->pf_vf);
11291 /* set to report FD ID by default */
11292 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11293 entry.action.rx_queue = res->queue_id;
11294 entry.soft_id = res->fd_id_value;
11295 if (!strcmp(res->ops, "add"))
11296 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11297 RTE_ETH_FILTER_ADD, &entry);
11298 else if (!strcmp(res->ops, "del"))
11299 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11300 RTE_ETH_FILTER_DELETE, &entry);
11302 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11303 RTE_ETH_FILTER_UPDATE, &entry);
11305 printf("flow director programming error: (%s)\n",
11309 cmdline_parse_token_string_t cmd_flow_director_filter =
11310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11311 flow_director_filter, "flow_director_filter");
11312 cmdline_parse_token_num_t cmd_flow_director_port_id =
11313 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11315 cmdline_parse_token_string_t cmd_flow_director_ops =
11316 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11317 ops, "add#del#update");
11318 cmdline_parse_token_string_t cmd_flow_director_flow =
11319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11321 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11324 cmdline_parse_token_string_t cmd_flow_director_ether =
11325 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11327 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11328 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11329 ether_type, UINT16);
11330 cmdline_parse_token_string_t cmd_flow_director_src =
11331 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11333 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11334 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11336 cmdline_parse_token_num_t cmd_flow_director_port_src =
11337 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11339 cmdline_parse_token_string_t cmd_flow_director_dst =
11340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11342 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11343 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11345 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11346 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11348 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11350 verify_tag, "verify_tag");
11351 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11352 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11353 verify_tag_value, UINT32);
11354 cmdline_parse_token_string_t cmd_flow_director_tos =
11355 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11357 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11358 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11360 cmdline_parse_token_string_t cmd_flow_director_proto =
11361 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11363 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11364 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11365 proto_value, UINT8);
11366 cmdline_parse_token_string_t cmd_flow_director_ttl =
11367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11369 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11370 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11372 cmdline_parse_token_string_t cmd_flow_director_vlan =
11373 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11375 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11376 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11377 vlan_value, UINT16);
11378 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11379 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11380 flexbytes, "flexbytes");
11381 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11383 flexbytes_value, NULL);
11384 cmdline_parse_token_string_t cmd_flow_director_drop =
11385 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11387 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11390 cmdline_parse_token_string_t cmd_flow_director_queue =
11391 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11393 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11394 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11396 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11397 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11399 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11400 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11401 fd_id_value, UINT32);
11403 cmdline_parse_token_string_t cmd_flow_director_mode =
11404 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11406 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11407 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11409 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11410 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11411 mode_value, "MAC-VLAN");
11412 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11413 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11414 mode_value, "Tunnel");
11415 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11416 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11417 mode_value, "raw");
11418 cmdline_parse_token_string_t cmd_flow_director_mac =
11419 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11421 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11422 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11424 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11425 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11427 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11428 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11429 tunnel_type, "NVGRE#VxLAN");
11430 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11431 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11432 tunnel_id, "tunnel-id");
11433 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11434 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11435 tunnel_id_value, UINT32);
11436 cmdline_parse_token_string_t cmd_flow_director_packet =
11437 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11439 cmdline_parse_token_string_t cmd_flow_director_filepath =
11440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11443 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11444 .f = cmd_flow_director_filter_parsed,
11446 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11447 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11448 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11449 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11450 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11451 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11452 "fd_id <fd_id_value>: "
11453 "Add or delete an ip flow director entry on NIC",
11455 (void *)&cmd_flow_director_filter,
11456 (void *)&cmd_flow_director_port_id,
11457 (void *)&cmd_flow_director_mode,
11458 (void *)&cmd_flow_director_mode_ip,
11459 (void *)&cmd_flow_director_ops,
11460 (void *)&cmd_flow_director_flow,
11461 (void *)&cmd_flow_director_flow_type,
11462 (void *)&cmd_flow_director_src,
11463 (void *)&cmd_flow_director_ip_src,
11464 (void *)&cmd_flow_director_dst,
11465 (void *)&cmd_flow_director_ip_dst,
11466 (void *)&cmd_flow_director_tos,
11467 (void *)&cmd_flow_director_tos_value,
11468 (void *)&cmd_flow_director_proto,
11469 (void *)&cmd_flow_director_proto_value,
11470 (void *)&cmd_flow_director_ttl,
11471 (void *)&cmd_flow_director_ttl_value,
11472 (void *)&cmd_flow_director_vlan,
11473 (void *)&cmd_flow_director_vlan_value,
11474 (void *)&cmd_flow_director_flexbytes,
11475 (void *)&cmd_flow_director_flexbytes_value,
11476 (void *)&cmd_flow_director_drop,
11477 (void *)&cmd_flow_director_pf_vf,
11478 (void *)&cmd_flow_director_queue,
11479 (void *)&cmd_flow_director_queue_id,
11480 (void *)&cmd_flow_director_fd_id,
11481 (void *)&cmd_flow_director_fd_id_value,
11486 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11487 .f = cmd_flow_director_filter_parsed,
11489 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11490 "director entry on NIC",
11492 (void *)&cmd_flow_director_filter,
11493 (void *)&cmd_flow_director_port_id,
11494 (void *)&cmd_flow_director_mode,
11495 (void *)&cmd_flow_director_mode_ip,
11496 (void *)&cmd_flow_director_ops,
11497 (void *)&cmd_flow_director_flow,
11498 (void *)&cmd_flow_director_flow_type,
11499 (void *)&cmd_flow_director_src,
11500 (void *)&cmd_flow_director_ip_src,
11501 (void *)&cmd_flow_director_port_src,
11502 (void *)&cmd_flow_director_dst,
11503 (void *)&cmd_flow_director_ip_dst,
11504 (void *)&cmd_flow_director_port_dst,
11505 (void *)&cmd_flow_director_tos,
11506 (void *)&cmd_flow_director_tos_value,
11507 (void *)&cmd_flow_director_ttl,
11508 (void *)&cmd_flow_director_ttl_value,
11509 (void *)&cmd_flow_director_vlan,
11510 (void *)&cmd_flow_director_vlan_value,
11511 (void *)&cmd_flow_director_flexbytes,
11512 (void *)&cmd_flow_director_flexbytes_value,
11513 (void *)&cmd_flow_director_drop,
11514 (void *)&cmd_flow_director_pf_vf,
11515 (void *)&cmd_flow_director_queue,
11516 (void *)&cmd_flow_director_queue_id,
11517 (void *)&cmd_flow_director_fd_id,
11518 (void *)&cmd_flow_director_fd_id_value,
11523 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11524 .f = cmd_flow_director_filter_parsed,
11526 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11527 "director entry on NIC",
11529 (void *)&cmd_flow_director_filter,
11530 (void *)&cmd_flow_director_port_id,
11531 (void *)&cmd_flow_director_mode,
11532 (void *)&cmd_flow_director_mode_ip,
11533 (void *)&cmd_flow_director_ops,
11534 (void *)&cmd_flow_director_flow,
11535 (void *)&cmd_flow_director_flow_type,
11536 (void *)&cmd_flow_director_src,
11537 (void *)&cmd_flow_director_ip_src,
11538 (void *)&cmd_flow_director_port_src,
11539 (void *)&cmd_flow_director_dst,
11540 (void *)&cmd_flow_director_ip_dst,
11541 (void *)&cmd_flow_director_port_dst,
11542 (void *)&cmd_flow_director_verify_tag,
11543 (void *)&cmd_flow_director_verify_tag_value,
11544 (void *)&cmd_flow_director_tos,
11545 (void *)&cmd_flow_director_tos_value,
11546 (void *)&cmd_flow_director_ttl,
11547 (void *)&cmd_flow_director_ttl_value,
11548 (void *)&cmd_flow_director_vlan,
11549 (void *)&cmd_flow_director_vlan_value,
11550 (void *)&cmd_flow_director_flexbytes,
11551 (void *)&cmd_flow_director_flexbytes_value,
11552 (void *)&cmd_flow_director_drop,
11553 (void *)&cmd_flow_director_pf_vf,
11554 (void *)&cmd_flow_director_queue,
11555 (void *)&cmd_flow_director_queue_id,
11556 (void *)&cmd_flow_director_fd_id,
11557 (void *)&cmd_flow_director_fd_id_value,
11562 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11563 .f = cmd_flow_director_filter_parsed,
11565 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11566 "director entry on NIC",
11568 (void *)&cmd_flow_director_filter,
11569 (void *)&cmd_flow_director_port_id,
11570 (void *)&cmd_flow_director_mode,
11571 (void *)&cmd_flow_director_mode_ip,
11572 (void *)&cmd_flow_director_ops,
11573 (void *)&cmd_flow_director_flow,
11574 (void *)&cmd_flow_director_flow_type,
11575 (void *)&cmd_flow_director_ether,
11576 (void *)&cmd_flow_director_ether_type,
11577 (void *)&cmd_flow_director_flexbytes,
11578 (void *)&cmd_flow_director_flexbytes_value,
11579 (void *)&cmd_flow_director_drop,
11580 (void *)&cmd_flow_director_pf_vf,
11581 (void *)&cmd_flow_director_queue,
11582 (void *)&cmd_flow_director_queue_id,
11583 (void *)&cmd_flow_director_fd_id,
11584 (void *)&cmd_flow_director_fd_id_value,
11589 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11590 .f = cmd_flow_director_filter_parsed,
11592 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11593 "director entry on NIC",
11595 (void *)&cmd_flow_director_filter,
11596 (void *)&cmd_flow_director_port_id,
11597 (void *)&cmd_flow_director_mode,
11598 (void *)&cmd_flow_director_mode_mac_vlan,
11599 (void *)&cmd_flow_director_ops,
11600 (void *)&cmd_flow_director_mac,
11601 (void *)&cmd_flow_director_mac_addr,
11602 (void *)&cmd_flow_director_vlan,
11603 (void *)&cmd_flow_director_vlan_value,
11604 (void *)&cmd_flow_director_flexbytes,
11605 (void *)&cmd_flow_director_flexbytes_value,
11606 (void *)&cmd_flow_director_drop,
11607 (void *)&cmd_flow_director_queue,
11608 (void *)&cmd_flow_director_queue_id,
11609 (void *)&cmd_flow_director_fd_id,
11610 (void *)&cmd_flow_director_fd_id_value,
11615 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11616 .f = cmd_flow_director_filter_parsed,
11618 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11619 "director entry on NIC",
11621 (void *)&cmd_flow_director_filter,
11622 (void *)&cmd_flow_director_port_id,
11623 (void *)&cmd_flow_director_mode,
11624 (void *)&cmd_flow_director_mode_tunnel,
11625 (void *)&cmd_flow_director_ops,
11626 (void *)&cmd_flow_director_mac,
11627 (void *)&cmd_flow_director_mac_addr,
11628 (void *)&cmd_flow_director_vlan,
11629 (void *)&cmd_flow_director_vlan_value,
11630 (void *)&cmd_flow_director_tunnel,
11631 (void *)&cmd_flow_director_tunnel_type,
11632 (void *)&cmd_flow_director_tunnel_id,
11633 (void *)&cmd_flow_director_tunnel_id_value,
11634 (void *)&cmd_flow_director_flexbytes,
11635 (void *)&cmd_flow_director_flexbytes_value,
11636 (void *)&cmd_flow_director_drop,
11637 (void *)&cmd_flow_director_queue,
11638 (void *)&cmd_flow_director_queue_id,
11639 (void *)&cmd_flow_director_fd_id,
11640 (void *)&cmd_flow_director_fd_id_value,
11645 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11646 .f = cmd_flow_director_filter_parsed,
11648 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11649 "director entry on NIC",
11651 (void *)&cmd_flow_director_filter,
11652 (void *)&cmd_flow_director_port_id,
11653 (void *)&cmd_flow_director_mode,
11654 (void *)&cmd_flow_director_mode_raw,
11655 (void *)&cmd_flow_director_ops,
11656 (void *)&cmd_flow_director_flow,
11657 (void *)&cmd_flow_director_flow_type,
11658 (void *)&cmd_flow_director_drop,
11659 (void *)&cmd_flow_director_queue,
11660 (void *)&cmd_flow_director_queue_id,
11661 (void *)&cmd_flow_director_fd_id,
11662 (void *)&cmd_flow_director_fd_id_value,
11663 (void *)&cmd_flow_director_packet,
11664 (void *)&cmd_flow_director_filepath,
11669 struct cmd_flush_flow_director_result {
11670 cmdline_fixed_string_t flush_flow_director;
11674 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11675 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11676 flush_flow_director, "flush_flow_director");
11677 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11678 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11682 cmd_flush_flow_director_parsed(void *parsed_result,
11683 __rte_unused struct cmdline *cl,
11684 __rte_unused void *data)
11686 struct cmd_flow_director_result *res = parsed_result;
11689 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11691 printf("flow director is not supported on port %u.\n",
11696 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11697 RTE_ETH_FILTER_FLUSH, NULL);
11699 printf("flow director table flushing error: (%s)\n",
11703 cmdline_parse_inst_t cmd_flush_flow_director = {
11704 .f = cmd_flush_flow_director_parsed,
11706 .help_str = "flush_flow_director <port_id>: "
11707 "Flush all flow director entries of a device on NIC",
11709 (void *)&cmd_flush_flow_director_flush,
11710 (void *)&cmd_flush_flow_director_port_id,
11715 /* *** deal with flow director mask *** */
11716 struct cmd_flow_director_mask_result {
11717 cmdline_fixed_string_t flow_director_mask;
11719 cmdline_fixed_string_t mode;
11720 cmdline_fixed_string_t mode_value;
11721 cmdline_fixed_string_t vlan;
11722 uint16_t vlan_mask;
11723 cmdline_fixed_string_t src_mask;
11724 cmdline_ipaddr_t ipv4_src;
11725 cmdline_ipaddr_t ipv6_src;
11727 cmdline_fixed_string_t dst_mask;
11728 cmdline_ipaddr_t ipv4_dst;
11729 cmdline_ipaddr_t ipv6_dst;
11731 cmdline_fixed_string_t mac;
11732 uint8_t mac_addr_byte_mask;
11733 cmdline_fixed_string_t tunnel_id;
11734 uint32_t tunnel_id_mask;
11735 cmdline_fixed_string_t tunnel_type;
11736 uint8_t tunnel_type_mask;
11740 cmd_flow_director_mask_parsed(void *parsed_result,
11741 __rte_unused struct cmdline *cl,
11742 __rte_unused void *data)
11744 struct cmd_flow_director_mask_result *res = parsed_result;
11745 struct rte_eth_fdir_masks *mask;
11746 struct rte_port *port;
11748 port = &ports[res->port_id];
11749 /** Check if the port is not started **/
11750 if (port->port_status != RTE_PORT_STOPPED) {
11751 printf("Please stop port %d first\n", res->port_id);
11755 mask = &port->dev_conf.fdir_conf.mask;
11757 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11758 if (strcmp(res->mode_value, "MAC-VLAN")) {
11759 printf("Please set mode to MAC-VLAN.\n");
11763 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11764 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11765 if (strcmp(res->mode_value, "Tunnel")) {
11766 printf("Please set mode to Tunnel.\n");
11770 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11771 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11772 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11773 mask->tunnel_type_mask = res->tunnel_type_mask;
11775 if (strcmp(res->mode_value, "IP")) {
11776 printf("Please set mode to IP.\n");
11780 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11781 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11782 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11783 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11784 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11785 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11786 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11789 cmd_reconfig_device_queue(res->port_id, 1, 1);
11792 cmdline_parse_token_string_t cmd_flow_director_mask =
11793 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11794 flow_director_mask, "flow_director_mask");
11795 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11796 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11798 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11801 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11802 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11803 vlan_mask, UINT16);
11804 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11805 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11806 src_mask, "src_mask");
11807 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11808 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11810 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11811 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11813 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11814 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11816 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11817 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11818 dst_mask, "dst_mask");
11819 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11820 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11822 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11823 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11825 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11826 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11829 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11830 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11832 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11833 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11835 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11836 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11837 mode_value, "MAC-VLAN");
11838 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11839 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11840 mode_value, "Tunnel");
11841 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11842 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11844 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11845 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11846 mac_addr_byte_mask, UINT8);
11847 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11848 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11849 tunnel_type, "tunnel-type");
11850 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11851 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11852 tunnel_type_mask, UINT8);
11853 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11854 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11855 tunnel_id, "tunnel-id");
11856 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11857 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11858 tunnel_id_mask, UINT32);
11860 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11861 .f = cmd_flow_director_mask_parsed,
11863 .help_str = "flow_director_mask ... : "
11864 "Set IP mode flow director's mask on NIC",
11866 (void *)&cmd_flow_director_mask,
11867 (void *)&cmd_flow_director_mask_port_id,
11868 (void *)&cmd_flow_director_mask_mode,
11869 (void *)&cmd_flow_director_mask_mode_ip,
11870 (void *)&cmd_flow_director_mask_vlan,
11871 (void *)&cmd_flow_director_mask_vlan_value,
11872 (void *)&cmd_flow_director_mask_src,
11873 (void *)&cmd_flow_director_mask_ipv4_src,
11874 (void *)&cmd_flow_director_mask_ipv6_src,
11875 (void *)&cmd_flow_director_mask_port_src,
11876 (void *)&cmd_flow_director_mask_dst,
11877 (void *)&cmd_flow_director_mask_ipv4_dst,
11878 (void *)&cmd_flow_director_mask_ipv6_dst,
11879 (void *)&cmd_flow_director_mask_port_dst,
11884 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11885 .f = cmd_flow_director_mask_parsed,
11887 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11888 "flow director's mask on NIC",
11890 (void *)&cmd_flow_director_mask,
11891 (void *)&cmd_flow_director_mask_port_id,
11892 (void *)&cmd_flow_director_mask_mode,
11893 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11894 (void *)&cmd_flow_director_mask_vlan,
11895 (void *)&cmd_flow_director_mask_vlan_value,
11900 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11901 .f = cmd_flow_director_mask_parsed,
11903 .help_str = "flow_director_mask ... : Set tunnel mode "
11904 "flow director's mask on NIC",
11906 (void *)&cmd_flow_director_mask,
11907 (void *)&cmd_flow_director_mask_port_id,
11908 (void *)&cmd_flow_director_mask_mode,
11909 (void *)&cmd_flow_director_mask_mode_tunnel,
11910 (void *)&cmd_flow_director_mask_vlan,
11911 (void *)&cmd_flow_director_mask_vlan_value,
11912 (void *)&cmd_flow_director_mask_mac,
11913 (void *)&cmd_flow_director_mask_mac_value,
11914 (void *)&cmd_flow_director_mask_tunnel_type,
11915 (void *)&cmd_flow_director_mask_tunnel_type_value,
11916 (void *)&cmd_flow_director_mask_tunnel_id,
11917 (void *)&cmd_flow_director_mask_tunnel_id_value,
11922 /* *** deal with flow director mask on flexible payload *** */
11923 struct cmd_flow_director_flex_mask_result {
11924 cmdline_fixed_string_t flow_director_flexmask;
11926 cmdline_fixed_string_t flow;
11927 cmdline_fixed_string_t flow_type;
11928 cmdline_fixed_string_t mask;
11932 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11933 __rte_unused struct cmdline *cl,
11934 __rte_unused void *data)
11936 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11937 struct rte_eth_fdir_info fdir_info;
11938 struct rte_eth_fdir_flex_mask flex_mask;
11939 struct rte_port *port;
11940 uint64_t flow_type_mask;
11944 port = &ports[res->port_id];
11945 /** Check if the port is not started **/
11946 if (port->port_status != RTE_PORT_STOPPED) {
11947 printf("Please stop port %d first\n", res->port_id);
11951 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11952 ret = parse_flexbytes(res->mask,
11954 RTE_ETH_FDIR_MAX_FLEXLEN);
11956 printf("error: Cannot parse mask input.\n");
11960 memset(&fdir_info, 0, sizeof(fdir_info));
11961 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11962 RTE_ETH_FILTER_INFO, &fdir_info);
11964 printf("Cannot get FDir filter info\n");
11968 if (!strcmp(res->flow_type, "none")) {
11969 /* means don't specify the flow type */
11970 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11971 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11972 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11973 0, sizeof(struct rte_eth_fdir_flex_mask));
11974 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11975 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11977 sizeof(struct rte_eth_fdir_flex_mask));
11978 cmd_reconfig_device_queue(res->port_id, 1, 1);
11981 flow_type_mask = fdir_info.flow_types_mask[0];
11982 if (!strcmp(res->flow_type, "all")) {
11983 if (!flow_type_mask) {
11984 printf("No flow type supported\n");
11987 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11988 if (flow_type_mask & (1ULL << i)) {
11989 flex_mask.flow_type = i;
11990 fdir_set_flex_mask(res->port_id, &flex_mask);
11993 cmd_reconfig_device_queue(res->port_id, 1, 1);
11996 flex_mask.flow_type = str2flowtype(res->flow_type);
11997 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11998 printf("Flow type %s not supported on port %d\n",
11999 res->flow_type, res->port_id);
12002 fdir_set_flex_mask(res->port_id, &flex_mask);
12003 cmd_reconfig_device_queue(res->port_id, 1, 1);
12006 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12008 flow_director_flexmask,
12009 "flow_director_flex_mask");
12010 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12011 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12013 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12014 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12016 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12017 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12018 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12019 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12020 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12021 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12024 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12025 .f = cmd_flow_director_flex_mask_parsed,
12027 .help_str = "flow_director_flex_mask ... : "
12028 "Set flow director's flex mask on NIC",
12030 (void *)&cmd_flow_director_flexmask,
12031 (void *)&cmd_flow_director_flexmask_port_id,
12032 (void *)&cmd_flow_director_flexmask_flow,
12033 (void *)&cmd_flow_director_flexmask_flow_type,
12034 (void *)&cmd_flow_director_flexmask_mask,
12039 /* *** deal with flow director flexible payload configuration *** */
12040 struct cmd_flow_director_flexpayload_result {
12041 cmdline_fixed_string_t flow_director_flexpayload;
12043 cmdline_fixed_string_t payload_layer;
12044 cmdline_fixed_string_t payload_cfg;
12048 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12051 const char *p, *p0 = q_arg;
12053 unsigned long int_fld;
12054 char *str_fld[max_num];
12059 p = strchr(p0, '(');
12063 p0 = strchr(p, ')');
12068 if (size >= sizeof(s))
12071 snprintf(s, sizeof(s), "%.*s", size, p);
12072 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12073 if (ret < 0 || ret > max_num)
12075 for (i = 0; i < ret; i++) {
12077 int_fld = strtoul(str_fld[i], &end, 0);
12078 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12080 offsets[i] = (uint16_t)int_fld;
12086 cmd_flow_director_flxpld_parsed(void *parsed_result,
12087 __rte_unused struct cmdline *cl,
12088 __rte_unused void *data)
12090 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12091 struct rte_eth_flex_payload_cfg flex_cfg;
12092 struct rte_port *port;
12095 port = &ports[res->port_id];
12096 /** Check if the port is not started **/
12097 if (port->port_status != RTE_PORT_STOPPED) {
12098 printf("Please stop port %d first\n", res->port_id);
12102 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12104 if (!strcmp(res->payload_layer, "raw"))
12105 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12106 else if (!strcmp(res->payload_layer, "l2"))
12107 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12108 else if (!strcmp(res->payload_layer, "l3"))
12109 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12110 else if (!strcmp(res->payload_layer, "l4"))
12111 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12113 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12114 RTE_ETH_FDIR_MAX_FLEXLEN);
12116 printf("error: Cannot parse flex payload input.\n");
12120 fdir_set_flex_payload(res->port_id, &flex_cfg);
12121 cmd_reconfig_device_queue(res->port_id, 1, 1);
12124 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12125 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12126 flow_director_flexpayload,
12127 "flow_director_flex_payload");
12128 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12129 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12131 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12132 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12133 payload_layer, "raw#l2#l3#l4");
12134 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12135 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12136 payload_cfg, NULL);
12138 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12139 .f = cmd_flow_director_flxpld_parsed,
12141 .help_str = "flow_director_flexpayload ... : "
12142 "Set flow director's flex payload on NIC",
12144 (void *)&cmd_flow_director_flexpayload,
12145 (void *)&cmd_flow_director_flexpayload_port_id,
12146 (void *)&cmd_flow_director_flexpayload_payload_layer,
12147 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12152 /* Generic flow interface command. */
12153 extern cmdline_parse_inst_t cmd_flow;
12155 /* *** Classification Filters Control *** */
12156 /* *** Get symmetric hash enable per port *** */
12157 struct cmd_get_sym_hash_ena_per_port_result {
12158 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12163 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12164 __rte_unused struct cmdline *cl,
12165 __rte_unused void *data)
12167 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12168 struct rte_eth_hash_filter_info info;
12171 if (rte_eth_dev_filter_supported(res->port_id,
12172 RTE_ETH_FILTER_HASH) < 0) {
12173 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12178 memset(&info, 0, sizeof(info));
12179 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12180 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12181 RTE_ETH_FILTER_GET, &info);
12184 printf("Cannot get symmetric hash enable per port "
12185 "on port %u\n", res->port_id);
12189 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12190 "enabled" : "disabled", res->port_id);
12193 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12194 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12195 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12196 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12197 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12200 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12201 .f = cmd_get_sym_hash_per_port_parsed,
12203 .help_str = "get_sym_hash_ena_per_port <port_id>",
12205 (void *)&cmd_get_sym_hash_ena_per_port_all,
12206 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12211 /* *** Set symmetric hash enable per port *** */
12212 struct cmd_set_sym_hash_ena_per_port_result {
12213 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12214 cmdline_fixed_string_t enable;
12219 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12220 __rte_unused struct cmdline *cl,
12221 __rte_unused void *data)
12223 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12224 struct rte_eth_hash_filter_info info;
12227 if (rte_eth_dev_filter_supported(res->port_id,
12228 RTE_ETH_FILTER_HASH) < 0) {
12229 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12234 memset(&info, 0, sizeof(info));
12235 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12236 if (!strcmp(res->enable, "enable"))
12237 info.info.enable = 1;
12238 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12239 RTE_ETH_FILTER_SET, &info);
12241 printf("Cannot set symmetric hash enable per port on "
12242 "port %u\n", res->port_id);
12245 printf("Symmetric hash has been set to %s on port %u\n",
12246 res->enable, res->port_id);
12249 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12250 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12251 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12252 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12253 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12255 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12256 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12257 enable, "enable#disable");
12259 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12260 .f = cmd_set_sym_hash_per_port_parsed,
12262 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12264 (void *)&cmd_set_sym_hash_ena_per_port_all,
12265 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12266 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12271 /* Get global config of hash function */
12272 struct cmd_get_hash_global_config_result {
12273 cmdline_fixed_string_t get_hash_global_config;
12278 flowtype_to_str(uint16_t ftype)
12284 } ftype_table[] = {
12285 {"ipv4", RTE_ETH_FLOW_IPV4},
12286 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12287 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12288 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12289 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12290 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12291 {"ipv6", RTE_ETH_FLOW_IPV6},
12292 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12293 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12294 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12295 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12296 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12297 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12298 {"port", RTE_ETH_FLOW_PORT},
12299 {"vxlan", RTE_ETH_FLOW_VXLAN},
12300 {"geneve", RTE_ETH_FLOW_GENEVE},
12301 {"nvgre", RTE_ETH_FLOW_NVGRE},
12302 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12305 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12306 if (ftype_table[i].ftype == ftype)
12307 return ftype_table[i].str;
12314 cmd_get_hash_global_config_parsed(void *parsed_result,
12315 __rte_unused struct cmdline *cl,
12316 __rte_unused void *data)
12318 struct cmd_get_hash_global_config_result *res = parsed_result;
12319 struct rte_eth_hash_filter_info info;
12320 uint32_t idx, offset;
12325 if (rte_eth_dev_filter_supported(res->port_id,
12326 RTE_ETH_FILTER_HASH) < 0) {
12327 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12332 memset(&info, 0, sizeof(info));
12333 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12334 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12335 RTE_ETH_FILTER_GET, &info);
12337 printf("Cannot get hash global configurations by port %d\n",
12342 switch (info.info.global_conf.hash_func) {
12343 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12344 printf("Hash function is Toeplitz\n");
12346 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12347 printf("Hash function is Simple XOR\n");
12349 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12350 printf("Hash function is Symmetric Toeplitz\n");
12353 printf("Unknown hash function\n");
12357 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12358 idx = i / UINT64_BIT;
12359 offset = i % UINT64_BIT;
12360 if (!(info.info.global_conf.valid_bit_mask[idx] &
12363 str = flowtype_to_str(i);
12366 printf("Symmetric hash is %s globally for flow type %s "
12368 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12369 (1ULL << offset)) ? "enabled" : "disabled"), str,
12374 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12375 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12376 get_hash_global_config, "get_hash_global_config");
12377 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12378 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12381 cmdline_parse_inst_t cmd_get_hash_global_config = {
12382 .f = cmd_get_hash_global_config_parsed,
12384 .help_str = "get_hash_global_config <port_id>",
12386 (void *)&cmd_get_hash_global_config_all,
12387 (void *)&cmd_get_hash_global_config_port_id,
12392 /* Set global config of hash function */
12393 struct cmd_set_hash_global_config_result {
12394 cmdline_fixed_string_t set_hash_global_config;
12396 cmdline_fixed_string_t hash_func;
12397 cmdline_fixed_string_t flow_type;
12398 cmdline_fixed_string_t enable;
12402 cmd_set_hash_global_config_parsed(void *parsed_result,
12403 __rte_unused struct cmdline *cl,
12404 __rte_unused void *data)
12406 struct cmd_set_hash_global_config_result *res = parsed_result;
12407 struct rte_eth_hash_filter_info info;
12408 uint32_t ftype, idx, offset;
12411 if (rte_eth_dev_filter_supported(res->port_id,
12412 RTE_ETH_FILTER_HASH) < 0) {
12413 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12417 memset(&info, 0, sizeof(info));
12418 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12419 if (!strcmp(res->hash_func, "toeplitz"))
12420 info.info.global_conf.hash_func =
12421 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12422 else if (!strcmp(res->hash_func, "simple_xor"))
12423 info.info.global_conf.hash_func =
12424 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12425 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12426 info.info.global_conf.hash_func =
12427 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12428 else if (!strcmp(res->hash_func, "default"))
12429 info.info.global_conf.hash_func =
12430 RTE_ETH_HASH_FUNCTION_DEFAULT;
12432 ftype = str2flowtype(res->flow_type);
12433 idx = ftype / UINT64_BIT;
12434 offset = ftype % UINT64_BIT;
12435 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12436 if (!strcmp(res->enable, "enable"))
12437 info.info.global_conf.sym_hash_enable_mask[idx] |=
12439 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12440 RTE_ETH_FILTER_SET, &info);
12442 printf("Cannot set global hash configurations by port %d\n",
12445 printf("Global hash configurations have been set "
12446 "successfully by port %d\n", res->port_id);
12449 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12450 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12451 set_hash_global_config, "set_hash_global_config");
12452 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12453 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12455 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12456 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12457 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12458 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12459 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12461 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12462 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12463 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12464 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12465 enable, "enable#disable");
12467 cmdline_parse_inst_t cmd_set_hash_global_config = {
12468 .f = cmd_set_hash_global_config_parsed,
12470 .help_str = "set_hash_global_config <port_id> "
12471 "toeplitz|simple_xor|symmetric_toeplitz|default "
12472 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12473 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12474 "l2_payload enable|disable",
12476 (void *)&cmd_set_hash_global_config_all,
12477 (void *)&cmd_set_hash_global_config_port_id,
12478 (void *)&cmd_set_hash_global_config_hash_func,
12479 (void *)&cmd_set_hash_global_config_flow_type,
12480 (void *)&cmd_set_hash_global_config_enable,
12485 /* Set hash input set */
12486 struct cmd_set_hash_input_set_result {
12487 cmdline_fixed_string_t set_hash_input_set;
12489 cmdline_fixed_string_t flow_type;
12490 cmdline_fixed_string_t inset_field;
12491 cmdline_fixed_string_t select;
12494 static enum rte_eth_input_set_field
12495 str2inset(char *string)
12499 static const struct {
12501 enum rte_eth_input_set_field inset;
12502 } inset_table[] = {
12503 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12504 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12505 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12506 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12507 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12508 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12509 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12510 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12511 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12512 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12513 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12514 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12515 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12516 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12517 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12518 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12519 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12520 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12521 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12522 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12523 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12524 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12525 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12526 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12527 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12528 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12529 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12530 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12531 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12532 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12533 {"none", RTE_ETH_INPUT_SET_NONE},
12536 for (i = 0; i < RTE_DIM(inset_table); i++) {
12537 if (!strcmp(string, inset_table[i].str))
12538 return inset_table[i].inset;
12541 return RTE_ETH_INPUT_SET_UNKNOWN;
12545 cmd_set_hash_input_set_parsed(void *parsed_result,
12546 __rte_unused struct cmdline *cl,
12547 __rte_unused void *data)
12549 struct cmd_set_hash_input_set_result *res = parsed_result;
12550 struct rte_eth_hash_filter_info info;
12552 memset(&info, 0, sizeof(info));
12553 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12554 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12555 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12556 info.info.input_set_conf.inset_size = 1;
12557 if (!strcmp(res->select, "select"))
12558 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12559 else if (!strcmp(res->select, "add"))
12560 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12561 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12562 RTE_ETH_FILTER_SET, &info);
12565 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12566 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12567 set_hash_input_set, "set_hash_input_set");
12568 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12569 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12571 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12572 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12574 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12575 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12577 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12578 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12579 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12580 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12581 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12583 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12584 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12585 select, "select#add");
12587 cmdline_parse_inst_t cmd_set_hash_input_set = {
12588 .f = cmd_set_hash_input_set_parsed,
12590 .help_str = "set_hash_input_set <port_id> "
12591 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12592 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12593 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12594 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12595 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12596 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12597 "fld-7th|fld-8th|none select|add",
12599 (void *)&cmd_set_hash_input_set_cmd,
12600 (void *)&cmd_set_hash_input_set_port_id,
12601 (void *)&cmd_set_hash_input_set_flow_type,
12602 (void *)&cmd_set_hash_input_set_field,
12603 (void *)&cmd_set_hash_input_set_select,
12608 /* Set flow director input set */
12609 struct cmd_set_fdir_input_set_result {
12610 cmdline_fixed_string_t set_fdir_input_set;
12612 cmdline_fixed_string_t flow_type;
12613 cmdline_fixed_string_t inset_field;
12614 cmdline_fixed_string_t select;
12618 cmd_set_fdir_input_set_parsed(void *parsed_result,
12619 __rte_unused struct cmdline *cl,
12620 __rte_unused void *data)
12622 struct cmd_set_fdir_input_set_result *res = parsed_result;
12623 struct rte_eth_fdir_filter_info info;
12625 memset(&info, 0, sizeof(info));
12626 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12627 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12628 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12629 info.info.input_set_conf.inset_size = 1;
12630 if (!strcmp(res->select, "select"))
12631 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12632 else if (!strcmp(res->select, "add"))
12633 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12634 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12635 RTE_ETH_FILTER_SET, &info);
12638 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12639 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12640 set_fdir_input_set, "set_fdir_input_set");
12641 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12642 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12644 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12645 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12647 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12648 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12649 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12650 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12652 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12653 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12654 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12655 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12656 "sctp-veri-tag#none");
12657 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12658 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12659 select, "select#add");
12661 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12662 .f = cmd_set_fdir_input_set_parsed,
12664 .help_str = "set_fdir_input_set <port_id> "
12665 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12666 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12667 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12668 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12669 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12670 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12671 "sctp-veri-tag|none select|add",
12673 (void *)&cmd_set_fdir_input_set_cmd,
12674 (void *)&cmd_set_fdir_input_set_port_id,
12675 (void *)&cmd_set_fdir_input_set_flow_type,
12676 (void *)&cmd_set_fdir_input_set_field,
12677 (void *)&cmd_set_fdir_input_set_select,
12682 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12683 struct cmd_mcast_addr_result {
12684 cmdline_fixed_string_t mcast_addr_cmd;
12685 cmdline_fixed_string_t what;
12687 struct rte_ether_addr mc_addr;
12690 static void cmd_mcast_addr_parsed(void *parsed_result,
12691 __rte_unused struct cmdline *cl,
12692 __rte_unused void *data)
12694 struct cmd_mcast_addr_result *res = parsed_result;
12696 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12697 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12698 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12699 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12700 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12703 if (strcmp(res->what, "add") == 0)
12704 mcast_addr_add(res->port_num, &res->mc_addr);
12706 mcast_addr_remove(res->port_num, &res->mc_addr);
12709 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12710 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12711 mcast_addr_cmd, "mcast_addr");
12712 cmdline_parse_token_string_t cmd_mcast_addr_what =
12713 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12715 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12716 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12717 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12718 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12720 cmdline_parse_inst_t cmd_mcast_addr = {
12721 .f = cmd_mcast_addr_parsed,
12723 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12724 "Add/Remove multicast MAC address on port_id",
12726 (void *)&cmd_mcast_addr_cmd,
12727 (void *)&cmd_mcast_addr_what,
12728 (void *)&cmd_mcast_addr_portnum,
12729 (void *)&cmd_mcast_addr_addr,
12734 /* l2 tunnel config
12735 * only support E-tag now.
12738 /* Ether type config */
12739 struct cmd_config_l2_tunnel_eth_type_result {
12740 cmdline_fixed_string_t port;
12741 cmdline_fixed_string_t config;
12742 cmdline_fixed_string_t all;
12744 cmdline_fixed_string_t l2_tunnel;
12745 cmdline_fixed_string_t l2_tunnel_type;
12746 cmdline_fixed_string_t eth_type;
12747 uint16_t eth_type_val;
12750 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12751 TOKEN_STRING_INITIALIZER
12752 (struct cmd_config_l2_tunnel_eth_type_result,
12754 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12755 TOKEN_STRING_INITIALIZER
12756 (struct cmd_config_l2_tunnel_eth_type_result,
12758 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12759 TOKEN_STRING_INITIALIZER
12760 (struct cmd_config_l2_tunnel_eth_type_result,
12762 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12763 TOKEN_NUM_INITIALIZER
12764 (struct cmd_config_l2_tunnel_eth_type_result,
12766 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12767 TOKEN_STRING_INITIALIZER
12768 (struct cmd_config_l2_tunnel_eth_type_result,
12769 l2_tunnel, "l2-tunnel");
12770 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12771 TOKEN_STRING_INITIALIZER
12772 (struct cmd_config_l2_tunnel_eth_type_result,
12773 l2_tunnel_type, "E-tag");
12774 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12775 TOKEN_STRING_INITIALIZER
12776 (struct cmd_config_l2_tunnel_eth_type_result,
12777 eth_type, "ether-type");
12778 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12779 TOKEN_NUM_INITIALIZER
12780 (struct cmd_config_l2_tunnel_eth_type_result,
12781 eth_type_val, UINT16);
12783 static enum rte_eth_tunnel_type
12784 str2fdir_l2_tunnel_type(char *string)
12788 static const struct {
12790 enum rte_eth_tunnel_type type;
12791 } l2_tunnel_type_str[] = {
12792 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12795 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12796 if (!strcmp(l2_tunnel_type_str[i].str, string))
12797 return l2_tunnel_type_str[i].type;
12799 return RTE_TUNNEL_TYPE_NONE;
12802 /* ether type config for all ports */
12804 cmd_config_l2_tunnel_eth_type_all_parsed
12805 (void *parsed_result,
12806 __rte_unused struct cmdline *cl,
12807 __rte_unused void *data)
12809 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12810 struct rte_eth_l2_tunnel_conf entry;
12813 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12814 entry.ether_type = res->eth_type_val;
12816 RTE_ETH_FOREACH_DEV(pid) {
12817 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12821 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12822 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12824 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12826 (void *)&cmd_config_l2_tunnel_eth_type_port,
12827 (void *)&cmd_config_l2_tunnel_eth_type_config,
12828 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12829 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12830 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12831 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12832 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12837 /* ether type config for a specific port */
12839 cmd_config_l2_tunnel_eth_type_specific_parsed(
12840 void *parsed_result,
12841 __rte_unused struct cmdline *cl,
12842 __rte_unused void *data)
12844 struct cmd_config_l2_tunnel_eth_type_result *res =
12846 struct rte_eth_l2_tunnel_conf entry;
12848 if (port_id_is_invalid(res->id, ENABLED_WARN))
12851 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12852 entry.ether_type = res->eth_type_val;
12854 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12857 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12858 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12860 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12862 (void *)&cmd_config_l2_tunnel_eth_type_port,
12863 (void *)&cmd_config_l2_tunnel_eth_type_config,
12864 (void *)&cmd_config_l2_tunnel_eth_type_id,
12865 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12866 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12867 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12868 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12873 /* Enable/disable l2 tunnel */
12874 struct cmd_config_l2_tunnel_en_dis_result {
12875 cmdline_fixed_string_t port;
12876 cmdline_fixed_string_t config;
12877 cmdline_fixed_string_t all;
12879 cmdline_fixed_string_t l2_tunnel;
12880 cmdline_fixed_string_t l2_tunnel_type;
12881 cmdline_fixed_string_t en_dis;
12884 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12885 TOKEN_STRING_INITIALIZER
12886 (struct cmd_config_l2_tunnel_en_dis_result,
12888 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12889 TOKEN_STRING_INITIALIZER
12890 (struct cmd_config_l2_tunnel_en_dis_result,
12892 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12893 TOKEN_STRING_INITIALIZER
12894 (struct cmd_config_l2_tunnel_en_dis_result,
12896 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12897 TOKEN_NUM_INITIALIZER
12898 (struct cmd_config_l2_tunnel_en_dis_result,
12900 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12901 TOKEN_STRING_INITIALIZER
12902 (struct cmd_config_l2_tunnel_en_dis_result,
12903 l2_tunnel, "l2-tunnel");
12904 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12905 TOKEN_STRING_INITIALIZER
12906 (struct cmd_config_l2_tunnel_en_dis_result,
12907 l2_tunnel_type, "E-tag");
12908 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12909 TOKEN_STRING_INITIALIZER
12910 (struct cmd_config_l2_tunnel_en_dis_result,
12911 en_dis, "enable#disable");
12913 /* enable/disable l2 tunnel for all ports */
12915 cmd_config_l2_tunnel_en_dis_all_parsed(
12916 void *parsed_result,
12917 __rte_unused struct cmdline *cl,
12918 __rte_unused void *data)
12920 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12921 struct rte_eth_l2_tunnel_conf entry;
12925 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12927 if (!strcmp("enable", res->en_dis))
12932 RTE_ETH_FOREACH_DEV(pid) {
12933 rte_eth_dev_l2_tunnel_offload_set(pid,
12935 ETH_L2_TUNNEL_ENABLE_MASK,
12940 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12941 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12943 .help_str = "port config all l2-tunnel E-tag enable|disable",
12945 (void *)&cmd_config_l2_tunnel_en_dis_port,
12946 (void *)&cmd_config_l2_tunnel_en_dis_config,
12947 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12948 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12949 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12950 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12955 /* enable/disable l2 tunnel for a port */
12957 cmd_config_l2_tunnel_en_dis_specific_parsed(
12958 void *parsed_result,
12959 __rte_unused struct cmdline *cl,
12960 __rte_unused void *data)
12962 struct cmd_config_l2_tunnel_en_dis_result *res =
12964 struct rte_eth_l2_tunnel_conf entry;
12966 if (port_id_is_invalid(res->id, ENABLED_WARN))
12969 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12971 if (!strcmp("enable", res->en_dis))
12972 rte_eth_dev_l2_tunnel_offload_set(res->id,
12974 ETH_L2_TUNNEL_ENABLE_MASK,
12977 rte_eth_dev_l2_tunnel_offload_set(res->id,
12979 ETH_L2_TUNNEL_ENABLE_MASK,
12983 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12984 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12986 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12988 (void *)&cmd_config_l2_tunnel_en_dis_port,
12989 (void *)&cmd_config_l2_tunnel_en_dis_config,
12990 (void *)&cmd_config_l2_tunnel_en_dis_id,
12991 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12992 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12993 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12998 /* E-tag configuration */
13000 /* Common result structure for all E-tag configuration */
13001 struct cmd_config_e_tag_result {
13002 cmdline_fixed_string_t e_tag;
13003 cmdline_fixed_string_t set;
13004 cmdline_fixed_string_t insertion;
13005 cmdline_fixed_string_t stripping;
13006 cmdline_fixed_string_t forwarding;
13007 cmdline_fixed_string_t filter;
13008 cmdline_fixed_string_t add;
13009 cmdline_fixed_string_t del;
13010 cmdline_fixed_string_t on;
13011 cmdline_fixed_string_t off;
13012 cmdline_fixed_string_t on_off;
13013 cmdline_fixed_string_t port_tag_id;
13014 uint32_t port_tag_id_val;
13015 cmdline_fixed_string_t e_tag_id;
13016 uint16_t e_tag_id_val;
13017 cmdline_fixed_string_t dst_pool;
13018 uint8_t dst_pool_val;
13019 cmdline_fixed_string_t port;
13021 cmdline_fixed_string_t vf;
13025 /* Common CLI fields for all E-tag configuration */
13026 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13027 TOKEN_STRING_INITIALIZER
13028 (struct cmd_config_e_tag_result,
13030 cmdline_parse_token_string_t cmd_config_e_tag_set =
13031 TOKEN_STRING_INITIALIZER
13032 (struct cmd_config_e_tag_result,
13034 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13035 TOKEN_STRING_INITIALIZER
13036 (struct cmd_config_e_tag_result,
13037 insertion, "insertion");
13038 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13039 TOKEN_STRING_INITIALIZER
13040 (struct cmd_config_e_tag_result,
13041 stripping, "stripping");
13042 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13043 TOKEN_STRING_INITIALIZER
13044 (struct cmd_config_e_tag_result,
13045 forwarding, "forwarding");
13046 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13047 TOKEN_STRING_INITIALIZER
13048 (struct cmd_config_e_tag_result,
13050 cmdline_parse_token_string_t cmd_config_e_tag_add =
13051 TOKEN_STRING_INITIALIZER
13052 (struct cmd_config_e_tag_result,
13054 cmdline_parse_token_string_t cmd_config_e_tag_del =
13055 TOKEN_STRING_INITIALIZER
13056 (struct cmd_config_e_tag_result,
13058 cmdline_parse_token_string_t cmd_config_e_tag_on =
13059 TOKEN_STRING_INITIALIZER
13060 (struct cmd_config_e_tag_result,
13062 cmdline_parse_token_string_t cmd_config_e_tag_off =
13063 TOKEN_STRING_INITIALIZER
13064 (struct cmd_config_e_tag_result,
13066 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13067 TOKEN_STRING_INITIALIZER
13068 (struct cmd_config_e_tag_result,
13070 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13071 TOKEN_STRING_INITIALIZER
13072 (struct cmd_config_e_tag_result,
13073 port_tag_id, "port-tag-id");
13074 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13075 TOKEN_NUM_INITIALIZER
13076 (struct cmd_config_e_tag_result,
13077 port_tag_id_val, UINT32);
13078 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13079 TOKEN_STRING_INITIALIZER
13080 (struct cmd_config_e_tag_result,
13081 e_tag_id, "e-tag-id");
13082 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13083 TOKEN_NUM_INITIALIZER
13084 (struct cmd_config_e_tag_result,
13085 e_tag_id_val, UINT16);
13086 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13087 TOKEN_STRING_INITIALIZER
13088 (struct cmd_config_e_tag_result,
13089 dst_pool, "dst-pool");
13090 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13091 TOKEN_NUM_INITIALIZER
13092 (struct cmd_config_e_tag_result,
13093 dst_pool_val, UINT8);
13094 cmdline_parse_token_string_t cmd_config_e_tag_port =
13095 TOKEN_STRING_INITIALIZER
13096 (struct cmd_config_e_tag_result,
13098 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13099 TOKEN_NUM_INITIALIZER
13100 (struct cmd_config_e_tag_result,
13102 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13103 TOKEN_STRING_INITIALIZER
13104 (struct cmd_config_e_tag_result,
13106 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13107 TOKEN_NUM_INITIALIZER
13108 (struct cmd_config_e_tag_result,
13111 /* E-tag insertion configuration */
13113 cmd_config_e_tag_insertion_en_parsed(
13114 void *parsed_result,
13115 __rte_unused struct cmdline *cl,
13116 __rte_unused void *data)
13118 struct cmd_config_e_tag_result *res =
13120 struct rte_eth_l2_tunnel_conf entry;
13122 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13125 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13126 entry.tunnel_id = res->port_tag_id_val;
13127 entry.vf_id = res->vf_id;
13128 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13130 ETH_L2_TUNNEL_INSERTION_MASK,
13135 cmd_config_e_tag_insertion_dis_parsed(
13136 void *parsed_result,
13137 __rte_unused struct cmdline *cl,
13138 __rte_unused void *data)
13140 struct cmd_config_e_tag_result *res =
13142 struct rte_eth_l2_tunnel_conf entry;
13144 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13147 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13148 entry.vf_id = res->vf_id;
13150 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13152 ETH_L2_TUNNEL_INSERTION_MASK,
13156 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13157 .f = cmd_config_e_tag_insertion_en_parsed,
13159 .help_str = "E-tag ... : E-tag insertion enable",
13161 (void *)&cmd_config_e_tag_e_tag,
13162 (void *)&cmd_config_e_tag_set,
13163 (void *)&cmd_config_e_tag_insertion,
13164 (void *)&cmd_config_e_tag_on,
13165 (void *)&cmd_config_e_tag_port_tag_id,
13166 (void *)&cmd_config_e_tag_port_tag_id_val,
13167 (void *)&cmd_config_e_tag_port,
13168 (void *)&cmd_config_e_tag_port_id,
13169 (void *)&cmd_config_e_tag_vf,
13170 (void *)&cmd_config_e_tag_vf_id,
13175 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13176 .f = cmd_config_e_tag_insertion_dis_parsed,
13178 .help_str = "E-tag ... : E-tag insertion disable",
13180 (void *)&cmd_config_e_tag_e_tag,
13181 (void *)&cmd_config_e_tag_set,
13182 (void *)&cmd_config_e_tag_insertion,
13183 (void *)&cmd_config_e_tag_off,
13184 (void *)&cmd_config_e_tag_port,
13185 (void *)&cmd_config_e_tag_port_id,
13186 (void *)&cmd_config_e_tag_vf,
13187 (void *)&cmd_config_e_tag_vf_id,
13192 /* E-tag stripping configuration */
13194 cmd_config_e_tag_stripping_parsed(
13195 void *parsed_result,
13196 __rte_unused struct cmdline *cl,
13197 __rte_unused void *data)
13199 struct cmd_config_e_tag_result *res =
13201 struct rte_eth_l2_tunnel_conf entry;
13203 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13206 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13208 if (!strcmp(res->on_off, "on"))
13209 rte_eth_dev_l2_tunnel_offload_set
13212 ETH_L2_TUNNEL_STRIPPING_MASK,
13215 rte_eth_dev_l2_tunnel_offload_set
13218 ETH_L2_TUNNEL_STRIPPING_MASK,
13222 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13223 .f = cmd_config_e_tag_stripping_parsed,
13225 .help_str = "E-tag ... : E-tag stripping enable/disable",
13227 (void *)&cmd_config_e_tag_e_tag,
13228 (void *)&cmd_config_e_tag_set,
13229 (void *)&cmd_config_e_tag_stripping,
13230 (void *)&cmd_config_e_tag_on_off,
13231 (void *)&cmd_config_e_tag_port,
13232 (void *)&cmd_config_e_tag_port_id,
13237 /* E-tag forwarding configuration */
13239 cmd_config_e_tag_forwarding_parsed(
13240 void *parsed_result,
13241 __rte_unused struct cmdline *cl,
13242 __rte_unused void *data)
13244 struct cmd_config_e_tag_result *res = parsed_result;
13245 struct rte_eth_l2_tunnel_conf entry;
13247 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13250 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13252 if (!strcmp(res->on_off, "on"))
13253 rte_eth_dev_l2_tunnel_offload_set
13256 ETH_L2_TUNNEL_FORWARDING_MASK,
13259 rte_eth_dev_l2_tunnel_offload_set
13262 ETH_L2_TUNNEL_FORWARDING_MASK,
13266 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13267 .f = cmd_config_e_tag_forwarding_parsed,
13269 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13271 (void *)&cmd_config_e_tag_e_tag,
13272 (void *)&cmd_config_e_tag_set,
13273 (void *)&cmd_config_e_tag_forwarding,
13274 (void *)&cmd_config_e_tag_on_off,
13275 (void *)&cmd_config_e_tag_port,
13276 (void *)&cmd_config_e_tag_port_id,
13281 /* E-tag filter configuration */
13283 cmd_config_e_tag_filter_add_parsed(
13284 void *parsed_result,
13285 __rte_unused struct cmdline *cl,
13286 __rte_unused void *data)
13288 struct cmd_config_e_tag_result *res = parsed_result;
13289 struct rte_eth_l2_tunnel_conf entry;
13292 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13295 if (res->e_tag_id_val > 0x3fff) {
13296 printf("e-tag-id must be equal or less than 0x3fff.\n");
13300 ret = rte_eth_dev_filter_supported(res->port_id,
13301 RTE_ETH_FILTER_L2_TUNNEL);
13303 printf("E-tag filter is not supported on port %u.\n",
13308 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13309 entry.tunnel_id = res->e_tag_id_val;
13310 entry.pool = res->dst_pool_val;
13312 ret = rte_eth_dev_filter_ctrl(res->port_id,
13313 RTE_ETH_FILTER_L2_TUNNEL,
13314 RTE_ETH_FILTER_ADD,
13317 printf("E-tag filter programming error: (%s)\n",
13321 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13322 .f = cmd_config_e_tag_filter_add_parsed,
13324 .help_str = "E-tag ... : E-tag filter add",
13326 (void *)&cmd_config_e_tag_e_tag,
13327 (void *)&cmd_config_e_tag_set,
13328 (void *)&cmd_config_e_tag_filter,
13329 (void *)&cmd_config_e_tag_add,
13330 (void *)&cmd_config_e_tag_e_tag_id,
13331 (void *)&cmd_config_e_tag_e_tag_id_val,
13332 (void *)&cmd_config_e_tag_dst_pool,
13333 (void *)&cmd_config_e_tag_dst_pool_val,
13334 (void *)&cmd_config_e_tag_port,
13335 (void *)&cmd_config_e_tag_port_id,
13341 cmd_config_e_tag_filter_del_parsed(
13342 void *parsed_result,
13343 __rte_unused struct cmdline *cl,
13344 __rte_unused void *data)
13346 struct cmd_config_e_tag_result *res = parsed_result;
13347 struct rte_eth_l2_tunnel_conf entry;
13350 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13353 if (res->e_tag_id_val > 0x3fff) {
13354 printf("e-tag-id must be less than 0x3fff.\n");
13358 ret = rte_eth_dev_filter_supported(res->port_id,
13359 RTE_ETH_FILTER_L2_TUNNEL);
13361 printf("E-tag filter is not supported on port %u.\n",
13366 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13367 entry.tunnel_id = res->e_tag_id_val;
13369 ret = rte_eth_dev_filter_ctrl(res->port_id,
13370 RTE_ETH_FILTER_L2_TUNNEL,
13371 RTE_ETH_FILTER_DELETE,
13374 printf("E-tag filter programming error: (%s)\n",
13378 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13379 .f = cmd_config_e_tag_filter_del_parsed,
13381 .help_str = "E-tag ... : E-tag filter delete",
13383 (void *)&cmd_config_e_tag_e_tag,
13384 (void *)&cmd_config_e_tag_set,
13385 (void *)&cmd_config_e_tag_filter,
13386 (void *)&cmd_config_e_tag_del,
13387 (void *)&cmd_config_e_tag_e_tag_id,
13388 (void *)&cmd_config_e_tag_e_tag_id_val,
13389 (void *)&cmd_config_e_tag_port,
13390 (void *)&cmd_config_e_tag_port_id,
13395 /* vf vlan anti spoof configuration */
13397 /* Common result structure for vf vlan anti spoof */
13398 struct cmd_vf_vlan_anti_spoof_result {
13399 cmdline_fixed_string_t set;
13400 cmdline_fixed_string_t vf;
13401 cmdline_fixed_string_t vlan;
13402 cmdline_fixed_string_t antispoof;
13405 cmdline_fixed_string_t on_off;
13408 /* Common CLI fields for vf vlan anti spoof enable disable */
13409 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13410 TOKEN_STRING_INITIALIZER
13411 (struct cmd_vf_vlan_anti_spoof_result,
13413 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13414 TOKEN_STRING_INITIALIZER
13415 (struct cmd_vf_vlan_anti_spoof_result,
13417 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13418 TOKEN_STRING_INITIALIZER
13419 (struct cmd_vf_vlan_anti_spoof_result,
13421 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13422 TOKEN_STRING_INITIALIZER
13423 (struct cmd_vf_vlan_anti_spoof_result,
13424 antispoof, "antispoof");
13425 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13426 TOKEN_NUM_INITIALIZER
13427 (struct cmd_vf_vlan_anti_spoof_result,
13429 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13430 TOKEN_NUM_INITIALIZER
13431 (struct cmd_vf_vlan_anti_spoof_result,
13433 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13434 TOKEN_STRING_INITIALIZER
13435 (struct cmd_vf_vlan_anti_spoof_result,
13439 cmd_set_vf_vlan_anti_spoof_parsed(
13440 void *parsed_result,
13441 __rte_unused struct cmdline *cl,
13442 __rte_unused void *data)
13444 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13445 int ret = -ENOTSUP;
13447 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13449 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13452 #ifdef RTE_LIBRTE_IXGBE_PMD
13453 if (ret == -ENOTSUP)
13454 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13455 res->vf_id, is_on);
13457 #ifdef RTE_LIBRTE_I40E_PMD
13458 if (ret == -ENOTSUP)
13459 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13460 res->vf_id, is_on);
13462 #ifdef RTE_LIBRTE_BNXT_PMD
13463 if (ret == -ENOTSUP)
13464 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13465 res->vf_id, is_on);
13472 printf("invalid vf_id %d\n", res->vf_id);
13475 printf("invalid port_id %d\n", res->port_id);
13478 printf("function not implemented\n");
13481 printf("programming error: (%s)\n", strerror(-ret));
13485 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13486 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13488 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13490 (void *)&cmd_vf_vlan_anti_spoof_set,
13491 (void *)&cmd_vf_vlan_anti_spoof_vf,
13492 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13493 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13494 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13495 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13496 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13501 /* vf mac anti spoof configuration */
13503 /* Common result structure for vf mac anti spoof */
13504 struct cmd_vf_mac_anti_spoof_result {
13505 cmdline_fixed_string_t set;
13506 cmdline_fixed_string_t vf;
13507 cmdline_fixed_string_t mac;
13508 cmdline_fixed_string_t antispoof;
13511 cmdline_fixed_string_t on_off;
13514 /* Common CLI fields for vf mac anti spoof enable disable */
13515 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13516 TOKEN_STRING_INITIALIZER
13517 (struct cmd_vf_mac_anti_spoof_result,
13519 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13520 TOKEN_STRING_INITIALIZER
13521 (struct cmd_vf_mac_anti_spoof_result,
13523 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13524 TOKEN_STRING_INITIALIZER
13525 (struct cmd_vf_mac_anti_spoof_result,
13527 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13528 TOKEN_STRING_INITIALIZER
13529 (struct cmd_vf_mac_anti_spoof_result,
13530 antispoof, "antispoof");
13531 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13532 TOKEN_NUM_INITIALIZER
13533 (struct cmd_vf_mac_anti_spoof_result,
13535 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13536 TOKEN_NUM_INITIALIZER
13537 (struct cmd_vf_mac_anti_spoof_result,
13539 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13540 TOKEN_STRING_INITIALIZER
13541 (struct cmd_vf_mac_anti_spoof_result,
13545 cmd_set_vf_mac_anti_spoof_parsed(
13546 void *parsed_result,
13547 __rte_unused struct cmdline *cl,
13548 __rte_unused void *data)
13550 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13551 int ret = -ENOTSUP;
13553 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13555 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13558 #ifdef RTE_LIBRTE_IXGBE_PMD
13559 if (ret == -ENOTSUP)
13560 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13561 res->vf_id, is_on);
13563 #ifdef RTE_LIBRTE_I40E_PMD
13564 if (ret == -ENOTSUP)
13565 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13566 res->vf_id, is_on);
13568 #ifdef RTE_LIBRTE_BNXT_PMD
13569 if (ret == -ENOTSUP)
13570 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13571 res->vf_id, is_on);
13578 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13581 printf("invalid port_id %d\n", res->port_id);
13584 printf("function not implemented\n");
13587 printf("programming error: (%s)\n", strerror(-ret));
13591 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13592 .f = cmd_set_vf_mac_anti_spoof_parsed,
13594 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13596 (void *)&cmd_vf_mac_anti_spoof_set,
13597 (void *)&cmd_vf_mac_anti_spoof_vf,
13598 (void *)&cmd_vf_mac_anti_spoof_mac,
13599 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13600 (void *)&cmd_vf_mac_anti_spoof_port_id,
13601 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13602 (void *)&cmd_vf_mac_anti_spoof_on_off,
13607 /* vf vlan strip queue configuration */
13609 /* Common result structure for vf mac anti spoof */
13610 struct cmd_vf_vlan_stripq_result {
13611 cmdline_fixed_string_t set;
13612 cmdline_fixed_string_t vf;
13613 cmdline_fixed_string_t vlan;
13614 cmdline_fixed_string_t stripq;
13617 cmdline_fixed_string_t on_off;
13620 /* Common CLI fields for vf vlan strip enable disable */
13621 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13622 TOKEN_STRING_INITIALIZER
13623 (struct cmd_vf_vlan_stripq_result,
13625 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13626 TOKEN_STRING_INITIALIZER
13627 (struct cmd_vf_vlan_stripq_result,
13629 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13630 TOKEN_STRING_INITIALIZER
13631 (struct cmd_vf_vlan_stripq_result,
13633 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13634 TOKEN_STRING_INITIALIZER
13635 (struct cmd_vf_vlan_stripq_result,
13637 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13638 TOKEN_NUM_INITIALIZER
13639 (struct cmd_vf_vlan_stripq_result,
13641 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13642 TOKEN_NUM_INITIALIZER
13643 (struct cmd_vf_vlan_stripq_result,
13645 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13646 TOKEN_STRING_INITIALIZER
13647 (struct cmd_vf_vlan_stripq_result,
13651 cmd_set_vf_vlan_stripq_parsed(
13652 void *parsed_result,
13653 __rte_unused struct cmdline *cl,
13654 __rte_unused void *data)
13656 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13657 int ret = -ENOTSUP;
13659 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13661 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13664 #ifdef RTE_LIBRTE_IXGBE_PMD
13665 if (ret == -ENOTSUP)
13666 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13667 res->vf_id, is_on);
13669 #ifdef RTE_LIBRTE_I40E_PMD
13670 if (ret == -ENOTSUP)
13671 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13672 res->vf_id, is_on);
13674 #ifdef RTE_LIBRTE_BNXT_PMD
13675 if (ret == -ENOTSUP)
13676 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13677 res->vf_id, is_on);
13684 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13687 printf("invalid port_id %d\n", res->port_id);
13690 printf("function not implemented\n");
13693 printf("programming error: (%s)\n", strerror(-ret));
13697 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13698 .f = cmd_set_vf_vlan_stripq_parsed,
13700 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13702 (void *)&cmd_vf_vlan_stripq_set,
13703 (void *)&cmd_vf_vlan_stripq_vf,
13704 (void *)&cmd_vf_vlan_stripq_vlan,
13705 (void *)&cmd_vf_vlan_stripq_stripq,
13706 (void *)&cmd_vf_vlan_stripq_port_id,
13707 (void *)&cmd_vf_vlan_stripq_vf_id,
13708 (void *)&cmd_vf_vlan_stripq_on_off,
13713 /* vf vlan insert configuration */
13715 /* Common result structure for vf vlan insert */
13716 struct cmd_vf_vlan_insert_result {
13717 cmdline_fixed_string_t set;
13718 cmdline_fixed_string_t vf;
13719 cmdline_fixed_string_t vlan;
13720 cmdline_fixed_string_t insert;
13726 /* Common CLI fields for vf vlan insert enable disable */
13727 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13728 TOKEN_STRING_INITIALIZER
13729 (struct cmd_vf_vlan_insert_result,
13731 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13732 TOKEN_STRING_INITIALIZER
13733 (struct cmd_vf_vlan_insert_result,
13735 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13736 TOKEN_STRING_INITIALIZER
13737 (struct cmd_vf_vlan_insert_result,
13739 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13740 TOKEN_STRING_INITIALIZER
13741 (struct cmd_vf_vlan_insert_result,
13743 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13744 TOKEN_NUM_INITIALIZER
13745 (struct cmd_vf_vlan_insert_result,
13747 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13748 TOKEN_NUM_INITIALIZER
13749 (struct cmd_vf_vlan_insert_result,
13751 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13752 TOKEN_NUM_INITIALIZER
13753 (struct cmd_vf_vlan_insert_result,
13757 cmd_set_vf_vlan_insert_parsed(
13758 void *parsed_result,
13759 __rte_unused struct cmdline *cl,
13760 __rte_unused void *data)
13762 struct cmd_vf_vlan_insert_result *res = parsed_result;
13763 int ret = -ENOTSUP;
13765 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13768 #ifdef RTE_LIBRTE_IXGBE_PMD
13769 if (ret == -ENOTSUP)
13770 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13773 #ifdef RTE_LIBRTE_I40E_PMD
13774 if (ret == -ENOTSUP)
13775 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13778 #ifdef RTE_LIBRTE_BNXT_PMD
13779 if (ret == -ENOTSUP)
13780 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13788 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13791 printf("invalid port_id %d\n", res->port_id);
13794 printf("function not implemented\n");
13797 printf("programming error: (%s)\n", strerror(-ret));
13801 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13802 .f = cmd_set_vf_vlan_insert_parsed,
13804 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13806 (void *)&cmd_vf_vlan_insert_set,
13807 (void *)&cmd_vf_vlan_insert_vf,
13808 (void *)&cmd_vf_vlan_insert_vlan,
13809 (void *)&cmd_vf_vlan_insert_insert,
13810 (void *)&cmd_vf_vlan_insert_port_id,
13811 (void *)&cmd_vf_vlan_insert_vf_id,
13812 (void *)&cmd_vf_vlan_insert_vlan_id,
13817 /* tx loopback configuration */
13819 /* Common result structure for tx loopback */
13820 struct cmd_tx_loopback_result {
13821 cmdline_fixed_string_t set;
13822 cmdline_fixed_string_t tx;
13823 cmdline_fixed_string_t loopback;
13825 cmdline_fixed_string_t on_off;
13828 /* Common CLI fields for tx loopback enable disable */
13829 cmdline_parse_token_string_t cmd_tx_loopback_set =
13830 TOKEN_STRING_INITIALIZER
13831 (struct cmd_tx_loopback_result,
13833 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13834 TOKEN_STRING_INITIALIZER
13835 (struct cmd_tx_loopback_result,
13837 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13838 TOKEN_STRING_INITIALIZER
13839 (struct cmd_tx_loopback_result,
13840 loopback, "loopback");
13841 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13842 TOKEN_NUM_INITIALIZER
13843 (struct cmd_tx_loopback_result,
13845 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13846 TOKEN_STRING_INITIALIZER
13847 (struct cmd_tx_loopback_result,
13851 cmd_set_tx_loopback_parsed(
13852 void *parsed_result,
13853 __rte_unused struct cmdline *cl,
13854 __rte_unused void *data)
13856 struct cmd_tx_loopback_result *res = parsed_result;
13857 int ret = -ENOTSUP;
13859 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13861 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13864 #ifdef RTE_LIBRTE_IXGBE_PMD
13865 if (ret == -ENOTSUP)
13866 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13868 #ifdef RTE_LIBRTE_I40E_PMD
13869 if (ret == -ENOTSUP)
13870 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13872 #ifdef RTE_LIBRTE_BNXT_PMD
13873 if (ret == -ENOTSUP)
13874 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13876 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13877 if (ret == -ENOTSUP)
13878 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13885 printf("invalid is_on %d\n", is_on);
13888 printf("invalid port_id %d\n", res->port_id);
13891 printf("function not implemented\n");
13894 printf("programming error: (%s)\n", strerror(-ret));
13898 cmdline_parse_inst_t cmd_set_tx_loopback = {
13899 .f = cmd_set_tx_loopback_parsed,
13901 .help_str = "set tx loopback <port_id> on|off",
13903 (void *)&cmd_tx_loopback_set,
13904 (void *)&cmd_tx_loopback_tx,
13905 (void *)&cmd_tx_loopback_loopback,
13906 (void *)&cmd_tx_loopback_port_id,
13907 (void *)&cmd_tx_loopback_on_off,
13912 /* all queues drop enable configuration */
13914 /* Common result structure for all queues drop enable */
13915 struct cmd_all_queues_drop_en_result {
13916 cmdline_fixed_string_t set;
13917 cmdline_fixed_string_t all;
13918 cmdline_fixed_string_t queues;
13919 cmdline_fixed_string_t drop;
13921 cmdline_fixed_string_t on_off;
13924 /* Common CLI fields for tx loopback enable disable */
13925 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13926 TOKEN_STRING_INITIALIZER
13927 (struct cmd_all_queues_drop_en_result,
13929 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13930 TOKEN_STRING_INITIALIZER
13931 (struct cmd_all_queues_drop_en_result,
13933 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13934 TOKEN_STRING_INITIALIZER
13935 (struct cmd_all_queues_drop_en_result,
13937 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13938 TOKEN_STRING_INITIALIZER
13939 (struct cmd_all_queues_drop_en_result,
13941 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13942 TOKEN_NUM_INITIALIZER
13943 (struct cmd_all_queues_drop_en_result,
13945 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13946 TOKEN_STRING_INITIALIZER
13947 (struct cmd_all_queues_drop_en_result,
13951 cmd_set_all_queues_drop_en_parsed(
13952 void *parsed_result,
13953 __rte_unused struct cmdline *cl,
13954 __rte_unused void *data)
13956 struct cmd_all_queues_drop_en_result *res = parsed_result;
13957 int ret = -ENOTSUP;
13958 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13960 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13963 #ifdef RTE_LIBRTE_IXGBE_PMD
13964 if (ret == -ENOTSUP)
13965 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13967 #ifdef RTE_LIBRTE_BNXT_PMD
13968 if (ret == -ENOTSUP)
13969 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13975 printf("invalid is_on %d\n", is_on);
13978 printf("invalid port_id %d\n", res->port_id);
13981 printf("function not implemented\n");
13984 printf("programming error: (%s)\n", strerror(-ret));
13988 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13989 .f = cmd_set_all_queues_drop_en_parsed,
13991 .help_str = "set all queues drop <port_id> on|off",
13993 (void *)&cmd_all_queues_drop_en_set,
13994 (void *)&cmd_all_queues_drop_en_all,
13995 (void *)&cmd_all_queues_drop_en_queues,
13996 (void *)&cmd_all_queues_drop_en_drop,
13997 (void *)&cmd_all_queues_drop_en_port_id,
13998 (void *)&cmd_all_queues_drop_en_on_off,
14003 /* vf split drop enable configuration */
14005 /* Common result structure for vf split drop enable */
14006 struct cmd_vf_split_drop_en_result {
14007 cmdline_fixed_string_t set;
14008 cmdline_fixed_string_t vf;
14009 cmdline_fixed_string_t split;
14010 cmdline_fixed_string_t drop;
14013 cmdline_fixed_string_t on_off;
14016 /* Common CLI fields for vf split drop enable disable */
14017 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14018 TOKEN_STRING_INITIALIZER
14019 (struct cmd_vf_split_drop_en_result,
14021 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14022 TOKEN_STRING_INITIALIZER
14023 (struct cmd_vf_split_drop_en_result,
14025 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14026 TOKEN_STRING_INITIALIZER
14027 (struct cmd_vf_split_drop_en_result,
14029 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14030 TOKEN_STRING_INITIALIZER
14031 (struct cmd_vf_split_drop_en_result,
14033 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14034 TOKEN_NUM_INITIALIZER
14035 (struct cmd_vf_split_drop_en_result,
14037 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14038 TOKEN_NUM_INITIALIZER
14039 (struct cmd_vf_split_drop_en_result,
14041 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14042 TOKEN_STRING_INITIALIZER
14043 (struct cmd_vf_split_drop_en_result,
14047 cmd_set_vf_split_drop_en_parsed(
14048 void *parsed_result,
14049 __rte_unused struct cmdline *cl,
14050 __rte_unused void *data)
14052 struct cmd_vf_split_drop_en_result *res = parsed_result;
14053 int ret = -ENOTSUP;
14054 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14056 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14059 #ifdef RTE_LIBRTE_IXGBE_PMD
14060 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14067 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14070 printf("invalid port_id %d\n", res->port_id);
14073 printf("not supported on port %d\n", res->port_id);
14076 printf("programming error: (%s)\n", strerror(-ret));
14080 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14081 .f = cmd_set_vf_split_drop_en_parsed,
14083 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14085 (void *)&cmd_vf_split_drop_en_set,
14086 (void *)&cmd_vf_split_drop_en_vf,
14087 (void *)&cmd_vf_split_drop_en_split,
14088 (void *)&cmd_vf_split_drop_en_drop,
14089 (void *)&cmd_vf_split_drop_en_port_id,
14090 (void *)&cmd_vf_split_drop_en_vf_id,
14091 (void *)&cmd_vf_split_drop_en_on_off,
14096 /* vf mac address configuration */
14098 /* Common result structure for vf mac address */
14099 struct cmd_set_vf_mac_addr_result {
14100 cmdline_fixed_string_t set;
14101 cmdline_fixed_string_t vf;
14102 cmdline_fixed_string_t mac;
14103 cmdline_fixed_string_t addr;
14106 struct rte_ether_addr mac_addr;
14110 /* Common CLI fields for vf split drop enable disable */
14111 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14112 TOKEN_STRING_INITIALIZER
14113 (struct cmd_set_vf_mac_addr_result,
14115 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14116 TOKEN_STRING_INITIALIZER
14117 (struct cmd_set_vf_mac_addr_result,
14119 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14120 TOKEN_STRING_INITIALIZER
14121 (struct cmd_set_vf_mac_addr_result,
14123 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14124 TOKEN_STRING_INITIALIZER
14125 (struct cmd_set_vf_mac_addr_result,
14127 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14128 TOKEN_NUM_INITIALIZER
14129 (struct cmd_set_vf_mac_addr_result,
14131 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14132 TOKEN_NUM_INITIALIZER
14133 (struct cmd_set_vf_mac_addr_result,
14135 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14136 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14140 cmd_set_vf_mac_addr_parsed(
14141 void *parsed_result,
14142 __rte_unused struct cmdline *cl,
14143 __rte_unused void *data)
14145 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14146 int ret = -ENOTSUP;
14148 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14151 #ifdef RTE_LIBRTE_IXGBE_PMD
14152 if (ret == -ENOTSUP)
14153 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14156 #ifdef RTE_LIBRTE_I40E_PMD
14157 if (ret == -ENOTSUP)
14158 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14161 #ifdef RTE_LIBRTE_BNXT_PMD
14162 if (ret == -ENOTSUP)
14163 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14171 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14174 printf("invalid port_id %d\n", res->port_id);
14177 printf("function not implemented\n");
14180 printf("programming error: (%s)\n", strerror(-ret));
14184 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14185 .f = cmd_set_vf_mac_addr_parsed,
14187 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14189 (void *)&cmd_set_vf_mac_addr_set,
14190 (void *)&cmd_set_vf_mac_addr_vf,
14191 (void *)&cmd_set_vf_mac_addr_mac,
14192 (void *)&cmd_set_vf_mac_addr_addr,
14193 (void *)&cmd_set_vf_mac_addr_port_id,
14194 (void *)&cmd_set_vf_mac_addr_vf_id,
14195 (void *)&cmd_set_vf_mac_addr_mac_addr,
14200 /* MACsec configuration */
14202 /* Common result structure for MACsec offload enable */
14203 struct cmd_macsec_offload_on_result {
14204 cmdline_fixed_string_t set;
14205 cmdline_fixed_string_t macsec;
14206 cmdline_fixed_string_t offload;
14208 cmdline_fixed_string_t on;
14209 cmdline_fixed_string_t encrypt;
14210 cmdline_fixed_string_t en_on_off;
14211 cmdline_fixed_string_t replay_protect;
14212 cmdline_fixed_string_t rp_on_off;
14215 /* Common CLI fields for MACsec offload disable */
14216 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14217 TOKEN_STRING_INITIALIZER
14218 (struct cmd_macsec_offload_on_result,
14220 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14221 TOKEN_STRING_INITIALIZER
14222 (struct cmd_macsec_offload_on_result,
14224 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14225 TOKEN_STRING_INITIALIZER
14226 (struct cmd_macsec_offload_on_result,
14227 offload, "offload");
14228 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14229 TOKEN_NUM_INITIALIZER
14230 (struct cmd_macsec_offload_on_result,
14232 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14233 TOKEN_STRING_INITIALIZER
14234 (struct cmd_macsec_offload_on_result,
14236 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14237 TOKEN_STRING_INITIALIZER
14238 (struct cmd_macsec_offload_on_result,
14239 encrypt, "encrypt");
14240 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14241 TOKEN_STRING_INITIALIZER
14242 (struct cmd_macsec_offload_on_result,
14243 en_on_off, "on#off");
14244 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14245 TOKEN_STRING_INITIALIZER
14246 (struct cmd_macsec_offload_on_result,
14247 replay_protect, "replay-protect");
14248 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14249 TOKEN_STRING_INITIALIZER
14250 (struct cmd_macsec_offload_on_result,
14251 rp_on_off, "on#off");
14254 cmd_set_macsec_offload_on_parsed(
14255 void *parsed_result,
14256 __rte_unused struct cmdline *cl,
14257 __rte_unused void *data)
14259 struct cmd_macsec_offload_on_result *res = parsed_result;
14260 int ret = -ENOTSUP;
14261 portid_t port_id = res->port_id;
14262 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14263 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14264 struct rte_eth_dev_info dev_info;
14266 if (port_id_is_invalid(port_id, ENABLED_WARN))
14268 if (!port_is_stopped(port_id)) {
14269 printf("Please stop port %d first\n", port_id);
14273 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14277 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14278 #ifdef RTE_LIBRTE_IXGBE_PMD
14279 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14287 ports[port_id].dev_conf.txmode.offloads |=
14288 DEV_TX_OFFLOAD_MACSEC_INSERT;
14289 cmd_reconfig_device_queue(port_id, 1, 1);
14292 printf("invalid port_id %d\n", port_id);
14295 printf("not supported on port %d\n", port_id);
14298 printf("programming error: (%s)\n", strerror(-ret));
14302 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14303 .f = cmd_set_macsec_offload_on_parsed,
14305 .help_str = "set macsec offload <port_id> on "
14306 "encrypt on|off replay-protect on|off",
14308 (void *)&cmd_macsec_offload_on_set,
14309 (void *)&cmd_macsec_offload_on_macsec,
14310 (void *)&cmd_macsec_offload_on_offload,
14311 (void *)&cmd_macsec_offload_on_port_id,
14312 (void *)&cmd_macsec_offload_on_on,
14313 (void *)&cmd_macsec_offload_on_encrypt,
14314 (void *)&cmd_macsec_offload_on_en_on_off,
14315 (void *)&cmd_macsec_offload_on_replay_protect,
14316 (void *)&cmd_macsec_offload_on_rp_on_off,
14321 /* Common result structure for MACsec offload disable */
14322 struct cmd_macsec_offload_off_result {
14323 cmdline_fixed_string_t set;
14324 cmdline_fixed_string_t macsec;
14325 cmdline_fixed_string_t offload;
14327 cmdline_fixed_string_t off;
14330 /* Common CLI fields for MACsec offload disable */
14331 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14332 TOKEN_STRING_INITIALIZER
14333 (struct cmd_macsec_offload_off_result,
14335 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14336 TOKEN_STRING_INITIALIZER
14337 (struct cmd_macsec_offload_off_result,
14339 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14340 TOKEN_STRING_INITIALIZER
14341 (struct cmd_macsec_offload_off_result,
14342 offload, "offload");
14343 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14344 TOKEN_NUM_INITIALIZER
14345 (struct cmd_macsec_offload_off_result,
14347 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14348 TOKEN_STRING_INITIALIZER
14349 (struct cmd_macsec_offload_off_result,
14353 cmd_set_macsec_offload_off_parsed(
14354 void *parsed_result,
14355 __rte_unused struct cmdline *cl,
14356 __rte_unused void *data)
14358 struct cmd_macsec_offload_off_result *res = parsed_result;
14359 int ret = -ENOTSUP;
14360 struct rte_eth_dev_info dev_info;
14361 portid_t port_id = res->port_id;
14363 if (port_id_is_invalid(port_id, ENABLED_WARN))
14365 if (!port_is_stopped(port_id)) {
14366 printf("Please stop port %d first\n", port_id);
14370 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14374 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14375 #ifdef RTE_LIBRTE_IXGBE_PMD
14376 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14381 ports[port_id].dev_conf.txmode.offloads &=
14382 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14383 cmd_reconfig_device_queue(port_id, 1, 1);
14386 printf("invalid port_id %d\n", port_id);
14389 printf("not supported on port %d\n", port_id);
14392 printf("programming error: (%s)\n", strerror(-ret));
14396 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14397 .f = cmd_set_macsec_offload_off_parsed,
14399 .help_str = "set macsec offload <port_id> off",
14401 (void *)&cmd_macsec_offload_off_set,
14402 (void *)&cmd_macsec_offload_off_macsec,
14403 (void *)&cmd_macsec_offload_off_offload,
14404 (void *)&cmd_macsec_offload_off_port_id,
14405 (void *)&cmd_macsec_offload_off_off,
14410 /* Common result structure for MACsec secure connection configure */
14411 struct cmd_macsec_sc_result {
14412 cmdline_fixed_string_t set;
14413 cmdline_fixed_string_t macsec;
14414 cmdline_fixed_string_t sc;
14415 cmdline_fixed_string_t tx_rx;
14417 struct rte_ether_addr mac;
14421 /* Common CLI fields for MACsec secure connection configure */
14422 cmdline_parse_token_string_t cmd_macsec_sc_set =
14423 TOKEN_STRING_INITIALIZER
14424 (struct cmd_macsec_sc_result,
14426 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14427 TOKEN_STRING_INITIALIZER
14428 (struct cmd_macsec_sc_result,
14430 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14431 TOKEN_STRING_INITIALIZER
14432 (struct cmd_macsec_sc_result,
14434 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14435 TOKEN_STRING_INITIALIZER
14436 (struct cmd_macsec_sc_result,
14438 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14439 TOKEN_NUM_INITIALIZER
14440 (struct cmd_macsec_sc_result,
14442 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14443 TOKEN_ETHERADDR_INITIALIZER
14444 (struct cmd_macsec_sc_result,
14446 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14447 TOKEN_NUM_INITIALIZER
14448 (struct cmd_macsec_sc_result,
14452 cmd_set_macsec_sc_parsed(
14453 void *parsed_result,
14454 __rte_unused struct cmdline *cl,
14455 __rte_unused void *data)
14457 struct cmd_macsec_sc_result *res = parsed_result;
14458 int ret = -ENOTSUP;
14459 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14461 #ifdef RTE_LIBRTE_IXGBE_PMD
14463 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14464 res->mac.addr_bytes) :
14465 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14466 res->mac.addr_bytes, res->pi);
14468 RTE_SET_USED(is_tx);
14474 printf("invalid port_id %d\n", res->port_id);
14477 printf("not supported on port %d\n", res->port_id);
14480 printf("programming error: (%s)\n", strerror(-ret));
14484 cmdline_parse_inst_t cmd_set_macsec_sc = {
14485 .f = cmd_set_macsec_sc_parsed,
14487 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14489 (void *)&cmd_macsec_sc_set,
14490 (void *)&cmd_macsec_sc_macsec,
14491 (void *)&cmd_macsec_sc_sc,
14492 (void *)&cmd_macsec_sc_tx_rx,
14493 (void *)&cmd_macsec_sc_port_id,
14494 (void *)&cmd_macsec_sc_mac,
14495 (void *)&cmd_macsec_sc_pi,
14500 /* Common result structure for MACsec secure connection configure */
14501 struct cmd_macsec_sa_result {
14502 cmdline_fixed_string_t set;
14503 cmdline_fixed_string_t macsec;
14504 cmdline_fixed_string_t sa;
14505 cmdline_fixed_string_t tx_rx;
14510 cmdline_fixed_string_t key;
14513 /* Common CLI fields for MACsec secure connection configure */
14514 cmdline_parse_token_string_t cmd_macsec_sa_set =
14515 TOKEN_STRING_INITIALIZER
14516 (struct cmd_macsec_sa_result,
14518 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14519 TOKEN_STRING_INITIALIZER
14520 (struct cmd_macsec_sa_result,
14522 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14523 TOKEN_STRING_INITIALIZER
14524 (struct cmd_macsec_sa_result,
14526 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14527 TOKEN_STRING_INITIALIZER
14528 (struct cmd_macsec_sa_result,
14530 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14531 TOKEN_NUM_INITIALIZER
14532 (struct cmd_macsec_sa_result,
14534 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14535 TOKEN_NUM_INITIALIZER
14536 (struct cmd_macsec_sa_result,
14538 cmdline_parse_token_num_t cmd_macsec_sa_an =
14539 TOKEN_NUM_INITIALIZER
14540 (struct cmd_macsec_sa_result,
14542 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14543 TOKEN_NUM_INITIALIZER
14544 (struct cmd_macsec_sa_result,
14546 cmdline_parse_token_string_t cmd_macsec_sa_key =
14547 TOKEN_STRING_INITIALIZER
14548 (struct cmd_macsec_sa_result,
14552 cmd_set_macsec_sa_parsed(
14553 void *parsed_result,
14554 __rte_unused struct cmdline *cl,
14555 __rte_unused void *data)
14557 struct cmd_macsec_sa_result *res = parsed_result;
14558 int ret = -ENOTSUP;
14559 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14560 uint8_t key[16] = { 0 };
14566 key_len = strlen(res->key) / 2;
14570 for (i = 0; i < key_len; i++) {
14571 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14574 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14577 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14580 #ifdef RTE_LIBRTE_IXGBE_PMD
14582 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14583 res->idx, res->an, res->pn, key) :
14584 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14585 res->idx, res->an, res->pn, key);
14587 RTE_SET_USED(is_tx);
14594 printf("invalid idx %d or an %d\n", res->idx, res->an);
14597 printf("invalid port_id %d\n", res->port_id);
14600 printf("not supported on port %d\n", res->port_id);
14603 printf("programming error: (%s)\n", strerror(-ret));
14607 cmdline_parse_inst_t cmd_set_macsec_sa = {
14608 .f = cmd_set_macsec_sa_parsed,
14610 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14612 (void *)&cmd_macsec_sa_set,
14613 (void *)&cmd_macsec_sa_macsec,
14614 (void *)&cmd_macsec_sa_sa,
14615 (void *)&cmd_macsec_sa_tx_rx,
14616 (void *)&cmd_macsec_sa_port_id,
14617 (void *)&cmd_macsec_sa_idx,
14618 (void *)&cmd_macsec_sa_an,
14619 (void *)&cmd_macsec_sa_pn,
14620 (void *)&cmd_macsec_sa_key,
14625 /* VF unicast promiscuous mode configuration */
14627 /* Common result structure for VF unicast promiscuous mode */
14628 struct cmd_vf_promisc_result {
14629 cmdline_fixed_string_t set;
14630 cmdline_fixed_string_t vf;
14631 cmdline_fixed_string_t promisc;
14634 cmdline_fixed_string_t on_off;
14637 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14638 cmdline_parse_token_string_t cmd_vf_promisc_set =
14639 TOKEN_STRING_INITIALIZER
14640 (struct cmd_vf_promisc_result,
14642 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14643 TOKEN_STRING_INITIALIZER
14644 (struct cmd_vf_promisc_result,
14646 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14647 TOKEN_STRING_INITIALIZER
14648 (struct cmd_vf_promisc_result,
14649 promisc, "promisc");
14650 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14651 TOKEN_NUM_INITIALIZER
14652 (struct cmd_vf_promisc_result,
14654 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14655 TOKEN_NUM_INITIALIZER
14656 (struct cmd_vf_promisc_result,
14658 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14659 TOKEN_STRING_INITIALIZER
14660 (struct cmd_vf_promisc_result,
14664 cmd_set_vf_promisc_parsed(
14665 void *parsed_result,
14666 __rte_unused struct cmdline *cl,
14667 __rte_unused void *data)
14669 struct cmd_vf_promisc_result *res = parsed_result;
14670 int ret = -ENOTSUP;
14672 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14674 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14677 #ifdef RTE_LIBRTE_I40E_PMD
14678 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14679 res->vf_id, is_on);
14686 printf("invalid vf_id %d\n", res->vf_id);
14689 printf("invalid port_id %d\n", res->port_id);
14692 printf("function not implemented\n");
14695 printf("programming error: (%s)\n", strerror(-ret));
14699 cmdline_parse_inst_t cmd_set_vf_promisc = {
14700 .f = cmd_set_vf_promisc_parsed,
14702 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14703 "Set unicast promiscuous mode for a VF from the PF",
14705 (void *)&cmd_vf_promisc_set,
14706 (void *)&cmd_vf_promisc_vf,
14707 (void *)&cmd_vf_promisc_promisc,
14708 (void *)&cmd_vf_promisc_port_id,
14709 (void *)&cmd_vf_promisc_vf_id,
14710 (void *)&cmd_vf_promisc_on_off,
14715 /* VF multicast promiscuous mode configuration */
14717 /* Common result structure for VF multicast promiscuous mode */
14718 struct cmd_vf_allmulti_result {
14719 cmdline_fixed_string_t set;
14720 cmdline_fixed_string_t vf;
14721 cmdline_fixed_string_t allmulti;
14724 cmdline_fixed_string_t on_off;
14727 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14728 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14729 TOKEN_STRING_INITIALIZER
14730 (struct cmd_vf_allmulti_result,
14732 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14733 TOKEN_STRING_INITIALIZER
14734 (struct cmd_vf_allmulti_result,
14736 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14737 TOKEN_STRING_INITIALIZER
14738 (struct cmd_vf_allmulti_result,
14739 allmulti, "allmulti");
14740 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14741 TOKEN_NUM_INITIALIZER
14742 (struct cmd_vf_allmulti_result,
14744 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14745 TOKEN_NUM_INITIALIZER
14746 (struct cmd_vf_allmulti_result,
14748 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14749 TOKEN_STRING_INITIALIZER
14750 (struct cmd_vf_allmulti_result,
14754 cmd_set_vf_allmulti_parsed(
14755 void *parsed_result,
14756 __rte_unused struct cmdline *cl,
14757 __rte_unused void *data)
14759 struct cmd_vf_allmulti_result *res = parsed_result;
14760 int ret = -ENOTSUP;
14762 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14764 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14767 #ifdef RTE_LIBRTE_I40E_PMD
14768 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14769 res->vf_id, is_on);
14776 printf("invalid vf_id %d\n", res->vf_id);
14779 printf("invalid port_id %d\n", res->port_id);
14782 printf("function not implemented\n");
14785 printf("programming error: (%s)\n", strerror(-ret));
14789 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14790 .f = cmd_set_vf_allmulti_parsed,
14792 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14793 "Set multicast promiscuous mode for a VF from the PF",
14795 (void *)&cmd_vf_allmulti_set,
14796 (void *)&cmd_vf_allmulti_vf,
14797 (void *)&cmd_vf_allmulti_allmulti,
14798 (void *)&cmd_vf_allmulti_port_id,
14799 (void *)&cmd_vf_allmulti_vf_id,
14800 (void *)&cmd_vf_allmulti_on_off,
14805 /* vf broadcast mode configuration */
14807 /* Common result structure for vf broadcast */
14808 struct cmd_set_vf_broadcast_result {
14809 cmdline_fixed_string_t set;
14810 cmdline_fixed_string_t vf;
14811 cmdline_fixed_string_t broadcast;
14814 cmdline_fixed_string_t on_off;
14817 /* Common CLI fields for vf broadcast enable disable */
14818 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14819 TOKEN_STRING_INITIALIZER
14820 (struct cmd_set_vf_broadcast_result,
14822 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14823 TOKEN_STRING_INITIALIZER
14824 (struct cmd_set_vf_broadcast_result,
14826 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14827 TOKEN_STRING_INITIALIZER
14828 (struct cmd_set_vf_broadcast_result,
14829 broadcast, "broadcast");
14830 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14831 TOKEN_NUM_INITIALIZER
14832 (struct cmd_set_vf_broadcast_result,
14834 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14835 TOKEN_NUM_INITIALIZER
14836 (struct cmd_set_vf_broadcast_result,
14838 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14839 TOKEN_STRING_INITIALIZER
14840 (struct cmd_set_vf_broadcast_result,
14844 cmd_set_vf_broadcast_parsed(
14845 void *parsed_result,
14846 __rte_unused struct cmdline *cl,
14847 __rte_unused void *data)
14849 struct cmd_set_vf_broadcast_result *res = parsed_result;
14850 int ret = -ENOTSUP;
14852 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14854 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14857 #ifdef RTE_LIBRTE_I40E_PMD
14858 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14859 res->vf_id, is_on);
14866 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14869 printf("invalid port_id %d\n", res->port_id);
14872 printf("function not implemented\n");
14875 printf("programming error: (%s)\n", strerror(-ret));
14879 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14880 .f = cmd_set_vf_broadcast_parsed,
14882 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14884 (void *)&cmd_set_vf_broadcast_set,
14885 (void *)&cmd_set_vf_broadcast_vf,
14886 (void *)&cmd_set_vf_broadcast_broadcast,
14887 (void *)&cmd_set_vf_broadcast_port_id,
14888 (void *)&cmd_set_vf_broadcast_vf_id,
14889 (void *)&cmd_set_vf_broadcast_on_off,
14894 /* vf vlan tag configuration */
14896 /* Common result structure for vf vlan tag */
14897 struct cmd_set_vf_vlan_tag_result {
14898 cmdline_fixed_string_t set;
14899 cmdline_fixed_string_t vf;
14900 cmdline_fixed_string_t vlan;
14901 cmdline_fixed_string_t tag;
14904 cmdline_fixed_string_t on_off;
14907 /* Common CLI fields for vf vlan tag enable disable */
14908 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14909 TOKEN_STRING_INITIALIZER
14910 (struct cmd_set_vf_vlan_tag_result,
14912 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14913 TOKEN_STRING_INITIALIZER
14914 (struct cmd_set_vf_vlan_tag_result,
14916 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14917 TOKEN_STRING_INITIALIZER
14918 (struct cmd_set_vf_vlan_tag_result,
14920 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14921 TOKEN_STRING_INITIALIZER
14922 (struct cmd_set_vf_vlan_tag_result,
14924 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14925 TOKEN_NUM_INITIALIZER
14926 (struct cmd_set_vf_vlan_tag_result,
14928 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14929 TOKEN_NUM_INITIALIZER
14930 (struct cmd_set_vf_vlan_tag_result,
14932 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14933 TOKEN_STRING_INITIALIZER
14934 (struct cmd_set_vf_vlan_tag_result,
14938 cmd_set_vf_vlan_tag_parsed(
14939 void *parsed_result,
14940 __rte_unused struct cmdline *cl,
14941 __rte_unused void *data)
14943 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14944 int ret = -ENOTSUP;
14946 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14948 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14951 #ifdef RTE_LIBRTE_I40E_PMD
14952 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14953 res->vf_id, is_on);
14960 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14963 printf("invalid port_id %d\n", res->port_id);
14966 printf("function not implemented\n");
14969 printf("programming error: (%s)\n", strerror(-ret));
14973 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14974 .f = cmd_set_vf_vlan_tag_parsed,
14976 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14978 (void *)&cmd_set_vf_vlan_tag_set,
14979 (void *)&cmd_set_vf_vlan_tag_vf,
14980 (void *)&cmd_set_vf_vlan_tag_vlan,
14981 (void *)&cmd_set_vf_vlan_tag_tag,
14982 (void *)&cmd_set_vf_vlan_tag_port_id,
14983 (void *)&cmd_set_vf_vlan_tag_vf_id,
14984 (void *)&cmd_set_vf_vlan_tag_on_off,
14989 /* Common definition of VF and TC TX bandwidth configuration */
14990 struct cmd_vf_tc_bw_result {
14991 cmdline_fixed_string_t set;
14992 cmdline_fixed_string_t vf;
14993 cmdline_fixed_string_t tc;
14994 cmdline_fixed_string_t tx;
14995 cmdline_fixed_string_t min_bw;
14996 cmdline_fixed_string_t max_bw;
14997 cmdline_fixed_string_t strict_link_prio;
15002 cmdline_fixed_string_t bw_list;
15006 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15007 TOKEN_STRING_INITIALIZER
15008 (struct cmd_vf_tc_bw_result,
15010 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15011 TOKEN_STRING_INITIALIZER
15012 (struct cmd_vf_tc_bw_result,
15014 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15015 TOKEN_STRING_INITIALIZER
15016 (struct cmd_vf_tc_bw_result,
15018 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15019 TOKEN_STRING_INITIALIZER
15020 (struct cmd_vf_tc_bw_result,
15022 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15023 TOKEN_STRING_INITIALIZER
15024 (struct cmd_vf_tc_bw_result,
15025 strict_link_prio, "strict-link-priority");
15026 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15027 TOKEN_STRING_INITIALIZER
15028 (struct cmd_vf_tc_bw_result,
15029 min_bw, "min-bandwidth");
15030 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15031 TOKEN_STRING_INITIALIZER
15032 (struct cmd_vf_tc_bw_result,
15033 max_bw, "max-bandwidth");
15034 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15035 TOKEN_NUM_INITIALIZER
15036 (struct cmd_vf_tc_bw_result,
15038 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15039 TOKEN_NUM_INITIALIZER
15040 (struct cmd_vf_tc_bw_result,
15042 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15043 TOKEN_NUM_INITIALIZER
15044 (struct cmd_vf_tc_bw_result,
15046 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15047 TOKEN_NUM_INITIALIZER
15048 (struct cmd_vf_tc_bw_result,
15050 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15051 TOKEN_STRING_INITIALIZER
15052 (struct cmd_vf_tc_bw_result,
15054 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15055 TOKEN_NUM_INITIALIZER
15056 (struct cmd_vf_tc_bw_result,
15059 /* VF max bandwidth setting */
15061 cmd_vf_max_bw_parsed(
15062 void *parsed_result,
15063 __rte_unused struct cmdline *cl,
15064 __rte_unused void *data)
15066 struct cmd_vf_tc_bw_result *res = parsed_result;
15067 int ret = -ENOTSUP;
15069 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15072 #ifdef RTE_LIBRTE_I40E_PMD
15073 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15074 res->vf_id, res->bw);
15081 printf("invalid vf_id %d or bandwidth %d\n",
15082 res->vf_id, res->bw);
15085 printf("invalid port_id %d\n", res->port_id);
15088 printf("function not implemented\n");
15091 printf("programming error: (%s)\n", strerror(-ret));
15095 cmdline_parse_inst_t cmd_vf_max_bw = {
15096 .f = cmd_vf_max_bw_parsed,
15098 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15100 (void *)&cmd_vf_tc_bw_set,
15101 (void *)&cmd_vf_tc_bw_vf,
15102 (void *)&cmd_vf_tc_bw_tx,
15103 (void *)&cmd_vf_tc_bw_max_bw,
15104 (void *)&cmd_vf_tc_bw_port_id,
15105 (void *)&cmd_vf_tc_bw_vf_id,
15106 (void *)&cmd_vf_tc_bw_bw,
15112 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15117 const char *p, *p0 = str;
15124 p = strchr(p0, '(');
15126 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15130 p0 = strchr(p, ')');
15132 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15136 if (size >= sizeof(s)) {
15137 printf("The string size exceeds the internal buffer size\n");
15140 snprintf(s, sizeof(s), "%.*s", size, p);
15141 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15143 printf("Failed to get the bandwidth list. ");
15147 for (i = 0; i < ret; i++)
15148 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15153 /* TC min bandwidth setting */
15155 cmd_vf_tc_min_bw_parsed(
15156 void *parsed_result,
15157 __rte_unused struct cmdline *cl,
15158 __rte_unused void *data)
15160 struct cmd_vf_tc_bw_result *res = parsed_result;
15163 int ret = -ENOTSUP;
15165 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15168 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15172 #ifdef RTE_LIBRTE_I40E_PMD
15173 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15181 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15184 printf("invalid port_id %d\n", res->port_id);
15187 printf("function not implemented\n");
15190 printf("programming error: (%s)\n", strerror(-ret));
15194 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15195 .f = cmd_vf_tc_min_bw_parsed,
15197 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15198 " <bw1, bw2, ...>",
15200 (void *)&cmd_vf_tc_bw_set,
15201 (void *)&cmd_vf_tc_bw_vf,
15202 (void *)&cmd_vf_tc_bw_tc,
15203 (void *)&cmd_vf_tc_bw_tx,
15204 (void *)&cmd_vf_tc_bw_min_bw,
15205 (void *)&cmd_vf_tc_bw_port_id,
15206 (void *)&cmd_vf_tc_bw_vf_id,
15207 (void *)&cmd_vf_tc_bw_bw_list,
15213 cmd_tc_min_bw_parsed(
15214 void *parsed_result,
15215 __rte_unused struct cmdline *cl,
15216 __rte_unused void *data)
15218 struct cmd_vf_tc_bw_result *res = parsed_result;
15219 struct rte_port *port;
15222 int ret = -ENOTSUP;
15224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15227 port = &ports[res->port_id];
15228 /** Check if the port is not started **/
15229 if (port->port_status != RTE_PORT_STOPPED) {
15230 printf("Please stop port %d first\n", res->port_id);
15234 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15238 #ifdef RTE_LIBRTE_IXGBE_PMD
15239 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15246 printf("invalid bandwidth\n");
15249 printf("invalid port_id %d\n", res->port_id);
15252 printf("function not implemented\n");
15255 printf("programming error: (%s)\n", strerror(-ret));
15259 cmdline_parse_inst_t cmd_tc_min_bw = {
15260 .f = cmd_tc_min_bw_parsed,
15262 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15264 (void *)&cmd_vf_tc_bw_set,
15265 (void *)&cmd_vf_tc_bw_tc,
15266 (void *)&cmd_vf_tc_bw_tx,
15267 (void *)&cmd_vf_tc_bw_min_bw,
15268 (void *)&cmd_vf_tc_bw_port_id,
15269 (void *)&cmd_vf_tc_bw_bw_list,
15274 /* TC max bandwidth setting */
15276 cmd_vf_tc_max_bw_parsed(
15277 void *parsed_result,
15278 __rte_unused struct cmdline *cl,
15279 __rte_unused void *data)
15281 struct cmd_vf_tc_bw_result *res = parsed_result;
15282 int ret = -ENOTSUP;
15284 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15287 #ifdef RTE_LIBRTE_I40E_PMD
15288 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15289 res->tc_no, res->bw);
15296 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15297 res->vf_id, res->tc_no, res->bw);
15300 printf("invalid port_id %d\n", res->port_id);
15303 printf("function not implemented\n");
15306 printf("programming error: (%s)\n", strerror(-ret));
15310 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15311 .f = cmd_vf_tc_max_bw_parsed,
15313 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15316 (void *)&cmd_vf_tc_bw_set,
15317 (void *)&cmd_vf_tc_bw_vf,
15318 (void *)&cmd_vf_tc_bw_tc,
15319 (void *)&cmd_vf_tc_bw_tx,
15320 (void *)&cmd_vf_tc_bw_max_bw,
15321 (void *)&cmd_vf_tc_bw_port_id,
15322 (void *)&cmd_vf_tc_bw_vf_id,
15323 (void *)&cmd_vf_tc_bw_tc_no,
15324 (void *)&cmd_vf_tc_bw_bw,
15330 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15332 /* *** Set Port default Traffic Management Hierarchy *** */
15333 struct cmd_set_port_tm_hierarchy_default_result {
15334 cmdline_fixed_string_t set;
15335 cmdline_fixed_string_t port;
15336 cmdline_fixed_string_t tm;
15337 cmdline_fixed_string_t hierarchy;
15338 cmdline_fixed_string_t def;
15342 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15343 TOKEN_STRING_INITIALIZER(
15344 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15345 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15346 TOKEN_STRING_INITIALIZER(
15347 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15348 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15349 TOKEN_STRING_INITIALIZER(
15350 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15351 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15352 TOKEN_STRING_INITIALIZER(
15353 struct cmd_set_port_tm_hierarchy_default_result,
15354 hierarchy, "hierarchy");
15355 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15356 TOKEN_STRING_INITIALIZER(
15357 struct cmd_set_port_tm_hierarchy_default_result,
15359 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15360 TOKEN_NUM_INITIALIZER(
15361 struct cmd_set_port_tm_hierarchy_default_result,
15364 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15365 __rte_unused struct cmdline *cl,
15366 __rte_unused void *data)
15368 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15369 struct rte_port *p;
15370 portid_t port_id = res->port_id;
15372 if (port_id_is_invalid(port_id, ENABLED_WARN))
15375 p = &ports[port_id];
15377 /* Forward mode: tm */
15378 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15379 printf(" softnicfwd mode not enabled(error)\n");
15383 /* Set the default tm hierarchy */
15384 p->softport.default_tm_hierarchy_enable = 1;
15387 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15388 .f = cmd_set_port_tm_hierarchy_default_parsed,
15390 .help_str = "set port tm hierarchy default <port_id>",
15392 (void *)&cmd_set_port_tm_hierarchy_default_set,
15393 (void *)&cmd_set_port_tm_hierarchy_default_port,
15394 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15395 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15396 (void *)&cmd_set_port_tm_hierarchy_default_default,
15397 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15403 /** Set VXLAN encapsulation details */
15404 struct cmd_set_vxlan_result {
15405 cmdline_fixed_string_t set;
15406 cmdline_fixed_string_t vxlan;
15407 cmdline_fixed_string_t pos_token;
15408 cmdline_fixed_string_t ip_version;
15409 uint32_t vlan_present:1;
15413 cmdline_ipaddr_t ip_src;
15414 cmdline_ipaddr_t ip_dst;
15418 struct rte_ether_addr eth_src;
15419 struct rte_ether_addr eth_dst;
15422 cmdline_parse_token_string_t cmd_set_vxlan_set =
15423 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15424 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15425 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15426 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15427 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15429 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15430 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15431 "vxlan-with-vlan");
15432 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15433 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15435 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15436 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15438 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15439 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15441 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15442 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15443 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15444 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15446 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15447 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15448 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15449 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15451 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15452 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15453 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15454 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15456 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15457 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15458 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15459 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15461 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15462 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15463 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15464 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15466 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15467 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15468 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15469 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15471 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15472 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15473 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15474 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15476 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15477 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15478 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15479 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15481 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15482 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15483 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15484 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15486 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15487 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15489 static void cmd_set_vxlan_parsed(void *parsed_result,
15490 __rte_unused struct cmdline *cl,
15491 __rte_unused void *data)
15493 struct cmd_set_vxlan_result *res = parsed_result;
15498 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15501 vxlan_encap_conf.select_tos_ttl = 0;
15502 if (strcmp(res->vxlan, "vxlan") == 0)
15503 vxlan_encap_conf.select_vlan = 0;
15504 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15505 vxlan_encap_conf.select_vlan = 1;
15506 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15507 vxlan_encap_conf.select_vlan = 0;
15508 vxlan_encap_conf.select_tos_ttl = 1;
15510 if (strcmp(res->ip_version, "ipv4") == 0)
15511 vxlan_encap_conf.select_ipv4 = 1;
15512 else if (strcmp(res->ip_version, "ipv6") == 0)
15513 vxlan_encap_conf.select_ipv4 = 0;
15516 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15517 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15518 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15519 vxlan_encap_conf.ip_tos = res->tos;
15520 vxlan_encap_conf.ip_ttl = res->ttl;
15521 if (vxlan_encap_conf.select_ipv4) {
15522 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15523 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15525 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15526 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15528 if (vxlan_encap_conf.select_vlan)
15529 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15530 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15531 RTE_ETHER_ADDR_LEN);
15532 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15533 RTE_ETHER_ADDR_LEN);
15536 cmdline_parse_inst_t cmd_set_vxlan = {
15537 .f = cmd_set_vxlan_parsed,
15539 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15540 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15541 " eth-src <eth-src> eth-dst <eth-dst>",
15543 (void *)&cmd_set_vxlan_set,
15544 (void *)&cmd_set_vxlan_vxlan,
15545 (void *)&cmd_set_vxlan_ip_version,
15546 (void *)&cmd_set_vxlan_ip_version_value,
15547 (void *)&cmd_set_vxlan_vni,
15548 (void *)&cmd_set_vxlan_vni_value,
15549 (void *)&cmd_set_vxlan_udp_src,
15550 (void *)&cmd_set_vxlan_udp_src_value,
15551 (void *)&cmd_set_vxlan_udp_dst,
15552 (void *)&cmd_set_vxlan_udp_dst_value,
15553 (void *)&cmd_set_vxlan_ip_src,
15554 (void *)&cmd_set_vxlan_ip_src_value,
15555 (void *)&cmd_set_vxlan_ip_dst,
15556 (void *)&cmd_set_vxlan_ip_dst_value,
15557 (void *)&cmd_set_vxlan_eth_src,
15558 (void *)&cmd_set_vxlan_eth_src_value,
15559 (void *)&cmd_set_vxlan_eth_dst,
15560 (void *)&cmd_set_vxlan_eth_dst_value,
15565 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15566 .f = cmd_set_vxlan_parsed,
15568 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15569 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15570 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15571 " eth-dst <eth-dst>",
15573 (void *)&cmd_set_vxlan_set,
15574 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15575 (void *)&cmd_set_vxlan_ip_version,
15576 (void *)&cmd_set_vxlan_ip_version_value,
15577 (void *)&cmd_set_vxlan_vni,
15578 (void *)&cmd_set_vxlan_vni_value,
15579 (void *)&cmd_set_vxlan_udp_src,
15580 (void *)&cmd_set_vxlan_udp_src_value,
15581 (void *)&cmd_set_vxlan_udp_dst,
15582 (void *)&cmd_set_vxlan_udp_dst_value,
15583 (void *)&cmd_set_vxlan_ip_tos,
15584 (void *)&cmd_set_vxlan_ip_tos_value,
15585 (void *)&cmd_set_vxlan_ip_ttl,
15586 (void *)&cmd_set_vxlan_ip_ttl_value,
15587 (void *)&cmd_set_vxlan_ip_src,
15588 (void *)&cmd_set_vxlan_ip_src_value,
15589 (void *)&cmd_set_vxlan_ip_dst,
15590 (void *)&cmd_set_vxlan_ip_dst_value,
15591 (void *)&cmd_set_vxlan_eth_src,
15592 (void *)&cmd_set_vxlan_eth_src_value,
15593 (void *)&cmd_set_vxlan_eth_dst,
15594 (void *)&cmd_set_vxlan_eth_dst_value,
15599 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15600 .f = cmd_set_vxlan_parsed,
15602 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15603 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15604 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15607 (void *)&cmd_set_vxlan_set,
15608 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15609 (void *)&cmd_set_vxlan_ip_version,
15610 (void *)&cmd_set_vxlan_ip_version_value,
15611 (void *)&cmd_set_vxlan_vni,
15612 (void *)&cmd_set_vxlan_vni_value,
15613 (void *)&cmd_set_vxlan_udp_src,
15614 (void *)&cmd_set_vxlan_udp_src_value,
15615 (void *)&cmd_set_vxlan_udp_dst,
15616 (void *)&cmd_set_vxlan_udp_dst_value,
15617 (void *)&cmd_set_vxlan_ip_src,
15618 (void *)&cmd_set_vxlan_ip_src_value,
15619 (void *)&cmd_set_vxlan_ip_dst,
15620 (void *)&cmd_set_vxlan_ip_dst_value,
15621 (void *)&cmd_set_vxlan_vlan,
15622 (void *)&cmd_set_vxlan_vlan_value,
15623 (void *)&cmd_set_vxlan_eth_src,
15624 (void *)&cmd_set_vxlan_eth_src_value,
15625 (void *)&cmd_set_vxlan_eth_dst,
15626 (void *)&cmd_set_vxlan_eth_dst_value,
15631 /** Set NVGRE encapsulation details */
15632 struct cmd_set_nvgre_result {
15633 cmdline_fixed_string_t set;
15634 cmdline_fixed_string_t nvgre;
15635 cmdline_fixed_string_t pos_token;
15636 cmdline_fixed_string_t ip_version;
15638 cmdline_ipaddr_t ip_src;
15639 cmdline_ipaddr_t ip_dst;
15641 struct rte_ether_addr eth_src;
15642 struct rte_ether_addr eth_dst;
15645 cmdline_parse_token_string_t cmd_set_nvgre_set =
15646 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15647 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15648 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15649 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15650 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15651 "nvgre-with-vlan");
15652 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15653 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15655 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15656 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15658 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15659 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15661 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15662 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15663 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15664 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15666 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15667 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15668 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15669 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15671 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15672 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15673 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15674 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15676 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15677 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15678 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15679 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15681 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15682 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15683 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15684 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15686 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15687 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15689 static void cmd_set_nvgre_parsed(void *parsed_result,
15690 __rte_unused struct cmdline *cl,
15691 __rte_unused void *data)
15693 struct cmd_set_nvgre_result *res = parsed_result;
15695 uint32_t nvgre_tni;
15698 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15701 if (strcmp(res->nvgre, "nvgre") == 0)
15702 nvgre_encap_conf.select_vlan = 0;
15703 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15704 nvgre_encap_conf.select_vlan = 1;
15705 if (strcmp(res->ip_version, "ipv4") == 0)
15706 nvgre_encap_conf.select_ipv4 = 1;
15707 else if (strcmp(res->ip_version, "ipv6") == 0)
15708 nvgre_encap_conf.select_ipv4 = 0;
15711 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15712 if (nvgre_encap_conf.select_ipv4) {
15713 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15714 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15716 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15717 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15719 if (nvgre_encap_conf.select_vlan)
15720 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15721 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15722 RTE_ETHER_ADDR_LEN);
15723 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15724 RTE_ETHER_ADDR_LEN);
15727 cmdline_parse_inst_t cmd_set_nvgre = {
15728 .f = cmd_set_nvgre_parsed,
15730 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15731 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15732 " eth-dst <eth-dst>",
15734 (void *)&cmd_set_nvgre_set,
15735 (void *)&cmd_set_nvgre_nvgre,
15736 (void *)&cmd_set_nvgre_ip_version,
15737 (void *)&cmd_set_nvgre_ip_version_value,
15738 (void *)&cmd_set_nvgre_tni,
15739 (void *)&cmd_set_nvgre_tni_value,
15740 (void *)&cmd_set_nvgre_ip_src,
15741 (void *)&cmd_set_nvgre_ip_src_value,
15742 (void *)&cmd_set_nvgre_ip_dst,
15743 (void *)&cmd_set_nvgre_ip_dst_value,
15744 (void *)&cmd_set_nvgre_eth_src,
15745 (void *)&cmd_set_nvgre_eth_src_value,
15746 (void *)&cmd_set_nvgre_eth_dst,
15747 (void *)&cmd_set_nvgre_eth_dst_value,
15752 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15753 .f = cmd_set_nvgre_parsed,
15755 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15756 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15757 " eth-src <eth-src> eth-dst <eth-dst>",
15759 (void *)&cmd_set_nvgre_set,
15760 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15761 (void *)&cmd_set_nvgre_ip_version,
15762 (void *)&cmd_set_nvgre_ip_version_value,
15763 (void *)&cmd_set_nvgre_tni,
15764 (void *)&cmd_set_nvgre_tni_value,
15765 (void *)&cmd_set_nvgre_ip_src,
15766 (void *)&cmd_set_nvgre_ip_src_value,
15767 (void *)&cmd_set_nvgre_ip_dst,
15768 (void *)&cmd_set_nvgre_ip_dst_value,
15769 (void *)&cmd_set_nvgre_vlan,
15770 (void *)&cmd_set_nvgre_vlan_value,
15771 (void *)&cmd_set_nvgre_eth_src,
15772 (void *)&cmd_set_nvgre_eth_src_value,
15773 (void *)&cmd_set_nvgre_eth_dst,
15774 (void *)&cmd_set_nvgre_eth_dst_value,
15779 /** Set L2 encapsulation details */
15780 struct cmd_set_l2_encap_result {
15781 cmdline_fixed_string_t set;
15782 cmdline_fixed_string_t l2_encap;
15783 cmdline_fixed_string_t pos_token;
15784 cmdline_fixed_string_t ip_version;
15785 uint32_t vlan_present:1;
15787 struct rte_ether_addr eth_src;
15788 struct rte_ether_addr eth_dst;
15791 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15792 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15793 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15794 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15795 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15796 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15797 "l2_encap-with-vlan");
15798 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15799 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15801 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15802 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15804 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15805 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15807 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15808 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15809 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15810 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15812 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15813 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15814 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15815 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15817 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15818 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15820 static void cmd_set_l2_encap_parsed(void *parsed_result,
15821 __rte_unused struct cmdline *cl,
15822 __rte_unused void *data)
15824 struct cmd_set_l2_encap_result *res = parsed_result;
15826 if (strcmp(res->l2_encap, "l2_encap") == 0)
15827 l2_encap_conf.select_vlan = 0;
15828 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15829 l2_encap_conf.select_vlan = 1;
15830 if (strcmp(res->ip_version, "ipv4") == 0)
15831 l2_encap_conf.select_ipv4 = 1;
15832 else if (strcmp(res->ip_version, "ipv6") == 0)
15833 l2_encap_conf.select_ipv4 = 0;
15836 if (l2_encap_conf.select_vlan)
15837 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15838 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15839 RTE_ETHER_ADDR_LEN);
15840 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15841 RTE_ETHER_ADDR_LEN);
15844 cmdline_parse_inst_t cmd_set_l2_encap = {
15845 .f = cmd_set_l2_encap_parsed,
15847 .help_str = "set l2_encap ip-version ipv4|ipv6"
15848 " eth-src <eth-src> eth-dst <eth-dst>",
15850 (void *)&cmd_set_l2_encap_set,
15851 (void *)&cmd_set_l2_encap_l2_encap,
15852 (void *)&cmd_set_l2_encap_ip_version,
15853 (void *)&cmd_set_l2_encap_ip_version_value,
15854 (void *)&cmd_set_l2_encap_eth_src,
15855 (void *)&cmd_set_l2_encap_eth_src_value,
15856 (void *)&cmd_set_l2_encap_eth_dst,
15857 (void *)&cmd_set_l2_encap_eth_dst_value,
15862 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15863 .f = cmd_set_l2_encap_parsed,
15865 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15866 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15868 (void *)&cmd_set_l2_encap_set,
15869 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15870 (void *)&cmd_set_l2_encap_ip_version,
15871 (void *)&cmd_set_l2_encap_ip_version_value,
15872 (void *)&cmd_set_l2_encap_vlan,
15873 (void *)&cmd_set_l2_encap_vlan_value,
15874 (void *)&cmd_set_l2_encap_eth_src,
15875 (void *)&cmd_set_l2_encap_eth_src_value,
15876 (void *)&cmd_set_l2_encap_eth_dst,
15877 (void *)&cmd_set_l2_encap_eth_dst_value,
15882 /** Set L2 decapsulation details */
15883 struct cmd_set_l2_decap_result {
15884 cmdline_fixed_string_t set;
15885 cmdline_fixed_string_t l2_decap;
15886 cmdline_fixed_string_t pos_token;
15887 uint32_t vlan_present:1;
15890 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15891 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15892 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15893 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15895 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15896 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15897 "l2_decap-with-vlan");
15899 static void cmd_set_l2_decap_parsed(void *parsed_result,
15900 __rte_unused struct cmdline *cl,
15901 __rte_unused void *data)
15903 struct cmd_set_l2_decap_result *res = parsed_result;
15905 if (strcmp(res->l2_decap, "l2_decap") == 0)
15906 l2_decap_conf.select_vlan = 0;
15907 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15908 l2_decap_conf.select_vlan = 1;
15911 cmdline_parse_inst_t cmd_set_l2_decap = {
15912 .f = cmd_set_l2_decap_parsed,
15914 .help_str = "set l2_decap",
15916 (void *)&cmd_set_l2_decap_set,
15917 (void *)&cmd_set_l2_decap_l2_decap,
15922 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15923 .f = cmd_set_l2_decap_parsed,
15925 .help_str = "set l2_decap-with-vlan",
15927 (void *)&cmd_set_l2_decap_set,
15928 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15933 /** Set MPLSoGRE encapsulation details */
15934 struct cmd_set_mplsogre_encap_result {
15935 cmdline_fixed_string_t set;
15936 cmdline_fixed_string_t mplsogre;
15937 cmdline_fixed_string_t pos_token;
15938 cmdline_fixed_string_t ip_version;
15939 uint32_t vlan_present:1;
15941 cmdline_ipaddr_t ip_src;
15942 cmdline_ipaddr_t ip_dst;
15944 struct rte_ether_addr eth_src;
15945 struct rte_ether_addr eth_dst;
15948 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15949 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15951 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15952 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15954 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15955 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15956 mplsogre, "mplsogre_encap-with-vlan");
15957 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15958 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15959 pos_token, "ip-version");
15960 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15961 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15962 ip_version, "ipv4#ipv6");
15963 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15964 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15965 pos_token, "label");
15966 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15967 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15969 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15970 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15971 pos_token, "ip-src");
15972 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15973 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15974 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15975 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15976 pos_token, "ip-dst");
15977 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15978 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15979 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15980 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15981 pos_token, "vlan-tci");
15982 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15983 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15985 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15986 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15987 pos_token, "eth-src");
15988 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15989 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15991 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15992 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15993 pos_token, "eth-dst");
15994 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15995 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15998 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15999 __rte_unused struct cmdline *cl,
16000 __rte_unused void *data)
16002 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16004 uint32_t mplsogre_label;
16007 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16010 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16011 mplsogre_encap_conf.select_vlan = 0;
16012 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16013 mplsogre_encap_conf.select_vlan = 1;
16014 if (strcmp(res->ip_version, "ipv4") == 0)
16015 mplsogre_encap_conf.select_ipv4 = 1;
16016 else if (strcmp(res->ip_version, "ipv6") == 0)
16017 mplsogre_encap_conf.select_ipv4 = 0;
16020 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16021 if (mplsogre_encap_conf.select_ipv4) {
16022 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16023 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16025 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16026 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16028 if (mplsogre_encap_conf.select_vlan)
16029 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16030 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16031 RTE_ETHER_ADDR_LEN);
16032 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16033 RTE_ETHER_ADDR_LEN);
16036 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16037 .f = cmd_set_mplsogre_encap_parsed,
16039 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16040 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16041 " eth-dst <eth-dst>",
16043 (void *)&cmd_set_mplsogre_encap_set,
16044 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16045 (void *)&cmd_set_mplsogre_encap_ip_version,
16046 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16047 (void *)&cmd_set_mplsogre_encap_label,
16048 (void *)&cmd_set_mplsogre_encap_label_value,
16049 (void *)&cmd_set_mplsogre_encap_ip_src,
16050 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16051 (void *)&cmd_set_mplsogre_encap_ip_dst,
16052 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16053 (void *)&cmd_set_mplsogre_encap_eth_src,
16054 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16055 (void *)&cmd_set_mplsogre_encap_eth_dst,
16056 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16061 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16062 .f = cmd_set_mplsogre_encap_parsed,
16064 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16065 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16066 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16068 (void *)&cmd_set_mplsogre_encap_set,
16069 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16070 (void *)&cmd_set_mplsogre_encap_ip_version,
16071 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16072 (void *)&cmd_set_mplsogre_encap_label,
16073 (void *)&cmd_set_mplsogre_encap_label_value,
16074 (void *)&cmd_set_mplsogre_encap_ip_src,
16075 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16076 (void *)&cmd_set_mplsogre_encap_ip_dst,
16077 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16078 (void *)&cmd_set_mplsogre_encap_vlan,
16079 (void *)&cmd_set_mplsogre_encap_vlan_value,
16080 (void *)&cmd_set_mplsogre_encap_eth_src,
16081 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16082 (void *)&cmd_set_mplsogre_encap_eth_dst,
16083 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16088 /** Set MPLSoGRE decapsulation details */
16089 struct cmd_set_mplsogre_decap_result {
16090 cmdline_fixed_string_t set;
16091 cmdline_fixed_string_t mplsogre;
16092 cmdline_fixed_string_t pos_token;
16093 cmdline_fixed_string_t ip_version;
16094 uint32_t vlan_present:1;
16097 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16098 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16100 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16101 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16103 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16104 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16105 mplsogre, "mplsogre_decap-with-vlan");
16106 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16107 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16108 pos_token, "ip-version");
16109 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16110 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16111 ip_version, "ipv4#ipv6");
16113 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16114 __rte_unused struct cmdline *cl,
16115 __rte_unused void *data)
16117 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16119 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16120 mplsogre_decap_conf.select_vlan = 0;
16121 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16122 mplsogre_decap_conf.select_vlan = 1;
16123 if (strcmp(res->ip_version, "ipv4") == 0)
16124 mplsogre_decap_conf.select_ipv4 = 1;
16125 else if (strcmp(res->ip_version, "ipv6") == 0)
16126 mplsogre_decap_conf.select_ipv4 = 0;
16129 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16130 .f = cmd_set_mplsogre_decap_parsed,
16132 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16134 (void *)&cmd_set_mplsogre_decap_set,
16135 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16136 (void *)&cmd_set_mplsogre_decap_ip_version,
16137 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16142 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16143 .f = cmd_set_mplsogre_decap_parsed,
16145 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16147 (void *)&cmd_set_mplsogre_decap_set,
16148 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16149 (void *)&cmd_set_mplsogre_decap_ip_version,
16150 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16155 /** Set MPLSoUDP encapsulation details */
16156 struct cmd_set_mplsoudp_encap_result {
16157 cmdline_fixed_string_t set;
16158 cmdline_fixed_string_t mplsoudp;
16159 cmdline_fixed_string_t pos_token;
16160 cmdline_fixed_string_t ip_version;
16161 uint32_t vlan_present:1;
16165 cmdline_ipaddr_t ip_src;
16166 cmdline_ipaddr_t ip_dst;
16168 struct rte_ether_addr eth_src;
16169 struct rte_ether_addr eth_dst;
16172 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16173 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16175 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16176 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16178 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16179 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16180 mplsoudp, "mplsoudp_encap-with-vlan");
16181 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16182 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16183 pos_token, "ip-version");
16184 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16185 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16186 ip_version, "ipv4#ipv6");
16187 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16188 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16189 pos_token, "label");
16190 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16191 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16193 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16194 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16195 pos_token, "udp-src");
16196 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16197 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16199 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16200 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16201 pos_token, "udp-dst");
16202 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16203 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16205 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16206 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16207 pos_token, "ip-src");
16208 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16209 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16210 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16211 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16212 pos_token, "ip-dst");
16213 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16214 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16215 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16216 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16217 pos_token, "vlan-tci");
16218 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16219 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16221 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16222 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16223 pos_token, "eth-src");
16224 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16225 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16227 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16228 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16229 pos_token, "eth-dst");
16230 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16231 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16234 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16235 __rte_unused struct cmdline *cl,
16236 __rte_unused void *data)
16238 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16240 uint32_t mplsoudp_label;
16243 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16246 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16247 mplsoudp_encap_conf.select_vlan = 0;
16248 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16249 mplsoudp_encap_conf.select_vlan = 1;
16250 if (strcmp(res->ip_version, "ipv4") == 0)
16251 mplsoudp_encap_conf.select_ipv4 = 1;
16252 else if (strcmp(res->ip_version, "ipv6") == 0)
16253 mplsoudp_encap_conf.select_ipv4 = 0;
16256 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16257 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16258 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16259 if (mplsoudp_encap_conf.select_ipv4) {
16260 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16261 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16263 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16264 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16266 if (mplsoudp_encap_conf.select_vlan)
16267 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16268 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16269 RTE_ETHER_ADDR_LEN);
16270 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16271 RTE_ETHER_ADDR_LEN);
16274 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16275 .f = cmd_set_mplsoudp_encap_parsed,
16277 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16278 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16279 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16281 (void *)&cmd_set_mplsoudp_encap_set,
16282 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16283 (void *)&cmd_set_mplsoudp_encap_ip_version,
16284 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16285 (void *)&cmd_set_mplsoudp_encap_label,
16286 (void *)&cmd_set_mplsoudp_encap_label_value,
16287 (void *)&cmd_set_mplsoudp_encap_udp_src,
16288 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16289 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16290 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16291 (void *)&cmd_set_mplsoudp_encap_ip_src,
16292 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16293 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16294 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16295 (void *)&cmd_set_mplsoudp_encap_eth_src,
16296 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16297 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16298 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16303 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16304 .f = cmd_set_mplsoudp_encap_parsed,
16306 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16307 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16308 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16309 " eth-src <eth-src> eth-dst <eth-dst>",
16311 (void *)&cmd_set_mplsoudp_encap_set,
16312 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16313 (void *)&cmd_set_mplsoudp_encap_ip_version,
16314 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16315 (void *)&cmd_set_mplsoudp_encap_label,
16316 (void *)&cmd_set_mplsoudp_encap_label_value,
16317 (void *)&cmd_set_mplsoudp_encap_udp_src,
16318 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16319 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16320 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16321 (void *)&cmd_set_mplsoudp_encap_ip_src,
16322 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16323 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16324 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16325 (void *)&cmd_set_mplsoudp_encap_vlan,
16326 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16327 (void *)&cmd_set_mplsoudp_encap_eth_src,
16328 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16329 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16330 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16335 /** Set MPLSoUDP decapsulation details */
16336 struct cmd_set_mplsoudp_decap_result {
16337 cmdline_fixed_string_t set;
16338 cmdline_fixed_string_t mplsoudp;
16339 cmdline_fixed_string_t pos_token;
16340 cmdline_fixed_string_t ip_version;
16341 uint32_t vlan_present:1;
16344 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16345 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16347 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16348 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16350 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16351 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16352 mplsoudp, "mplsoudp_decap-with-vlan");
16353 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16354 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16355 pos_token, "ip-version");
16356 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16357 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16358 ip_version, "ipv4#ipv6");
16360 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16361 __rte_unused struct cmdline *cl,
16362 __rte_unused void *data)
16364 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16366 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16367 mplsoudp_decap_conf.select_vlan = 0;
16368 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16369 mplsoudp_decap_conf.select_vlan = 1;
16370 if (strcmp(res->ip_version, "ipv4") == 0)
16371 mplsoudp_decap_conf.select_ipv4 = 1;
16372 else if (strcmp(res->ip_version, "ipv6") == 0)
16373 mplsoudp_decap_conf.select_ipv4 = 0;
16376 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16377 .f = cmd_set_mplsoudp_decap_parsed,
16379 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16381 (void *)&cmd_set_mplsoudp_decap_set,
16382 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16383 (void *)&cmd_set_mplsoudp_decap_ip_version,
16384 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16389 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16390 .f = cmd_set_mplsoudp_decap_parsed,
16392 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16394 (void *)&cmd_set_mplsoudp_decap_set,
16395 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16396 (void *)&cmd_set_mplsoudp_decap_ip_version,
16397 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16402 /* Strict link priority scheduling mode setting */
16404 cmd_strict_link_prio_parsed(
16405 void *parsed_result,
16406 __rte_unused struct cmdline *cl,
16407 __rte_unused void *data)
16409 struct cmd_vf_tc_bw_result *res = parsed_result;
16410 int ret = -ENOTSUP;
16412 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16415 #ifdef RTE_LIBRTE_I40E_PMD
16416 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16423 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16426 printf("invalid port_id %d\n", res->port_id);
16429 printf("function not implemented\n");
16432 printf("programming error: (%s)\n", strerror(-ret));
16436 cmdline_parse_inst_t cmd_strict_link_prio = {
16437 .f = cmd_strict_link_prio_parsed,
16439 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16441 (void *)&cmd_vf_tc_bw_set,
16442 (void *)&cmd_vf_tc_bw_tx,
16443 (void *)&cmd_vf_tc_bw_strict_link_prio,
16444 (void *)&cmd_vf_tc_bw_port_id,
16445 (void *)&cmd_vf_tc_bw_tc_map,
16450 /* Load dynamic device personalization*/
16451 struct cmd_ddp_add_result {
16452 cmdline_fixed_string_t ddp;
16453 cmdline_fixed_string_t add;
16458 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16459 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16460 cmdline_parse_token_string_t cmd_ddp_add_add =
16461 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16462 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16463 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16464 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16465 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16468 cmd_ddp_add_parsed(
16469 void *parsed_result,
16470 __rte_unused struct cmdline *cl,
16471 __rte_unused void *data)
16473 struct cmd_ddp_add_result *res = parsed_result;
16479 int ret = -ENOTSUP;
16481 if (!all_ports_stopped()) {
16482 printf("Please stop all ports first\n");
16486 filepath = strdup(res->filepath);
16487 if (filepath == NULL) {
16488 printf("Failed to allocate memory\n");
16491 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16493 buff = open_file(file_fld[0], &size);
16495 free((void *)filepath);
16499 #ifdef RTE_LIBRTE_I40E_PMD
16500 if (ret == -ENOTSUP)
16501 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16503 RTE_PMD_I40E_PKG_OP_WR_ADD);
16506 if (ret == -EEXIST)
16507 printf("Profile has already existed.\n");
16509 printf("Failed to load profile.\n");
16510 else if (file_num == 2)
16511 save_file(file_fld[1], buff, size);
16514 free((void *)filepath);
16517 cmdline_parse_inst_t cmd_ddp_add = {
16518 .f = cmd_ddp_add_parsed,
16520 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16522 (void *)&cmd_ddp_add_ddp,
16523 (void *)&cmd_ddp_add_add,
16524 (void *)&cmd_ddp_add_port_id,
16525 (void *)&cmd_ddp_add_filepath,
16530 /* Delete dynamic device personalization*/
16531 struct cmd_ddp_del_result {
16532 cmdline_fixed_string_t ddp;
16533 cmdline_fixed_string_t del;
16538 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16539 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16540 cmdline_parse_token_string_t cmd_ddp_del_del =
16541 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16542 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16543 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16544 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16545 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16548 cmd_ddp_del_parsed(
16549 void *parsed_result,
16550 __rte_unused struct cmdline *cl,
16551 __rte_unused void *data)
16553 struct cmd_ddp_del_result *res = parsed_result;
16556 int ret = -ENOTSUP;
16558 if (!all_ports_stopped()) {
16559 printf("Please stop all ports first\n");
16563 buff = open_file(res->filepath, &size);
16567 #ifdef RTE_LIBRTE_I40E_PMD
16568 if (ret == -ENOTSUP)
16569 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16571 RTE_PMD_I40E_PKG_OP_WR_DEL);
16574 if (ret == -EACCES)
16575 printf("Profile does not exist.\n");
16577 printf("Failed to delete profile.\n");
16582 cmdline_parse_inst_t cmd_ddp_del = {
16583 .f = cmd_ddp_del_parsed,
16585 .help_str = "ddp del <port_id> <backup_profile_path>",
16587 (void *)&cmd_ddp_del_ddp,
16588 (void *)&cmd_ddp_del_del,
16589 (void *)&cmd_ddp_del_port_id,
16590 (void *)&cmd_ddp_del_filepath,
16595 /* Get dynamic device personalization profile info */
16596 struct cmd_ddp_info_result {
16597 cmdline_fixed_string_t ddp;
16598 cmdline_fixed_string_t get;
16599 cmdline_fixed_string_t info;
16603 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16604 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16605 cmdline_parse_token_string_t cmd_ddp_info_get =
16606 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16607 cmdline_parse_token_string_t cmd_ddp_info_info =
16608 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16609 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16610 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16613 cmd_ddp_info_parsed(
16614 void *parsed_result,
16615 __rte_unused struct cmdline *cl,
16616 __rte_unused void *data)
16618 struct cmd_ddp_info_result *res = parsed_result;
16621 int ret = -ENOTSUP;
16622 #ifdef RTE_LIBRTE_I40E_PMD
16625 uint32_t buff_size = 0;
16626 struct rte_pmd_i40e_profile_info info;
16627 uint32_t dev_num = 0;
16628 struct rte_pmd_i40e_ddp_device_id *devs;
16629 uint32_t proto_num = 0;
16630 struct rte_pmd_i40e_proto_info *proto = NULL;
16631 uint32_t pctype_num = 0;
16632 struct rte_pmd_i40e_ptype_info *pctype;
16633 uint32_t ptype_num = 0;
16634 struct rte_pmd_i40e_ptype_info *ptype;
16639 pkg = open_file(res->filepath, &pkg_size);
16643 #ifdef RTE_LIBRTE_I40E_PMD
16644 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16645 (uint8_t *)&info, sizeof(info),
16646 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16648 printf("Global Track id: 0x%x\n", info.track_id);
16649 printf("Global Version: %d.%d.%d.%d\n",
16650 info.version.major,
16651 info.version.minor,
16652 info.version.update,
16653 info.version.draft);
16654 printf("Global Package name: %s\n\n", info.name);
16657 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16658 (uint8_t *)&info, sizeof(info),
16659 RTE_PMD_I40E_PKG_INFO_HEADER);
16661 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16662 printf("i40e Profile Version: %d.%d.%d.%d\n",
16663 info.version.major,
16664 info.version.minor,
16665 info.version.update,
16666 info.version.draft);
16667 printf("i40e Profile name: %s\n\n", info.name);
16670 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16671 (uint8_t *)&buff_size, sizeof(buff_size),
16672 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16673 if (!ret && buff_size) {
16674 buff = (uint8_t *)malloc(buff_size);
16676 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16678 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16680 printf("Package Notes:\n%s\n\n", buff);
16685 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16686 (uint8_t *)&dev_num, sizeof(dev_num),
16687 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16688 if (!ret && dev_num) {
16689 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16690 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16692 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16693 (uint8_t *)devs, buff_size,
16694 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16696 printf("List of supported devices:\n");
16697 for (i = 0; i < dev_num; i++) {
16698 printf(" %04X:%04X %04X:%04X\n",
16699 devs[i].vendor_dev_id >> 16,
16700 devs[i].vendor_dev_id & 0xFFFF,
16701 devs[i].sub_vendor_dev_id >> 16,
16702 devs[i].sub_vendor_dev_id & 0xFFFF);
16710 /* get information about protocols and packet types */
16711 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16712 (uint8_t *)&proto_num, sizeof(proto_num),
16713 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16714 if (ret || !proto_num)
16715 goto no_print_return;
16717 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16718 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16720 goto no_print_return;
16722 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16724 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16726 printf("List of used protocols:\n");
16727 for (i = 0; i < proto_num; i++)
16728 printf(" %2u: %s\n", proto[i].proto_id,
16732 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16733 (uint8_t *)&pctype_num, sizeof(pctype_num),
16734 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16735 if (ret || !pctype_num)
16736 goto no_print_pctypes;
16738 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16739 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16741 goto no_print_pctypes;
16743 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16745 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16748 goto no_print_pctypes;
16751 printf("List of defined packet classification types:\n");
16752 for (i = 0; i < pctype_num; i++) {
16753 printf(" %2u:", pctype[i].ptype_id);
16754 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16755 proto_id = pctype[i].protocols[j];
16756 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16757 for (n = 0; n < proto_num; n++) {
16758 if (proto[n].proto_id == proto_id) {
16759 printf(" %s", proto[n].name);
16772 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16774 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16775 if (ret || !ptype_num)
16776 goto no_print_return;
16778 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16779 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16781 goto no_print_return;
16783 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16785 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16788 goto no_print_return;
16790 printf("List of defined packet types:\n");
16791 for (i = 0; i < ptype_num; i++) {
16792 printf(" %2u:", ptype[i].ptype_id);
16793 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16794 proto_id = ptype[i].protocols[j];
16795 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16796 for (n = 0; n < proto_num; n++) {
16797 if (proto[n].proto_id == proto_id) {
16798 printf(" %s", proto[n].name);
16814 if (ret == -ENOTSUP)
16815 printf("Function not supported in PMD driver\n");
16819 cmdline_parse_inst_t cmd_ddp_get_info = {
16820 .f = cmd_ddp_info_parsed,
16822 .help_str = "ddp get info <profile_path>",
16824 (void *)&cmd_ddp_info_ddp,
16825 (void *)&cmd_ddp_info_get,
16826 (void *)&cmd_ddp_info_info,
16827 (void *)&cmd_ddp_info_filepath,
16832 /* Get dynamic device personalization profile info list*/
16833 #define PROFILE_INFO_SIZE 48
16834 #define MAX_PROFILE_NUM 16
16836 struct cmd_ddp_get_list_result {
16837 cmdline_fixed_string_t ddp;
16838 cmdline_fixed_string_t get;
16839 cmdline_fixed_string_t list;
16843 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16844 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16845 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16846 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16847 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16848 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16849 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16850 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16853 cmd_ddp_get_list_parsed(
16854 __rte_unused void *parsed_result,
16855 __rte_unused struct cmdline *cl,
16856 __rte_unused void *data)
16858 #ifdef RTE_LIBRTE_I40E_PMD
16859 struct cmd_ddp_get_list_result *res = parsed_result;
16860 struct rte_pmd_i40e_profile_list *p_list;
16861 struct rte_pmd_i40e_profile_info *p_info;
16866 int ret = -ENOTSUP;
16868 #ifdef RTE_LIBRTE_I40E_PMD
16869 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16870 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16872 printf("%s: Failed to malloc buffer\n", __func__);
16874 if (ret == -ENOTSUP)
16875 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16876 (uint8_t *)p_list, size);
16879 p_num = p_list->p_count;
16880 printf("Profile number is: %d\n\n", p_num);
16882 for (i = 0; i < p_num; i++) {
16883 p_info = &p_list->p_info[i];
16884 printf("Profile %d:\n", i);
16885 printf("Track id: 0x%x\n", p_info->track_id);
16886 printf("Version: %d.%d.%d.%d\n",
16887 p_info->version.major,
16888 p_info->version.minor,
16889 p_info->version.update,
16890 p_info->version.draft);
16891 printf("Profile name: %s\n\n", p_info->name);
16899 printf("Failed to get ddp list\n");
16902 cmdline_parse_inst_t cmd_ddp_get_list = {
16903 .f = cmd_ddp_get_list_parsed,
16905 .help_str = "ddp get list <port_id>",
16907 (void *)&cmd_ddp_get_list_ddp,
16908 (void *)&cmd_ddp_get_list_get,
16909 (void *)&cmd_ddp_get_list_list,
16910 (void *)&cmd_ddp_get_list_port_id,
16915 /* Configure input set */
16916 struct cmd_cfg_input_set_result {
16917 cmdline_fixed_string_t port;
16918 cmdline_fixed_string_t cfg;
16920 cmdline_fixed_string_t pctype;
16922 cmdline_fixed_string_t inset_type;
16923 cmdline_fixed_string_t opt;
16924 cmdline_fixed_string_t field;
16929 cmd_cfg_input_set_parsed(
16930 __rte_unused void *parsed_result,
16931 __rte_unused struct cmdline *cl,
16932 __rte_unused void *data)
16934 #ifdef RTE_LIBRTE_I40E_PMD
16935 struct cmd_cfg_input_set_result *res = parsed_result;
16936 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16937 struct rte_pmd_i40e_inset inset;
16939 int ret = -ENOTSUP;
16941 if (!all_ports_stopped()) {
16942 printf("Please stop all ports first\n");
16946 #ifdef RTE_LIBRTE_I40E_PMD
16947 if (!strcmp(res->inset_type, "hash_inset"))
16948 inset_type = INSET_HASH;
16949 else if (!strcmp(res->inset_type, "fdir_inset"))
16950 inset_type = INSET_FDIR;
16951 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16952 inset_type = INSET_FDIR_FLX;
16953 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16954 &inset, inset_type);
16956 printf("Failed to get input set.\n");
16960 if (!strcmp(res->opt, "get")) {
16961 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16964 printf("Field index %d is enabled.\n", res->field_idx);
16966 printf("Field index %d is disabled.\n", res->field_idx);
16968 } else if (!strcmp(res->opt, "set"))
16969 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16971 else if (!strcmp(res->opt, "clear"))
16972 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16975 printf("Failed to configure input set field.\n");
16979 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16980 &inset, inset_type);
16982 printf("Failed to set input set.\n");
16987 if (ret == -ENOTSUP)
16988 printf("Function not supported\n");
16991 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16992 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16994 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16995 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16997 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16998 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17000 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17001 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17003 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17004 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17006 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17007 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17009 "hash_inset#fdir_inset#fdir_flx_inset");
17010 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17011 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17012 opt, "get#set#clear");
17013 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17014 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17016 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17017 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17020 cmdline_parse_inst_t cmd_cfg_input_set = {
17021 .f = cmd_cfg_input_set_parsed,
17023 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17024 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17026 (void *)&cmd_cfg_input_set_port,
17027 (void *)&cmd_cfg_input_set_cfg,
17028 (void *)&cmd_cfg_input_set_port_id,
17029 (void *)&cmd_cfg_input_set_pctype,
17030 (void *)&cmd_cfg_input_set_pctype_id,
17031 (void *)&cmd_cfg_input_set_inset_type,
17032 (void *)&cmd_cfg_input_set_opt,
17033 (void *)&cmd_cfg_input_set_field,
17034 (void *)&cmd_cfg_input_set_field_idx,
17039 /* Clear input set */
17040 struct cmd_clear_input_set_result {
17041 cmdline_fixed_string_t port;
17042 cmdline_fixed_string_t cfg;
17044 cmdline_fixed_string_t pctype;
17046 cmdline_fixed_string_t inset_type;
17047 cmdline_fixed_string_t clear;
17048 cmdline_fixed_string_t all;
17052 cmd_clear_input_set_parsed(
17053 __rte_unused void *parsed_result,
17054 __rte_unused struct cmdline *cl,
17055 __rte_unused void *data)
17057 #ifdef RTE_LIBRTE_I40E_PMD
17058 struct cmd_clear_input_set_result *res = parsed_result;
17059 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17060 struct rte_pmd_i40e_inset inset;
17062 int ret = -ENOTSUP;
17064 if (!all_ports_stopped()) {
17065 printf("Please stop all ports first\n");
17069 #ifdef RTE_LIBRTE_I40E_PMD
17070 if (!strcmp(res->inset_type, "hash_inset"))
17071 inset_type = INSET_HASH;
17072 else if (!strcmp(res->inset_type, "fdir_inset"))
17073 inset_type = INSET_FDIR;
17074 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17075 inset_type = INSET_FDIR_FLX;
17077 memset(&inset, 0, sizeof(inset));
17079 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17080 &inset, inset_type);
17082 printf("Failed to clear input set.\n");
17088 if (ret == -ENOTSUP)
17089 printf("Function not supported\n");
17092 cmdline_parse_token_string_t cmd_clear_input_set_port =
17093 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17095 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17096 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17098 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17099 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17101 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17102 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17104 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17105 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17107 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17108 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17110 "hash_inset#fdir_inset#fdir_flx_inset");
17111 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17112 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17114 cmdline_parse_token_string_t cmd_clear_input_set_all =
17115 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17118 cmdline_parse_inst_t cmd_clear_input_set = {
17119 .f = cmd_clear_input_set_parsed,
17121 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17122 "fdir_inset|fdir_flx_inset clear all",
17124 (void *)&cmd_clear_input_set_port,
17125 (void *)&cmd_clear_input_set_cfg,
17126 (void *)&cmd_clear_input_set_port_id,
17127 (void *)&cmd_clear_input_set_pctype,
17128 (void *)&cmd_clear_input_set_pctype_id,
17129 (void *)&cmd_clear_input_set_inset_type,
17130 (void *)&cmd_clear_input_set_clear,
17131 (void *)&cmd_clear_input_set_all,
17136 /* show vf stats */
17138 /* Common result structure for show vf stats */
17139 struct cmd_show_vf_stats_result {
17140 cmdline_fixed_string_t show;
17141 cmdline_fixed_string_t vf;
17142 cmdline_fixed_string_t stats;
17147 /* Common CLI fields show vf stats*/
17148 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17149 TOKEN_STRING_INITIALIZER
17150 (struct cmd_show_vf_stats_result,
17152 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17153 TOKEN_STRING_INITIALIZER
17154 (struct cmd_show_vf_stats_result,
17156 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17157 TOKEN_STRING_INITIALIZER
17158 (struct cmd_show_vf_stats_result,
17160 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17161 TOKEN_NUM_INITIALIZER
17162 (struct cmd_show_vf_stats_result,
17164 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17165 TOKEN_NUM_INITIALIZER
17166 (struct cmd_show_vf_stats_result,
17170 cmd_show_vf_stats_parsed(
17171 void *parsed_result,
17172 __rte_unused struct cmdline *cl,
17173 __rte_unused void *data)
17175 struct cmd_show_vf_stats_result *res = parsed_result;
17176 struct rte_eth_stats stats;
17177 int ret = -ENOTSUP;
17178 static const char *nic_stats_border = "########################";
17180 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17183 memset(&stats, 0, sizeof(stats));
17185 #ifdef RTE_LIBRTE_I40E_PMD
17186 if (ret == -ENOTSUP)
17187 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17191 #ifdef RTE_LIBRTE_BNXT_PMD
17192 if (ret == -ENOTSUP)
17193 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17202 printf("invalid vf_id %d\n", res->vf_id);
17205 printf("invalid port_id %d\n", res->port_id);
17208 printf("function not implemented\n");
17211 printf("programming error: (%s)\n", strerror(-ret));
17214 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17215 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17217 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17219 stats.ipackets, stats.imissed, stats.ibytes);
17220 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17221 printf(" RX-nombuf: %-10"PRIu64"\n",
17223 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17225 stats.opackets, stats.oerrors, stats.obytes);
17227 printf(" %s############################%s\n",
17228 nic_stats_border, nic_stats_border);
17231 cmdline_parse_inst_t cmd_show_vf_stats = {
17232 .f = cmd_show_vf_stats_parsed,
17234 .help_str = "show vf stats <port_id> <vf_id>",
17236 (void *)&cmd_show_vf_stats_show,
17237 (void *)&cmd_show_vf_stats_vf,
17238 (void *)&cmd_show_vf_stats_stats,
17239 (void *)&cmd_show_vf_stats_port_id,
17240 (void *)&cmd_show_vf_stats_vf_id,
17245 /* clear vf stats */
17247 /* Common result structure for clear vf stats */
17248 struct cmd_clear_vf_stats_result {
17249 cmdline_fixed_string_t clear;
17250 cmdline_fixed_string_t vf;
17251 cmdline_fixed_string_t stats;
17256 /* Common CLI fields clear vf stats*/
17257 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17258 TOKEN_STRING_INITIALIZER
17259 (struct cmd_clear_vf_stats_result,
17261 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17262 TOKEN_STRING_INITIALIZER
17263 (struct cmd_clear_vf_stats_result,
17265 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17266 TOKEN_STRING_INITIALIZER
17267 (struct cmd_clear_vf_stats_result,
17269 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17270 TOKEN_NUM_INITIALIZER
17271 (struct cmd_clear_vf_stats_result,
17273 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17274 TOKEN_NUM_INITIALIZER
17275 (struct cmd_clear_vf_stats_result,
17279 cmd_clear_vf_stats_parsed(
17280 void *parsed_result,
17281 __rte_unused struct cmdline *cl,
17282 __rte_unused void *data)
17284 struct cmd_clear_vf_stats_result *res = parsed_result;
17285 int ret = -ENOTSUP;
17287 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17290 #ifdef RTE_LIBRTE_I40E_PMD
17291 if (ret == -ENOTSUP)
17292 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17295 #ifdef RTE_LIBRTE_BNXT_PMD
17296 if (ret == -ENOTSUP)
17297 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17305 printf("invalid vf_id %d\n", res->vf_id);
17308 printf("invalid port_id %d\n", res->port_id);
17311 printf("function not implemented\n");
17314 printf("programming error: (%s)\n", strerror(-ret));
17318 cmdline_parse_inst_t cmd_clear_vf_stats = {
17319 .f = cmd_clear_vf_stats_parsed,
17321 .help_str = "clear vf stats <port_id> <vf_id>",
17323 (void *)&cmd_clear_vf_stats_clear,
17324 (void *)&cmd_clear_vf_stats_vf,
17325 (void *)&cmd_clear_vf_stats_stats,
17326 (void *)&cmd_clear_vf_stats_port_id,
17327 (void *)&cmd_clear_vf_stats_vf_id,
17332 /* port config pctype mapping reset */
17334 /* Common result structure for port config pctype mapping reset */
17335 struct cmd_pctype_mapping_reset_result {
17336 cmdline_fixed_string_t port;
17337 cmdline_fixed_string_t config;
17339 cmdline_fixed_string_t pctype;
17340 cmdline_fixed_string_t mapping;
17341 cmdline_fixed_string_t reset;
17344 /* Common CLI fields for port config pctype mapping reset*/
17345 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17346 TOKEN_STRING_INITIALIZER
17347 (struct cmd_pctype_mapping_reset_result,
17349 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17350 TOKEN_STRING_INITIALIZER
17351 (struct cmd_pctype_mapping_reset_result,
17353 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17354 TOKEN_NUM_INITIALIZER
17355 (struct cmd_pctype_mapping_reset_result,
17357 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17358 TOKEN_STRING_INITIALIZER
17359 (struct cmd_pctype_mapping_reset_result,
17361 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17362 TOKEN_STRING_INITIALIZER
17363 (struct cmd_pctype_mapping_reset_result,
17364 mapping, "mapping");
17365 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17366 TOKEN_STRING_INITIALIZER
17367 (struct cmd_pctype_mapping_reset_result,
17371 cmd_pctype_mapping_reset_parsed(
17372 void *parsed_result,
17373 __rte_unused struct cmdline *cl,
17374 __rte_unused void *data)
17376 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17377 int ret = -ENOTSUP;
17379 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17382 #ifdef RTE_LIBRTE_I40E_PMD
17383 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17390 printf("invalid port_id %d\n", res->port_id);
17393 printf("function not implemented\n");
17396 printf("programming error: (%s)\n", strerror(-ret));
17400 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17401 .f = cmd_pctype_mapping_reset_parsed,
17403 .help_str = "port config <port_id> pctype mapping reset",
17405 (void *)&cmd_pctype_mapping_reset_port,
17406 (void *)&cmd_pctype_mapping_reset_config,
17407 (void *)&cmd_pctype_mapping_reset_port_id,
17408 (void *)&cmd_pctype_mapping_reset_pctype,
17409 (void *)&cmd_pctype_mapping_reset_mapping,
17410 (void *)&cmd_pctype_mapping_reset_reset,
17415 /* show port pctype mapping */
17417 /* Common result structure for show port pctype mapping */
17418 struct cmd_pctype_mapping_get_result {
17419 cmdline_fixed_string_t show;
17420 cmdline_fixed_string_t port;
17422 cmdline_fixed_string_t pctype;
17423 cmdline_fixed_string_t mapping;
17426 /* Common CLI fields for pctype mapping get */
17427 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17428 TOKEN_STRING_INITIALIZER
17429 (struct cmd_pctype_mapping_get_result,
17431 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17432 TOKEN_STRING_INITIALIZER
17433 (struct cmd_pctype_mapping_get_result,
17435 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17436 TOKEN_NUM_INITIALIZER
17437 (struct cmd_pctype_mapping_get_result,
17439 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17440 TOKEN_STRING_INITIALIZER
17441 (struct cmd_pctype_mapping_get_result,
17443 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17444 TOKEN_STRING_INITIALIZER
17445 (struct cmd_pctype_mapping_get_result,
17446 mapping, "mapping");
17449 cmd_pctype_mapping_get_parsed(
17450 void *parsed_result,
17451 __rte_unused struct cmdline *cl,
17452 __rte_unused void *data)
17454 struct cmd_pctype_mapping_get_result *res = parsed_result;
17455 int ret = -ENOTSUP;
17456 #ifdef RTE_LIBRTE_I40E_PMD
17457 struct rte_pmd_i40e_flow_type_mapping
17458 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17459 int i, j, first_pctype;
17462 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17465 #ifdef RTE_LIBRTE_I40E_PMD
17466 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17473 printf("invalid port_id %d\n", res->port_id);
17476 printf("function not implemented\n");
17479 printf("programming error: (%s)\n", strerror(-ret));
17483 #ifdef RTE_LIBRTE_I40E_PMD
17484 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17485 if (mapping[i].pctype != 0ULL) {
17488 printf("pctype: ");
17489 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17490 if (mapping[i].pctype & (1ULL << j)) {
17491 printf(first_pctype ?
17492 "%02d" : ",%02d", j);
17496 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17502 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17503 .f = cmd_pctype_mapping_get_parsed,
17505 .help_str = "show port <port_id> pctype mapping",
17507 (void *)&cmd_pctype_mapping_get_show,
17508 (void *)&cmd_pctype_mapping_get_port,
17509 (void *)&cmd_pctype_mapping_get_port_id,
17510 (void *)&cmd_pctype_mapping_get_pctype,
17511 (void *)&cmd_pctype_mapping_get_mapping,
17516 /* port config pctype mapping update */
17518 /* Common result structure for port config pctype mapping update */
17519 struct cmd_pctype_mapping_update_result {
17520 cmdline_fixed_string_t port;
17521 cmdline_fixed_string_t config;
17523 cmdline_fixed_string_t pctype;
17524 cmdline_fixed_string_t mapping;
17525 cmdline_fixed_string_t update;
17526 cmdline_fixed_string_t pctype_list;
17527 uint16_t flow_type;
17530 /* Common CLI fields for pctype mapping update*/
17531 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17532 TOKEN_STRING_INITIALIZER
17533 (struct cmd_pctype_mapping_update_result,
17535 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17536 TOKEN_STRING_INITIALIZER
17537 (struct cmd_pctype_mapping_update_result,
17539 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17540 TOKEN_NUM_INITIALIZER
17541 (struct cmd_pctype_mapping_update_result,
17543 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17544 TOKEN_STRING_INITIALIZER
17545 (struct cmd_pctype_mapping_update_result,
17547 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17548 TOKEN_STRING_INITIALIZER
17549 (struct cmd_pctype_mapping_update_result,
17550 mapping, "mapping");
17551 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17552 TOKEN_STRING_INITIALIZER
17553 (struct cmd_pctype_mapping_update_result,
17555 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17556 TOKEN_STRING_INITIALIZER
17557 (struct cmd_pctype_mapping_update_result,
17558 pctype_list, NULL);
17559 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17560 TOKEN_NUM_INITIALIZER
17561 (struct cmd_pctype_mapping_update_result,
17562 flow_type, UINT16);
17565 cmd_pctype_mapping_update_parsed(
17566 void *parsed_result,
17567 __rte_unused struct cmdline *cl,
17568 __rte_unused void *data)
17570 struct cmd_pctype_mapping_update_result *res = parsed_result;
17571 int ret = -ENOTSUP;
17572 #ifdef RTE_LIBRTE_I40E_PMD
17573 struct rte_pmd_i40e_flow_type_mapping mapping;
17575 unsigned int nb_item;
17576 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17579 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17582 #ifdef RTE_LIBRTE_I40E_PMD
17583 nb_item = parse_item_list(res->pctype_list, "pctypes",
17584 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17585 mapping.flow_type = res->flow_type;
17586 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17587 mapping.pctype |= (1ULL << pctype_list[i]);
17588 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17598 printf("invalid pctype or flow type\n");
17601 printf("invalid port_id %d\n", res->port_id);
17604 printf("function not implemented\n");
17607 printf("programming error: (%s)\n", strerror(-ret));
17611 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17612 .f = cmd_pctype_mapping_update_parsed,
17614 .help_str = "port config <port_id> pctype mapping update"
17615 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17617 (void *)&cmd_pctype_mapping_update_port,
17618 (void *)&cmd_pctype_mapping_update_config,
17619 (void *)&cmd_pctype_mapping_update_port_id,
17620 (void *)&cmd_pctype_mapping_update_pctype,
17621 (void *)&cmd_pctype_mapping_update_mapping,
17622 (void *)&cmd_pctype_mapping_update_update,
17623 (void *)&cmd_pctype_mapping_update_pc_type,
17624 (void *)&cmd_pctype_mapping_update_flow_type,
17629 /* ptype mapping get */
17631 /* Common result structure for ptype mapping get */
17632 struct cmd_ptype_mapping_get_result {
17633 cmdline_fixed_string_t ptype;
17634 cmdline_fixed_string_t mapping;
17635 cmdline_fixed_string_t get;
17637 uint8_t valid_only;
17640 /* Common CLI fields for ptype mapping get */
17641 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17642 TOKEN_STRING_INITIALIZER
17643 (struct cmd_ptype_mapping_get_result,
17645 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17646 TOKEN_STRING_INITIALIZER
17647 (struct cmd_ptype_mapping_get_result,
17648 mapping, "mapping");
17649 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17650 TOKEN_STRING_INITIALIZER
17651 (struct cmd_ptype_mapping_get_result,
17653 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17654 TOKEN_NUM_INITIALIZER
17655 (struct cmd_ptype_mapping_get_result,
17657 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17658 TOKEN_NUM_INITIALIZER
17659 (struct cmd_ptype_mapping_get_result,
17660 valid_only, UINT8);
17663 cmd_ptype_mapping_get_parsed(
17664 void *parsed_result,
17665 __rte_unused struct cmdline *cl,
17666 __rte_unused void *data)
17668 struct cmd_ptype_mapping_get_result *res = parsed_result;
17669 int ret = -ENOTSUP;
17670 #ifdef RTE_LIBRTE_I40E_PMD
17671 int max_ptype_num = 256;
17672 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17677 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17680 #ifdef RTE_LIBRTE_I40E_PMD
17681 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17692 printf("invalid port_id %d\n", res->port_id);
17695 printf("function not implemented\n");
17698 printf("programming error: (%s)\n", strerror(-ret));
17701 #ifdef RTE_LIBRTE_I40E_PMD
17703 for (i = 0; i < count; i++)
17704 printf("%3d\t0x%08x\n",
17705 mapping[i].hw_ptype, mapping[i].sw_ptype);
17710 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17711 .f = cmd_ptype_mapping_get_parsed,
17713 .help_str = "ptype mapping get <port_id> <valid_only>",
17715 (void *)&cmd_ptype_mapping_get_ptype,
17716 (void *)&cmd_ptype_mapping_get_mapping,
17717 (void *)&cmd_ptype_mapping_get_get,
17718 (void *)&cmd_ptype_mapping_get_port_id,
17719 (void *)&cmd_ptype_mapping_get_valid_only,
17724 /* ptype mapping replace */
17726 /* Common result structure for ptype mapping replace */
17727 struct cmd_ptype_mapping_replace_result {
17728 cmdline_fixed_string_t ptype;
17729 cmdline_fixed_string_t mapping;
17730 cmdline_fixed_string_t replace;
17737 /* Common CLI fields for ptype mapping replace */
17738 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17739 TOKEN_STRING_INITIALIZER
17740 (struct cmd_ptype_mapping_replace_result,
17742 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17743 TOKEN_STRING_INITIALIZER
17744 (struct cmd_ptype_mapping_replace_result,
17745 mapping, "mapping");
17746 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17747 TOKEN_STRING_INITIALIZER
17748 (struct cmd_ptype_mapping_replace_result,
17749 replace, "replace");
17750 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17751 TOKEN_NUM_INITIALIZER
17752 (struct cmd_ptype_mapping_replace_result,
17754 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17755 TOKEN_NUM_INITIALIZER
17756 (struct cmd_ptype_mapping_replace_result,
17758 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17759 TOKEN_NUM_INITIALIZER
17760 (struct cmd_ptype_mapping_replace_result,
17762 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17763 TOKEN_NUM_INITIALIZER
17764 (struct cmd_ptype_mapping_replace_result,
17768 cmd_ptype_mapping_replace_parsed(
17769 void *parsed_result,
17770 __rte_unused struct cmdline *cl,
17771 __rte_unused void *data)
17773 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17774 int ret = -ENOTSUP;
17776 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17779 #ifdef RTE_LIBRTE_I40E_PMD
17780 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17790 printf("invalid ptype 0x%8x or 0x%8x\n",
17791 res->target, res->pkt_type);
17794 printf("invalid port_id %d\n", res->port_id);
17797 printf("function not implemented\n");
17800 printf("programming error: (%s)\n", strerror(-ret));
17804 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17805 .f = cmd_ptype_mapping_replace_parsed,
17808 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17810 (void *)&cmd_ptype_mapping_replace_ptype,
17811 (void *)&cmd_ptype_mapping_replace_mapping,
17812 (void *)&cmd_ptype_mapping_replace_replace,
17813 (void *)&cmd_ptype_mapping_replace_port_id,
17814 (void *)&cmd_ptype_mapping_replace_target,
17815 (void *)&cmd_ptype_mapping_replace_mask,
17816 (void *)&cmd_ptype_mapping_replace_pkt_type,
17821 /* ptype mapping reset */
17823 /* Common result structure for ptype mapping reset */
17824 struct cmd_ptype_mapping_reset_result {
17825 cmdline_fixed_string_t ptype;
17826 cmdline_fixed_string_t mapping;
17827 cmdline_fixed_string_t reset;
17831 /* Common CLI fields for ptype mapping reset*/
17832 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17833 TOKEN_STRING_INITIALIZER
17834 (struct cmd_ptype_mapping_reset_result,
17836 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17837 TOKEN_STRING_INITIALIZER
17838 (struct cmd_ptype_mapping_reset_result,
17839 mapping, "mapping");
17840 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17841 TOKEN_STRING_INITIALIZER
17842 (struct cmd_ptype_mapping_reset_result,
17844 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17845 TOKEN_NUM_INITIALIZER
17846 (struct cmd_ptype_mapping_reset_result,
17850 cmd_ptype_mapping_reset_parsed(
17851 void *parsed_result,
17852 __rte_unused struct cmdline *cl,
17853 __rte_unused void *data)
17855 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17856 int ret = -ENOTSUP;
17858 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17861 #ifdef RTE_LIBRTE_I40E_PMD
17862 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17869 printf("invalid port_id %d\n", res->port_id);
17872 printf("function not implemented\n");
17875 printf("programming error: (%s)\n", strerror(-ret));
17879 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17880 .f = cmd_ptype_mapping_reset_parsed,
17882 .help_str = "ptype mapping reset <port_id>",
17884 (void *)&cmd_ptype_mapping_reset_ptype,
17885 (void *)&cmd_ptype_mapping_reset_mapping,
17886 (void *)&cmd_ptype_mapping_reset_reset,
17887 (void *)&cmd_ptype_mapping_reset_port_id,
17892 /* ptype mapping update */
17894 /* Common result structure for ptype mapping update */
17895 struct cmd_ptype_mapping_update_result {
17896 cmdline_fixed_string_t ptype;
17897 cmdline_fixed_string_t mapping;
17898 cmdline_fixed_string_t reset;
17904 /* Common CLI fields for ptype mapping update*/
17905 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17906 TOKEN_STRING_INITIALIZER
17907 (struct cmd_ptype_mapping_update_result,
17909 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17910 TOKEN_STRING_INITIALIZER
17911 (struct cmd_ptype_mapping_update_result,
17912 mapping, "mapping");
17913 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17914 TOKEN_STRING_INITIALIZER
17915 (struct cmd_ptype_mapping_update_result,
17917 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17918 TOKEN_NUM_INITIALIZER
17919 (struct cmd_ptype_mapping_update_result,
17921 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17922 TOKEN_NUM_INITIALIZER
17923 (struct cmd_ptype_mapping_update_result,
17925 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17926 TOKEN_NUM_INITIALIZER
17927 (struct cmd_ptype_mapping_update_result,
17931 cmd_ptype_mapping_update_parsed(
17932 void *parsed_result,
17933 __rte_unused struct cmdline *cl,
17934 __rte_unused void *data)
17936 struct cmd_ptype_mapping_update_result *res = parsed_result;
17937 int ret = -ENOTSUP;
17938 #ifdef RTE_LIBRTE_I40E_PMD
17939 struct rte_pmd_i40e_ptype_mapping mapping;
17941 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17944 #ifdef RTE_LIBRTE_I40E_PMD
17945 mapping.hw_ptype = res->hw_ptype;
17946 mapping.sw_ptype = res->sw_ptype;
17947 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17957 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17960 printf("invalid port_id %d\n", res->port_id);
17963 printf("function not implemented\n");
17966 printf("programming error: (%s)\n", strerror(-ret));
17970 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17971 .f = cmd_ptype_mapping_update_parsed,
17973 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17975 (void *)&cmd_ptype_mapping_update_ptype,
17976 (void *)&cmd_ptype_mapping_update_mapping,
17977 (void *)&cmd_ptype_mapping_update_update,
17978 (void *)&cmd_ptype_mapping_update_port_id,
17979 (void *)&cmd_ptype_mapping_update_hw_ptype,
17980 (void *)&cmd_ptype_mapping_update_sw_ptype,
17985 /* Common result structure for file commands */
17986 struct cmd_cmdfile_result {
17987 cmdline_fixed_string_t load;
17988 cmdline_fixed_string_t filename;
17991 /* Common CLI fields for file commands */
17992 cmdline_parse_token_string_t cmd_load_cmdfile =
17993 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17994 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17995 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17998 cmd_load_from_file_parsed(
17999 void *parsed_result,
18000 __rte_unused struct cmdline *cl,
18001 __rte_unused void *data)
18003 struct cmd_cmdfile_result *res = parsed_result;
18005 cmdline_read_from_file(res->filename);
18008 cmdline_parse_inst_t cmd_load_from_file = {
18009 .f = cmd_load_from_file_parsed,
18011 .help_str = "load <filename>",
18013 (void *)&cmd_load_cmdfile,
18014 (void *)&cmd_load_cmdfile_filename,
18019 /* Get Rx offloads capabilities */
18020 struct cmd_rx_offload_get_capa_result {
18021 cmdline_fixed_string_t show;
18022 cmdline_fixed_string_t port;
18024 cmdline_fixed_string_t rx_offload;
18025 cmdline_fixed_string_t capabilities;
18028 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18029 TOKEN_STRING_INITIALIZER
18030 (struct cmd_rx_offload_get_capa_result,
18032 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18033 TOKEN_STRING_INITIALIZER
18034 (struct cmd_rx_offload_get_capa_result,
18036 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18037 TOKEN_NUM_INITIALIZER
18038 (struct cmd_rx_offload_get_capa_result,
18040 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18041 TOKEN_STRING_INITIALIZER
18042 (struct cmd_rx_offload_get_capa_result,
18043 rx_offload, "rx_offload");
18044 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18045 TOKEN_STRING_INITIALIZER
18046 (struct cmd_rx_offload_get_capa_result,
18047 capabilities, "capabilities");
18050 print_rx_offloads(uint64_t offloads)
18052 uint64_t single_offload;
18060 begin = __builtin_ctzll(offloads);
18061 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18063 single_offload = 1ULL << begin;
18064 for (bit = begin; bit < end; bit++) {
18065 if (offloads & single_offload)
18067 rte_eth_dev_rx_offload_name(single_offload));
18068 single_offload <<= 1;
18073 cmd_rx_offload_get_capa_parsed(
18074 void *parsed_result,
18075 __rte_unused struct cmdline *cl,
18076 __rte_unused void *data)
18078 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18079 struct rte_eth_dev_info dev_info;
18080 portid_t port_id = res->port_id;
18081 uint64_t queue_offloads;
18082 uint64_t port_offloads;
18085 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18089 queue_offloads = dev_info.rx_queue_offload_capa;
18090 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18092 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18093 printf(" Per Queue :");
18094 print_rx_offloads(queue_offloads);
18097 printf(" Per Port :");
18098 print_rx_offloads(port_offloads);
18102 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18103 .f = cmd_rx_offload_get_capa_parsed,
18105 .help_str = "show port <port_id> rx_offload capabilities",
18107 (void *)&cmd_rx_offload_get_capa_show,
18108 (void *)&cmd_rx_offload_get_capa_port,
18109 (void *)&cmd_rx_offload_get_capa_port_id,
18110 (void *)&cmd_rx_offload_get_capa_rx_offload,
18111 (void *)&cmd_rx_offload_get_capa_capabilities,
18116 /* Get Rx offloads configuration */
18117 struct cmd_rx_offload_get_configuration_result {
18118 cmdline_fixed_string_t show;
18119 cmdline_fixed_string_t port;
18121 cmdline_fixed_string_t rx_offload;
18122 cmdline_fixed_string_t configuration;
18125 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18126 TOKEN_STRING_INITIALIZER
18127 (struct cmd_rx_offload_get_configuration_result,
18129 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18130 TOKEN_STRING_INITIALIZER
18131 (struct cmd_rx_offload_get_configuration_result,
18133 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18134 TOKEN_NUM_INITIALIZER
18135 (struct cmd_rx_offload_get_configuration_result,
18137 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18138 TOKEN_STRING_INITIALIZER
18139 (struct cmd_rx_offload_get_configuration_result,
18140 rx_offload, "rx_offload");
18141 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18142 TOKEN_STRING_INITIALIZER
18143 (struct cmd_rx_offload_get_configuration_result,
18144 configuration, "configuration");
18147 cmd_rx_offload_get_configuration_parsed(
18148 void *parsed_result,
18149 __rte_unused struct cmdline *cl,
18150 __rte_unused void *data)
18152 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18153 struct rte_eth_dev_info dev_info;
18154 portid_t port_id = res->port_id;
18155 struct rte_port *port = &ports[port_id];
18156 uint64_t port_offloads;
18157 uint64_t queue_offloads;
18158 uint16_t nb_rx_queues;
18162 printf("Rx Offloading Configuration of port %d :\n", port_id);
18164 port_offloads = port->dev_conf.rxmode.offloads;
18166 print_rx_offloads(port_offloads);
18169 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18173 nb_rx_queues = dev_info.nb_rx_queues;
18174 for (q = 0; q < nb_rx_queues; q++) {
18175 queue_offloads = port->rx_conf[q].offloads;
18176 printf(" Queue[%2d] :", q);
18177 print_rx_offloads(queue_offloads);
18183 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18184 .f = cmd_rx_offload_get_configuration_parsed,
18186 .help_str = "show port <port_id> rx_offload configuration",
18188 (void *)&cmd_rx_offload_get_configuration_show,
18189 (void *)&cmd_rx_offload_get_configuration_port,
18190 (void *)&cmd_rx_offload_get_configuration_port_id,
18191 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18192 (void *)&cmd_rx_offload_get_configuration_configuration,
18197 /* Enable/Disable a per port offloading */
18198 struct cmd_config_per_port_rx_offload_result {
18199 cmdline_fixed_string_t port;
18200 cmdline_fixed_string_t config;
18202 cmdline_fixed_string_t rx_offload;
18203 cmdline_fixed_string_t offload;
18204 cmdline_fixed_string_t on_off;
18207 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18208 TOKEN_STRING_INITIALIZER
18209 (struct cmd_config_per_port_rx_offload_result,
18211 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18212 TOKEN_STRING_INITIALIZER
18213 (struct cmd_config_per_port_rx_offload_result,
18215 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18216 TOKEN_NUM_INITIALIZER
18217 (struct cmd_config_per_port_rx_offload_result,
18219 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18220 TOKEN_STRING_INITIALIZER
18221 (struct cmd_config_per_port_rx_offload_result,
18222 rx_offload, "rx_offload");
18223 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18224 TOKEN_STRING_INITIALIZER
18225 (struct cmd_config_per_port_rx_offload_result,
18226 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18227 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18228 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18229 "scatter#timestamp#security#keep_crc#rss_hash");
18230 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18231 TOKEN_STRING_INITIALIZER
18232 (struct cmd_config_per_port_rx_offload_result,
18236 search_rx_offload(const char *name)
18238 uint64_t single_offload;
18239 const char *single_name;
18243 single_offload = 1;
18244 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18245 single_name = rte_eth_dev_rx_offload_name(single_offload);
18246 if (!strcasecmp(single_name, name)) {
18250 single_offload <<= 1;
18254 return single_offload;
18260 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18261 __rte_unused struct cmdline *cl,
18262 __rte_unused void *data)
18264 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18265 portid_t port_id = res->port_id;
18266 struct rte_eth_dev_info dev_info;
18267 struct rte_port *port = &ports[port_id];
18268 uint64_t single_offload;
18269 uint16_t nb_rx_queues;
18273 if (port->port_status != RTE_PORT_STOPPED) {
18274 printf("Error: Can't config offload when Port %d "
18275 "is not stopped\n", port_id);
18279 single_offload = search_rx_offload(res->offload);
18280 if (single_offload == 0) {
18281 printf("Unknown offload name: %s\n", res->offload);
18285 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18289 nb_rx_queues = dev_info.nb_rx_queues;
18290 if (!strcmp(res->on_off, "on")) {
18291 port->dev_conf.rxmode.offloads |= single_offload;
18292 for (q = 0; q < nb_rx_queues; q++)
18293 port->rx_conf[q].offloads |= single_offload;
18295 port->dev_conf.rxmode.offloads &= ~single_offload;
18296 for (q = 0; q < nb_rx_queues; q++)
18297 port->rx_conf[q].offloads &= ~single_offload;
18300 cmd_reconfig_device_queue(port_id, 1, 1);
18303 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18304 .f = cmd_config_per_port_rx_offload_parsed,
18306 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18307 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18308 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18309 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18312 (void *)&cmd_config_per_port_rx_offload_result_port,
18313 (void *)&cmd_config_per_port_rx_offload_result_config,
18314 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18315 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18316 (void *)&cmd_config_per_port_rx_offload_result_offload,
18317 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18322 /* Enable/Disable a per queue offloading */
18323 struct cmd_config_per_queue_rx_offload_result {
18324 cmdline_fixed_string_t port;
18326 cmdline_fixed_string_t rxq;
18328 cmdline_fixed_string_t rx_offload;
18329 cmdline_fixed_string_t offload;
18330 cmdline_fixed_string_t on_off;
18333 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18334 TOKEN_STRING_INITIALIZER
18335 (struct cmd_config_per_queue_rx_offload_result,
18337 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18338 TOKEN_NUM_INITIALIZER
18339 (struct cmd_config_per_queue_rx_offload_result,
18341 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18342 TOKEN_STRING_INITIALIZER
18343 (struct cmd_config_per_queue_rx_offload_result,
18345 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18346 TOKEN_NUM_INITIALIZER
18347 (struct cmd_config_per_queue_rx_offload_result,
18349 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18350 TOKEN_STRING_INITIALIZER
18351 (struct cmd_config_per_queue_rx_offload_result,
18352 rx_offload, "rx_offload");
18353 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18354 TOKEN_STRING_INITIALIZER
18355 (struct cmd_config_per_queue_rx_offload_result,
18356 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18357 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18358 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18359 "scatter#timestamp#security#keep_crc");
18360 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18361 TOKEN_STRING_INITIALIZER
18362 (struct cmd_config_per_queue_rx_offload_result,
18366 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18367 __rte_unused struct cmdline *cl,
18368 __rte_unused void *data)
18370 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18371 struct rte_eth_dev_info dev_info;
18372 portid_t port_id = res->port_id;
18373 uint16_t queue_id = res->queue_id;
18374 struct rte_port *port = &ports[port_id];
18375 uint64_t single_offload;
18378 if (port->port_status != RTE_PORT_STOPPED) {
18379 printf("Error: Can't config offload when Port %d "
18380 "is not stopped\n", port_id);
18384 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18388 if (queue_id >= dev_info.nb_rx_queues) {
18389 printf("Error: input queue_id should be 0 ... "
18390 "%d\n", dev_info.nb_rx_queues - 1);
18394 single_offload = search_rx_offload(res->offload);
18395 if (single_offload == 0) {
18396 printf("Unknown offload name: %s\n", res->offload);
18400 if (!strcmp(res->on_off, "on"))
18401 port->rx_conf[queue_id].offloads |= single_offload;
18403 port->rx_conf[queue_id].offloads &= ~single_offload;
18405 cmd_reconfig_device_queue(port_id, 1, 1);
18408 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18409 .f = cmd_config_per_queue_rx_offload_parsed,
18411 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18412 "vlan_strip|ipv4_cksum|"
18413 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18414 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18415 "jumbo_frame|scatter|timestamp|security|keep_crc "
18418 (void *)&cmd_config_per_queue_rx_offload_result_port,
18419 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18420 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18421 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18422 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18423 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18424 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18429 /* Get Tx offloads capabilities */
18430 struct cmd_tx_offload_get_capa_result {
18431 cmdline_fixed_string_t show;
18432 cmdline_fixed_string_t port;
18434 cmdline_fixed_string_t tx_offload;
18435 cmdline_fixed_string_t capabilities;
18438 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18439 TOKEN_STRING_INITIALIZER
18440 (struct cmd_tx_offload_get_capa_result,
18442 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18443 TOKEN_STRING_INITIALIZER
18444 (struct cmd_tx_offload_get_capa_result,
18446 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18447 TOKEN_NUM_INITIALIZER
18448 (struct cmd_tx_offload_get_capa_result,
18450 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18451 TOKEN_STRING_INITIALIZER
18452 (struct cmd_tx_offload_get_capa_result,
18453 tx_offload, "tx_offload");
18454 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18455 TOKEN_STRING_INITIALIZER
18456 (struct cmd_tx_offload_get_capa_result,
18457 capabilities, "capabilities");
18460 print_tx_offloads(uint64_t offloads)
18462 uint64_t single_offload;
18470 begin = __builtin_ctzll(offloads);
18471 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18473 single_offload = 1ULL << begin;
18474 for (bit = begin; bit < end; bit++) {
18475 if (offloads & single_offload)
18477 rte_eth_dev_tx_offload_name(single_offload));
18478 single_offload <<= 1;
18483 cmd_tx_offload_get_capa_parsed(
18484 void *parsed_result,
18485 __rte_unused struct cmdline *cl,
18486 __rte_unused void *data)
18488 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18489 struct rte_eth_dev_info dev_info;
18490 portid_t port_id = res->port_id;
18491 uint64_t queue_offloads;
18492 uint64_t port_offloads;
18495 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18499 queue_offloads = dev_info.tx_queue_offload_capa;
18500 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18502 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18503 printf(" Per Queue :");
18504 print_tx_offloads(queue_offloads);
18507 printf(" Per Port :");
18508 print_tx_offloads(port_offloads);
18512 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18513 .f = cmd_tx_offload_get_capa_parsed,
18515 .help_str = "show port <port_id> tx_offload capabilities",
18517 (void *)&cmd_tx_offload_get_capa_show,
18518 (void *)&cmd_tx_offload_get_capa_port,
18519 (void *)&cmd_tx_offload_get_capa_port_id,
18520 (void *)&cmd_tx_offload_get_capa_tx_offload,
18521 (void *)&cmd_tx_offload_get_capa_capabilities,
18526 /* Get Tx offloads configuration */
18527 struct cmd_tx_offload_get_configuration_result {
18528 cmdline_fixed_string_t show;
18529 cmdline_fixed_string_t port;
18531 cmdline_fixed_string_t tx_offload;
18532 cmdline_fixed_string_t configuration;
18535 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18536 TOKEN_STRING_INITIALIZER
18537 (struct cmd_tx_offload_get_configuration_result,
18539 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18540 TOKEN_STRING_INITIALIZER
18541 (struct cmd_tx_offload_get_configuration_result,
18543 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18544 TOKEN_NUM_INITIALIZER
18545 (struct cmd_tx_offload_get_configuration_result,
18547 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18548 TOKEN_STRING_INITIALIZER
18549 (struct cmd_tx_offload_get_configuration_result,
18550 tx_offload, "tx_offload");
18551 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18552 TOKEN_STRING_INITIALIZER
18553 (struct cmd_tx_offload_get_configuration_result,
18554 configuration, "configuration");
18557 cmd_tx_offload_get_configuration_parsed(
18558 void *parsed_result,
18559 __rte_unused struct cmdline *cl,
18560 __rte_unused void *data)
18562 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18563 struct rte_eth_dev_info dev_info;
18564 portid_t port_id = res->port_id;
18565 struct rte_port *port = &ports[port_id];
18566 uint64_t port_offloads;
18567 uint64_t queue_offloads;
18568 uint16_t nb_tx_queues;
18572 printf("Tx Offloading Configuration of port %d :\n", port_id);
18574 port_offloads = port->dev_conf.txmode.offloads;
18576 print_tx_offloads(port_offloads);
18579 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18583 nb_tx_queues = dev_info.nb_tx_queues;
18584 for (q = 0; q < nb_tx_queues; q++) {
18585 queue_offloads = port->tx_conf[q].offloads;
18586 printf(" Queue[%2d] :", q);
18587 print_tx_offloads(queue_offloads);
18593 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18594 .f = cmd_tx_offload_get_configuration_parsed,
18596 .help_str = "show port <port_id> tx_offload configuration",
18598 (void *)&cmd_tx_offload_get_configuration_show,
18599 (void *)&cmd_tx_offload_get_configuration_port,
18600 (void *)&cmd_tx_offload_get_configuration_port_id,
18601 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18602 (void *)&cmd_tx_offload_get_configuration_configuration,
18607 /* Enable/Disable a per port offloading */
18608 struct cmd_config_per_port_tx_offload_result {
18609 cmdline_fixed_string_t port;
18610 cmdline_fixed_string_t config;
18612 cmdline_fixed_string_t tx_offload;
18613 cmdline_fixed_string_t offload;
18614 cmdline_fixed_string_t on_off;
18617 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18618 TOKEN_STRING_INITIALIZER
18619 (struct cmd_config_per_port_tx_offload_result,
18621 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18622 TOKEN_STRING_INITIALIZER
18623 (struct cmd_config_per_port_tx_offload_result,
18625 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18626 TOKEN_NUM_INITIALIZER
18627 (struct cmd_config_per_port_tx_offload_result,
18629 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18630 TOKEN_STRING_INITIALIZER
18631 (struct cmd_config_per_port_tx_offload_result,
18632 tx_offload, "tx_offload");
18633 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18634 TOKEN_STRING_INITIALIZER
18635 (struct cmd_config_per_port_tx_offload_result,
18636 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18637 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18638 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18639 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18640 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18641 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18642 TOKEN_STRING_INITIALIZER
18643 (struct cmd_config_per_port_tx_offload_result,
18647 search_tx_offload(const char *name)
18649 uint64_t single_offload;
18650 const char *single_name;
18654 single_offload = 1;
18655 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18656 single_name = rte_eth_dev_tx_offload_name(single_offload);
18657 if (single_name == NULL)
18659 if (!strcasecmp(single_name, name)) {
18662 } else if (!strcasecmp(single_name, "UNKNOWN"))
18664 single_offload <<= 1;
18668 return single_offload;
18674 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18675 __rte_unused struct cmdline *cl,
18676 __rte_unused void *data)
18678 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18679 portid_t port_id = res->port_id;
18680 struct rte_eth_dev_info dev_info;
18681 struct rte_port *port = &ports[port_id];
18682 uint64_t single_offload;
18683 uint16_t nb_tx_queues;
18687 if (port->port_status != RTE_PORT_STOPPED) {
18688 printf("Error: Can't config offload when Port %d "
18689 "is not stopped\n", port_id);
18693 single_offload = search_tx_offload(res->offload);
18694 if (single_offload == 0) {
18695 printf("Unknown offload name: %s\n", res->offload);
18699 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18703 nb_tx_queues = dev_info.nb_tx_queues;
18704 if (!strcmp(res->on_off, "on")) {
18705 port->dev_conf.txmode.offloads |= single_offload;
18706 for (q = 0; q < nb_tx_queues; q++)
18707 port->tx_conf[q].offloads |= single_offload;
18709 port->dev_conf.txmode.offloads &= ~single_offload;
18710 for (q = 0; q < nb_tx_queues; q++)
18711 port->tx_conf[q].offloads &= ~single_offload;
18714 cmd_reconfig_device_queue(port_id, 1, 1);
18717 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18718 .f = cmd_config_per_port_tx_offload_parsed,
18720 .help_str = "port config <port_id> tx_offload "
18721 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18722 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18723 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18724 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18725 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18727 (void *)&cmd_config_per_port_tx_offload_result_port,
18728 (void *)&cmd_config_per_port_tx_offload_result_config,
18729 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18730 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18731 (void *)&cmd_config_per_port_tx_offload_result_offload,
18732 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18737 /* Enable/Disable a per queue offloading */
18738 struct cmd_config_per_queue_tx_offload_result {
18739 cmdline_fixed_string_t port;
18741 cmdline_fixed_string_t txq;
18743 cmdline_fixed_string_t tx_offload;
18744 cmdline_fixed_string_t offload;
18745 cmdline_fixed_string_t on_off;
18748 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18749 TOKEN_STRING_INITIALIZER
18750 (struct cmd_config_per_queue_tx_offload_result,
18752 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18753 TOKEN_NUM_INITIALIZER
18754 (struct cmd_config_per_queue_tx_offload_result,
18756 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18757 TOKEN_STRING_INITIALIZER
18758 (struct cmd_config_per_queue_tx_offload_result,
18760 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18761 TOKEN_NUM_INITIALIZER
18762 (struct cmd_config_per_queue_tx_offload_result,
18764 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18765 TOKEN_STRING_INITIALIZER
18766 (struct cmd_config_per_queue_tx_offload_result,
18767 tx_offload, "tx_offload");
18768 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18769 TOKEN_STRING_INITIALIZER
18770 (struct cmd_config_per_queue_tx_offload_result,
18771 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18772 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18773 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18774 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18775 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18776 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18777 TOKEN_STRING_INITIALIZER
18778 (struct cmd_config_per_queue_tx_offload_result,
18782 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18783 __rte_unused struct cmdline *cl,
18784 __rte_unused void *data)
18786 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18787 struct rte_eth_dev_info dev_info;
18788 portid_t port_id = res->port_id;
18789 uint16_t queue_id = res->queue_id;
18790 struct rte_port *port = &ports[port_id];
18791 uint64_t single_offload;
18794 if (port->port_status != RTE_PORT_STOPPED) {
18795 printf("Error: Can't config offload when Port %d "
18796 "is not stopped\n", port_id);
18800 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18804 if (queue_id >= dev_info.nb_tx_queues) {
18805 printf("Error: input queue_id should be 0 ... "
18806 "%d\n", dev_info.nb_tx_queues - 1);
18810 single_offload = search_tx_offload(res->offload);
18811 if (single_offload == 0) {
18812 printf("Unknown offload name: %s\n", res->offload);
18816 if (!strcmp(res->on_off, "on"))
18817 port->tx_conf[queue_id].offloads |= single_offload;
18819 port->tx_conf[queue_id].offloads &= ~single_offload;
18821 cmd_reconfig_device_queue(port_id, 1, 1);
18824 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18825 .f = cmd_config_per_queue_tx_offload_parsed,
18827 .help_str = "port <port_id> txq <queue_id> tx_offload "
18828 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18829 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18830 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18831 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18832 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18835 (void *)&cmd_config_per_queue_tx_offload_result_port,
18836 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18837 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18838 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18839 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18840 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18841 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18846 /* *** configure tx_metadata for specific port *** */
18847 struct cmd_config_tx_metadata_specific_result {
18848 cmdline_fixed_string_t port;
18849 cmdline_fixed_string_t keyword;
18851 cmdline_fixed_string_t item;
18856 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18857 __rte_unused struct cmdline *cl,
18858 __rte_unused void *data)
18860 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18862 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18864 ports[res->port_id].tx_metadata = res->value;
18865 /* Add/remove callback to insert valid metadata in every Tx packet. */
18866 if (ports[res->port_id].tx_metadata)
18867 add_tx_md_callback(res->port_id);
18869 remove_tx_md_callback(res->port_id);
18870 rte_flow_dynf_metadata_register();
18873 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18874 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18876 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18877 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18878 keyword, "config");
18879 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18880 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18882 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18883 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18884 item, "tx_metadata");
18885 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18886 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18889 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18890 .f = cmd_config_tx_metadata_specific_parsed,
18892 .help_str = "port config <port_id> tx_metadata <value>",
18894 (void *)&cmd_config_tx_metadata_specific_port,
18895 (void *)&cmd_config_tx_metadata_specific_keyword,
18896 (void *)&cmd_config_tx_metadata_specific_id,
18897 (void *)&cmd_config_tx_metadata_specific_item,
18898 (void *)&cmd_config_tx_metadata_specific_value,
18903 /* *** set dynf *** */
18904 struct cmd_config_tx_dynf_specific_result {
18905 cmdline_fixed_string_t port;
18906 cmdline_fixed_string_t keyword;
18908 cmdline_fixed_string_t item;
18909 cmdline_fixed_string_t name;
18910 cmdline_fixed_string_t value;
18914 cmd_config_dynf_specific_parsed(void *parsed_result,
18915 __rte_unused struct cmdline *cl,
18916 __rte_unused void *data)
18918 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18919 struct rte_mbuf_dynflag desc_flag;
18921 uint64_t old_port_flags;
18923 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18925 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18927 if (strlcpy(desc_flag.name, res->name,
18928 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18929 printf("Flag name too long\n");
18932 desc_flag.flags = 0;
18933 flag = rte_mbuf_dynflag_register(&desc_flag);
18935 printf("Can't register flag\n");
18938 strcpy(dynf_names[flag], desc_flag.name);
18940 old_port_flags = ports[res->port_id].mbuf_dynf;
18941 if (!strcmp(res->value, "set")) {
18942 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18943 if (old_port_flags == 0)
18944 add_tx_dynf_callback(res->port_id);
18946 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18947 if (ports[res->port_id].mbuf_dynf == 0)
18948 remove_tx_dynf_callback(res->port_id);
18952 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18953 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18955 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18956 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18957 keyword, "config");
18958 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18959 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18961 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18962 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18964 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18965 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18967 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18968 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18969 value, "set#clear");
18971 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18972 .f = cmd_config_dynf_specific_parsed,
18974 .help_str = "port config <port id> dynf <name> set|clear",
18976 (void *)&cmd_config_tx_dynf_specific_port,
18977 (void *)&cmd_config_tx_dynf_specific_keyword,
18978 (void *)&cmd_config_tx_dynf_specific_port_id,
18979 (void *)&cmd_config_tx_dynf_specific_item,
18980 (void *)&cmd_config_tx_dynf_specific_name,
18981 (void *)&cmd_config_tx_dynf_specific_value,
18986 /* *** display tx_metadata per port configuration *** */
18987 struct cmd_show_tx_metadata_result {
18988 cmdline_fixed_string_t cmd_show;
18989 cmdline_fixed_string_t cmd_port;
18990 cmdline_fixed_string_t cmd_keyword;
18995 cmd_show_tx_metadata_parsed(void *parsed_result,
18996 __rte_unused struct cmdline *cl,
18997 __rte_unused void *data)
18999 struct cmd_show_tx_metadata_result *res = parsed_result;
19001 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19002 printf("invalid port id %u\n", res->cmd_pid);
19005 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19006 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19007 ports[res->cmd_pid].tx_metadata);
19011 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19012 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19014 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19015 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19017 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19018 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19020 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19021 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19022 cmd_keyword, "tx_metadata");
19024 cmdline_parse_inst_t cmd_show_tx_metadata = {
19025 .f = cmd_show_tx_metadata_parsed,
19027 .help_str = "show port <port_id> tx_metadata",
19029 (void *)&cmd_show_tx_metadata_show,
19030 (void *)&cmd_show_tx_metadata_port,
19031 (void *)&cmd_show_tx_metadata_pid,
19032 (void *)&cmd_show_tx_metadata_keyword,
19037 /* show port supported ptypes */
19039 /* Common result structure for show port ptypes */
19040 struct cmd_show_port_supported_ptypes_result {
19041 cmdline_fixed_string_t show;
19042 cmdline_fixed_string_t port;
19044 cmdline_fixed_string_t ptypes;
19047 /* Common CLI fields for show port ptypes */
19048 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19049 TOKEN_STRING_INITIALIZER
19050 (struct cmd_show_port_supported_ptypes_result,
19052 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19053 TOKEN_STRING_INITIALIZER
19054 (struct cmd_show_port_supported_ptypes_result,
19056 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19057 TOKEN_NUM_INITIALIZER
19058 (struct cmd_show_port_supported_ptypes_result,
19060 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19061 TOKEN_STRING_INITIALIZER
19062 (struct cmd_show_port_supported_ptypes_result,
19066 cmd_show_port_supported_ptypes_parsed(
19067 void *parsed_result,
19068 __rte_unused struct cmdline *cl,
19069 __rte_unused void *data)
19071 #define RSVD_PTYPE_MASK 0xf0000000
19072 #define MAX_PTYPES_PER_LAYER 16
19073 #define LTYPE_NAMESIZE 32
19074 #define PTYPE_NAMESIZE 256
19075 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19076 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19077 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19078 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19079 uint16_t port_id = res->port_id;
19082 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19086 while (ptype_mask != RSVD_PTYPE_MASK) {
19088 switch (ptype_mask) {
19089 case RTE_PTYPE_L2_MASK:
19090 strlcpy(ltype, "L2", sizeof(ltype));
19092 case RTE_PTYPE_L3_MASK:
19093 strlcpy(ltype, "L3", sizeof(ltype));
19095 case RTE_PTYPE_L4_MASK:
19096 strlcpy(ltype, "L4", sizeof(ltype));
19098 case RTE_PTYPE_TUNNEL_MASK:
19099 strlcpy(ltype, "Tunnel", sizeof(ltype));
19101 case RTE_PTYPE_INNER_L2_MASK:
19102 strlcpy(ltype, "Inner L2", sizeof(ltype));
19104 case RTE_PTYPE_INNER_L3_MASK:
19105 strlcpy(ltype, "Inner L3", sizeof(ltype));
19107 case RTE_PTYPE_INNER_L4_MASK:
19108 strlcpy(ltype, "Inner L4", sizeof(ltype));
19114 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19115 ptype_mask, ptypes,
19116 MAX_PTYPES_PER_LAYER);
19119 printf("Supported %s ptypes:\n", ltype);
19121 printf("%s ptypes unsupported\n", ltype);
19123 for (i = 0; i < ret; ++i) {
19124 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19125 printf("%s\n", buf);
19132 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19133 .f = cmd_show_port_supported_ptypes_parsed,
19135 .help_str = "show port <port_id> ptypes",
19137 (void *)&cmd_show_port_supported_ptypes_show,
19138 (void *)&cmd_show_port_supported_ptypes_port,
19139 (void *)&cmd_show_port_supported_ptypes_port_id,
19140 (void *)&cmd_show_port_supported_ptypes_ptypes,
19145 /* *** display rx/tx descriptor status *** */
19146 struct cmd_show_rx_tx_desc_status_result {
19147 cmdline_fixed_string_t cmd_show;
19148 cmdline_fixed_string_t cmd_port;
19149 cmdline_fixed_string_t cmd_keyword;
19150 cmdline_fixed_string_t cmd_desc;
19151 cmdline_fixed_string_t cmd_status;
19158 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19159 __rte_unused struct cmdline *cl,
19160 __rte_unused void *data)
19162 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19165 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19166 printf("invalid port id %u\n", res->cmd_pid);
19170 if (!strcmp(res->cmd_keyword, "rxq")) {
19171 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19174 printf("Invalid queueid = %d\n", res->cmd_qid);
19177 if (rc == RTE_ETH_RX_DESC_AVAIL)
19178 printf("Desc status = AVAILABLE\n");
19179 else if (rc == RTE_ETH_RX_DESC_DONE)
19180 printf("Desc status = DONE\n");
19182 printf("Desc status = UNAVAILABLE\n");
19183 } else if (!strcmp(res->cmd_keyword, "txq")) {
19184 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19187 printf("Invalid queueid = %d\n", res->cmd_qid);
19190 if (rc == RTE_ETH_TX_DESC_FULL)
19191 printf("Desc status = FULL\n");
19192 else if (rc == RTE_ETH_TX_DESC_DONE)
19193 printf("Desc status = DONE\n");
19195 printf("Desc status = UNAVAILABLE\n");
19199 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19200 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19202 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19203 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19205 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19206 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19208 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19209 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19210 cmd_keyword, "rxq#txq");
19211 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19212 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19214 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19215 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19217 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19218 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19220 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19221 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19222 cmd_status, "status");
19223 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19224 .f = cmd_show_rx_tx_desc_status_parsed,
19226 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19229 (void *)&cmd_show_rx_tx_desc_status_show,
19230 (void *)&cmd_show_rx_tx_desc_status_port,
19231 (void *)&cmd_show_rx_tx_desc_status_pid,
19232 (void *)&cmd_show_rx_tx_desc_status_keyword,
19233 (void *)&cmd_show_rx_tx_desc_status_qid,
19234 (void *)&cmd_show_rx_tx_desc_status_desc,
19235 (void *)&cmd_show_rx_tx_desc_status_did,
19236 (void *)&cmd_show_rx_tx_desc_status_status,
19241 /* Common result structure for set port ptypes */
19242 struct cmd_set_port_ptypes_result {
19243 cmdline_fixed_string_t set;
19244 cmdline_fixed_string_t port;
19246 cmdline_fixed_string_t ptype_mask;
19250 /* Common CLI fields for set port ptypes */
19251 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19252 TOKEN_STRING_INITIALIZER
19253 (struct cmd_set_port_ptypes_result,
19255 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19256 TOKEN_STRING_INITIALIZER
19257 (struct cmd_set_port_ptypes_result,
19259 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19260 TOKEN_NUM_INITIALIZER
19261 (struct cmd_set_port_ptypes_result,
19263 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19264 TOKEN_STRING_INITIALIZER
19265 (struct cmd_set_port_ptypes_result,
19266 ptype_mask, "ptype_mask");
19267 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19268 TOKEN_NUM_INITIALIZER
19269 (struct cmd_set_port_ptypes_result,
19273 cmd_set_port_ptypes_parsed(
19274 void *parsed_result,
19275 __rte_unused struct cmdline *cl,
19276 __rte_unused void *data)
19278 struct cmd_set_port_ptypes_result *res = parsed_result;
19279 #define PTYPE_NAMESIZE 256
19280 char ptype_name[PTYPE_NAMESIZE];
19281 uint16_t port_id = res->port_id;
19282 uint32_t ptype_mask = res->mask;
19285 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19288 printf("Port %d doesn't support any ptypes.\n", port_id);
19292 uint32_t ptypes[ret];
19294 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19296 printf("Unable to set requested ptypes for Port %d\n", port_id);
19300 printf("Successfully set following ptypes for Port %d\n", port_id);
19301 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19302 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19303 printf("%s\n", ptype_name);
19306 clear_ptypes = false;
19309 cmdline_parse_inst_t cmd_set_port_ptypes = {
19310 .f = cmd_set_port_ptypes_parsed,
19312 .help_str = "set port <port_id> ptype_mask <mask>",
19314 (void *)&cmd_set_port_ptypes_set,
19315 (void *)&cmd_set_port_ptypes_port,
19316 (void *)&cmd_set_port_ptypes_port_id,
19317 (void *)&cmd_set_port_ptypes_mask_str,
19318 (void *)&cmd_set_port_ptypes_mask_u32,
19323 /* *** display mac addresses added to a port *** */
19324 struct cmd_showport_macs_result {
19325 cmdline_fixed_string_t cmd_show;
19326 cmdline_fixed_string_t cmd_port;
19327 cmdline_fixed_string_t cmd_keyword;
19332 cmd_showport_macs_parsed(void *parsed_result,
19333 __rte_unused struct cmdline *cl,
19334 __rte_unused void *data)
19336 struct cmd_showport_macs_result *res = parsed_result;
19338 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19341 if (!strcmp(res->cmd_keyword, "macs"))
19342 show_macs(res->cmd_pid);
19343 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19344 show_mcast_macs(res->cmd_pid);
19347 cmdline_parse_token_string_t cmd_showport_macs_show =
19348 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19350 cmdline_parse_token_string_t cmd_showport_macs_port =
19351 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19353 cmdline_parse_token_num_t cmd_showport_macs_pid =
19354 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19356 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19357 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19358 cmd_keyword, "macs#mcast_macs");
19360 cmdline_parse_inst_t cmd_showport_macs = {
19361 .f = cmd_showport_macs_parsed,
19363 .help_str = "show port <port_id> macs|mcast_macs",
19365 (void *)&cmd_showport_macs_show,
19366 (void *)&cmd_showport_macs_port,
19367 (void *)&cmd_showport_macs_pid,
19368 (void *)&cmd_showport_macs_keyword,
19373 /* ******************************************************************************** */
19375 /* list of instructions */
19376 cmdline_parse_ctx_t main_ctx[] = {
19377 (cmdline_parse_inst_t *)&cmd_help_brief,
19378 (cmdline_parse_inst_t *)&cmd_help_long,
19379 (cmdline_parse_inst_t *)&cmd_quit,
19380 (cmdline_parse_inst_t *)&cmd_load_from_file,
19381 (cmdline_parse_inst_t *)&cmd_showport,
19382 (cmdline_parse_inst_t *)&cmd_showqueue,
19383 (cmdline_parse_inst_t *)&cmd_showportall,
19384 (cmdline_parse_inst_t *)&cmd_showdevice,
19385 (cmdline_parse_inst_t *)&cmd_showcfg,
19386 (cmdline_parse_inst_t *)&cmd_showfwdall,
19387 (cmdline_parse_inst_t *)&cmd_start,
19388 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19389 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19390 (cmdline_parse_inst_t *)&cmd_set_link_up,
19391 (cmdline_parse_inst_t *)&cmd_set_link_down,
19392 (cmdline_parse_inst_t *)&cmd_reset,
19393 (cmdline_parse_inst_t *)&cmd_set_numbers,
19394 (cmdline_parse_inst_t *)&cmd_set_log,
19395 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19396 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19397 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19398 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19399 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19400 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19401 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19402 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19403 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19404 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19405 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19406 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19407 (cmdline_parse_inst_t *)&cmd_set_link_check,
19408 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19409 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19410 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19411 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19412 #ifdef RTE_LIBRTE_PMD_BOND
19413 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19414 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19415 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19416 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19417 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19418 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19419 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19420 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19421 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19422 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19423 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19425 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19426 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19427 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19428 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19429 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19430 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19431 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19432 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19433 (cmdline_parse_inst_t *)&cmd_csum_set,
19434 (cmdline_parse_inst_t *)&cmd_csum_show,
19435 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19436 (cmdline_parse_inst_t *)&cmd_tso_set,
19437 (cmdline_parse_inst_t *)&cmd_tso_show,
19438 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19439 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19440 (cmdline_parse_inst_t *)&cmd_gro_enable,
19441 (cmdline_parse_inst_t *)&cmd_gro_flush,
19442 (cmdline_parse_inst_t *)&cmd_gro_show,
19443 (cmdline_parse_inst_t *)&cmd_gso_enable,
19444 (cmdline_parse_inst_t *)&cmd_gso_size,
19445 (cmdline_parse_inst_t *)&cmd_gso_show,
19446 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19447 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19448 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19449 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19450 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19451 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19452 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19453 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19454 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19455 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19456 (cmdline_parse_inst_t *)&cmd_config_dcb,
19457 (cmdline_parse_inst_t *)&cmd_read_reg,
19458 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19459 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19460 (cmdline_parse_inst_t *)&cmd_write_reg,
19461 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19462 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19463 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19464 (cmdline_parse_inst_t *)&cmd_stop,
19465 (cmdline_parse_inst_t *)&cmd_mac_addr,
19466 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19467 (cmdline_parse_inst_t *)&cmd_set_qmap,
19468 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19469 (cmdline_parse_inst_t *)&cmd_operate_port,
19470 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19471 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19472 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19473 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19474 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19475 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19476 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19477 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19478 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19479 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19480 (cmdline_parse_inst_t *)&cmd_config_mtu,
19481 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19482 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19483 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19484 (cmdline_parse_inst_t *)&cmd_config_rss,
19485 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19486 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19487 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19488 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19489 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19490 (cmdline_parse_inst_t *)&cmd_showport_reta,
19491 (cmdline_parse_inst_t *)&cmd_showport_macs,
19492 (cmdline_parse_inst_t *)&cmd_config_burst,
19493 (cmdline_parse_inst_t *)&cmd_config_thresh,
19494 (cmdline_parse_inst_t *)&cmd_config_threshold,
19495 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19496 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19497 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19498 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19499 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19500 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19501 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19502 (cmdline_parse_inst_t *)&cmd_global_config,
19503 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19504 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19505 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19506 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19507 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19508 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19509 (cmdline_parse_inst_t *)&cmd_dump,
19510 (cmdline_parse_inst_t *)&cmd_dump_one,
19511 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19512 (cmdline_parse_inst_t *)&cmd_syn_filter,
19513 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19514 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19515 (cmdline_parse_inst_t *)&cmd_flex_filter,
19516 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19517 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19518 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19519 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19520 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19521 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19522 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19523 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19524 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19525 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19526 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19527 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19528 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19529 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19530 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19531 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19532 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19533 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19534 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19535 (cmdline_parse_inst_t *)&cmd_flow,
19536 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19537 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19538 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19539 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19540 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19541 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19542 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19543 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19544 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19545 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19546 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19547 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19548 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19549 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19550 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19551 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19552 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19553 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19554 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19555 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19556 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19557 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19558 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19559 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19560 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19561 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19562 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19563 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19564 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19565 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19566 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19567 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19568 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19569 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19570 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19571 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19572 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19573 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19574 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19575 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19576 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19577 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19578 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19579 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19580 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19581 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19582 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19583 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19584 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19585 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19586 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19588 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19589 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19590 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19591 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19592 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19593 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19594 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19595 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19596 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19597 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19598 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19599 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19600 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19601 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19602 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19603 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19604 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19605 (cmdline_parse_inst_t *)&cmd_ddp_add,
19606 (cmdline_parse_inst_t *)&cmd_ddp_del,
19607 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19608 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19609 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19610 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19611 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19612 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19613 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19614 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19615 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19616 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19617 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19618 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19620 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19621 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19622 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19623 (cmdline_parse_inst_t *)&cmd_queue_region,
19624 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19625 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19626 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19627 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19628 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19629 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19630 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19631 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19632 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19633 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19634 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19635 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19636 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19637 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19638 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19639 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19640 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19641 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19642 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19643 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19644 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19645 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19646 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19647 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19648 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19649 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19650 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19651 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19652 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19653 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19654 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19655 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19656 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19657 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19658 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19659 #ifdef RTE_LIBRTE_BPF
19660 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19661 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19663 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19664 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19665 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19666 (cmdline_parse_inst_t *)&cmd_set_raw,
19667 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19668 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19669 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19673 /* read cmdline commands from file */
19675 cmdline_read_from_file(const char *filename)
19677 struct cmdline *cl;
19679 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19681 printf("Failed to create file based cmdline context: %s\n",
19686 cmdline_interact(cl);
19691 printf("Read CLI commands from %s\n", filename);
19694 /* prompt function, called from main on MASTER lcore */
19698 /* initialize non-constant commands */
19699 cmd_set_fwd_mode_init();
19700 cmd_set_fwd_retry_mode_init();
19702 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19703 if (testpmd_cl == NULL)
19705 cmdline_interact(testpmd_cl);
19706 cmdline_stdin_exit(testpmd_cl);
19712 if (testpmd_cl != NULL)
19713 cmdline_quit(testpmd_cl);
19717 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19719 if (id == (portid_t)RTE_PORT_ALL) {
19722 RTE_ETH_FOREACH_DEV(pid) {
19723 /* check if need_reconfig has been set to 1 */
19724 if (ports[pid].need_reconfig == 0)
19725 ports[pid].need_reconfig = dev;
19726 /* check if need_reconfig_queues has been set to 1 */
19727 if (ports[pid].need_reconfig_queues == 0)
19728 ports[pid].need_reconfig_queues = queue;
19730 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19731 /* check if need_reconfig has been set to 1 */
19732 if (ports[id].need_reconfig == 0)
19733 ports[id].need_reconfig = dev;
19734 /* check if need_reconfig_queues has been set to 1 */
19735 if (ports[id].need_reconfig_queues == 0)
19736 ports[id].need_reconfig_queues = queue;